Ok, I will try and be as concise as possible. I am not very good with math and what might seem obvious to you will most likely be rocket science to me.
I am using Three.js w/CSS3DRenderer to create a virtual gallery space.
I need a first person perspective, like an FPS game.
I have gotten the camera to move forwards, backwards, left and right all successfully.
However, when I go to rotate the camera, I get the result
The camera is rotating its local axis, but what I need is for the viewport
, not the camera, to rotate, like
So what I need is for the camera to orbit around a pivot point/vector, and then refocus by using Object3d.lookAt()
I am aware that I can solve my problem by parenting the camera as a child of another object, and then rotating the axis of the object. However, I would rather do the math myself.
In short, I want to understand how to rotate one vector point around another, and how to represent that relationship mathematically.
I do not want to utilize a script, e.g., three.js pointer_lock controls, to get the job done. I want to get my hands dirty with the actual math.
Any advice or links to tutorials would be much appreciated!!!
Standard method is to create var camera_pivot = new object3D() to the same location as the object. Put camera as a child, move camera back to make observable distance and rotate the object.
You can move object3D() and rotate by your needs. It is optimal solution for easy code and for performance.
On object3D you can use camera_pivot.translateX(), camera_pivot.rotateX(), camera_pivot.lookAt(obj) etc...
Other-way is difficult to do any actions without affect on another object in the scene.