In my animate() function I have the following code:
if (this.controls.forward) {
// move in direction we look at
var cameraDirectionVector = new THREE.Vector3(0, 0, -1);
cameraDirectionVector.applyQuaternion(this.camera.quaternion);
var angle = cameraDirectionVector.angleTo(this.characterMesh.position);
this.characterMesh.translateOnAxis(cameraDirectionVector.cross(this.characterMesh.position), moveDistance);
this.characterMesh.translateZ(-moveDistance);
}
if (this.controls.backward) {
this.characterMesh.translateZ(moveDistance);
}
The camera is a child of the characterMesh. Moving foreward and backward works perfectly. But I want to move (on a plane) where I am actually looking (just yaw). I found a code example for Unity3D and try to adapt it for three.js which did not work.
Any help or hints would be very much appreciated!