@adatechnology/game-items-three 0.9.0 → 0.9.1

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.
@@ -21168,6 +21168,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21168
21168
  return j.st.progress;
21169
21169
  }).value;
21170
21170
  },
21171
+ take(objectId, partId) {
21172
+ if (impls.has(objectId)) return null;
21173
+ const o = getObj(objectId);
21174
+ const part = o.byId.get(partId);
21175
+ const hands = part?.spec.hands;
21176
+ if (!part || !hands || isLost(part)) return null;
21177
+ const holding = (o.byPart.get(partId) ?? []).filter((j) => !j.st.open);
21178
+ if (holding.length === 0 || holding.some((j) => !j.spec.tools.includes("hand"))) return null;
21179
+ run(() => {
21180
+ for (const j of holding) {
21181
+ j.st.progress = 1;
21182
+ j.st.open = true;
21183
+ j.st.openedBy = "tool";
21184
+ }
21185
+ loosened(o, holding, "tool");
21186
+ collapseCheck(o);
21187
+ });
21188
+ return hands;
21189
+ },
21171
21190
  workableJoints(objectId, tool2) {
21172
21191
  const im = impls.get(objectId);
21173
21192
  if (im) {
@@ -22059,6 +22078,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22059
22078
  outdoor_bin: TRASH,
22060
22079
  china_cabinet: [entry("china_plates", 3, 6, "utensil", false, 3), entry("wine_glasses", 2, 5, "utensil", false, 2)]
22061
22080
  };
22081
+ var NETWORK_POST = { h: 6, anchor: 5.7, half: 0.07, bracket: 0.06, conduitOff: 0.025 };
22062
22082
  var DEFAULT_LAMP_TYPE = "bulb_e27";
22063
22083
  var OUTBUILDING_ROOM_TYPE = { guest_room: "bedroom", office: "office", storage: "stockroom", gourmet: "living" };
22064
22084
  var CEILING_LIGHT = 0.35;
@@ -22190,8 +22210,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22190
22210
  const twoWay = Math.max(width, depth) < 2 * Math.min(width, depth) && Math.max(width, depth) <= options.twoWayMaxSpan + options.lineTolerance;
22191
22211
  if (Math.min(width, depth) > options.maxSpan + options.lineTolerance && !twoWay) {
22192
22212
  const longer = width >= depth ? "v" : "u";
22193
- const square = Math.abs(width - depth) <= options.lineTolerance;
22194
- const pool = candidates.filter((c) => c.coverage >= PARTIAL_WALL && (square || c.dir === longer));
22213
+ const square2 = Math.abs(width - depth) <= options.lineTolerance;
22214
+ const pool = candidates.filter((c) => c.coverage >= PARTIAL_WALL && (square2 || c.dir === longer));
22195
22215
  if (pool.length) {
22196
22216
  const best2 = pool.reduce((a, b) => b.coverage - 0.25 * b.skew > a.coverage - 0.25 * a.skew ? b : a);
22197
22217
  return { dir: best2.dir, at: round(best2.at) };
@@ -23820,6 +23840,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23820
23840
  });
23821
23841
  }
23822
23842
  var towerLocales = { en: { labels: en_default.labels }, "pt-BR": { labels: pt_BR_default.labels } };
23843
+ var MAST_PIPE_RADIUS = 0.021;
23844
+ var WEATHERHEAD = { bend: 0.08, capRadius: 0.032, capLength: 0.06, segments: 8 };
23845
+ var round32 = (value) => Math.round(value * 1e3) / 1e3;
23846
+ function mastPathOf(mast) {
23847
+ const { bend, segments } = WEATHERHEAD;
23848
+ const arc = Array.from({ length: segments }, (_, index) => {
23849
+ const angle = Math.PI * (index + 1) / segments;
23850
+ return [mast.u, round32(mast.v - bend + bend * Math.cos(angle)), round32(mast.y1 + bend * Math.sin(angle))];
23851
+ });
23852
+ return [[mast.u, mast.v, mast.y0], [mast.u, mast.v, mast.y1], ...arc];
23853
+ }
23823
23854
 
23824
23855
  // ../game-interactables/dist/index.js
23825
23856
  function hashString(text) {
@@ -42770,6 +42801,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
42770
42801
  wall_switch: { body: { material: "plastic", joint: "screw" }, parts: [["rocker", { material: "plastic", joint: "clip", piece: "rocker" }]] },
42771
42802
  service_entrance: { body: { material: "steel", joint: "bolt" }, parts: [["meter_door", door("steel")]] },
42772
42803
  conduit_run: { body: { material: "plastic", joint: "clip" }, parts: [] },
42804
+ service_mast: { body: { material: "steel", joint: "clip" }, parts: [] },
42773
42805
  electrical_panel: {
42774
42806
  body: { material: "steel", joint: "screw" },
42775
42807
  parts: [[/^breaker/, { material: "plastic", joint: "clip", piece: "breaker" }], ["door", door("steel")]]
@@ -42844,6 +42876,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
42844
42876
  "type.wall_socket": "Wall socket",
42845
42877
  "type.wall_switch": "Light switch",
42846
42878
  "type.service_entrance": "Service entrance pole",
42879
+ "type.service_mast": "Service mast (pontalete)",
42847
42880
  "type.conduit_run": "Conduit run",
42848
42881
  "type.tv": "Television",
42849
42882
  "type.microwave": "Microwave",
@@ -43086,6 +43119,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43086
43119
  "type.wall_socket": "Tomada",
43087
43120
  "type.wall_switch": "Interruptor",
43088
43121
  "type.service_entrance": "Poste de entrada de energia",
43122
+ "type.service_mast": "Pontalete de entrada de energia",
43089
43123
  "type.conduit_run": "Eletroduto",
43090
43124
  "type.tv": "Televis\xE3o",
43091
43125
  "type.microwave": "Micro-ondas",
@@ -43586,6 +43620,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43586
43620
  solid: true,
43587
43621
  massKg: 60
43588
43622
  },
43623
+ {
43624
+ id: "service_mast",
43625
+ group: "electrical",
43626
+ w: 0.1,
43627
+ d: 0.25,
43628
+ h: 4.4,
43629
+ y: 0,
43630
+ solid: true,
43631
+ massKg: 14
43632
+ },
43589
43633
  {
43590
43634
  id: "electrical_panel",
43591
43635
  group: "electrical",
@@ -44999,11 +45043,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44999
45043
  house: [r3(K.x(end[0]) - px), end[2], r3(K.z(end[1]) - pz)]
45000
45044
  };
45001
45045
  if (ee.tap || electrical.mode === "tap") item.variant = "gato";
45046
+ else if (ee.street === "network") item.variant = "network";
45002
45047
  const e = entry2("service_entrance", "service_entrance", item, "service_entrance", -1);
45003
45048
  push(e);
45004
45049
  result.serviceEntrance = e.id;
45005
45050
  }
45006
- if (ee && ee.descent && ee.descent.length > 1 && onFloor(-1, true)) conduit("conduit_descent", ee.descent, -1);
45051
+ if (ee && ee.mast && onFloor(-1, true)) {
45052
+ const path = mastPathOf(ee.mast);
45053
+ const x0 = K.x(ee.mast.u);
45054
+ const z0 = K.z(ee.mast.v);
45055
+ const item = { x: x0, z: z0, ry: 0, seed: seedOf2("service_mast"), points: path.map((p) => [r3(K.x(p[0]) - x0), p[2], r3(K.z(p[1]) - z0)]) };
45056
+ const e = entry2("service_mast", "service_mast", item, "service_mast", -1);
45057
+ e.floorY = o.base;
45058
+ push(e);
45059
+ result.serviceMast = e.id;
45060
+ } else if (ee && ee.descent && ee.descent.length > 1 && onFloor(-1, true)) conduit("conduit_descent", ee.descent, -1);
45007
45061
  const q = electrical.panel;
45008
45062
  if (q && onFloor(q.floor, false)) {
45009
45063
  const hdq = 0.06;
@@ -46514,7 +46568,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46514
46568
  }
46515
46569
  var residentialTower = residentialTowerTemplate();
46516
46570
 
46517
- // ../game-floorplan-three/dist/chunk-P3WNQUTC.js
46571
+ // ../game-floorplan-three/dist/chunk-RQNZIQZ5.js
46518
46572
  var __defProp3 = Object.defineProperty;
46519
46573
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
46520
46574
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -49934,7 +49988,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49934
49988
  var FEED_EXIT_Y = -0.15;
49935
49989
  var FEED_BOX_OFFSET = 0.25;
49936
49990
  var BRICK_FACE_INSET = 0.014;
49991
+ var SLAB_MIDDLE = 0.065;
49992
+ var CEILING_SLAB = 0.5;
49993
+ var PASSING_END_CLEAR = { water: 0.335, conduit: 0.485 };
49994
+ var SLAB_LIFT = { water: -0.02, conduit: 0.015 };
49937
49995
  var OPENING_CLEARANCE = 0.12;
49996
+ var DEFAULT_END_CLEAR = 0.1;
49938
49997
  var DEFAULT_THICKNESS = 0.15;
49939
49998
  function atticFloor(plan) {
49940
49999
  const top = plan.floors[plan.floors.length - 1];
@@ -49947,18 +50006,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49947
50006
  return [Math.min(...walls.map((w) => w.u0)), Math.min(...walls.map((w) => w.v0)), Math.max(...walls.map((w) => w.u1)), Math.max(...walls.map((w) => w.v1))];
49948
50007
  }
49949
50008
  var inside2 = (box4, u, v, margin) => u >= box4[0] - margin && u <= box4[2] + margin && v >= box4[1] - margin && v <= box4[3] + margin;
49950
- function clearOfOpenings(plan, wall, along2) {
50009
+ function reaches(plan, opening, floor) {
50010
+ if (opening.floor === floor) return true;
50011
+ if (opening.floor > floor || opening.y1 === void 0) return false;
50012
+ return (plan.floors[opening.floor]?.y0 ?? 0) + opening.y1 > (plan.floors[floor]?.y0 ?? 0);
50013
+ }
50014
+ function clearOfOpenings(plan, wall, along2, endClear = DEFAULT_END_CLEAR) {
49951
50015
  const line = wall.axis === "u" ? wall.v0 : wall.u0;
49952
50016
  const a0 = wall.axis === "u" ? wall.u0 : wall.v0, a1 = wall.axis === "u" ? wall.u1 : wall.v1;
49953
- let at2 = along2;
50017
+ let at2 = endClear > DEFAULT_END_CLEAR ? Math.max(a0 + endClear, Math.min(a1 - endClear, along2)) : along2;
49954
50018
  for (const o of plan.openings) {
49955
- if (o.floor !== wall.floor || o.axis !== wall.axis || Math.abs(o.pos - line) > 0.05) continue;
50019
+ if (o.axis !== wall.axis || Math.abs(o.pos - line) > 0.05 || !reaches(plan, o, wall.floor)) continue;
49956
50020
  const lo = o.at - o.width / 2 - OPENING_CLEARANCE, hi = o.at + o.width / 2 + OPENING_CLEARANCE;
49957
50021
  if (at2 <= lo || at2 >= hi) continue;
49958
50022
  const toLo = at2 - lo, toHi = hi - at2;
49959
50023
  at2 = toLo <= toHi && lo >= a0 + 0.1 || hi > a1 - 0.1 ? lo : hi;
49960
50024
  }
49961
- return Math.max(a0 + 0.1, Math.min(a1 - 0.1, at2));
50025
+ return Math.max(a0 + DEFAULT_END_CLEAR, Math.min(a1 - DEFAULT_END_CLEAR, at2));
49962
50026
  }
49963
50027
  function wallDrop(plan, floor, u, v, options = {}) {
49964
50028
  let best = null;
@@ -49972,7 +50036,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49972
50036
  if (!best) return null;
49973
50037
  const { wall } = best;
49974
50038
  const alongU = wall.axis === "u";
49975
- const along2 = clearOfOpenings(plan, wall, best.along);
50039
+ const along2 = clearOfOpenings(plan, wall, best.along, options.endClear);
49976
50040
  const line = alongU ? wall.v0 : wall.u0;
49977
50041
  const [ru, rv] = options.toward ?? [u, v];
49978
50042
  const across2 = alongU ? rv - line : ru - line;
@@ -50061,6 +50125,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50061
50125
  }
50062
50126
  return true;
50063
50127
  }
50128
+ var DOOR_HEAD = 2.1;
50129
+ function crossesOpening(plan, a, b, y) {
50130
+ return plan.openings.some((o) => {
50131
+ const base = plan.floors[o.floor]?.y0 ?? 0;
50132
+ if (y <= base + (o.y0 ?? 0) || y >= base + (o.y1 ?? DOOR_HEAD)) return false;
50133
+ const [p0, p1, q0, q1] = o.axis === "u" ? [a[1], b[1], a[0], b[0]] : [a[0], b[0], a[1], b[1]];
50134
+ const across2 = Math.min(p0, p1) <= o.pos + 0.1 && Math.max(p0, p1) >= o.pos - 0.1;
50135
+ return across2 && Math.max(Math.min(q0, q1), o.at - o.width / 2) < Math.min(Math.max(q0, q1), o.at + o.width / 2);
50136
+ });
50137
+ }
50138
+ function slabPath(plan, from, to, y, first) {
50139
+ const clear = (path) => !path.slice(1).some((p, i) => crossesOpening(plan, [path[i][0], path[i][2]], [p[0], p[2]], y));
50140
+ for (const order2 of [first, first === "u" ? "v" : "u"]) {
50141
+ const path = atticPath(from, to, y, order2);
50142
+ if (clear(path)) return path;
50143
+ }
50144
+ const [cu, cv] = centreOf(houseFootprint(plan));
50145
+ const alongU = Math.abs(to[0] - from[0]) >= Math.abs(to[1] - from[1]);
50146
+ const step = alongU ? [0, Math.sign(cv - from[1]) * SLAB_DETOUR] : [Math.sign(cu - from[0]) * SLAB_DETOUR, 0];
50147
+ return [[from[0], y, from[1]], [from[0] + step[0], y, from[1] + step[1]], [to[0] + step[0], y, to[1] + step[1]], [to[0], y, to[1]]];
50148
+ }
50149
+ var SLAB_DETOUR = 0.6;
50150
+ function toMiddle(drop) {
50151
+ return drop.wall.axis === "u" ? { ...drop, v: drop.wall.v0 } : { ...drop, u: drop.wall.u0 };
50152
+ }
50064
50153
  function atticPath(from, to, y, first) {
50065
50154
  const corner = first === "u" ? [to[0], from[1]] : [from[0], to[1]];
50066
50155
  const out = [[from[0], y, from[1]]];
@@ -50075,18 +50164,43 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50075
50164
  const storey = plan.floors[floor];
50076
50165
  const y = (storey ? storey.y0 : 0) + target.y;
50077
50166
  const footprint = houseFootprint(plan);
50078
- if (inside2(footprint, target.u, target.v, 0.4)) {
50079
- const drop = wallDrop(plan, floor, target.u, target.v, options);
50080
- if (!drop) return [];
50081
- return [...atticPath(from, [drop.u, drop.v], attic, first), [drop.u, y, drop.v]];
50082
- }
50167
+ if (inside2(footprint, target.u, target.v, 0.4)) return descend(plan, from, target, { ...options, attic, first, y });
50083
50168
  const feed = feedTo(plan, target, y, options);
50084
50169
  if (!feed) return [];
50085
50170
  return [...atticPath(from, [feed.exit.u, feed.exit.v], attic, first), ...feed.route];
50086
50171
  }
50172
+ function descend(plan, from, target, options) {
50173
+ const floor = Math.max(0, target.floor);
50174
+ const top = Math.max(floor, plan.floors.length - 1);
50175
+ const route = [];
50176
+ let at2 = from;
50177
+ let height = options.attic;
50178
+ for (let storey = top; storey >= floor; storey--) {
50179
+ const passing = storey !== floor || options.passing === true;
50180
+ const found = wallDrop(plan, storey, target.u, target.v, passing ? { ...options, surface: false, endClear: PASSING_END_CLEAR[options.kind] } : options);
50181
+ if (!found) return [];
50182
+ const drop = passing && options.kind === "conduit" ? toMiddle(found) : found;
50183
+ const path = slabPath(plan, at2, [drop.u, drop.v], height, options.first);
50184
+ route.push(...route.length ? path.slice(1) : path);
50185
+ at2 = [drop.u, drop.v];
50186
+ if (storey === floor) break;
50187
+ height = (plan.floors[storey]?.y0 ?? 0) - SLAB_MIDDLE + SLAB_LIFT[options.kind];
50188
+ route.push([drop.u, height, drop.v]);
50189
+ }
50190
+ route.push([at2[0], options.y, at2[1]]);
50191
+ return route.filter((p, i) => i === 0 || Math.hypot(p[0] - route[i - 1][0], p[1] - route[i - 1][1], p[2] - route[i - 1][2]) > 1e-4);
50192
+ }
50087
50193
  function routeToCeiling(plan, from, u, v, ceilingY) {
50088
50194
  const attic = atticFloor(plan) + ATTIC_LIFT.conduit;
50089
- if (inside2(houseFootprint(plan), u, v, 0.4)) return [...atticPath(from, [u, v], attic, "v"), [u, ceilingY, v]];
50195
+ if (inside2(houseFootprint(plan), u, v, 0.4)) {
50196
+ const over = plan.floors.findIndex((floor, index) => index > 0 && floor.y0 > ceilingY - CEILING_SLAB);
50197
+ if (over < 0) return [...atticPath(from, [u, v], attic, "v"), [u, ceilingY, v]];
50198
+ const slabY = (plan.floors[over]?.y0 ?? 0) - SLAB_MIDDLE + SLAB_LIFT.conduit;
50199
+ const down2 = descend(plan, from, { u, v, y: 0, floor: over }, { kind: "conduit", attic, first: "v", y: slabY, passing: true });
50200
+ const foot = down2[down2.length - 1];
50201
+ if (!foot) return [];
50202
+ return [...down2, ...slabPath(plan, [foot[0], foot[2]], [u, v], slabY, "v").slice(1), [u, Math.min(ceilingY, slabY), v]];
50203
+ }
50090
50204
  const feed = feedTo(plan, { u, v }, ceilingY + IN_SLAB, {});
50091
50205
  if (!feed) return [];
50092
50206
  const top = feed.route[feed.route.length - 1];
@@ -50104,6 +50218,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50104
50218
  return { walls: plan.walls, openings: [...plan.doors, ...plan.windows], floors: plan.floors };
50105
50219
  }
50106
50220
  var toPlan = (route) => route.map((p) => [p[0], p[2], p[1]]);
50221
+ function homeRun(plan, run) {
50222
+ const { riser, floor, top, home, ceilingY } = run;
50223
+ const start = [riser.u, top, riser.v];
50224
+ const above = plan.floors[floor + 1];
50225
+ if (above && above.y0 > ceilingY - CEILING_SLAB && inside2(houseFootprint(plan), home[0], home[1], 0.4)) {
50226
+ const slabY = above.y0 - SLAB_MIDDLE + SLAB_LIFT.conduit;
50227
+ return [start, [riser.u, slabY, riser.v], ...slabPath(plan, [riser.u, riser.v], home, slabY, "v").slice(1), [home[0], Math.min(ceilingY, slabY), home[1]]];
50228
+ }
50229
+ const attic = atticFloor(plan) + ATTIC_LIFT.conduit;
50230
+ const up = [...descend(plan, [riser.u, riser.v], { u: riser.u, v: riser.v, y: 0, floor }, { kind: "conduit", attic, first: "v", y: top })].reverse();
50231
+ const route = [start, ...up.slice(1), ...routeToCeiling(plan, [riser.u, riser.v], home[0], home[1], ceilingY)];
50232
+ return route.filter((p, i) => i === 0 || Math.hypot(p[0] - route[i - 1][0], p[1] - route[i - 1][1], p[2] - route[i - 1][2]) > 1e-4);
50233
+ }
50107
50234
  function routeConduits(plan, electrical, lamps) {
50108
50235
  const Q = electrical.panel;
50109
50236
  const terminals = /* @__PURE__ */ new Map();
@@ -50122,7 +50249,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50122
50249
  const ceilingY = lamp ? lamp.y : storey ? storey.y0 + storey.ceiling : 2.8;
50123
50250
  homes.set(c.circuit, [home[0], home[1], ceilingY]);
50124
50251
  const top = (Q.y ?? 1.5) + (Q.h ?? 0.4) / 2;
50125
- return { ...c, points: [[riser.u, riser.v, top], ...toPlan(routeToCeiling(plan, [riser.u, riser.v], home[0], home[1], ceilingY))] };
50252
+ return { ...c, points: toPlan(homeRun(plan, { riser, floor, top, home, ceilingY })) };
50126
50253
  }
50127
50254
  const target = terminals.get(c.to);
50128
50255
  const start = homes.get(c.from) ?? (home ? [home[0], home[1], atticFloor(plan)] : void 0);
@@ -50445,6 +50572,67 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50445
50572
  group.userData.rain = { pieces: rainwater.pieces, trenches: [...rainwater.trenches, ...rainwater.boxes.map(pitOf)].map((t) => t.rect), boxes: rainwater.boxes };
50446
50573
  return group;
50447
50574
  }
50575
+ var SUBFLOOR_Y = -0.15;
50576
+ var RISER_CLEAR = 2e-3;
50577
+ var WALL_OUTLET_HEIGHT = { tap: 0.5, tub: 0.45, machine: 0.5 };
50578
+ var FLOOR_OUTLET_DROP = 3e-3;
50579
+ function square(a, b, y) {
50580
+ const corner = [b[0], y, a[1]];
50581
+ const out = [];
50582
+ if (Math.abs(b[0] - a[0]) > 1e-4 && Math.abs(b[1] - a[1]) > 1e-4) out.push(corner);
50583
+ out.push([b[0], y, b[1]]);
50584
+ return out;
50585
+ }
50586
+ var onCentre = (at2) => {
50587
+ if (at2.wall.axis === "u") return [at2.u, at2.wall.v0 + Math.sign(at2.v - at2.wall.v0) * STACK_OFF_CENTRE];
50588
+ return [at2.wall.u0 + Math.sign(at2.u - at2.wall.u0) * STACK_OFF_CENTRE, at2.v];
50589
+ };
50590
+ var STACK_OFF_CENTRE = 0.013;
50591
+ function drainRoute(plan, point) {
50592
+ const floor = point.floor;
50593
+ if (floor < 0) return null;
50594
+ const y0 = plan.floors[floor]?.y0 ?? 0;
50595
+ const outlet = WALL_OUTLET_HEIGHT[point.kind];
50596
+ const points = [];
50597
+ let at2 = [point.u, point.v];
50598
+ let storey = floor;
50599
+ if (outlet !== void 0) {
50600
+ const drop = wallDrop(plan, floor, point.u, point.v);
50601
+ if (!drop) return null;
50602
+ at2 = onCentre(drop);
50603
+ points.push([at2[0], y0 + outlet, at2[1]]);
50604
+ } else {
50605
+ points.push([point.u, y0 - FLOOR_OUTLET_DROP, point.v]);
50606
+ if (floor > 0) {
50607
+ const slabY = y0 - SLAB_MIDDLE;
50608
+ points.push([point.u, slabY, point.v]);
50609
+ const below = wallDrop(plan, floor - 1, point.u, point.v);
50610
+ if (!below) return null;
50611
+ at2 = onCentre(below);
50612
+ points.push(...square([point.u, point.v], at2, slabY));
50613
+ storey = floor - 1;
50614
+ }
50615
+ }
50616
+ for (; storey > 0; storey--) {
50617
+ const slabY = (plan.floors[storey]?.y0 ?? 0) - SLAB_MIDDLE;
50618
+ points.push([at2[0], slabY, at2[1]]);
50619
+ const below = wallDrop(plan, storey - 1, at2[0], at2[1]);
50620
+ if (!below) continue;
50621
+ const from = at2;
50622
+ at2 = onCentre(below);
50623
+ points.push(...square(from, at2, slabY));
50624
+ }
50625
+ if (Math.hypot(at2[0] - point.u, at2[1] - point.v) < 1e-3) return null;
50626
+ {
50627
+ points.push([at2[0], SUBFLOOR_Y, at2[1]]);
50628
+ const legs = square(at2, [point.u, point.v], SUBFLOOR_Y);
50629
+ const last = legs.length > 1 ? legs[legs.length - 2] : [at2[0], SUBFLOOR_Y, at2[1]];
50630
+ const run = Math.hypot(point.u - last[0], point.v - last[2]), stop = run > 0 ? Math.max(0, run - ((DRAIN_BORE[point.kind] ?? 0.05) / 2 + RISER_CLEAR)) / run : 0;
50631
+ legs[legs.length - 1] = [last[0] + (point.u - last[0]) * stop, SUBFLOOR_Y, last[2] + (point.v - last[2]) * stop];
50632
+ points.push(...legs);
50633
+ }
50634
+ return points.filter((p, i) => i === 0 || Math.hypot(p[0] - points[i - 1][0], p[1] - points[i - 1][1], p[2] - points[i - 1][2]) > 1e-4);
50635
+ }
50448
50636
  var DEFAULT_SEGMENT_LIMITS = { wiring: 3, pipe: 2.5 };
50449
50637
  var CUT_ROLES = /* @__PURE__ */ new Set(["slab", "wall", "partition"]);
50450
50638
  var EPSILON2 = 1e-6;
@@ -50732,6 +50920,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50732
50920
  }
50733
50921
  function underSink(tr) {
50734
50922
  const H = shared2.ctx.r.utilities?.plumbing, nA = shared2.ctx.r.floors.length, pt = H && H.points.find((p) => p.id === tr.to), pts = tr.points.map((p) => [p[0], p[2], p[1]]), d = tr.diameter || 0.025;
50923
+ const stage = cursor.stage;
50924
+ if (shared2.ctx.constructionStages) cursor.stage = "furniture";
50735
50925
  cursor.group = pt && pt.floor >= 0 ? "f" + Math.min(pt.floor, nA - 1) : "lot";
50736
50926
  cursor.pc = pieceRecord("pipe:" + tr.id, "plastic", null, { tags: ["pipe"] });
50737
50927
  for (let i = 0; i + 1 < pts.length; i++) pipe(pts[i], pts[i + 1], d, PIPE_COLOR);
@@ -50739,39 +50929,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50739
50929
  cylBase("metal", p[0], p[1] - d * 0.9, p[2], d * 0.75, d * 1.8, 13158596);
50740
50930
  }
50741
50931
  cursor.pc = null;
50932
+ cursor.stage = stage;
50742
50933
  }
50743
50934
  const defined = { createWater, PIPE_COLOR, pipe, _v3, waterPipes };
50744
50935
  Object.assign(K, defined);
50745
50936
  }
50746
50937
  var SEWER_COLOR = 15262940;
50747
- var MOUTH_HEIGHT = { flush: 0.18, shower: 0.03, tap: 0.5, tub: 0.45, machine: 0.5 };
50748
- var SLAB_MIDDLE = 0.065;
50749
50938
  var CLAMP_REACH = 0.3;
50750
50939
  var CLAMP_DROP = 0.06;
50751
50940
  var CLAMP_HEIGHT = 0.03;
50752
50941
  var CLAMPED_ROLES = /* @__PURE__ */ new Set(["wall", "partition", "column"]);
50753
- function drainRoute(plan, point) {
50754
- const floor = point.floor;
50755
- if (floor < 0) return null;
50756
- const drop = wallDrop(plan, floor, point.u, point.v);
50757
- if (!drop) return null;
50758
- const onCentre = (at22) => at22.wall.axis === "u" ? [at22.u, at22.wall.v0] : [at22.wall.u0, at22.v];
50759
- const mouth = (plan.floors[floor]?.y0 ?? 0) + (MOUTH_HEIGHT[point.kind] ?? 0.3);
50760
- let at2 = onCentre(drop);
50761
- const points = [[point.u, mouth, point.v], [at2[0], mouth, at2[1]]];
50762
- for (let storey = floor; storey > 0; storey--) {
50763
- const slabY = (plan.floors[storey]?.y0 ?? 0) - SLAB_MIDDLE;
50764
- points.push([at2[0], slabY, at2[1]]);
50765
- const below = wallDrop(plan, storey - 1, at2[0], at2[1]);
50766
- if (!below) continue;
50767
- at2 = onCentre(below);
50768
- points.push([at2[0], slabY, at2[1]]);
50769
- }
50770
- points.push([at2[0], plan.floors[0]?.y0 ?? 0, at2[1]]);
50771
- return points;
50772
- }
50773
50942
  function installUtilitiesDrains(K, shared2) {
50774
- const { part, pipe, cylBase } = K;
50943
+ const { part, pipe, cylBase, cursor } = K;
50775
50944
  const sh = (...a) => K.sh(...a);
50776
50945
  function layRun(run) {
50777
50946
  const spans = cutRun(run.points, run.limit, solidsOf(shared2.ctx.structureIndex));
@@ -50812,6 +50981,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50812
50981
  }
50813
50982
  function downpipes() {
50814
50983
  const runs = shared2.ctx.gutterInfo?.runs ?? [];
50984
+ const stage = cursor.stage;
50985
+ if (shared2.ctx.constructionStages) cursor.stage = "roof";
50815
50986
  runs.forEach((run, index) => {
50816
50987
  const top = run.points[0];
50817
50988
  const points = run.points.map((p) => [p[0], p[1], p[2]]);
@@ -50819,6 +50990,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50819
50990
  const limit = Number.isFinite(shared2.ctx.segmentLimits.pipe) ? Math.min(shared2.ctx.segmentLimits.pipe, run.clampEvery) : Infinity;
50820
50991
  layRun({ id: `downpipe_${index}`, points, diameter: run.radius * 2, color: run.color, group: `f${run.f}`, limit, ...clampedTo ? { clampedTo } : {}, clampEvery: run.clampEvery });
50821
50992
  });
50993
+ cursor.stage = stage;
50822
50994
  }
50823
50995
  function drainPipes() {
50824
50996
  if (shared2.ctx.visorScene) return;
@@ -51051,11 +51223,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51051
51223
  for (const x of [u0 + inset, u1 - inset]) for (const z of [v0 + inset, v1 - inset]) addStageBox(THREE, parent, x - r, yBase, z - r, x + r, yBase + height, z + r, rebarMat);
51052
51224
  for (let y = yBase + 0.08; y < yBase + height - 0.03; y += 0.14) addStageBox(THREE, parent, u0 + inset, y, v0 + inset, u1 - inset, y + 6e-3, v1 - inset, rebarMat);
51053
51225
  }
51226
+ var DIRT_BED_INSET = 0.03;
51054
51227
  function createStageMaterials(THREE) {
51055
51228
  return {
51056
51229
  dirt: new THREE.MeshStandardMaterial({ color: 9073232, roughness: 0.96 }),
51057
51230
  footing: new THREE.MeshStandardMaterial({ color: 8025710, roughness: 0.92 }),
51058
- baldrame: new THREE.MeshStandardMaterial({ color: 6051922, roughness: 0.88 }),
51231
+ // the ground beams are waterproofed (black bitumen on their top and sides) before the masonry goes up on them
51232
+ baldrame: new THREE.MeshStandardMaterial({ color: 2894375, roughness: 0.7 }),
51059
51233
  slab0: new THREE.MeshStandardMaterial({ color: 10920600, roughness: 0.86 }),
51060
51234
  // pillars, beams and slabs are cast in one concrete: where they meet, they are one surface
51061
51235
  concrete: new THREE.MeshStandardMaterial({ color: 10262672, roughness: 0.82 }),
@@ -51293,11 +51467,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51293
51467
  parts2.push(...ob.parts);
51294
51468
  openings.push(...ob.openings);
51295
51469
  }
51296
- const footprint = rawStructure.parts.filter((p) => p.floor === 0 || p.y0 <= 0.1);
51470
+ const footprint = rawStructure.parts.filter((p) => p.y0 <= 0.1);
51297
51471
  if (footprint.length) {
51298
- addStageBox(THREE, foundation, Math.min(...footprint.map((p) => p.aabb[0])) - 0.05, -0.06, Math.min(...footprint.map((p) => p.aabb[1])) - 0.05, Math.max(...footprint.map((p) => p.aabb[2])) + 0.05, 6e-3, Math.max(...footprint.map((p) => p.aabb[3])) + 0.05, mats.dirt, "foundation_dirt_bed");
51472
+ addStageBox(THREE, foundation, Math.min(...footprint.map((p) => p.aabb[0])) + DIRT_BED_INSET, -0.06, Math.min(...footprint.map((p) => p.aabb[1])) + DIRT_BED_INSET, Math.max(...footprint.map((p) => p.aabb[2])) - DIRT_BED_INSET, 6e-3, Math.max(...footprint.map((p) => p.aabb[3])) - DIRT_BED_INSET, mats.dirt, "foundation_dirt_bed");
51299
51473
  }
51300
- for (const e of outbuildings ?? []) addStageBox(THREE, foundation, e.aabb[0] - 0.15, -0.06, e.aabb[1] - 0.15, e.aabb[2] + 0.15, 6e-3, e.aabb[3] + 0.15, mats.dirt, `${e.id}_dirt_bed`);
51474
+ for (const e of outbuildings ?? []) addStageBox(THREE, foundation, e.aabb[0] + DIRT_BED_INSET, -0.06, e.aabb[1] + DIRT_BED_INSET, e.aabb[2] - DIRT_BED_INSET, 6e-3, e.aabb[3] - DIRT_BED_INSET, mats.dirt, `${e.id}_dirt_bed`);
51301
51475
  const seen = /* @__PURE__ */ new Set();
51302
51476
  const foundations = parts2.filter(isFoundation).filter((p) => !seen.has(p.id) && !!seen.add(p.id)).map(foundationSolid);
51303
51477
  for (const s of foundations) addStageBox(THREE, foundation, s.aabb[0], s.y0, s.aabb[1], s.aabb[2], s.y1, s.aabb[3], mats[s.kind], s.id);
@@ -51520,8 +51694,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51520
51694
  wireL(span.a, span.b, radius);
51521
51695
  });
51522
51696
  };
51523
- const wiringSpans = (P, drop) => {
51524
- const poleId = (u) => "pole:" + u.toFixed(1), nearestPole = (x) => poleId([P.u - 22, P.u, P.u + 22].reduce((best, u) => Math.abs(u - x) < Math.abs(best - x) ? u : best));
51697
+ const wiringSpans = (P, drop, ownPole) => {
51698
+ const poleId = (u) => "pole:" + u.toFixed(1), piecePoles = ownPole ? [P.u - 22, P.u, P.u + 22] : [P.u - 22, P.u + 22], nearestPole = (x) => poleId(piecePoles.reduce((best, u) => Math.abs(u - x) < Math.abs(best - x) ? u : best));
51525
51699
  if (!Number.isFinite(shared2.ctx.segmentLimits.wiring)) {
51526
51700
  cursor.pc = pieceRecord("wiring:grid", "copper", null, { tags: ["wiring"] });
51527
51701
  for (const dx of [-0.65, -0.2, 0.25, 0.7]) for (const k of [-1, 1]) wireL([P.u + dx, P.h - 0.5, P.v], [P.u + k * 22 + dx, P.h - 0.5, P.v], 7e-3);
@@ -51565,25 +51739,44 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51565
51739
  for (let i = 0; i < n; i++) wireSpans(at2(i / n), at2((i + 1) / n), 9e-3, "wiring:service:" + i, "ground");
51566
51740
  cursor.pc = null;
51567
51741
  };
51742
+ const servicePost = (u, v, h) => {
51743
+ const half = NETWORK_POST.half, buried = postEmbedment(h), below = shared2.ctx.visorScene ? 0 : buried, face = v - half;
51744
+ cursor.group = lotGroup;
51745
+ cursor.pc = pieceRecord("pole:" + u.toFixed(1), "concrete", null, { tags: ["pole"], holder: "ground", holdJoint: footingJointOf("concrete"), embedment: { depth: buried, width: half * 2 } });
51746
+ bx("plain", u - half, -below, v - half, u + half, h, v + half, concreteColor);
51747
+ bx("metal", u - 0.02, NETWORK_POST.anchor - 0.06, face - NETWORK_POST.bracket, u + 0.02, NETWORK_POST.anchor + 0.04, face - 2e-3, iron);
51748
+ cursor.pc = null;
51749
+ };
51750
+ const serviceMast = (mast) => {
51751
+ const path = mastPathOf(mast).map((p) => [p[0], p[2], p[1]]), end = path[path.length - 1], galvanised = 11120307;
51752
+ cursor.group = lotGroup;
51753
+ cursor.pc = pieceRecord("mast:" + mast.u.toFixed(1), "steel", null, { tags: ["mast"], holdOn: "wall", holdJoint: "clip" });
51754
+ for (let i = 0; i + 1 < path.length; i++) pipe2(path[i], path[i + 1], MAST_PIPE_RADIUS * 2, galvanised);
51755
+ cylBase("metal", end[0], end[1] - WEATHERHEAD.capLength, end[2], WEATHERHEAD.capRadius, WEATHERHEAD.capLength, galvanised);
51756
+ cursor.pc = null;
51757
+ };
51568
51758
  if (en22) {
51569
51759
  const P = en22.pole, from = shared2.ctx.serviceFrom, kitDraws = !!(KV && KV.serviceEntrance);
51570
51760
  if (P) {
51571
- if (!kitDraws) pole(P.u, P.v, P.h);
51761
+ if (!kitDraws && en22.street === "network") servicePost(P.u, P.v, P.h);
51762
+ else if (!kitDraws) pole(P.u, P.v, P.h);
51572
51763
  info.pole = { pos: [P.u, 0, P.v], h: P.h };
51573
51764
  }
51574
- const landing = en22.drop[0];
51575
- if (from && landing) {
51576
- streetDrop(from, [landing[0], landing[2], landing[1]]);
51765
+ const landing = en22.drop[0], network = en22.street === "network";
51766
+ if ((from || network) && landing) {
51767
+ if (from && !network) streetDrop(from, [landing[0], landing[2], landing[1]]);
51577
51768
  const end = en22.drop[en22.drop.length - 1];
51578
51769
  if (P && end && en22.drop.length > 1 && !kitDraws) {
51579
51770
  wireSpans([landing[0], landing[2], landing[1]], [end[0], end[2], end[1]], 9e-3, "wiring:drop:0", "pole:" + P.u.toFixed(1));
51580
51771
  cursor.pc = null;
51581
51772
  }
51582
- } else if (P) {
51773
+ } else if (P && !network) {
51583
51774
  for (const k of [-1, 1]) pole(P.u + k * 22, P.v, P.h);
51584
- wiringSpans(P, en22.drop && en22.drop.length > 1 && !kitDraws ? en22.drop : null);
51775
+ wiringSpans(P, en22.drop && en22.drop.length > 1 && !kitDraws ? en22.drop : null, !kitDraws);
51585
51776
  }
51586
- if (en22.descent && en22.descent.length > 1 && !(KV && (KV.serviceEntrance || !P))) {
51777
+ if (en22.mast) {
51778
+ if (!(KV && KV.serviceMast)) serviceMast(en22.mast);
51779
+ } else if (en22.descent && en22.descent.length > 1 && !(KV && (KV.serviceEntrance || !P))) {
51587
51780
  const d0 = en22.descent[0], d1 = en22.descent[en22.descent.length - 1];
51588
51781
  cylBase("metal", d0[0], d1[2], d0[1], 0.02, d0[2] - d1[2] - (shared2.ctx.visorScene ? 0 : 0.01), 9080466);
51589
51782
  const hw = shared2.ctx.visorScene ? 0.05 : 0.047;
@@ -51763,6 +51956,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51763
51956
  return { w, au, L: au ? w.v0 : w.u0, a: Math.min(au ? w.u0 : w.v0, au ? w.u1 : w.v1), b: Math.max(au ? w.u0 : w.v0, au ? w.u1 : w.v1), th: w.thickness || 0.15 };
51764
51957
  });
51765
51958
  cursor.group = "f0";
51959
+ const stage = cursor.stage;
51960
+ if (shared2.ctx.constructionStages) cursor.stage = "exterior";
51766
51961
  const junction = (A, e, sd) => {
51767
51962
  let r = 0;
51768
51963
  for (const B of ws) {
@@ -51814,6 +52009,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51814
52009
  strip(W, y0, y0 + SIDEWALK_TOP, 0, W, "sidewalk", cal, A.w.id ? `sidewalk:${A.w.id}:${sd < 0 ? 0 : 1}` : void 0, SIDEWALK_SLABS);
51815
52010
  }
51816
52011
  if (!shared2.ctx.baseboardBand) doorways(ws, W, y0, cal);
52012
+ cursor.stage = stage;
51817
52013
  }
51818
52014
  function clearSpan({ a, b, au, across: across2, rise }) {
51819
52015
  let from = a, to = b;
@@ -51842,11 +52038,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
51842
52038
  const slab = au ? [a, y0, lo, b, y0 + SIDEWALK_TOP, hi] : [lo, y0, a, hi, y0 + SIDEWALK_TOP, b];
51843
52039
  bx("sidewalk", slab[0], slab[1], slab[2], slab[3], slab[4], slab[5], cal);
51844
52040
  if (!shared2.ctx.visorScene) shared2.ctx.paving?.push(slab);
52041
+ const paving = cursor.stage;
52042
+ if (shared2.ctx.constructionStages) cursor.stage = "finishes";
51845
52043
  const top = y0 + (shared2.ctx.constructionStages ? FLOOR_OVER_GROUND : 0) + 2e-3, t0 = d.pos - th / 2, t1 = d.pos + th / 2;
51846
52044
  const [from, to] = clearSpan({ a: a + DOOR_JAMB_WIDTH, b: b - DOOR_JAMB_WIDTH, au, across: [t0, t1], rise: [y0, top] });
51847
52045
  cursor.pc = pieceRecord(`threshold:${d.id}`, THRESHOLD.material, null, { floor: 0, mass: Math.round((to - from) * th * (top - y0) * THRESHOLD.density * 100) / 100, tags: ["threshold"], holdOn: "floor", holdJoint: footingJointOf(THRESHOLD.material) });
51848
52046
  if (au) bx("plain", from, y0, t0, to, top, t1, THRESHOLD.color);
51849
52047
  else bx("plain", t0, y0, from, t1, top, to, THRESHOLD.color);
52048
+ cursor.stage = paving;
51850
52049
  }
51851
52050
  cursor.pc = null;
51852
52051
  }
@@ -52708,6 +52907,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52708
52907
  mine("gas_cylinder", FURNITURE.gas_cylinder);
52709
52908
  mine("cooking_gas_cylinder", FURNITURE.cooking_gas_cylinder);
52710
52909
  mine("gas_shelter", FURNITURE.gas_shelter);
52910
+ mine("gas_hose", FURNITURE.gas_hose);
52711
52911
  mine("outdoor_bin", FURNITURE.outdoor_bin);
52712
52912
  mine("outdoor_pot", FURNITURE.outdoor_pot);
52713
52913
  mine("planter_bed", FURNITURE.planter_bed);
@@ -53239,13 +53439,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53239
53439
  const copper = 12088115;
53240
53440
  for (let k = 0; k + 1 < shelter.route.length; k++) K2.t("metal", local(shelter.route[k]), local(shelter.route[k + 1]), 75e-4, copper);
53241
53441
  if (shelter.hose.length > 1) {
53242
- const valve = local(shelter.hose[0]), stove = local(shelter.hose[shelter.hose.length - 1]);
53442
+ const valve = local(shelter.hose[0]);
53243
53443
  K2.b("metal", valve[0], valve[1] - 0.02, valve[2], 0.04, 0.04, 0.04, 13214282);
53244
- const sag = [(valve[0] + stove[0]) / 2, Math.max(0.1, Math.min(valve[1], stove[1]) - 0.15), (valve[2] + stove[2]) / 2];
53245
- K2.t("plain", [valve[0], valve[1] - 0.02, valve[2]], sag, 0.011, 12071454);
53246
- K2.t("plain", sag, stove, 0.011, 12071454);
53247
53444
  }
53248
53445
  }
53446
+ const GAS_HOSE_COLOR = 14267452;
53447
+ FURNITURE.gas_hose = function(M, A) {
53448
+ const shelter = shelterOf(M);
53449
+ if (!shelter || shelter.hose.length < 2) return;
53450
+ const K2 = kit2(M, A);
53451
+ const local = (p) => [p[0] - M.x, p[2] - (typeof M.y === "number" ? M.y : 0), p[1] - M.z];
53452
+ const valve = local(shelter.hose[0]), stove = local(shelter.hose[shelter.hose.length - 1]);
53453
+ const sag = [(valve[0] + stove[0]) / 2, Math.max(0.1, Math.min(valve[1], stove[1]) - 0.15), (valve[2] + stove[2]) / 2];
53454
+ K2.t("plain", [valve[0], valve[1] - 0.02, valve[2]], sag, 0.011, GAS_HOSE_COLOR);
53455
+ K2.t("plain", sag, stove, 0.011, GAS_HOSE_COLOR);
53456
+ };
53249
53457
  FURNITURE.mailbox = function(M, A) {
53250
53458
  const K2 = kit2(M, A, 0), w = M.w || 0.3, d = M.d || 0.22, h = M.h || 0.3, y = M.y != null && M.y > 0 ? M.y : 1, structure = STYLE(), pc = structure === "high" ? 2763824 : structure === "mid" ? 13676640 : 13126202, rnd = rngString(SEED() + "|" + seedKey(M.seed) + "|correio");
53251
53459
  if (M.pole !== false && !(M.y != null && M.y > 0)) {
@@ -53386,6 +53594,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53386
53594
  cursor.stage = st;
53387
53595
  }
53388
53596
  }
53597
+ if (m.type === "cooking_gas_cylinder" && m.shelter && T2.gas_hose) {
53598
+ const st = cursor.stage;
53599
+ if (shared2.ctx.constructionStages) cursor.stage = "furniture";
53600
+ try {
53601
+ buildItem2(m, M, T2.gas_hose, api, cursor.group);
53602
+ } finally {
53603
+ cursor.stage = st;
53604
+ }
53605
+ }
53389
53606
  if (shared2.ctx.iv && shared2.ctx.iv.replace.has(m.id)) {
53390
53607
  registerCollision(m, M);
53391
53608
  continue;
@@ -55586,6 +55803,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55586
55803
  supports.push({ part: p.id, on: p.holder, joint: p.holdJoint ?? "clip", bears: false, extra: true, ...p.tears ? { tears: true } : {} });
55587
55804
  continue;
55588
55805
  }
55806
+ if (typeof p.holder === "string") {
55807
+ unheld.push(p.id);
55808
+ continue;
55809
+ }
55589
55810
  if (p.holdOn) {
55590
55811
  const on = p.holdOn === "floor" ? floorUnder(p) : wallBeside(p, p.holdReach ?? HOLD_REACH);
55591
55812
  if (on) supports.push({ part: p.id, on: on.id, joint: p.holdJoint ?? "clip", bears: false, extra: true });
@@ -56040,9 +56261,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56040
56261
  if (q.id === part.id || q.role !== "wall" && q.role !== "partition" || !structure.meshesOf(q.id).some((it) => it.mesh)) continue;
56041
56262
  if (Math.min(q.y1, part.y1) - Math.max(q.y0, part.y0) <= 0.5) continue;
56042
56263
  const inside22 = cu >= q.aabb[0] - 1e-3 && cu <= q.aabb[2] + 1e-3 && cv >= q.aabb[1] - 1e-3 && cv <= q.aabb[3] + 1e-3;
56043
- const reaches = Math.min(q.aabb[2], part.aabb[2]) - Math.max(q.aabb[0], part.aabb[0]) > PILLAR_REACH2 && Math.min(q.aabb[3], part.aabb[3]) - Math.max(q.aabb[1], part.aabb[1]) > PILLAR_REACH2;
56264
+ const reaches2 = Math.min(q.aabb[2], part.aabb[2]) - Math.max(q.aabb[0], part.aabb[0]) > PILLAR_REACH2 && Math.min(q.aabb[3], part.aabb[3]) - Math.max(q.aabb[1], part.aabb[1]) > PILLAR_REACH2;
56044
56265
  if (inside22) first.push(q.id);
56045
- else if (reaches) other.push(q.id);
56266
+ else if (reaches2) other.push(q.id);
56046
56267
  }
56047
56268
  return [...first, ...other];
56048
56269
  }
@@ -57353,20 +57574,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57353
57574
  if (!Number.isFinite(level)) return CONSTRUCTION_LEVEL_MAX;
57354
57575
  return Math.max(0, Math.min(CONSTRUCTION_LEVEL_MAX, Math.round(level)));
57355
57576
  }
57577
+ var STAGE_LEVEL = { foundation: 1, frame: 2, masonry: 3, installations: 4, roofFraming: 5, roof: 6, finishes: 7, openings: 8, last: 8 };
57356
57578
  function stageVisible(stage, level, opts) {
57357
57579
  switch (stage) {
57358
57580
  case "installations":
57359
- return level >= 4;
57581
+ return level >= STAGE_LEVEL.installations;
57360
57582
  case "finishes":
57361
- return level >= 5;
57583
+ return level >= STAGE_LEVEL.finishes;
57362
57584
  case "openings":
57363
- return level >= 6;
57585
+ return level >= STAGE_LEVEL.openings;
57364
57586
  case "roof":
57365
- return level >= 8 && opts.roofLayer !== false;
57587
+ return level >= STAGE_LEVEL.roof && opts.roofLayer !== false;
57366
57588
  case "furniture":
57367
- return level >= 8;
57589
+ return level >= STAGE_LEVEL.last;
57590
+ // the protective sidewalk round the house: the last of the work outside
57591
+ case "exterior":
57592
+ return level >= STAGE_LEVEL.last;
57368
57593
  case "perimeter":
57369
- return level >= 8 && opts.lotLayer !== false;
57594
+ return level >= STAGE_LEVEL.last && opts.lotLayer !== false;
57370
57595
  default:
57371
57596
  return true;
57372
57597
  }
@@ -57374,17 +57599,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57374
57599
  var EMBEDDED = /* @__PURE__ */ new Set(["wall_pipe", "wall_conduit", "electrical_box"]);
57375
57600
  function groupVisible(name, level, opts) {
57376
57601
  const roofOn = opts.roofLayer !== false;
57602
+ const bare = level < STAGE_LEVEL.finishes;
57377
57603
  if (name === "stage:0:blueprint") return level <= 1;
57378
- if (name === "stage:1:foundation") return level >= 1 && level <= 4;
57379
- if (name === "stage:1:starter_bars") return level === 1;
57380
- if (name === "stage:2:frame") return level >= 2 && level <= 4;
57381
- if (name === "stage:3:masonry") return level >= 3 && level <= 4;
57382
- if (name === "stage:4:installations") return level === 4 || level >= 4 && opts.waterLayer === true;
57383
- if (name === "stage:4:sewer_boxes") return level >= 4;
57384
- if (name === "stage:7:roof_framing") return level >= 7 && roofOn;
57385
- if (name === "roof") return level >= 8 && roofOn;
57386
- if (name === "attic_tank") return level >= 4;
57387
- if (/^t\d+$/.test(name)) return level >= 5;
57604
+ if (name === "stage:1:foundation") return level >= STAGE_LEVEL.foundation && bare;
57605
+ if (name === "stage:1:starter_bars") return level === STAGE_LEVEL.foundation;
57606
+ if (name === "stage:2:frame") return level >= STAGE_LEVEL.frame && bare;
57607
+ if (name === "stage:3:masonry") return level >= STAGE_LEVEL.masonry && bare;
57608
+ if (name === "stage:4:installations") return level === STAGE_LEVEL.installations || level >= STAGE_LEVEL.installations && opts.waterLayer === true;
57609
+ if (name === "stage:4:sewer_boxes") return level >= STAGE_LEVEL.installations;
57610
+ if (name === "stage:7:roof_framing") return level >= STAGE_LEVEL.roofFraming && roofOn;
57611
+ if (name === "roof") return level >= STAGE_LEVEL.roof && roofOn;
57612
+ if (name === "attic_tank") return level >= STAGE_LEVEL.installations;
57613
+ if (/^t\d+$/.test(name)) return level >= STAGE_LEVEL.finishes;
57388
57614
  return null;
57389
57615
  }
57390
57616
  function applyConstructionLevel(houseGroup, rawLevel, opts = {}) {
@@ -57398,7 +57624,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57398
57624
  const lines = name === "stage:0:blueprint" ? child.getObjectByName(BLUEPRINT_LINES) : void 0;
57399
57625
  if (lines) lines.visible = level === 0;
57400
57626
  const heap = name === "stage:4:installations" ? child.getObjectByName(SPOIL_HEAP) : void 0;
57401
- if (heap) heap.visible = level === 4;
57627
+ if (heap) heap.visible = level === STAGE_LEVEL.installations;
57628
+ if (name === "roof") {
57629
+ for (const mesh2 of child.children) if (/\/plaster$/.test(mesh2.name)) mesh2.visible = level >= STAGE_LEVEL.finishes;
57630
+ }
57402
57631
  continue;
57403
57632
  }
57404
57633
  if (name === "lot") child.visible = level >= 4 && lotOn;
@@ -57408,7 +57637,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57408
57637
  const ud = obj.userData;
57409
57638
  if (!ud) return;
57410
57639
  if (ud.part === "lamp_holder" || ud.part === "lamp_bulb") {
57411
- obj.visible = typeof ud.id !== "string" || (ud.mount === "slab" ? level === 4 : level >= 5 && level <= 7);
57640
+ obj.visible = typeof ud.id !== "string" || (ud.mount === "slab" ? level >= STAGE_LEVEL.installations && level < STAGE_LEVEL.finishes : level >= STAGE_LEVEL.finishes && level < STAGE_LEVEL.last);
57412
57641
  return;
57413
57642
  }
57414
57643
  if (typeof ud.part === "string" && EMBEDDED.has(ud.part)) {
@@ -57544,6 +57773,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57544
57773
  }
57545
57774
  return t;
57546
57775
  }
57776
+ function battenClearOfSolids(slope, s, [a, b], solids) {
57777
+ const { batten } = TIMBER;
57778
+ const p0 = down(slope.point(s, a), batten.top), p1 = down(slope.point(s, b), batten.top);
57779
+ const axis = Math.abs(p1[0] - p0[0]) < 1e-6 ? 0 : 2;
57780
+ const other = axis === 0 ? 2 : 0;
57781
+ const rise = Math.abs(slope.point(1, a)[axis] - slope.point(0, a)[axis]);
57782
+ if (rise < 1e-6) return s;
57783
+ const lo = Math.min(p0[other], p1[other]), hi = Math.max(p0[other], p1[other]);
57784
+ const y0 = Math.min(p0[1], p1[1]) - batten.height, y1 = Math.max(p0[1], p1[1]);
57785
+ for (const box4 of solids) {
57786
+ if (box4[other] > hi || box4[other + 3] < lo || box4[1] > y1 || box4[4] < y0) continue;
57787
+ for (const face of [box4[axis], box4[axis + 3]]) for (const side of [p0[axis] - batten.width / 2, p0[axis] + batten.width / 2]) if (Math.abs(face - side) < BATTEN_SIDE_CLEAR) return s + SIDE_STEP * 2 / rise;
57788
+ }
57789
+ return s;
57790
+ }
57547
57791
  function spanAt(slope, s) {
57548
57792
  return slope.hipped ? [slope.t0 + s + EDGE2, slope.t1 - s - EDGE2] : [slope.t0 + EDGE2, slope.t1 - EDGE2];
57549
57793
  }
@@ -57551,8 +57795,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57551
57795
  const { batten, rafter, purlin } = TIMBER;
57552
57796
  for (let s = batten.spacing / 2; s < slope.run - 0.12; s += batten.spacing) {
57553
57797
  const [a0, b0] = spanAt(slope, s);
57554
- const a = a0 + 0.015, b = b0 - 0.015;
57555
- if (b - a > 0.05) addTimberAround(batches.battens, down(slope.point(s, a), batten.top), down(slope.point(s, b), batten.top), batten.width, batten.height, keepOut);
57798
+ const a = a0 + BATTEN_SHORT, b = b0 - BATTEN_SHORT;
57799
+ if (b - a <= 0.05) continue;
57800
+ const at2 = battenClearOfSolids(slope, s, [a, b], solids);
57801
+ addTimberAround(batches.battens, down(slope.point(at2, a), batten.top), down(slope.point(at2, b), batten.top), batten.width, batten.height, keepOut);
57556
57802
  }
57557
57803
  const t0 = slope.t0 + EDGE2, t1 = slope.t1 - EDGE2;
57558
57804
  const count = Math.max(1, Math.round((t1 - t0) / rafter.spacing));
@@ -57572,7 +57818,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57572
57818
  const p0 = down(slope.point(s, a), top), p1 = down(slope.point(s, b), top);
57573
57819
  const depth = Math.min(purlin.height, p0[1] - slabTop - 3e-3);
57574
57820
  if (depth < 0.02) return;
57575
- addTimberAround(batches.timber, p0, p1, purlin.width, depth, keepOut, k === 0 ? void 0 : (end) => addPost(batches.timber, end[0], end[2], slabTop, end[1] - purlin.height));
57821
+ addTimberAround(batches.timber, p0, p1, k === 0 ? purlin.width - PLATE_NARROWER : purlin.width, depth, keepOut, k === 0 ? void 0 : (end) => addPost(batches.timber, end[0], end[2], slabTop, end[1] - purlin.height));
57576
57822
  if (k === 0) return;
57577
57823
  const posts = Math.max(1, Math.ceil((b - a) / TIMBER.post.spacing));
57578
57824
  for (let j = 0; j <= posts; j++) {
@@ -57581,6 +57827,29 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57581
57827
  }
57582
57828
  });
57583
57829
  }
57830
+ var BATTEN_SHORT = 0.0185;
57831
+ var BATTEN_SIDE_CLEAR = 35e-4;
57832
+ var PLATE_NARROWER = 8e-3;
57833
+ var BOX_VERTICES = 24;
57834
+ function bareBoxesOf(THREE, groups) {
57835
+ const out = [];
57836
+ const v = new THREE.Vector3();
57837
+ for (const group of groups) {
57838
+ group.updateMatrixWorld(true);
57839
+ group.traverse((o) => {
57840
+ const mesh2 = o;
57841
+ if (!mesh2.isMesh) return;
57842
+ const position = mesh2.geometry.getAttribute("position");
57843
+ const step = position.count > BOX_VERTICES && position.count % BOX_VERTICES === 0 ? BOX_VERTICES : position.count;
57844
+ for (let i = 0; i + step <= position.count; i += step) {
57845
+ const box4 = new THREE.Box3();
57846
+ for (let k = i; k < i + step; k++) box4.expandByPoint(v.fromBufferAttribute(position, k).applyMatrix4(mesh2.matrixWorld));
57847
+ out.push([box4.min.x, box4.min.y, box4.min.z, box4.max.x, box4.max.y, box4.max.z]);
57848
+ }
57849
+ });
57850
+ }
57851
+ return out;
57852
+ }
57584
57853
  function buildRoofFramingStage(THREE, roofRects, material, solids = [], keepOut = []) {
57585
57854
  const group = new THREE.Group();
57586
57855
  group.name = "stage:7:roof_framing";
@@ -58071,7 +58340,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58071
58340
  const bp = buildBlueprintStage(THREE, K.DOC, r, rectsOf2);
58072
58341
  const stGroups = buildStructuralStageGroups(THREE, r0.structure, r.outbuildings || [], [...embeddedRunsOf(house), ...wallBoxRunsOf(r, shared2.ctx.wallBoxShifts)], shared2.ctx.blockLaid ?? []);
58073
58342
  const instGroup = buildInstallationsStage(THREE, r, shared2.ctx.gutterInfo?.drains ?? [], shared2.ctx.paving ?? []);
58074
- const roofFraming = buildRoofFramingStage(THREE, shared2.ctx.roofRects || [], void 0, shared2.ctx.occupied, [...atticKeepOut(THREE, house, Object.values(parts2)), ...gutterKeepOut(shared2.ctx.gutterInfo?.gutters ?? [])]);
58343
+ const roofFraming = buildRoofFramingStage(THREE, shared2.ctx.roofRects || [], void 0, [...shared2.ctx.occupied ?? [], ...bareBoxesOf(THREE, [stGroups.frame, stGroups.masonry])], [...atticKeepOut(THREE, house, Object.values(parts2)), ...gutterKeepOut(shared2.ctx.gutterInfo?.gutters ?? [])]);
58075
58344
  const yardBoxes = instGroup.userData.yardBoxes;
58076
58345
  for (const sg of [bp, stGroups.foundation, stGroups.starterBars, stGroups.frame, stGroups.masonry, instGroup, ...yardBoxes ? [yardBoxes] : [], roofFraming]) {
58077
58346
  gs[sg.name] = sg;
@@ -58567,6 +58836,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58567
58836
  const part = { id: p.id, material, shape: p.shape, position: p.position };
58568
58837
  if (p.rotation) part.rotation = p.rotation;
58569
58838
  if (!LOOSE.has(material) && p.min[1] <= FLOOR_TOUCH) part.anchored = true;
58839
+ if (opts.carcass && LOOSE.has(material)) {
58840
+ part.hands = 1;
58841
+ part.tags = ["book"];
58842
+ }
58570
58843
  return part;
58571
58844
  });
58572
58845
  const byId = new Map(drawn.map((p) => [p.id, p]));