Combining multiple geometric lines into one geometry

I am completely new to Three.js and I am trying to add edges to solid models.

The problem is that I add edges individually, rendering becomes slow. Therefore, thinking about combining geometries in one, so that rendering is slightly accelerated.

I came across this: https://github.com/mrdoob/three.js/issues/1370 But after using the above technique, the result does not remain true.

My code is below:

/* Edge Data */ var vertices = edgeData.vertices; var edges = edgeData.edges; // Final Geometry var combinedGeo = new THREE.Geometry(); /* Add lines */ for( var i=0; i<edges.length; i++){ var geom = new THREE.Geometry(); for (var j=0; j<edges[i].length; j++){ var v1 = vertices[edges[i][j]]; geom.vertices.push(new THREE.Vector3(v1[0], v1[1], v1[2])); } // var line = new THREE.Line(geom, material, THREE.LinePieces); THREE.GeometryUtils.merge( combinedGeo, geom); // scene.add(line); } var edgesGeo = new THREE.Line(combinedGeo, material, THREE.LineStrip); scene.add(edgesGeo); 
+4
source share
1 answer

No merge required. First add pairs of points to your geometry , and then create one Line with the LinePieces setting. See, for example, the code THREE.AxisHelper .

+3
source

Source: https://habr.com/ru/post/1486605/


All Articles