Orbitcontrol changes camera position across multiple scenes

Hi,

I have a particular design where I have to switch between the 2D/3D representation of an engineering drawing.

The design is as follows:
1 THREE.WebglRenderer instance (It renders onto a single canvas)
2 THREE.Scene Objects instances(Each containing 2D/3D elements). Also, I have associated an Orthographic camera with the 2D scene and a Perspective camera with the 3D scene.
2 Orbitcontrol instances (One for each drawing type)

When I make a switch between 2D/3D I just change the parameters to the renderer.render function like this. This makes sure that I show the right scene every time.

renderer.render(currentScene,currentCamera)

Now, the issue that I see is that if I pan or rotate on the 2D scene and I switch over to 3D view I see that the camera has updated its position in 3D as well or vice versa,

What I am not able to understand is since the camera/orbit controls are independent to each drawing, how can the camera update that was done in one drawing affect the camera position/target in another?

Hope someone can help me with this.

Thanks
Srinivas

Have you tried to toggle the enabled property of the controls when you switch the scene/camera?

If both instances of OrbitControls are registered to the same DOM element (e.g. the renderer’s canvas), both will transform their camera unless you set enabled to false.

2 Likes

That’s it. It worked :slight_smile: Thank you Michael.