Gizmo to move Light disappears:

I cannot get this figured out.

I want to control the position of a directional light. I have a gizmo connected to it.

On first initialization of the scen the gizmo is visible, but if I hit my button to restart the scene the gizmo and the light gizmo disappear and will not reappear unless I refresh the browser.

Here is how I am doing it.

const dirLight = new DirectionalLight(
“dirLight”,
new Vector3(0, -10, 10),
scene
);
//dirLight.position = new Vector3(0, 0, 0);
dirLight.position = new Vector3(0, 400, -400);
var lightGizmo = new LightGizmo();
lightGizmo.light = dirLight;
if (lightGizmo.attachedMesh) {
lightGizmo.attachedMesh.position = new Vector3(0, 400, -400);
}

    var m = new GizmoManager(scene)
    m.positionGizmoEnabled = true;
    m.rotationGizmoEnabled = true;
    m.usePointerToAttachGizmos = false;
    m.attachToMesh(lightGizmo.attachedMesh)

I cannot figure this out and cannot find anyone else having this issue.

Can you create a repro in the playground so that we ll have a look.

1 Like

Here is the PG:

I do not see how this repro your issue ? I can run a lot of time the scene without any issues.

Yeah, I saw that as well…Not sure what could be causing this issue.

Could it be because of the way I am restarting babylon without disposing the scene and engine first?

It could be yes

That’s it. I bound a scene.dispose(): to a key press….the scene freezes and if I hit the button to re-reun it works….

Added this to the vue.js method:

var event = new KeyboardEvent(‘keydown’, {
key: 'e’,
code: 'KeyE’,
charCode: ‘e’.charCodeAt(0),
});

    window.dispatchEvent(event);

That disposes the scene then restarts it and it works pretty good.

Is this a good way of doing this? Or is it hackish?

Sounds weird, is there no better places to put this at the moment ?

Well, because I am fairly new to babylon, and actually vue as well. I am still wrapping my head around this. This stack is totally new to me coming from .NET and C#. I am learning though.

So getting started with vuetify and sticking a babylon canvas in it is a little different than even three.js in a .NET app.

I followed a tutorial to get babylon in vue so that kind of has road blocked me with some of the things I need to do.

So to answer your question….I do not know yet…lol