Hey, im using OrbitControls in a relatively messy project and I have a strange problem. I have two views: orthographic view from above (2D) and a perspective camera view (3D). After switching to 3D view, when zooming, it is zooming towards the center of the scene. When rotating, it is rotating around a adjusted vector value. How do I set the value for both? Or reset them. Im doing this when switching:
I dont really know where its coming from. I deleted each line where the controls.target is set or where controls.object.position/camera.position/camera.lookAt are set
Assuming you are using the current version of OrbitControls (r112) and that you haven’t modified it, what you described is not actually possible. As the camera target and pivot of rotation are coupled into the same variable orbitControls.target.
Can you create a minimal example of this taking place?
I am also going through the same problem. In my application, I intend to put the orbit target using the mouse click. while I am getting success in setting the target using mouse, I am able to rotate around that point, but when I am zooming in, it is zooming towards the center of the screen/scene but not towards the target that I set.
Check if you change the values of orbitcontrols.target or orbitcontrols.position/camera.position or camera.lookAt after each zoom/rotation and delete them.
Set it once or on a reset button or whatever. But not each second or frame call.
If you wanna find the bug you need to disable as much as possible and slowly enable the code part for part. So comment all the lines you think could affect orbitcontrols till it works normal, then uncomment them line for line.
Orbitcontrols has only 1 target to dolly/zoom. So it will be the same all the time. Unless you change the target at the wrong time.
Imagin having a scrollwheel event, that on scroll, will change the target.
Then on your mousedown event, you reset the target to initial value.
It will always rotate around the init value (center), but will scroll towards your changed value.