diff --git a/src/views/bim/bimHome/components/ThreeView2.vue b/src/views/bim/bimHome/components/ThreeView2.vue index b8d7596..8879250 100644 --- a/src/views/bim/bimHome/components/ThreeView2.vue +++ b/src/views/bim/bimHome/components/ThreeView2.vue @@ -78,7 +78,7 @@ let objM = []; // 监测设备 let warnSets = []; // 设置漫游索引 -let currentIndex = 0; +let currentIndex = 1; let romeObj = [] // 设置巡检 let checkArr = []; @@ -173,16 +173,6 @@ const loadSence = () => { yjobj.push(e); } }) - // 设置漫游点位 - const objname = ['start', 'middle1', 'middle2', 'end'] - objname.forEach((item, index) => { - var targetModel = model.getObjectByName(item); - if (targetModel) romeObj.push( - targetModel - ) - console.log('targetModel', targetModel) - }) - // 漫游结束 // 获取巡检设备 const checkname = [{ @@ -426,47 +416,6 @@ const centerSelectedGroup = (obj) => { tween.start(); } -// 漫游 -const roam = () => { - if (currentIndex < romeObj.length) { - console.log('照相机坐标', camera.position); - console.log('物体坐标', romeObj[currentIndex].getWorldPosition(new THREE.Vector3())); - - - var nextPosition = romeObj[currentIndex].getWorldPosition(new THREE.Vector3()); - // 在动画完成后触发下一个漫游 - gsap.to(camera.position, { - x: nextPosition.x, - y: nextPosition.y + 2.2, - z: nextPosition.z, - duration: 10, - ease: 'power1.inOut', - onComplete: () => { - roam() - } - }); - - let lookObj; - if (currentIndex == romeObj.length - 1) { - lookObj = romeObj[0].getWorldPosition(new THREE.Vector3()) - } else if (currentIndex < romeObj.length) { - lookObj = romeObj[currentIndex + 1].getWorldPosition(new THREE.Vector3()) - } - gsap.to(controls.target, { - x: lookObj.x, - y: lookObj.y + 2.2, - z: lookObj.z, - duration: 10, - - ease: "power1.inOut", - onComplete: () => { }, - }); - currentIndex++; - console.log('lookObj', currentIndex) - } else { - toHomeView(); - } -} // 返回初始值 const toHomeView = () => { // 清除选中框 @@ -624,18 +573,6 @@ const xfadd = (obj, state) => { } // 移除消防标签 const removexf = () => { - // model.traverse(e => { - // if (e.isMesh && e.children.length > 0) { - // e.remove(e.children[0]) - // } else { - // e.traverse(o => { - // if (o.isMesh && o.children.length > 0) { - // o.remove(o.children[0]) - // } - // }) - - // } - // }) console.log(xfobj.length); xfobj.forEach((o) => { // 倒序 @@ -677,11 +614,11 @@ const changeMap = (img) => { } // 巡检 const check = () => { - - if (currentIndex < romeObj.length) { - // .getWorldPosition()属性需要用三维向量表示摸个坐标后方可读取 - var checkPosition = checkArr[checkindex].getWorldPosition(new THREE.Vector3()); + console.log('照相机坐标', camera.position); + console.log('物体坐标', checkArr[checkindex].getWorldPosition(new THREE.Vector3())); + if (checkindex < checkArr.length ) { + var checkPosition = checkArr[checkindex].getWorldPosition(new THREE.Vector3()); gsap.to(camera.position, { x: checkPosition.x, y: checkPosition.y + 5.2, @@ -689,23 +626,24 @@ const check = () => { duration: 10, ease: 'power1.inOut', onComplete: () => { - check() + // 显示标签,已经检查通过 + addLabel(checkArr[checkindex], checkArr[checkindex].isPass); + if (checkindex == checkArr.length - 1) { // 巡检结束 + checkComplete(); + } else { + check() + + } } }); - var pos1 = new THREE.Vector3( camera.position ); - console.log(12354, pos1); - var pos2 = new THREE.Vector3( checkPosition ); - console.log(54321, pos2); - var distance = pos1.distanceTo(pos2); - console.log(0, distance); - + let nextObj; if (checkindex == checkArr.length - 1) { nextObj = checkArr[0].getWorldPosition(new THREE.Vector3()) - return; } else if (checkindex < checkArr.length - 1) { nextObj = checkArr[checkindex + 1].getWorldPosition(new THREE.Vector3()) } + gsap.to(controls.target, { x: nextObj.x, y: nextObj.y + 5.2, @@ -713,22 +651,17 @@ const check = () => { duration: 10, ease: "power1.inOut", onComplete: () => { - if (checkindex == romeObj.length) { // 巡检结束 - checkComplete(); - } - // 显示标签,已经检查通过 - // addLabel(checkArr[checkindex], checkArr[checkindex].isPass); + }, }); checkindex++; - console.log('nextObj', checkindex) } } // 巡检结束 const checkComplete = () => { toHomeView(); - bimStore().setCheckArr(romeObj); - emit('checkComplete', romeObj); + bimStore().setCheckArr(checkArr); + emit('checkComplete', checkArr); return; }