var mtx = new THREE.Matrix4() ;
let curPos = new THREE.Vector3();
curPos.copy(intersection.position);
curPos.sub(new Vector3(-0.5,0,0));
mtx.lookAt(curPos, _this.getCameraPos() , intersection.up) //設(shè)置朝向
mtx.multiply(new THREE.Matrix4().makeRotationFromEuler(new THREE.Euler(0 , Math.PI , 0 )))
//獲取歐拉角
var toEuler = new THREE.Euler().setFromRotationMatrix(mtx);
var toRot = new THREE.Quaternion().setFromEuler(new THREE.Vector3(0,toEuler.y,0));
intersection.quaternion.slerp(toRot , 0.2)
let offset = new THREE.Vector3();
offset.copy(value.mInitialGrabOffset);
let objectPosition = inputEndPosition.add(offset.applyQuaternion(toRot));
// intersection.position.copy(objectPosition);
intersection.position.lerp(objectPosition,0.25);
這段代碼是在vr模式下昆庇,拖動物體找御,并且物體始終看向相機(jī)舅踪,這個有一個問題是 當(dāng)把物體拖動到后方的時候邪锌,物體沒有看向相機(jī)的位置,請大神指點(diǎn)一下 ,多謝
Three.js控制物體朝向,旋轉(zhuǎn)角度在使用Three.js開發(fā)應(yīng)用中拌蜘,我們經(jīng)常需要控制物體朝指定路徑移動,那么怎樣控制物體的朝向始終時朝著前方或者其他某個角度呢牙丽? 答案是使用四元數(shù)