i build a buttons in js that move the camera in rotation left and right and forward , but when i rotate the
the camera, and try to move forward, the forward motion not goes in the direction that the camera is facing, how can i fix this.
But maybe don’t create a object every time., reuse a Vector3 instead like this:
const direction = new THREE.Vector3;
let speed = 1.0;
function eventOrLoopOrSomething() {
camera.getWorldDirection(direction);
camera.position.addScaledVector(direction, speed);
}
i can move forward when i rotate the camera, but still cannot find solution to the issue when i rotate the camera
and try to move right or left or backward the direction is all off, its like the axe is not updating the camera rotation position,
any help will be appreciated
Not sure if it helps but I always create a Object3D instance where I want the camera and then parent this to something that is moving in the scene, then lerp the camera to the dummy and use lookAt to orientate the camera to a target. Not the same thing as what you are doing but maybe one possible work around https://codepen.io/nik-lever/pen/PrEvKb