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控制物体朝向,旋转角度在使用Three.js开发应用中,我们经常需要控制物体朝指定路径移动,那么怎样控制物体的朝向始终时朝着前方或者其他某个角度呢? 答案是使用四元数