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 : https://jsfiddle.net/8kn4qrz0/

*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: *

Thank’s

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.position.set(0,0,20);
camera.lookAt(0,0,0);
camera.rotation.z += Math.PI/2
camera.updateProjectionMatrix();	
 }

To:

function rigth(){
camera.position.set(20,0,0);
controls.target.set(0,0,0);
controls.update();
}

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 controls.target.

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 ? https://jsfiddle.net/8kn4qrz0/

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.