Weird behavior when using ShaderMaterial in LineSegments

I was trying to write a grid with animation effect using noise function in the shader, and found out that, if you use LineSegments and ShaderMaterial together, the output is not as expected.

code
The sample code is supposed to draw a square, but it actually draws (at least) 2 extra lines. I assume it switchs to gl.LINE_LOOP under the hood while LineSegments should use gl.LINES. When I changed the material to LineBasicMaterial, everything works fine.
Is it a bug or intended?

Can you please update your codesandbox so it does not produce a runtime error each frame?

Sorry for that. I updated it and removed some irrelevant code.

I think your issue can be solved by just removing wireframe: true. This is actually not needed since you are already rendering lines.

:sweat_smile: Oh I was so stupid. Thank you.