Ray disappearing after some time

hello guys . i made a simple ray attached to a mesh then i used ray helper to see it , it works just fine .

but when i make the mesh moves, the ray start disappearing and appearing in a weird way after some time (depending on the length of the ray).
i don’t know if the ray disappears or only it’s visualization of rayHelper .
this is the PG:
https://playground.babylonjs.com/#SGVL8A#2
please help if you have any idea why is doing that . thank you

1 Like

I’m unsure why the visualization disappears, although it seems like the ray’s origin is updating correctly:

scene.registerBeforeRender(() => {
    sphere.locallyTranslate(new BABYLON.Vector3(0, 0, 1));
    console.log(ray.origin) // added for debugging
});
1 Like

This PR will fix the problem:

In the meantime and as a temporary fix, you can do rayHelper._renderLine.alwaysSelectAsActiveMesh = true;:

https://playground.babylonjs.com#SGVL8A#3

3 Likes

thank you so much , i appreciate it