|
@@ -47,7 +47,6 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
};
|
|
|
// 触发事件进行从服务器获取数据
|
|
|
window.vm.$socket.emit("REPT", msg, (datas) => {
|
|
|
- // debugger
|
|
|
g_PosArrayResult = datas.data;
|
|
|
window.benchDBList = datas.data;
|
|
|
var now = new Date();
|
|
@@ -60,6 +59,8 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
|
|
|
{
|
|
|
let result = g_PosArrayResult;
|
|
|
+
|
|
|
+ console.log('添加水滴start',Date.now())
|
|
|
for (var item of result) {
|
|
|
let x = item.x;
|
|
|
let y = item.y;
|
|
@@ -172,9 +173,9 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
|
|
|
// 创建精灵对象
|
|
|
const geometry = new THREE.PlaneGeometry(1.2, 1.2);
|
|
|
- let spriteMaterial = new THREE.SpriteMaterial({
|
|
|
- map: texture
|
|
|
- });
|
|
|
+ // let spriteMaterial = new THREE.SpriteMaterial({
|
|
|
+ // map: texture
|
|
|
+ // });
|
|
|
let uniformsA = {
|
|
|
amplitude: { value: 1.0 },
|
|
|
color: { value: new THREE.Color(0xff2200) },
|
|
@@ -198,7 +199,7 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
side: THREE.DoubleSide,
|
|
|
transparent: true
|
|
|
})
|
|
|
- let sprite = new THREE.Sprite(spriteMaterial);
|
|
|
+ // let sprite = new THREE.Sprite(spriteMaterial);
|
|
|
|
|
|
const mesh = new THREE.Mesh(geometry, shaderMaterial);
|
|
|
var customData = {
|
|
@@ -214,127 +215,259 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
window.waterMap[bench_id] = mesh;
|
|
|
if (sdkInstance) {
|
|
|
if (benchIdList.indexOf(Number(bench_id)) > 0) {
|
|
|
- if (window.benchMeshWaterMap[bench_id]) {
|
|
|
window.benchMeshWaterMap[bench_id] = mesh;
|
|
|
sdkInstance.sceneRenderer.scene.add(mesh)
|
|
|
- }
|
|
|
- else {
|
|
|
- window.benchMeshWaterMap[bench_id] = mesh;
|
|
|
- }
|
|
|
+ // if (window.benchMeshWaterMap[bench_id]) {
|
|
|
+ // console.log(window.benchMeshWaterMap[bench_id])
|
|
|
+ // window.benchMeshWaterMap[bench_id] = mesh;
|
|
|
+ // sdkInstance.sceneRenderer.scene.add(mesh)
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // console.log(window.benchMeshWaterMap[bench_id])
|
|
|
+ // window.benchMeshWaterMap[bench_id] = mesh;
|
|
|
+ // }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
};
|
|
|
+ console.log('添加水滴end',Date.now())
|
|
|
}
|
|
|
|
|
|
let dracoLoader = new THREE.DRACOLoader();
|
|
|
THREE.DRACOLoader.setDecoderPath("../gltf/");
|
|
|
|
|
|
- var fbxLoader1 = new THREE.GLTFLoader();
|
|
|
- fbxLoader1.setDRACOLoader(dracoLoader);
|
|
|
- if (!fbxLoader1Loaded) {
|
|
|
- fbxLoader1.load("../models/meshDraco.gltf", function (fbx) {
|
|
|
- console.log('loadzmg')
|
|
|
- let benchIdList = window.store.getters['benchList/getBenchList'].map(m => m.id);
|
|
|
- //fbxLoader1Loaded = true;
|
|
|
- let result = g_PosArrayResult;
|
|
|
- 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
|
|
|
- //if (item.use_fix_pos == 1) {
|
|
|
- if (true) {
|
|
|
- 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 {
|
|
|
- }
|
|
|
+ new DBUtil().get('../models/meshDraco.gltf',(progress) => {
|
|
|
+ // console.log(progress)
|
|
|
+ }).then((blob) => {
|
|
|
+ var fbxLoader1 = new THREE.GLTFLoader();
|
|
|
+ fbxLoader1.setDRACOLoader(dracoLoader);
|
|
|
+ let url = URL.createObjectURL(new Blob([blob]));
|
|
|
+ console.log(11, Date.now())
|
|
|
+ fbxLoader1.load(url, function (gltf) {
|
|
|
+ console.log(12, Date.now())
|
|
|
+ let benchIdList = window.store.getters['benchList/getBenchList'].map(m => m.id);
|
|
|
+ //fbxLoader1Loaded = true;
|
|
|
+ let result = g_PosArrayResult;
|
|
|
+ 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
|
|
|
+ //if (item.use_fix_pos == 1) {
|
|
|
+ if (true) {
|
|
|
+ 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 {
|
|
|
+ }
|
|
|
|
|
|
- var distance = 10000.0;
|
|
|
-
|
|
|
- var xSubTmp = x;
|
|
|
- var ySubTmp = y;
|
|
|
- var zSubTmp = z;
|
|
|
- var ang_xSubTmp = ang_x;
|
|
|
- var ang_ySubTmp = ang_y;
|
|
|
- var ang_zSubTmp = ang_z;
|
|
|
-
|
|
|
- if (g_PosArrayResult) {
|
|
|
- var iCount = 0;
|
|
|
- for (var itemSub of g_PosArrayResult) {
|
|
|
-
|
|
|
- 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(y - ySub, 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;
|
|
|
+ var distance = 10000.0;
|
|
|
+
|
|
|
+ var xSubTmp = x;
|
|
|
+ var ySubTmp = y;
|
|
|
+ var zSubTmp = z;
|
|
|
+ var ang_xSubTmp = ang_x;
|
|
|
+ var ang_ySubTmp = ang_y;
|
|
|
+ var ang_zSubTmp = ang_z;
|
|
|
+
|
|
|
+ if (g_PosArrayResult) {
|
|
|
+ var iCount = 0;
|
|
|
+ for (var itemSub of g_PosArrayResult) {
|
|
|
+
|
|
|
+ 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(y - ySub, 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));
|
|
|
-
|
|
|
- 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 = fbx.scene.children[0].children[0];
|
|
|
- let childMeshTmp = new THREE.Mesh(childMesh.geometry, childMesh.material)
|
|
|
- let scale = 5;
|
|
|
- childMeshTmp.scale.set(scale, scale, scale)
|
|
|
- //fbx.scene.children[0].scale.set(5, 5, 5)
|
|
|
- //fbx.scene.children[0].position.set(8.7, -1.6, 5.4)
|
|
|
- childMeshTmp.position.set(x, y, z)
|
|
|
- var Euler = new THREE.Euler(Math.PI * ang_x, Math.PI * ang_y, Math.PI * ang_z);
|
|
|
- //var Euler = new THREE.Euler( Math.PI*1.5, Math.PI*0, Math.PI*0);
|
|
|
- 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;
|
|
|
- if (benchIdList.indexOf(Number(bench_id)) > 0) {
|
|
|
+ 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));
|
|
|
+
|
|
|
+ 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 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))
|
|
|
+ var customData = {
|
|
|
+ benchId: bench_id,
|
|
|
+ benchFlag: true,
|
|
|
+ bShowRemoteButton: show_remote_button == 1 ? true : false,
|
|
|
+ benchImg: bench_img,
|
|
|
+ };
|
|
|
+ childMeshTmp.userData = customData;
|
|
|
+ if (benchIdList.indexOf(Number(bench_id)) > 0) {
|
|
|
+ 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);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ console.log("全部台架加载完成", Date.now())
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ new DBUtil().get('../models/mesh2Draco.gltf',(progress) => {
|
|
|
+ // console.log(progress)
|
|
|
+ }).then((blob) => {
|
|
|
+ var fbxLoader2 = new THREE.GLTFLoader();
|
|
|
+ fbxLoader2.setDRACOLoader(dracoLoader);
|
|
|
+ let url = URL.createObjectURL(new Blob([blob]));
|
|
|
+ console.log(12, Date.now())
|
|
|
+ fbxLoader2.load(url, function (gltf) {
|
|
|
+ console.log('22', Date.now())
|
|
|
+ let result = g_PosArrayResult;
|
|
|
+ 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
|
|
|
+ //if (item.use_fix_pos == 1) {
|
|
|
+ if (true) {
|
|
|
+ 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 {
|
|
|
+ }
|
|
|
+
|
|
|
+ var distance = 10000.0;
|
|
|
+
|
|
|
+ var xSubTmp = x;
|
|
|
+ var ySubTmp = y;
|
|
|
+ var zSubTmp = z;
|
|
|
+ var ang_xSubTmp = ang_x;
|
|
|
+ var ang_ySubTmp = ang_y;
|
|
|
+ var ang_zSubTmp = ang_z;
|
|
|
+
|
|
|
+ if (g_PosArrayResult) {
|
|
|
+ var iCount = 0;
|
|
|
+ for (var itemSub of g_PosArrayResult) {
|
|
|
+
|
|
|
+ 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(y - ySub, 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));
|
|
|
+
|
|
|
+ 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)
|
|
|
+ let scale = 0.05;
|
|
|
+ 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;
|
|
|
+
|
|
|
if (!window.benchMeshMap[bench_id]) {
|
|
|
window.benchMeshMap[bench_id] = childMeshTmp;
|
|
|
sdkInstance.sceneRenderer.scene.add(childMeshTmp)
|
|
@@ -349,179 +482,43 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
sdkInstance.sceneRenderer.scene.add(childMeshTmp);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- var fbxLoader2 = new THREE.GLTFLoader();
|
|
|
- fbxLoader2.setDRACOLoader(dracoLoader);
|
|
|
- if (!fbxLoader2Loaded) {
|
|
|
- fbxLoader2.load("../models/mesh2Draco.gltf", function (fbx) {
|
|
|
- //fbxLoader2Loaded = true;
|
|
|
- let result = g_PosArrayResult;
|
|
|
- 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
|
|
|
- //if (item.use_fix_pos == 1) {
|
|
|
- if (true) {
|
|
|
- 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 {
|
|
|
- }
|
|
|
-
|
|
|
- var distance = 10000.0;
|
|
|
-
|
|
|
- var xSubTmp = x;
|
|
|
- var ySubTmp = y;
|
|
|
- var zSubTmp = z;
|
|
|
- var ang_xSubTmp = ang_x;
|
|
|
- var ang_ySubTmp = ang_y;
|
|
|
- var ang_zSubTmp = ang_z;
|
|
|
-
|
|
|
- if (g_PosArrayResult) {
|
|
|
- var iCount = 0;
|
|
|
- for (var itemSub of g_PosArrayResult) {
|
|
|
-
|
|
|
- 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(y - ySub, 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));
|
|
|
-
|
|
|
- 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 = fbx.scene.children[0];
|
|
|
- let childMeshTmp = new THREE.Mesh(childMesh.geometry, childMesh.material)
|
|
|
- let scale = 0.05;
|
|
|
- childMeshTmp.scale.set(scale, scale, scale)
|
|
|
- //fbx.scene.children[0].scale.set(5, 5, 5)
|
|
|
- //fbx.scene.children[0].position.set(8.7, -1.6, 5.4)
|
|
|
- childMeshTmp.position.set(x, y, z)
|
|
|
- var Euler = new THREE.Euler(Math.PI * ang_x, Math.PI * ang_y, Math.PI * ang_z);
|
|
|
- //var Euler = new THREE.Euler( Math.PI*1.5, Math.PI*0, Math.PI*0);
|
|
|
- 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;
|
|
|
-
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- if (!sessionStorage.getItem('3dMode') || sessionStorage.getItem('3dMode') == 0) {
|
|
|
- if(!window.otherInterval)
|
|
|
- {
|
|
|
- window.otherInterval = setInterval(() => {
|
|
|
- if (window.uwbInstance)
|
|
|
- {
|
|
|
- clearInterval(window.otherInterval)
|
|
|
- //var benchPosList = [];
|
|
|
- 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,
|
|
|
- }
|
|
|
- )
|
|
|
+ };
|
|
|
+ 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);
|
|
|
}
|
|
|
- window.showBenchPos(window.benchPosList);
|
|
|
- //setInterval(()=>{
|
|
|
- // getsqlDataRealTime();
|
|
|
- //},60*1000)
|
|
|
- }
|
|
|
- }, 2 * 1000)
|
|
|
+ }, 2 * 1000)
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- // var fbxLoader3 = new THREE.GLTFLoader();
|
|
|
- // fbxLoader3.setDRACOLoader(dracoLoader);
|
|
|
+ })
|
|
|
+ })
|
|
|
|
|
|
new DBUtil().get('../models/mesh3Draco.gltf',(progress) => {
|
|
|
- console.log(progress)
|
|
|
+ // console.log(progress)
|
|
|
}).then((blob) => {
|
|
|
- console.log('getModel获取成功', blob);
|
|
|
var fbxLoader3 = new THREE.GLTFLoader();
|
|
|
fbxLoader3.setDRACOLoader(dracoLoader);
|
|
|
let url = URL.createObjectURL(new Blob([blob]));
|
|
|
fbxLoader3.load(url, function (gltf) {
|
|
|
- console.log("================================================")
|
|
|
- console.log(gltf)
|
|
|
let benchIdList = window.store.getters['benchList/getBenchList'].map(m => m.id);
|
|
|
let result = g_PosArrayResult;
|
|
|
for (var item of result) {
|
|
@@ -632,131 +629,15 @@ function getsqlData(sdkInstance, uwbInstance, bAddModel) {
|
|
|
};
|
|
|
// model.add(gltf.scene);
|
|
|
}, function ( xhr ) {
|
|
|
- console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
|
|
|
+ // console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- // if (!fbxLoader3Loaded) {
|
|
|
- // fbxLoader3.load("../models/mesh3Draco.gltf", function (fbx) {
|
|
|
- // console.log('1loadzmg211111111111111111111')
|
|
|
- // let benchIdList = window.store.getters['benchList/getBenchList'].map(m => m.id);
|
|
|
- // let result = g_PosArrayResult;
|
|
|
- // 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
|
|
|
- // if (true) {
|
|
|
- // 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));
|
|
|
- // }
|
|
|
- // var distance = 10000.0;
|
|
|
- // var xSubTmp = x;
|
|
|
- // var ySubTmp = y;
|
|
|
- // var zSubTmp = z;
|
|
|
- // var ang_xSubTmp = ang_x;
|
|
|
- // var ang_ySubTmp = ang_y;
|
|
|
- // var ang_zSubTmp = ang_z;
|
|
|
-
|
|
|
- // if (g_PosArrayResult) {
|
|
|
- // var iCount = 0;
|
|
|
- // for (var itemSub of g_PosArrayResult) {
|
|
|
- // 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(y - ySub, 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));
|
|
|
-
|
|
|
- // 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) {
|
|
|
- // console.log("控制台查看加载gltf文件返回的对象结构", fbx);
|
|
|
- // var childMesh = fbx.scene.children[0].children[0];
|
|
|
- // // var childMesh = fbx.scene.children[0];
|
|
|
- // let childMeshTmp = new THREE.Mesh(childMesh.geometry, childMesh.material)
|
|
|
- // let scale = 0.1;
|
|
|
- // childMeshTmp.scale.set(scale, scale, scale)
|
|
|
- // //fbx.scene.children[0].scale.set(5, 5, 5)
|
|
|
- // //fbx.scene.children[0].position.set(8.7, -1.6, 5.4)
|
|
|
- // childMeshTmp.position.set(x, y, z)
|
|
|
- // var Euler = new THREE.Euler(Math.PI * ang_x, Math.PI * ang_y, Math.PI * ang_z);
|
|
|
- // //var Euler = new THREE.Euler( Math.PI*1.5, Math.PI*0, Math.PI*0);
|
|
|
- // 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;
|
|
|
- // if (benchIdList.indexOf(Number(bench_id)) > 0) {
|
|
|
- // 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);
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // }
|
|
|
-
|
|
|
- // };
|
|
|
- // })
|
|
|
- // }
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+
|
|
|
function getsqlDataRealTime() {
|
|
|
if (true) {
|
|
|
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)";
|
|
@@ -972,6 +853,7 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
|
|
|
}
|
|
|
|
|
|
sdkInstance.on("endLoading", (mode) => {
|
|
|
+ console.log('房间加载end',Date.now())
|
|
|
console.log('endLoading')
|
|
|
vrBgContainer.style.display = "none";
|
|
|
|
|
@@ -1006,7 +888,7 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
|
|
|
sdkInstance.sceneRenderer.scene.add(pointLight); //将点光源添加至场景
|
|
|
|
|
|
if (g_fbxLoader == null) {
|
|
|
- g_fbxLoader = new THREE.GLTFLoader();
|
|
|
+ // g_fbxLoader = new THREE.GLTFLoader();
|
|
|
// g_fbxLoader.load("../models/mesh2.gltf", function (fbx) {
|
|
|
// let ambientLight = new THREE.AmbientLight(0xffffff); //设置环境光
|
|
|
// sdkInstance.sceneRenderer.scene.add(ambientLight); //将环境光添加到场景中
|
|
@@ -1038,7 +920,7 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
|
|
|
return;
|
|
|
}
|
|
|
oldStatus = statusList;
|
|
|
- getsqlData(sdkInstance, uwbInstance, false)
|
|
|
+ // getsqlData(sdkInstance, uwbInstance, false)
|
|
|
}
|
|
|
}, 6 * 1000);
|
|
|
}
|
|
@@ -1079,6 +961,8 @@ export function uwbMain(domId, modelWidth, modelHeight, finalMode, callback) {
|
|
|
if (box) {
|
|
|
sdkInstance.sceneRenderer.scene.remove(box);
|
|
|
}
|
|
|
+ console.log(m);
|
|
|
+ console.log("==============查看m对象===============")
|
|
|
window.handleBenchClick(m.object.userData.benchId, m.object.userData.bShowRemoteButton)
|
|
|
box = new THREE.BoxHelper(m.object, '#ff0000'); //object 模型
|
|
|
sdkInstance.sceneRenderer.scene.add(box)
|