如何在某个轴上设置旋转

How to set rotation on a certain axis

我正在使用 FlyControl,我希望它始终让相机保持直立。如果我向下看,然后向左看,无论我向下看多远,整个视图都会倾斜。只是以某种方式设置欧拉顺序似乎并没有做到,因为它仍然搞砸了。我一直在努力研究这个问题,但我一无所获。

如何旋转相机使其竖直,但仍指向正确的方向?

主应用程序

camera.up = new THREE.Vector3( 0, 0, 1 );
camera.rotation.order = "ZYX";

FlyControl.js:

this.update = function( delta ) {

    var moveMult = delta * this.movementSpeed * this.movementSpeedMultiplier;
    var rotMult = delta * this.rollSpeed;

    var cur = this.object.rotation;

    this.object.translateX( this.moveVector.x * moveMult );
    this.object.translateY( this.moveVector.y * moveMult );
    this.object.translateZ( this.moveVector.z * moveMult );

    //this.tmpQuaternion.set( this.rotationVector.x * rotMult, this.rotationVector.y * rotMult, this.rotationVector.z * rotMult, 1 ).normalize();
    //this.object.quaternion.multiply( this.tmpQuaternion );
    //this.object.lookAt(this.object.getWorldDirection())
    this.object.rotation.set( cur.x + this.rotationVector.x * rotMult, /*cur.y + this.rotationVector.y * rotMult*/ 0,  cur.z + this.rotationVector.y * rotMult, cur.order );
    console.log(this.rotationVector);
    // expose the rotation vector for convenience
    //this.object.rotation.setFromQuaternion( this.object.quaternion, this.object.rotation.order );


};