diff --git a/Frontend/_sysElevator.html b/Frontend/_sysElevator.html index 2723e4d..cb12e7c 100644 --- a/Frontend/_sysElevator.html +++ b/Frontend/_sysElevator.html @@ -35,12 +35,12 @@
- - +
+
+
+
-
-
-
@@ -55,8 +56,11 @@ $(document).ready(function () { //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU2JUIwJUI4JUU2JTk4JUE1JUU2JUEzJUE3JUUzJTgwJTkxJUUzJTgwJTkwTUVQJUUzJTgwJTkxVjMubndk'); //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwTUVQJUUzJTgwJTkxLm53Yw');//[TEST].nwd - launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MFRFU1QlRTMlODAlOTEubndk'); + //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MFRFU1QlRTMlODAlOTEubndk'); + launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwTUVQJUUzJTgwJTkxLm53Yw=='); + // + //launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwVEVTVCVFMyU4MCU5MS5ud2Q='); }); function move1Floor() { @@ -74,6 +78,13 @@ setElevatorFloor(2); requestAnimationFrame(movElevator); } + + function changeLightPower() { + var value = document.getElementById('lightBar').value; + console.log("power: " + value); + setLightPower(value); + } + diff --git a/Frontend/index.html b/Frontend/index.html index a51076e..de22389 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -37,7 +37,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li - + - + + - - + - + diff --git a/Frontend/js/forge/forgemodel.js b/Frontend/js/forge/forgemodel.js index 26605f3..1d2ffaf 100644 --- a/Frontend/js/forge/forgemodel.js +++ b/Frontend/js/forge/forgemodel.js @@ -1,62 +1,25 @@ var viewer; -const devices = [ - { - id: "Sensor 1", - position: { - x: -22.779729106182415, - y: 5.431043023608719, - z: 4.553068469137088, - }, - type: "combo", - sensorTypes: ["temperature", "co2"], - dbId: 1, - }, - { - id: "Sensor 2", - position: { - x: 0.20752051811882666, - y: 5.431043023608719, - z: 4.553068469137088, - }, - type: "combo", - sensorTypes: ["temperature", "co2"], - dbId: 2, - }, -]; - -var sensorStyleDefinitions = { - co2: { - url: "https://d2zqnmauvnpnnm.cloudfront.net/assets-1/images/co2.svg", - color: 0xffffff, - }, - temperature: { - url: "https://d2zqnmauvnpnnm.cloudfront.net/assets-1/images/thermometer.svg", - color: 0xffffff, - }, - default: { - url: "https://d2zqnmauvnpnnm.cloudfront.net/assets-1/images/circle.svg", - color: 0xffffff, - }, -}; - // Initialize sensor values -let sensorVals = []; +//let sensorVals = []; let fragProxy; var targetFloorZ; var elevatorSpeed; -for (let i = 0; i < devices.length; i++) { - sensorVals[i] = Math.random(); -} +let bulbLight; +//for (let i = 0; i < devices.length; i++) { +// sensorVals[i] = Math.random(); +//} function launchViewer(urn) { var options = { env: 'AutodeskProduction', - getAccessToken: getForgeToken + getAccessToken: getForgeToken, + language: 'en' }; Autodesk.Viewing.Initializer(options, () => { viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('forgeViewer')); + //viewer = new Autodesk.Viewing.Viewer3D(document.getElementById('forgeViewer'));//這是沒有工具列的 viewer.start(); var documentId = 'urn:' + urn; Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure); @@ -64,26 +27,26 @@ function launchViewer(urn) { //test - for (let i = 0; i < urn.length; i++) { - Autodesk.Viewing.Document.load(urn[i]["urn"], async (doc) => { - let viewables = doc.getRoot().getDefaultGeometry(); - let model = await viewer.loadDocumentNode(doc, viewables, { - preserveView: false, - keepCurrentModels: true, - placementTransform: (new THREE.Matrix4()).setPosition(urn[i]["xform"]), - keepCurrentModels: true, - globalOffset: { - x: 0, - y: 0, - z: 0 - } - }); + //for (let i = 0; i < urn.length; i++) { + // Autodesk.Viewing.Document.load(urn[i]["urn"], async (doc) => { + // let viewables = doc.getRoot().getDefaultGeometry(); + // let model = await viewer.loadDocumentNode(doc, viewables, { + // preserveView: false, + // keepCurrentModels: true, + // placementTransform: (new THREE.Matrix4()).setPosition(urn[i]["xform"]), + // keepCurrentModels: true, + // globalOffset: { + // x: 0, + // y: 0, + // z: 0 + // } + // }); - await viewer.waitForLoadDone(); //!<<< Wait for loading materials, properties and geometries for this model (URN) - }); - } + // await viewer.waitForLoadDone(); //!<<< Wait for loading materials, properties and geometries for this model (URN) + // }); + //} - loadHeatmaps(viewer.getAllModels()[0]); //!<<< equals to viewer.model + //loadHeatmaps(viewer.getAllModels()[0]); //!<<< equals to viewer.model @@ -122,57 +85,65 @@ function onDocumentLoadSuccess(doc) { viewer.loadDocumentNode(doc, viewables).then(i => { // documented loaded, any action? }); - viewer.addEventListener(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, (args) => { - var currSelection = viewer.getSelection(); - var domElem = document.getElementById('id_printer'); - domElem.innerText = currSelection[0]; - }); + //viewer.addEventListener(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, (args) => { + // var currSelection = viewer.getSelection(); + // var domElem = document.getElementById('id_printer'); + // domElem.innerText = currSelection[0]; - viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function () { - var instanceTree = viewer.model.getData().instanceTree; - var allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex); - var domElem = document.getElementById('all_id'); - domElem.innerText = allDbIdsStr; - //allDbIdsStr.map(function (id) { return parseInt(id) }); - //getAllLeafComponents(viewer, function (jsonData) { - // console.log("data: " + jsonData); + // const targetElem = currSelection[0]; + + // const model = viewer.model; + // const instanceTree = model.getData().instanceTree; + // const fragList = model.getFragmentList(); + + // let bounds = new THREE.Box3(); + + // instanceTree.enumNodeFragments(targetElem, (fragId) => { + // let box = new THREE.Box3(); + // fragList.getWorldBounds(fragId, box); + // bounds.union(box); + // }, true); + + // const position = bounds.center(); + // console.log(position) + + //}); + + viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function (data) { + //var viewer = data.target; + //var instanceTree = viewer.model.getData().instanceTree; + //var allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex); + //var domElem = document.getElementById('all_id'); + //domElem.innerText = allDbIdsStr; + + + //let tree = viewer.model.getData().instanceTree; + //let nodeId = 10952; + + //tree.enumNodeFragments(nodeId, function (frag) { + // fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + // console.log("p:" + fragProxy.position); + // fragProxy.getAnimTransform(); + // let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26 + // fragProxy.position = fragPosition; + // fragProxy.updateAnimTransform(); //}); - //var a = getAllDbIds(viewer); - //console.log("a: " + a);//10952 + //viewer.impl.sceneUpdated(true); - let tree = viewer.model.getData().instanceTree; - let nodeId = 10952; + });//, { once: true, } - tree.enumNodeFragments(nodeId, function (frag) { - fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); - fragProxy.getAnimTransform(); - //fragProxy.quaternion = new THREE.Quaternion().setFromAxisAngle( - // new THREE.Vector3(0, 0.3, 0), - // -Math.PI / 2); - //fragProxy.quaternion = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0)); - //fragProxy.quaternion = new THREE.Quaternion().setPosition(new THREE.Vector3(10, 5, 0), 5); - //fragProxy.updateAnimTransform(); - //do some work with fragment proxy + //bulbLight = new THREE.PointLight(0xff0000, 20, 2, 1);//0xffee88 + //bulbLight.position.set(39.33340644836426, 19.965089797973633, 18);//17.880840301513672 + //bulbLight.castShadow = true; + //bulbLight.power = 100;// 110000; + //bulbLight.emissiveIntensity = bulbLight.intensity / Math.pow(0.02, 2.0); + //viewer.scene.add(bulbLight); +} - - //var fragPosition = new THREE.Vector3( - // 10 - fragProxy.offset.x, - // 10 - fragProxy.offset.y, - // 10 - fragProxy.offset.z) - - - let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26 - - fragProxy.position = fragPosition - - fragProxy.updateAnimTransform() - - }); - viewer.impl.sceneUpdated(true); - - }); - - +function setLightPower(value) { + bulbLight.intensity = (value * 10); + viewer.impl.sceneUpdated(true); + //bulbLight.power = value; } function setElevatorFloor(floor) {