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”
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 *
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.
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.
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.
might be a bit late to this, but i ran into a very similar issue where i wanted to rotate the camera itself that was already attached to orbit controls, and when calling update the camera’s rotation would be lost. stepped through the orbit controls code and the reason seems to be that it grabs a normalized up vector from the camera and uses that vector to orient the controls (meaning the camera always rotates around the Y Axis). you can change this vector by setting “camera.up” to a normal vector of your choice and then call update on the controls again. one caveat is that the camera cannot be directly in line with the Y axis or the orbit controls will experience gimbal lock. in the code below i solve this by modifying the up vector to the pos Z axis.
var q = control.getWorldQuaternion();
var upVec = new THREE.Vector3(0,1,0);
upVec.applyQuaternion(q);
if(camera.orientation === Orientation.Y) {
upVec = new THREE.Vector3(0,0,1);
upVec.applyQuaternion(q);
}
root.camera.up = upVec;
root.controls.update();