Gizmo and Multiviews

Hello everybody, I can’t find a way to choose what camera should display the gizmoManager when in multiview?

Here is a playground for test/solution purpose: https://www.babylonjs-playground.com/#E9IRIF#43

Plus in that example, it seems that the function attachtomesh is not working, see line 66.

Thanks a lot for your help :wink:

Pinging @trevordev

Looking at that playground, this is apparently enough to set the attachedMesh property instead of using the attachtomesh function:
https://www.babylonjs-playground.com/#31M2AP#6

Edit: This only for subClass PositionGizmo

@PichouPichou I think this PR will solve your issue (Let me know if i’m incorrect). add ability to set render camera on utility layer by TrevorDev · Pull Request #6410 · BabylonJS/Babylon.js · GitHub

It added a setRenderCamera to a utility layer to do this. See this playground once the next nightly is pushed https://playground.babylonjs.com/#JZRFDB#1

2 Likes

Thanks, I will keep you in touch once we make the update! :wink:

And what about the attachtomesh function? Is it something wrong in what I do?

In the playground you linked it looks like attachtomesh is not called. It seems to work in this playground https://playground.babylonjs.com/#8MGKWK#25 let me know if you see otherwise

1 Like

Ok my bad, it works well indeed: https://www.babylonjs-playground.com/#E9IRIF#44 :wink:

1 Like

@trevordev is there anyway I could set the camera I need for the utilityLayer before being able to test your modifications?
I can’t really progress on my feature before the packages are updated unfortunetly.
For instance is the utilityLayer using the last created camera by default? And in that case I could maybe trick it.

Edit: Indeed it seems that this the first camera pushed in scene.activeCameras which is used by Gizmo’s utilityLayer

You are going to laugh.
I am also using several scenes in my application. And it seems like we can’t control in which scene the Gizmo will be render too.
Is it something we will be able to do thanks to your PR @trevordev? :wink:

@PichouPichou :joy: Any chance you have a playground of your setup so I can see if I can make that scenario work?

Here you go @trevordev: https://www.babylonjs-playground.com/#E9IRIF#46

Two different scenes and the gizmo is not visible by the first scene anymore.

@PichouPichou thanks for the playground. It looks like the issue is that gizmoManager uses a defaultUtilityLayer which uses the last created scene which caused some issues. I also updated your playground to render both scenes as by default the playground seems to only render the first scene.

This PR should be able to help: use custom utility layer in gizmo manager by TrevorDev · Pull Request #6428 · BabylonJS/Babylon.js · GitHub

Once that is merged this playground should work https://playground.babylonjs.com/#B3LMW7#3 (see useScene1 variable, toggling it and rerunning will let the gizmos work on the scene of your choosing).
Let me know if you are still hitting blocking issues.

1 Like

Thanks @trevordev, I love your very specific and complete answers with a playground in addition to quickly understand the improvement. This is perfect!

I see there has been an update in babylonjs packages so I should be able to test it! I will keep you in touch! :wink:

It works well @trevordev so thanks again for the improvement.
I will add one last thing which could cause other issue. And this is the layerMask. Indeed my camera also uses a layerMask and I didn’t find a way to set the layerMask of the gizmo?

Right now I managed to make it work without it :wink:

Also I think there should be a function to easily disableDragBehavior on boundingBoxGizmo.

To do that I currently do

gizmoManager.boundingBoxDragBehavior.detach();

everytime after attaching a mesh to the gizmoManager

Glad it sounds like you are not longer blocked.

Sure, I can add a way to disable that dragging by setting gizmoManager.boundingBoxDragBehavior to null.

For layerMask, because the gizmo is on a utilityLayer I currently expect it always to be rendered. Can you share how you expect layerMask to effect gizmo (Playground maybe) if you still think a change should be made here?

Hum honestly I think this is a false good idea. It turns out for now I always managed to set the gizmo on the right layerMask by setting the camera I want which then will have the right layerMask.

So thanks to your last change I am not sure we will need to set the layerMask of the gizmo.

2 Likes