Rotate camera and Update orbitControl with the new camera rotation

Hello hello,

I’m trying to rotate a camera and to be able to continue to use orbit-control but from the new “point of view” of the camera.

My final objective is to have pre-configured views of an object : UP/DOWN/LEFT/RIGHT/FRONT/BACK

I get that orbitControl is overriding the camera rotation (Thank’s to discourse)
I succeed to apply the rotation to the camera when I do not call controls.update() but I would be able to use my controls after the rotations.

I tried to totally remove the controls before applying the rotation and then re-creating new controls but it’s the same effect my applied camera-rotation is “override”

Here a little fiddle to experiment :

*by the way if someone is able to explain to me why the controls in the jsfiddle is still working without controls.update() : it would be great :slight_smile: *


1 Like

i think you need to call controls.update() after you have set the camera, that is, every time you set it. this is what allows it to function afterwards.

*by the way if someone is able to explain to me why the controls in the jsfiddle is still working without controls.update() : it would be great :slight_smile: *

i could be totally mistaken but imo update is only needed for damping. if it just catches events off pointermove it probably doesn’t require manual update calls. but again, i this may have been the case, or not anymore, or not at all.

1 Like

And for autoRotate, as both of them are computed in .update().

Forgot about changes in camera rotation and position.

Change this function

function rigth(){
camera.rotation.z += Math.PI/2


function rigth(){

I don’t see anywhere controls getting disabled or over-ridded.

If you still having difficulty accomplishing your goal, a demo can be provided.

1 Like

Nice thank’s !

I get now the mechanism with

But there’s is something missing :
How can I do to have an effective :
camera.rotation.z += Math.PI/2

This is important to me (for the sphere it’s not significant but in my case it’s important)

you can do whatever you want with your camera, just call controls.update() after the operation.

Can you please show me from this fiddle if you know how to do ?

I do not succeed to keep the camera.rotation after controls.update() … :upside_down_face:

Is this what you after ( rotate camera 90° on its own z-axis )

If so. OrbitControls source has to be edited. This is a dirty hack which makes navigation almost impossible.

I suggest you rotate the mesh instead.

Why changing the camera rotation doesn’t work?

Must be called after any manual changes to the camera's transform.

From Docs, One would expect changing camera rotation and calling update() should change camera orientation. But in reality camera rotation is reverted back on the next time OrbitControls is engaged.

This is because, OrbitControls reset scale and rotation in the update function. This fact should be included in the Docs.



Just to let you know I found a better trick (I did not think about it before)

I created a second camera and I changed the rendered camera when selecting the correct view

1 Like

Thanks for this answer and explanation. I’ve been fussing with trying to hack together some controls all day that do this, the whole time thinking exactly what you said above (needless to say it has been a waste of time). The rotating model approach I have been going for, but I have this issue I can’t figure out, say you are animating the rotation of a model or object instead, how do you animate the rotation without having axis flipping issues when dealing with duplicate models with some offset between them?so, for example: animating object.rotation.x of the duplicate causes the z and y positions to flip, causing unwanted position changes on those axis. (something that would not be an issue otherwise if just one instance is being rendered – because the offset wouldn’t exist) Is there a way to avoid this? I This a very niche question, and probably deserves it’s own post, but thought it’s at least related so decided to ask here. EDIT: that eluded me for so long, but I figured it out. I was setting the y and z positions on the most outer group, not the inner group that directly parents the mesh! (sorry if that doesn’t make any sense.) so happy to have gotten to the bottom of that. Thanks for your insight, helped me find the answer.

1 Like

Sorry,I do not understand what you mean,Can you please show from the fiddle if you know how to do ?