rivers_lines_seg = {
const group = new THREE.Group();
const geometries = [];
let positions = [],
indices = [],
next = 0;
const commit = () => {
if (!indices.length || !positions.length) return;
const geometry = new THREE.BufferGeometry();
geometry.setIndex(indices);
geometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(positions, 3)
);
geometries.push(geometry);
indices = [];
positions = [];
next = 0;
};
for (let { cord: points } of xyzcords) {
points = points.filter(([x, y]) => !isNaN(x) && !isNaN(y));
if (points.length < 2) continue;
if (positions.length + points.length * 3 > 0xffff) commit();
for (let i = 0; i < points.length; i++) {
const [x, y, z] = points[i];
if (i > 0) indices.push(next - 1, next);
positions.push(x, Math.max(0, z || 0), -y);
next++;
}
}
commit();
for (const geometry of geometries) {
group.add(new THREE.LineSegments(geometry, material));
}
return group;
}