[Frontend] 增加函式 移動視角至設備

This commit is contained in:
wanli 2023-01-09 17:09:44 +08:00
parent 46f9ca1642
commit fac789c635

View File

@ -726,7 +726,7 @@ async function getLightData(data) {
async function testNewLight(dataList) {
dataList.forEach((myData, index) => {
const position = JSON.parse(myData.device_node_coordinate_3d);
lightList.push({ dbid: myData.forge_dbid, device_guid: myData.device_guid, lightObject: new THREE.SpotLight(0xff0000, 200, 20, 0.6, 0.5, 10) });
lightList.push({ dbid: myData.forge_dbid, device_guid: myData.device_guid, lightObject: new THREE.SpotLight(0xffffff, 200, 20, 0.6, 0.5, 10) });
lightList[index].lightObject.position.set(position.x, position.y, position.z);
lightList[index].lightObject.castShadow = true;
@ -798,6 +798,7 @@ async function addHotPoint(data) {
if (lightList != undefined && lightList != null && lightList.length > 0) {
//setLightOpenOrClose(false, myData.device_guid);//關燈測試
//setLightValues(myData.device_guid, 20, 0x00ff00);//更改燈光顏色和強度的測試
moveViewToDevice(myData.forge_dbid);//移動視角至該設備
}
$(selector).trigger("autodesk:click:sprite", { event, myData });
} else {
@ -1170,4 +1171,15 @@ function setShadowShow(type = false) {
viewer.impl.sceneUpdated(true);
}
//============================= end ===================================
//============================= end ===================================
function moveViewToDevice(letter) {
if (letter != "") {
viewer.clearSelection();
viewer.select(letter);
viewer.fitToView([letter]);
}
else {
viewer.clearSelection();
}
}