When i create lines with MeshBuilder.CreateLines is it possible to access each line as a mesh to modify?

Hi everyone

I have 10 points to build lines, each lines have specific color, is it any way to modify each line like a mesh?
this is my PG:
https://playground.babylonjs.com/#FRJX06

You can set the colors by passing an array of colors to the line constructor:

https://playground.babylonjs.com/#FRJX06#2

You can’t have a different material for each segment.

thank you for answering to my question. how can have a different material for each segment, should I use different method?

You would need different lines for that.

But why would you need a different material for each segment? Besides the color, you can’t change much the appearance of a line…

1 Like

because I have three kinds of color one for Rock, one for Au and another for Cu, I should show each of them separately with specific color.

The PG I updated does this: see the lineColors array.

1 Like

thank you so much, if i want to add the other two material (Au and Cu), should I create lines again or is it possible to change the color ?

when I do this in this way, how can I deleted the preview one after I want to see the next one, I mean when I press “r” and the “a” I think “r” is under “a”.

Just make your line mesh updatable and reuse the same instance:

https://playground.babylonjs.com/#FRJX06#4

2 Likes

Thank you so much, you are great. :pray:

Hi @Evgeni_Popov
sorry for my questions and for taking your precious time, if i wanted to have each 3 points as one line and then have 3 separated line, should I divided my array to three arrays and then should I write for loop for each line? or is there better way to do this?
because the main project is 400 points, and it is difficult to have a 10 for loop for each line.

https://playground.babylonjs.com/#FRJX06#8

https://playground.babylonjs.com/#FRJX06#9

I mean is it possible to say that every 3 points cut the lines and start another line?

https://doc.babylonjs.com/how_to/parametric_shapes#line-system

I have been read this, and I can do it for 10 or 20 points, But in my project there are 400 points, and I need an optimize way to do this, I mean I want to know how can I define a IF statement in my FOR LOOP to cut the line every 3 points.

I guess it’s more a javascript question, but you can do something like:

https://playground.babylonjs.com/#FRJX06#16

2 Likes

thank you so much, its great. You are wonderful.