attachControl and CameraGizmo with Frustum

Hello,

When I use the cameraGizmo with Frustum mode, the main active camera has the Control randomly activate.

On this PG, simply click several times to move the camera. But she this blocks and this unblocks by accident and blocks…
https://www.babylonjs-playground.com/#Z4ZGAY#12

And the Gizmo is not pickable, which might be good for displaying gizmo axes after selecting the Gizmo camera. The lightGizmo have the same concern, they cannot be pickable.

Otherwise, great this CameraGizmo and LightGizmo :+1:

Thank you!

Adding @Cedric (please be patient as Cedric is out for vacations)

Well actually I found the issue. Will be fixed in a couple of hours :wink:

3 Likes

Cool, thanks DK

It looks fix for moving the main camera.

But for the selection of cameraGizmo and lightGizmo, it is still not pickable. There is no property that makes it pickable, or I missed it.

GizmoCamera pick:
https://www.babylonjs-playground.com/#Z4ZGAY#15

LightGizmo pick
https://www.babylonjs-playground.com/#Z4ZGAY#14

Thank you

What do you mean by selection? We can switch to french if this is easier :wink:

Je parle de pickedMesh. Pouvoir “sélectionner” les gizmos des cameras et lumières.

Quelque chose comme :

cameraGizmo = new BABYLON.CameraGizmo(); 
cameraGizmo.isPickable = true;

Mais je ne trouve pas isPickable ou j’ai l’ai rater.

Puis on pourrait utiliser ceci pour afficher le gizmo :

scene.onPointerDown = function (_evt, pickResult) { 
        if (pickResult.hit) {
            manipulator.attachToNode(pickResult.pickedMesh);
        }
    }; 

Un peut comme quand on sélectionne un maillage et que cela affiche le Gizmo, mais là on selectionne une cameraGizmo et une lightGizmo.

Oui ce n’est pas gere ca. Tu peux toutefois t’abonner aux observables pour savoir si ca a bouge

Je ne comprend pas trop comment faire cela avec des observables. Peuvent ils sélectionner un maillage ?

Le Gizmo de la camera est un maillage (ou plutôt construit à partir de primitif) Pourquoi ils ne sont pas pickable comme n’importe quelle maillage ? Je comprend qu’une camera et une lumière ne peuvent pas être pickable, mais le Gizmo lui pourrait l’être.

Merci DK

Il est dans une scene a part, un utility layer afin de ne pas perturber la scene

Tu peux hacker un truc avec:
gizmo.gizmoLayer.utilityLayerScene.pick()
tu devras fournir ton predicate car les meshes du gizmo ne sont pas pickables par defaut

Tu me fait penser a un truc du coup.

Si je met une box invisible que je parent a la camera, cela pourrait fonctionner peut être ? Du coup je met un type car box.metadata ={type: “camera”} pour savoir que le pick une camera.

Je vais tester ca. Merci DK pour tes idées.

lol avec plaisir!

J’ai tenter la box.parent = camera2, mais elle ce retrouve dans l’utilityLayer et du coup ca ne fonctionne pas correctement: https://www.babylonjs-playground.com/#Z4ZGAY#23

Je n’ai pas compris le hack avec gizmo.gizmoLayer.utilityLayerScene.pick() et le predicate. Aurait tu un exemple dans un PG ? Je suis un peut à la ramasse là.

Ou peut être que je devrais résoudre ce sujet qui est résolu et poser cette nouvelle question dans “Question/Reponse”

Merci Encore

I found the solution that works.

this.cameraGizmo.gizmoLayer.utilityLayerScene.onPointerObservable.add((pickResult) => {
    if(pickResult.type == 2)
    {
        if(!pickResult.pickInfo.pickedMesh) return;
        if(pickResult.pickInfo.pickedMesh.name == "rootCameraGizmo")
        {
            m.attachToNode(camera2);              
        }  
    }
});

PG here:
https://www.babylonjs-playground.com/#Z4ZGAY#24

It remains to be tested a bit more, but it is a lead

Well, in fact this solution works if you have a single camera with a Gizmo. If I add more it is always the last camera added that gets the gizmo.

I think babylon should add this feature, because that seems like a hassle. (all the mesh of the Gizmo is called rootCameraGizmo and no way to differentiate the different meshCamera to add by giving them a name for example.

In short, I move on and leave that aside. Maybe @Cedric after he comes back from vacation will try to see what he can do about it.

I disagree, the utlity layer is meant for the gizmo. I still don’t understand why you want to pick the gizmo model. Maybe start a new thread explaining why you need to pick the gizmo manually

This is useful for an editor. The user adds cameras, of lights and edits its properties. Then he must be able to select the GizmoCamera or GizmoLight on the scene to move the cameras or the lights and edit the propertys.

All editors do this (unity, Unreal …)

Oh now I understand…You want to enable to enable manipulations not by clicking on light or camera gizmos…

Gotcha… Please create an issue for @cedric

Yes I would like to be able to click on the CameraGizmo or LightGizmo (Which are meshes the user can see and should be able to click on) just to activate the GizmoManager and by the same to recover the camera or the light which is attached.

Currently I cannot find any correct workaround.

Should I create the problem on GitHub

Yes please