Have an error with change color line when I want to change some of them in particular state

Hello Everyone

I am trying to change the color of some lines, but I got an error , is it possible to help me solve it?
this is my PG:

You should not pass the instance parameter to CreateLineSystem as lines is not defined, and the lineColors variable should be an array of array, like myLines: you created a simple array instead.

1 Like

Thank you @Evgeni_Popov, You are great.
I have done it as you said, but the problem is all the line change to red, But I want just the line[i].AU that are bigger than 5 changed to red and rest of them be green. where is my mistake?

That’s because you used line instead of entriesWithID in your last loop:


1 Like

Thank you so much.

if I don’t want to have transition, and immediately changed greed to red , what should I use instead of BABYLON.Color4.Lerp ?

Colors are interpolated from previous vertex to current vertex. If you want a straight color change, you must duplicate the last vertex and assign the new color.

For eg, if you have 3 points with coordinates A, B and C and you want color red ® between A and B and blue (B) between B and C, you must really create 4 points in your line system [A,B,B,C], the corresponding colors being [R,R,B,B].

Note that your usage of Lerp is wrong because the 3rd value should be between 0 and 1. Anyway, I don’t think you want to use Lerp but instead push directly the color into the array.

1 Like

I have pushed color directly into array, But how can duplicate B point in my code?

Hi @Evgeni_Popov
I’ve duplicate the points in line array but didn’t fix the problem.

You can try something like this:



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