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

**URL:** <https://forum.babylonjs.com/t/unable-to-change-visibility-on-lines-from-createlines/47874>\
**Category:** Questions\
**Created:** [February 6, 2024, 10:43pm UTC](https://forum.babylonjs.com/t/unable-to-change-visibility-on-lines-from-createlines/47874 "2024-02-06T22:43:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [February 6, 2024, 10:43pm UTC](https://forum.babylonjs.com/t/unable-to-change-visibility-on-lines-from-createlines/47874/1 "2024-02-06T22:43:44Z")

</div>

Hi,

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?

> **[Babylon.js Playground](https://playground.babylonjs.com/#WVX9MS)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Thanks! 🙂

---

<div class="post-metadata">

**Author:** ![Benjythebee](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/benjythebee/32/13587_2.png) [@Benjythebee](https://forum.babylonjs.com/u/Benjythebee)\
**Post date:** [February 7, 2024, 7:23am UTC](https://forum.babylonjs.com/t/unable-to-change-visibility-on-lines-from-createlines/47874/2 "2024-02-07T07:23:20Z")

</div>

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;

> **[Babylon.js Playground](https://playground.babylonjs.com/#WVX9MS%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

If you change lines 52 - 54 from  
`new BABYLON.Color3.Random().toColor4(1)`  
to  
`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](https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Meshes/Builders/linesBuilder.ts#L137-L164)

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [February 7, 2024, 8:07am UTC](https://forum.babylonjs.com/t/unable-to-change-visibility-on-lines-from-createlines/47874/3 "2024-02-07T08:07:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [February 7, 2024, 11:36am UTC](https://forum.babylonjs.com/t/unable-to-change-visibility-on-lines-from-createlines/47874/4 "2024-02-07T11:36:54Z")

</div>

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):

> **[Babylon.js Playground](https://playground.babylonjs.com/#WVX9MS%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

`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).

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [February 7, 2024, 5:22pm UTC](https://forum.babylonjs.com/t/unable-to-change-visibility-on-lines-from-createlines/47874/5 "2024-02-07T17:22:43Z")

</div>

Yeah, that works great too, thank you 🙂
