|
@@ -6,7 +6,7 @@ import fetchAndCombine from "../public/loader/loader";
|
|
|
import { UWB } from "../public/plugin/uwb/index.js";
|
|
|
import { FXAAShader } from "../public/shader/FAAXShader.js"
|
|
|
import '../public/libs/tools.js'
|
|
|
-import { DBUtil } from "../src/DButil";
|
|
|
+// import { DBUtil } from "../src/DButil";
|
|
|
|
|
|
// 定义一个函数,接受元素ID和一个回调函数作为参数,用于处理点击事件
|
|
|
window.sdkInstance = null;
|
|
@@ -19,6 +19,9 @@ window.modeChangeInterval = null;
|
|
|
window.benchListInterval = null;
|
|
|
window.otherInterval = null;
|
|
|
|
|
|
+var fbxMesh1 = null;
|
|
|
+var fbxMesh2 = null;
|
|
|
+var fbxMesh3 = null;
|
|
|
var fbxLoader1Loaded = false;
|
|
|
var fbxLoader2Loaded = false;
|
|
|
var fbxLoader3Loaded = false
|
|
@@ -183,6 +186,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
fbxLoader1.load("../models/meshDraco.gltf", function (gltf) {
|
|
|
console.log("12-old", Date.now());
|
|
|
fbxLoader1Loaded = true;
|
|
|
+ fbxMesh1 = gltf.scene.children[0].children[0];
|
|
|
let benchIdList = window.store.getters['benchList/getBenchList'].map(m => m.id);
|
|
|
let result = g_PosArrayResult;
|
|
|
for (var item of result) {
|
|
@@ -193,6 +197,10 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
let ang_y = 0.0;
|
|
|
let ang_z = 0.0;
|
|
|
let benchType = item.bench_type;
|
|
|
+ let card_id = item.card_id;
|
|
|
+ let bench_id = item.bench_id;
|
|
|
+ let bench_img = item.bench_img;
|
|
|
+ let show_remote_button = item.show_remote_button;
|
|
|
|
|
|
if (true) {
|
|
|
x = JSON.parse(JSON.stringify(item.fix_pos_x));
|
|
@@ -203,19 +211,15 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
|
|
|
}
|
|
|
|
|
|
- let card_id = item.card_id;
|
|
|
- let bench_id = item.bench_id;
|
|
|
- let bench_img = item.bench_img;
|
|
|
- let show_remote_button = item.show_remote_button;
|
|
|
if (benchType == 1) {
|
|
|
var childMesh = gltf.scene.children[0].children[0];
|
|
|
- let childMeshTmp = new THREE.Mesh(childMesh.geometry, childMesh.material)
|
|
|
+ let childMeshTmp = new THREE.Mesh(childMesh.geometry, childMesh.material);
|
|
|
let scale = 5;
|
|
|
childMeshTmp.scale.set(scale, scale, scale)
|
|
|
childMeshTmp.position.set(x, y, z)
|
|
|
var Euler = new THREE.Euler(Math.PI * ang_x, Math.PI * ang_y, Math.PI * ang_z);
|
|
|
var quaternion = new THREE.Quaternion();
|
|
|
- childMeshTmp.quaternion.copy(quaternion.setFromEuler(Euler))
|
|
|
+ childMeshTmp.quaternion.copy(quaternion.setFromEuler(Euler));
|
|
|
var customData = {
|
|
|
benchId: bench_id,
|
|
|
benchFlag: true,
|
|
@@ -227,17 +231,15 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
if (benchIdList.indexOf(Number(bench_id)) >= 0) {
|
|
|
if (!window.benchMeshMap[bench_id]) {
|
|
|
window.benchMeshMap[bench_id] = childMeshTmp;
|
|
|
- sdkInstance.sceneRenderer.scene.add(childMeshTmp)
|
|
|
-
|
|
|
+ sdkInstance.sceneRenderer.scene.add(childMeshTmp);
|
|
|
} else {
|
|
|
let deleteChildMesh = window.benchMeshMap[bench_id];
|
|
|
- sdkInstance.sceneRenderer.scene.remove(deleteChildMesh)
|
|
|
+ sdkInstance.sceneRenderer.scene.remove(deleteChildMesh);
|
|
|
deleteChildMesh.geometry.dispose(); // 清理几何体
|
|
|
deleteChildMesh.material.dispose(); // 清理材质
|
|
|
deleteChildMesh = null; // 置空指向该3D模型的变量
|
|
|
window.benchMeshMap[bench_id] = childMeshTmp;
|
|
|
sdkInstance.sceneRenderer.scene.add(childMeshTmp);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -381,6 +383,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
fbxLoader2.load("../models/mesh2Draco.gltf", function (gltf) {
|
|
|
console.log('22-old', Date.now());
|
|
|
fbxLoader2Loaded = true;
|
|
|
+ fbxMesh2 = gltf.scene.children[0];
|
|
|
let benchIdList = window.store.getters['benchList/getBenchList'].map(m => m.id);
|
|
|
let result = g_PosArrayResult;
|
|
|
for (var item of result) {
|
|
@@ -391,6 +394,10 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
let ang_y = 0.0;
|
|
|
let ang_z = 0.0;
|
|
|
let benchType = item.bench_type;
|
|
|
+ let card_id = item.card_id;
|
|
|
+ let bench_id = item.bench_id;
|
|
|
+ let bench_img = item.bench_img;
|
|
|
+ let show_remote_button = item.show_remote_button;
|
|
|
|
|
|
if (true) {
|
|
|
x = JSON.parse(JSON.stringify(item.fix_pos_x));
|
|
@@ -401,11 +408,6 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
|
|
|
}
|
|
|
|
|
|
- let card_id = item.card_id;
|
|
|
- let bench_id = item.bench_id;
|
|
|
- let show_remote_button = item.show_remote_button;
|
|
|
- let bench_img = item.bench_img;
|
|
|
-
|
|
|
if (benchType == 2) {
|
|
|
var childMesh = gltf.scene.children[0];
|
|
|
let childMeshTmp = new THREE.Mesh(childMesh.geometry, childMesh.material)
|
|
@@ -512,7 +514,6 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
// // }
|
|
|
// // }
|
|
|
|
|
|
-
|
|
|
// // x = xSubTmp;
|
|
|
// // y = ySubTmp;
|
|
|
// // z = zSubTmp;
|
|
@@ -564,35 +565,10 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
// }
|
|
|
// }
|
|
|
// };
|
|
|
- // // if (!sessionStorage.getItem('3dMode') || sessionStorage.getItem('3dMode') == 0) {
|
|
|
- // // if (!window.otherInterval) {
|
|
|
- // // window.otherInterval = setInterval(() => {
|
|
|
- // // if (window.uwbInstance) {
|
|
|
- // // clearInterval(window.otherInterval)
|
|
|
- // // for (var item of result) {
|
|
|
- // // var localPosition = new THREE.Vector3(item.fix_pos_x, item.fix_pos_y, item.fix_pos_z);
|
|
|
- // // var worldPosition = window.uwbInstance.convertLocalToWorld(localPosition);
|
|
|
- // // var pos = window.sdkInstance.getScreenPosition(worldPosition);
|
|
|
- // // window.benchPosList.push(
|
|
|
- // // {
|
|
|
- // // x: pos.x,
|
|
|
- // // y: pos.y,
|
|
|
- // // benchType: item.bench_type,
|
|
|
- // // benchId: item.bench_id,
|
|
|
- // // benchImg: item.bench_img,
|
|
|
- // // }
|
|
|
- // // )
|
|
|
- // // }
|
|
|
- // // window.showBenchPos(window.benchPosList);
|
|
|
- // // }
|
|
|
- // // }, 2 * 1000)
|
|
|
- // // }
|
|
|
- // // }
|
|
|
// console.log('23', Date.now());
|
|
|
// })
|
|
|
// });
|
|
|
|
|
|
-
|
|
|
// 加载模型3
|
|
|
console.log('31-old', Date.now())
|
|
|
var fbxLoader3 = new THREE.GLTFLoader();
|
|
@@ -602,6 +578,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
// console.log("控制台查看加载gltf文件返回的对象结构", gltf);
|
|
|
console.log('32-old', Date.now());
|
|
|
fbxLoader3Loaded = true;
|
|
|
+ fbxMesh3 = gltf.scene.children[0].children[0];
|
|
|
let benchIdList = window.store.getters['benchList/getBenchList'].map(m => m.id);
|
|
|
let result = g_PosArrayResult;
|
|
|
for (var item of result) {
|
|
@@ -612,6 +589,10 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
let ang_y = 0.0;
|
|
|
let ang_z = 0.0;
|
|
|
let benchType = item.bench_type;
|
|
|
+ let card_id = item.card_id;
|
|
|
+ let bench_id = item.bench_id;
|
|
|
+ let bench_img = item.bench_img;
|
|
|
+ let show_remote_button = item.show_remote_button;
|
|
|
|
|
|
if (true) {
|
|
|
x = JSON.parse(JSON.stringify(item.fix_pos_x));
|
|
@@ -622,10 +603,6 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
|
|
|
}
|
|
|
|
|
|
- let card_id = item.card_id;
|
|
|
- let bench_id = item.bench_id;
|
|
|
- let bench_img = item.bench_img;
|
|
|
- let show_remote_button = item.show_remote_button;
|
|
|
if (benchType == 3) {
|
|
|
// var childMesh = fbx.scene.children[0];
|
|
|
var childMesh = gltf.scene.children[0].children[0];
|
|
@@ -789,6 +766,33 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
// // console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
|
|
|
// })
|
|
|
// });
|
|
|
+
|
|
|
+ // console.log("3dMode", !sessionStorage.getItem('3dMode') || sessionStorage.getItem('3dMode') == 0)
|
|
|
+ if (!sessionStorage.getItem('3dMode') || sessionStorage.getItem('3dMode') == 0) {
|
|
|
+ let result = g_PosArrayResult;
|
|
|
+ if (!window.otherInterval) {
|
|
|
+ window.otherInterval = setInterval(() => {
|
|
|
+ if (window.uwbInstance) {
|
|
|
+ clearInterval(window.otherInterval)
|
|
|
+ for (var item of result) {
|
|
|
+ var localPosition = new THREE.Vector3(item.fix_pos_x, item.fix_pos_y, item.fix_pos_z);
|
|
|
+ var worldPosition = window.uwbInstance.convertLocalToWorld(localPosition);
|
|
|
+ var pos = window.sdkInstance.getScreenPosition(worldPosition);
|
|
|
+ window.benchPosList.push(
|
|
|
+ {
|
|
|
+ x: pos.x,
|
|
|
+ y: pos.y,
|
|
|
+ benchType: item.bench_type,
|
|
|
+ benchId: item.bench_id,
|
|
|
+ benchImg: item.bench_img,
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ window.showBenchPos(window.benchPosList);
|
|
|
+ }
|
|
|
+ }, 2 * 1000)
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -801,7 +805,7 @@ function getsqlDataRealTime() {
|
|
|
// console.log(fbxLoader1Loaded, fbxLoader2Loaded, fbxLoader3Loaded, fbxLoader1Loaded & fbxLoader2Loaded & fbxLoader3Loaded)
|
|
|
// 如果各台架模型已全部load完成
|
|
|
if (fbxLoader1Loaded & fbxLoader2Loaded & fbxLoader3Loaded) {
|
|
|
- console.log("oldStatus", oldStatus)
|
|
|
+ // console.log("oldStatus", oldStatus)
|
|
|
// var sqlstr = "select t3.* ,t4.fix_pos_x, t4.fix_pos_y, t4.fix_pos_z,t4.fix_angle_x, t4.fix_angle_y, t4.fix_angle_z, t4.bench_type, t4.bench_id, t4.bench_img, t4.use_fix_pos from (SELECT t1.* FROM his_location_tadiao_result_unity t1 INNER JOIN (SELECT MAX(loc_time) AS max_loc_time FROM his_location_tadiao_result_unity GROUP BY card_id) t2 ON t1.loc_time = t2.max_loc_time) as t3 INNER JOIN dat_bench_extend t4 ON (t4.card_id=t3.card_id)";
|
|
|
//sqlstr = sqlstr.format(two_seconds_ago, two_seconds_ago)
|
|
|
var sqlstr = "SELECT * FROM dat_bench_extend order by bench_id asc";
|
|
@@ -819,111 +823,123 @@ function getsqlDataRealTime() {
|
|
|
waterRefresh(result);
|
|
|
// 台架刷新逻辑
|
|
|
benchRefresh(result);
|
|
|
+ //
|
|
|
+ for (var item of result) {
|
|
|
+ let x = item.x;
|
|
|
+ let y = item.y;
|
|
|
+ let z = item.z;
|
|
|
+ let ang_x = 0.0;
|
|
|
+ let ang_y = 0.0;
|
|
|
+ let ang_z = 0.0;
|
|
|
+ let benchType = item.bench_type
|
|
|
+ let card_id = item.card_id;
|
|
|
+ let bench_id = item.bench_id;
|
|
|
+ let show_remote_button = item.show_remote_button;
|
|
|
+
|
|
|
+ if (item.use_fix_pos == 0) {
|
|
|
+ x = JSON.parse(JSON.stringify(item.x)) - 12.4;
|
|
|
+ y = JSON.parse(JSON.stringify(item.fix_pos_y));
|
|
|
+ z = 6.8 - JSON.parse(JSON.stringify(item.z));
|
|
|
+ ang_x = JSON.parse(JSON.stringify(item.fix_angle_x));
|
|
|
+ ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
|
|
|
+ ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
|
|
|
+ } else if (item.use_fix_pos == 1) {
|
|
|
+ x = JSON.parse(JSON.stringify(item.fix_pos_x));
|
|
|
+ y = JSON.parse(JSON.stringify(item.fix_pos_y));
|
|
|
+ z = JSON.parse(JSON.stringify(item.fix_pos_z));
|
|
|
+ ang_x = JSON.parse(JSON.stringify(item.fix_angle_x));
|
|
|
+ ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
|
|
|
+ ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
|
|
|
+ } else if (item.use_fix_pos == 2) {
|
|
|
+ var distance = 10000.0;
|
|
|
+ var xSubTmp = x;
|
|
|
+ var ySubTmp = y;
|
|
|
+ var zSubTmp = z;
|
|
|
+ x = x - 14.7;
|
|
|
+ z = y - 14;
|
|
|
+ var ang_xSubTmp = ang_x;
|
|
|
+ var ang_ySubTmp = ang_y;
|
|
|
+ var ang_zSubTmp = ang_z;
|
|
|
+ if (window.benchDBList) {
|
|
|
+ var iCount = 0;
|
|
|
+ for (var itemSub of window.benchDBList) {
|
|
|
+ iCount++;
|
|
|
+ var xSub = itemSub.x;
|
|
|
+ var ySub = itemSub.y;
|
|
|
+ var zSub = itemSub.z;
|
|
|
+ var ang_xSub = 0.0;
|
|
|
+ var ang_ySub = 0.0;
|
|
|
+ var ang_zSub = 0.0;
|
|
|
+ xSub = itemSub.fix_pos_x;
|
|
|
+ ySub = itemSub.fix_pos_y;
|
|
|
+ zSub = itemSub.fix_pos_z;
|
|
|
+ ang_xSub = itemSub.fix_angle_x;
|
|
|
+ ang_ySub = itemSub.fix_angle_y;
|
|
|
+ ang_zSub = itemSub.fix_angle_z;
|
|
|
+ var disTmp = Math.sqrt(Math.pow(x - xSub, 2) + Math.pow(z - zSub, 2))
|
|
|
+ if (disTmp < distance) {
|
|
|
+ distance = disTmp;
|
|
|
+ xSubTmp = xSub;
|
|
|
+ ySubTmp = ySub;
|
|
|
+ zSubTmp = zSub;
|
|
|
+ ang_xSubTmp = ang_xSub;
|
|
|
+ ang_ySubTmp = ang_ySub;
|
|
|
+ ang_zSubTmp = ang_zSub;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ x = xSubTmp;
|
|
|
+ y = ySubTmp;
|
|
|
+ z = zSubTmp;
|
|
|
+ ang_x = ang_xSubTmp;
|
|
|
+ ang_y = ang_ySubTmp;
|
|
|
+ ang_z = ang_zSubTmp;
|
|
|
+
|
|
|
+ x = JSON.parse(JSON.stringify(xSubTmp));
|
|
|
+ y = JSON.parse(JSON.stringify(ySubTmp));
|
|
|
+ z = JSON.parse(JSON.stringify(zSubTmp));
|
|
|
+ ang_x = JSON.parse(JSON.stringify(ang_xSubTmp));
|
|
|
+ ang_y = JSON.parse(JSON.stringify(ang_ySubTmp));
|
|
|
+ ang_z = JSON.parse(JSON.stringify(ang_zSubTmp));
|
|
|
|
|
|
- // for (var item of result) {
|
|
|
- // let x = item.x;
|
|
|
- // let y = item.y;
|
|
|
- // let z = item.z;
|
|
|
- // let ang_x = 0.0;
|
|
|
- // let ang_y = 0.0;
|
|
|
- // let ang_z = 0.0;
|
|
|
- // let benchType = item.bench_type
|
|
|
- // let card_id = item.card_id;
|
|
|
- // let bench_id = item.bench_id;
|
|
|
- // let show_remote_button = item.show_remote_button;
|
|
|
-
|
|
|
- // if (item.use_fix_pos == 0) {
|
|
|
- // x = JSON.parse(JSON.stringify(item.x));
|
|
|
- // y = JSON.parse(JSON.stringify(item.fix_pos_y));
|
|
|
- // z = JSON.parse(JSON.stringify(item.z));
|
|
|
- // ang_x = JSON.parse(JSON.stringify(item.fix_angle_x));
|
|
|
- // ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
|
|
|
- // ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
|
|
|
- // } else if (item.use_fix_pos == 1) {
|
|
|
- // x = JSON.parse(JSON.stringify(item.fix_pos_x));
|
|
|
- // y = JSON.parse(JSON.stringify(item.fix_pos_y));
|
|
|
- // z = JSON.parse(JSON.stringify(item.fix_pos_z));
|
|
|
- // ang_x = JSON.parse(JSON.stringify(item.fix_angle_x));
|
|
|
- // ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
|
|
|
- // ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
|
|
|
- // } else if (item.use_fix_pos == 2) {
|
|
|
- // var distance = 10000.0;
|
|
|
- // var xSubTmp = x;
|
|
|
- // var ySubTmp = y;
|
|
|
- // var zSubTmp = z;
|
|
|
- // x = x - 14.7;
|
|
|
- // z = y - 14;
|
|
|
- // var ang_xSubTmp = ang_x;
|
|
|
- // var ang_ySubTmp = ang_y;
|
|
|
- // var ang_zSubTmp = ang_z;
|
|
|
- // if (window.benchDBList) {
|
|
|
- // var iCount = 0;
|
|
|
- // for (var itemSub of window.benchDBList) {
|
|
|
- // iCount++;
|
|
|
- // var xSub = itemSub.x;
|
|
|
- // var ySub = itemSub.y;
|
|
|
- // var zSub = itemSub.z;
|
|
|
- // var ang_xSub = 0.0;
|
|
|
- // var ang_ySub = 0.0;
|
|
|
- // var ang_zSub = 0.0;
|
|
|
- // xSub = itemSub.fix_pos_x;
|
|
|
- // ySub = itemSub.fix_pos_y;
|
|
|
- // zSub = itemSub.fix_pos_z;
|
|
|
- // ang_xSub = itemSub.fix_angle_x;
|
|
|
- // ang_ySub = itemSub.fix_angle_y;
|
|
|
- // ang_zSub = itemSub.fix_angle_z;
|
|
|
- // var disTmp = Math.sqrt(Math.pow(x - xSub, 2) + Math.pow(z - zSub, 2))
|
|
|
- // if (disTmp < distance) {
|
|
|
- // distance = disTmp;
|
|
|
- // xSubTmp = xSub;
|
|
|
- // ySubTmp = ySub;
|
|
|
- // zSubTmp = zSub;
|
|
|
- // ang_xSubTmp = ang_xSub;
|
|
|
- // ang_ySubTmp = ang_ySub;
|
|
|
- // ang_zSubTmp = ang_zSub;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // x = xSubTmp;
|
|
|
- // y = ySubTmp;
|
|
|
- // z = zSubTmp;
|
|
|
- // ang_x = ang_xSubTmp;
|
|
|
- // ang_y = ang_ySubTmp;
|
|
|
- // ang_z = ang_zSubTmp;
|
|
|
-
|
|
|
- // x = JSON.parse(JSON.stringify(xSubTmp));
|
|
|
- // y = JSON.parse(JSON.stringify(ySubTmp));
|
|
|
- // z = JSON.parse(JSON.stringify(zSubTmp));
|
|
|
- // ang_x = JSON.parse(JSON.stringify(ang_xSubTmp));
|
|
|
- // ang_y = JSON.parse(JSON.stringify(ang_ySubTmp));
|
|
|
- // ang_z = JSON.parse(JSON.stringify(ang_zSubTmp));
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- // if (window.benchMeshMap[item.bench_id] && window.benchMeshWaterMap[item.bench_id]) {
|
|
|
-
|
|
|
- // if (item.use_fix_pos == 0) {
|
|
|
- // window.benchMeshMap[item.bench_id].position.set(x - 14.7, y, z - 14);
|
|
|
- // window.benchMeshWaterMap[item.bench_id].position.set(x - 14.7, y + 10, z - 14);
|
|
|
- // } else {
|
|
|
- // window.benchMeshMap[item.bench_id].position.set(x, y, z);
|
|
|
- // window.benchMeshWaterMap[item.bench_id].position.set(x, y + 10, z);
|
|
|
- // }
|
|
|
- // 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);
|
|
|
- // window.benchPosList.forEach(function (element) {
|
|
|
- // if (element.benchId == item.bench_id) {
|
|
|
- // element.x = pos.x
|
|
|
- // element.y = pos.y
|
|
|
- // element.benchType = item.bench_type
|
|
|
- // element.benchId = item.bench_id
|
|
|
- // element.benchImg = item.bench_img
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }
|
|
|
- // }
|
|
|
- // window.showBenchPos(window.benchPosList);
|
|
|
+ }
|
|
|
+
|
|
|
+ var localPosition = new THREE.Vector3(x, y, z);
|
|
|
+ var worldPosition = window.uwbInstance.convertLocalToWorld(localPosition);
|
|
|
+ var pos = window.sdkInstance.getScreenPosition(worldPosition);
|
|
|
+ window.benchPosList.forEach(function (element) {
|
|
|
+ if (element.benchId == item.bench_id) {
|
|
|
+ element.x = pos.x;
|
|
|
+ element.y = pos.y;
|
|
|
+ element.benchType = item.bench_type;
|
|
|
+ element.benchId = item.bench_id;
|
|
|
+ element.benchImg = item.bench_img;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // if (window.benchMeshMap[item.bench_id] && window.benchMeshWaterMap[item.bench_id]) {
|
|
|
+ // if (item.use_fix_pos == 0) {
|
|
|
+ // window.benchMeshMap[item.bench_id].position.set(x - 14.7, y, z - 14);
|
|
|
+ // window.benchMeshWaterMap[item.bench_id].position.set(x - 14.7, y + 10, z - 14);
|
|
|
+ // } else {
|
|
|
+ // window.benchMeshMap[item.bench_id].position.set(x, y, z);
|
|
|
+ // window.benchMeshWaterMap[item.bench_id].position.set(x, y + 10, z);
|
|
|
+ // }
|
|
|
+ // 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);
|
|
|
+ // window.benchPosList.forEach(function (element) {
|
|
|
+ // if (element.benchId == item.bench_id) {
|
|
|
+ // element.x = pos.x
|
|
|
+ // element.y = pos.y
|
|
|
+ // element.benchType = item.bench_type
|
|
|
+ // element.benchId = item.bench_id
|
|
|
+ // element.benchImg = item.bench_img
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ window.showBenchPos(window.benchPosList);
|
|
|
});
|
|
|
} else {
|
|
|
console.log("台架未初始化,等待下次刷新");
|
|
@@ -933,6 +949,7 @@ function getsqlDataRealTime() {
|
|
|
function waterRefresh(result) {
|
|
|
// console.log("刷新水滴")
|
|
|
let benchList = window.store ? window.store.getters['benchList/getBenchList'] : [];
|
|
|
+ let benchIdList = benchList.map(m => m.id);
|
|
|
let statusList = benchList.map(b => b.status).join();
|
|
|
if (statusList == oldStatus) { // 水滴无变化,只需移动原模型位置
|
|
|
// console.log("水滴状态无变化")
|
|
@@ -965,20 +982,20 @@ function waterRefresh(result) {
|
|
|
}
|
|
|
|
|
|
// let num = Math.floor((Math.random() * 10) + 1)
|
|
|
-
|
|
|
- // 查看对应的像素点
|
|
|
- // var localPosition = new THREE.Vector3(x, y, z);
|
|
|
- // var worldPosition = window.uwbInstance.convertLocalToWorld(localPosition);
|
|
|
- // var pos = window.sdkInstance.getScreenPosition(worldPosition);
|
|
|
- // console.log("转换的像素点位", pos)
|
|
|
-
|
|
|
- let benchIdList = benchList.map(m => m.id);
|
|
|
if (benchIdList.indexOf(Number(bench_id)) >= 0) {
|
|
|
// console.log('移动原水滴模型位置', bench_id)
|
|
|
- let mesh_temp = window.benchMeshWaterMap[bench_id]
|
|
|
- let uuid = mesh_temp.uuid
|
|
|
- // console.log('uuid', uuid)
|
|
|
- let meshChild = window.sdkInstance.sceneRenderer.scene.getObjectByProperty('uuid', uuid)
|
|
|
+ // var customData = {
|
|
|
+ // benchId: bench_id,
|
|
|
+ // benchFlag: false,
|
|
|
+ // bShowRemoteButton: false,
|
|
|
+ // type: 'water'
|
|
|
+ // };
|
|
|
+ // window.benchMeshWaterMap[bench_id].userData = customData;
|
|
|
+ window.benchMeshWaterMap[bench_id].position.set(x, y + 10, z);
|
|
|
+ // let meshTemp = window.benchMeshWaterMap[bench_id]
|
|
|
+ // let uuid = meshTemp.uuid
|
|
|
+ // // console.log('uuid', uuid)
|
|
|
+ // let meshChild = window.sdkInstance.sceneRenderer.scene.getObjectByProperty('uuid', uuid)
|
|
|
// var customData = {
|
|
|
// benchId: bench_id,
|
|
|
// benchFlag: false,
|
|
@@ -986,7 +1003,7 @@ function waterRefresh(result) {
|
|
|
// type: 'water'
|
|
|
// };
|
|
|
// meshChild.userData = customData;
|
|
|
- meshChild.position.set(x, y + 10, z);
|
|
|
+ // meshChild.position.set(x, y + 10, z);
|
|
|
}
|
|
|
}
|
|
|
} else { // 水滴变化,需移除原模型后重新添加新模型
|
|
@@ -1025,16 +1042,13 @@ function waterRefresh(result) {
|
|
|
// window.sdkInstance.sceneRenderer.scene.remove(window.benchMeshWaterMap[bench_id]);
|
|
|
let deleteChildMesh = window.benchMeshWaterMap[bench_id];
|
|
|
window.sdkInstance.sceneRenderer.scene.remove(deleteChildMesh)
|
|
|
-
|
|
|
deleteChildMesh.geometry.dispose(); // 清理几何体
|
|
|
deleteChildMesh.material.dispose(); // 清理材质
|
|
|
deleteChildMesh = null; // 置空指向该3D模型的变量
|
|
|
- // window.benchMeshWaterMap[bench_id] = childMeshTmp;
|
|
|
- // window.sdkInstance.sceneRenderer.scene.add(childMeshTmp);
|
|
|
+ delete window.benchMeshWaterMap[bench_id];
|
|
|
}
|
|
|
|
|
|
let currentBench = benchList.find(b => b.id == bench_id);
|
|
|
-
|
|
|
// 创建几何体
|
|
|
const geometry = new THREE.PlaneGeometry(1.2, 1.2);
|
|
|
// 创建材质
|
|
@@ -1092,7 +1106,6 @@ function waterRefresh(result) {
|
|
|
mesh.position.set(x, y + 10, z);
|
|
|
mesh.rotation.set(-Math.PI / 2, 0, 0);
|
|
|
|
|
|
- let benchIdList = benchList.map(m => m.id);
|
|
|
if (benchIdList.indexOf(Number(bench_id)) >= 0) {
|
|
|
window.benchMeshWaterMap[bench_id] = mesh;
|
|
|
window.sdkInstance.sceneRenderer.scene.add(mesh);
|
|
@@ -1108,11 +1121,136 @@ function benchRefresh(result) {
|
|
|
let newBenchIds = benchIdList.join();
|
|
|
if (newBenchIds == oldBenchIds) { // 台架无变化,只需移动原模型位置
|
|
|
// console.log("台架id无变动")
|
|
|
- // if (window.benchMeshMap[item.bench_id]) {
|
|
|
- // }
|
|
|
+ for (var item of result) {
|
|
|
+ let x = item.x;
|
|
|
+ let y = item.y;
|
|
|
+ let z = item.z;
|
|
|
+ let ang_x = 0.0;
|
|
|
+ let ang_y = 0.0;
|
|
|
+ let ang_z = 0.0;
|
|
|
+ let benchType = item.bench_type;
|
|
|
+ let card_id = item.card_id;
|
|
|
+ let bench_id = item.bench_id;
|
|
|
+ let show_remote_button = item.show_remote_button;
|
|
|
+
|
|
|
+ if (item.use_fix_pos == 0) {
|
|
|
+ x = JSON.parse(JSON.stringify(item.x)) - 12.4; // 页面原点x和实际原点(8号基站位置)x偏移量为 12.4m
|
|
|
+ y = JSON.parse(JSON.stringify(item.fix_pos_y));
|
|
|
+ z = 6.8 - JSON.parse(JSON.stringify(item.z)); // 页面原点y和实际原点(8号基站位置)y偏移量为 6.8m
|
|
|
+ ang_x = JSON.parse(JSON.stringify(item.fix_angle_x));
|
|
|
+ ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
|
|
|
+ ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
|
|
|
+ } else if (item.use_fix_pos == 1) {
|
|
|
+ x = JSON.parse(JSON.stringify(item.fix_pos_x));
|
|
|
+ y = JSON.parse(JSON.stringify(item.fix_pos_y));
|
|
|
+ z = JSON.parse(JSON.stringify(item.fix_pos_z));
|
|
|
+ ang_x = JSON.parse(JSON.stringify(item.fix_angle_x));
|
|
|
+ ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
|
|
|
+ ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (benchIdList.indexOf(Number(bench_id)) >= 0) {
|
|
|
+ console.log('移动原台架模型位置', bench_id)
|
|
|
+ window.benchMeshMap[bench_id].position.set(x, y + 10, z);
|
|
|
+ }
|
|
|
+ }
|
|
|
} else { // 台架变化,需移除原模型后重新添加新模型
|
|
|
// console.log("台架id变动")
|
|
|
oldBenchIds = newBenchIds;
|
|
|
+ // 请求到的新台架id
|
|
|
+
|
|
|
+ let new_bench_id_arr = []
|
|
|
+ benchList.forEach(function (item) {
|
|
|
+ new_bench_id_arr.push(item.id)
|
|
|
+ })
|
|
|
+ // console.log('新台架id', new_bench_id_arr)
|
|
|
+
|
|
|
+ // 旧存的台架id
|
|
|
+ let old_bench_id_arr = Object.keys(window.benchMeshMap);
|
|
|
+ // console.log('旧台架id', old_bench_id_arr)
|
|
|
+
|
|
|
+ // 要移除的台架id
|
|
|
+ let remove_bench_id_arr = old_bench_id_arr.filter(item => !new_bench_id_arr.includes(item))
|
|
|
+ // console.log('要移除的台架', remove_bench_id_arr)
|
|
|
+
|
|
|
+ if (remove_bench_id_arr.length > 0) {
|
|
|
+ // console.log('存在消失的台架,移除模型')
|
|
|
+ for (var bench_id of remove_bench_id_arr) {
|
|
|
+ let deleteChildMesh = window.benchMeshMap[bench_id];
|
|
|
+ window.sdkInstance.sceneRenderer.scene.remove(deleteChildMesh)
|
|
|
+ // deleteChildMesh.geometry.dispose(); // 清理几何体
|
|
|
+ // deleteChildMesh.material.dispose(); // 清理材质
|
|
|
+ deleteChildMesh = null; // 置空指向该3D模型的变量
|
|
|
+ delete window.benchMeshMap[bench_id];
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ for (var item of result) {
|
|
|
+ let x = item.x;
|
|
|
+ let y = item.y;
|
|
|
+ let z = item.z;
|
|
|
+ let ang_x = 0.0;
|
|
|
+ let ang_y = 0.0;
|
|
|
+ let ang_z = 0.0;
|
|
|
+ let benchType = item.bench_type;
|
|
|
+ let card_id = item.card_id;
|
|
|
+ let bench_id = item.bench_id;
|
|
|
+ let bench_img = item.bench_img;
|
|
|
+ let show_remote_button = item.show_remote_button;
|
|
|
+
|
|
|
+ if (item.use_fix_pos == 0) {
|
|
|
+ x = JSON.parse(JSON.stringify(item.x)) - 12.4; // 页面原点x和实际原点(8号基站位置)x偏移量为 12.4m
|
|
|
+ y = JSON.parse(JSON.stringify(item.fix_pos_y));
|
|
|
+ z = 6.8 - JSON.parse(JSON.stringify(item.z)); // 页面原点y和实际原点(8号基站位置)y偏移量为 6.8m
|
|
|
+ ang_x = JSON.parse(JSON.stringify(item.fix_angle_x));
|
|
|
+ ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
|
|
|
+ ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
|
|
|
+ } else if (item.use_fix_pos == 1) {
|
|
|
+ x = JSON.parse(JSON.stringify(item.fix_pos_x));
|
|
|
+ y = JSON.parse(JSON.stringify(item.fix_pos_y));
|
|
|
+ z = JSON.parse(JSON.stringify(item.fix_pos_z));
|
|
|
+ ang_x = JSON.parse(JSON.stringify(item.fix_angle_x));
|
|
|
+ ang_y = JSON.parse(JSON.stringify(item.fix_angle_y));
|
|
|
+ ang_z = JSON.parse(JSON.stringify(item.fix_angle_z));
|
|
|
+ }
|
|
|
+ if (benchIdList.indexOf(Number(bench_id)) >= 0) {
|
|
|
+ if (window.benchMeshMap[bench_id]) {
|
|
|
+ // console.log('已存在的台架,移动原模型位置', bench_id)
|
|
|
+ window.benchMeshMap[bench_id].position.set(x, y, z);
|
|
|
+ } else {
|
|
|
+ // console.log('不存在的台架,添加新模型', bench_id)
|
|
|
+ let childMeshTmp = new THREE.Mesh();
|
|
|
+ let scale = 1;
|
|
|
+ if (benchType == 1) {
|
|
|
+ childMeshTmp = new THREE.Mesh(fbxMesh1.geometry, fbxMesh1.material);
|
|
|
+ scale = 5;
|
|
|
+ } else if (benchType == 2) {
|
|
|
+ childMeshTmp = new THREE.Mesh(fbxMesh2.geometry, fbxMesh2.material)
|
|
|
+ scale = 0.05;
|
|
|
+ } else if (benchType == 3) {
|
|
|
+ childMeshTmp = new THREE.Mesh(fbxMesh3.geometry, fbxMesh3.material)
|
|
|
+ scale = 0.05;
|
|
|
+ } else {
|
|
|
+ console.log("未知的台架类型,bench_type=", benchType)
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ childMeshTmp.scale.set(scale, scale, scale);
|
|
|
+ childMeshTmp.position.set(x, y, z);
|
|
|
+ var Euler = new THREE.Euler(Math.PI * ang_x, Math.PI * ang_y, Math.PI * ang_z);
|
|
|
+ var quaternion = new THREE.Quaternion();
|
|
|
+ childMeshTmp.quaternion.copy(quaternion.setFromEuler(Euler));
|
|
|
+ var customData = {
|
|
|
+ benchId: bench_id,
|
|
|
+ benchFlag: true,
|
|
|
+ bShowRemoteButton: show_remote_button == 1 ? true : false,
|
|
|
+ benchImg: bench_img,
|
|
|
+ };
|
|
|
+ childMeshTmp.userData = customData;
|
|
|
+ sdkInstance.sceneRenderer.scene.add(childMeshTmp);
|
|
|
+ window.benchMeshMap[bench_id] = childMeshTmp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|