I am in the process of creating a demonstration, and I'm facing an issue with moving the camera in my scene in the direction it is pointing. The concept is similar to pointer lock controls, but I need the camera to have the ability to move up, down, forward, backward, left, and right. Currently, I've been taking the camera's rotation and adding it to the position, but this method doesn't quite move the camera forward (relative to its perspective). It seems to be moving in an unexpected direction relative to the viewer, with the direction changing based on where you're looking. Here is the code snippet I've been using:
const rotation = this.internalCamera.rotation.toVector3();
const speed = 1;
this.internalCamera.position.add(
new Vector3(
rotation.x * speed,
rotation.y * speed,
rotation.z * speed
)
);
I suspect that the issue may lie within the spatial system in three.js, but I'm not entirely sure. Can someone help me identify what mistake I've made?