@wildshard/sdk 0.2.12 → 0.3.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.
Files changed (72) hide show
  1. package/GUIDE.md +16 -11
  2. package/bin/wildshard.mjs +2 -1
  3. package/docs/api/EXPORT-TIERS.md +12 -3
  4. package/lint/export-tiers.json +9 -0
  5. package/lint/tile-bake-debt.json +26 -1
  6. package/package.json +17 -5
  7. package/scripts/build-shardfiles.mjs +7 -2
  8. package/scripts/preparation-preview.mjs +6 -1
  9. package/scripts/prepare-product.mjs +2 -2
  10. package/scripts/scratch-sweep.mjs +180 -0
  11. package/scripts/wildshard.mjs +1 -1
  12. package/skills/wildshard-mockup-to-model/SKILL.md +5 -3
  13. package/skills/wildshard-upgrade/SKILL.md +4 -4
  14. package/src/cli/help.ts +9 -5
  15. package/src/cli/upload/validate.ts +7 -5
  16. package/src/sharddev/assets.ts +1 -1
  17. package/src/sharddev/bake/compactGlb.ts +1 -1
  18. package/src/sharddev/bake/glbCompression.ts +1 -1
  19. package/src/sharddev/bake/gltfSource.ts +1 -1
  20. package/src/sharddev/bake/placeholders.ts +1 -1
  21. package/src/sharddev/bake/terrain.ts +1 -1
  22. package/src/sharddev/blobBytes.ts +1 -1
  23. package/src/sharddev/blobs.ts +2 -2
  24. package/src/sharddev/cli.ts +17 -4
  25. package/src/sharddev/formatJsonSchema.ts +1 -1
  26. package/src/sharddev/materialGraphFiles.ts +1 -1
  27. package/src/sharddev/newProject.ts +18 -10
  28. package/src/sharddev/outputProduct.ts +2 -2
  29. package/src/sharddev/productOutput.ts +2 -2
  30. package/src/sharddev/project.ts +1 -1
  31. package/src/sharddev/projectMap.ts +1 -1
  32. package/src/sharddev/refusals.ts +4 -2
  33. package/src/sharddev/reportCard.ts +1 -1
  34. package/src/sharddev/scene/author.ts +79 -0
  35. package/src/sharddev/scene/canvas.ts +213 -0
  36. package/src/sharddev/scene/description.ts +170 -0
  37. package/src/sharddev/scene/hash.ts +23 -0
  38. package/src/sharddev/scene/lower.ts +226 -0
  39. package/src/sharddev/scene/shard.ts +38 -0
  40. package/src/sharddev/scene/shardfile.ts +328 -0
  41. package/src/sharddev/threeGate.mjs +14 -0
  42. package/src/sharddev/threePin.mjs +40 -0
  43. package/src/sharddev/watch/page.ts +197 -0
  44. package/src/sharddev/watch/pageEntry.ts +23 -0
  45. package/src/sharddev/watch/proof.mjs +92 -0
  46. package/src/sharddev/watch/protocol.ts +108 -0
  47. package/src/sharddev/watch/socket.ts +57 -0
  48. package/src/sharddev/watch/watch.ts +209 -0
  49. package/src/shards/_template/card/landscape.jpg +0 -0
  50. package/src/shards/_template/card/portrait.jpg +0 -0
  51. package/src/shards/_template/card/thumb.jpg +0 -0
  52. package/src/shards/_template/data/card.json +21 -14
  53. package/src/shards/_template/data/clientScripts.json +27 -27
  54. package/src/shards/_template/data/creatures.json +5 -5
  55. package/src/shards/_template/data/encounters.json +2 -2
  56. package/src/shards/_template/data/layout.json +56 -25
  57. package/src/shards/_template/data/look.json +450 -220
  58. package/src/shards/_template/data/quests.json +2 -2
  59. package/src/shards/_template/data/water.json +131 -4
  60. package/src/shards/_template/generators/landscape.ts +19 -7
  61. package/src/shards/_template/generators/product.ts +7 -5
  62. package/src/shards/_template/generators/templatePropsSource.ts +3 -1
  63. package/src/shards/_template/generators/terrain.ts +28 -4
  64. package/src/shards/_template/generators/weather.ts +128 -0
  65. package/src/shards/_template/generators/world.ts +274 -98
  66. package/src/shards/_template/hero.json +6 -6
  67. package/src/shards/_template/manifest.json +21 -14
  68. package/src/shards/authoring-slice/generators/shard.ts +6 -0
  69. package/src/shards/authoring-slice/generators/textures.ts +173 -0
  70. package/src/shards/authoring-slice/generators/world.ts +415 -0
  71. package/src/shards/authoring-slice/shard.config.ts +7 -0
  72. package/src/shards/_template/assets/f2db05998615ce1cb79ea96be32c168842eb6a2b34ec01feb86d36404603ee54 +0 -0
@@ -1,8 +1,11 @@
1
1
  import { BoxCollider } from '@wildshard/sdk/physics';
2
2
  import type { PropsBakeSource } from '@wildshard/sdk/bake/props';
3
3
  import { measureUv, type MeasureRole } from '@wildshard/sdk/measure';
4
- import { BoxGeometry, BufferGeometry, CircleGeometry, CylinderGeometry, Float32BufferAttribute, Group, IcosahedronGeometry, Material, Matrix4, Mesh, MeshStandardMaterial, PointLight, Vector3, type Object3D } from 'three';
4
+ import { BoxGeometry, BufferGeometry, CircleGeometry, CylinderGeometry, Float32BufferAttribute, Group, IcosahedronGeometry, LatheGeometry, Material, Matrix4, Mesh, MeshStandardMaterial, PointLight, Vector2, Vector3, type Object3D } from 'three';
5
5
  import layout from '../data/layout.json' with { type: 'json' };
6
+ import { POND, pondEdge, pondSDF } from './landscape';
7
+ import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
8
+ import { coursedBox, lumpyCrown, surfaceBox, weather } from './weather';
6
9
 
7
10
  /**
8
11
  * Build-time only (SHARD-PLATFORM SF16): the template's grey-box shapes as the props baker
@@ -11,7 +14,7 @@ import layout from '../data/layout.json' with { type: 'json' };
11
14
  * runtime builders' shapes, kept here so the bake no longer reads the runtime modules (retired with the template
12
15
  * chunk); nothing here is imported by the client.
13
16
  */
14
- export const poolMask = (x: number, z: number): boolean => Math.hypot(x - 25, z - 20) < 5;
17
+ export const poolMask = (x: number, z: number): boolean => pondSDF(x, z) < 0;
15
18
 
16
19
  /**
17
20
  * A w × h × d box whose first UV set carries SF56's measure data (its `role` and each face's own metres and size: the
@@ -33,11 +36,44 @@ export function measureBox(w: number, h: number, d: number, role: MeasureRole):
33
36
  * hut's blocks a warmer grey, moss its own green (so a trim cap stays moss under a trim tint), wood and iron for the hut's
34
37
  * posts, bench, barrels and lamp.
35
38
  */
36
- export const STONE = 0x847a7d, HUT_STONE = 0x8d8479, MOSS = 0x5b7a30, MOSS_LIGHT = 0x76963c, WOOD = 0x86592f, WOOD_DARK = 0x5e3d22, IRON = 0x3a3634, CAP_RED = 0xb23a26, STEM = 0xd6cbb2;
37
- /** LF1-7: the door lamp's post (the lantern hangs 1 m left of it, over the doorway's right edge, in L0 tile 0/4/3). */
38
- export const LAMP_POST = { x: 1.55, z: -8.3 } as const;
39
+ export const STONE = 0x8c867a, HUT_STONE = 0x9a9080, MOSS = 0x5b7a30, MOSS_LIGHT = 0x76963c, WOOD = 0x86592f, WOOD_DARK = 0x5e3d22, IRON = 0x3a3634, CAP_RED = 0xb23a26, STEM = 0xd6cbb2, SLAB = 0x9a9488;
40
+ /** The moss gate's opening half width and pillar size: the yard's west wall stops at the pillars' outer faces. */
41
+ export const GATE_GAP = 1.5, GATE_PILLAR = 1.35;
42
+ /** M2: the moss bridge's six stones span the pond's long axis, their centres this far either side of its middle. */
43
+ export const BRIDGE_STONES = 6, BRIDGE_REACH = 5.2;
44
+ /** The arena's way in, as an angle round `layout.ARENA`: M2's arch faces west, toward the yard's east gap. */
45
+ const arenaDoor = (): number => -Math.PI / 2;
46
+ /** M2: the arena ring is a low mossy wall (the cleanroom's); the arch and its gate stand taller. */
47
+ export const ARENA_WALL = 2.0, ARENA_GATE = 3.0;
48
+ /** M2: the hut room's floor planks and rug. */
49
+ export const PLANK = 0xa07a58, CLOTH = 0x8a3a2a;
50
+ const [[YX0, YZ0], [YX1, YZ1]] = layout.YARD as [[number, number], [number, number]];
51
+ /** The ivy's and the hanging moss's greens. */
52
+ export const IVY = 0x3d6a24, DRAPE = 0x5a7a2a;
53
+ /** The yard's stepping-slab paths (TEMPLATES-CLEANROOM M2, the cleanroom's): spawn to the hut door, to the moss gate, to
54
+ * brazier A's pad, to the arena arch, from the gate to the pond's east bank and from its west bank to brazier B. */
55
+ const G0 = layout.MOSSGATE, A0 = layout.BRAZIERS[0] ?? [0, 0], B0 = layout.BRAZIERS[1] ?? [0, 0];
56
+ export const PATHS: readonly (readonly [number, number])[][] = [
57
+ [[0, 2.2], ...(layout.TRAIL[0] ?? []).slice(1).map(([x = 0, z = 0]): [number, number] => [x, z]).slice(0, -1), [layout.HUT.x, layout.HUT.doorZ + 0.6]],
58
+ [[-1.4, 0.6], [-5, 0.2], [G0.x + 5.2, G0.z]],
59
+ [[0.8, -1.2], [4.2, -4], [A0[0] ?? 0, (A0[1] ?? 0) + 2.1]],
60
+ [[1.5, 0.6], [6, -1.2], [layout.ARENA.x - layout.ARENA.radius - 1.4, layout.ARENA.z]],
61
+ [[G0.x - 1.4, G0.z], [POND.x + POND.hx + 0.9, POND.z]],
62
+ [[POND.x - POND.hx - 0.6, POND.z], [(B0[0] ?? 0) + 1.3, B0[1] ?? 0]],
63
+ ];
64
+ /** The practice ramp's foot (its treads climb 2 m toward −z), outside the yard's south wall. */
65
+ export const RAMP = { x: 4, z: 20 } as const;
66
+ /** LF1-7: the door lamp's post, right of the hut door (the lantern hangs 1 m left of it, over the doorway's right edge). */
67
+ export const LAMP_POST = { x: layout.HUT.x + 1.55, z: layout.HUT.doorZ + 0.7 } as const;
39
68
  /** a grey-box shape (role 1, structure: stone; role 2, trim: moss) */
