diff --git a/packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts b/packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts index f58893f6..8138efe9 100644 --- a/packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts +++ b/packages/core/src/hooks/spatial-grid/spatial-grid-manager.ts @@ -468,7 +468,8 @@ export class SpatialGridManager { if (slab.polygon.length >= 3 && pointInPolygon(x, z, slab.polygon)) { // Check if point is in any hole let inHole = false - for (const hole of slab.holes) { + const holes = slab.holes || [] + for (const hole of holes) { if (hole.length >= 3 && pointInPolygon(x, z, hole)) { inHole = true break @@ -507,7 +508,8 @@ export class SpatialGridManager { // We consider it entirely in a hole if the item center is in the hole let inHole = false const [cx, , cz] = position - for (const hole of slab.holes) { + const holes = slab.holes || [] + for (const hole of holes) { if (hole.length >= 3 && pointInPolygon(cx, cz, hole)) { inHole = true break @@ -546,7 +548,8 @@ export class SpatialGridManager { let inHole = false const midX = (start[0] + end[0]) / 2 const midZ = (start[1] + end[1]) / 2 - for (const hole of slab.holes) { + const holes = slab.holes || [] + for (const hole of holes) { if (hole.length >= 3 && pointInPolygon(midX, midZ, hole)) { inHole = true break diff --git a/packages/core/src/systems/slab/slab-system.tsx b/packages/core/src/systems/slab/slab-system.tsx index 945e80c3..29a2c8b6 100644 --- a/packages/core/src/systems/slab/slab-system.tsx +++ b/packages/core/src/systems/slab/slab-system.tsx @@ -124,7 +124,8 @@ export function generateSlabGeometry(slabNode: SlabNode): THREE.BufferGeometry { shape.closePath() // Add holes to the shape - for (const holePolygon of slabNode.holes) { + const holes = slabNode.holes || [] + for (const holePolygon of holes) { if (holePolygon.length < 3) continue const holePath = new THREE.Path()