Multi-scene switching and interaction of mouse events !!!

My current requirement is multi-scene switching, and it has almost been completed, but when I switch to another scene while rotating the scene with the mouse in a certain scene, I find that the other scene is also rotating.

After testing, it was found that only the mouse and the canvas interact with each other, and their own animations do not affect each other

When I set camera.detachControl() to one of the scenes, I rotate the scene, of course the scene doesn’t rotate, but when I switch to the second scene, the second scene rotates.

Should I solve this problem?

Here is the PG Multi-scene switching

Probably you need to remove brackets around the engine
Change this and similar


and similar, otherwise I doubt if it works.

Is that mean I have to make the pre-scene stopRender every time when I switch scenes?
After the switchover succeeds, executed again ?


Essentially, yes. Your application code will need to manage which scene(s) are rendered every frame with the runRenderLoop call.
Part of the render loop involves going through cameras and updating them based on user input, so your issue may be that you’re not rendering/detaching the correct scenes?

I don’t know how you have set up the detach control, but for me it would be the way to go :
(only camera attached at start, not camera1)

switch (clicks % 2) {
    case 0: {
        camera.attachControl(canvas, true);
    case 1: {
        camera1.attachControl(canvas, true);

:arrow_right: Playground


1 Like

I think this is a common problem, it does separate the two scenarios, but it does affect each other

1 Like

It worked. Thank you. But two scenes with two cameras, why would they affect each other, I don’t understand that

Pleasure :slight_smile:

As soon as you “attach control” of a camera, it attaches control, regardless of which one is rendered, or whatever. Then the mouse will move all the cameras at the same time. In some cases it does make senses, when you are dealing with a multicamera setup, merged together in a specific way, but still you want them aligned with a single mouse

Okay, I pretend to understand hahaha ~Thank you all the same.

For example in that topic the user wanted to apply different post processing for different object, while postprocessing is per camera based.

In the given solution I’m using a double camera setup, but both are rendered in the same viewport, it’s not a matter of switching from a camera to another. Therefore we absolutely need both cameras to be rotated synchronously :slight_smile:

1 Like

Thank you for your patient answer. Learned :grinning:

1 Like