I have a ThreeJS set up where the camera can move through a 3D world and while moving it will change its lookAt
multiple times. So let's assume that camera.getWorldDirection()
will always be more or less random.
Now I need the camera to move exactly left / right / up / down relative to camera.getWorldDirection()
.
You can't just use something like camera.position.x += 1
because that only applies for a world direction of Vector3(0, 0, -1)
. If the world direction changes to e.g. (1, -1, 0)
, moving the camera to the right does require changes in the X and the Z axis.
I had a look at quaternions and 4D matrices but I can't get my monkeybrain around them. Would be really nice if someone could help me out.
Here is a demo: https://normanwink.com/demo/room/