40
- const cube = (w: number, h: number, d: number, color?: number, role: MeasureRole = 1): Mesh => new Mesh(measureBox(w, h, d, role), new MeshStandardMaterial({ color: color ?? (role === 2 ? MOSS : STONE), flatShading: true }));
69
+ let walls = 0;
70
+ /** TEMPLATES-CLEANROOM M2: a tall thin box is a coursed masonry wall (`coursedBox`), anything else a plain box. */
71
+ const shape = (w: number, h: number, d: number, stone: boolean): BufferGeometry => (stone && h >= 1.2 && Math.max(w, d) >= 1.8 && Math.min(w, d) <= 1.6 ? coursedBox(w, h, d, walls++) : surfaceBox(w, h, d));
72
+ const cube = (w: number, h: number, d: number, color?: number, role: MeasureRole = 1): Mesh => {
73
+ const geometry = shape(w, h, d, color === undefined || color === STONE || color === HUT_STONE), mesh = new Mesh(geometry, new MeshStandardMaterial({ color: color ?? (role === 2 ? MOSS : STONE), flatShading: true }));
74
+ if (geometry.getAttribute('position').count > 24) mesh.userData.plainBox = [w, h, d];
75
+ return mesh;
76
+ };
41
77
  /** What the shapes need: a root, a scope that owns their buffers, the registry sink, the seeded RNG and the ground height. */
42
78
  /** One authored scene part and its collider rows, before SDK compilation. No native registry owns it. */
43
79
  export interface TemplatePart {
@@ -66,17 +102,20 @@ export function buildTemplateWorld(ctx: TemplateWorldPorts, propCount: number):
66
102
  colliders.push(BoxCollider.fromData({ kind: 'box', x: layout.HUT.x + x, y: (y + 3 + y) / 2, z: layout.HUT.z + z, hx: hw, hy: Math.max(0.005, (y + 3 - y) / 2), hz: hd, yaw: -0, surface: 'wood' }).toColliderData());
67
103
  }
68
104
  ctx.root.add(hut); ctx.piece({ id: 'template.hut', name: 'Grey hut', category: 'buildings', file, object: hut, colliders, surface: 'wood' });
105
+ // M2: the furnished room inside and the ivy up the front corners, their own piece so the coarse tiles and far proxy skip them
106
+ const room = hutInterior(); room.position.copy(hut.position);
107
+ ctx.root.add(room); ctx.piece({ id: 'template.hut-interior', name: 'Hut room and ivy', category: 'props', file, object: room });
69
108
  const panel = cube(1.8, 2.5, 0.2, WOOD_DARK, 1); panel.position.set(layout.HUT.x, y + 1.2, layout.HUT.doorZ);
70
109
  ctx.root.add(panel); ctx.piece({ id: 'template.door', name: 'Open hut door', category: 'buildings', file, object: panel,
71
110
  colliders: [BoxCollider.fromData({ kind: 'box', x: layout.HUT.x, y: (y + 2.5 + y) / 2, z: layout.HUT.doorZ, hx: 0.9, hy: Math.max(0.005, (y + 2.5 - y) / 2), hz: 0.1, yaw: -0, surface: 'wood' }).toColliderData()], active: () => true });
72
- // Mossgate Hollow v3: braziers A, B and C on labelled pads where the story puts them (LF1-0): A by the moss gate, B on
73
- // the pond's far bank, C beside the arena gate. Unlit until their fields say so.
111
+ // Braziers A, B and C on lettered pads where the story puts them (TEMPLATES-CLEANROOM M2, the goldens' composition): A heads
112
+ // the row at the back of the yard, B waits across the moss bridge, C stands by the arena arch. The row's two beacons
113
+ // (layout.ROW) light with B and C. Unlit until their fields say so.
74
114
  const braziers = new Group(), stands: NonNullable<TemplatePart['colliders']> = [];
