[Frontend] 取得3D模型中的tag_id,並獲取底下的電梯三個物件的nodeId(電梯門、電梯內部空間、電梯升降空間)

This commit is contained in:
wanli 2022-12-07 00:41:55 +08:00
parent 2db82f49aa
commit 2d38c6511f
5 changed files with 145 additions and 18 deletions

View File

@ -20,6 +20,17 @@
<button id="1F1oor" onclick="move1Floor()">1 Floor</button>
<button id="2F1oor" onclick="move2Floor()">2 Floor</button>
<button id="3F1oor" onclick="move3Floor()">3 Floor</button>
<button id="1F1oor" onclick="move4Floor()">4 Floor</button>
<button id="2F1oor" onclick="move5Floor()">5 Floor</button>
<button id="3F1oor" onclick="move6Floor()">6 Floor</button>
<button id="1F1oor" onclick="move7Floor()">7 Floor</button>
<button id="2F1oor" onclick="move8Floor()">8 Floor</button>
<button id="3F1oor" onclick="move9Floor()">9 Floor</button>
<button id="1F1oor" onclick="move10Floor()">10 Floor</button>
<button id="2F1oor" onclick="move11Floor()">11 Floor</button>
<button id="3F1oor" onclick="move12Floor()">12 Floor</button>
<button id="3F1oor" onclick="moveB1Floor()">B1 Floor</button>
<input id="lightBar" type="range" min="0" max="100" step="5" onchange="changeLightPower()">亮度
<!-- <input type="range">Main Axis</input> -->
</div>
@ -49,7 +60,8 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.7/jstree.min.js"></script>
<script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/viewer3D.js"></script>
<!-- <script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.16/viewer3D.js"></script> -->
<script src="js/forge/forgemodel.js"></script>
<!--<script src="js/forge/forgemodel.js"></script>-->
<script src="js/forge/modeltest.js"></script>
<script>
@ -58,10 +70,12 @@
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwTUVQJUUzJTgwJTkxLm53Yw');//[TEST].nwd
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MFRFU1QlRTMlODAlOTEubndk');
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwTUVQJUUzJTgwJTkxLm53Yw==');
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwTUVQJUUzJTgwJTkxLm53Yw==');
//
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwVEVTVCVFMyU4MCU5MS5ud2Q=');
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDLm53ZA');
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDLm53ZA');
//dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDLm53ZA
});
function move1Floor() {
setElevatorSpeed(0.2);
@ -79,6 +93,57 @@
requestAnimationFrame(movElevator);
}
function move4Floor() {
setElevatorSpeed(0.2);
setElevatorFloor(3);
requestAnimationFrame(movElevator);
}
function move5Floor() {
setElevatorSpeed(0.2);
setElevatorFloor(4);
requestAnimationFrame(movElevator);
}
function move6Floor() {
setElevatorSpeed(0.2);
setElevatorFloor(5);
requestAnimationFrame(movElevator);
}
function move7Floor() {
setElevatorSpeed(0.2);
setElevatorFloor(6);
requestAnimationFrame(movElevator);
}
function move8Floor() {
setElevatorSpeed(0.2);
setElevatorFloor(7);
requestAnimationFrame(movElevator);
}
function move9Floor() {
setElevatorSpeed(0.2);
setElevatorFloor(8);
requestAnimationFrame(movElevator);
}
function move10Floor() {
setElevatorSpeed(0.2);
setElevatorFloor(9);
requestAnimationFrame(movElevator);
}
function move11Floor() {
setElevatorSpeed(0.2);
setElevatorFloor(10);
requestAnimationFrame(movElevator);
}
function move12Floor() {
setElevatorSpeed(0.2);
setElevatorFloor(11);
requestAnimationFrame(movElevator);
}
function moveB1Floor() {
setElevatorSpeed(0.2);
setElevatorFloor(-1);
requestAnimationFrame(movElevator);
}
function changeLightPower() {
var value = document.getElementById('lightBar').value;
console.log("power: " + value);

View File

@ -52,7 +52,7 @@
<script src="js/forge/modeltest.js"></script>
<script src="js/forge/AdnLevelSectionPanel.js"></script>
<!--<script src="js/forge/AdnLevelSectionPanel.js"></script>-->
<style>
.show-env-bg-button {
@ -69,6 +69,7 @@
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dnNjb2RlX2ZvcmdlX3Rlc3QvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDLm53ZA');
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDMjAyMjEyMDEubndk');
launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MCVFNSU4RiVCMCVFNSU4QyU5NyVFNCVCOCVBRCVFOCU4RiVCMSVFNSVBNCVBNyVFNiVBOCU5MyVFMyU4MCU5MUFSQ18yMDIyMTIwNS5ud2Q');
//launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6LW1vZGVsX3Rlc3QxMTIxLyVFMyU4MCU5MCVFNSU4RiVCMCVFNSU4QyU5NyVFNCVCOCVBRCVFOCU4RiVCMSVFNSVBNCVBNyVFNiVBOCU5MyVFMyU4MCU5MUFSQ18yMDIyMTIwNS5ud2Q');
});
function move1Floor() {
setElevatorSpeed(0.2);

View File

@ -95,22 +95,25 @@ function onDocumentLoadSuccess(doc) {
//viewer.setThemingColor(751, color, null, true);
var myDbid = currSelection;
viewer.getProperties(myDbid, function (e) {
//console.log('Entire object response ', e);
//console.log('Properties ', e.properties);
//foreach(item in e.properties) {
// if (item.displayName == "【tag_id】") {
// console.log(">> " + item.displayValue);
// }
//}
//viewer.getProperties(myDbid, function (e) {
// //console.log('Entire object response ', e);
// //console.log('Properties ', e.properties);
// //foreach(item in e.properties) {
// // if (item.displayName == "【tag_id】") {
// // console.log(">> " + item.displayValue);
// // }
// //}
e.properties.forEach(function (item) {
if (item.displayName == "【tag_id】") {
console.log(">> " + item.displayValue);
}
});
// e.properties.forEach(function (item) {
// //if (item.displayName == "【tag_id】") {
// // console.log(">> " + item.displayValue);
// //}
// if (item.displayName == "tag_id") {
// console.log(">> " + item.displayValue);
// }
// });
});
//});
});
@ -123,7 +126,65 @@ function onDocumentLoadSuccess(doc) {
var domElem = document.getElementById('all_id');
domElem.innerText = allDbIdsStr;
//parseInt(allDbIdsStr[i]
//for (var i = 0; i < allDbIdsStr.length; i++) {
// //setTransparency(parseInt(allDbIdsStr[i]), 0.2);
// viewer.getProperties(parseInt(allDbIdsStr[i], function (e) {
// e.properties.forEach(function (item) {
// //if (item.displayName == "【tag_id】") {
// // console.log(">> " + item.displayValue);
// //}
// if (item.displayName == "tag_id") {
// console.log(">> " + item.displayValue);
// }
// });
// })
//}
// ------------------ 取得tag_id底下的nodeId --------------------------------------
var curDbId = 0;
var tagId = 0;
var _parentId = 0;
var _childId = 0;
//var childIdArr = new Array();
let evelMap = new Map();
allDbIdsStr.forEach((dbId) => {
curDbId = parseInt(dbId);
viewer.getProperties(curDbId, function (e) {
e.properties.forEach(function (item) {
if (item.displayName == "tag_id" && e.name == "【電梯】") {
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) {
var childIdArr = new Array();
e3.properties.forEach(function (item3) {
if (item3.displayName == "child") {
_childId = item3.displayValue;
childIdArr.push(_childId);
}
});
evelMap.set(item.displayValue, childIdArr)
console.log("map: " + evelMap);
})
}
});
})
}
});
})
})
//---------------------- end ---------------------------------------------------