Why is the worldMatrix not considered when calculating distance in computeLineDistances?

Hi.
Why is the worldMatrix not considered when calculating distance in computeLineDistances?
I know distances will be used for dash line. But if the worldmatrix does not participate in the calculation, the distances obtained are inaccurate

Can you please provide a live example that demonstrates how the distance computation breaks?


The vertices involved in the calculation are only in the local coordinate system

That’s not what I’ve meant. We need a real live example that demonstrates the breakage.

Refer to the dashed line example on the official website:
https://threejs.org/examples/?q=line#webgl_lines_dashed

If the worldmatrix is ​​considered, will the rendering of the dashed line be different?

If I understood correctly, does this example show the issue? One line keeps the correct dash-size-ratio when scaled, while the other one remains unchanged, regardless of the world scale?

.computeLineDistances computes the dashes locally - so indeed the distances between dashes will no longer be true, if you apply any external scaling to the Line afterwards. But keep in mind - that method runs in Javascript / on the CPU, and iterates through all points on the line, so calling it on each frame may just be slow - it should be called only once.

Instead of calling .computeLineDistances and applying worldMatrix there - consider using LineDashedMaterial.scale. It’s applied on the GPU, and will give you exactly the same effect.

1 Like

Thanks your reply.
If worldMatrix contains non-uniform scale, this result may also be wrong