75
- for (const [x, z] of layout.BRAZIERS) {
115
+ for (const [x, z] of [...layout.BRAZIERS, ...layout.ROW]) {
76
116
  if (x === undefined || z === undefined) continue;
77
- const by = heightAt(x, z), pad = cube(3, 0.1, 3, 0x6f6866, 1), base = cube(1.1, 0.4, 1.1, STONE), stem = cube(0.6, 0.7, 0.6, STONE), bowl = cube(1.3, 0.3, 1.3, 0x6c6264, 1);
78
- pad.position.set(x, by + 0.05, z); base.position.set(x, by + 0.3, z); stem.position.set(x, by + 0.85, z); bowl.position.set(x, by + 1.35, z);
79
- braziers.add(pad, base, stem, bowl);
117
+ const by = heightAt(x, z);
118
+ braziers.add(brazierStand(x, by, z));
80
119
  stands.push(BoxCollider.fromData({ kind: 'box', x, y: by + 0.75, z, hx: 0.55, hy: 0.75, hz: 0.55, yaw: -0, surface: 'stone' }).toColliderData());
81
120
  }
82
121
  ctx.root.add(braziers); ctx.piece({ id: 'template.braziers', name: 'Braziers A, B and C', category: 'props', file, object: braziers, colliders: stands, surface: 'stone' });
@@ -105,18 +144,23 @@ export function buildTemplateWorld(ctx: TemplateWorldPorts, propCount: number):
105
144
  ctx.root.add(dressing.object); ctx.piece({ id: 'template.dressing', name: 'Mossgate dressing', category: 'nature', file, object: dressing.object, colliders: dressing.colliders, surface: 'stone' });
106
145
  const foliage = mossgateFoliage(heightAt);
107
146
  ctx.root.add(foliage.object); ctx.piece({ id: 'template.foliage', name: 'Mossgate trees, tufts and ferns', category: 'nature', file, object: foliage.object, colliders: foliage.colliders, surface: 'wood' });
108
- const ramp = new Group(), from: [number, number, number] = [8, heightAt(8, -8), -8], to: [number, number, number] = [8, from[1] + 2, -14];
109
- for (let i = 0; i < 10; i++) { const tread = cube(3, 0.2, 0.6, 0x888888, 2); tread.position.set(8, from[1] + (i + 1) * 0.2 - 0.1, -8 - (i + 0.5) * 0.6); ramp.add(tread); }
110
- const slope = cube(3, 0.24, Math.sqrt(40), 0x888888, 2); slope.position.set(12, from[1] + 0.9, -11); slope.rotation.x = Math.atan2(2, 6); ramp.add(slope);
147
+ // the practice ramp and its stair treads, outside the yard's south wall (M2 moved it off the brazier row)
148
+ const { x: rx, z: rz } = RAMP, ramp = new Group(), from: [number, number, number] = [rx, heightAt(rx, rz), rz], to: [number, number, number] = [rx, from[1] + 2, rz - 6];
149
+ for (let i = 0; i < 10; i++) { const tread = cube(3, 0.2, 0.6, 0x888888, 2); tread.position.set(rx, from[1] + (i + 1) * 0.2 - 0.1, rz - (i + 0.5) * 0.6); ramp.add(tread); }
150
+ const slope = cube(3, 0.24, Math.sqrt(40), 0x888888, 2); slope.position.set(rx + 4, from[1] + 0.9, rz - 3); slope.rotation.x = Math.atan2(2, 6); ramp.add(slope);
111
151
  ctx.root.add(ramp); ctx.piece({ id: 'template.ramp', name: 'Ramp and stair treads', category: 'buildings', file, object: ramp,
112
- colliders: [{ kind: 'box', x: 12, y: from[1] + 0.9, z: -11, hx: 1.5, hy: 0.12, hz: Math.sqrt(40) / 2,
152
+ colliders: [{ kind: 'box', x: rx + 4, y: from[1] + 0.9, z: rz - 3, hx: 1.5, hy: 0.12, hz: Math.sqrt(40) / 2,
113
153
  rot: { x: Math.sin(Math.atan2(2, 6) / 2), y: 0, z: 0, w: Math.cos(Math.atan2(2, 6) / 2) }, surface: 'wood' },
114
154
  { kind: 'treads', from: { x: from[0], y: from[1], z: from[2] }, to: { x: to[0], y: to[1], z: to[2] }, width: 3, count: 10, surface: 'wood' }], surface: 'wood' });
155
+ // M2: the yard's low coursed walls, the pond garden's and their moss caps, ivy and hanging moss
156
+ const yard = yardWalls(heightAt);
157
+ ctx.root.add(yard.object); ctx.piece({ id: 'template.yard-walls', name: 'Yard walls', category: 'buildings', file, object: yard.object, colliders: yard.colliders, surface: 'stone' });
115
158
  const props = new Group(), random = ctx.rng.stream('cosmetic');
116
159
  for (let i = 0; i < propCount; i++) { const x = random.range(-25, 25), z = random.range(5, 30), prop = cube(0.6, 0.6, 0.6); prop.position.set(x, heightAt(x, z) + 0.3, z); props.add(prop); }
117
160
  ctx.root.add(props); ctx.piece({ id: 'template.props', name: 'Grey props', category: 'props', file, object: props });
118
161
  const pool = new Mesh(new CircleGeometry(5, 24), new MeshStandardMaterial({ color: 0x9aa6b0, transparent: true, opacity: 0.7 }));
119
- pool.rotation.x = -Math.PI / 2; pool.position.set(25, 0, 20); ctx.root.add(pool);
162
+ pool.rotation.x = -Math.PI / 2; pool.position.set(POND.x, 0, POND.z); ctx.root.add(pool);
163
+ weather(ctx.root, heightAt);
120
164
  ctx.root.traverse((node) => {
121
165
  if (!(node instanceof Mesh)) return;
122
166
  if (node.geometry instanceof BufferGeometry) ctx.scope.own(node.geometry);
@@ -135,10 +179,8 @@ type Colliders = NonNullable<TemplatePart['colliders']>;
135
179
  /** A stone box collider at (x, y, z), half sizes `hx`, `hy`, `hz`, turned `yaw`. */
136
180
  const stoneBox = (x: number, y: number, z: number, hx: number, hy: number, hz: number, yaw = 0): Colliders[number] =>
137
181
  BoxCollider.fromData({ kind: 'box', x, y, z, hx, hy, hz, yaw: yaw === 0 ? -0 : yaw, surface: 'stone' }).toColliderData();
138
- /** L0 tile 0/4/3 (x in [0, 62.5), z in [−62.5, 0)): the one yard tile with draws to spare for the red caps' emissive draw. */
139
- export const redCap = (x: number, z: number): boolean => x >= 0.3 && x < 62 && z < -0.3 && z >= -62;
140
- /** The dressing's mushroom positions, as `mossgateDressing` places them. */
141
- const MUSHROOMS: [number, number][] = [[-1.1, -4.6], [0.9, -6.6], [-3.6, -6.9], [4.4, -3.2], [-5.0, -3.6], [2.2, -8.6], [-1.9, -7.4]];
182
+ /** The dressing's mushroom clumps, as `mossgateDressing` places them: by the hut path, the hut and the boulders. */
183
+ const MUSHROOMS: [number, number][] = [[-1.7, -6.0], [1.9, -9.4], [-6.4, -10.6], [3.2, -3.4], [-4.6, -4.0], [-0.2, -12.4], [-7.6, -6.8], [6.9, 2.6], [-8.8, 5.2]];
142
184
  /**
143
185
  * Mossgate Hollow v3 (MH-1b): the yard's dressing, one step past grey-box and still a test level. A stepping-slab path
144
186
  * from spawn to the hut door, the door lamp, mossy boulders, ferns and mushroom clumps, all measure boxes (the dev-map
@@ -147,11 +189,20 @@ const MUSHROOMS: [number, number][] = [[-1.1, -4.6], [0.9, -6.6], [-3.6, -6.9],
147
189
  export function mossgateDressing(heightAt: (x: number, z: number) => number): { object: Group; colliders: NonNullable<TemplatePart['colliders']> } {
148
190
  const root = new Group(), colliders: NonNullable<TemplatePart['colliders']> = [];
149
191
  const box = (x: number, y: number, z: number, hx: number, hy: number, hz: number): void => { colliders.push(BoxCollider.fromData({ kind: 'box', x, y, z, hx, hy, hz, yaw: -0, surface: 'stone' }).toColliderData()); };
150
- // the slab path: eight stepping stones from spawn to the door, each a little off the line and turned
151
- for (let i = 0; i < 8; i++) {
152
- const z = -1.4 - i * 1.0, x = jitter(i, 1) * 0.28, w = 1.05 + jitter(i, 2) * 0.2, d = 0.72 + jitter(i, 3) * 0.12;
153
- root.add(block(w, 0.08, d, 1, x, heightAt(x, z) + 0.04, z, jitter(i, 4) * 0.35));
192
+ // the slab paths: flat irregular stepping stones along each walk, each a little off the line and turned (the cleanroom's)
193
+ let n = 0;
194
+ for (const points of PATHS) for (let i = 0; i < points.length - 1; i++) {
195
+ const [ax = 0, az = 0] = points[i] ?? [], [bx = 0, bz = 0] = points[i + 1] ?? [], len = Math.hypot(bx - ax, bz - az), steps = Math.max(1, Math.round(len / 1.15)), dir = Math.atan2(bx - ax, bz - az);
196
+ for (let k = i === 0 ? 0 : 1; k <= steps; k++, n++) {
197
+ const t = k / steps, x = ax + (bx - ax) * t + jitter(n, 1) * 0.15, z = az + (bz - az) * t + jitter(n, 2) * 0.1;
198
+ if (poolMask(x, z)) continue;
199
+ root.add(block(1.05 + jitter(n, 3) * 0.18, 0.08, 0.82 + jitter(n, 4) * 0.1, 1, x, heightAt(x, z) + 0.035, z, dir + jitter(n, 5) * 0.22, 0, SLAB));
200
+ }
154
201
  }
202
+ // the sign post at the fork: a post and a board turned toward the hut path
203
+ const [sx = 0, sz = 0] = layout.SIGN, sy = heightAt(sx, sz);
204
+ root.add(block(0.16, 1.9, 0.16, 1, sx, sy + 0.85, sz, 0, 0, WOOD_DARK), block(1.2, 0.34, 0.07, 1, sx - 0.15, sy + 1.4, sz, 0.35, 0, WOOD), block(0.5, 0.2, 0.06, 1, sx + 0.1, sy + 1.02, sz, -0.3, 0, WOOD));
205
+ box(sx, sy + 0.85, sz, 0.1, 0.85, 0.1);
155
206
  // the door lamp: a post right of the door, an arm over the doorway and a lamp box under a moss cap
156
207
  const { x: lx, z: lz } = LAMP_POST, ly = heightAt(lx, lz);
157
208
  root.add(block(0.18, 2.6, 0.18, 1, lx, ly + 1.3, lz, 0, 0, IRON), block(1.2, 0.1, 0.1, 1, lx - 0.5, ly + 2.5, lz, 0, 0, IRON), block(0.06, 0.2, 0.06, 1, lx - 1.0, ly + 2.36, lz, 0, 0, IRON));
@@ -162,7 +213,7 @@ export function mossgateDressing(heightAt: (x: number, z: number) => number): {
162
213
  hutFront(root, colliders, heightAt);
163
214
  // mossy boulders: two or three tumbled stones and a moss cap each. LF1-7 checks: the small one moved from (-2.6, 2.6),
164
215
  // which sat on the spawn-to-arena walk, to between the arena and brazier C walks (foliage.test.ts keeps them clear)
165
- const boulders: [number, number, number][] = [[-4.4, -6.2, 1.3], [-5.2, 1.9, 1.0], [5.2, -2.6, 1.15], [-6.8, -10.4, 1.6], [13.2, -7.4, 1.4], [-1.0, 4.0, 0.8]];
216
+ const boulders: [number, number, number][] = [[-6.2, -4.6, 1.3], [6.4, 3.4, 1.35], [-8.2, -11.2, 1.2], [10.6, -16.2, 1.35], [-8.4, 6.6, 1.2], [7.8, 5.8, 1.0], [-6.8, -17.3, 0.95], [2.4, -17.2, 0.85], [POND.x + POND.hx + 2.4, POND.z + 4.5, 1.35], [POND.x - POND.hx - 2.2, POND.z - 4.6, 1.2], [13.8, 3.4, 1.0], [-3.6, 5.4, 0.8]];
166
217
  boulders.forEach(([x, z, s], i) => {
167
218
  const y = heightAt(x, z);
168
219
  root.add(block(s, s * 0.7, s * 0.9, 1, x, y + s * 0.3, z, jitter(i, 5) * 1.5, jitter(i, 6) * 0.18));
@@ -172,7 +223,7 @@ export function mossgateDressing(heightAt: (x: number, z: number) => number): {
172
223
  box(x, y + s * 0.35, z, s * 0.55, s * 0.35, s * 0.5);
173
224
  });
174
225
  // ferns: seven moss fronds fanned up and out from one root (LF1-5: tent fronds, half a box frond's bytes)
175
- const ferns: [number, number, number][] = [[-3.45, -8.1, 1], [3.5, -8.1, 1], [-3.5, -5.2, 0.9], [1.7, -3.3, 0.8], [-1.6, -2.0, 0.75], [6.0, -4.4, 0.9], [-5.3, -8.4, 1.1], [-4.4, -0.6, 0.85], [8.3, -8.6, 1], [-3.2, -9.6, 0.8]];
226
+ const ferns: [number, number, number][] = [[-1.6, -12.4, 1], [-6.8, -12.0, 1.1], [-7.2, -12.8, 0.9], [-8.8, -2.9, 1], [-8.8, 2.9, 1], [-2.2, -5.4, 0.9], [3.1, -6.2, 0.8], [1.6, -11.8, 0.9], [-5.6, -3.6, 0.8], [7.2, 4.8, 0.9]];
176
227
  ferns.forEach(([x, z, s], i) => { root.add(fern(x, heightAt(x, z), z, s, i)); });
177
228
  // mushroom clumps: pale stems under domed caps, by the path and the boulders. LF1-5: a cap in L0 tile 0/4/3 (x ≥ 0, z < 0)
178
229
  // is red (`mushroomCaps`, its own emissive draw); 0/3/3 is at its 8 draws, so a cap there stays a stone box (its bytes
@@ -181,7 +232,6 @@ export function mossgateDressing(heightAt: (x: number, z: number) => number): {
181
232
  for (let k = 0; k < 3; k++) {
182
233
  const mx = x + jitter(i, 20 + k) * 0.28, mz = z + jitter(i, 30 + k) * 0.28, h = 0.16 + (k === 0 ? 0.12 : 0) + jitter(i, 40 + k) * 0.04, y = heightAt(mx, mz);
183
234
  root.add(block(0.06, h, 0.06, 1, mx, y + h / 2, mz, 0, 0, STEM));
184
- if (!redCap(mx, mz)) root.add(block(0.24 - k * 0.04, 0.07, 0.24 - k * 0.04, 1, mx, y + h + 0.03, mz, jitter(i, 50 + k), jitter(i, 60 + k) * 0.2, CAP_RED));
185
235
  }
186
236
  });
187
237
  return { object: root, colliders };
@@ -210,6 +260,80 @@ function tent(points: readonly Vector3[], triangles: readonly [number, number, n
210
260
  const geometry = new BufferGeometry().setAttribute('position', new Float32BufferAttribute(out, 3)); geometry.computeVertexNormals();
211
261
  return foliageUv(geometry, role);
212
262
  }
263
+ /** M2: the brazier stand, the cleanroom's: a lettered slab pad, a stepped plinth, a round stem and a wide lathed bowl whose rim
264
+ * sits 1.5 m over the pad (the flame panel and the fire's particles rise from there). */
265
+ function brazierStand(x: number, by: number, z: number): Group {
266
+ const root = new Group(), bowl: Vector2[] = [new Vector2(0, 0)];
267
+ for (let i = 0; i <= 8; i++) { const t = i / 8; bowl.push(new Vector2(0.26 + 0.5 * Math.sin((t * Math.PI) / 2), t * 0.48)); }
268
+ bowl.push(new Vector2(0.86, 0.5), new Vector2(0.84, 0.55), new Vector2(0.72, 0.5), new Vector2(0, 0.38));
269
+ root.add(block(2.1, 0.1, 2.1, 1, x, by + 0.05, z, 0, 0, SLAB), block(1.18, 0.17, 1.18, 1, x, by + 0.085, z, 0, 0, STONE), block(0.94, 0.6, 0.94, 1, x, by + 0.4, z, 0, 0, STONE));
270
+ const stem = new Mesh(foliageUv(new CylinderGeometry(0.24, 0.36, 0.3, 8), 1), foliageMaterial(STONE)); stem.position.set(x, by + 0.85, z);
271
+ const cup = new Mesh(foliageUv(new LatheGeometry(bowl, 8), 1), foliageMaterial(0x6c6264)); cup.position.set(x, by + 0.95, z);
272
+ root.add(stem, cup);
273
+ return root;
274
+ }
275
+ /** A leafy ivy strand hanging `len` down from (x, y, z): small two-sided leaf diamonds either side of a stem, in the plane turned
276
+ * `yaw` (its width runs along (cos yaw, 0, −sin yaw)), `w` its spread. */
277
+ function ivy(x: number, y: number, z: number, len: number, yaw: number, w: number, seed: number): Mesh {
278
+ const out: number[] = [], ux = Math.cos(yaw), uz = -Math.sin(yaw), nx = Math.sin(yaw), nz = Math.cos(yaw);
279
+ for (let k = 0, d = 0.04; d < len; k++, d += 0.065 + (jitter(seed, 300 + k) + 1) * 0.02) {
280
+ const side = (k % 2 === 0 ? 1 : -1) * (0.3 + (jitter(seed, 320 + k) + 1) * 0.35) * w * 0.5, sway = Math.sin(d * 2.2 + seed) * 0.06;
281
+ const cx = (side + sway) * ux, cz = (side + sway) * uz, cy = -d, s = 0.045 + (jitter(seed, 340 + k) + 1) * 0.02, lift = 0.02 + (jitter(seed, 360 + k) + 1) * 0.02;
282
+ const p = [[cx - s * ux, cy, cz - s * uz], [cx, cy + s * 1.2, cz], [cx + s * ux, cy, cz + s * uz], [cx, cy - s * 0.9, cz]].map(([a = 0, b = 0, c = 0]) => [a + nx * lift, b, c + nz * lift]);
283
+ for (const [i, j, l] of [[0, 1, 2], [0, 2, 3], [0, 2, 1], [0, 3, 2]] as const) for (const q of [p[i], p[j], p[l]]) out.push(...(q ?? [0, 0, 0]));
284
+ }
285
+ const geometry = new BufferGeometry().setAttribute('position', new Float32BufferAttribute(out, 3)); geometry.computeVertexNormals();
286
+ const mesh = new Mesh(foliageUv(geometry, 2), foliageMaterial(IVY)); mesh.position.set(x, y, z); return mesh;
287
+ }
288
+ /** A strip of hanging moss `len` long under a cap's edge at (x, y, z), its ragged lower edge 0.35 to 1 × `h` down; two-sided, in
289
+ * the plane turned `yaw` like `ivy`. */
290
+ function drape(x: number, y: number, z: number, len: number, yaw: number, h: number, seed: number): Mesh {
291
+ const out: number[] = [], ux = Math.cos(yaw), uz = -Math.sin(yaw), n = Math.max(2, Math.round(len * 4));
292
+ const at = (c: number, down: number): number[] => { const t = -len / 2 + (len * c) / n; return [t * ux, -down, t * uz]; };
293
+ for (let c = 0; c < n; c++) {
294
+ const d0 = c === 0 ? 0.1 : h * (0.35 + (jitter(seed, 400 + c) + 1) * 0.32), d1 = c === n - 1 ? 0.1 : h * (0.35 + (jitter(seed, 401 + c) + 1) * 0.32);
295
+ const a = at(c, 0), b = at(c + 1, 0), e = at(c, d0), f = at(c + 1, d1), tip = at(c + 0.5, Math.max(d0, d1) * (1.05 + (jitter(seed, 450 + c) + 1) * 0.2));
296
+ for (const tri of [[a, b, e], [b, f, e], [e, f, tip]]) { for (const q of tri) out.push(...q); for (const q of [...tri].reverse()) out.push(...q); }
297
+ }
298
+ const geometry = new BufferGeometry().setAttribute('position', new Float32BufferAttribute(out, 3)); geometry.computeVertexNormals();
299
+ const mesh = new Mesh(foliageUv(geometry, 2), foliageMaterial(DRAPE)); mesh.position.set(x, y, z); return mesh;
300
+ }
301
+ /**
302
+ * TEMPLATES-CLEANROOM M2: the yard's walls (layout.YARD), the cleanroom's: low coursed stone runs with fat moss caps, hanging
303
+ * moss under the caps and ivy down both faces; open at the moss gate (west) and toward the arena arch (east). The pond garden's
304
+ * lower walls run west from the yard round brazier B. Axis-aligned runs, cut in pieces of at most 4.2 m, a collider each.
305
+ */
306
+ export function yardWalls(heightAt: (x: number, z: number) => number): { object: Group; colliders: Colliders } {
307
+ const root = new Group(), colliders: Colliders = [], T = 0.75, SINK = 0.25;
308
+ const gx = layout.MOSSGATE, g = GATE_GAP + GATE_PILLAR - 0.05, px = POND.x - POND.hx - 7;
309
+ const runs: [number, number, number, number, number, [number, number][]][] = [
310
+ [YX0, YZ0, YX1, YZ0, 1.45, []], [YX1, YZ0, YX1, YZ1, 1.45, [[layout.ARENA.z - 1.9, layout.ARENA.z + 1.9]]], [YX0, YZ1, YX1, YZ1, 1.2, []],
311
+ [YX0, YZ0, YX0, YZ1, 1.45, [[gx.z - g, gx.z + g]]], [px, -9, YX0 - T / 2, -9, 1.2, []], [px, 9, YX0 - T / 2, 9, 1.2, []], [px, -9, px, 9, 1.2, []],
312
+ ];
313
+ let seed = 0;
314
+ for (const [x0, z0, x1, z1, h, gaps] of runs) {
315
+ const alongX = z0 === z1, lo = alongX ? x0 : z0, hi = alongX ? x1 : z1, cuts = [lo, ...gaps.flat(), hi];
316
+ for (let i = 0; i < cuts.length; i += 2) {
317
+ const a = cuts[i] ?? lo, b = cuts[i + 1] ?? hi, n = Math.ceil((b - a) / 4.2), L = (b - a) / n;
318
+ for (let k = 0; k < n; k++, seed++) {
319
+ const m = a + (k + 0.5) * L, x = alongX ? m : x0, z = alongX ? z0 : m, yaw = alongX ? 0 : Math.PI / 2;
320
+ const ends = [-0.5, 0, 0.5].map((t) => heightAt(alongX ? m + t * L : x, alongX ? z : m + t * L)), y = Math.min(...ends) - SINK, top = Math.max(...ends) + h;
321
+ const wall = alongX ? block(L + 0.02, top - y, T, 1, x, (y + top) / 2, z, 0, 0, STONE) : block(T, top - y, L + 0.02, 1, x, (y + top) / 2, z, 0, 0, STONE);
322
+ const cap = alongX ? block(L + 0.14, 0.3, T + 0.24, 2, x, top + 0.1, z) : block(T + 0.24, 0.3, L + 0.14, 2, x, top + 0.1, z);
323
+ root.add(wall, cap);
324
+ colliders.push(BoxCollider.fromData({ kind: 'box', x, y: (y + top) / 2 + 0.1, z, hx: alongX ? L / 2 : T / 2, hy: (top - y) / 2 + 0.1, hz: alongX ? T / 2 : L / 2, yaw: -0, surface: 'stone' }).toColliderData());
325
+ for (const side of [-1, 1]) {
326
+ const ox = alongX ? 0 : side * (T / 2 + 0.13), oz = alongX ? side * (T / 2 + 0.13) : 0, ux = alongX ? 1 : 0, uz = alongX ? 0 : 1;
327
+ const dl = Math.min(L - 0.4, 0.8 + (jitter(seed, 512 + side) + 1) * 0.6), d0 = jitter(seed, 510 + side) * (L - dl - 0.2) * 0.5;
328
+ if (dl > 0.3) root.add(drape(x + ox + ux * d0, top - 0.03, z + oz + uz * d0, dl, yaw, 0.3 + (jitter(seed, 514 + side) + 1) * 0.18, seed * 2 + side));
329
+ if (jitter(seed, 516 + side) > -0.2) { const t = jitter(seed, 518 + side) * L * 0.4; root.add(ivy(x + ox * 0.6 + ux * t, top - 0.02, z + oz * 0.6 + uz * t, 0.6 + (jitter(seed, 520 + side) + 1) * (h - 0.4) * 0.5, yaw, 0.3, seed * 3 + side)); }
330
+ }
331
+ }
332
+ }
333
+ }
334
+ return { object: root, colliders };
335
+ }
336
+
213
337
  /** A fern at (x, y, z), `s` its size: seven tent fronds (six triangles each, seen from above and below) fanned up and out. */
214
338
  function fern(x: number, y: number, z: number, s: number, i: number): Group {
215
339
  const root = new Group(), material = foliageMaterial(0x4f7a2a); root.position.set(x, y + 0.02, z);
@@ -286,13 +410,40 @@ function hutFront(root: Group, colliders: Colliders, heightAt: (x: number, z: nu
286
410
  wood(x, z, r, h / 2, r, gy);
287
411
  }
288
412
  }
413
+ /** M2: the room inside the hut (its own frame, door at z = +3, walls 0.3 m thick at ±3), the cleanroom's: a plank floor, a red
414
+ * rug, a table with a bowl and two stools, a shelf of jars on the back wall, stacked crates and a barrel; ivy up the front
415
+ * corners and hanging moss off the eaves. No colliders (the walk in and out stays as it was). */
416
+ function hutInterior(): Group {
417
+ const root = new Group(), JARS = [0x6a8a5a, 0xb08a4a, 0x8a4a3a, 0x5a6a8a, 0xc0a070];
418
+ const at = (mesh: Mesh, x: number, y: number, z: number): Mesh => { mesh.position.set(x, y, z); return mesh; };
419
+ root.add(block(5.66, 0.06, 5.66, 1, 0, 0.04, 0, 0, 0, PLANK), block(1.9, 0.02, 1.25, 1, 0.1, 0.08, 0.7, 0.05, 0, CLOTH));
420
+ root.add(block(1.3, 0.08, 0.75, 1, 0.8, 0.8, -0.5, 0, 0, WOOD));
421
+ for (const [lx, lz] of [[-0.55, -0.3], [0.55, -0.3], [-0.55, 0.3], [0.55, 0.3]] as const) root.add(block(0.08, 0.76, 0.08, 1, 0.8 + lx, 0.4, -0.5 + lz, 0, 0, WOOD_DARK));
422
+ root.add(at(new Mesh(foliageUv(new CylinderGeometry(0.14, 0.09, 0.12, 8), 1), foliageMaterial(0x7a5634)), 0.55, 0.9, -0.45));
423
+ for (const [x, z] of [[-0.35, -0.1], [1.95, -0.3]] as const) root.add(at(new Mesh(foliageUv(new CylinderGeometry(0.2, 0.18, 0.46, 8), 1), foliageMaterial(WOOD)), x, 0.27, z));
424
+ for (const y of [0.95, 1.5]) root.add(block(1.9, 0.06, 0.34, 1, -1.1, y, -2.62, 0, 0, WOOD));
425
+ for (const x of [-2.02, -0.18]) root.add(block(0.06, 1.62, 0.34, 1, x, 0.85, -2.62, 0, 0, WOOD_DARK));
426
+ for (let i = 0; i < 9; i++) {
427
+ const h = 0.16 + (jitter(i, 600) + 1) * 0.06, jar = new Mesh(foliageUv(new CylinderGeometry(0.07, 0.08, h, 8), 1), foliageMaterial(JARS[i % 5] ?? WOOD));
428
+ root.add(at(jar, -1.85 + (i % 5) * 0.36 + jitter(i, 601) * 0.04, (i < 5 ? 0.98 : 1.53) + h / 2, -2.6));
429
+ }
430
+ for (const [x, y, z, s, yaw] of [[-2.35, 0, -1.6, 0.62, 0.2], [-2.38, 0, -0.85, 0.52, -0.25], [-2.3, 0.62, -1.5, 0.42, 0.4]] as const) root.add(block(s, s, s, 1, x, 0.06 + y + s / 2, z, yaw, 0, WOOD));
431
+ root.add(at(new Mesh(foliageUv(new CylinderGeometry(0.33, 0.3, 0.8, 10), 1), foliageMaterial(WOOD)), 2.3, 0.46, -2.2));
432
+ for (const y of [0.22, 0.7]) root.add(at(new Mesh(foliageUv(new CylinderGeometry(0.34, 0.34, 0.06, 10, 1, true), 1), foliageMaterial(IRON)), 2.3, y, -2.2));
433
+ // outside: ivy up the two front corners and the right side, hanging moss off both eaves
434
+ root.add(ivy(-3.12, 3.0, 3.12, 2.7, 0, 0.42, 71), ivy(3.12, 3.0, 3.12, 2.1, 0, 0.36, 72), ivy(3.18, 3.0, 1.4, 2.4, Math.PI / 2, 0.4, 73), ivy(-3.18, 3.0, -1.2, 1.8, Math.PI / 2, 0.36, 74));
435
+ for (const side of [-1, 1]) root.add(drape(0, 3.08, side * 3.72, 6.4, 0, 0.42, 80 + side));
436
+ return root;
437
+ }
289
438
  /**
290
439
  * LF1-7 with LF1-2: the door lamp's glass, one whole shape at the lantern (L0 tile 0/4/3) in the GLB material
291
440
  * `mossgate.lamp`, which `props.materials` binds to an emissive look entry: one draw, no shadow.
292
441
  */
293
442
  export function hutLamp(heightAt: (x: number, z: number) => number): { mesh: Mesh; transform: Matrix4 } {
294
443
  const x = LAMP_POST.x - 1.0, z = LAMP_POST.z, y = heightAt(LAMP_POST.x, LAMP_POST.z) + 2.0;
295
- const geometry = new BoxGeometry(0.36, 0.48, 0.36).toNonIndexed(); geometry.deleteAttribute('uv');
444
+ // M2: and the hut room's hanging lamp over the table, in the same whole (one draw)
445
+ const room = new BoxGeometry(0.3, 0.38, 0.3).translate(layout.HUT.x + 0.8 - x, heightAt(layout.HUT.x, layout.HUT.z) + 2.15 - y, layout.HUT.z - 0.5 - z);
446
+ const geometry = mergeGeometries([new BoxGeometry(0.36, 0.48, 0.36), room]).toNonIndexed(); geometry.deleteAttribute('uv');
296
447
  geometry.setAttribute('color', new Float32BufferAttribute(new Float32Array(geometry.getAttribute('position').count * 3).fill(1), 3));
297
448
  const mesh = new Mesh(geometry, new MeshStandardMaterial({ color: 0xffffff, vertexColors: true })); mesh.castShadow = false;
298
449
  return { mesh, transform: new Matrix4().makeTranslation(x, y, z) };
@@ -303,24 +454,48 @@ export function hutLamp(heightAt: (x: number, z: number) => number): { mesh: Mes
303
454
  * in the bowl, in the GLB material `mossgate.flame` (emissive), with no shadow, so it costs L0 tile 0/3/3 one draw.
304
455
  */
305
456
  export function brazierFlame(heightAt: (x: number, z: number) => number, which = 0): Group {
306
- const [x = 0, z = 0] = layout.BRAZIERS[which] ?? [], y = heightAt(x, z) + 1.5, flame = new Group();
457
+ const flame = new Group(), [x = 0, z = 0] = layout.BRAZIERS[which] ?? [];
458
+ flameCones(flame, x, heightAt(x, z) + 1.5, z);
459
+ // M2: brazier B's field also lights the row's B beacon at the back of the yard
460
+ if (which === 1) { const [bx = 0, bz = 0] = layout.ROW[0] ?? []; flameCones(flame, bx, heightAt(bx, bz) + 1.5, bz); }
461
+ return flame;
462
+ }
463
+ /** Five faceted cones in a bowl whose rim is at y. */
464
+ function flameCones(flame: Group, x: number, y: number, z: number): void {
307
465
  const cones: [number, number, number, number][] = [[0, 0, 0.42, 1.3], [0.24, 0.12, 0.24, 0.8], [-0.22, 0.16, 0.26, 0.9], [0.08, -0.25, 0.22, 0.75], [-0.14, -0.18, 0.2, 0.65]];
308
466
  cones.forEach(([dx, dz, r, h], i) => {
309
- const cone = new Mesh(foliageUv(new CylinderGeometry(0, r, h, 5), 1), foliageMaterial(0xffffff)); cone.position.set(x + dx, y + h / 2, z + dz); cone.rotation.y = jitter(i, 110) * 1.2; flame.add(cone);
467
+ const cone = new Mesh(foliageUv(new CylinderGeometry(0, r, h, 5), 1), foliageMaterial(0xffffff)); cone.position.set(x + dx, y + h / 2 - 0.05, z + dz); cone.rotation.y = jitter(i, 110) * 1.2; flame.add(cone);
310
468
  });
311
- return flame;
312
469
  }
313
470
 
314
- /** Round toy trees in the yard (LF1-5): x, z, size. Off every walk the MH-2, MH-3 and LF1-0 proofs take (see foliage test). */
315
- export const TREES: readonly [number, number, number][] = [[-6.0, -13.5, 1.1], [-9.0, -16.5, 0.95], [5.3, -13.6, 1.1], [9.5, -2.5, 0.9], [15.5, -5.0, 1.0], [2.5, 7.5, 1.0], [12.5, 3.0, 1.05], [-12.5, 3.5, 0.9]];
316
- /** Grass tufts at the wall bases (the hut, the moss gate's wings and pillars, the arena ring) and a few in the open yard. */
471
+ /** Round toy trees (TEMPLATES-CLEANROOM M2, the cleanroom's spots): x, z, size. A few in the yard's corners, the rest round its
472
+ * walls, the pond garden and the arena, framing the goldens' views. Off every walk the proofs take (see foliage test). */
473
+ export const TREES: readonly [number, number, number][] = [
474
+ [-8.2, -16.6, 1.0], [0.8, -21, 1.15], [-12.5, -21, 1.2], [6.5, -20.5, 1.05], [11, -16.4, 0.95], [-13, -12, 1.1], [-7.8, 5.6, 0.9], [9.5, 5.5, 1.0],
475
+ [-13.5, 8, 1.15], [-30, 9, 1.2], [-30, -8, 1.15], [-24.5, -10.5, 1.05], [-14.5, 11.5, 1.0], [16, -9.5, 1.0], [16, 6, 1.1], [36, -12, 1.2],
476
+ [37, 8, 1.15], [24, 10, 1.1], [20, -15, 1.25], [3, 12, 1.2],
477
+ ];
478
+ /** Grass tufts and ferns along the inside foot of the yard walls (clear of the gate and the arch gaps) and round the hut. */
479
+ const WALL_FOOT: readonly [number, number][] = (() => {
480
+ const out: [number, number][] = [];
481
+ for (let z = YZ0 + 0.9, i = 0; z < YZ1 - 0.6; z += 1.6 + (jitter(i, 200) + 1) * 0.6, i++) {
482
+ if (Math.abs(z - layout.MOSSGATE.z) > 3.2) out.push([YX0 + 0.85, z]);
483
+ if (Math.abs(z - layout.ARENA.z) > 2.6) out.push([YX1 - 0.85, z + 0.4]);
484
+ }
485
+ for (let x = YX0 + 0.9, i = 0; x < YX1 - 0.6; x += 1.7 + (jitter(i, 201) + 1) * 0.6, i++) { out.push([x, YZ0 + 0.85]); out.push([x + 0.5, YZ1 - 0.85]); }
486
+ return out;
487
+ })();
488
+ const HUT_FOOT: readonly [number, number][] = [[-3.4, 3.25], [3.4, 3.25], [-3.3, 1.6], [-3.3, -0.6], [-3.3, -2.3], [3.3, 1.4], [3.3, -0.5], [3.3, -2.5], [-1.4, -3.3], [1.3, -3.35]];
317
489
  const TUFTS: readonly [number, number, number][] = [
318
- [-3.6, -8.75, 1], [3.65, -8.7, 0.9], [-3.35, -10.2, 1.1], [-3.35, -12.6, 0.9], [-3.35, -14.3, 1], [3.35, -10.4, 1], [3.35, -12.2, 1.1], [3.35, -14.5, 0.9], [-1.4, -15.35, 1], [1.3, -15.35, 0.9],
319
- [-8.6, -10.4, 1], [-8.6, -8.2, 0.9], [-8.4, -6.65, 1.1], [-8.4, -3.35, 1], [-8.6, -2.2, 0.9], [-8.6, 0.6, 1],
320
- [3.6, -1.6, 0.8], [-2.2, -5.6, 0.8], [5.8, -7.0, 0.9], [-5.6, -11.8, 1], [7.5, -1.2, 0.9], [11.2, -4.6, 0.8], [-0.8, 3.2, 0.8], [4.2, 4.8, 0.9],
490
+ ...WALL_FOOT.filter((_, i) => i % 2 === 0).map(([x, z], i): [number, number, number] => [x, z, 0.9 + (jitter(i, 202) + 1) * 0.1]),
491
+ ...HUT_FOOT.map(([x, z], i): [number, number, number] => [layout.HUT.x + x, layout.HUT.z + z, 0.9 + (jitter(i, 203) + 1) * 0.1]),
492
+ [3.6, -1.6, 0.8], [-2.2, -5.6, 0.8], [5.8, -7.0, 0.9], [7.5, -1.2, 0.9], [-0.8, 3.2, 0.8], [4.2, 4.8, 0.9], [-5.5, 2.8, 0.9],
493
+ ];
494
+ /** Ferns along the wall feet (the other half of `WALL_FOOT`) and at the hut's back corners. */
495
+ const WALL_FERNS: readonly [number, number, number][] = [
496
+ ...WALL_FOOT.filter((_, i) => i % 2 === 1).map(([x, z], i): [number, number, number] => [x, z, 0.9 + (jitter(i, 204) + 1) * 0.12]),
497
+ [layout.HUT.x + 3.5, layout.HUT.z - 2.9, 0.95], [layout.HUT.x - 3.55, layout.HUT.z - 2.8, 0.9],
321
498
  ];
322
- /** New ferns at the wall bases (the dressing's ten stay where they were): the hut's back corners, the gate wings, the arena. */
323
- const WALL_FERNS: readonly [number, number, number][] = [[3.5, -14.9, 0.95], [-3.55, -14.8, 0.9], [-8.5, -9.4, 1], [-8.5, 0.1, 0.9]];
324
499
 
325
500
  /**
326
501
  * LF1-5: the yard's foliage, all in the measure stone's one static draw per tile (the props bake merges a tile's static
@@ -333,14 +508,14 @@ export function mossgateFoliage(heightAt: (x: number, z: number) => number): { o
333
508
  TREES.forEach(([x, z, s], i) => {
334
509
  const y = heightAt(x, z), h = 2.3 * s, r = 1.3 * s;
335
510
  const trunk = new Mesh(foliageUv(new CylinderGeometry(0.17 * s, 0.26 * s, h + 0.3, 6, 1, true), 1), bark); trunk.position.set(x, y + h / 2 - 0.15, z);
336
- const crown = new Mesh(foliageUv(new IcosahedronGeometry(r, 1), 2), leaves); crown.position.set(x, y + h + r * 0.75, z); crown.rotation.set(jitter(i, 100) * 0.4, jitter(i, 101) * 3, 0);
511
+ const crown = new Mesh(lumpyCrown(r * 1.12, i), leaves); crown.position.set(x, y + h + r * 0.8, z); crown.rotation.set(0, jitter(i, 101) * 3, 0);
337
512
  root.add(trunk, crown);
338
513
  colliders.push(BoxCollider.fromData({ kind: 'box', x, y: y + h / 2, z, hx: 0.24 * s, hy: h / 2, hz: 0.24 * s, yaw: -0, surface: 'wood' }).toColliderData());
339
514
  });
340
515
  TUFTS.forEach(([x, z, s], i) => { root.add(tuft(x, heightAt(x, z), z, s, i)); });
341
516
  WALL_FERNS.forEach(([x, z, s], i) => { root.add(fern(x, heightAt(x, z), z, s, 20 + i)); });
342
517
  // the arena ring's outer foot, on the yard's side of it: tufts and two ferns either side of the way in
343
- const { x: cx, z: cz, radius } = layout.ARENA, door = Math.atan2(-cx, -cz);
518
+ const { x: cx, z: cz, radius } = layout.ARENA, door = arenaDoor();
344
519
  [-0.62, -0.44, -0.3, 0.3, 0.46, 0.66, -0.95, 0.98].forEach((da, k) => {
345
520
  const x = cx + (radius + 0.75) * Math.sin(door + da), z = cz + (radius + 0.75) * Math.cos(door + da);
346
521
  root.add(k < 6 ? tuft(x, heightAt(x, z), z, 1, 40 + k) : fern(x, heightAt(x, z), z, 0.95, 30 + k));
@@ -357,14 +532,13 @@ export function mushroomCaps(heightAt: (x: number, z: number) => number): { mesh
357
532
  MUSHROOMS.forEach(([x, z], i) => {
358
533
  for (let k = 0; k < 3; k++) {
359
534
  const mx = x + jitter(i, 20 + k) * 0.28, mz = z + jitter(i, 30 + k) * 0.28, h = 0.16 + (k === 0 ? 0.12 : 0) + jitter(i, 40 + k) * 0.04, y = heightAt(mx, mz);
360
- if (!redCap(mx, mz)) continue;
361
535
  origin ??= new Vector3(mx, y, mz);
362
536
  const cap = mushroomCap(0.12 - k * 0.02, foliageMaterial(0xffffff)); cap.position.set(mx - origin.x, y + h - origin.y, mz - origin.z); cap.updateMatrix();
363
537
  const g = cap.geometry.toNonIndexed().applyMatrix4(cap.matrix), p = g.getAttribute('position'), n = g.getAttribute('normal');
364
538
  for (let v = 0; v < p.count; v++) { out.push(p.getX(v), p.getY(v), p.getZ(v)); normals.push(n.getX(v), n.getY(v), n.getZ(v)); }
365
539
  }
366
540
  });
367
- if (origin === undefined) throw new Error('mushroomCaps: no cap in tile 0/4/3');
541
+ if (origin === undefined) throw new Error('mushroomCaps: no cap');
368
542
  const geometry = new BufferGeometry().setAttribute('position', new Float32BufferAttribute(out, 3)).setAttribute('normal', new Float32BufferAttribute(normals, 3))
369
543
  .setAttribute('color', new Float32BufferAttribute(new Float32Array(out.length).fill(1), 3));
370
544
  const mesh = new Mesh(geometry, new MeshStandardMaterial({ color: 0xffffff, vertexColors: true })); mesh.castShadow = false;
@@ -380,23 +554,20 @@ export function mushroomCaps(heightAt: (x: number, z: number) => number): { mesh
380
554
  export function mossGate(heightAt: (x: number, z: number) => number): { frame: Group; panel: Group; vines: Group; frameColliders: NonNullable<TemplatePart['colliders']>; panelColliders: NonNullable<TemplatePart['colliders']> } {
381
555
  const { x, z } = layout.MOSSGATE, y = heightAt(x, z), frame = new Group(), panel = new Group(), vines = new Group(), frameColliders: NonNullable<TemplatePart['colliders']> = [];
382
556
  const box = (bx: number, by: number, bz: number, hx: number, hy: number, hz: number): NonNullable<TemplatePart['colliders']>[number] => BoxCollider.fromData({ kind: 'box', x: bx, y: by, z: bz, hx, hy, hz, yaw: -0, surface: 'stone' }).toColliderData();
383
- const GAP = 1.3, P = 1.1, H = 3.2;
557
+ const GAP = GATE_GAP, P = GATE_PILLAR, H = 3.6;
384
558
  for (const side of [-1, 1]) {
385
559
  const pz = z + side * (GAP + P / 2);
386
- // LF1-8: a thick moss cushion over each pillar (t1-06), the same box resized, so no bytes added in 0/3/3
387
- frame.add(block(P, H, P, 1, x, y + H / 2, pz), block(P + 0.28, 0.36, P + 0.28, 2, x, y + H + 0.16, pz, jitter(side, 95) * 0.06), block(P + 0.12, 0.3, P + 0.12, 1, x, y + 0.15, pz));
560
+ // M2: two tall stone pillars in four courses (the cleanroom's), a fat moss cushion on each; the yard's west wall meets them
561
+ for (let r = 0; r < 4; r++) frame.add(block(P - r * 0.03, 0.88, P - r * 0.03, 1, x, y + r * 0.9 + 0.45, pz, jitter(r + side * 4, 94) * 0.04, 0, STONE));
562
+ frame.add(block(P + 0.3, 0.5, P + 0.3, 2, x, y + H + 0.1, pz, jitter(side, 95) * 0.06), block(P + 0.12, 0.3, P + 0.12, 1, x, y + 0.15, pz));
388
563
  frameColliders.push(box(x, y + H / 2, pz, P / 2, H / 2, P / 2));
389
- const wz = z + side * 4.1;
390
- frame.add(block(0.6, 1.5, 4.4, 1, x, y + 0.75, wz), block(0.7, 0.1, 4.5, 2, x, y + 1.55, wz));
391
- frameColliders.push(box(x, y + 0.75, wz, 0.3, 0.75, 2.2));
392
- // three vines down the pillar's yard (east) face, each a moss strand with two leaf tufts
393
- for (let k = 0; k < 3; k++) {
394
- const vz = pz + (k - 1) * 0.34 + jitter(k, 90 + side) * 0.06, len = 1.1 + (jitter(k, 92 + side) + 1) * 0.55, vx = x + P / 2 + 0.03;
395
- vines.add(block(0.05, len, 0.09, 2, vx, y + H - len / 2, vz));
396
- for (let t = 0; t < 2; t++) vines.add(block(0.08, 0.16, 0.2, 2, vx + 0.02, y + H - len * (0.35 + t * 0.45), vz + (t === 0 ? 0.07 : -0.07), 0, 0.3));
564
+ // ivy up both faces and hanging moss off the cushion, the gate's own piece so the coarse tiles can skip it
565
+ for (const face of [-1, 1]) {
566
+ for (let k = 0; k < 3; k++) vines.add(ivy(x + face * (P / 2 + 0.03), y + H - 0.05, pz + (k - 1) * 0.42 + jitter(k, 90 + side) * 0.08, 1.3 + (jitter(k, 92 + side * face) + 1) * 0.7, Math.PI / 2, 0.36, k + side * 7 + face * 3));
567
+ vines.add(drape(x + face * (P / 2 + 0.17), y + H - 0.12, pz, P + 0.3, Math.PI / 2, 0.5 + (jitter(side, 93 + face) + 1) * 0.15, side * 5 + face));
397
568
  }
398
569
  }
399
- frame.add(block(0.8, 0.4, GAP * 2, 1, x, y + 2.85, z), block(0.96, 0.16, GAP * 2, 2, x, y + 3.13, z));
570
+ frame.add(block(0.8, 0.4, GAP * 2, 1, x, y + H - 0.55, z), block(0.96, 0.16, GAP * 2, 2, x, y + H - 0.27, z));
400
571
  // LF1-8: four flagstones leading up to the sill from the yard (t1-06): flat quads, two triangles each (0/3/3 is near its bytes)
401
572
  for (let k = 0; k < 4; k++) {
402
573
  const fx = x + 1.25 + k * 1.05, fz = z + jitter(k, 96) * 0.22, w = 0.95 + jitter(k, 97) * 0.12, d = 1.15 + jitter(k, 98) * 0.15, slab = new Mesh(flagstone(w, d), foliageMaterial(STONE));
@@ -405,7 +576,7 @@ export function mossGate(heightAt: (x: number, z: number) => number): { frame: G
405
576
  }
406
577
  // the panel: five thick stone bars on a sill, under the lintel
407
578
  panel.add(block(0.34, 0.2, GAP * 2, 1, x, y + 0.1, z));
408
- for (let k = 0; k < 5; k++) panel.add(block(0.26, 2.45, 0.26, 1, x, y + 0.2 + 2.45 / 2, z - 1.04 + k * 0.52));
579
+ for (let k = 0; k < 6; k++) panel.add(block(0.26, 2.75, 0.26, 1, x, y + 0.2 + 2.75 / 2, z - GAP + 0.25 + k * ((GAP * 2 - 0.5) / 5)));
409
580
  return { frame, panel, vines, frameColliders, panelColliders: [box(x, y + 1.6, z, 0.2, 1.6, GAP)] };
410
581
  }
411
582
 
@@ -416,8 +587,8 @@ export function mossGate(heightAt: (x: number, z: number) => number): { frame: G
416
587
  */
417
588
  export function pondStones(): { raised: Group; sunk: Group; colliders: Colliders } {
418
589
  const { x: cx, z: cz } = layout.POND, raised = new Group(), sunk = new Group(), colliders: Colliders = [], BED = -3, w = 1.75;
419
- for (let i = 0; i < 5; i++) {
420
- const x = cx - 4.1 + i * 2.05, z = cz + jitter(i, 80) * 0.12, yaw = jitter(i, 81) * 0.1;
590
+ for (let i = 0; i < BRIDGE_STONES; i++) {
591
+ const x = cx - BRIDGE_REACH + i * ((BRIDGE_REACH * 2) / (BRIDGE_STONES - 1)), z = cz + jitter(i, 80) * 0.12, yaw = jitter(i, 81) * 0.1;
421
592
  for (const [root, top, s] of [[raised, 0.1, w], [sunk, -1.4, w - 0.2]] as const) {
422
593
  const h = top - BED - 0.1;
423
594
  root.add(block(s, h, s, 1, x, BED + h / 2, z, yaw), block(s + 0.1, 0.1, s + 0.1, 2, x, top - 0.05, z, yaw));
@@ -430,15 +601,16 @@ export function pondStones(): { raised: Group; sunk: Group; colliders: Colliders
430
601
  export const REED = 0x5f8a32, CATTAIL = 0x6b4226, LILY = 0x4c8a3a, LILY_FLOWER = 0xf2a6c2;
431
602
  /** LF1-8: the crossing's line (the MH-3 bridge walk runs along z = POND.z) and the half width kept clear of plants and lip. */
432
603
  export const CROSSING_CLEAR = 1.5;
433
- /** LF1-8: reed clumps round the pond: angle (degrees from +x), radius, size. Off the crossing line and B's pad. */
604
+ /** LF1-8: reed clumps round the pond: angle (degrees from +x), metres past the edge (negative: in the shallows), size. Off
605
+ * the crossing line and B's pad. */
434
606
  export const REEDS: readonly [number, number, number][] = [
435
- [28, 5.3, 1.05], [52, 4.6, 0.9], [74, 5.4, 1.1], [101, 5.25, 0.95], [126, 4.7, 1.0], [152, 5.4, 1.1],
436
- [205, 5.3, 1.0], [228, 4.6, 0.9], [251, 5.45, 1.1], [283, 5.2, 0.95], [306, 4.65, 1.05], [333, 5.35, 0.9],
607
+ [28, 0.3, 1.05], [40, -0.4, 0.95], [52, -0.4, 0.9], [74, 0.4, 1.1], [101, 0.25, 0.95], [126, -0.3, 1.0], [140, 0.35, 1.05], [152, 0.4, 1.1],
608
+ [205, 0.3, 1.0], [220, -0.35, 0.95], [228, -0.4, 0.9], [251, 0.45, 1.1], [283, 0.2, 0.95], [306, -0.35, 1.05], [320, 0.3, 1.0], [333, 0.35, 0.9],
437
609
  ];
438
- /** LF1-8: lily pads on the water: x and z off the pond's centre, radius; `flower` marks the three in bloom. */
610
+ /** LF1-8: lily pads on the water: x and z off the pond's centre, radius; `flower` marks the ones in bloom. */
439
611
  export const LILIES: readonly [number, number, number, boolean][] = [
440
- [-2.6, 2.4, 0.42, true], [-1.2, 3.3, 0.34, false], [1.4, 2.6, 0.4, false], [2.9, 1.9, 0.3, true], [0.2, 3.9, 0.28, false],
441
- [-2.9, -2.1, 0.38, false], [-0.8, -3.2, 0.44, true], [1.8, -2.7, 0.32, false], [3.1, -1.8, 0.36, false], [-1.9, -3.6, 0.26, false],
612
+ [-3.4, 2.6, 0.42, true], [-1.6, 3.6, 0.34, false], [1.8, 2.9, 0.4, false], [3.8, 2.1, 0.3, true], [0.3, 4.2, 0.28, false], [-4.6, 3.6, 0.3, false],
613
+ [-3.8, -2.3, 0.38, false], [-1.0, -3.5, 0.44, true], [2.3, -3.0, 0.32, false], [4.0, -2.0, 0.36, false], [-2.5, -4.0, 0.26, false], [4.7, -3.6, 0.3, true],
442
614
  ];
443
615
  /** LF1-8: a flat, upward-facing w × d quad (a flagstone): two triangles, no grid. */
444
616
  function flagstone(w: number, d: number): BufferGeometry {
@@ -482,11 +654,11 @@ function reedClump(x: number, y: number, z: number, s: number, i: number): Group
482
654
  * colliders: the bridge walk and the swim are unchanged.
483
655
  */
484
656
  export function pondPlanting(heightAt: (x: number, z: number) => number): Group {
485
- const { x: cx, z: cz } = layout.POND, root = new Group(), WATER = 0, R = 5;
486
- REEDS.forEach(([deg, r, s], i) => {
487
- const a = (deg * Math.PI) / 180, x = cx + Math.cos(a) * r, z = cz + Math.sin(a) * r;
488
- // a clump in the shallows (inside the rim) stands up from just under the surface; one on the bank from the ground
489
- root.add(reedClump(x, r < R ? WATER - 0.35 : heightAt(x, z), z, s, i));
657
+ const { x: cx, z: cz } = layout.POND, root = new Group(), WATER = 0;
658
+ REEDS.forEach(([deg, out, s], i) => {
659
+ const [x, z] = pondEdge((deg * Math.PI) / 180, out);
660
+ // a clump in the shallows (inside the edge) stands up from just under the surface; one on the bank from the ground
661
+ root.add(reedClump(x, out < 0 ? WATER - 0.35 : heightAt(x, z), z, s, i));
490
662
  });
491
663
  const flowers = foliageMaterial(LILY_FLOWER), pads = foliageMaterial(LILY);
492
664
  LILIES.forEach(([dx, dz, r, flower], i) => {
@@ -496,63 +668,65 @@ export function pondPlanting(heightAt: (x: number, z: number) => number): Group
496
668
  const bloom = new Mesh(tent([...points, new Vector3(0, 0.14, 0)], [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 0, 5]], new Vector3(0, 0.03, 0), 1), flowers);
497
669
  bloom.position.set(cx + dx + 0.08, WATER + 0.05, cz + dz - 0.05); root.add(bloom);
498
670
  });
499
- // the lip: 20 segments of a moss-topped stone kerb over the rim (a top, an inner face down to the water and a short outer
500
- // face, six triangles a segment), the ones the crossing passes through left out
501
- const N = 20, RIN = R - 0.3, ROUT = R + 0.45, moss = foliageMaterial(MOSS), stone = foliageMaterial(STONE);
502
- for (let k = 0; k < N; k++) {
503
- const a0 = (k / N) * Math.PI * 2, a1 = ((k + 1) / N) * Math.PI * 2, am = (a0 + a1) / 2;
504
- if (Math.abs(Math.sin(am) * R) < CROSSING_CLEAR) continue;
505
- const at = (r: number, a: number, y: number): Vector3 => new Vector3(cx + Math.cos(a) * r, y, cz + Math.sin(a) * r);
506
- const ground = heightAt(cx + Math.cos(am) * ROUT, cz + Math.sin(am) * ROUT) - 0.05, top = Math.max(ground + 0.17, WATER + 0.12); // the kerb stands proud of the water
507
- const lid = [at(RIN, a0, top), at(ROUT, a0, top), at(ROUT, a1, top), at(RIN, a1, top)];
508
- root.add(new Mesh(tent(lid, [[0, 1, 2], [0, 2, 3]], at((RIN + ROUT) / 2, am, top - 1), 2), moss));
509
- const sides = [at(RIN, a0, top), at(RIN, a1, top), at(RIN, a1, WATER - 0.4), at(RIN, a0, WATER - 0.4), at(ROUT, a0, top), at(ROUT, a1, top), at(ROUT, a1, ground), at(ROUT, a0, ground)];
510
- root.add(new Mesh(tent(sides, [[0, 1, 2], [0, 2, 3], [4, 5, 6], [4, 6, 7]], at((RIN + ROUT) / 2, am, (top + ground) / 2), 1), stone));
671
+ // M2: the kerb, the cleanroom's: a ring of low tumbled stone blocks along the water's edge, every fourth with a moss cap,
672
+ // open where the crossing lands on each bank. No collider: the swim and the bridge walk are unchanged.
673
+ for (let k = 0, at = 0; k < 140; k++) {
674
+ const [ax, az] = pondEdge((k / 140) * Math.PI * 2, 0.05), [bx, bz] = pondEdge(((k + 1) / 140) * Math.PI * 2, 0.05);
675
+ at += Math.hypot(bx - ax, bz - az);
676
+ if (at < 0.85) continue;
677
+ at = 0;
678
+ if (Math.abs(az - cz) < CROSSING_CLEAR + 0.45) continue;
679
+ const yaw = Math.atan2(-(bz - az), bx - ax) + jitter(k, 180) * 0.15, w = 0.82 + jitter(k, 181) * 0.12, d = 0.58 + jitter(k, 182) * 0.07;
680
+ root.add(block(w, 0.36, d, 1, ax, WATER - 0.1 + jitter(k, 183) * 0.03, az, yaw, jitter(k, 184) * 0.05, STONE));
681
+ if (k % 4 === 1) root.add(block(w * 0.7, 0.09, d * 0.75, 2, ax, WATER + 0.11, az, yaw + 0.2));
511
682
  }
512
683
  return root;
513
684
  }
514
685
 
515
686
  /**
516
- * The arena (MH-3): a 3.2 m stone ring at `layout.ARENA` round the boss's floor, twenty segments with the one facing spawn
687
+ * The arena (MH-3): a low stone ring (M2: `ARENA_WALL`) at `layout.ARENA` round the boss's floor, twenty segments with the one facing the yard
517
688
  * left out as the way in. Two posts and a lintel frame it, and `gate` (bars, a panel with its own collider) shuts it
518
689
  * until brazier C's field takes it away. It sits north-west of spawn so the gate's panel lands in L0 tile 0/3/4, the
519
690
  * one tile there with two draws to spare.
520
691
  */
521
692
  export function arenaRing(heightAt: (x: number, z: number) => number): { wall: Group; gate: Group; wallColliders: Colliders; gateColliders: Colliders } {
522
- const { x: cx, z: cz, radius: r } = layout.ARENA, wall = new Group(), gate = new Group(), wallColliders: Colliders = [], N = 20, H = 3.2;
523
- const door = Math.atan2(-cx, -cz), len = 2 * r * Math.sin(Math.PI / N) + 0.2;
693
+ const { x: cx, z: cz, radius: r } = layout.ARENA, wall = new Group(), gate = new Group(), wallColliders: Colliders = [], N = 20, H = ARENA_WALL;
694
+ const door = arenaDoor(), len = 2 * r * Math.sin(Math.PI / N) + 0.2;
524
695
  for (let k = 1; k < N; k++) {
525
696
  const a = door + (k / N) * Math.PI * 2, x = cx + r * Math.sin(a), z = cz + r * Math.cos(a), y = heightAt(x, z) - 0.2;
526
- wall.add(block(len, H, 0.7, 1, x, y + H / 2, z, a), block(len + 0.05, 0.14, 0.86, 2, x, y + H + 0.07, z, a));
697
+ wall.add(block(len, H, 0.8, 1, x, y + H / 2, z, a), block(len + 0.12, 0.3, 1.0, 2, x, y + H + 0.12, z, a));
527
698
  wallColliders.push(stoneBox(x, y + H / 2, z, len / 2, H / 2, 0.35, a));
528
699
  }
529
700
  // the way in: posts at the gap's two ends, a lintel over it, and the bars between, all in the gap's own frame
530
701
  const half = r * Math.sin(Math.PI / N), inner = r * Math.cos(Math.PI / N), at = (along: number): [number, number] =>
531
702
  [cx + inner * Math.sin(door) + along * Math.cos(door), cz + inner * Math.cos(door) - along * Math.sin(door)];
532
703
  const [gx, gz] = at(0), gy = heightAt(gx, gz) - 0.2;
704
+ // M2: the arch is taller than the low ring (the cleanroom's): four-course posts, a lintel with a moss cushion
705
+ const GH = ARENA_GATE;
533
706
  for (const side of [-1, 1]) {
534
707
  const [px, pz] = at(side * half);
535
- wall.add(block(0.9, H + 0.8, 0.9, 1, px, gy + (H + 0.8) / 2, pz, door), block(1.0, 0.14, 1.0, 2, px, gy + H + 0.87, pz, door));
536
- wallColliders.push(stoneBox(px, gy + (H + 0.8) / 2, pz, 0.45, (H + 0.8) / 2, 0.45, door));
708
+ for (let c = 0; c < 4; c++) wall.add(block(1.05 - c * 0.03, (GH + 0.6) / 4 - 0.02, 1.05 - c * 0.03, 1, px, gy + ((c + 0.5) * (GH + 0.6)) / 4, pz, door + jitter(c + side * 4, 96) * 0.04, 0, STONE));
709
+ wall.add(block(1.15, 0.3, 1.15, 2, px, gy + GH + 0.72, pz, door));
710
+ wallColliders.push(stoneBox(px, gy + (GH + 0.6) / 2, pz, 0.5, (GH + 0.6) / 2, 0.5, door));
537
711
  }
538
- wall.add(block(half * 2 + 0.9, 0.5, 0.8, 1, gx, gy + H + 0.55, gz, door));
539
- for (let k = 0; k < 7; k++) { const [bx, bz] = at(-half + 0.45 + (k + 0.5) * (half * 2 - 0.9) / 7); gate.add(block(0.14, H - 0.1, 0.14, 2, bx, gy + (H - 0.1) / 2, bz, door)); }
540
- for (const y of [0.5, 1.7, 2.8]) gate.add(block(half * 2 - 0.9, 0.12, 0.1, 2, gx, gy + y, gz, door));
541
- return { wall, gate, wallColliders, gateColliders: [stoneBox(gx, gy + H / 2, gz, half - 0.45, H / 2, 0.15, door)] };
712
+ wall.add(block(half * 2 + 1.0, 0.55, 0.9, 1, gx, gy + GH + 0.85, gz, door, 0, STONE), block(half * 2 + 1.2, 0.36, 1.1, 2, gx, gy + GH + 1.25, gz, door));
713
+ for (let k = 0; k < 7; k++) { const [bx, bz] = at(-half + 0.45 + (k + 0.5) * (half * 2 - 0.9) / 7); gate.add(block(0.14, GH - 0.1, 0.14, 2, bx, gy + (GH - 0.1) / 2, bz, door)); }
714
+ for (const y of [0.5, 1.5, GH - 0.4]) gate.add(block(half * 2 - 0.9, 0.12, 0.1, 2, gx, gy + y, gz, door));
715
+ return { wall, gate, wallColliders, gateColliders: [stoneBox(gx, gy + GH / 2, gz, half - 0.45, GH / 2, 0.15, door)] };
542
716
  }
543
717
 
544
718
  /** LF1-9: the arena floor's slate (the checker's dark squares; the light ones are moss) and its cell, in metres. */
545
719
  export const SLATE = 0x4f4d52, FLOOR_MOSS = 0x4e6a2a, ARENA_CELL = 1.5;
546
720
  /** LF1-9: the three braziers on the arena rim, as angles round `layout.ARENA` from the way in (across from it and either side). */
547
721
  export const RIM_BRAZIERS: readonly number[] = [Math.PI - 0.72, Math.PI, Math.PI + 0.72];
722
+ /** M2: the Warden's core gem floats this high over its feet (the Warden is 3 times the blob, was 2.2). */
723
+ export const WARDEN_CORE = 4.6;
548
724
  /** LF1-9: the Warden's slam tell, a ring this far round `layout.BOSS` (MH-4's twelve anchors stood 3.5 m out). */
549
725
  export const TELL_RADIUS = 3.5;
550
- /** The arena's way in, as an angle round `layout.ARENA` (the gap faces spawn). */
551
- const arenaDoor = (): number => Math.atan2(-layout.ARENA.x, -layout.ARENA.z);
552
726
  /** A rim brazier's centre, on the wall cap's top. */
553
727
  function rimBrazier(heightAt: (x: number, z: number) => number, k: number): [number, number, number] {
554
728
  const { x: cx, z: cz, radius: r } = layout.ARENA, a = arenaDoor() + (RIM_BRAZIERS[k] ?? 0), x = cx + r * Math.sin(a), z = cz + r * Math.cos(a);
555
- return [x, heightAt(x, z) - 0.2 + 3.2 + 0.14, z];
729
+ return [x, heightAt(x, z) - 0.2 + ARENA_WALL + 0.27, z];
556
730
  }
557
731
  /**
558
732
  * LF1-9 (t1-12 to t1-15): the arena's floor and rim, in its tile's (0/3/4) one static draw. A checker of flat 1.5 m squares,
@@ -561,7 +735,7 @@ function rimBrazier(heightAt: (x: number, z: number) => number, k: number): [num
561
735
  * from the way in, their flames a panel brazier C's field shows (`rimFlames`).
562
736
  */
563
737
  function arenaDressing(root: Group, heightAt: (x: number, z: number) => number): void {
564
- const { x: cx, z: cz, radius: r } = layout.ARENA, door = arenaDoor(), N = 20, H = 3.2, slate = foliageMaterial(SLATE), moss = foliageMaterial(MOSS), floorMoss = foliageMaterial(FLOOR_MOSS);
738
+ const { x: cx, z: cz, radius: r } = layout.ARENA, door = arenaDoor(), N = 20, H = ARENA_WALL, slate = foliageMaterial(SLATE), moss = foliageMaterial(MOSS), floorMoss = foliageMaterial(FLOOR_MOSS);
565
739
  const reach = r - 1.0, n = Math.ceil(reach / ARENA_CELL), s = ARENA_CELL / 2 - 0.04;
566
740
  for (let i = -n; i <= n; i++) for (let j = -n; j <= n; j++) {
567
741
  const x = cx + i * ARENA_CELL, z = cz + j * ARENA_CELL;
@@ -572,7 +746,7 @@ function arenaDressing(root: Group, heightAt: (x: number, z: number) => number):
572
746
  // the moss drip: under each segment's cap on the inner face, a strip whose lower edge hangs 0.2 to 0.9 m down
573
747
  for (let k = 1; k < N; k++) {
574
748
  // on the segment box's inner face (a chord `half` long each way, 0.35 m in from the ring), 2 cm proud of it
575
- const am = door + (k / N) * Math.PI * 2, ri = r - 0.37, half = r * Math.sin(Math.PI / N) + 0.05;
749
+ const am = door + (k / N) * Math.PI * 2, ri = r - 0.52, half = r * Math.sin(Math.PI / N) + 0.05;
576
750
  const top = heightAt(cx + r * Math.sin(am), cz + r * Math.cos(am)) - 0.2 + H, at = (t: number, y: number): Vector3 => new Vector3(cx + ri * Math.sin(am) + t * Math.cos(am), y, cz + ri * Math.cos(am) - t * Math.sin(am));
577
751
  const points: Vector3[] = [], tris: [number, number, number][] = [];
578
752
  for (let c = 0; c <= 4; c++) { const t = -half + (half * 2 * c) / 4; points.push(at(t, top), at(t, top - 0.2 - (jitter(k, 160 + c) + 1) * 0.35)); }
@@ -594,6 +768,8 @@ export function rimFlames(heightAt: (x: number, z: number) => number): Group {
594
768
  const cone = new Mesh(foliageUv(new CylinderGeometry(0, rr, h, 5), 1), foliageMaterial(0xffffff)); cone.position.set(x + dx, y + 0.94 + h / 2, z + dz); cone.rotation.y = jitter(k * 3 + i, 170) * 1.2; flames.add(cone);
595
769
  }
596
770
  });
771
+ // M2: brazier C's field also lights the row's C beacon at the back of the yard
772
+ const [bx = 0, bz = 0] = layout.ROW[1] ?? []; flameCones(flames, bx, heightAt(bx, bz) + 1.5, bz);
597
773
  return flames;
598
774
  }
599
775
  /**
@@ -611,7 +787,7 @@ export function wardenTell(heightAt: (x: number, z: number) => number): { ring:
611
787
  }
612
788
  // `tent` winds each face away from a point under the ring, so every triangle faces up
613
789
  ring.add(new Mesh(tent(points, tris, new Vector3(bx, heightAt(bx, bz) - 5, bz), 1), foliageMaterial(0xffffff)));
614
- const gem = new Mesh(foliageUv(new IcosahedronGeometry(0.42, 0), 1), foliageMaterial(0xffffff)); gem.position.set(bx, heightAt(bx, bz) + 3.5, bz); gem.scale.set(1.2, 1.8, 1.2); core.add(gem);
790
+ const gem = new Mesh(foliageUv(new IcosahedronGeometry(0.42, 0), 1), foliageMaterial(0xffffff)); gem.position.set(bx, heightAt(bx, bz) + WARDEN_CORE, bz); gem.scale.set(1.2, 1.8, 1.2); core.add(gem);
615
791
  return { ring, core };
616
792
  }
617
793