fix(paint-slots): guard empty fence slot group before mergeGeometries

mergeGeometries throws on an empty array, so an absent slot group (infill with
showInfill off, base on a floating fence) crashed the geometry build. Return an
empty BufferGeometry for an empty group; the renderer already skips meshes with
no position attribute.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Wassim SAMAD
2026-06-17 20:57:46 -04:00
co-authored by Claude Opus 4.8
parent bba0cc5f68
commit f7e774485c
@@ -252,6 +252,10 @@ function createFenceParts(fence: FenceNode): FenceSlotParts {
}
function mergeFenceParts(parts: FencePart[]): THREE.BufferGeometry {
// An empty slot group (e.g. infill with showInfill off, or base on a floating
// fence) must not reach mergeGeometries — it throws on an empty array. The
// empty geometry has no position attribute, so the renderer skips its mesh.
if (parts.length === 0) return new THREE.BufferGeometry()
const geometries = parts.map(createFencePartGeometry)
const merged = mergeGeometries(geometries, false) ?? new THREE.BufferGeometry()
geometries.forEach((geometry) => {