瓶中沙 2024-01-09 21:28:55 +08:00
parent 3339a3d389
commit d2ab5baea8
1 changed files with 18 additions and 85 deletions

View File

@ -78,7 +78,7 @@ let objM = [];
// //
let warnSets = []; let warnSets = [];
// //
let currentIndex = 0; let currentIndex = 1;
let romeObj = [] let romeObj = []
// //
let checkArr = []; let checkArr = [];
@ -173,16 +173,6 @@ const loadSence = () => {
yjobj.push(e); 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 = [{ const checkname = [{
@ -426,47 +416,6 @@ const centerSelectedGroup = (obj) => {
tween.start(); 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 = () => { const toHomeView = () => {
// //
@ -624,18 +573,6 @@ const xfadd = (obj, state) => {
} }
// //
const removexf = () => { 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); console.log(xfobj.length);
xfobj.forEach((o) => { xfobj.forEach((o) => {
// //
@ -677,11 +614,11 @@ const changeMap = (img) => {
} }
// //
const check = () => { const check = () => {
console.log('照相机坐标', camera.position);
if (currentIndex < romeObj.length) { console.log('物体坐标', checkArr[checkindex].getWorldPosition(new THREE.Vector3()));
// .getWorldPosition()
var checkPosition = checkArr[checkindex].getWorldPosition(new THREE.Vector3());
if (checkindex < checkArr.length ) {
var checkPosition = checkArr[checkindex].getWorldPosition(new THREE.Vector3());
gsap.to(camera.position, { gsap.to(camera.position, {
x: checkPosition.x, x: checkPosition.x,
y: checkPosition.y + 5.2, y: checkPosition.y + 5.2,
@ -689,23 +626,24 @@ const check = () => {
duration: 10, duration: 10,
ease: 'power1.inOut', ease: 'power1.inOut',
onComplete: () => { 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; let nextObj;
if (checkindex == checkArr.length - 1) { if (checkindex == checkArr.length - 1) {
nextObj = checkArr[0].getWorldPosition(new THREE.Vector3()) nextObj = checkArr[0].getWorldPosition(new THREE.Vector3())
return;
} else if (checkindex < checkArr.length - 1) { } else if (checkindex < checkArr.length - 1) {
nextObj = checkArr[checkindex + 1].getWorldPosition(new THREE.Vector3()) nextObj = checkArr[checkindex + 1].getWorldPosition(new THREE.Vector3())
} }
gsap.to(controls.target, { gsap.to(controls.target, {
x: nextObj.x, x: nextObj.x,
y: nextObj.y + 5.2, y: nextObj.y + 5.2,
@ -713,22 +651,17 @@ const check = () => {
duration: 10, duration: 10,
ease: "power1.inOut", ease: "power1.inOut",
onComplete: () => { onComplete: () => {
if (checkindex == romeObj.length) { //
checkComplete();
}
//
// addLabel(checkArr[checkindex], checkArr[checkindex].isPass);
}, },
}); });
checkindex++; checkindex++;
console.log('nextObj', checkindex)
} }
} }
// //
const checkComplete = () => { const checkComplete = () => {
toHomeView(); toHomeView();
bimStore().setCheckArr(romeObj); bimStore().setCheckArr(checkArr);
emit('checkComplete', romeObj); emit('checkComplete', checkArr);
return; return;
} }