Skip to content
Advertisement

OrbitControls on a shared camera cannot handle panning

I am trying to create two renderers on two different div containers. Each renderer wish has its own OrbitControls for updating the associated camera. The camera is shared between the two renderers.

The goal is to sync the camera for OrbitControl (so that two containers can have the same camera view) and render between the two render loops.

I noticed that the general rotation could be shared automatically. However, when I do panning, it behaves a bit strange. Here is a video:

https://user-images.githubusercontent.com/5498964/170499367-44c2581d-8089-492e-bc90-a6675976bb44.mov

This is the minimum reproducible code:

JavaScript

What is the reason and how could we achieve desired behavior?

Thank you!

Advertisement

Answer

The actual solution for this problem is to sync cameras and orbit control’s target explicitly as they change. See c1.addEventListener("change", () => { ... }} and c2.addEventListener("change", () => { ... }}.

Here is a complete code for solving the issue:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement