@adatechnology/game-floorplan-three 0.10.0 → 0.10.2
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.
- package/dist/{chunk-7XVCZF6H.js → chunk-Y3Y7NYOL.js} +422 -272
- package/dist/chunk-Y3Y7NYOL.js.map +1 -0
- package/dist/index.d.ts +92 -34
- package/dist/index.global.js +447 -292
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/testing-BK7QmoUq.d.ts +1611 -0
- package/dist/testing.d.ts +12 -1
- package/dist/testing.js +1 -1
- package/package.json +24 -10
- package/dist/chunk-7XVCZF6H.js.map +0 -1
- package/dist/testing-CcAh3Eg1.d.ts +0 -386
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
ptBR,
|
|
17
17
|
rectsOf,
|
|
18
18
|
specimenSpec
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-Y3Y7NYOL.js";
|
|
20
20
|
|
|
21
21
|
// src/navigation/floor-navigator.ts
|
|
22
22
|
var CELL = 0.1;
|
|
@@ -689,9 +689,9 @@ function wallPlan(options) {
|
|
|
689
689
|
waterTank: null,
|
|
690
690
|
outbuildings: []
|
|
691
691
|
};
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
return plan;
|
|
692
|
+
const construction = masonryConstruction({ ...plan, facade: { ...facade, roof: "colonial" } });
|
|
693
|
+
const structure = buildStructure({ ...plan, construction }, { wallDetail: "coarse", construction, roof: false });
|
|
694
|
+
return Object.assign(plan, { construction, structure });
|
|
695
695
|
}
|
|
696
696
|
function draw(THREE, plan, options) {
|
|
697
697
|
return create(THREE, { ...options, fleet: null }).build(plan, { quality: "game", terrain: false, noPerimeter: true, pieces: "meshes" });
|
|
@@ -701,7 +701,7 @@ function label(house) {
|
|
|
701
701
|
houses.set(house.group, house);
|
|
702
702
|
for (const [id, items] of Object.entries(house.destruction.ranges())) {
|
|
703
703
|
for (const item of items) {
|
|
704
|
-
const object =
|
|
704
|
+
const object = "isObject3D" in item ? item : item.mesh;
|
|
705
705
|
object.userData.destructionPart = id;
|
|
706
706
|
}
|
|
707
707
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/navigation/floor-navigator.ts","../src/navigation/from-house.ts","../src/navigation/bind.ts","../src/furniture/spec.ts","../src/wall.ts"],"sourcesContent":["/*\n * Floor navigator: walking on several floors of a house (stairs, banisters, path field, occlusion). Literal port of the team's AndaresSDK\n * (sdk/andares), with English names. Coordinates are the house's. The ground floor can keep using the game's own grid: `blocked` answers -1\n * (\"use the ground grid\") unless the house is registered with `own: true`.\n *\n * House: { id, floors: [{ y, h, solids: [[x0, z0, x1, z1], ...] }], stairs: [[x0, z0, x1, z1, from, to, axis], ...], groups: [obj | [obj] ...], roof }\n * - a stair climbs from x0/z0 to x1/z1 (x0 > x1 reverses); stairs with the same footprint become a U-turn (one lane for each flight).\n * - groups[f] = what is drawn of floor f (an Object3D with .visible, or a function show(bool)); roof the same.\n *\n * Additions over the team's code (spec 001, T2.4d): `openCells` and `closeCells` change the fine grid at run time, so a breach (stage 2) opens the\n * cells of a wall and a slab that collapses or fractures removes the cells of its floor (`bindNavigator`, ./bind.ts).\n */\n\n/** A rectangle `[x0, z0, x1, z1]` in the house's coordinates. */\nexport type NavRect = [number, number, number, number]\n/** `[x0, z0, x1, z1, from, to, axis]`: a flight from floor `from` to floor `to` along `axis`. */\nexport type NavStair = [number, number, number, number, number, number, 'x' | 'z']\n\nexport interface NavFloor {\n /** Absolute height of the floor level. */\n y: number\n /** Height of the storey. */\n h: number\n solids?: NavRect[]\n}\n\nexport interface NavHouseDef {\n id: string\n floors: NavFloor[]\n stairs?: NavStair[]\n groups?: unknown[]\n roof?: unknown\n /** The fine grid also rules the ground floor inside the house (default: the ground floor uses the game's grid, except stairs and banisters). */\n own?: boolean\n /** The house's rectangle (default: the union of its solids and stairs). */\n rect?: NavRect\n}\n\n/** A shape on the plan: a rectangle `[x0, z0, x1, z1]` or a circle `[cx, cz, radius]`. */\nexport type NavShape = { rect: NavRect } | { circle: [number, number, number] }\n\nexport interface NavResult {\n y: number\n floor: number\n dx: number\n dz: number\n t: number\n stair: NavFlight | null\n}\n\nexport interface NavFlight {\n x0: number; z0: number; x1: number; z1: number\n axis: 0 | 1\n from: number\n to: number\n group: any\n yFrom: number\n yTo: number\n dir: number\n lo: number\n len: number\n e: number\n}\n\nexport interface NavHouse {\n id: string\n own: boolean\n floors: NavFloor[]\n groups: unknown[]\n roof: unknown\n flights: NavFlight[]\n grids: Uint8Array[]\n fields: any[]\n /** Triples (floor, cell, previous value) of the run-time changes of the grid. */\n journal: number[]\n shown: number\n x0: number; z0: number; x1: number; z1: number\n ox: number; oz: number; nx: number; nz: number\n n: number\n}\n\nconst CELL = 0.1 // fine cell, 10 cm\nconst COARSE = 2 // coarse cell of the path field = 2 x 2 fine ones\nconst OPEN_END = 0.7 // at the ends, the side stays open for 0.7 m (entry/exit by the side)\nconst SLACK = 0.45 // flat stretch at the ends of a stair (m): there one can enter and leave by the sides\nconst SOLID = 1\nconst FREE = 2 // forced free (inside the stair)\nconst VOID = 4 // no floor (a collapsed slab)\nconst clamp = (v: number, a: number, b: number) => (v < a ? a : v > b ? b : v)\n\nexport function createFloorNavigator() {\n const N: any = { houses: [] as NavHouse[], x0: 1e9, z0: 1e9, x1: -1e9, z1: -1e9, currentHouse: null as NavHouse | null, currentFloor: 0, time: 0, result: { y: 0, floor: 0, dx: 0, dz: 0, t: 0, stair: null } as NavResult }\n\n // ----- fine grid of a floor: bit 1 solid, bit 2 forced free (inside the stair), bit 4 no floor -----\n function paint(c: NavHouse, g: Uint8Array, x0: number, z0: number, x1: number, z1: number, v: number) {\n const i0 = Math.max(0, Math.ceil((x0 - c.ox) / CELL - 0.5)), i1 = Math.min(c.nx - 1, Math.floor((x1 - c.ox) / CELL - 0.5))\n const j0 = Math.max(0, Math.ceil((z0 - c.oz) / CELL - 0.5)), j1 = Math.min(c.nz - 1, Math.floor((z1 - c.oz) / CELL - 0.5))\n for (let j = j0; j <= j1; j++) for (let i = i0; i <= i1; i++) { if (v === FREE) g[j * c.nx + i] = FREE; else g[j * c.nx + i] |= v }\n }\n\n function register(def: NavHouseDef): NavHouse {\n const c: NavHouse = { id: def.id, own: !!def.own, floors: def.floors, groups: def.groups || [], roof: def.roof || null, flights: [], grids: [], fields: [], journal: [], shown: -2, x0: 0, z0: 0, x1: 0, z1: 0, ox: 0, oz: 0, nx: 0, nz: 0, n: def.floors.length }\n // the house's rectangle: union of the solids and stairs of all floors (or the given one)\n let x0 = 1e9, z0 = 1e9, x1 = -1e9, z1 = -1e9\n const env = (r: any) => { x0 = Math.min(x0, r[0], r[2]); z0 = Math.min(z0, r[1], r[3]); x1 = Math.max(x1, r[0], r[2]); z1 = Math.max(z1, r[1], r[3]) }\n if (def.rect) env(def.rect); else { for (const a of def.floors) for (const s of a.solids || []) env(s); for (const e of def.stairs || []) env(e) }\n c.x0 = x0; c.z0 = z0; c.x1 = x1; c.z1 = z1\n c.ox = x0 - 0.5; c.oz = z0 - 0.5; c.nx = Math.ceil((x1 - x0 + 1) / CELL); c.nz = Math.ceil((z1 - z0 + 1) / CELL)\n // stairs: groups the ones with the same footprint; each flight takes a lane and the odd ones climb backwards (U-turn)\n const groups: any[] = []\n for (const e of def.stairs || []) {\n const r = [Math.min(e[0], e[2]), Math.min(e[1], e[3]), Math.max(e[0], e[2]), Math.max(e[1], e[3])], ax = e[6] === 'z' ? 1 : 0, inv = ax ? e[3] < e[1] : e[2] < e[0]\n let g = groups.find((q) => q.ax === ax && Math.abs(q.r[0] - r[0]) < 0.08 && Math.abs(q.r[1] - r[1]) < 0.08 && Math.abs(q.r[2] - r[2]) < 0.08 && Math.abs(q.r[3] - r[3]) < 0.08)\n if (!g) groups.push((g = { ax, r, m: [] }))\n g.m.push({ from: e[4], to: e[5], inv })\n }\n for (const g of groups) {\n g.m.sort((a: any, b: any) => a.from - b.from)\n const k = g.m.length, lat = g.ax ? 0 : 1 // lateral axis\n g.m.forEach((m: any, q: number) => {\n const r = g.r.slice(), l0 = g.r[lat], w = (g.r[lat + 2] - l0) / k\n r[lat] = l0 + w * q; r[lat + 2] = l0 + w * (q + 1)\n const s: NavFlight = { x0: r[0], z0: r[1], x1: r[2], z1: r[3], axis: g.ax, from: m.from, to: m.to, group: g, yFrom: def.floors[m.from].y, yTo: def.floors[m.to].y, dir: 0, lo: 0, len: 0, e: 0 }\n s.dir = q & 1 ? (m.inv ? 1 : -1) : m.inv ? -1 : 1 // direction of the axis when climbing\n s.lo = g.ax ? r[1] : r[0]; s.len = (g.ax ? r[3] : r[2]) - s.lo; s.e = Math.min(0.3, SLACK / s.len)\n c.flights.push(s)\n })\n }\n // fine grid per floor\n for (let a = 0; a < c.n; a++) {\n const g = new Uint8Array(c.nx * c.nz); c.grids.push(g)\n for (const s of def.floors[a].solids || []) paint(c, g, Math.min(s[0], s[2]), Math.min(s[1], s[3]), Math.max(s[0], s[2]), Math.max(s[1], s[3]), SOLID)\n }\n // banister: sides and caps closed, except at the open ends of that floor; inside of the stair free\n const T = 0.22\n for (const g of groups) {\n const [rx0, rz0, rx1, rz1] = g.r, ax = g.ax, lo = ax ? rz0 : rx0, hi = ax ? rz1 : rx1, len = hi - lo, f = Math.min(OPEN_END, len * 0.3)\n const pe = (a0: number, b0: number, a1: number, b1: number, grd: Uint8Array, v = SOLID) => (ax ? paint(c, grd, b0, a0, b1, a1, v) : paint(c, grd, a0, b0, a1, b1, v)) // (axis, lateral)\n const l0 = ax ? rx0 : rz0, l1 = ax ? rx1 : rz1\n const floors = new Set<number>(); for (const m of g.m) { floors.add(m.from); floors.add(m.to) }\n for (const a of floors) pe(lo, l0, hi, l1, c.grids[a], FREE) // inside of the stair free\n for (const a of floors) {\n const grd = c.grids[a]\n // open end on the axis: base (lowest coordinate) or top; depends on the direction of each flight\n let openLo = false, openHi = false\n for (const s of c.flights) if (s.group === g) {\n const baseLo = s.dir > 0 // the base is at the lowest coordinate\n if (s.from === a) { if (baseLo) openLo = true; else openHi = true }\n if (s.to === a) { if (baseLo) openHi = true; else openLo = true }\n }\n // outer sides and dividers between lanes, outside the open-end zones\n const ini = openLo ? lo + f : lo - T, fim = openHi ? hi - f : hi + T\n pe(ini, l0 - T, fim, l0, grd); pe(ini, l1, fim, l1 + T, grd)\n const k = g.m.length; for (let q = 1; q < k; q++) { const lm = l0 + ((l1 - l0) * q) / k; pe(lo + f, lm - 0.05, hi - f, lm + 0.05, grd) }\n if (!openLo) pe(lo - T, l0, lo, l1, grd)\n if (!openHi) pe(hi, l0, hi + T, l1, grd)\n }\n }\n N.houses.push(c); N.x0 = Math.min(N.x0, x0); N.z0 = Math.min(N.z0, z0); N.x1 = Math.max(N.x1, x1); N.z1 = Math.max(N.z1, z1)\n return c\n }\n\n const houseAt = (x: number, z: number): NavHouse | null => {\n if (x < N.x0 || x > N.x1 || z < N.z0 || z > N.z1) return null\n for (let k = 0; k < N.houses.length; k++) { const c = N.houses[k]; if (x >= c.x0 && x <= c.x1 && z >= c.z0 && z <= c.z1) return c }\n return null\n }\n // cell of the fine grid (value 0..7) or -1 outside the house\n const cell = (c: NavHouse, a: number, x: number, z: number): number => {\n const i = Math.floor((x - c.ox) / CELL), j = Math.floor((z - c.oz) / CELL)\n return i < 0 || j < 0 || i >= c.nx || j >= c.nz ? -1 : c.grids[a][j * c.nx + i]\n }\n // block per floor: 1 blocked, 0 free, -1 \"use the ground grid\" (floor 0 with nothing special there)\n function blocked(x: number, z: number, floor: number): number {\n const c = houseAt(x, z)\n if (!c) return floor > 0 ? 1 : -1\n if (floor >= c.n) return 1\n const v = cell(c, floor, x, z)\n if (v === FREE) return 0\n if (v >= 0 && v & VOID) return 1\n if (floor > 0 || c.own) return v < 0 || v & SOLID ? 1 : 0 // own: the fine grid of the house also rules the ground floor\n return v > 0 ? 1 : -1\n }\n // level: y and floor of the point, considering the stair. Returns true when it is on a stair (result in N.result)\n function level(x: number, z: number, floor: number): boolean {\n const r: NavResult = N.result, c = houseAt(x, z); r.stair = null\n if (!c) { r.floor = floor; r.y = 0; return false }\n for (let k = 0; k < c.flights.length; k++) {\n const s = c.flights[k]\n if ((floor !== s.from && floor !== s.to) || x < s.x0 || x > s.x1 || z < s.z0 || z > s.z1) continue\n let t = ((s.axis ? z : x) - s.lo) / s.len; if (s.dir < 0) t = 1 - t\n const u = clamp((t - s.e) / (1 - 2 * s.e), 0, 1)\n r.y = s.yFrom + (s.yTo - s.yFrom) * u; r.t = t; r.floor = t < 0.5 ? s.from : s.to; r.stair = s\n return true\n }\n r.floor = floor; r.y = c.floors[floor] ? c.floors[floor].y : 0\n return false\n }\n // point at an end of the stair, at the centre of the lane; inside > 0 towards the inside of the end, < 0 towards the outside\n function landing(s: NavFlight, top: boolean, inside: number, out: number[]): number[] {\n const lo = top ? s.dir < 0 : s.dir > 0, a = lo ? s.lo + inside : s.lo + s.len - inside, b = s.axis ? (s.x0 + s.x1) / 2 : (s.z0 + s.z1) / 2\n out[0] = s.axis ? b : a; out[1] = s.axis ? a : b\n return out\n }\n // stair that takes floor a to floor b (b > a climbs, b < a descends) in the house; null if there is none\n function stairTo(c: NavHouse, a: number, b: number): NavFlight | null {\n for (const s of c.flights) if (b > a ? s.from === a : s.to === a) return s\n return null\n }\n // ----- path field per floor (BFS on the coarse grid) to a point; recomputed only when the target changes cell -----\n function field(c: NavHouse, a: number) {\n const f = c.fields[a]; if (f) return f\n const gx = Math.ceil(c.nx / COARSE), gz = Math.ceil(c.nz / COARSE), free = new Uint8Array(gx * gz), g = c.grids[a]\n for (let j = 0; j < gz; j++) for (let i = 0; i < gx; i++) {\n let b = 0\n for (let q = 0; q < COARSE && !b; q++) for (let p = 0; p < COARSE; p++) {\n const ii = i * COARSE + p, jj = j * COARSE + q\n if (ii < c.nx && jj < c.nz) { const v = g[jj * c.nx + ii]; if (v === SOLID || v & VOID) { b = 1; break } }\n }\n free[j * gx + i] = b ? 0 : 1\n }\n return (c.fields[a] = { gx, gz, free, d: new Int16Array(gx * gz), q: new Int32Array(gx * gz), target: -1, t: -9 })\n }\n const DX = [1, -1, 0, 0, 1, 1, -1, -1], DZ = [0, 0, 1, -1, 1, -1, 1, -1]\n // direction (in N.result.dx/dz, unit) from (x,z) towards (tx,tz) walking on floor a; false if there is no path (go straight)\n function heading(c: NavHouse, a: number, x: number, z: number, tx: number, tz: number): boolean {\n const f = field(c, a), cs = CELL * COARSE\n const ci = clamp(Math.floor((tx - c.ox) / cs), 0, f.gx - 1), cj = clamp(Math.floor((tz - c.oz) / cs), 0, f.gz - 1), ca = cj * f.gx + ci\n if (ca !== f.target && N.time - f.t > 0.15) { // BFS from the target\n f.target = ca; f.t = N.time; f.d.fill(-1); let h = 0, e = 0; f.q[e++] = ca; f.d[ca] = 0\n while (h < e) {\n const k = f.q[h++], i = k % f.gx, j = (k / f.gx) | 0\n for (let n = 0; n < 8; n++) {\n const ni = i + DX[n], nj = j + DZ[n]; if (ni < 0 || nj < 0 || ni >= f.gx || nj >= f.gz) continue\n const nk = nj * f.gx + ni; if (f.d[nk] >= 0 || !f.free[nk]) continue\n if (n > 3 && (!f.free[j * f.gx + ni] || !f.free[nj * f.gx + i])) continue // a diagonal does not cut a corner\n f.d[nk] = f.d[k] + 1; f.q[e++] = nk\n }\n }\n }\n const i = Math.floor((x - c.ox) / cs), j = Math.floor((z - c.oz) / cs)\n if (i < 0 || j < 0 || i >= f.gx || j >= f.gz) return false\n const k0 = j * f.gx + i, r: NavResult = N.result\n let best = f.d[k0] >= 0 ? f.d[k0] : 1e9, bi = -1 // blocked cell (e.g. inside the stair): leaves by the neighbour closest to the target\n if (f.target < 0) return false\n for (let n = 0; n < 8; n++) {\n const ni = i + DX[n], nj = j + DZ[n]; if (ni < 0 || nj < 0 || ni >= f.gx || nj >= f.gz) continue\n const d = f.d[nj * f.gx + ni]; if (d < 0 || d >= best) continue\n if (n > 3 && (!f.free[j * f.gx + ni] || !f.free[nj * f.gx + i])) continue\n best = d; bi = n\n }\n if (bi < 0) return false\n const px = c.ox + (i + DX[bi] + 0.5) * cs, pz = c.oz + (j + DZ[bi] + 0.5) * cs, dx = px - x, dz = pz - z, l = Math.hypot(dx, dz) || 1\n r.dx = dx / l; r.dz = dz / l\n return true\n }\n // ceiling of a floor: the next floor's level minus the slab; on the last one, the storey height\n const ceilingOf = (c: NavHouse, a: number): number => (a + 1 < c.n ? c.floors[a + 1].y - 0.2 : c.floors[a].y + c.floors[a].h)\n // ray against the grids and the floor's ceiling: distance until it hits or -1\n function ray(c: NavHouse, a: number, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, max: number): number {\n const top = ceilingOf(c, a)\n for (let s = 0.1; s <= max; s += 0.1) {\n const x = ox + dx * s, y = oy + dy * s, z = oz + dz * s\n if (y > top || y < c.floors[a].y) return s\n const v = cell(c, a, x, z); if (v < 0 || v === SOLID) return s\n }\n return -1\n }\n function apply(c: NavHouse, floor: number) {\n if (c.shown === floor) return\n c.shown = floor\n const show = (o: any, v: boolean) => { if (!o) return; if (typeof o === 'function') o(v); else if (Array.isArray(o)) o.forEach((q) => show(q, v)); else o.visible = v }\n for (let a = 0; a < c.groups.length; a++) show(c.groups[a], floor < 0 || a <= floor)\n show(c.roof, floor < 0)\n }\n // occlusion: hides the floors above whoever is inside, and the roof; outside, shows everything\n function occlude(x: number, z: number, floor: number): NavHouse | null {\n const c = houseAt(x, z)\n if (c !== N.currentHouse && N.currentHouse) apply(N.currentHouse, -1)\n N.currentHouse = c; N.currentFloor = floor\n if (c) apply(c, floor)\n return c\n }\n\n // ----- run-time changes of the grid (destruction) -----\n const houseOf = (id: string): NavHouse | null => N.houses.find((h: NavHouse) => h.id === id) || null\n /** Visits the cells of the fine grid inside `shape` on `floor`. Returns how many it visited. */\n function each(c: NavHouse, floor: number, shape: NavShape, fn: (g: Uint8Array, k: number) => void): number {\n const g = c.grids[floor]; if (!g) return 0\n let x0: number, z0: number, x1: number, z1: number\n const circle = 'circle' in shape ? shape.circle : null\n if (circle) { x0 = circle[0] - circle[2]; z0 = circle[1] - circle[2]; x1 = circle[0] + circle[2]; z1 = circle[1] + circle[2] } else [x0, z0, x1, z1] = (shape as { rect: NavRect }).rect\n const i0 = Math.max(0, Math.ceil((Math.min(x0, x1) - c.ox) / CELL - 0.5)), i1 = Math.min(c.nx - 1, Math.floor((Math.max(x0, x1) - c.ox) / CELL - 0.5))\n const j0 = Math.max(0, Math.ceil((Math.min(z0, z1) - c.oz) / CELL - 0.5)), j1 = Math.min(c.nz - 1, Math.floor((Math.max(z0, z1) - c.oz) / CELL - 0.5))\n let n = 0\n for (let j = j0; j <= j1; j++) for (let i = i0; i <= i1; i++) {\n if (circle) { const dx = c.ox + (i + 0.5) * CELL - circle[0], dz = c.oz + (j + 0.5) * CELL - circle[1]; if (dx * dx + dz * dz > circle[2] * circle[2]) continue }\n fn(g, j * c.nx + i); n++\n }\n return n\n }\n /** A wall or a banister opened (breach, fracture): the solid cells inside `shape` on `floor` become free. Returns the cells it visited. */\n function openCells(houseId: string, floor: number, shape: NavShape): number {\n const c = houseOf(houseId); if (!c) return 0\n const n = each(c, floor, shape, (g, k) => { if (g[k] !== FREE && g[k] & SOLID) { c.journal.push(floor, k, g[k]); g[k] &= ~SOLID } })\n c.fields[floor] = null\n return n\n }\n /** A slab collapsed or fractured: the cells inside `shape` on `floor` have no floor any more (blocked, and the path field avoids them). */\n function closeCells(houseId: string, floor: number, shape: NavShape): number {\n const c = houseOf(houseId); if (!c) return 0\n const n = each(c, floor, shape, (g, k) => { if (!(g[k] & VOID)) { c.journal.push(floor, k, g[k]); g[k] = (g[k] === FREE ? 0 : g[k]) | VOID } })\n c.fields[floor] = null\n return n\n }\n /** Puts the grid of the house back to what it was (after a world reset): undoes every `openCells` and `closeCells`. */\n function undoChanges(houseId: string): void {\n const c = houseOf(houseId); if (!c) return\n const j = c.journal\n for (let k = j.length - 3; k >= 0; k -= 3) { c.grids[j[k]][j[k + 1]] = j[k + 2]; c.fields[j[k]] = null }\n j.length = 0\n }\n\n return Object.assign(N, { register, houseAt, blocked, level, landing, stairTo, heading, ray, ceilingOf, occlude, cell, apply, houseOf, openCells, closeCells, undoChanges }) as FloorNavigator\n}\n\nexport interface FloorNavigator {\n houses: NavHouse[]\n /** Frame time in seconds; the path field is recomputed at most every 0.15 s of it. */\n time: number\n currentHouse: NavHouse | null\n currentFloor: number\n /** Result of the last `level` and `heading` call (no allocation per query). */\n result: NavResult\n register(def: NavHouseDef): NavHouse\n houseAt(x: number, z: number): NavHouse | null\n blocked(x: number, z: number, floor: number): number\n level(x: number, z: number, floor: number): boolean\n landing(flight: NavFlight, top: boolean, inside: number, out: number[]): number[]\n stairTo(house: NavHouse, from: number, to: number): NavFlight | null\n heading(house: NavHouse, floor: number, x: number, z: number, tx: number, tz: number): boolean\n ray(house: NavHouse, floor: number, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, max: number): number\n ceilingOf(house: NavHouse, floor: number): number\n occlude(x: number, z: number, floor: number): NavHouse | null\n cell(house: NavHouse, floor: number, x: number, z: number): number\n apply(house: NavHouse, floor: number): void\n houseOf(id: string): NavHouse | null\n openCells(houseId: string, floor: number, shape: NavShape): number\n closeCells(houseId: string, floor: number, shape: NavShape): number\n undoChanges(houseId: string): void\n}\n","import type { NavHouseDef, NavRect, NavStair } from './floor-navigator.js'\n\n/** The parts of a built house (`create(THREE, options).build(...)`) the navigator reads. */\nexport interface NavigableHouse {\n name?: string\n r: { floors: { index: number; y0: number; ceiling: number }[] }\n colliders: { type: string; f: number; x0: number; z0: number; x1: number; z1: number }[]\n stairs: { m: { ry: number }; f: number; to: number; rect: NavRect }[]\n floors: unknown[]\n roof: unknown\n}\n\nexport interface NavigationDefOptions {\n /** Id the house registers with (default: the house's name). */\n id?: string\n /** Collider types that make a cell solid (default: walls and the boards of a barricade; the gaps of the doors stay free). */\n solids?: string[]\n /** The fine grid also rules the ground floor inside the house. */\n own?: boolean\n}\n\n/**\n * The registration of a built house in a floor navigator: heights from the plan's floors, solids from the house's wall colliders, one flight per\n * stair (its footprint, from the floor it leaves to the floor it reaches, along the axis the flight runs on) and the floor groups and roof to hide\n * by occlusion.\n */\nexport function navigationDefOf(house: NavigableHouse, options: NavigationDefOptions = {}): NavHouseDef {\n const types = new Set(options.solids ?? ['wall', 'board'])\n const floors = house.r.floors.map((floor) => ({\n y: floor.y0,\n h: floor.ceiling,\n solids: house.colliders.filter((c) => c.f === floor.index && types.has(c.type)).map((c): NavRect => [c.x0, c.z0, c.x1, c.z1]),\n }))\n // a flight climbs towards the local -z of its item (its bottom is at +z): in the world that is (-sin, -cos) of the rotation\n const stairs = house.stairs.map((stair): NavStair => {\n const c = Math.cos(stair.m.ry), s = Math.sin(stair.m.ry), [x0, z0, x1, z1] = stair.rect\n if (Math.abs(c) >= Math.abs(s)) return -c > 0 ? [x0, z0, x1, z1, stair.f, stair.to, 'z'] : [x0, z1, x1, z0, stair.f, stair.to, 'z']\n return -s > 0 ? [x0, z0, x1, z1, stair.f, stair.to, 'x'] : [x1, z0, x0, z1, stair.f, stair.to, 'x']\n })\n return { id: options.id ?? house.name ?? 'house', floors, stairs, groups: house.floors, roof: house.roof, own: options.own }\n}\n","import type { FloorNavigator, NavRect } from './floor-navigator.js'\n\n/** The parts of a built house the binding reads: its structure (parts by id), its floors and its destruction adapter. */\nexport interface DestructibleHouse {\n r: { floors: { index: number; y0: number }[] }\n structure: { byId: Map<string, { role: string; floor: number; aabb: NavRect; y1: number }> }\n destruction: { onEvent(listener: (event: any) => void): () => void; restore?: () => void }\n}\n\nexport interface NavigatorBinding {\n /** Stops listening. */\n off(): void\n /** Puts the grid back (after a world reset). */\n reset(): void\n}\n\nconst WALL_ROLES = new Set(['wall', 'partition'])\n\n/**\n * Connects a floor navigator to the destruction of a house, so the people walking in it follow what the world did to it:\n * - a wall that reaches stage 2 opens the cells inside its opening (a circle on its floor);\n * - a wall that fractures or collapses opens all the cells of its footprint;\n * - a slab that supports a floor and fractures or collapses removes the cells of that floor under it (they become blocked).\n * The house has to be registered in the navigator under `houseId` (`navigationDefOf`). Events arrive once the house's destruction is active.\n * Returns the binding; `reset()` undoes the changes.\n */\nexport function bindNavigator(navigator: FloorNavigator, houseId: string, house: DestructibleHouse): NavigatorBinding {\n const level = (floor: number) => house.r.floors.find((f) => f.index === floor)?.y0\n const gone = (id: string) => {\n const part = house.structure.byId.get(id)\n if (!part) return\n if (WALL_ROLES.has(part.role)) navigator.openCells(houseId, part.floor, { rect: part.aabb })\n else if (part.role === 'slab') {\n const y = level(part.floor)\n // only the slab a floor stands on: its top is the floor level (a roof slab is not a floor)\n if (y !== undefined && Math.abs(part.y1 - y) < 0.1) navigator.closeCells(houseId, part.floor, { rect: part.aabb })\n }\n }\n const off = house.destruction.onEvent((event) => {\n if (event.type === 'stage' && event.stage === 2 && event.opening) {\n const part = house.structure.byId.get(event.part)\n if (part && WALL_ROLES.has(part.role)) navigator.openCells(houseId, part.floor, { circle: [event.opening.center[0], event.opening.center[2], event.opening.radius] })\n } else if (event.type === 'fracture') gone(event.part)\n else if (event.type === 'collapse') for (const id of event.parts) gone(id)\n })\n return { off, reset: () => navigator.undoChanges(houseId) }\n}\n","import { inferJoints } from '@adatechnology/game-destruction'\nimport { markKitOrigin } from '@adatechnology/game-contracts'\nimport type { DestructibleSpec, JointSpec, PartSpec } from '@adatechnology/game-contracts'\n\nimport { residentialItems } from '@adatechnology/game-floorplan-residential'\n\nimport { create } from '../create.js'\n\n/** What `furnitureSpec` reads of a catalogue entry (the items of `game-floorplan-residential` and the other packs have more). */\nexport interface FurnitureCatalogEntry {\n type: string\n w: number\n d: number\n h: number\n}\n\nexport interface FurnitureSpecOptions {\n /** Size in metres (default: the catalogue entry of the type). */\n w?: number\n d?: number\n h?: number\n /** Seed of the builder's random (the books of a shelf, the crates): same seed, same piece (default 1). */\n seed?: number\n /** Builder-level choices. */\n options?: {\n /** Material of the destruction world per builder material key (`wood`, `metal`, `plain`, `fabric`, `glass`...), overriding the defaults. */\n materials?: Record<string, string>\n /** Keep the chairs a table draws (default true). Chairs are drawn by the builder in a frame of their own, so this drops everything drawn in another frame than the piece's. */\n chairs?: boolean\n /** Colour roles of the builder (`wood`, `fabric_main`, `fabric_accent`, `metal`...) as `0xRRGGBB`. */\n palette?: Record<string, number>\n }\n /** Catalogue the default size is read from (`defaultFurnitureCatalog()` of `game-kit-defaults`, or the game's own). Default `residentialItems`, which is deprecated: pass the catalogue. */\n catalog?: readonly FurnitureCatalogEntry[]\n /** The `document` the house renderer makes its textures with (default the global one). */\n document?: unknown\n}\n\nexport interface FurnitureSpecResult {\n /** One part per box or cylinder the builder drew, origin at the centre of the footprint on the floor. */\n spec: DestructibleSpec\n /** Draws the piece: one mesh per part, named by the part id, coloured as the builder coloured it. */\n build(THREE: any): any\n /** The widest high horizontal part and the height of its upper face (what loose things rest on), or null when the piece has none. */\n /** What loose things rest on. A solid top is boards: `parts` are all of them, `part` the one in the middle. */\n top: { part: string; y: number; parts?: string[] } | null\n /** Size the piece was drawn at. */\n size: { w: number; d: number; h: number }\n /** Where the water leaves the taps the builder drew (a sink, a tub), in the space of the spec; empty for furniture without a tap. */\n spouts: Array<[number, number, number]>\n}\n\ninterface Drawn {\n id: string\n key: string\n shape: PartSpec['shape']\n position: [number, number, number]\n rotation: [number, number, number] | null\n color: number\n min: [number, number, number]\n max: [number, number, number]\n}\n\nconst WOOD_THIN = 0.035\n/** A solid wooden top is boards glued edge to edge: thicker than this it is a block and stays whole; narrower than `BOARD_TOP_WIDTH` it is one board. */\nconst BOARD_TOP_THICK = 0.07\nconst BOARD_TOP_WIDTH = 0.5\nconst BOARD_WIDTH = 0.16\n/** A shelf falls when what holds it leaves it this many times its own length of span (one side gone: twice its length). */\nconst SHELF_SPAN = 1.5\n/** Types that are cases with shelves: their `plain` boxes are books and boxes, and they stand as a carcass. */\nconst SHELVING = /shelf|bookcase|rack/\n\n/**\n * The frame of a case piece (a bookcase, a shelf unit, a rack): the uprights stand on the floor and carry, each shelf rests on them and needs both\n * ends held (`structure.maxSpan`), and the back panel carries nothing. Break a side and the shelves it held fall with what is on them.\n */\nfunction carcass(parts: PartSpec[], drawn: Map<string, Drawn>): void {\n const all = [...drawn.values()]\n const width = Math.max(...all.map((p) => p.max[0])) - Math.min(...all.map((p) => p.min[0]))\n for (const part of parts) {\n if (LOOSE.has(part.material) || part.shape.kind !== 'box' || part.rotation) continue\n const [x, y, z] = part.shape.size\n if (y >= x && y >= z) {\n // upright: a side (thin across the width) carries; a back or front panel (thin in depth, as wide as the piece) does not\n if (z < x && x >= 0.6 * width) continue\n part.structure = { role: 'column' }\n } else if (y <= x && y <= z) part.structure = { role: 'beam', maxSpan: SHELF_SPAN * Math.max(x, z) }\n }\n}\n/** Each solid top of the drawing becomes its boards (`<id>_b<n>`), along its length, so that it breaks board by board where it is hit. Returns the boards of each top. */\nfunction splitTopsIntoBoards(drawn: Drawn[], materialOf: Record<string, string>, carcassed: boolean): Map<string, Drawn[]> {\n const tops = new Map<string, Drawn[]>()\n if (carcassed) return tops\n for (let i = drawn.length - 1; i >= 0; i--) {\n const p = drawn[i]\n if (p.key !== 'wood' || materialOf.wood !== 'wood_hard' || p.shape.kind !== 'box' || p.rotation) continue\n const [sx, sy, sz] = p.shape.size\n const across = sx < sz ? 0 : 2\n const width = Math.min(sx, sz)\n if (sy < WOOD_THIN || sy > BOARD_TOP_THICK || sy >= width || width < BOARD_TOP_WIDTH) continue\n const count = Math.round(width / BOARD_WIDTH)\n const boards: Drawn[] = []\n for (let b = 0; b < count; b++) {\n const size: [number, number, number] = [sx, sy, sz]\n size[across] = width / count\n const position: [number, number, number] = [...p.position]\n position[across] += (b + 0.5) * size[across] - width / 2\n const min: [number, number, number] = [...p.min]\n const max: [number, number, number] = [...p.max]\n min[across] = position[across] - size[across] / 2\n max[across] = position[across] + size[across] / 2\n boards.push({ ...p, id: `${p.id}_b${b}`, shape: { kind: 'box', size }, position, min, max, color: shadeBoard(p.color, b) })\n }\n drawn.splice(i, 1, ...boards)\n tops.set(p.id, boards)\n }\n return tops\n}\n\n/** Boards of one top are not cut from the same tree: each has its own tone. */\nfunction shadeBoard(color: number, board: number): number {\n const k = [1, 0.94, 1.05, 0.97, 1.03][board % 5]\n const channel = (shift: number): number => Math.min(255, Math.round(((color >> shift) & 255) * k)) << shift\n return channel(16) | channel(8) | channel(0)\n}\n\nconst FLOOR_TOUCH = 0.005\nconst LOOSE = new Set(['paper'])\nconst BASE_MATERIAL: Record<string, string> = {\n wood: 'wood_hard',\n metal: 'steel',\n fabric: 'fabric',\n glass: 'glass',\n plain: 'plastic',\n plant: 'foliage',\n picture: 'paper',\n emissive: 'glass',\n}\n\n// one house renderer per three.js namespace: it makes the type table the builders hang from\nconst renderers = new WeakMap<object, any>()\nfunction rendererOf(THREE: any, document: unknown): any {\n let r = renderers.get(THREE)\n if (!r) {\n r = create(THREE, document ? { document: document as never } : {})\n renderers.set(THREE, r)\n }\n return r\n}\n\ninterface RecordOptions {\n /** Destruction material per builder material key, over the defaults. */\n materials: Record<string, string>\n chairs?: boolean\n /** The piece is a case with shelves (`carcass`). */\n carcass?: boolean\n}\n\n/** Runs `run` with a recording stand-in for the drawing api and turns what it drew into a spec, a drawing and the top. `root` is the frame of the piece (the builder's `M`). */\nfunction recordSpec(THREE: any, name: string, root: any, run: (A: any) => void, opts: RecordOptions): { spec: DestructibleSpec; build: (T3: any) => any; top: FurnitureSpecResult['top'] } {\n const o = { chairs: opts.chairs }\n const materialOf = { ...BASE_MATERIAL, ...opts.materials }\n const drawn: Drawn[] = []\n const counters = new Map<string, number>()\n const q = new THREE.Quaternion()\n const eul = new THREE.Euler()\n const xyz = new THREE.Euler()\n const v = new THREE.Vector3()\n\n const loc = (M: any, lx: number, lz: number): [number, number] => {\n const c = Math.cos(M.ry)\n const s = Math.sin(M.ry)\n return [M.x + lx * c + lz * s, M.z - lx * s + lz * c]\n }\n const record = (M: any, key: string, shape: PartSpec['shape'], px: number, py: number, pz: number, rx: number, ry: number, rz: number, color: number): void => {\n if ((o.chairs === false && M !== root) || key === 'water') return // water is not a solid\n q.setFromEuler(eul.set(rx, ry, rz, 'YXZ'))\n const turned = rx !== 0 || ry !== 0 || rz !== 0\n const size: [number, number, number] = shape.kind === 'box' ? shape.size : shape.kind === 'cylinder' ? [shape.radius * 2, shape.height, shape.radius * 2] : [shape.radius * 2, shape.radius * 2, shape.radius * 2]\n const min: [number, number, number] = [Infinity, Infinity, Infinity]\n const max: [number, number, number] = [-Infinity, -Infinity, -Infinity]\n for (const sx of [-0.5, 0.5]) for (const sy of [-0.5, 0.5]) for (const sz of [-0.5, 0.5]) {\n v.set(sx * size[0], sy * size[1], sz * size[2]).applyQuaternion(q)\n const c = [v.x + px - root.x, v.y + py, v.z + pz - root.z]\n for (let k = 0; k < 3; k++) {\n min[k] = Math.min(min[k], c[k])\n max[k] = Math.max(max[k], c[k])\n }\n }\n const n = counters.get(key) ?? 0\n counters.set(key, n + 1)\n let rotation: [number, number, number] | null = null\n if (turned) {\n xyz.setFromQuaternion(q, 'XYZ')\n rotation = [xyz.x, xyz.y, xyz.z]\n }\n drawn.push({ id: `${key}_${n}`, key, shape, position: [px - root.x, py, pz - root.z], rotation, color, min, max })\n }\n\n const A = {\n box(M: any, mat: string, x: number, y: number, z: number, bw: number, bh: number, bd: number, color: number, ry = 0, rx = 0, rz = 0): void {\n const [px, pz] = loc(M, x, z)\n record(M, mat, { kind: 'box', size: [bw, bh, bd] }, px, M.base + y + bh / 2, pz, rx, M.ry + ry, rz, color)\n },\n cylinder(M: any, mat: string, x: number, y: number, z: number, r: number, ch: number, color: number, rx = 0, rz = 0): void {\n const [px, pz] = loc(M, x, z)\n record(M, mat, { kind: 'cylinder', radius: r, height: ch }, px, M.base + y + (rx || rz ? 0 : ch / 2), pz, rx || 0, M.ry, rz || 0, color)\n },\n leaf(): void {},\n plane(): void {},\n light(): void {},\n }\n run(A)\n if (!drawn.length) throw new Error(`game-floorplan-three: the builder of \"${name}\" drew no box or cylinder`)\n\n const boardsOf = splitTopsIntoBoards(drawn, materialOf, Boolean(opts.carcass))\n const parts: PartSpec[] = drawn.map((p) => {\n const thin = Math.min(...(p.shape.kind === 'box' ? p.shape.size : p.shape.kind === 'cylinder' ? [p.shape.radius * 2, p.shape.height] : [p.shape.radius * 2]))\n let material = materialOf[p.key] ?? 'plastic'\n // a case with shelves is MDF (as bought); elsewhere thin boards are pine and thick ones hardwood\n if (p.key === 'wood' && material === 'wood_hard' && opts.carcass && !opts.materials?.wood) material = 'mdf'\n else if (p.key === 'wood' && material === 'wood_hard' && thin < WOOD_THIN) material = 'wood_soft'\n const part: PartSpec = { id: p.id, material, shape: p.shape, position: p.position }\n if (p.rotation) part.rotation = p.rotation\n if (!LOOSE.has(material) && p.min[1] <= FLOOR_TOUCH) part.anchored = true\n return part\n })\n const byId = new Map(drawn.map((p) => [p.id, p]))\n\n const joints: JointSpec[] = []\n for (const j of inferJoints(parts, 0.01)) {\n const a = parts.find((p) => p.id === j.a)!\n const b = parts.find((p) => p.id === j.b)!\n const la = LOOSE.has(a.material)\n const lb = LOOSE.has(b.material)\n if (la && lb) continue\n if (la || lb) {\n // paper rests on what is under it: its lower face on the other's upper face\n const [loose, other] = la ? [a, b] : [b, a]\n if (Math.abs(byId.get(loose.id)!.min[1] - byId.get(other.id)!.max[1]) > 0.02) continue\n joints.push({ id: j.id, a: j.a, b: j.b, kind: 'resting' })\n continue\n }\n joints.push(j)\n }\n\n // the top: among the boxes that cover most of the footprint, the highest upper face (not fabric: a cloth lies on the top)\n const all = drawn.reduce(\n (m, p) => ({ x0: Math.min(m.x0, p.min[0]), x1: Math.max(m.x1, p.max[0]), z0: Math.min(m.z0, p.min[2]), z1: Math.max(m.z1, p.max[2]) }),\n { x0: Infinity, x1: -Infinity, z0: Infinity, z1: -Infinity },\n )\n const footprint = (all.x1 - all.x0) * (all.z1 - all.z0)\n let top: FurnitureSpecResult['top'] = null\n for (const p of drawn) {\n const part = parts.find((x) => x.id === p.id)!\n if (part.shape.kind === 'sphere' || part.rotation || part.material === 'fabric' || LOOSE.has(part.material)) continue\n const area = (p.max[0] - p.min[0]) * (p.max[2] - p.min[2])\n if (area < 0.6 * footprint || p.max[1] < 0.2) continue\n if (!top || p.max[1] > top.y + 1e-6) top = { part: p.id, y: p.max[1] }\n }\n for (const boards of boardsOf.values()) {\n if (top && boards[0].max[1] <= top.y - 1e-6) continue\n const mid = boards[boards.length >> 1]\n const min = [Math.min(...boards.map((b) => b.min[0])), Math.min(...boards.map((b) => b.min[2]))]\n const max = [Math.max(...boards.map((b) => b.max[0])), Math.max(...boards.map((b) => b.max[2]))]\n if ((max[0] - min[0]) * (max[1] - min[1]) >= 0.6 * footprint && mid.max[1] >= 0.2) top = { part: mid.id, y: mid.max[1], parts: boards.map((b) => b.id) }\n }\n\n if (opts.carcass) carcass(parts, byId)\n const spec: DestructibleSpec = { name, parts, joints, tags: ['furniture'] }\n const colors = new Map(drawn.map((p) => [p.id, p.color]))\n\n const build = (T3: any): any => {\n const group = markKitOrigin(new T3.Group(), { owner: 'game-floorplan-three', kind: 'furniture', id: name })\n group.name = name\n const mats = new Map<string, any>()\n for (const p of parts) {\n const color = colors.get(p.id) ?? 0x888888\n const metal = p.material === 'steel'\n const glass = p.material === 'glass'\n const key = `${color}:${metal}:${glass}`\n let mat = mats.get(key)\n if (!mat) {\n mat = new T3.MeshStandardMaterial({ color, roughness: metal ? 0.45 : 0.85, metalness: metal ? 0.7 : 0, transparent: glass, opacity: glass ? 0.4 : 1 })\n mats.set(key, mat)\n }\n const s = p.shape\n const geo = s.kind === 'box' ? new T3.BoxGeometry(s.size[0], s.size[1], s.size[2]) : s.kind === 'cylinder' ? new T3.CylinderGeometry(s.radius, s.radius, s.height, 14) : new T3.SphereGeometry(s.radius, 12, 8)\n const mesh = new T3.Mesh(geo, mat)\n mesh.name = p.id\n mesh.userData.destructionPart = p.id\n mesh.userData.destructionMaterial = p.material\n mesh.position.set(p.position[0], p.position[1], p.position[2])\n if (p.rotation) mesh.rotation.set(p.rotation[0], p.rotation[1], p.rotation[2], 'XYZ')\n mesh.castShadow = !glass\n mesh.receiveShadow = true\n group.add(mesh)\n }\n return group\n }\n\n return { spec, build, top }\n}\n\n/**\n * The team's furniture as a destructible spec. It runs the builder of `type` (`FURNITURE.shelf` for `bookcase`, `FURNITURE.table` for `dining_table`,\n * mapped in `furniture/type-table.ts`) unchanged, with a recording stand-in for the drawing api instead of the house's accumulators: every box and\n * cylinder it draws becomes a part, named `<material key>_<n>` in drawing order (`wood_0`, `plain_17`), with the colour the builder gave it.\n * Planes and leaves (flat, no volume) and water are left out.\n *\n * Materials: `wood` is `wood_hard`, and `wood_soft` for thin boards and panels (under 3.5 cm); `metal` is `steel`; `fabric`, `glass` and `plant` keep\n * their name; `plain` is `plastic`, or `paper` for shelves and racks (their books and boxes). Parts that touch the floor are anchored. Joints come from\n * `inferJoints` (screws between wood, welds or bolts between metal...), except that paper rests on what it lies on with a `resting` joint (weak: it falls when\n * the board breaks) and is not joined to its neighbours. Shelves and racks stand as a carcass: the sides carry, each shelf needs both of its ends\n * held, and the back panel carries nothing, so a broken side drops the shelves it held, with their books.\n *\n * @example\n * const { spec, build, top } = furnitureSpec(THREE, 'bookcase') // 1.2 x 0.35 x 2 m, boards and books\n */\nexport function furnitureSpec(THREE: any, type: string, opts: FurnitureSpecOptions = {}): FurnitureSpecResult {\n const renderer = rendererOf(THREE, opts.document)\n const ent = renderer.types[type]\n if (!ent) throw new Error(`game-floorplan-three: no builder for the furniture type \"${type}\"`)\n const entry = (opts.catalog ?? (residentialItems as unknown as readonly FurnitureCatalogEntry[])).find((i) => i.type === type)\n const w = opts.w ?? entry?.w\n const d = opts.d ?? entry?.d\n const h = opts.h ?? entry?.h\n if (w === undefined || d === undefined || h === undefined) throw new Error(`game-floorplan-three: furniture type \"${type}\" is not in the catalogue, so give w, d and h`)\n const o = opts.options ?? {}\n const seed = Math.round(opts.seed ?? 1)\n const plain = SHELVING.test(type) ? 'paper' : 'plastic'\n const root: any = { x: seed, z: 0, ry: 0, w, d, h, y: 0, base: 0, palette: o.palette, seed: `furniture_${type}_${seed}` }\n const { K, shared } = renderer.internals\n const before = K.PARTS.length\n const made = recordSpec(\n THREE,\n type,\n root,\n (A) => {\n const saved = { api0: shared.api0, ctx: shared.ctx }\n shared.api0 = A // the levers and taps that the kit draws as moving parts go through its own api\n shared.ctx = shared.ctx ?? {} // outside a house the builders read the style of the plan from here\n try {\n ent.f(root, A)\n } finally {\n shared.api0 = saved.api0\n shared.ctx = saved.ctx\n }\n },\n { materials: { plain, ...o.materials }, chairs: o.chairs, carcass: SHELVING.test(type) },\n )\n const spouts = K.PARTS.slice(before)\n .filter((p: any) => p.type === 'water_tap')\n .map((p: any): [number, number, number] => [p.pos[0] - root.x, p.pos[1], p.pos[2] - root.z])\n K.PARTS.length = before\n return { spec: made.spec, build: made.build, top: made.top, size: { w, d, h }, spouts }\n}\n\nexport interface TapSpecOptions {\n /** `counter` (default): the tap of a sink, standing on the counter; `wall`: the tap of a laundry tub or a garden, with its plate on the wall. */\n kind?: 'counter' | 'wall'\n /** How far the counter tap's spout reaches, metres (default 0.2: the kitchen sink's). */\n reach?: number\n /** The `document` the house renderer makes its textures with (default the global one). */\n document?: unknown\n}\n\nexport interface TapSpecResult {\n /** The tap as parts (base, column, spout, lever), origin on the counter under the column (`counter`) or on the wall plate's centre line at the floor (`wall`). */\n spec: DestructibleSpec\n /** Draws the tap: one mesh per part, named by the part id. */\n build(THREE: any): any\n /** Where the water leaves the spout, in the space of the spec. */\n spout: [number, number, number]\n}\n\n/**\n * The team's tap (`counterTap` of the sink, `wallTap` of the laundry tub: `furniture/taps.ts`) drawn by the same code into parts, with the lever at rest. `spout` is where its\n * water thread starts, so a host can put a tap of the fluids world there; the water thread itself is not drawn.\n */\nexport function tapSpec(THREE: any, opts: TapSpecOptions = {}): TapSpecResult {\n const renderer = rendererOf(THREE, opts.document)\n const { K, shared } = renderer.internals\n const kind = opts.kind ?? 'counter'\n const root: any = { x: 1, z: 0, ry: 0, w: 0.3, d: 0.3, h: 0.3, y: 0, base: 0, seed: `tap_${kind}` }\n const before = K.PARTS.length\n const made = recordSpec(THREE, kind === 'counter' ? 'tap' : 'wall_tap', root, (A) => {\n const kit = K.kit2(root, A)\n const saved = shared.api0\n shared.api0 = A // the lever and the water thread are parts that the kit draws through its own api\n try {\n if (kind === 'counter') K.counterTap(kit, 0, 0, 0, opts.reach ?? 0.2, 0.17, {})\n else K.wallTap(kit, 0, 0.3, 0, 1, 0.1, {})\n } finally {\n shared.api0 = saved\n }\n }, { materials: {} })\n const water = K.PARTS.slice(before).find((p: any) => p.type === 'water_tap')\n if (!water) throw new Error('game-floorplan-three: the tap drew no water thread')\n K.PARTS.length = before\n return { spec: made.spec, build: made.build, spout: [water.pos[0] - root.x, water.pos[1], water.pos[2] - root.z] }\n}\n","import type { WarmUpProbes } from '@adatechnology/game-contracts'\nimport { createDestruction } from '@adatechnology/game-destruction'\nimport type { Hit } from '@adatechnology/game-destruction'\nimport { buildStructure, masonryConstruction } from '@adatechnology/game-floorplan-structure'\n\nimport { create } from './create.js'\nimport type { House, HouseRendererOptions } from './types.js'\n\n/** A free-standing wall built and drawn as the walls of the houses. */\nexport interface WallPieceOptions {\n /** Length and height in metres. */\n w: number\n h: number\n /** Default 0.15 m, the houses' wall. */\n thickness?: number\n /** Facade finish of the houses: `plaster` (default), `roughcast` or `exposed_block`. */\n finish?: string\n /** Paint colour of the plaster (default the light plaster of the houses' palette). */\n color?: number\n /** Options of the house renderer (`create`) that draws it. */\n house?: Partial<HouseRendererOptions>\n}\n\nexport interface WallPiece {\n /** The plan of the wall: one storey, one exterior wall, no rooms and no roof; its `structure` is the houses' load path. */\n readonly plan: any\n /** The destructible spec, as a house gives it (`house.structure.spec()`): the wall with its layers, units and breach on the ground, its concrete pillars (`wall_column_*`, at the ends and every 4 m at most) and the bond beam on both. */\n readonly spec: any\n /** Draws the wall with the house renderer: meshes carry `userData.destructionPart` of their part, in the space of the spec. */\n build(THREE: any): any\n /**\n * Once a drawing from `build` is in a destruction world as `objectId` (with this `spec`), the house renderer follows its events and draws on it what\n * a generic destruction renderer cannot: the bricks that shots and blows knock out (`chip`) and the opening of a breach, as gaps in the wall's\n * courses. `restore` puts the wall back (after `world.reset`), `dispose` stops following. `update` paints the damage of the events since the last call, once\n * per wall (call it every frame; without it the damage is painted 100 ms after the event).\n */\n follow(root: any, world: any, objectId: string): { restore(): void; dispose(): void; update(): void } | null\n /**\n * The wall drawn with one brick shot out of it, for a host to draw once at load (`WarmUpProbes`): the breach's materials (the shell around the hole and\n * the bricks laid bare, instanced, lit and in the shadows) get their shader programs then, not at the first shot or blast of play. `dispose` frees its\n * geometries and textures and leaves its materials to the host's warmup, which keeps them so the programs stay.\n */\n warmUpProbes(THREE: unknown): WarmUpProbes\n}\n\n/** A rifle round at the middle of the wall: it knocks a brick out, so the breach draws its shell and its bare bricks. */\nconst WARM_UP_SHOT: Hit = { type: 'ballistic', point: [0, 1.2, 0.1], direction: [0, 0, -1], energy: 3500, caliber: 7.62 }\nconst WARM_UP_FRAMES = 5\n\n/** What the probe reads of the drawing (structural: three.js objects fit). */\ntype ProbeTexture = { readonly isTexture?: boolean; dispose(): void }\ntype ProbeMaterial = { readonly uniforms?: Record<string, { readonly value?: unknown }>; readonly map?: ProbeTexture | null }\ntype ProbeNode = { visible: boolean; frustumCulled: boolean; readonly geometry?: { dispose(): void }; readonly material?: ProbeMaterial | ProbeMaterial[] }\ntype ProbeRoot = { traverse(visit: (node: ProbeNode) => void): void }\ntype ProbeHouse = {\n readonly destruction?: {\n follow?(world: unknown, objectId: string, spec: unknown): { update?(): void } | null\n readonly breach?: { flush?(budgetMs: number): number }\n }\n}\n\nconst isTexture = (value: unknown): value is ProbeTexture => typeof value === 'object' && value !== null && (value as ProbeTexture).isTexture === true\n\nconst PLASTER = 0xe8e2d4\nconst WALL_ID = 'wall_0_0'\n\n/**\n * The plan of a free-standing wall along x, centred on the origin: a one-storey plan whose only wall is exterior on both sides, with the masonry construction of\n * the houses (brick, concrete bond beam, strip footing) and the structure `buildStructure` gives the houses, without a roof.\n */\nexport function wallPlan(options: WallPieceOptions): any {\n const { w, h, thickness = 0.15, finish = 'plaster', color = PLASTER } = options\n const facade = { finish, roof: 'none', floors: 1 }\n const wall = { id: WALL_ID, floor: 0, axis: 'u', u0: -w / 2, v0: 0, u1: w / 2, v1: 0, thickness, sides: ['outside', 'outside'], exterior: true, type: 'wall', h }\n const plan: any = {\n template: 'wall', name: 'wall', style: 'mid', state: 'normal', w, d: thickness,\n floors: [{ index: 0, y0: 0, ceiling: h }], rooms: [], walls: [wall], doors: [], windows: [], items: [], stateItems: [], openPairs: [], partyWalls: [], missing: [],\n facade, colors: { facade: color, wall: color }, lot: null, building: null, waterTank: null, outbuildings: [],\n }\n plan.construction = masonryConstruction({ ...plan, facade: { ...facade, roof: 'colonial' } })\n plan.structure = buildStructure(plan, { wallDetail: 'coarse', construction: plan.construction, roof: false })\n return plan\n}\n\nfunction draw(THREE: any, plan: any, options: Partial<HouseRendererOptions>): House {\n return create(THREE, { ...options, fleet: null }).build(plan, { quality: 'game', terrain: false, noPerimeter: true, pieces: 'meshes' })\n}\n\n/** The house each drawing of `build` came from (its root is the house's group). */\nconst houses = new WeakMap<object, House>()\n\n/** Labels the meshes of each structural piece with its part id, so a destruction renderer binds them by `userData.destructionPart`. */\nfunction label(house: House): any {\n houses.set(house.group, house)\n for (const [id, items] of Object.entries<any[]>(house.destruction.ranges())) {\n for (const item of items) {\n const object = item.isObject3D ? item : item.mesh\n object.userData.destructionPart = id\n }\n }\n return house.group\n}\n\n/**\n * A free-standing wall (a target wall, a garden wall) built and drawn exactly as the walls of the houses: the structure of `game-floorplan-structure` (the wall on\n * the strip footing, the bond beam on it, the assembly's layers, units and breach) and the house renderer's plaster, paint, baseboard and sidewalk.\n */\nexport function wallPiece(THREE: any, options: WallPieceOptions): WallPiece {\n const plan = wallPlan(options)\n const houseOptions = options.house ?? {}\n // no world: the wall is drawn once to describe its structure, as the houses' specimens are. The wall keeps the detail of the houses' walls (its\n // assembly's plaster, bricks and breach), so shots wear the brick they hit and knock it out\n const probe = draw(THREE, plan, { ...houseOptions, destruction: undefined, destructionRenderer: undefined })\n const spec = probe.structure.spec()\n probe.dispose()\n return {\n plan,\n spec,\n build: (T: any) => label(draw(T, plan, houseOptions)),\n follow: (root: any, world: any, objectId: string) => (houses.get(root) as any)?.destruction?.follow?.(world, objectId, spec) ?? null,\n warmUpProbes: (T: unknown): WarmUpProbes => {\n const house = draw(T, plan, houseOptions)\n const root = label(house) as ProbeRoot\n const world = createDestruction({ seed: 1 })\n const objectId = world.add(spec, { id: 'warm_up_wall' })\n const destruction = (house as unknown as ProbeHouse).destruction\n const follower = destruction?.follow?.(world, objectId, spec) ?? null\n world.hitPart(objectId, WALL_ID, WARM_UP_SHOT)\n for (let frame = 0; frame < WARM_UP_FRAMES; frame++) {\n world.update(1 / 60)\n follower?.update?.()\n }\n // paint all of it now: in a room the breach paints within the frame budget, and the probe is drawn before any frame runs\n for (let guard = 0; guard < WARM_UP_FRAMES && (destruction?.breach?.flush?.(Infinity) ?? 0) > 0; guard++);\n // drawn whatever the camera: the breach hides its bricks from afar (its level of detail), and an object that is not drawn builds no program\n root.traverse((node) => {\n node.visible = true\n node.frustumCulled = false\n })\n return {\n group: root,\n // the materials stay: the warmup keeps them as anchors, and disposing the last material of a program frees the program it was drawn for (so the\n // follower is not disposed either: it would put the wall back and dispose the breach's materials; its world goes with the probe)\n dispose: () => {\n root.traverse((node) => {\n node.geometry?.dispose()\n for (const material of Array.isArray(node.material) ? node.material : node.material ? [node.material] : []) {\n for (const uniform of Object.values(material.uniforms ?? {})) if (isTexture(uniform.value)) uniform.value.dispose()\n material.map?.dispose()\n }\n })\n },\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiFA,IAAM,OAAO;AACb,IAAM,SAAS;AACf,IAAM,WAAW;AACjB,IAAM,QAAQ;AACd,IAAM,QAAQ;AACd,IAAM,OAAO;AACb,IAAM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,UAAU,IAAI,KAAK;AACjE,YAAM,QAAQ,UAAU,SAAS,YAAY;AAC7C,eAAS,QAAQ,GAAG,QAAQ,gBAAgB,SAAS;AACnD,cAAM,OAAO,IAAI,EAAE;AACnB,kBAAU,SAAS;AAAA,MACrB;AAEA,eAAS,QAAQ,GAAG,QAAQ,mBAAmB,aAAa,QAAQ,QAAQ,QAAQ,KAAK,KAAK,GAAG,QAAQ;AAEzG,WAAK,SAAS,CAAC,SAAS;AACtB,aAAK,UAAU;AACf,aAAK,gBAAgB;AAAA,MACvB,CAAC;AACD,aAAO;AAAA,QACL,OAAO;AAAA;AAAA;AAAA,QAGP,SAAS,MAAM;AACb,eAAK,SAAS,CAAC,SAAS;AACtB,iBAAK,UAAU,QAAQ;AACvB,uBAAW,YAAY,MAAM,QAAQ,KAAK,QAAQ,IAAI,KAAK,WAAW,KAAK,WAAW,CAAC,KAAK,QAAQ,IAAI,CAAC,GAAG;AAC1G,yBAAW,WAAW,OAAO,OAAO,SAAS,YAAY,CAAC,CAAC,EAAG,KAAI,UAAU,QAAQ,KAAK,EAAG,SAAQ,MAAM,QAAQ;AAClH,uBAAS,KAAK,QAAQ;AAAA,YACxB;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["i","j"]}
|
|
1
|
+
{"version":3,"sources":["../src/navigation/floor-navigator.ts","../src/navigation/from-house.ts","../src/navigation/bind.ts","../src/furniture/spec.ts","../src/wall.ts"],"sourcesContent":["/*\n * Floor navigator: walking on several floors of a house (stairs, banisters, path field, occlusion). Literal port of the team's AndaresSDK\n * (sdk/andares), with English names. Coordinates are the house's. The ground floor can keep using the game's own grid: `blocked` answers -1\n * (\"use the ground grid\") unless the house is registered with `own: true`.\n *\n * House: { id, floors: [{ y, h, solids: [[x0, z0, x1, z1], ...] }], stairs: [[x0, z0, x1, z1, from, to, axis], ...], groups: [obj | [obj] ...], roof }\n * - a stair climbs from x0/z0 to x1/z1 (x0 > x1 reverses); stairs with the same footprint become a U-turn (one lane for each flight).\n * - groups[f] = what is drawn of floor f (an Object3D with .visible, or a function show(bool)); roof the same.\n *\n * Additions over the team's code (spec 001, T2.4d): `openCells` and `closeCells` change the fine grid at run time, so a breach (stage 2) opens the\n * cells of a wall and a slab that collapses or fractures removes the cells of its floor (`bindNavigator`, ./bind.ts).\n */\n\n/** A rectangle `[x0, z0, x1, z1]` in the house's coordinates. */\nexport type NavRect = [number, number, number, number]\n/** `[x0, z0, x1, z1, from, to, axis]`: a flight from floor `from` to floor `to` along `axis`. */\nexport type NavStair = [number, number, number, number, number, number, 'x' | 'z']\n\nexport interface NavFloor {\n /** Absolute height of the floor level. */\n y: number\n /** Height of the storey. */\n h: number\n solids?: NavRect[]\n}\n\nexport interface NavHouseDef {\n id: string\n floors: NavFloor[]\n stairs?: NavStair[]\n groups?: NavShowable[]\n roof?: NavShowable\n /** The fine grid also rules the ground floor inside the house (default: the ground floor uses the game's grid, except stairs and banisters). */\n own?: boolean\n /** The house's rectangle (default: the union of its solids and stairs). */\n rect?: NavRect\n}\n\n/** A shape on the plan: a rectangle `[x0, z0, x1, z1]` or a circle `[cx, cz, radius]`. */\nexport type NavShape = { rect: NavRect } | { circle: [number, number, number] }\n\nexport interface NavResult {\n y: number\n floor: number\n dx: number\n dz: number\n t: number\n stair: NavFlight | null\n}\n\nexport interface NavFlight {\n x0: number; z0: number; x1: number; z1: number\n axis: 0 | 1\n from: number\n to: number\n group: StairGroup\n yFrom: number\n yTo: number\n dir: number\n lo: number\n len: number\n e: number\n}\n\n/** What is drawn of a floor (or the roof): an object with `visible`, a function `show(visible)`, or a list of them. */\nexport type NavShowable = { visible: boolean } | ((visible: boolean) => void) | readonly NavShowable[] | null | undefined\n\n/** The flights that share one stair footprint: the axis they climb along, the footprint and each flight's floors. */\nexport interface StairGroup {\n ax: 0 | 1\n r: number[]\n m: { from: number; to: number; inv: boolean }[]\n}\n\n/** The path field of a floor on the coarse grid: free cells, distances and the BFS queue to the current target cell. */\nexport interface PathField {\n gx: number\n gz: number\n free: Uint8Array\n d: Int16Array\n q: Int32Array\n target: number\n t: number\n}\n\nexport interface NavHouse {\n id: string\n own: boolean\n floors: NavFloor[]\n groups: NavShowable[]\n roof: NavShowable\n flights: NavFlight[]\n grids: Uint8Array[]\n fields: (PathField | null)[]\n /** Triples (floor, cell, previous value) of the run-time changes of the grid. */\n journal: number[]\n shown: number\n x0: number; z0: number; x1: number; z1: number\n ox: number; oz: number; nx: number; nz: number\n n: number\n}\n\nconst CELL = 0.1 // fine cell, 10 cm\nconst COARSE = 2 // coarse cell of the path field = 2 x 2 fine ones\nconst OPEN_END = 0.7 // at the ends, the side stays open for 0.7 m (entry/exit by the side)\nconst SLACK = 0.45 // flat stretch at the ends of a stair (m): there one can enter and leave by the sides\nconst SOLID = 1\nconst FREE = 2 // forced free (inside the stair)\nconst VOID = 4 // no floor (a collapsed slab)\nconst clamp = (v: number, a: number, b: number) => (v < a ? a : v > b ? b : v)\n\nexport function createFloorNavigator() {\n const N: { houses: NavHouse[]; x0: number; z0: number; x1: number; z1: number; currentHouse: NavHouse | null; currentFloor: number; time: number; result: NavResult } = { houses: [] as NavHouse[], x0: 1e9, z0: 1e9, x1: -1e9, z1: -1e9, currentHouse: null as NavHouse | null, currentFloor: 0, time: 0, result: { y: 0, floor: 0, dx: 0, dz: 0, t: 0, stair: null } as NavResult }\n\n // ----- fine grid of a floor: bit 1 solid, bit 2 forced free (inside the stair), bit 4 no floor -----\n function paint(c: NavHouse, g: Uint8Array, x0: number, z0: number, x1: number, z1: number, v: number) {\n const i0 = Math.max(0, Math.ceil((x0 - c.ox) / CELL - 0.5)), i1 = Math.min(c.nx - 1, Math.floor((x1 - c.ox) / CELL - 0.5))\n const j0 = Math.max(0, Math.ceil((z0 - c.oz) / CELL - 0.5)), j1 = Math.min(c.nz - 1, Math.floor((z1 - c.oz) / CELL - 0.5))\n for (let j = j0; j <= j1; j++) for (let i = i0; i <= i1; i++) { if (v === FREE) g[j * c.nx + i] = FREE; else g[j * c.nx + i] |= v }\n }\n\n function register(def: NavHouseDef): NavHouse {\n const c: NavHouse = { id: def.id, own: !!def.own, floors: def.floors, groups: def.groups || [], roof: def.roof || null, flights: [], grids: [], fields: [], journal: [], shown: -2, x0: 0, z0: 0, x1: 0, z1: 0, ox: 0, oz: 0, nx: 0, nz: 0, n: def.floors.length }\n // the house's rectangle: union of the solids and stairs of all floors (or the given one)\n let x0 = 1e9, z0 = 1e9, x1 = -1e9, z1 = -1e9\n const env = (r: { 0: number; 1: number; 2: number; 3: number }) => { x0 = Math.min(x0, r[0], r[2]); z0 = Math.min(z0, r[1], r[3]); x1 = Math.max(x1, r[0], r[2]); z1 = Math.max(z1, r[1], r[3]) }\n if (def.rect) env(def.rect); else { for (const a of def.floors) for (const s of a.solids || []) env(s); for (const e of def.stairs || []) env(e) }\n c.x0 = x0; c.z0 = z0; c.x1 = x1; c.z1 = z1\n c.ox = x0 - 0.5; c.oz = z0 - 0.5; c.nx = Math.ceil((x1 - x0 + 1) / CELL); c.nz = Math.ceil((z1 - z0 + 1) / CELL)\n // stairs: groups the ones with the same footprint; each flight takes a lane and the odd ones climb backwards (U-turn)\n const groups: StairGroup[] = []\n for (const e of def.stairs || []) {\n const r = [Math.min(e[0], e[2]), Math.min(e[1], e[3]), Math.max(e[0], e[2]), Math.max(e[1], e[3])], ax = e[6] === 'z' ? 1 : 0, inv = ax ? e[3] < e[1] : e[2] < e[0]\n let g = groups.find((q) => q.ax === ax && Math.abs(q.r[0] - r[0]) < 0.08 && Math.abs(q.r[1] - r[1]) < 0.08 && Math.abs(q.r[2] - r[2]) < 0.08 && Math.abs(q.r[3] - r[3]) < 0.08)\n if (!g) groups.push((g = { ax, r, m: [] }))\n g.m.push({ from: e[4], to: e[5], inv })\n }\n for (const g of groups) {\n g.m.sort((a, b) => a.from - b.from)\n const k = g.m.length, lat = g.ax ? 0 : 1 // lateral axis\n g.m.forEach((m, q: number) => {\n const r = g.r.slice(), l0 = g.r[lat], w = (g.r[lat + 2] - l0) / k\n r[lat] = l0 + w * q; r[lat + 2] = l0 + w * (q + 1)\n const s: NavFlight = { x0: r[0], z0: r[1], x1: r[2], z1: r[3], axis: g.ax, from: m.from, to: m.to, group: g, yFrom: def.floors[m.from].y, yTo: def.floors[m.to].y, dir: 0, lo: 0, len: 0, e: 0 }\n s.dir = q & 1 ? (m.inv ? 1 : -1) : m.inv ? -1 : 1 // direction of the axis when climbing\n s.lo = g.ax ? r[1] : r[0]; s.len = (g.ax ? r[3] : r[2]) - s.lo; s.e = Math.min(0.3, SLACK / s.len)\n c.flights.push(s)\n })\n }\n // fine grid per floor\n for (let a = 0; a < c.n; a++) {\n const g = new Uint8Array(c.nx * c.nz); c.grids.push(g)\n for (const s of def.floors[a].solids || []) paint(c, g, Math.min(s[0], s[2]), Math.min(s[1], s[3]), Math.max(s[0], s[2]), Math.max(s[1], s[3]), SOLID)\n }\n // banister: sides and caps closed, except at the open ends of that floor; inside of the stair free\n const T = 0.22\n for (const g of groups) {\n const [rx0, rz0, rx1, rz1] = g.r, ax = g.ax, lo = ax ? rz0 : rx0, hi = ax ? rz1 : rx1, len = hi - lo, f = Math.min(OPEN_END, len * 0.3)\n const pe = (a0: number, b0: number, a1: number, b1: number, grd: Uint8Array, v = SOLID) => (ax ? paint(c, grd, b0, a0, b1, a1, v) : paint(c, grd, a0, b0, a1, b1, v)) // (axis, lateral)\n const l0 = ax ? rx0 : rz0, l1 = ax ? rx1 : rz1\n const floors = new Set<number>(); for (const m of g.m) { floors.add(m.from); floors.add(m.to) }\n for (const a of floors) pe(lo, l0, hi, l1, c.grids[a], FREE) // inside of the stair free\n for (const a of floors) {\n const grd = c.grids[a]\n // open end on the axis: base (lowest coordinate) or top; depends on the direction of each flight\n let openLo = false, openHi = false\n for (const s of c.flights) if (s.group === g) {\n const baseLo = s.dir > 0 // the base is at the lowest coordinate\n if (s.from === a) { if (baseLo) openLo = true; else openHi = true }\n if (s.to === a) { if (baseLo) openHi = true; else openLo = true }\n }\n // outer sides and dividers between lanes, outside the open-end zones\n const ini = openLo ? lo + f : lo - T, fim = openHi ? hi - f : hi + T\n pe(ini, l0 - T, fim, l0, grd); pe(ini, l1, fim, l1 + T, grd)\n const k = g.m.length; for (let q = 1; q < k; q++) { const lm = l0 + ((l1 - l0) * q) / k; pe(lo + f, lm - 0.05, hi - f, lm + 0.05, grd) }\n if (!openLo) pe(lo - T, l0, lo, l1, grd)\n if (!openHi) pe(hi, l0, hi + T, l1, grd)\n }\n }\n N.houses.push(c); N.x0 = Math.min(N.x0, x0); N.z0 = Math.min(N.z0, z0); N.x1 = Math.max(N.x1, x1); N.z1 = Math.max(N.z1, z1)\n return c\n }\n\n const houseAt = (x: number, z: number): NavHouse | null => {\n if (x < N.x0 || x > N.x1 || z < N.z0 || z > N.z1) return null\n for (let k = 0; k < N.houses.length; k++) { const c = N.houses[k]; if (x >= c.x0 && x <= c.x1 && z >= c.z0 && z <= c.z1) return c }\n return null\n }\n // cell of the fine grid (value 0..7) or -1 outside the house\n const cell = (c: NavHouse, a: number, x: number, z: number): number => {\n const i = Math.floor((x - c.ox) / CELL), j = Math.floor((z - c.oz) / CELL)\n return i < 0 || j < 0 || i >= c.nx || j >= c.nz ? -1 : c.grids[a][j * c.nx + i]\n }\n // block per floor: 1 blocked, 0 free, -1 \"use the ground grid\" (floor 0 with nothing special there)\n function blocked(x: number, z: number, floor: number): number {\n const c = houseAt(x, z)\n if (!c) return floor > 0 ? 1 : -1\n if (floor >= c.n) return 1\n const v = cell(c, floor, x, z)\n if (v === FREE) return 0\n if (v >= 0 && v & VOID) return 1\n if (floor > 0 || c.own) return v < 0 || v & SOLID ? 1 : 0 // own: the fine grid of the house also rules the ground floor\n return v > 0 ? 1 : -1\n }\n // level: y and floor of the point, considering the stair. Returns true when it is on a stair (result in N.result)\n function level(x: number, z: number, floor: number): boolean {\n const r: NavResult = N.result, c = houseAt(x, z); r.stair = null\n if (!c) { r.floor = floor; r.y = 0; return false }\n for (let k = 0; k < c.flights.length; k++) {\n const s = c.flights[k]\n if ((floor !== s.from && floor !== s.to) || x < s.x0 || x > s.x1 || z < s.z0 || z > s.z1) continue\n let t = ((s.axis ? z : x) - s.lo) / s.len; if (s.dir < 0) t = 1 - t\n const u = clamp((t - s.e) / (1 - 2 * s.e), 0, 1)\n r.y = s.yFrom + (s.yTo - s.yFrom) * u; r.t = t; r.floor = t < 0.5 ? s.from : s.to; r.stair = s\n return true\n }\n r.floor = floor; r.y = c.floors[floor] ? c.floors[floor].y : 0\n return false\n }\n // point at an end of the stair, at the centre of the lane; inside > 0 towards the inside of the end, < 0 towards the outside\n function landing(s: NavFlight, top: boolean, inside: number, out: number[]): number[] {\n const lo = top ? s.dir < 0 : s.dir > 0, a = lo ? s.lo + inside : s.lo + s.len - inside, b = s.axis ? (s.x0 + s.x1) / 2 : (s.z0 + s.z1) / 2\n out[0] = s.axis ? b : a; out[1] = s.axis ? a : b\n return out\n }\n // stair that takes floor a to floor b (b > a climbs, b < a descends) in the house; null if there is none\n function stairTo(c: NavHouse, a: number, b: number): NavFlight | null {\n for (const s of c.flights) if (b > a ? s.from === a : s.to === a) return s\n return null\n }\n // ----- path field per floor (BFS on the coarse grid) to a point; recomputed only when the target changes cell -----\n function field(c: NavHouse, a: number) {\n const f = c.fields[a]; if (f) return f\n const gx = Math.ceil(c.nx / COARSE), gz = Math.ceil(c.nz / COARSE), free = new Uint8Array(gx * gz), g = c.grids[a]\n for (let j = 0; j < gz; j++) for (let i = 0; i < gx; i++) {\n let b = 0\n for (let q = 0; q < COARSE && !b; q++) for (let p = 0; p < COARSE; p++) {\n const ii = i * COARSE + p, jj = j * COARSE + q\n if (ii < c.nx && jj < c.nz) { const v = g[jj * c.nx + ii]; if (v === SOLID || v & VOID) { b = 1; break } }\n }\n free[j * gx + i] = b ? 0 : 1\n }\n return (c.fields[a] = { gx, gz, free, d: new Int16Array(gx * gz), q: new Int32Array(gx * gz), target: -1, t: -9 })\n }\n const DX = [1, -1, 0, 0, 1, 1, -1, -1], DZ = [0, 0, 1, -1, 1, -1, 1, -1]\n // direction (in N.result.dx/dz, unit) from (x,z) towards (tx,tz) walking on floor a; false if there is no path (go straight)\n function heading(c: NavHouse, a: number, x: number, z: number, tx: number, tz: number): boolean {\n const f = field(c, a), cs = CELL * COARSE\n const ci = clamp(Math.floor((tx - c.ox) / cs), 0, f.gx - 1), cj = clamp(Math.floor((tz - c.oz) / cs), 0, f.gz - 1), ca = cj * f.gx + ci\n if (ca !== f.target && N.time - f.t > 0.15) { // BFS from the target\n f.target = ca; f.t = N.time; f.d.fill(-1); let h = 0, e = 0; f.q[e++] = ca; f.d[ca] = 0\n while (h < e) {\n const k = f.q[h++], i = k % f.gx, j = (k / f.gx) | 0\n for (let n = 0; n < 8; n++) {\n const ni = i + DX[n], nj = j + DZ[n]; if (ni < 0 || nj < 0 || ni >= f.gx || nj >= f.gz) continue\n const nk = nj * f.gx + ni; if (f.d[nk] >= 0 || !f.free[nk]) continue\n if (n > 3 && (!f.free[j * f.gx + ni] || !f.free[nj * f.gx + i])) continue // a diagonal does not cut a corner\n f.d[nk] = f.d[k] + 1; f.q[e++] = nk\n }\n }\n }\n const i = Math.floor((x - c.ox) / cs), j = Math.floor((z - c.oz) / cs)\n if (i < 0 || j < 0 || i >= f.gx || j >= f.gz) return false\n const k0 = j * f.gx + i, r: NavResult = N.result\n let best = f.d[k0] >= 0 ? f.d[k0] : 1e9, bi = -1 // blocked cell (e.g. inside the stair): leaves by the neighbour closest to the target\n if (f.target < 0) return false\n for (let n = 0; n < 8; n++) {\n const ni = i + DX[n], nj = j + DZ[n]; if (ni < 0 || nj < 0 || ni >= f.gx || nj >= f.gz) continue\n const d = f.d[nj * f.gx + ni]; if (d < 0 || d >= best) continue\n if (n > 3 && (!f.free[j * f.gx + ni] || !f.free[nj * f.gx + i])) continue\n best = d; bi = n\n }\n if (bi < 0) return false\n const px = c.ox + (i + DX[bi] + 0.5) * cs, pz = c.oz + (j + DZ[bi] + 0.5) * cs, dx = px - x, dz = pz - z, l = Math.hypot(dx, dz) || 1\n r.dx = dx / l; r.dz = dz / l\n return true\n }\n // ceiling of a floor: the next floor's level minus the slab; on the last one, the storey height\n const ceilingOf = (c: NavHouse, a: number): number => (a + 1 < c.n ? c.floors[a + 1].y - 0.2 : c.floors[a].y + c.floors[a].h)\n // ray against the grids and the floor's ceiling: distance until it hits or -1\n function ray(c: NavHouse, a: number, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, max: number): number {\n const top = ceilingOf(c, a)\n for (let s = 0.1; s <= max; s += 0.1) {\n const x = ox + dx * s, y = oy + dy * s, z = oz + dz * s\n if (y > top || y < c.floors[a].y) return s\n const v = cell(c, a, x, z); if (v < 0 || v === SOLID) return s\n }\n return -1\n }\n function apply(c: NavHouse, floor: number) {\n if (c.shown === floor) return\n c.shown = floor\n const show = (o: NavShowable, v: boolean): void => { if (!o) return; if (typeof o === 'function') o(v); else if (Array.isArray(o)) o.forEach((q) => show(q, v)); else (o as { visible: boolean }).visible = v }\n for (let a = 0; a < c.groups.length; a++) show(c.groups[a], floor < 0 || a <= floor)\n show(c.roof, floor < 0)\n }\n // occlusion: hides the floors above whoever is inside, and the roof; outside, shows everything\n function occlude(x: number, z: number, floor: number): NavHouse | null {\n const c = houseAt(x, z)\n if (c !== N.currentHouse && N.currentHouse) apply(N.currentHouse, -1)\n N.currentHouse = c; N.currentFloor = floor\n if (c) apply(c, floor)\n return c\n }\n\n // ----- run-time changes of the grid (destruction) -----\n const houseOf = (id: string): NavHouse | null => N.houses.find((h: NavHouse) => h.id === id) || null\n /** Visits the cells of the fine grid inside `shape` on `floor`. Returns how many it visited. */\n function each(c: NavHouse, floor: number, shape: NavShape, fn: (g: Uint8Array, k: number) => void): number {\n const g = c.grids[floor]; if (!g) return 0\n let x0: number, z0: number, x1: number, z1: number\n const circle = 'circle' in shape ? shape.circle : null\n if (circle) { x0 = circle[0] - circle[2]; z0 = circle[1] - circle[2]; x1 = circle[0] + circle[2]; z1 = circle[1] + circle[2] } else [x0, z0, x1, z1] = (shape as { rect: NavRect }).rect\n const i0 = Math.max(0, Math.ceil((Math.min(x0, x1) - c.ox) / CELL - 0.5)), i1 = Math.min(c.nx - 1, Math.floor((Math.max(x0, x1) - c.ox) / CELL - 0.5))\n const j0 = Math.max(0, Math.ceil((Math.min(z0, z1) - c.oz) / CELL - 0.5)), j1 = Math.min(c.nz - 1, Math.floor((Math.max(z0, z1) - c.oz) / CELL - 0.5))\n let n = 0\n for (let j = j0; j <= j1; j++) for (let i = i0; i <= i1; i++) {\n if (circle) { const dx = c.ox + (i + 0.5) * CELL - circle[0], dz = c.oz + (j + 0.5) * CELL - circle[1]; if (dx * dx + dz * dz > circle[2] * circle[2]) continue }\n fn(g, j * c.nx + i); n++\n }\n return n\n }\n /** A wall or a banister opened (breach, fracture): the solid cells inside `shape` on `floor` become free. Returns the cells it visited. */\n function openCells(houseId: string, floor: number, shape: NavShape): number {\n const c = houseOf(houseId); if (!c) return 0\n const n = each(c, floor, shape, (g, k) => { if (g[k] !== FREE && g[k] & SOLID) { c.journal.push(floor, k, g[k]); g[k] &= ~SOLID } })\n c.fields[floor] = null\n return n\n }\n /** A slab collapsed or fractured: the cells inside `shape` on `floor` have no floor any more (blocked, and the path field avoids them). */\n function closeCells(houseId: string, floor: number, shape: NavShape): number {\n const c = houseOf(houseId); if (!c) return 0\n const n = each(c, floor, shape, (g, k) => { if (!(g[k] & VOID)) { c.journal.push(floor, k, g[k]); g[k] = (g[k] === FREE ? 0 : g[k]) | VOID } })\n c.fields[floor] = null\n return n\n }\n /** Puts the grid of the house back to what it was (after a world reset): undoes every `openCells` and `closeCells`. */\n function undoChanges(houseId: string): void {\n const c = houseOf(houseId); if (!c) return\n const j = c.journal\n for (let k = j.length - 3; k >= 0; k -= 3) { c.grids[j[k]][j[k + 1]] = j[k + 2]; c.fields[j[k]] = null }\n j.length = 0\n }\n\n return Object.assign(N, { register, houseAt, blocked, level, landing, stairTo, heading, ray, ceilingOf, occlude, cell, apply, houseOf, openCells, closeCells, undoChanges }) as FloorNavigator\n}\n\nexport interface FloorNavigator {\n houses: NavHouse[]\n /** Frame time in seconds; the path field is recomputed at most every 0.15 s of it. */\n time: number\n currentHouse: NavHouse | null\n currentFloor: number\n /** Result of the last `level` and `heading` call (no allocation per query). */\n result: NavResult\n register(def: NavHouseDef): NavHouse\n houseAt(x: number, z: number): NavHouse | null\n blocked(x: number, z: number, floor: number): number\n level(x: number, z: number, floor: number): boolean\n landing(flight: NavFlight, top: boolean, inside: number, out: number[]): number[]\n stairTo(house: NavHouse, from: number, to: number): NavFlight | null\n heading(house: NavHouse, floor: number, x: number, z: number, tx: number, tz: number): boolean\n ray(house: NavHouse, floor: number, ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, max: number): number\n ceilingOf(house: NavHouse, floor: number): number\n occlude(x: number, z: number, floor: number): NavHouse | null\n cell(house: NavHouse, floor: number, x: number, z: number): number\n apply(house: NavHouse, floor: number): void\n houseOf(id: string): NavHouse | null\n openCells(houseId: string, floor: number, shape: NavShape): number\n closeCells(houseId: string, floor: number, shape: NavShape): number\n undoChanges(houseId: string): void\n}\n","import type { NavHouseDef, NavRect, NavShowable, NavStair } from './floor-navigator.js'\n\n/** A box collider of the house: type, floor and rectangle. */\nexport interface NavBoxCollider { type: string; f: number; x0: number; z0: number; x1: number; z1: number }\n\n/** The parts of a built house (`create(THREE, options).build(...)`) the navigator reads. */\nexport interface NavigableHouse {\n name?: string\n r: { floors: { index: number; y0: number; ceiling: number }[] }\n /** Its colliders; the box ones (`x0`..`z1`) of the solid types make the cells solid. */\n colliders: readonly (NavBoxCollider | { type: string; f: number })[]\n stairs: { m: { ry: number }; f: number; to: number; rect: NavRect }[]\n floors: NavShowable[]\n roof: NavShowable\n}\n\nexport interface NavigationDefOptions {\n /** Id the house registers with (default: the house's name). */\n id?: string\n /** Collider types that make a cell solid (default: walls and the boards of a barricade; the gaps of the doors stay free). */\n solids?: string[]\n /** The fine grid also rules the ground floor inside the house. */\n own?: boolean\n}\n\n/**\n * The registration of a built house in a floor navigator: heights from the plan's floors, solids from the house's wall colliders, one flight per\n * stair (its footprint, from the floor it leaves to the floor it reaches, along the axis the flight runs on) and the floor groups and roof to hide\n * by occlusion.\n */\nexport function navigationDefOf(house: NavigableHouse, options: NavigationDefOptions = {}): NavHouseDef {\n const types = new Set(options.solids ?? ['wall', 'board'])\n const floors = house.r.floors.map((floor) => ({\n y: floor.y0,\n h: floor.ceiling,\n solids: house.colliders.filter((c): c is NavBoxCollider => c.f === floor.index && types.has(c.type)).map((c): NavRect => [c.x0, c.z0, c.x1, c.z1]),\n }))\n // a flight climbs towards the local -z of its item (its bottom is at +z): in the world that is (-sin, -cos) of the rotation\n const stairs = house.stairs.map((stair): NavStair => {\n const c = Math.cos(stair.m.ry), s = Math.sin(stair.m.ry), [x0, z0, x1, z1] = stair.rect\n if (Math.abs(c) >= Math.abs(s)) return -c > 0 ? [x0, z0, x1, z1, stair.f, stair.to, 'z'] : [x0, z1, x1, z0, stair.f, stair.to, 'z']\n return -s > 0 ? [x0, z0, x1, z1, stair.f, stair.to, 'x'] : [x1, z0, x0, z1, stair.f, stair.to, 'x']\n })\n return { id: options.id ?? house.name ?? 'house', floors, stairs, groups: house.floors, roof: house.roof, own: options.own }\n}\n","import type { DestructionEvent } from '@adatechnology/game-destruction'\n\nimport type { FloorNavigator, NavRect } from './floor-navigator.js'\n\n/** The parts of a built house the binding reads: its structure (parts by id), its floors and its destruction adapter. */\nexport interface DestructibleHouse {\n r: { floors: { index: number; y0: number }[] }\n structure: { byId: Map<string, { role: string; floor: number; aabb: NavRect; y1: number }> }\n destruction: { onEvent(listener: (event: DestructionEvent) => void): () => void; restore?: () => void }\n}\n\nexport interface NavigatorBinding {\n /** Stops listening. */\n off(): void\n /** Puts the grid back (after a world reset). */\n reset(): void\n}\n\nconst WALL_ROLES = new Set(['wall', 'partition'])\n\n/**\n * Connects a floor navigator to the destruction of a house, so the people walking in it follow what the world did to it:\n * - a wall that reaches stage 2 opens the cells inside its opening (a circle on its floor);\n * - a wall that fractures or collapses opens all the cells of its footprint;\n * - a slab that supports a floor and fractures or collapses removes the cells of that floor under it (they become blocked).\n * The house has to be registered in the navigator under `houseId` (`navigationDefOf`). Events arrive once the house's destruction is active.\n * Returns the binding; `reset()` undoes the changes.\n */\nexport function bindNavigator(navigator: FloorNavigator, houseId: string, house: DestructibleHouse): NavigatorBinding {\n const level = (floor: number) => house.r.floors.find((f) => f.index === floor)?.y0\n const gone = (id: string) => {\n const part = house.structure.byId.get(id)\n if (!part) return\n if (WALL_ROLES.has(part.role)) navigator.openCells(houseId, part.floor, { rect: part.aabb })\n else if (part.role === 'slab') {\n const y = level(part.floor)\n // only the slab a floor stands on: its top is the floor level (a roof slab is not a floor)\n if (y !== undefined && Math.abs(part.y1 - y) < 0.1) navigator.closeCells(houseId, part.floor, { rect: part.aabb })\n }\n }\n const off = house.destruction.onEvent((event) => {\n if (event.type === 'stage' && event.stage === 2 && event.opening) {\n const part = house.structure.byId.get(event.part)\n if (part && WALL_ROLES.has(part.role)) navigator.openCells(houseId, part.floor, { circle: [event.opening.center[0], event.opening.center[2], event.opening.radius] })\n } else if (event.type === 'fracture') gone(event.part)\n else if (event.type === 'collapse') for (const id of event.parts) gone(id)\n })\n return { off, reset: () => navigator.undoChanges(houseId) }\n}\n","import { inferJoints } from '@adatechnology/game-destruction'\nimport { markKitOrigin } from '@adatechnology/game-contracts'\nimport type { DestructibleSpec, JointSpec, PartSpec } from '@adatechnology/game-contracts'\n\nimport { residentialItems } from '@adatechnology/game-floorplan-residential'\n\nimport { create } from '../create.js'\nimport type * as THREE_NS from 'three'\nimport type { BuildContext, Frame, FurnitureApi, HouseRendererInternal, Mount, Three } from '../kernel-types.js'\n\n/** What `furnitureSpec` reads of a catalogue entry (the items of `game-floorplan-residential` and the other packs have more). */\nexport interface FurnitureCatalogEntry {\n type: string\n w: number\n d: number\n h: number\n}\n\nexport interface FurnitureSpecOptions {\n /** Size in metres (default: the catalogue entry of the type). */\n w?: number\n d?: number\n h?: number\n /** Seed of the builder's random (the books of a shelf, the crates): same seed, same piece (default 1). */\n seed?: number\n /** Builder-level choices. */\n options?: {\n /** Material of the destruction world per builder material key (`wood`, `metal`, `plain`, `fabric`, `glass`...), overriding the defaults. */\n materials?: Record<string, string>\n /** Keep the chairs a table draws (default true). Chairs are drawn by the builder in a frame of their own, so this drops everything drawn in another frame than the piece's. */\n chairs?: boolean\n /** Colour roles of the builder (`wood`, `fabric_main`, `fabric_accent`, `metal`...) as `0xRRGGBB`. */\n palette?: Record<string, number>\n }\n /** Catalogue the default size is read from (`defaultFurnitureCatalog()` of `game-kit-defaults`, or the game's own). Default `residentialItems`, which is deprecated: pass the catalogue. */\n catalog?: readonly FurnitureCatalogEntry[]\n /** The `document` the house renderer makes its textures with (default the global one). */\n document?: unknown\n}\n\nexport interface FurnitureSpecResult {\n /** One part per box or cylinder the builder drew, origin at the centre of the footprint on the floor. */\n spec: DestructibleSpec\n /** Draws the piece: one mesh per part, named by the part id, coloured as the builder coloured it. */\n build(THREE: Three): THREE_NS.Group\n /** The widest high horizontal part and the height of its upper face (what loose things rest on), or null when the piece has none. */\n /** What loose things rest on. A solid top is boards: `parts` are all of them, `part` the one in the middle. */\n top: { part: string; y: number; parts?: string[] } | null\n /** Size the piece was drawn at. */\n size: { w: number; d: number; h: number }\n /** Where the water leaves the taps the builder drew (a sink, a tub), in the space of the spec; empty for furniture without a tap. */\n spouts: Array<[number, number, number]>\n}\n\ninterface Drawn {\n id: string\n key: string\n shape: PartSpec['shape']\n position: [number, number, number]\n rotation: [number, number, number] | null\n color: number\n min: [number, number, number]\n max: [number, number, number]\n}\n\nconst WOOD_THIN = 0.035\n/** A solid wooden top is boards glued edge to edge: thicker than this it is a block and stays whole; narrower than `BOARD_TOP_WIDTH` it is one board. */\nconst BOARD_TOP_THICK = 0.07\nconst BOARD_TOP_WIDTH = 0.5\nconst BOARD_WIDTH = 0.16\n/** A shelf falls when what holds it leaves it this many times its own length of span (one side gone: twice its length). */\nconst SHELF_SPAN = 1.5\n/** Types that are cases with shelves: their `plain` boxes are books and boxes, and they stand as a carcass. */\nconst SHELVING = /shelf|bookcase|rack/\n\n/**\n * The frame of a case piece (a bookcase, a shelf unit, a rack): the uprights stand on the floor and carry, each shelf rests on them and needs both\n * ends held (`structure.maxSpan`), and the back panel carries nothing. Break a side and the shelves it held fall with what is on them.\n */\nfunction carcass(parts: PartSpec[], drawn: Map<string, Drawn>): void {\n const all = [...drawn.values()]\n const width = Math.max(...all.map((p) => p.max[0])) - Math.min(...all.map((p) => p.min[0]))\n for (const part of parts) {\n if (LOOSE.has(part.material) || part.shape.kind !== 'box' || part.rotation) continue\n const [x, y, z] = part.shape.size\n if (y >= x && y >= z) {\n // upright: a side (thin across the width) carries; a back or front panel (thin in depth, as wide as the piece) does not\n if (z < x && x >= 0.6 * width) continue\n part.structure = { role: 'column' }\n } else if (y <= x && y <= z) part.structure = { role: 'beam', maxSpan: SHELF_SPAN * Math.max(x, z) }\n }\n}\n/** Each solid top of the drawing becomes its boards (`<id>_b<n>`), along its length, so that it breaks board by board where it is hit. Returns the boards of each top. */\nfunction splitTopsIntoBoards(drawn: Drawn[], materialOf: Record<string, string>, carcassed: boolean): Map<string, Drawn[]> {\n const tops = new Map<string, Drawn[]>()\n if (carcassed) return tops\n for (let i = drawn.length - 1; i >= 0; i--) {\n const p = drawn[i]\n if (p.key !== 'wood' || materialOf.wood !== 'wood_hard' || p.shape.kind !== 'box' || p.rotation) continue\n const [sx, sy, sz] = p.shape.size\n const across = sx < sz ? 0 : 2\n const width = Math.min(sx, sz)\n if (sy < WOOD_THIN || sy > BOARD_TOP_THICK || sy >= width || width < BOARD_TOP_WIDTH) continue\n const count = Math.round(width / BOARD_WIDTH)\n const boards: Drawn[] = []\n for (let b = 0; b < count; b++) {\n const size: [number, number, number] = [sx, sy, sz]\n size[across] = width / count\n const position: [number, number, number] = [...p.position]\n position[across] += (b + 0.5) * size[across] - width / 2\n const min: [number, number, number] = [...p.min]\n const max: [number, number, number] = [...p.max]\n min[across] = position[across] - size[across] / 2\n max[across] = position[across] + size[across] / 2\n boards.push({ ...p, id: `${p.id}_b${b}`, shape: { kind: 'box', size }, position, min, max, color: shadeBoard(p.color, b) })\n }\n drawn.splice(i, 1, ...boards)\n tops.set(p.id, boards)\n }\n return tops\n}\n\n/** Boards of one top are not cut from the same tree: each has its own tone. */\nfunction shadeBoard(color: number, board: number): number {\n const k = [1, 0.94, 1.05, 0.97, 1.03][board % 5]\n const channel = (shift: number): number => Math.min(255, Math.round(((color >> shift) & 255) * k)) << shift\n return channel(16) | channel(8) | channel(0)\n}\n\nconst FLOOR_TOUCH = 0.005\nconst LOOSE = new Set(['paper'])\nconst BASE_MATERIAL: Record<string, string> = {\n wood: 'wood_hard',\n metal: 'steel',\n fabric: 'fabric',\n glass: 'glass',\n plain: 'plastic',\n plant: 'foliage',\n picture: 'paper',\n emissive: 'glass',\n}\n\n// one house renderer per three.js namespace: it makes the type table the builders hang from\nconst renderers = new WeakMap<object, HouseRendererInternal>()\nfunction rendererOf(THREE: Three, document: unknown): HouseRendererInternal {\n let r = renderers.get(THREE)\n if (!r) {\n r = create(THREE, document ? { document: document as never } : {}) as HouseRendererInternal /* `buildApi` hands out the kernel too */\n renderers.set(THREE, r)\n }\n return r\n}\n\ninterface RecordOptions {\n /** Destruction material per builder material key, over the defaults. */\n materials: Record<string, string>\n chairs?: boolean\n /** The piece is a case with shelves (`carcass`). */\n carcass?: boolean\n}\n\n/** Runs `run` with a recording stand-in for the drawing api and turns what it drew into a spec, a drawing and the top. `root` is the frame of the piece (the builder's `M`). */\nfunction recordSpec(THREE: Three, name: string, root: Mount, run: (A: FurnitureApi) => void, opts: RecordOptions): { spec: DestructibleSpec; build: (T3: Three) => THREE_NS.Group; top: FurnitureSpecResult['top'] } {\n const o = { chairs: opts.chairs }\n const materialOf = { ...BASE_MATERIAL, ...opts.materials }\n const drawn: Drawn[] = []\n const counters = new Map<string, number>()\n const q = new THREE.Quaternion()\n const eul = new THREE.Euler()\n const xyz = new THREE.Euler()\n const v = new THREE.Vector3()\n\n const loc = (M: Frame, lx: number, lz: number): [number, number] => {\n const c = Math.cos(M.ry)\n const s = Math.sin(M.ry)\n return [M.x + lx * c + lz * s, M.z - lx * s + lz * c]\n }\n const record = (M: Frame, key: string, shape: PartSpec['shape'], px: number, py: number, pz: number, rx: number, ry: number, rz: number, color: number): void => {\n if ((o.chairs === false && M !== root) || key === 'water') return // water is not a solid\n q.setFromEuler(eul.set(rx, ry, rz, 'YXZ'))\n const turned = rx !== 0 || ry !== 0 || rz !== 0\n const size: [number, number, number] = shape.kind === 'box' ? shape.size : shape.kind === 'cylinder' ? [shape.radius * 2, shape.height, shape.radius * 2] : [shape.radius * 2, shape.radius * 2, shape.radius * 2]\n const min: [number, number, number] = [Infinity, Infinity, Infinity]\n const max: [number, number, number] = [-Infinity, -Infinity, -Infinity]\n for (const sx of [-0.5, 0.5]) for (const sy of [-0.5, 0.5]) for (const sz of [-0.5, 0.5]) {\n v.set(sx * size[0], sy * size[1], sz * size[2]).applyQuaternion(q)\n const c = [v.x + px - root.x, v.y + py, v.z + pz - root.z] as [number, number, number]\n for (let k = 0; k < 3; k++) {\n min[k] = Math.min(min[k], c[k])\n max[k] = Math.max(max[k], c[k])\n }\n }\n const n = counters.get(key) ?? 0\n counters.set(key, n + 1)\n let rotation: [number, number, number] | null = null\n if (turned) {\n xyz.setFromQuaternion(q, 'XYZ')\n rotation = [xyz.x, xyz.y, xyz.z]\n }\n drawn.push({ id: `${key}_${n}`, key, shape, position: [px - root.x, py, pz - root.z], rotation, color, min, max })\n }\n\n const A: FurnitureApi = {\n box(M: Frame, mat: string, x: number, y: number, z: number, bw: number, bh: number, bd: number, color: number, ry = 0, rx = 0, rz = 0): void {\n const [px, pz] = loc(M, x, z)\n record(M, mat, { kind: 'box', size: [bw, bh, bd] }, px, M.base + y + bh / 2, pz, rx, M.ry + ry, rz, color)\n },\n cylinder(M: Frame, mat: string, x: number, y: number, z: number, r: number, ch: number, color: number, rx = 0, rz = 0): void {\n const [px, pz] = loc(M, x, z)\n record(M, mat, { kind: 'cylinder', radius: r, height: ch }, px, M.base + y + (rx || rz ? 0 : ch / 2), pz, rx || 0, M.ry, rz || 0, color)\n },\n leaf(): void {},\n plane(): void {},\n light(): void {},\n }\n run(A)\n if (!drawn.length) throw new Error(`game-floorplan-three: the builder of \"${name}\" drew no box or cylinder`)\n\n const boardsOf = splitTopsIntoBoards(drawn, materialOf, Boolean(opts.carcass))\n const parts: PartSpec[] = drawn.map((p) => {\n const thin = Math.min(...(p.shape.kind === 'box' ? p.shape.size : p.shape.kind === 'cylinder' ? [p.shape.radius * 2, p.shape.height] : [p.shape.radius * 2]))\n let material = materialOf[p.key] ?? 'plastic'\n // a case with shelves is MDF (as bought); elsewhere thin boards are pine and thick ones hardwood\n if (p.key === 'wood' && material === 'wood_hard' && opts.carcass && !opts.materials?.wood) material = 'mdf'\n else if (p.key === 'wood' && material === 'wood_hard' && thin < WOOD_THIN) material = 'wood_soft'\n const part: PartSpec = { id: p.id, material, shape: p.shape, position: p.position }\n if (p.rotation) part.rotation = p.rotation\n if (!LOOSE.has(material) && p.min[1] <= FLOOR_TOUCH) part.anchored = true\n return part\n })\n const byId = new Map(drawn.map((p) => [p.id, p]))\n\n const joints: JointSpec[] = []\n for (const j of inferJoints(parts, 0.01)) {\n const a = parts.find((p) => p.id === j.a)!\n const b = parts.find((p) => p.id === j.b)!\n const la = LOOSE.has(a.material)\n const lb = LOOSE.has(b.material)\n if (la && lb) continue\n if (la || lb) {\n // paper rests on what is under it: its lower face on the other's upper face\n const [loose, other] = la ? [a, b] : [b, a]\n if (Math.abs(byId.get(loose.id)!.min[1] - byId.get(other.id)!.max[1]) > 0.02) continue\n joints.push({ id: j.id, a: j.a, b: j.b, kind: 'resting' })\n continue\n }\n joints.push(j)\n }\n\n // the top: among the boxes that cover most of the footprint, the highest upper face (not fabric: a cloth lies on the top)\n const all = drawn.reduce(\n (m, p) => ({ x0: Math.min(m.x0, p.min[0]), x1: Math.max(m.x1, p.max[0]), z0: Math.min(m.z0, p.min[2]), z1: Math.max(m.z1, p.max[2]) }),\n { x0: Infinity, x1: -Infinity, z0: Infinity, z1: -Infinity },\n )\n const footprint = (all.x1 - all.x0) * (all.z1 - all.z0)\n let top: FurnitureSpecResult['top'] = null\n for (const p of drawn) {\n const part = parts.find((x) => x.id === p.id)!\n if (part.shape.kind === 'sphere' || part.rotation || part.material === 'fabric' || LOOSE.has(part.material)) continue\n const area = (p.max[0] - p.min[0]) * (p.max[2] - p.min[2])\n if (area < 0.6 * footprint || p.max[1] < 0.2) continue\n if (!top || p.max[1] > top.y + 1e-6) top = { part: p.id, y: p.max[1] }\n }\n for (const boards of boardsOf.values()) {\n if (top && boards[0].max[1] <= top.y - 1e-6) continue\n const mid = boards[boards.length >> 1]\n const min = [Math.min(...boards.map((b) => b.min[0])), Math.min(...boards.map((b) => b.min[2]))]\n const max = [Math.max(...boards.map((b) => b.max[0])), Math.max(...boards.map((b) => b.max[2]))]\n if ((max[0] - min[0]) * (max[1] - min[1]) >= 0.6 * footprint && mid.max[1] >= 0.2) top = { part: mid.id, y: mid.max[1], parts: boards.map((b) => b.id) }\n }\n\n if (opts.carcass) carcass(parts, byId)\n const spec: DestructibleSpec = { name, parts, joints, tags: ['furniture'] }\n const colors = new Map(drawn.map((p) => [p.id, p.color]))\n\n const build = (T3: Three): THREE_NS.Group => {\n const group = markKitOrigin(new T3.Group(), { owner: 'game-floorplan-three', kind: 'furniture', id: name })\n group.name = name\n const mats = new Map<string, THREE_NS.MeshStandardMaterial>()\n for (const p of parts) {\n const color = colors.get(p.id) ?? 0x888888\n const metal = p.material === 'steel'\n const glass = p.material === 'glass'\n const key = `${color}:${metal}:${glass}`\n let mat = mats.get(key)\n if (!mat) {\n mat = new T3.MeshStandardMaterial({ color, roughness: metal ? 0.45 : 0.85, metalness: metal ? 0.7 : 0, transparent: glass, opacity: glass ? 0.4 : 1 })\n mats.set(key, mat)\n }\n const s = p.shape\n const geo = s.kind === 'box' ? new T3.BoxGeometry(s.size[0], s.size[1], s.size[2]) : s.kind === 'cylinder' ? new T3.CylinderGeometry(s.radius, s.radius, s.height, 14) : new T3.SphereGeometry(s.radius, 12, 8)\n const mesh = new T3.Mesh(geo, mat)\n mesh.name = p.id\n mesh.userData.destructionPart = p.id\n mesh.userData.destructionMaterial = p.material\n mesh.position.set(p.position[0], p.position[1], p.position[2])\n if (p.rotation) mesh.rotation.set(p.rotation[0], p.rotation[1], p.rotation[2], 'XYZ')\n mesh.castShadow = !glass\n mesh.receiveShadow = true\n group.add(mesh)\n }\n return group\n }\n\n return { spec, build, top }\n}\n\n/**\n * The team's furniture as a destructible spec. It runs the builder of `type` (`FURNITURE.shelf` for `bookcase`, `FURNITURE.table` for `dining_table`,\n * mapped in `furniture/type-table.ts`) unchanged, with a recording stand-in for the drawing api instead of the house's accumulators: every box and\n * cylinder it draws becomes a part, named `<material key>_<n>` in drawing order (`wood_0`, `plain_17`), with the colour the builder gave it.\n * Planes and leaves (flat, no volume) and water are left out.\n *\n * Materials: `wood` is `wood_hard`, and `wood_soft` for thin boards and panels (under 3.5 cm); `metal` is `steel`; `fabric`, `glass` and `plant` keep\n * their name; `plain` is `plastic`, or `paper` for shelves and racks (their books and boxes). Parts that touch the floor are anchored. Joints come from\n * `inferJoints` (screws between wood, welds or bolts between metal...), except that paper rests on what it lies on with a `resting` joint (weak: it falls when\n * the board breaks) and is not joined to its neighbours. Shelves and racks stand as a carcass: the sides carry, each shelf needs both of its ends\n * held, and the back panel carries nothing, so a broken side drops the shelves it held, with their books.\n *\n * @example\n * const { spec, build, top } = furnitureSpec(THREE, 'bookcase') // 1.2 x 0.35 x 2 m, boards and books\n */\nexport function furnitureSpec(THREE: Three, type: string, opts: FurnitureSpecOptions = {}): FurnitureSpecResult {\n const renderer = rendererOf(THREE, opts.document)\n const ent = renderer.types[type]\n if (!ent) throw new Error(`game-floorplan-three: no builder for the furniture type \"${type}\"`)\n const entry = (opts.catalog ?? (residentialItems as unknown as readonly FurnitureCatalogEntry[])).find((i) => i.type === type)\n const w = opts.w ?? entry?.w\n const d = opts.d ?? entry?.d\n const h = opts.h ?? entry?.h\n if (w === undefined || d === undefined || h === undefined) throw new Error(`game-floorplan-three: furniture type \"${type}\" is not in the catalogue, so give w, d and h`)\n const o = opts.options ?? {}\n const seed = Math.round(opts.seed ?? 1)\n const plain = SHELVING.test(type) ? 'paper' : 'plastic'\n const root: Mount = { x: seed, z: 0, ry: 0, w, d, h, y: 0, base: 0, palette: o.palette, seed: `furniture_${type}_${seed}` }\n const { K, shared } = renderer.internals\n const before = K.PARTS.length\n const made = recordSpec(\n THREE,\n type,\n root,\n (A) => {\n const saved = { api0: shared.api0, ctx: shared.ctx }\n shared.api0 = A // the levers and taps that the kit draws as moving parts go through its own api\n shared.ctx = shared.ctx ?? ({} as BuildContext) // outside a house the builders read the style of the plan from here\n try {\n ent.f(root, A)\n } finally {\n shared.api0 = saved.api0\n shared.ctx = saved.ctx\n }\n },\n { materials: { plain, ...o.materials }, chairs: o.chairs, carcass: SHELVING.test(type) },\n )\n const spouts = K.PARTS.slice(before)\n .filter((p) => p.type === 'water_tap')\n .map((p): [number, number, number] => [p.pos[0] - root.x, p.pos[1], p.pos[2] - root.z])\n K.PARTS.length = before\n return { spec: made.spec, build: made.build, top: made.top, size: { w, d, h }, spouts }\n}\n\nexport interface TapSpecOptions {\n /** `counter` (default): the tap of a sink, standing on the counter; `wall`: the tap of a laundry tub or a garden, with its plate on the wall. */\n kind?: 'counter' | 'wall'\n /** How far the counter tap's spout reaches, metres (default 0.2: the kitchen sink's). */\n reach?: number\n /** The `document` the house renderer makes its textures with (default the global one). */\n document?: unknown\n}\n\nexport interface TapSpecResult {\n /** The tap as parts (base, column, spout, lever), origin on the counter under the column (`counter`) or on the wall plate's centre line at the floor (`wall`). */\n spec: DestructibleSpec\n /** Draws the tap: one mesh per part, named by the part id. */\n build(THREE: Three): THREE_NS.Group\n /** Where the water leaves the spout, in the space of the spec. */\n spout: [number, number, number]\n}\n\n/**\n * The team's tap (`counterTap` of the sink, `wallTap` of the laundry tub: `furniture/taps.ts`) drawn by the same code into parts, with the lever at rest. `spout` is where its\n * water thread starts, so a host can put a tap of the fluids world there; the water thread itself is not drawn.\n */\nexport function tapSpec(THREE: Three, opts: TapSpecOptions = {}): TapSpecResult {\n const renderer = rendererOf(THREE, opts.document)\n const { K, shared } = renderer.internals\n const kind = opts.kind ?? 'counter'\n const root: Mount = { x: 1, z: 0, ry: 0, w: 0.3, d: 0.3, h: 0.3, y: 0, base: 0, seed: `tap_${kind}` }\n const before = K.PARTS.length\n const made = recordSpec(THREE, kind === 'counter' ? 'tap' : 'wall_tap', root, (A) => {\n const kit = K.kit2(root, A)\n const saved = shared.api0\n shared.api0 = A // the lever and the water thread are parts that the kit draws through its own api\n try {\n if (kind === 'counter') K.counterTap(kit, 0, 0, 0, opts.reach ?? 0.2, 0.17, {})\n else K.wallTap(kit, 0, 0.3, 0, 1, 0.1, {})\n } finally {\n shared.api0 = saved\n }\n }, { materials: {} })\n const water = K.PARTS.slice(before).find((p) => p.type === 'water_tap')\n if (!water) throw new Error('game-floorplan-three: the tap drew no water thread')\n K.PARTS.length = before\n return { spec: made.spec, build: made.build, spout: [water.pos[0] - root.x, water.pos[1], water.pos[2] - root.z] }\n}\n","import type { WarmUpProbes } from '@adatechnology/game-contracts'\nimport { createDestruction } from '@adatechnology/game-destruction'\nimport type { Hit } from '@adatechnology/game-destruction'\nimport { buildStructure, masonryConstruction } from '@adatechnology/game-floorplan-structure'\nimport type { Construction, SourceWall, Structure } from '@adatechnology/game-floorplan-structure'\n\nimport { create } from './create.js'\nimport type * as THREE from 'three'\nimport type { DestructibleSpec } from '@adatechnology/game-contracts'\nimport type { DestructionWorld } from '@adatechnology/game-destruction'\nimport type { HouseRecord, Three } from './kernel-types.js'\nimport type { House, HouseRendererOptions } from './types.js'\n\n/** A free-standing wall built and drawn as the walls of the houses. */\nexport interface WallPieceOptions {\n /** Length and height in metres. */\n w: number\n h: number\n /** Default 0.15 m, the houses' wall. */\n thickness?: number\n /** Facade finish of the houses: `plaster` (default), `roughcast` or `exposed_block`. */\n finish?: string\n /** Paint colour of the plaster (default the light plaster of the houses' palette). */\n color?: number\n /** Options of the house renderer (`create`) that draws it. */\n house?: Partial<HouseRendererOptions>\n}\n\nexport interface WallPiece {\n /** The plan of the wall: one storey, one exterior wall, no rooms and no roof; its `structure` is the houses' load path. */\n readonly plan: WallPlan\n /** The destructible spec, as a house gives it (`house.structure.spec()`): the wall with its layers, units and breach on the ground, its concrete pillars (`wall_column_*`, at the ends and every 4 m at most) and the bond beam on both. */\n readonly spec: DestructibleSpec\n /** Draws the wall with the house renderer: meshes carry `userData.destructionPart` of their part, in the space of the spec. */\n build(THREE: Three): THREE.Group\n /**\n * Once a drawing from `build` is in a destruction world as `objectId` (with this `spec`), the house renderer follows its events and draws on it what\n * a generic destruction renderer cannot: the bricks that shots and blows knock out (`chip`) and the opening of a breach, as gaps in the wall's\n * courses. `restore` puts the wall back (after `world.reset`), `dispose` stops following. `update` paints the damage of the events since the last call, once\n * per wall (call it every frame; without it the damage is painted 100 ms after the event).\n */\n follow(root: THREE.Object3D, world: DestructionWorld, objectId: string): { restore(): void; dispose(): void; update(): void } | null\n /**\n * The wall drawn with one brick shot out of it, for a host to draw once at load (`WarmUpProbes`): the breach's materials (the shell around the hole and\n * the bricks laid bare, instanced, lit and in the shadows) get their shader programs then, not at the first shot or blast of play. `dispose` frees its\n * geometries and textures and leaves its materials to the host's warmup, which keeps them so the programs stay.\n */\n warmUpProbes(THREE: unknown): WarmUpProbes\n}\n\n/** A rifle round at the middle of the wall: it knocks a brick out, so the breach draws its shell and its bare bricks. */\nconst WARM_UP_SHOT: Hit = { type: 'ballistic', point: [0, 1.2, 0.1], direction: [0, 0, -1], energy: 3500, caliber: 7.62 }\nconst WARM_UP_FRAMES = 5\n\n/** What the probe reads of the drawing (structural: three.js objects fit). */\ntype ProbeTexture = { readonly isTexture?: boolean; dispose(): void }\ntype ProbeMaterial = { readonly uniforms?: Record<string, { readonly value?: unknown }>; readonly map?: ProbeTexture | null }\ntype ProbeNode = { visible: boolean; frustumCulled: boolean; readonly geometry?: { dispose(): void }; readonly material?: ProbeMaterial | ProbeMaterial[] }\ntype ProbeRoot = { traverse(visit: (node: ProbeNode) => void): void }\ntype ProbeHouse = {\n readonly destruction?: {\n follow?(world: unknown, objectId: string, spec: unknown): { update?(): void } | null\n readonly breach?: { flush?(budgetMs: number): number }\n }\n}\n\nconst isTexture = (value: unknown): value is ProbeTexture => typeof value === 'object' && value !== null && (value as ProbeTexture).isTexture === true\n\nconst PLASTER = 0xe8e2d4\nconst WALL_ID = 'wall_0_0'\n\n/** The plan of a free-standing wall, with its construction and structure. */\nexport type WallPlan = HouseRecord & { construction: Construction; structure: Structure }\n\n/**\n * The plan of a free-standing wall along x, centred on the origin: a one-storey plan whose only wall is exterior on both sides, with the masonry construction of\n * the houses (brick, concrete bond beam, strip footing) and the structure `buildStructure` gives the houses, without a roof.\n */\nexport function wallPlan(options: WallPieceOptions): WallPlan {\n const { w, h, thickness = 0.15, finish = 'plaster', color = PLASTER } = options\n const facade = { finish, roof: 'none', floors: 1 }\n const wall: SourceWall & { id: string; sides: string[]; exterior: boolean; type: string; h: number } = { id: WALL_ID, floor: 0, axis: 'u', u0: -w / 2, v0: 0, u1: w / 2, v1: 0, thickness, sides: ['outside', 'outside'], exterior: true, type: 'wall', h }\n const plan = {\n template: 'wall', name: 'wall', style: 'mid', state: 'normal', w, d: thickness,\n floors: [{ index: 0, y0: 0, ceiling: h }], rooms: [] as HouseRecord['rooms'], walls: [wall], doors: [] as HouseRecord['doors'], windows: [] as HouseRecord['windows'], items: [] as HouseRecord['items'], stateItems: [] as HouseRecord['items'], openPairs: [] as unknown[], partyWalls: [] as unknown[], missing: [] as unknown[],\n facade, colors: { facade: color, wall: color }, lot: null, building: null, waterTank: null, outbuildings: [],\n }\n const construction = masonryConstruction({ ...plan, facade: { ...facade, roof: 'colonial' } })\n const structure = buildStructure({ ...plan, construction }, { wallDetail: 'coarse', construction, roof: false })\n return Object.assign(plan, { construction, structure }) as unknown as WallPlan /* the plan of one wall: the fields of a house plan it needs */\n}\n\nfunction draw(THREE: Three, plan: HouseRecord, options: Partial<HouseRendererOptions>): House {\n return create(THREE, { ...options, fleet: null }).build(plan, { quality: 'game', terrain: false, noPerimeter: true, pieces: 'meshes' })\n}\n\n/** The house each drawing of `build` came from (its root is the house's group). */\nconst houses = new WeakMap<object, House>()\n\n/** Labels the meshes of each structural piece with its part id, so a destruction renderer binds them by `userData.destructionPart`. */\nfunction label(house: House): THREE.Group {\n houses.set(house.group, house)\n for (const [id, items] of Object.entries<(THREE.Object3D | { mesh: THREE.Object3D })[]>(house.destruction.ranges())) {\n for (const item of items) {\n const object = 'isObject3D' in item ? item : item.mesh\n object.userData.destructionPart = id\n }\n }\n return house.group\n}\n\n/**\n * A free-standing wall (a target wall, a garden wall) built and drawn exactly as the walls of the houses: the structure of `game-floorplan-structure` (the wall on\n * the strip footing, the bond beam on it, the assembly's layers, units and breach) and the house renderer's plaster, paint, baseboard and sidewalk.\n */\nexport function wallPiece(THREE: Three, options: WallPieceOptions): WallPiece {\n const plan = wallPlan(options)\n const houseOptions = options.house ?? {}\n // no world: the wall is drawn once to describe its structure, as the houses' specimens are. The wall keeps the detail of the houses' walls (its\n // assembly's plaster, bricks and breach), so shots wear the brick they hit and knock it out\n const probe = draw(THREE, plan, { ...houseOptions, destruction: undefined, destructionRenderer: undefined })\n const spec: DestructibleSpec = probe.structure.spec()\n probe.dispose()\n return {\n plan,\n spec,\n build: (T: Three) => label(draw(T, plan, houseOptions)),\n follow: (root: THREE.Object3D, world: DestructionWorld, objectId: string) => houses.get(root)?.destruction?.follow?.(world, objectId, spec) ?? null,\n warmUpProbes: (T: unknown): WarmUpProbes => {\n const house = draw(T as Three, plan, houseOptions)\n const root = label(house) as ProbeRoot\n const world = createDestruction({ seed: 1 })\n const objectId = world.add(spec, { id: 'warm_up_wall' })\n const destruction = (house as unknown as ProbeHouse).destruction\n const follower = destruction?.follow?.(world, objectId, spec) ?? null\n world.hitPart(objectId, WALL_ID, WARM_UP_SHOT)\n for (let frame = 0; frame < WARM_UP_FRAMES; frame++) {\n world.update(1 / 60)\n follower?.update?.()\n }\n // paint all of it now: in a room the breach paints within the frame budget, and the probe is drawn before any frame runs\n for (let guard = 0; guard < WARM_UP_FRAMES && (destruction?.breach?.flush?.(Infinity) ?? 0) > 0; guard++);\n // drawn whatever the camera: the breach hides its bricks from afar (its level of detail), and an object that is not drawn builds no program\n root.traverse((node) => {\n node.visible = true\n node.frustumCulled = false\n })\n return {\n group: root,\n // the materials stay: the warmup keeps them as anchors, and disposing the last material of a program frees the program it was drawn for (so the\n // follower is not disposed either: it would put the wall back and dispose the breach's materials; its world goes with the probe)\n dispose: () => {\n root.traverse((node) => {\n node.geometry?.dispose()\n for (const material of Array.isArray(node.material) ? node.material : node.material ? [node.material] : []) {\n for (const uniform of Object.values(material.uniforms ?? {})) if (isTexture(uniform.value)) uniform.value.dispose()\n material.map?.dispose()\n }\n })\n },\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsGA,IAAM,OAAO;AACb,IAAM,SAAS;AACf,IAAM,WAAW;AACjB,IAAM,QAAQ;AACd,IAAM,QAAQ;AACd,IAAM,OAAO;AACb,IAAM,OAAO;AACb,IAAM,QAAQ,CAAC,GAAW,GAAW,MAAe,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI;AAErE,SAAS,uBAAuB;AACrC,QAAM,IAAkK,EAAE,QAAQ,CAAC,GAAiB,IAAI,KAAK,IAAI,KAAK,IAAI,MAAM,IAAI,MAAM,cAAc,MAAyB,cAAc,GAAG,MAAM,GAAG,QAAQ,EAAE,GAAG,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,OAAO,KAAK,EAAe;AAGpX,WAAS,MAAM,GAAa,GAAe,IAAY,IA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