I am successfully loading a dataset with polygon data that represents buildings in a city. Thus, each polygon represents one building. In Threejs, I can successfully represent them, but when I try to combine individual lines into one geometry, all the lines are connected (I understand why this makes sense, since all the vertices are added to the same collection).
But how to combine these separate building polygons into a single geometry without having the lines of separate polygons of the building connected to each other?
The code I have right now is:
var geometry = new THREE.Geometry(); for (var i = 0; i < data.length; i++) { var temp = new THREE.Geometry(); var polygon = data[i]; for (var j = 0; j < polygon.length; j++) { temp.vertices.push(new THREE.Vector3(polygon[j][0], polygon[j][1], 0)); } temp.vertices.push(new THREE.Vector3(polygon[0][0], polygon[0][1], 0)); THREE.GeometryUtils.merge(geometry, temp); } scene.add(new THREE.Line(geometry, buildingMaterial, THREE.LineStrip));
is a variable that contains all the polygon data for buildings.
source share