diff --git a/src/views/bim/bimHome/components/ThreeView2.vue b/src/views/bim/bimHome/components/ThreeView2.vue index ae33a9e..fced316 100644 --- a/src/views/bim/bimHome/components/ThreeView2.vue +++ b/src/views/bim/bimHome/components/ThreeView2.vue @@ -614,49 +614,52 @@ const changeMap = (img) => { } // 巡检 const check = () => { - console.log('照相机坐标', camera.position); - console.log('物体坐标', checkArr[checkindex].getWorldPosition(new THREE.Vector3())); - + let yn = 8, duration = 0; if (checkindex < checkArr.length ) { - // 显示标签 - addLabel(checkArr[checkindex], checkArr[checkindex].isPass); - - var checkPosition = checkArr[checkindex].getWorldPosition(new THREE.Vector3()); - gsap.to(camera.position, { - x: checkPosition.x, - y: checkPosition.y + 5.2, - z: checkPosition.z, - duration: 10, - ease: 'power1.inOut', - onComplete: () => { - - if (checkindex == checkArr.length - 1) { // 巡检结束 - checkComplete(); - } else { - check() - - } - } - }); - - let nextObj; - if (checkindex == checkArr.length - 1) { - nextObj = checkArr[0].getWorldPosition(new THREE.Vector3()) - } else if (checkindex < checkArr.length - 1) { - nextObj = checkArr[checkindex + 1].getWorldPosition(new THREE.Vector3()) + // 1,提前把下一个目标找到,转动镜头 + let nextObj;// 下一个目标 + if (checkindex == checkArr.length ) { + nextObj = checkArr[0].getWorldPosition(new THREE.Vector3()) } - + if(checkindex < checkArr.length) { + nextObj = checkArr[checkindex].getWorldPosition(new THREE.Vector3()) + } + if (checkindex === 0) { + duration = 0 + } else { + duration = 10 + } + // 2,转动镜头 gsap.to(controls.target, { x: nextObj.x, - y: nextObj.y + 5.2, + y: nextObj.y + yn, z: nextObj.z, - duration: 10, + duration: duration, ease: "power1.inOut", onComplete: () => { - + // 3,移动摄像机 + gsap.to(camera.position, { + x: nextObj.x, + y: nextObj.y + yn, + z: nextObj.z, + duration: 10, + ease: 'power1.inOut', + onComplete: () => { + // 显示标签,已经检查通过 + addLabel(checkArr[checkindex], checkArr[checkindex].isPass); + setTimeout(() => { + if (checkindex == checkArr.length) { // 巡检结束 + checkComplete(); + } else { + check() + + } + }, 2000) + checkindex++; + } + }); }, }); - checkindex++; } } // 巡检结束