# Multi-Camera controls

**URL:** <https://forum.babylonjs.com/t/multi-camera-controls/8462>\
**Category:** Questions\
**Created:** [February 6, 2020, 11:04pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462 "2020-02-06T23:04:15Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![kzaky](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@kzaky](https://forum.babylonjs.com/u/kzaky)\
**Post date:** [February 6, 2020, 11:04pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/1 "2020-02-06T23:04:15Z")

</div>

Hey guys,

I have 2 camera for the same scene.  
Camera1 covers full screen viewport and faces a lot of meshes.  
Camera2 is a mini-sized compass that is facing an axis mesh somewhere in the scene (far from where camera1 is pointing).

How can I make it so that Camera2 is infront of the meshes in camera1? This disables the clickable action manager meshes from camera1.  
I want to make camera2 to be in the front of activecamera and have the meshes remain clickable.

Is there a better alternative to creating a mini corner axis compass than having multiple camera?

Thanks

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 7, 2020, 5:48pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/2 "2020-02-07T17:48:28Z")

</div>

Hey!

I will recommend using two scenes 🙂 Onf or your main scene and a second one for your compass: [Use Multiple Scenes - Babylon.js Documentation](https://doc.babylonjs.com/how_to/multi_scenes)

---

<div class="post-metadata">

**Author:** ![kzaky](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@kzaky](https://forum.babylonjs.com/u/kzaky)\
**Post date:** [February 7, 2020, 6:15pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/3 "2020-02-07T18:15:35Z")

</div>

Thank you! if both scenes have their own listener, will they both be utilizable in respect to their sizes? I tried to add onPointerObservable click to each scene and it seems to trigger both despite having one of the scene having smaller camera viewport.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 7, 2020, 6:25pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/4 "2020-02-07T18:25:10Z")

</div>

Yes they will both listen to canvas events. You can call scene.attachControl() / detachControl() when you want based on where the user click

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 7, 2020, 6:26pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/5 "2020-02-07T18:26:59Z")

</div>

what you can do still is to play with camera.viewport to reduce the surface where the camera get the events

---

<div class="post-metadata">

**Author:** ![kzaky](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@kzaky](https://forum.babylonjs.com/u/kzaky)\
**Post date:** [February 7, 2020, 8:40pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/6 "2020-02-07T20:40:34Z")

</div>

Here is a modified playground from the multiple scenes example given. I’ve added listener to each scene, but it seems to be triggered on both scenes despite having a smaller viewport on cam2.

[https://www.babylonjs-playground.com/#L0IMUD#55](https://www.babylonjs-playground.com/#L0IMUD#55)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 8, 2020, 12:03am UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/7 "2020-02-08T00:03:33Z")

</div>

Yes it was a bad idea 🙂

So unfortunately you may have to handle which scene is active (by playing with attach / detachControl)

---

<div class="post-metadata">

**Author:** ![kzaky](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@kzaky](https://forum.babylonjs.com/u/kzaky)\
**Post date:** [February 10, 2020, 6:23pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/8 "2020-02-10T18:23:36Z")

</div>

I figured that everything (engine, scene, camera control) is attached to an html canvas. Do you reckon this would solve the problem if I had multiple canvas? since camera control is attached to a canvas, so viewport size wouldn’t affect the camera listener, but canvas would?

EDIT: nvm, this would require multiple enegines.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 10, 2020, 9:11pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/9 "2020-02-10T21:11:58Z")

</div>

> [@kzaky](#):
>
> this would require multiple enegines.

Correct 🙂

---

<div class="post-metadata">

**Author:** ![kzaky](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@kzaky](https://forum.babylonjs.com/u/kzaky)\
**Post date:** [February 10, 2020, 9:54pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/10 "2020-02-10T21:54:18Z")

</div>

Hey Delta, just came across the new multi-canvas implementation: [Use Multiple Canvases with one Engine - Babylon.js Documentation](https://doc.babylonjs.com/how_to/multi_canvases) . I saw the playground on one of the forum posts and modified them with listeners : [https://playground.babylonjs.com/#LEIZ83#25](https://playground.babylonjs.com/#LEIZ83#25). The listeners work fine through the solution you provided (by attach/detaching control using canvas mouseover) but apparently it seems to be creating 2 engines. I tried to use the same basic babylon engine for the meshes inside the multi-scene, but it wouldn’t work. Do you by any chance provide the playground of the demo that uses 1 engine for multi-scene?

Thanks!

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [February 11, 2020, 5:00pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/11 "2020-02-11T17:00:58Z")

</div>

Well you are creating a 2nd engine around line #135 🙂 so yeah you have 2 engines 🙂

Not sure what is your question? Maybe you can simplify the PG a bit as there is a lot of not needed code

---

<div class="post-metadata">

**Author:** ![kzaky](https://avatars.discourse-cdn.com/v4/letter/k/9fc29f/32.png) [@kzaky](https://forum.babylonjs.com/u/kzaky)\
**Post date:** [February 11, 2020, 10:51pm UTC](https://forum.babylonjs.com/t/multi-camera-controls/8462/12 "2020-02-11T22:51:14Z")

</div>

I actually managed to make it work with 2 scenes. I needed 2 clickable meshes on 2 different respective cameras with different sized viewports. Somehow managed to make it work by re-ordering active camera push and attach controls.

Thanks for all the help
