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) //設置朝向
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模式下因痛,拖動物體苇本,并且物體始終看向相機搞疗,這個有一個問題是 當把物體拖動到后方的時候爱葵,物體沒有看向相機的位置倔丈,請大神指點一下 灰嫉,多謝
Three.js控制物體朝向郊酒,旋轉(zhuǎn)角度在使用Three.js開發(fā)應用中遇绞,我們經(jīng)常需要控制物體朝指定路徑移動,那么怎樣控制物體的朝向始終時朝著前方或者其他某個角度呢燎窘? 答案是使用四元數(shù)