high geometry problem while drawing gcode

I read the G code line by line and have it drawn on the scene, but since each contour is a separate geometry, I experience freezing in the scene with high contour Gcodes. I tried to combine all the lines in a single geometry, there is no freezing, but this time it creates a line between the contours. Also, I cannot draw the contour with a different color, it becomes a fixed color.

Merging all lines in a single geometry is a good approach. Here are my suggestions for the two problems:

  • line between contours - instead of THREE.Line use THREE.LineSegments. It draws a set of independent segments. Thus, you may have several lines on the screen, that are one geometry in memory. The downside is that the data will be larger.
  • different colors - set the vertexColors property to allow individual color for each vertex, then add these colors as a color BufferAttribute in the geometry. The downside is that if you have a long multisegment line, the same color should be set for each vertex.

In the following example there are several rings with different colours. They are defined as one geometry and are drawn as one object.



1 Like