@kruschdev/pascal-plugin-furnishings 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,506 @@
1
+ /**
2
+ * Clean-Room MIT Deterministic Procedural 3D Botanical Engine (15 Trees, Bushes, Hedges & Houseplants).
3
+ *
4
+ * Uses a seeded PRNG (`mulberry32`) so identical seeds always emit identical organic branch angles
5
+ * and foliage clusters with 0 NaN vertices, seasonal deciduous palettes (spring/summer/autumn/winter),
6
+ * maturity scaling, and configurable pot/planter geometry. Zero React or `@pascal-app/*` imports.
7
+ */
8
+
9
+ import {
10
+ Box3,
11
+ BoxGeometry,
12
+ ConeGeometry,
13
+ CylinderGeometry,
14
+ DodecahedronGeometry,
15
+ Group,
16
+ IcosahedronGeometry,
17
+ Mesh,
18
+ type MeshStandardMaterial,
19
+ SphereGeometry,
20
+ } from 'three'
21
+ import {
22
+ PLANT_MATURITY_SCALE,
23
+ type PlantMaturity,
24
+ type PlantSeason,
25
+ type PotStyle,
26
+ } from '../furnishings/types'
27
+ import { createFurnishingsMaterialPool } from './materials'
28
+
29
+ export type PlantCadParams = {
30
+ readonly kind: string
31
+ readonly heightM: number
32
+ readonly canopyRadiusM: number
33
+ readonly maturity?: PlantMaturity
34
+ readonly season?: PlantSeason
35
+ readonly potStyle?: PotStyle
36
+ readonly seed?: number
37
+ }
38
+
39
+ function mulberry32(seed: number): () => number {
40
+ let a = (seed >>> 0) || 1
41
+ return () => {
42
+ a |= 0
43
+ a = (a + 0x6d2b79f5) | 0
44
+ let t = Math.imul(a ^ (a >>> 15), 1 | a)
45
+ t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t
46
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296
47
+ }
48
+ }
49
+
50
+ function resolveDeciduousPalette(kind: string, season: PlantSeason): readonly string[] {
51
+ if (kind === 'tree-maple-japanese') {
52
+ if (season === 'spring') return ['#b83b3b', '#c95248', '#8f2930']
53
+ if (season === 'summer') return ['#88202a', '#9e2b35', '#6e1922']
54
+ if (season === 'autumn') return ['#dc2626', '#ea580c', '#b91c1c']
55
+ return [] // bare branches in winter
56
+ }
57
+ if (season === 'spring') return ['#65a30d', '#84cc16', '#4d7c0f']
58
+ if (season === 'summer') return ['#2e6f34', '#3d8542', '#235728']
59
+ if (season === 'autumn') return ['#d97706', '#c2410c', '#eab308']
60
+ return [] // bare branches in winter
61
+ }
62
+
63
+ function buildPlanterPot(
64
+ parent: Group,
65
+ potStyle: PotStyle,
66
+ radius: number,
67
+ height: number,
68
+ pool: ReturnType<typeof createFurnishingsMaterialPool>,
69
+ ): number {
70
+ if (potStyle === 'none') return 0
71
+ const potMat = pool.pot(potStyle)
72
+ const soilMat = pool.make({ color: '#3b2b20', roughness: 0.96 })
73
+
74
+ if (potStyle === 'concrete-trough' || potStyle === 'cedar-box') {
75
+ const box = new Mesh(new BoxGeometry(radius * 2.4, height, radius * 1.1), potMat)
76
+ box.position.set(0, height / 2, 0)
77
+ box.castShadow = true
78
+ box.receiveShadow = true
79
+ parent.add(box)
80
+ const soil = new Mesh(new BoxGeometry(radius * 2.22, 0.04, radius * 0.94), soilMat)
81
+ soil.position.set(0, height - 0.025, 0)
82
+ parent.add(soil)
83
+ return height - 0.02
84
+ }
85
+
86
+ const pot = new Mesh(new CylinderGeometry(radius, radius * 0.76, height, 18), potMat)
87
+ pot.position.set(0, height / 2, 0)
88
+ pot.castShadow = true
89
+ pot.receiveShadow = true
90
+ parent.add(pot)
91
+
92
+ const rim = new Mesh(new CylinderGeometry(radius * 1.06, radius * 1.02, height * 0.14, 18), potMat)
93
+ rim.position.set(0, height - height * 0.07, 0)
94
+ parent.add(rim)
95
+
96
+ const soil = new Mesh(new CylinderGeometry(radius * 0.92, radius * 0.92, 0.03, 16), soilMat)
97
+ soil.position.set(0, height - 0.02, 0)
98
+ parent.add(soil)
99
+
100
+ return height - 0.02
101
+ }
102
+
103
+ export function buildPlantCad(params: PlantCadParams): Group {
104
+ const safeHeightM = Number.isFinite(params.heightM) ? Math.min(30, Math.max(0.2, params.heightM)) : 1.2
105
+ const safeCanopyRadiusM = Number.isFinite(params.canopyRadiusM)
106
+ ? Math.min(15, Math.max(0.12, params.canopyRadiusM))
107
+ : 0.5
108
+ const safeSeed = typeof params.seed === 'number' && Number.isFinite(params.seed) ? Math.trunc(params.seed) : 42
109
+ const g = buildPlantCadInternal({
110
+ ...params,
111
+ heightM: safeHeightM,
112
+ canopyRadiusM: safeCanopyRadiusM,
113
+ seed: safeSeed,
114
+ })
115
+ // Ground organic foliage/blades cleanly on y = 0 so no bush/grass lobe sinks beneath the floor plane
116
+ const box = new Box3().setFromObject(g)
117
+ if (!box.isEmpty() && Number.isFinite(box.min.y) && box.min.y < 0) {
118
+ const lift = -box.min.y
119
+ for (const child of g.children) {
120
+ child.position.y += lift
121
+ }
122
+ }
123
+ return g
124
+ }
125
+
126
+ function buildPlantCadInternal(params: PlantCadParams): Group {
127
+ const pool = createFurnishingsMaterialPool()
128
+ const rand = mulberry32(params.seed ?? 42)
129
+ const season: PlantSeason = params.season ?? 'summer'
130
+ const rawScale = PLANT_MATURITY_SCALE[params.maturity ?? 'mature']
131
+ const scale = typeof rawScale === 'number' && Number.isFinite(rawScale) ? rawScale : 1.0
132
+ const h = Math.min(40, Math.max(0.25, params.heightM * scale))
133
+ const r = Math.min(20, Math.max(0.15, params.canopyRadiusM * scale))
134
+ const potStyle: PotStyle = params.potStyle ?? 'none'
135
+
136
+ const g = new Group()
137
+ g.name = `plant:${params.kind}`
138
+
139
+ const addBlob = (x: number, y: number, z: number, rad: number, mat: MeshStandardMaterial, sx = 1, sy = 1, sz = 1) => {
140
+ const m = new Mesh(new IcosahedronGeometry(Math.max(0.04, rad), 1), mat)
141
+ m.position.set(x, y, z)
142
+ m.scale.set(sx, sy, sz)
143
+ m.rotation.set(rand() * 3, rand() * 3, rand() * 3)
144
+ m.castShadow = true
145
+ m.receiveShadow = true
146
+ g.add(m)
147
+ }
148
+
149
+ switch (params.kind) {
150
+ // =====================================================================
151
+ // DECIDUOUS & ORNAMENTAL TREES
152
+ // =====================================================================
153
+ case 'tree-oak-deciduous':
154
+ case 'tree-maple-japanese':
155
+ case 'tree-olive-ornamental': {
156
+ const potBaseY = buildPlanterPot(g, potStyle, Math.min(0.36, r * 0.32), Math.min(0.46, h * 0.18), pool)
157
+ const availH = Math.max(0.5, h - potBaseY)
158
+ const barkMat = pool.bark(params.kind === 'tree-olive-ornamental' ? '#7c7368' : '#5a4332')
159
+
160
+ // Primary trunk
161
+ const trunkH = availH * (params.kind === 'tree-maple-japanese' ? 0.42 : 0.48)
162
+ const trunkR = Math.max(0.04, r * (params.kind === 'tree-oak-deciduous' ? 0.12 : 0.09))
163
+ const trunk = new Mesh(new CylinderGeometry(trunkR * 0.65, trunkR * 1.18, trunkH, 10), barkMat)
164
+ trunk.position.set(0, potBaseY + trunkH / 2, 0)
165
+ trunk.castShadow = true
166
+ trunk.receiveShadow = true
167
+ g.add(trunk)
168
+
169
+ // Radiating primary branches
170
+ const branchCount = params.kind === 'tree-oak-deciduous' ? 6 : 5
171
+ const branchTips: Array<[number, number, number]> = []
172
+ for (let i = 0; i < branchCount; i++) {
173
+ const angle = (i / branchCount) * Math.PI * 2 + (rand() - 0.5) * 0.45
174
+ const tilt = 0.45 + rand() * 0.35
175
+ const bLen = availH * (0.34 + rand() * 0.12)
176
+ const bMesh = new Mesh(new CylinderGeometry(trunkR * 0.25, trunkR * 0.52, bLen, 7), barkMat)
177
+ const startY = potBaseY + trunkH * (0.76 + rand() * 0.2)
178
+ const dx = Math.sin(tilt) * Math.cos(angle) * (bLen * 0.5)
179
+ const dy = Math.cos(tilt) * (bLen * 0.5)
180
+ const dz = Math.sin(tilt) * Math.sin(angle) * (bLen * 0.5)
181
+ bMesh.position.set(dx, startY + dy, dz)
182
+ bMesh.rotation.order = 'YXZ'
183
+ bMesh.rotation.y = -angle + Math.PI / 2
184
+ bMesh.rotation.x = tilt
185
+ bMesh.castShadow = true
186
+ g.add(bMesh)
187
+ branchTips.push([dx * 1.9, startY + dy * 1.9, dz * 1.9])
188
+ }
189
+
190
+ // Canopy foliage clusters (evergreen olive keeps silver-green year round; deciduous drops in winter)
191
+ const palette =
192
+ params.kind === 'tree-olive-ornamental'
193
+ ? ['#7d9478', '#8ea688', '#687d63']
194
+ : resolveDeciduousPalette(params.kind, season)
195
+
196
+ if (palette.length > 0) {
197
+ const mats = palette.map((hex) => pool.foliage(hex))
198
+ // Central crown
199
+ addBlob(0, potBaseY + availH * 0.78, 0, r * 0.62, mats[0]!, 1.12, 0.78, 1.12)
200
+ for (let i = 0; i < branchTips.length; i++) {
201
+ const [tx, ty, tz] = branchTips[i]!
202
+ const m = mats[i % mats.length]!
203
+ addBlob(tx, Math.min(potBaseY + availH * 0.88, ty + r * 0.14), tz, r * (0.44 + rand() * 0.16), m, 1.15, 0.76, 1.15)
204
+ }
205
+ // Secondary outer leaf puffs for organic depth
206
+ for (let k = 0; k < 5; k++) {
207
+ const a = (k / 5) * Math.PI * 2 + 0.35
208
+ addBlob(
209
+ Math.cos(a) * r * 0.42,
210
+ potBaseY + availH * (0.72 + rand() * 0.16),
211
+ Math.sin(a) * r * 0.42,
212
+ r * 0.36,
213
+ mats[(k + 1) % mats.length]!,
214
+ 1.1,
215
+ 0.72,
216
+ 1.1,
217
+ )
218
+ }
219
+ }
220
+ return g
221
+ }
222
+
223
+ // =====================================================================
224
+ // EVERGREEN CONIFERS (PINE / CYPRESS)
225
+ // =====================================================================
226
+ case 'tree-pine-evergreen': {
227
+ const barkMat = pool.bark('#4f3829')
228
+ const trunk = new Mesh(new CylinderGeometry(r * 0.05, r * 0.13, h * 0.45, 10), barkMat)
229
+ trunk.position.set(0, h * 0.225, 0)
230
+ trunk.castShadow = true
231
+ g.add(trunk)
232
+
233
+ const tiers = 5
234
+ const colors = season === 'winter' ? ['#29533f', '#356650', '#4f7c6b'] : ['#1f4d2e', '#28603a', '#317246']
235
+ const mats = colors.map((c) => pool.foliage(c, 0.84))
236
+ for (let i = 0; i < tiers; i++) {
237
+ const t = i / (tiers - 1)
238
+ const coneR = r * (1.0 - t * 0.68)
239
+ const coneH = h * (0.34 - t * 0.04)
240
+ const coneY = h * (0.28 + t * 0.57)
241
+ const cone = new Mesh(new ConeGeometry(coneR, coneH, 10), mats[i % mats.length]!)
242
+ cone.position.set(0, coneY, 0)
243
+ cone.rotation.y = i * 0.55
244
+ cone.castShadow = true
245
+ cone.receiveShadow = true
246
+ g.add(cone)
247
+ }
248
+ return g
249
+ }
250
+
251
+ case 'tree-cypress-columnar': {
252
+ const barkMat = pool.bark('#513b2c')
253
+ const trunk = new Mesh(new CylinderGeometry(0.05, 0.08, h * 0.25, 8), barkMat)
254
+ trunk.position.set(0, h * 0.125, 0)
255
+ g.add(trunk)
256
+
257
+ const mat1 = pool.foliage('#234c31', 0.82)
258
+ const mat2 = pool.foliage('#2c5e3d', 0.82)
259
+ for (let i = 0; i < 6; i++) {
260
+ const t = i / 5
261
+ const segR = r * (0.85 - t * 0.58)
262
+ const segY = h * (0.2 + t * 0.68)
263
+ addBlob(0, segY, 0, segR, i % 2 === 0 ? mat1 : mat2, 1, 1.9, 1)
264
+ }
265
+ return g
266
+ }
267
+
268
+ // =====================================================================
269
+ // PALM TREE
270
+ // =====================================================================
271
+ case 'tree-palm-fan': {
272
+ const barkMat = pool.bark('#7a624a')
273
+ const segs = 7
274
+ let curX = 0
275
+ let curY = 0
276
+ for (let i = 0; i < segs; i++) {
277
+ const segH = (h * 0.78) / segs
278
+ const segR = Math.max(0.07, 0.18 - i * 0.014)
279
+ const seg = new Mesh(new CylinderGeometry(segR * 0.94, segR * 1.06, segH, 10), barkMat)
280
+ const lean = i * 0.035
281
+ seg.position.set(curX + lean * 0.4, curY + segH / 2, 0)
282
+ seg.rotation.z = -lean
283
+ seg.castShadow = true
284
+ g.add(seg)
285
+ curX += Math.sin(lean) * segH * 0.65
286
+ curY += segH * 0.98
287
+ }
288
+ const frondMat = pool.foliage('#3c7a38', 0.7)
289
+ const frondCount = 10
290
+ for (let i = 0; i < frondCount; i++) {
291
+ const a = (i / frondCount) * Math.PI * 2
292
+ const fLen = r * (0.88 + rand() * 0.22)
293
+ const frond = new Mesh(new BoxGeometry(0.18, 0.03, fLen), frondMat)
294
+ frond.position.set(curX + Math.sin(a) * fLen * 0.46, curY + 0.08, Math.cos(a) * fLen * 0.46)
295
+ frond.rotation.order = 'YXZ'
296
+ frond.rotation.y = a
297
+ frond.rotation.x = 0.42 + (i % 2) * 0.18
298
+ frond.castShadow = true
299
+ g.add(frond)
300
+ }
301
+ return g
302
+ }
303
+
304
+ // =====================================================================
305
+ // BUSHES, HEDGES, HYDRANGEAS & ORNAMENTAL GRASS
306
+ // =====================================================================
307
+ case 'bush-boxwood-round': {
308
+ const potBaseY = buildPlanterPot(g, potStyle, r * 0.62, Math.min(0.35, h * 0.38), pool)
309
+ const availH = h - potBaseY
310
+ const mats = [pool.foliage('#2f6a34'), pool.foliage('#3b7d40'), pool.foliage('#26582a')]
311
+ addBlob(0, potBaseY + availH * 0.48, 0, r * 0.78, mats[0]!, 1.05, availH / (r * 1.6), 1.05)
312
+ for (let i = 0; i < 6; i++) {
313
+ const a = (i / 6) * Math.PI * 2
314
+ addBlob(
315
+ Math.cos(a) * r * 0.45,
316
+ potBaseY + availH * (0.38 + rand() * 0.22),
317
+ Math.sin(a) * r * 0.45,
318
+ r * 0.44,
319
+ mats[i % mats.length]!,
320
+ )
321
+ }
322
+ return g
323
+ }
324
+
325
+ case 'bush-hedge-row': {
326
+ const lengthM = Math.max(1.2, r * 2)
327
+ const depthM = Math.min(0.85, Math.max(0.45, r * 0.62))
328
+ const baseMat = pool.foliage('#285b2e', 0.85)
329
+ const tuftMat = pool.foliage('#36723d', 0.82)
330
+ const core = new Mesh(new BoxGeometry(lengthM, h * 0.88, depthM), baseMat)
331
+ core.position.set(0, h * 0.44, 0)
332
+ core.castShadow = true
333
+ core.receiveShadow = true
334
+ g.add(core)
335
+ const puffs = Math.max(4, Math.round(lengthM / 0.42))
336
+ for (let i = 0; i < puffs; i++) {
337
+ const px = -lengthM / 2 + ((i + 0.5) * lengthM) / puffs
338
+ addBlob(px, h * 0.86, (rand() - 0.5) * 0.14, depthM * 0.46, tuftMat, 1.15, 0.65, 0.95)
339
+ }
340
+ return g
341
+ }
342
+
343
+ case 'bush-flowering-hydrangea': {
344
+ const leafMat = pool.foliage(season === 'autumn' ? '#7a6f35' : '#356d38')
345
+ const bloomColors = season === 'winter' ? ['#9c8d7a'] : ['#818cf8', '#a78bfa', '#c084fc', '#e0e7ff']
346
+ const bloomMats = bloomColors.map((c) => pool.foliage(c, 0.72))
347
+ addBlob(0, h * 0.42, 0, r * 0.76, leafMat, 1.1, 0.82, 1.1)
348
+ for (let i = 0; i < 6; i++) {
349
+ const a = (i / 6) * Math.PI * 2
350
+ addBlob(Math.cos(a) * r * 0.46, h * 0.36, Math.sin(a) * r * 0.46, r * 0.42, leafMat)
351
+ }
352
+ // Hydrangea flower domes
353
+ for (let f = 0; f < 9; f++) {
354
+ const a = (f / 9) * Math.PI * 2 + rand() * 0.4
355
+ const dist = f === 0 ? 0 : r * (0.35 + rand() * 0.32)
356
+ const fy = h * (f === 0 ? 0.82 : 0.56 + rand() * 0.24)
357
+ const bloom = new Mesh(new DodecahedronGeometry(r * 0.19, 1), bloomMats[f % bloomMats.length]!)
358
+ bloom.position.set(Math.cos(a) * dist, fy, Math.sin(a) * dist)
359
+ bloom.castShadow = true
360
+ g.add(bloom)
361
+ }
362
+ return g
363
+ }
364
+
365
+ case 'plant-ornamental-grass': {
366
+ const bladeColor = season === 'autumn' || season === 'winter' ? '#b89f6d' : '#5d8a3c'
367
+ const bladeMat = pool.foliage(bladeColor, 0.78)
368
+ const plumeMat = pool.foliage('#dfd3b8', 0.88)
369
+ const blades = 18
370
+ for (let i = 0; i < blades; i++) {
371
+ const a = (i / blades) * Math.PI * 2 + rand() * 0.2
372
+ const bH = h * (0.72 + rand() * 0.32)
373
+ const blade = new Mesh(new ConeGeometry(0.032, bH, 4), bladeMat)
374
+ const lean = 0.28 + rand() * 0.4
375
+ blade.position.set(Math.cos(a) * Math.sin(lean) * bH * 0.38, bH * 0.44, Math.sin(a) * Math.sin(lean) * bH * 0.38)
376
+ blade.rotation.order = 'YXZ'
377
+ blade.rotation.y = -a + Math.PI / 2
378
+ blade.rotation.x = lean
379
+ blade.castShadow = true
380
+ g.add(blade)
381
+ if (i % 3 === 0) {
382
+ const plume = new Mesh(new SphereGeometry(0.055, 7, 6), plumeMat)
383
+ plume.scale.set(0.65, 2.2, 0.65)
384
+ plume.position.set(Math.cos(a) * Math.sin(lean) * bH * 0.72, bH * 0.86, Math.sin(a) * Math.sin(lean) * bH * 0.72)
385
+ g.add(plume)
386
+ }
387
+ }
388
+ return g
389
+ }
390
+
391
+ // =====================================================================
392
+ // INDOOR POTTED PLANTS & RAISED PLANTERS
393
+ // =====================================================================
394
+ case 'plant-fiddle-leaf-fig': {
395
+ const potH = h * 0.24
396
+ const potR = Math.min(0.22, r * 0.56)
397
+ const baseY = buildPlanterPot(g, potStyle === 'none' ? 'woven-basket' : potStyle, potR, potH, pool)
398
+ const stemMat = pool.bark('#5c4634')
399
+ const leafMat = pool.foliage('#2b6a30', 0.48)
400
+ const availH = h - baseY
401
+ const stem = new Mesh(new CylinderGeometry(0.014, 0.024, availH * 0.78, 8), stemMat)
402
+ stem.position.set(0, baseY + availH * 0.39, 0)
403
+ g.add(stem)
404
+ for (let i = 0; i < 14; i++) {
405
+ const t = i / 13
406
+ const a = i * 2.399 // golden angle phyllotaxis
407
+ const ly = baseY + availH * (0.34 + t * 0.6)
408
+ const radOff = 0.08 + (1 - t * 0.4) * r * 0.48
409
+ const leaf = new Mesh(new SphereGeometry(0.11, 8, 6), leafMat)
410
+ leaf.scale.set(0.95, 0.14, 1.45)
411
+ leaf.position.set(Math.cos(a) * radOff, ly, Math.sin(a) * radOff)
412
+ leaf.rotation.order = 'YXZ'
413
+ leaf.rotation.y = -a + Math.PI / 2
414
+ leaf.rotation.x = 0.45 - t * 0.25
415
+ leaf.castShadow = true
416
+ g.add(leaf)
417
+ }
418
+ return g
419
+ }
420
+
421
+ case 'plant-monstera-potted':
422
+ case 'plant-fern-hanging': {
423
+ const potH = h * 0.32
424
+ const potR = Math.min(0.2, r * 0.56)
425
+ const baseY = buildPlanterPot(
426
+ g,
427
+ potStyle === 'none' ? (params.kind === 'plant-fern-hanging' ? 'terracotta' : 'ceramic-white') : potStyle,
428
+ potR,
429
+ potH,
430
+ pool,
431
+ )
432
+ const availH = h - baseY
433
+ const leafMat = pool.foliage(params.kind === 'plant-fern-hanging' ? '#2e7d32' : '#246632', 0.52)
434
+ const count = params.kind === 'plant-fern-hanging' ? 16 : 9
435
+ for (let i = 0; i < count; i++) {
436
+ const a = (i / count) * Math.PI * 2 + (rand() - 0.5) * 0.2
437
+ const dist = r * (0.42 + rand() * 0.42)
438
+ const ly = baseY + availH * (0.42 + rand() * 0.48)
439
+ const stem = new Mesh(new CylinderGeometry(0.008, 0.012, ly - baseY, 6), leafMat)
440
+ stem.position.set(Math.cos(a) * dist * 0.4, baseY + (ly - baseY) / 2, Math.sin(a) * dist * 0.4)
441
+ stem.rotation.order = 'YXZ'
442
+ stem.rotation.y = -a + Math.PI / 2
443
+ stem.rotation.x = 0.38
444
+ g.add(stem)
445
+
446
+ const blade = new Mesh(new SphereGeometry(params.kind === 'plant-fern-hanging' ? 0.09 : 0.14, 8, 6), leafMat)
447
+ blade.scale.set(params.kind === 'plant-fern-hanging' ? 0.45 : 1.05, 0.12, params.kind === 'plant-fern-hanging' ? 2.1 : 1.35)
448
+ blade.position.set(Math.cos(a) * dist * 0.8, ly, Math.sin(a) * dist * 0.8)
449
+ blade.rotation.order = 'YXZ'
450
+ blade.rotation.y = -a + Math.PI / 2
451
+ blade.rotation.x = params.kind === 'plant-fern-hanging' ? 0.75 : 0.35
452
+ blade.castShadow = true
453
+ g.add(blade)
454
+ }
455
+ return g
456
+ }
457
+
458
+ case 'plant-snake-planter': {
459
+ const potH = h * 0.36
460
+ const potR = Math.min(0.18, r * 0.78)
461
+ const baseY = buildPlanterPot(g, potStyle === 'none' ? 'ceramic-charcoal' : potStyle, potR, potH, pool)
462
+ const availH = h - baseY
463
+ const bladeMat1 = pool.foliage('#2f6f3e', 0.42)
464
+ const bladeMat2 = pool.foliage('#528c4e', 0.42)
465
+ for (let i = 0; i < 11; i++) {
466
+ const a = (i / 11) * Math.PI * 2 + rand() * 0.3
467
+ const rad = potR * (0.15 + rand() * 0.48)
468
+ const bh = availH * (0.65 + rand() * 0.38)
469
+ const sword = new Mesh(new ConeGeometry(0.042, bh, 4), i % 2 === 0 ? bladeMat1 : bladeMat2)
470
+ sword.scale.set(1, 1, 0.22)
471
+ sword.position.set(Math.cos(a) * rad, baseY + bh / 2, Math.sin(a) * rad)
472
+ sword.rotation.y = a
473
+ sword.rotation.x = (rand() - 0.5) * 0.14
474
+ sword.castShadow = true
475
+ g.add(sword)
476
+ }
477
+ return g
478
+ }
479
+
480
+ case 'plant-succulent-trough': {
481
+ const potH = h * 0.62
482
+ const baseY = buildPlanterPot(g, potStyle === 'none' ? 'concrete-trough' : potStyle, r * 0.8, potH, pool)
483
+ const agaveMat = pool.foliage('#5f8c7a', 0.58)
484
+ const succMat = pool.foliage('#7ba068', 0.62)
485
+ for (const cx of [-r * 0.65, 0, r * 0.65]) {
486
+ for (let i = 0; i < 8; i++) {
487
+ const a = (i / 8) * Math.PI * 2
488
+ const leaf = new Mesh(new ConeGeometry(0.036, 0.24, 5), cx === 0 ? agaveMat : succMat)
489
+ leaf.position.set(cx + Math.cos(a) * 0.08, baseY + 0.1, Math.sin(a) * 0.08)
490
+ leaf.rotation.order = 'YXZ'
491
+ leaf.rotation.y = -a + Math.PI / 2
492
+ leaf.rotation.x = 0.65
493
+ leaf.castShadow = true
494
+ g.add(leaf)
495
+ }
496
+ }
497
+ return g
498
+ }
499
+
500
+ default: {
501
+ const mat = pool.foliage('#357a3c')
502
+ addBlob(0, h * 0.5, 0, r * 0.7, mat)
503
+ return g
504
+ }
505
+ }
506
+ }