0

現在、three.js と pointerlockcontrols を使用して FPS を開発しています。

以下のコードを使用すると、任意の水平方向に撮影できます。

var direction = new THREE.Vector3( 0, 0, -1 );
var rotation = new THREE.Euler( 0, 0, 0, "XYZ" );
var cameraDirection = new THREE.Vector3(this.game.usermodel.root.children[0].position.x, this.game.usermodel.root.children[0].rotation._x, this.game.usermodel.root.children[0].position.z);
cameraDirection.copy( direction ).applyEuler( this.game.user.rotation );

var raycaster = new THREE.Raycaster(this.game.usermodel.root.children[0].position, cameraDirection); 

しかし、私のコードは y 軸を考慮していません。以下の行は、ピッチの回転を保持します。

this.game.usermodel.root.children[0].rotation._x

y 軸に沿って (任意の方向に垂直に) 撮影できるように、この値を適用するにはどうすればよいですか? 現在、弾丸は直線に沿って進んでいます。

よろしくお願いいたします。

4

2 に答える 2