Calculating distance from line's center

Hey. I am new to the shaders.

I made a Three.Point() with linear-gradient color, custom shader with distance()

I was wondering if it is possible somehow customize meshline shader to have similar effect. (Distance from center of the line to the edges) using onBeforeCompile

Meshline material source:

I use meshline becasue it is part of react drei Trail component.

I’ve already spend a lot of time trying to figure out how this even work. I would appreciate any bit of help.

I anyone would be wondering how did I solved this, I’ve just noticed, Trail from drei comes with useTrail hook. Therefore there is no need to override meshline and I can apply my shader to the points from useTrail.