|
@@ -206,7 +206,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
console.log('添加模型和水滴1111',benchIdList)
|
|
|
if (sdkInstance) {
|
|
|
if (benchIdList.indexOf(Number(bench_id)) > 0) {
|
|
|
- if (bAddModel && window.benchMeshWaterMap[bench_id]) {
|
|
|
+ if (window.benchMeshWaterMap[bench_id]) {
|
|
|
window.benchMeshWaterMap[bench_id] = mesh;
|
|
|
console.log('添加benchid', bench_id)
|
|
|
sdkInstance.sceneRenderer.scene.add(mesh)
|
|
@@ -332,12 +332,18 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
|
|
|
console.log('添加模型和水滴1111')
|
|
|
if (benchIdList.indexOf(Number(bench_id)) > 0) {
|
|
|
- if (bAddModel && window.benchMeshMap[bench_id]) {
|
|
|
+ if (window.benchMeshMap[bench_id]) {
|
|
|
window.benchMeshMap[bench_id] = childMeshTmp;
|
|
|
sdkInstance.sceneRenderer.scene.add(childMeshTmp)
|
|
|
}
|
|
|
else {
|
|
|
+ let deleteChildMesh = window.benchMeshMap[bench_id];
|
|
|
+ sdkInstance.sceneRenderer.scene.remove(deleteChildMesh)
|
|
|
+ deleteChildMesh.geometry.dispose(); // 清理几何体
|
|
|
+ deleteChildMesh.material.dispose(); // 清理材质
|
|
|
+ deleteChildMesh = null; // 置空指向该3D模型的变量
|
|
|
window.benchMeshMap[bench_id] = childMeshTmp;
|
|
|
+ sdkInstance.sceneRenderer.scene.add(childMeshTmp);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -453,12 +459,18 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
};
|
|
|
childMeshTmp.userData = customData;
|
|
|
|
|
|
- if (bAddModel && window.benchMeshMap[bench_id]) {
|
|
|
+ if (window.benchMeshMap[bench_id]) {
|
|
|
window.benchMeshMap[bench_id] = childMeshTmp;
|
|
|
sdkInstance.sceneRenderer.scene.add(childMeshTmp)
|
|
|
}
|
|
|
else {
|
|
|
+ let deleteChildMesh = window.benchMeshMap[bench_id];
|
|
|
+ sdkInstance.sceneRenderer.scene.remove(deleteChildMesh)
|
|
|
+ deleteChildMesh.geometry.dispose(); // 清理几何体
|
|
|
+ deleteChildMesh.material.dispose(); // 清理材质
|
|
|
+ deleteChildMesh = null; // 置空指向该3D模型的变量
|
|
|
window.benchMeshMap[bench_id] = childMeshTmp;
|
|
|
+ sdkInstance.sceneRenderer.scene.add(childMeshTmp);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -590,11 +602,11 @@ function getsqlDataRealTime() {
|
|
|
if(window.benchMeshMap[item.bench_id] && window.benchMeshWaterMap[item.bench_id])
|
|
|
{
|
|
|
window.benchMeshMap[item.bench_id].position.set(x, y, z);
|
|
|
- window.benchMeshWaterMap[item.bench_id].position.set(x, y + 10, z);
|
|
|
- if (item.use_fix_pos == 0) {
|
|
|
- window.benchMeshMap[item.bench_id].position.set(x - 14.7, JSON.parse(JSON.stringify(item.fix_pos_y)), y - 14);
|
|
|
- window.benchMeshWaterMap[item.bench_id].position.set(x - 14.7, JSON.parse(JSON.stringify(item.fix_pos_y)) + 10, y - 14);
|
|
|
- }
|
|
|
+ // window.benchMeshWaterMap[item.bench_id].position.set(x, y + 10, z);
|
|
|
+ // if (item.use_fix_pos == 0) {
|
|
|
+ // window.benchMeshMap[item.bench_id].position.set(x - 14.7, JSON.parse(JSON.stringify(item.fix_pos_y)), y - 14);
|
|
|
+ // window.benchMeshWaterMap[item.bench_id].position.set(x - 14.7, JSON.parse(JSON.stringify(item.fix_pos_y)) + 10, y - 14);
|
|
|
+ // }
|
|
|
var localPosition = new THREE.Vector3(window.benchMeshMap[item.bench_id].position.x,window.benchMeshMap[item.bench_id].position.y,window.benchMeshMap[item.bench_id].position.z);
|
|
|
var worldPosition = window.uwbInstance.convertLocalToWorld(localPosition);
|
|
|
var pos = window.sdkInstance.getScreenPosition(worldPosition);
|
|
@@ -691,10 +703,30 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
|
|
|
modeChangeInterval = setInterval(() => {
|
|
|
if (window.sdkInstance.player.controls) {
|
|
|
clearInterval(modeChangeInterval);
|
|
|
- window.sdkInstance.changeMode('floorplan');
|
|
|
- sdkInstance.player.cameras.floorplan.position.setY(10)
|
|
|
+ try {
|
|
|
+ window.sdkInstance.changeMode('floorplan');
|
|
|
+ sdkInstance.player.cameras.floorplan.position.setY(10)
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e, `changeMode('floorplan') error`)
|
|
|
+ modeChangeInterval = setInterval(() => {
|
|
|
+ if (window.sdkInstance.player.controls) {
|
|
|
+ clearInterval(modeChangeInterval);
|
|
|
+ try {
|
|
|
+ window.sdkInstance.changeMode('floorplan');
|
|
|
+ sdkInstance.player.cameras.floorplan.position.setY(10)
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e, `changeMode('floorplan') error`)
|
|
|
+ setTimeout(() => {
|
|
|
+ window.sdkInstance.changeMode('floorplan');
|
|
|
+ }, 6000);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- }, 6 * 1000)
|
|
|
+ }, 500)
|
|
|
}, 1500)
|
|
|
}
|
|
|
|