[Frontend] 測試設備清單
This commit is contained in:
parent
fac789c635
commit
aab47a13d4
@ -51,6 +51,7 @@
|
|||||||
<canvas id="iot-heatmap-legend" width="300" height="50"></canvas>
|
<canvas id="iot-heatmap-legend" width="300" height="50"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="btn btn-info" onclick="showHeat()">顯示熱圖圖示</button>
|
<button type="button" class="btn btn-info" onclick="showHeat()">顯示熱圖圖示</button>
|
||||||
|
<button type="button" class="btn btn-default" onclick="showList()">顯示設備清單</button>
|
||||||
<!--<input id="lightBar" type="range" min="0" max="100" step="5" onchange="changeLightPower()">亮度-->
|
<!--<input id="lightBar" type="range" min="0" max="100" step="5" onchange="changeLightPower()">亮度-->
|
||||||
<!-- <input type="range">Main Axis</input> -->
|
<!-- <input type="range">Main Axis</input> -->
|
||||||
</div>
|
</div>
|
||||||
@ -244,7 +245,7 @@
|
|||||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1pdHN1YmlzaGkvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU5JUExJUFGXzEyMjgubndk');
|
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1pdHN1YmlzaGkvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU5JUExJUFGXzEyMjgubndk');
|
||||||
|
|
||||||
//12.30 整棟樓 ARC + MEP
|
//12.30 整棟樓 ARC + MEP
|
||||||
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8xMl8zMC5ud2Q');
|
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8xMl8zMC5ud2Q');
|
||||||
|
|
||||||
//12.30 整棟樓 ARC + MEP 半透明
|
//12.30 整棟樓 ARC + MEP 半透明
|
||||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8lRTUlOEQlOEElRTklODAlOEYlRTYlOTglOEUlRTUlQkIlQkElRTclQUYlODlfMTJfMzAubndk');
|
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8lRTUlOEQlOEElRTklODAlOEYlRTYlOTglOEUlRTUlQkIlQkElRTclQUYlODlfMTJfMzAubndk');
|
||||||
@ -254,8 +255,11 @@
|
|||||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwTUVQJUUzJTgwJTkxXzIwMjJfMTJfMTMubndj');//new MEP
|
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwTUVQJUUzJTgwJTkxXzIwMjJfMTJfMTMubndj');//new MEP
|
||||||
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxJUU1JTg1JUE4JUU2JUEzJTlGXzIwMjJfMTJfMTMubndj');//全棟 ARC
|
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwQVJDJUUzJTgwJTkxJUU1JTg1JUE4JUU2JUEzJTlGXzIwMjJfMTJfMTMubndj');//全棟 ARC
|
||||||
|
|
||||||
|
//01.06 加上room_id(樓層有燈具)
|
||||||
|
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDJUU5JTlCJTk5JUU2JUE4JUExJUU1JUJDJThGK01FUCVFNiU4QiU4NiVFNyVCMyVCQiVFNyVCNSVCMV8yMDIzXzAxXzA2Lm53ZA');
|
||||||
|
|
||||||
|
//01.06 樓層刪除燈具
|
||||||
|
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MCVFNSU4RiVCMCVFNSU4QyU5NyVFNCVCOCVBRCVFOCU4RiVCMSVFNSVBNCVBNyVFNiVBOCU5MyVFMyU4MCU5MUFSQyVFOSU5QiU5OSVFNiVBOCVBMSVFNSVCQyU4RitNRVAlRTYlOEIlODYlRTclQjMlQkIlRTclQjUlQjFfJUU1JTg4JUFBJUU3JTg3JTg4JUU1JTg1JUI3XzIwMjNfMDFfMDYubndk');
|
||||||
|
|
||||||
});
|
});
|
||||||
//function move1Floor() {
|
//function move1Floor() {
|
||||||
@ -412,6 +416,10 @@
|
|||||||
createHeatmapRect(labels, colorStops);
|
createHeatmapRect(labels, colorStops);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showList() {
|
||||||
|
consoleList();
|
||||||
|
}
|
||||||
|
|
||||||
function createHeatmapRect(labels, colorStops) {
|
function createHeatmapRect(labels, colorStops) {
|
||||||
if (!this.canvas) {
|
if (!this.canvas) {
|
||||||
return;
|
return;
|
||||||
|
@ -5,6 +5,7 @@ var elevatorSpeed;
|
|||||||
var allDbIdsStr;
|
var allDbIdsStr;
|
||||||
let bulbLight;//點燈
|
let bulbLight;//點燈
|
||||||
var spotLight;//聚光燈
|
var spotLight;//聚光燈
|
||||||
|
let testLight;
|
||||||
var myDataList;//設備清單
|
var myDataList;//設備清單
|
||||||
var viewableData;
|
var viewableData;
|
||||||
var dataVizExtn;
|
var dataVizExtn;
|
||||||
@ -12,6 +13,8 @@ var spriteColorRed;
|
|||||||
var levels;//剖面用
|
var levels;//剖面用
|
||||||
var light;
|
var light;
|
||||||
let pointLightHelper;
|
let pointLightHelper;
|
||||||
|
var tagIdDevList = [];//模型設備List: device_number、device_coordinate_3d、forge_dbid
|
||||||
|
var roomDataList = [];//模型房間List: room_id、room_name
|
||||||
|
|
||||||
function launchViewer(urn) {
|
function launchViewer(urn) {
|
||||||
var av = Autodesk.Viewing;
|
var av = Autodesk.Viewing;
|
||||||
@ -140,11 +143,9 @@ function onDocumentLoadSuccess(doc) {
|
|||||||
|
|
||||||
viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function () {
|
viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function () {
|
||||||
var instanceTree = viewer.model.getData().instanceTree;
|
var instanceTree = viewer.model.getData().instanceTree;
|
||||||
|
|
||||||
var domElem = document.getElementById('all_id');
|
var domElem = document.getElementById('all_id');
|
||||||
allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex);
|
allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex);
|
||||||
domElem.innerText = allDbIdsStr;
|
domElem.innerText = allDbIdsStr;
|
||||||
|
|
||||||
//parseInt(allDbIdsStr[i]
|
//parseInt(allDbIdsStr[i]
|
||||||
//for (var i = 0; i < allDbIdsStr.length; i++) {
|
//for (var i = 0; i < allDbIdsStr.length; i++) {
|
||||||
// //setTransparency(parseInt(allDbIdsStr[i]), 0.2);
|
// //setTransparency(parseInt(allDbIdsStr[i]), 0.2);
|
||||||
@ -161,105 +162,152 @@ function onDocumentLoadSuccess(doc) {
|
|||||||
// })
|
// })
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// ------------------ 取得tag_id底下的nodeId --------------------------------------
|
//// ------------------ 取得tag_id底下的nodeId --------------------------------------
|
||||||
var curDbId = 0;
|
//var curDbId = 0;
|
||||||
var tagId = 0;
|
////var tagId = 0;
|
||||||
var _parentId = 0;
|
////var _parentId = 0;
|
||||||
var _childId = 0;
|
////var _childId = 0;
|
||||||
var itemName = '';
|
////var itemName = '';
|
||||||
var childIdArr = new Array();
|
////var childIdArr = new Array();
|
||||||
let evelMap = new Map();
|
////let evelMap = new Map();
|
||||||
|
|
||||||
let tree = viewer.model.getData().instanceTree;
|
//let tree = viewer.model.getData().instanceTree;
|
||||||
const model = viewer.model;
|
//const model = viewer.model;
|
||||||
const fragList = model.getFragmentList();
|
//const fragList = model.getFragmentList();
|
||||||
|
|
||||||
|
|
||||||
//loadHeatmaps(model);
|
// //loadHeatmaps(model);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////allDbIdsStr.forEach((dbId) => {
|
||||||
|
//// curDbId = parseInt(dbId);
|
||||||
|
//// viewer.getProperties(curDbId, function (e) {
|
||||||
|
//// e.properties.forEach(function (item) {
|
||||||
|
//// if (item.displayName == "tag_id" && e.name == "【電梯】") {
|
||||||
|
|
||||||
|
//// //getFragmentWorldMatrixByNodeId(e.dbId, viewer);
|
||||||
|
//// //let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
||||||
|
|
||||||
|
//// tree.enumNodeFragments(e.dbId, function (frag) {
|
||||||
|
|
||||||
|
//// let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
||||||
|
//// let matrix = new THREE.Matrix4();
|
||||||
|
//// console.log("proxy: " + fragProxy.position);
|
||||||
|
|
||||||
|
//// fragProxy.getWorldMatrix(matrix);
|
||||||
|
|
||||||
|
//// });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//// tagId = e.dbId;
|
||||||
|
//// viewer.getProperties(tagId, function (e2) {
|
||||||
|
//// e2.properties.forEach(function (item2) {
|
||||||
|
//// if (item2.displayName == "child") {
|
||||||
|
//// _parentId = item2.displayValue;
|
||||||
|
|
||||||
|
//// viewer.getProperties(_parentId, function (e3) {
|
||||||
|
//// let itemMap = new Map();
|
||||||
|
//// e3.properties.forEach(function (item3) {
|
||||||
|
//// if (item3.displayName == "child") {
|
||||||
|
//// _childId = item3.displayValue;
|
||||||
|
//// childIdArr.push(_childId);
|
||||||
|
|
||||||
|
//// var n = 0;
|
||||||
|
//// viewer.getProperties(childIdArr[n], function (e5) {
|
||||||
|
//// e5.properties.forEach(function (item5) {
|
||||||
|
//// if (item5.displayName == "Name") {
|
||||||
|
//// itemName = item5.displayValue;
|
||||||
|
//// itemMap.set(childIdArr[0], itemName)
|
||||||
|
//// console.log("childIdArr[0] ", childIdArr[0])
|
||||||
|
//// console.log("item name: ", itemName);
|
||||||
|
//// n += 3;
|
||||||
|
//// }
|
||||||
|
//// });
|
||||||
|
//// })
|
||||||
|
|
||||||
|
//// n = 1;
|
||||||
|
//// viewer.getProperties(childIdArr[n], function (e6) {
|
||||||
|
//// e6.properties.forEach(function (item6) {
|
||||||
|
//// if (item6.displayName == "Name") {
|
||||||
|
//// itemName = item6.displayValue;
|
||||||
|
//// itemMap.set(childIdArr[1], itemName)
|
||||||
|
//// console.log("childIdArr[1] ", childIdArr[1])
|
||||||
|
//// console.log("item name: ", itemName);
|
||||||
|
//// n += 3;
|
||||||
|
//// }
|
||||||
|
//// });
|
||||||
|
//// })
|
||||||
|
|
||||||
|
//// n = 2;
|
||||||
|
//// viewer.getProperties(childIdArr[n], function (e7) {
|
||||||
|
//// e7.properties.forEach(function (item7) {
|
||||||
|
//// if (item7.displayName == "Name") {
|
||||||
|
//// itemName = item7.displayValue;
|
||||||
|
//// itemMap.set(childIdArr[2], itemName)
|
||||||
|
//// console.log("childIdArr[2] ", childIdArr[2])
|
||||||
|
//// console.log("item name: ", itemName);
|
||||||
|
//// n += 3;
|
||||||
|
//// }
|
||||||
|
//// });
|
||||||
|
//// })
|
||||||
|
|
||||||
|
//// }
|
||||||
|
//// });
|
||||||
|
//// evelMap.set(item.displayValue, itemMap)
|
||||||
|
//// })
|
||||||
|
|
||||||
|
//// }
|
||||||
|
//// });
|
||||||
|
//// })
|
||||||
|
//// }
|
||||||
|
//// });
|
||||||
|
|
||||||
|
//// })
|
||||||
|
|
||||||
|
////})
|
||||||
|
|
||||||
//allDbIdsStr.forEach((dbId) => {
|
//allDbIdsStr.forEach((dbId) => {
|
||||||
// curDbId = parseInt(dbId);
|
// curDbId = parseInt(dbId);
|
||||||
// viewer.getProperties(curDbId, function (e) {
|
// viewer.getProperties(curDbId, function (e) {
|
||||||
// e.properties.forEach(function (item) {
|
// e.properties.forEach(function (item) {
|
||||||
// if (item.displayName == "tag_id" && e.name == "【電梯】") {
|
// if (item.displayName == "【tag_id】") { // Tag_name tag_id 【tag_id】
|
||||||
|
// if (item.displayValue != "") {
|
||||||
|
// if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) {// TPE_B1_ME_M10
|
||||||
|
// console.log("--------------------------------------------------");
|
||||||
|
// console.log("Tag_name dbid: " + e.dbId);
|
||||||
|
// console.log("value: " + item.displayValue);
|
||||||
|
// }
|
||||||
|
// //var v = getFragmentWorldMatrixByNodeId(e.dbId, viewer);
|
||||||
|
// //console.log("v: " + v);
|
||||||
|
|
||||||
|
|
||||||
|
// //tree.enumNodeFragments(e.dbId, function (frag) {
|
||||||
|
// // fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
||||||
|
// // fragProxy.getAnimTransform();
|
||||||
|
// // console.log("postion: " + fragProxy.position + ", fragP: " + fragProxy.fragPosition);
|
||||||
|
// //});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// let bounds = new THREE.Box3();
|
||||||
|
|
||||||
|
// instanceTree.enumNodeFragments(e.dbId, (fragId) => {
|
||||||
|
// let box = new THREE.Box3();
|
||||||
|
// fragList.getWorldBounds(fragId, box);
|
||||||
|
// bounds.union(box);
|
||||||
|
// }, true);
|
||||||
|
// var position = bounds.center();
|
||||||
|
// if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) {
|
||||||
|
// console.log("position: (" + (position.x).toFixed(2) + ", " + (position.y).toFixed(2) + ", " + (position.z).toFixed(2) + ")");
|
||||||
|
// console.log("--------------------------------------------------");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
// //getFragmentWorldMatrixByNodeId(e.dbId, viewer);
|
// //getFragmentWorldMatrixByNodeId(e.dbId, viewer);
|
||||||
// //let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
// //let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
||||||
|
|
||||||
// tree.enumNodeFragments(e.dbId, function (frag) {
|
|
||||||
|
|
||||||
// let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
|
||||||
// let matrix = new THREE.Matrix4();
|
|
||||||
// console.log("proxy: " + fragProxy.position);
|
|
||||||
|
|
||||||
// fragProxy.getWorldMatrix(matrix);
|
|
||||||
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// tagId = e.dbId;
|
|
||||||
// viewer.getProperties(tagId, function (e2) {
|
|
||||||
// e2.properties.forEach(function (item2) {
|
|
||||||
// if (item2.displayName == "child") {
|
|
||||||
// _parentId = item2.displayValue;
|
|
||||||
|
|
||||||
// viewer.getProperties(_parentId, function (e3) {
|
|
||||||
// let itemMap = new Map();
|
|
||||||
// e3.properties.forEach(function (item3) {
|
|
||||||
// if (item3.displayName == "child") {
|
|
||||||
// _childId = item3.displayValue;
|
|
||||||
// childIdArr.push(_childId);
|
|
||||||
|
|
||||||
// var n = 0;
|
|
||||||
// viewer.getProperties(childIdArr[n], function (e5) {
|
|
||||||
// e5.properties.forEach(function (item5) {
|
|
||||||
// if (item5.displayName == "Name") {
|
|
||||||
// itemName = item5.displayValue;
|
|
||||||
// itemMap.set(childIdArr[0], itemName)
|
|
||||||
// console.log("childIdArr[0] ", childIdArr[0])
|
|
||||||
// console.log("item name: ", itemName);
|
|
||||||
// n += 3;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// })
|
|
||||||
|
|
||||||
// n = 1;
|
|
||||||
// viewer.getProperties(childIdArr[n], function (e6) {
|
|
||||||
// e6.properties.forEach(function (item6) {
|
|
||||||
// if (item6.displayName == "Name") {
|
|
||||||
// itemName = item6.displayValue;
|
|
||||||
// itemMap.set(childIdArr[1], itemName)
|
|
||||||
// console.log("childIdArr[1] ", childIdArr[1])
|
|
||||||
// console.log("item name: ", itemName);
|
|
||||||
// n += 3;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// })
|
|
||||||
|
|
||||||
// n = 2;
|
|
||||||
// viewer.getProperties(childIdArr[n], function (e7) {
|
|
||||||
// e7.properties.forEach(function (item7) {
|
|
||||||
// if (item7.displayName == "Name") {
|
|
||||||
// itemName = item7.displayValue;
|
|
||||||
// itemMap.set(childIdArr[2], itemName)
|
|
||||||
// console.log("childIdArr[2] ", childIdArr[2])
|
|
||||||
// console.log("item name: ", itemName);
|
|
||||||
// n += 3;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// })
|
|
||||||
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// evelMap.set(item.displayValue, itemMap)
|
|
||||||
// })
|
|
||||||
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// })
|
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
@ -267,44 +315,55 @@ function onDocumentLoadSuccess(doc) {
|
|||||||
|
|
||||||
//})
|
//})
|
||||||
|
|
||||||
|
////---------------------- end ---------------------------------------------------
|
||||||
|
|
||||||
|
// ------------------ 2023.01.06 取得tag_id、底下的nodeId --------------------------------------
|
||||||
|
var curDbId = 0;
|
||||||
|
|
||||||
|
let tree = viewer.model.getData().instanceTree;
|
||||||
|
const model = viewer.model;
|
||||||
|
const fragList = model.getFragmentList();
|
||||||
|
|
||||||
|
|
||||||
allDbIdsStr.forEach((dbId) => {
|
allDbIdsStr.forEach((dbId) => {
|
||||||
curDbId = parseInt(dbId);
|
curDbId = parseInt(dbId);
|
||||||
viewer.getProperties(curDbId, function (e) {
|
viewer.getProperties(curDbId, function (e) {
|
||||||
e.properties.forEach(function (item) {
|
e.properties.forEach(function (item) {
|
||||||
if (item.displayName == "【tag_id】") { // Tag_name tag_id 【tag_id】
|
if (item.displayName == "【tag_id】") { // Tag_name tag_id 【tag_id】
|
||||||
if (item.displayValue != "") {
|
if (item.displayValue != "") {
|
||||||
if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) {// TPE_B1_ME_M10
|
////if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) {// TPE_B1_ME_M10
|
||||||
console.log("--------------------------------------------------");
|
//console.log("--------------------------------------------------");
|
||||||
console.log("Tag_name dbid: " + e.dbId);
|
//console.log("Tag_name dbid: " + e.dbId);
|
||||||
console.log("value: " + item.displayValue);
|
//console.log("value: " + item.displayValue);
|
||||||
|
////}
|
||||||
|
var str = item.displayValue.split('_');
|
||||||
|
if (str.length == 2) { //兩段為房間 ex: U7F_01
|
||||||
|
roomDataList.push({ room_id: e.dbId, room_name: item.displayValue });
|
||||||
}
|
}
|
||||||
//var v = getFragmentWorldMatrixByNodeId(e.dbId, viewer);
|
else if (str.length == 8) { //八段為設備 ex: TPE_B1_ME_M10_U7F_NA_FCU_N1
|
||||||
//console.log("v: " + v);
|
//取得座標
|
||||||
|
|
||||||
|
|
||||||
//tree.enumNodeFragments(e.dbId, function (frag) {
|
|
||||||
// fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
|
||||||
// fragProxy.getAnimTransform();
|
|
||||||
// console.log("postion: " + fragProxy.position + ", fragP: " + fragProxy.fragPosition);
|
|
||||||
//});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let bounds = new THREE.Box3();
|
let bounds = new THREE.Box3();
|
||||||
|
|
||||||
instanceTree.enumNodeFragments(e.dbId, (fragId) => {
|
instanceTree.enumNodeFragments(e.dbId, (fragId) => {
|
||||||
let box = new THREE.Box3();
|
let box = new THREE.Box3();
|
||||||
fragList.getWorldBounds(fragId, box);
|
fragList.getWorldBounds(fragId, box);
|
||||||
bounds.union(box);
|
bounds.union(box);
|
||||||
}, true);
|
}, true);
|
||||||
var position = bounds.center();
|
var position = bounds.center();
|
||||||
if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) {
|
////if ((item.displayValue).indexOf('TPE_B1_LT_L1') > -1) {
|
||||||
console.log("position: (" + (position.x).toFixed(2) + ", " + (position.y).toFixed(2) + ", " + (position.z).toFixed(2) + ")");
|
//console.log("position: (" + (position.x).toFixed(2) + ", " + (position.y).toFixed(2) + ", " + (position.z).toFixed(2) + ")");
|
||||||
console.log("--------------------------------------------------");
|
//console.log("--------------------------------------------------");
|
||||||
|
////}
|
||||||
|
tagIdDevList.push({ device_number: item.displayValue, device_coordinate_3d: '{ "x": ' + (position.x).toFixed(2) + ', "y": ' + (position.y).toFixed(2) + ', "z": ' + (position.z).toFixed(2) + ' }', forge_dbid: e.dbId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//getFragmentWorldMatrixByNodeId(e.dbId, viewer);
|
|
||||||
//let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -313,7 +372,6 @@ function onDocumentLoadSuccess(doc) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
//---------------------- end ---------------------------------------------------
|
//---------------------- end ---------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@ -361,114 +419,49 @@ function onDocumentLoadSuccess(doc) {
|
|||||||
//})
|
//})
|
||||||
|
|
||||||
|
|
||||||
//let tree = viewer.model.getData().instanceTree;
|
|
||||||
let nodeId = 12112;//12104; //749; //10952;
|
|
||||||
let nodeId2 = 12111;//12105; //750;
|
|
||||||
let nodeId3 = 12110;//12104; //751;
|
|
||||||
|
|
||||||
tree.enumNodeFragments(nodeId, function (frag) {
|
// //let tree = viewer.model.getData().instanceTree;
|
||||||
fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
//let nodeId = 12112;//12104; //749; //10952;
|
||||||
fragProxy.getAnimTransform();
|
//let nodeId2 = 12111;//12105; //750;
|
||||||
let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26
|
//let nodeId3 = 12110;//12104; //751;
|
||||||
|
|
||||||
fragProxy.position = fragPosition
|
//tree.enumNodeFragments(nodeId, function (frag) {
|
||||||
|
// fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
||||||
|
// fragProxy.getAnimTransform();
|
||||||
|
// let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26
|
||||||
|
// fragProxy.position = fragPosition
|
||||||
|
// fragProxy.updateAnimTransform()
|
||||||
|
//});
|
||||||
|
//viewer.impl.sceneUpdated(true);
|
||||||
|
|
||||||
fragProxy.updateAnimTransform()
|
////------------ add -------------
|
||||||
|
//tree.enumNodeFragments(nodeId2, function (frag) {
|
||||||
|
// fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
||||||
|
// fragProxy.getAnimTransform();
|
||||||
|
// let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26
|
||||||
|
|
||||||
|
// fragProxy.position = fragPosition
|
||||||
|
|
||||||
|
// fragProxy.updateAnimTransform()
|
||||||
|
|
||||||
|
//});
|
||||||
|
//viewer.impl.sceneUpdated(true);
|
||||||
|
|
||||||
|
//tree.enumNodeFragments(nodeId3, function (frag) {
|
||||||
|
// fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
||||||
|
// fragProxy.getAnimTransform();
|
||||||
|
// let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26
|
||||||
|
|
||||||
|
// fragProxy.position = fragPosition
|
||||||
|
|
||||||
|
// fragProxy.updateAnimTransform()
|
||||||
|
|
||||||
|
//});
|
||||||
|
//viewer.impl.sceneUpdated(true);
|
||||||
|
|
||||||
});
|
});
|
||||||
viewer.impl.sceneUpdated(true);
|
//newLight();
|
||||||
|
//testLight = new THREE.SpotLight();
|
||||||
//------------ add -------------
|
|
||||||
tree.enumNodeFragments(nodeId2, function (frag) {
|
|
||||||
fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
|
||||||
fragProxy.getAnimTransform();
|
|
||||||
let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26
|
|
||||||
|
|
||||||
fragProxy.position = fragPosition
|
|
||||||
|
|
||||||
fragProxy.updateAnimTransform()
|
|
||||||
|
|
||||||
});
|
|
||||||
viewer.impl.sceneUpdated(true);
|
|
||||||
|
|
||||||
tree.enumNodeFragments(nodeId3, function (frag) {
|
|
||||||
fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
|
|
||||||
fragProxy.getAnimTransform();
|
|
||||||
let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26
|
|
||||||
|
|
||||||
fragProxy.position = fragPosition
|
|
||||||
|
|
||||||
fragProxy.updateAnimTransform()
|
|
||||||
|
|
||||||
});
|
|
||||||
viewer.impl.sceneUpdated(true);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
//add toolbar fail
|
|
||||||
//function ToolbarExtension(viewer, options) {
|
|
||||||
// Autodesk.Viewing.Extension.call(this, viewer, options);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//ToolbarExtension.prototype = Object.create(Autodesk.Viewing.Extension.prototype);
|
|
||||||
//ToolbarExtension.prototype.constructor = ToolbarExtension;
|
|
||||||
|
|
||||||
//ToolbarExtension.prototype.load = function () {
|
|
||||||
// this.viewer.setLightPreset(6);
|
|
||||||
// this.viewer.setEnvMapBackground(true);
|
|
||||||
// this.viewer.fitToView();
|
|
||||||
// return true;
|
|
||||||
//};
|
|
||||||
|
|
||||||
//ToolbarExtension.prototype.unload = function () {
|
|
||||||
|
|
||||||
//};
|
|
||||||
//Autodesk.Viewing.theExtensionManager.registerExtension('ToolbarExtension', ToolbarExtension);
|
|
||||||
|
|
||||||
//ToolbarExtension.prototype.onToolbarCreated = function (toolbar) {
|
|
||||||
// //alert('TODO: customize Viewer toolbar');
|
|
||||||
|
|
||||||
// var viewer = this.viewer;
|
|
||||||
// var button1 = new Autodesk.Viewing.UI.Button('show-env-bg-button');
|
|
||||||
// button1.onClick = function (e) {
|
|
||||||
// viewer.setEnvMapBackground(true);
|
|
||||||
// };
|
|
||||||
// button1.addClass('show-env-bg-button');
|
|
||||||
// button1.setToolTip('Show Environment');
|
|
||||||
|
|
||||||
// //SubToolbar
|
|
||||||
// this.subToolbar = new Autodesk.Viewing.UI.ControlGroup('my-custom-toolbar');
|
|
||||||
// this.subToolbar.addControl(button1);
|
|
||||||
// toolbar.addControl(this.subToolbar);
|
|
||||||
|
|
||||||
//};
|
|
||||||
|
|
||||||
|
|
||||||
//加入點燈光
|
|
||||||
//bulbLight = new THREE.PointLight(0xffffff, 1, 1, 2);//0xff0000
|
|
||||||
//bulbLight.position.set(-17.33, 51.03, -2.52);//17.880840301513672
|
|
||||||
//bulbLight.castShadow = true;
|
|
||||||
//bulbLight.intensity = 50;
|
|
||||||
//bulbLight.distance = 1;
|
|
||||||
//bulbLight.emissiveIntensity = bulbLight.intensity / Math.pow(0.02, 2.0);
|
|
||||||
//viewer.scene.add(bulbLight);
|
|
||||||
|
|
||||||
//聚光燈
|
|
||||||
//spotLight = new THREE.SpotLight(0xffff00, 80, 10);//0xffffff
|
|
||||||
//spotLight.position.set(-7.58, 18.20, -0.25); //set(-17.33, 51.03, -2.52);
|
|
||||||
//spotLight.castShadow = true;
|
|
||||||
//spotLight.visible = true;
|
|
||||||
//var geom = new THREE.BoxGeometry(); //create 幾何對象 -17.33, 51.03, -4.52
|
|
||||||
//var material = new THREE.MeshLambertMaterial({ color: 0xffff00 });//0xff0000
|
|
||||||
//var cube = new THREE.Mesh(geom, material);
|
|
||||||
//cube.position.set(-7.58, 18.20, -1); //set(-17.33, 51.03, -10);//-4.52
|
|
||||||
//viewer.scene.add(cube);
|
|
||||||
//spotLight.target = cube;
|
|
||||||
//viewer.scene.add(spotLight);
|
|
||||||
|
|
||||||
//light = newLight();
|
|
||||||
newLight();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------- 加入熱點 -----------------
|
//------------------- 加入熱點 -----------------
|
||||||
@ -482,7 +475,8 @@ async function addHotPoint(data) {
|
|||||||
const spriteIcon = "https://d2zqnmauvnpnnm.cloudfront.net/assets-1/images/circle.svg"; //"/img/forge/hotspot.svg";
|
const spriteIcon = "https://d2zqnmauvnpnnm.cloudfront.net/assets-1/images/circle.svg"; //"/img/forge/hotspot.svg";
|
||||||
|
|
||||||
const style = new DataVizCore.ViewableStyle(viewableType, spriteColor, spriteIcon);
|
const style = new DataVizCore.ViewableStyle(viewableType, spriteColor, spriteIcon);
|
||||||
var a = newLight();
|
//var a = newLight();
|
||||||
|
newLight();
|
||||||
//function onSpriteClicked(event) {
|
//function onSpriteClicked(event) {
|
||||||
// console.log(`Sprite clicked: ${event.dbId}`);
|
// console.log(`Sprite clicked: ${event.dbId}`);
|
||||||
//}
|
//}
|
||||||
@ -521,7 +515,7 @@ async function addHotPoint(data) {
|
|||||||
event.hasStopped = true;
|
event.hasStopped = true;
|
||||||
if (event != undefined && event != null) {
|
if (event != undefined && event != null) {
|
||||||
if (event.dbId >= 10 && event.dbId <= 13) {//event.dbId > 0 && event.dbId < 19
|
if (event.dbId >= 10 && event.dbId <= 13) {//event.dbId > 0 && event.dbId < 19
|
||||||
setLightValues(20, 0x00ff00)
|
setLightValues(20, 0x00ff00);
|
||||||
console.log(`Sprite clicked: ${event.dbId}`);
|
console.log(`Sprite clicked: ${event.dbId}`);
|
||||||
openHotspotModal();
|
openHotspotModal();
|
||||||
}
|
}
|
||||||
@ -1387,26 +1381,26 @@ async function newLight() {
|
|||||||
//angle - 光從其上界為 Math.PI / 2 的方向散射的最大角度。
|
//angle - 光從其上界為 Math.PI / 2 的方向散射的最大角度。
|
||||||
//半影 - 由於半影而衰減的聚光燈錐體的百分比。取值介於 0 和 1 之間。默認值為零。
|
//半影 - 由於半影而衰減的聚光燈錐體的百分比。取值介於 0 和 1 之間。默認值為零。
|
||||||
//decay - 光沿光的距離變暗的量。
|
//decay - 光沿光的距離變暗的量。
|
||||||
//spotLight = new THREE.SpotLight(0xff0000, 200, 20, 0.6, 0.5, 10);//0xffffff 80, 10 //15, 20 , Math.PI / 12
|
spotLight = new THREE.SpotLight(0xff0000, 200, 20, 0.6, 0.5, 10);//0xffffff 80, 10 //15, 20 , Math.PI / 12
|
||||||
//spotLight.position.set(43.72, -15.65, -44.96); //set(-17.33, 51.03, -2.52); // -7.58, 18.20, -0.25 -44.96
|
spotLight.position.set(43.72, -15.65, -44.96); //set(-17.33, 51.03, -2.52); // -7.58, 18.20, -0.25 -44.96
|
||||||
//spotLight.castShadow = false;
|
spotLight.castShadow = false;
|
||||||
//spotLight.visible = true;
|
spotLight.visible = true;
|
||||||
|
|
||||||
//spotLight.target.position.set(43.72, -15.65, -60);// -15.65 -48
|
spotLight.target.position.set(43.72, -15.65, -60);// -15.65 -48
|
||||||
//viewer.scene.add(spotLight.target);
|
viewer.scene.add(spotLight.target);
|
||||||
|
|
||||||
//viewer.scene.add(spotLight);
|
viewer.scene.add(spotLight);
|
||||||
|
|
||||||
//viewer.impl.sceneUpdated(true);
|
viewer.impl.sceneUpdated(true);
|
||||||
|
|
||||||
//return spotLight;
|
//return spotLight;
|
||||||
|
|
||||||
//加入點燈光
|
//加入點燈光
|
||||||
bulbLight = new THREE.PointLight(0xff0000, 50, 20, 2);//0xff0000
|
//bulbLight = new THREE.PointLight(0xffffff, 50, 20, 2);//0xff0000
|
||||||
bulbLight.position.set(43.72, -15.65, -44.96);//17.880840301513672
|
//bulbLight.position.set(43.72, -15.65, -44.96);//17.880840301513672
|
||||||
bulbLight.castShadow = true;
|
//bulbLight.castShadow = true;
|
||||||
bulbLight.visible = true;
|
//bulbLight.visible = true;
|
||||||
viewer.scene.add(bulbLight);
|
//viewer.scene.add(bulbLight);
|
||||||
|
|
||||||
//pointLightHelper = new THREE.PointLightHelper(pointLight);
|
//pointLightHelper = new THREE.PointLightHelper(pointLight);
|
||||||
//viewer.scene.add(pointLightHelper);
|
//viewer.scene.add(pointLightHelper);
|
||||||
@ -1439,13 +1433,15 @@ function setLightValues(intensity, color) {// distance, angle, penumbra, decay,
|
|||||||
function setLightOpenOrClose(value) {//, light
|
function setLightOpenOrClose(value) {//, light
|
||||||
if (value) {
|
if (value) {
|
||||||
//light.visible = true;
|
//light.visible = true;
|
||||||
//spotLight.visible = true;
|
spotLight.visible = true;
|
||||||
bulbLight.visible = true;
|
//bulbLight.visible = true;
|
||||||
|
//testLight.visible = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//light.visible = false;
|
//light.visible = false;
|
||||||
//spotLight.visible = false;
|
spotLight.visible = false;
|
||||||
bulbLight.visible = false;
|
//bulbLight.visible = false;
|
||||||
|
//testLight.visible = false;
|
||||||
}
|
}
|
||||||
viewer.impl.sceneUpdated(true);
|
viewer.impl.sceneUpdated(true);
|
||||||
}
|
}
|
||||||
@ -1457,3 +1453,7 @@ function setLightTransparency(value) {
|
|||||||
}
|
}
|
||||||
//------------- end -----------------------------------
|
//------------- end -----------------------------------
|
||||||
|
|
||||||
|
function consoleList() {
|
||||||
|
console.log(tagIdDevList);
|
||||||
|
console.log(roomDataList);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user