Unable to change `visibility` on `Lines` from `CreateLines`


Is there a reason that visibility cannot be updated on a mesh created by CreateLines? I tried both using animations and a custom interval.

Is there also a reason why colors cannot be redefined after the lines have been created?

Thanks! :slight_smile:

I’m not sure if there was a builtin function (I couldn’t find one).
But I did some digging of the code, and it seems the colors are built into the vertices, so to update the transparency and vertices you’d probably have to update the vertices directly;

If you change lines 52 - 54 from
new BABYLON.Color3.Random().toColor4(1)
new BABYLON.Color3.Random().toColor4(0)
You’ll see that having a Color4 with a value different than 1 will also give you transparency;

Hopefully this helps

This was inspired by the source code: Babylon.js/packages/dev/core/src/Meshes/Builders/linesBuilder.ts at master · BabylonJS/Babylon.js · GitHub

1 Like

Ok cool! Maybe we could make a PR for a new method on the line updateColors? I’m gonna try and do it locally first.

You can do what you want by simply passing your existing trail object to the constructor of CreateLines through the instance property. In this case, the instance will be reused and modified with the new parameters (as long as you set updatable: true when you create the trail object):

visibility is not supported for line meshes. Instead, you can use the alpha property if you don’t use vertex colors (not your case), else you should update the alpha component of the vertex colors (your case).


Yeah, that works great too, thank you :slight_smile: