slab holes

This commit is contained in:
wass08
2026-02-12 10:41:37 +09:00
parent ae3af4318e
commit 29e7fa09ef
6 changed files with 224 additions and 5 deletions
+1
View File
@@ -8,6 +8,7 @@ export const SlabNode = BaseNode.extend({
// Specific props
// Polygon boundary - array of [x, z] coordinates defining the slab
polygon: z.array(z.tuple([z.number(), z.number()])),
holes: z.array(z.array(z.tuple([z.number(), z.number()]))).default([]),
elevation: z.number().default(0.05), // Elevation in meters
}).describe(
dedent`
@@ -123,6 +123,25 @@ export function generateSlabGeometry(slabNode: SlabNode): THREE.BufferGeometry {
}
shape.closePath()
// Add holes to the shape
if (slabNode.holes && slabNode.holes.length > 0) {
for (const holePolygon of slabNode.holes) {
if (holePolygon.length < 3) continue
const holePath = new THREE.Path()
const holeFirstPt = holePolygon[0]!
holePath.moveTo(holeFirstPt[0], -holeFirstPt[1])
for (let i = 1; i < holePolygon.length; i++) {
const pt = holePolygon[i]!
holePath.lineTo(pt[0], -pt[1])
}
holePath.closePath()
shape.holes.push(holePath)
}
}
// Extrude the shape by elevation
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: elevation,