@chanmeng666/archlang-3d 0.7.0 → 0.8.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.
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  FLOOR_LIFT_UM,
3
3
  FLOOR_OVERLAP_MIN_UM2,
4
+ T0_DEFAULTS,
4
5
  T0_HEIGHT_MM,
5
6
  T0_HUNG_FROM_TOP,
6
7
  T0_MATERIALS,
@@ -23,8 +24,9 @@ import {
23
24
  t0Shells,
24
25
  wallOwnership,
25
26
  where
26
- } from "./chunk-GXWLZ2KC.js";
27
+ } from "./chunk-33J3YGNF.js";
27
28
  import {
29
+ CONTACT_SHADOW,
28
30
  FENCE_PALETTE,
29
31
  GROUND_PLANE,
30
32
  GROUND_SPLITS,
@@ -33,12 +35,13 @@ import {
33
35
  STAIR_MATERIAL,
34
36
  STAIR_RAIL_MATERIAL,
35
37
  TRIM_MATERIAL,
36
- floorFinish
37
- } from "./chunk-TI4RYEOL.js";
38
+ floorFinish,
39
+ wordFinish
40
+ } from "./chunk-LNIVDMPG.js";
38
41
 
39
42
  // src/adapter/adapt.ts
40
43
  import * as core from "@chanmeng666/archlang";
41
- var MIN_CORE = "1.57.0";
44
+ var MIN_CORE = "1.61.0";
42
45
  var hasHanded = (storeys) => storeys.some((s) => s.ir.elements.some((e) => e.kind === "furniture" && isHandedAsset(assetFor(e.category))));
43
46
  function mirroredIds(source, world, n) {
44
47
  const unknown = Array.from({ length: n }, () => null);
@@ -842,8 +845,11 @@ function sectorSign(o, sector) {
842
845
  }
843
846
 
844
847
  // src/mesh/stair.ts
845
- function stairRisers(flights) {
846
- return flights.reduce((n, f) => n + f.treads + 1, 0);
848
+ function stairRisers(flights, landings = []) {
849
+ return flights.reduce((n, f) => n + f.treads + 1, 0) + landings.slice(0, Math.max(0, flights.length - 1)).reduce((n, l) => n + Math.max(0, (l.winders?.length ?? 1) - 1), 0);
850
+ }
851
+ function landingSteps(l) {
852
+ return l.winders?.length ? l.winders : [rect(l.at[0], l.at[1], l.at[0] + l.size.w, l.at[1] + l.size.h).outer];
847
853
  }
848
854
  function runCoordinate(f, d) {
849
855
  const [x, y] = f.at;
@@ -881,7 +887,7 @@ function sideways(section, c0, c1, runAlongY) {
881
887
  function stairSolid(stair, z0, rise) {
882
888
  const flights = stair.flights;
883
889
  if (!flights?.length || !(rise > 0)) return null;
884
- const R = stairRisers(flights);
890
+ const R = stairRisers(flights, stair.landings);
885
891
  const riserTop = (k) => z0 + Math.round(rise * k / R);
886
892
  const shells = [];
887
893
  const landingTops = [];
@@ -908,15 +914,14 @@ function stairSolid(stair, z0, rise) {
908
914
  climbed += n + 1;
909
915
  const landing = stair.landings?.[i];
910
916
  if (landing && i < flights.length - 1) {
911
- const top = riserTop(climbed);
912
- landingTops.push(top);
913
- const box = prism(
914
- rect(landing.at[0], landing.at[1], landing.at[0] + landing.size.w, landing.at[1] + landing.size.h),
915
- z0,
916
- top
917
- );
918
- if (box) shells.push(box);
919
- else dropped++;
917
+ landingTops.push(riserTop(climbed));
918
+ const steps = landingSteps(landing);
919
+ steps.forEach((ring, k) => {
920
+ const box = prism({ outer: ring }, z0, riserTop(climbed + k));
921
+ if (box) shells.push(box);
922
+ else dropped++;
923
+ });
924
+ climbed += steps.length - 1;
920
925
  }
921
926
  });
922
927
  return { shells, risers: R, landingTops, top: riserTop(R - 1), dropped };
@@ -961,7 +966,7 @@ function stairDetail(stair, z0, rise, solidAt) {
961
966
  if (!flights?.length || !(rise > 0)) return null;
962
967
  const MM4 = 1e3;
963
968
  const D = STAIR_DETAIL;
964
- const R = stairRisers(flights);
969
+ const R = stairRisers(flights, stair.landings);
965
970
  const riserTop = (k) => z0 + Math.round(rise * k / R);
966
971
  const r = rise / R / MM4;
967
972
  const W = stair.width / MM4;
@@ -1104,12 +1109,20 @@ function stairDetail(stair, z0, rise, solidAt) {
1104
1109
  const top = riserTop(climbed);
1105
1110
  base = top;
1106
1111
  const box = [landing.at[0], landing.at[1], landing.at[0] + landing.size.w, landing.at[1] + landing.size.h];
1107
- keep(out.treads, solid(box, z0, top));
1108
- landings.push({ box, top, going: Math.round(g * MM4), k: i + 1 });
1112
+ if (landing.winders?.length) {
1113
+ const steps = landing.winders.map((ring, j) => ({ ring, top: riserTop(climbed + j) }));
1114
+ for (const st of steps) keep(out.treads, prism({ outer: st.ring }, z0, st.top));
1115
+ climbed += steps.length - 1;
1116
+ base = riserTop(climbed);
1117
+ landings.push({ box, top, going: Math.round(g * MM4), k: i + 1, steps });
1118
+ } else {
1119
+ keep(out.treads, solid(box, z0, top));
1120
+ landings.push({ box, top, going: Math.round(g * MM4), k: i + 1 });
1121
+ }
1109
1122
  }
1110
1123
  });
1111
1124
  const taken = [...newels];
1112
- for (const { box, top, going, k } of landings) {
1125
+ for (const { box, top, going, k, steps } of landings) {
1113
1126
  const [x0, y0, x1, y1] = box;
1114
1127
  const p = D.probe * MM4;
1115
1128
  const edges = [
@@ -1118,8 +1131,18 @@ function stairDetail(stair, z0, rise, solidAt) {
1118
1131
  { side: "bottom", horizontal: true, at: y1, out: 1 },
1119
1132
  { side: "left", horizontal: false, at: x0, out: -1 }
1120
1133
  ];
1121
- const railTop = top + D.landingRailHeight * MM4;
1122
1134
  for (const { side, horizontal, at: at2, out: dir } of edges) {
1135
+ const piecesAlong = (q0, q1) => {
1136
+ if (!steps) return [[q0, q1, top]];
1137
+ const pieces = [];
1138
+ for (const st of steps) {
1139
+ const on = st.ring.filter((p2) => Math.abs((horizontal ? p2[1] : p2[0]) - at2) <= 1).map((p2) => horizontal ? p2[0] : p2[1]);
1140
+ if (on.length < 2) continue;
1141
+ const [p0, p1] = [Math.max(q0, Math.min(...on)), Math.min(q1, Math.max(...on))];
1142
+ if (p1 > p0) pieces.push([p0, p1, st.top]);
1143
+ }
1144
+ return pieces.sort((a, b) => a[0] - b[0]);
1145
+ };
1123
1146
  const [a0, a1] = horizontal ? [x0, x1] : [y0, y1];
1124
1147
  const [s0, s1] = dir > 0 ? [at2, at2 + p] : [at2 - p, at2];
1125
1148
  const flightRuns = flightBoxes.filter(
@@ -1140,20 +1163,22 @@ function stairDetail(stair, z0, rise, solidAt) {
1140
1163
  const across = side === "top" ? [y0, y0 + railW] : side === "bottom" ? [y1 - railW, y1] : side === "left" ? [x0, x0 + railW] : [x1 - railW, x1];
1141
1164
  for (const [r0, r1] of open) {
1142
1165
  const held = taken.filter((b) => horizontal ? b[1] < across[1] && b[3] > across[0] : b[0] < across[1] && b[2] > across[0]).map((b) => horizontal ? [b[0], b[2]] : [b[1], b[3]]);
1143
- for (const [q0, q1] of freeRuns(r0, r1, held, np)) {
1144
- const b = horizontal ? [q0, across[0], q1, across[1]] : [across[0], q0, across[1], q1];
1145
- keep(out.rails, solid(b, railTop - railW, railTop));
1146
- taken.push(b);
1147
- railed = true;
1148
- const len = q1 - q0;
1149
- const count = Math.max(1, Math.min(64, Math.floor(len / going)));
1150
- const mid = Math.round((across[0] + across[1] - bb) / 2);
1151
- for (let j = 0; j < count; j++) {
1152
- const c = Math.round(q0 + len * (2 * j + 1) / (2 * count) - bb / 2);
1153
- const bal = horizontal ? [c, mid, c + bb, mid + bb] : [mid, c, mid + bb, c + bb];
1154
- keep(out.rails, solid(bal, top, railTop - railW + MM4));
1166
+ for (const [f0, f1] of freeRuns(r0, r1, held, np))
1167
+ for (const [q0, q1, under] of piecesAlong(f0, f1)) {
1168
+ const railTop = under + D.landingRailHeight * MM4;
1169
+ const b = horizontal ? [q0, across[0], q1, across[1]] : [across[0], q0, across[1], q1];
1170
+ keep(out.rails, solid(b, railTop - railW, railTop));
1171
+ taken.push(b);
1172
+ railed = true;
1173
+ const len = q1 - q0;
1174
+ const count = Math.max(1, Math.min(64, Math.floor(len / going)));
1175
+ const mid = Math.round((across[0] + across[1] - bb) / 2);
1176
+ for (let j = 0; j < count; j++) {
1177
+ const c = Math.round(q0 + len * (2 * j + 1) / (2 * count) - bb / 2);
1178
+ const bal = horizontal ? [c, mid, c + bb, mid + bb] : [mid, c, mid + bb, c + bb];
1179
+ keep(out.rails, solid(bal, under, railTop - railW + MM4));
1180
+ }
1155
1181
  }
1156
- }
1157
1182
  }
1158
1183
  if (open.length > 0 && !railed) out.sides[sideAt].against = "newel";
1159
1184
  }
@@ -1272,6 +1297,12 @@ function fencePieces(f, profile, height) {
1272
1297
 
1273
1298
  // src/mesh/build.ts
1274
1299
  var MM3 = 1e3;
1300
+ var shadowRule = (r, size) => ({
1301
+ of: r.of,
1302
+ size,
1303
+ min: r.minMm,
1304
+ max: r.maxMm
1305
+ });
1275
1306
  var SLAB_MM = 200;
1276
1307
  var FLOOR_FINISH_MM = 5;
1277
1308
  var ROOF_MM = 150;
@@ -1472,15 +1503,17 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
1472
1503
  lv.floors.forEach((f, i) => {
1473
1504
  const pieces = f.polygon.holes?.length ? [f.polygon] : lessVoids(f.polygon.outer, lv.voids, `floor:${f.id}`, ledger);
1474
1505
  const z0 = e + (f.lift ?? 0);
1475
- const finish = floorFinish(f.uses);
1476
- ledger.push({
1477
- kind: "floor",
1478
- id: f.id,
1479
- field: "finish",
1480
- value: finish,
1481
- provenance: "default",
1482
- rule: "floor-finish-default"
1483
- });
1506
+ const authored = wordFinish(f.pattern);
1507
+ const finish = authored ?? floorFinish(f.uses);
1508
+ if (authored === void 0)
1509
+ ledger.push({
1510
+ kind: "floor",
1511
+ id: f.id,
1512
+ field: "finish",
1513
+ value: finish,
1514
+ provenance: "default",
1515
+ rule: "floor-finish-default"
1516
+ });
1484
1517
  node(
1485
1518
  "floor",
1486
1519
  f.id,
@@ -1585,6 +1618,27 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
1585
1618
  provenance: "derived",
1586
1619
  rule: "stair-risers-from-treads"
1587
1620
  });
1621
+ (s.landings ?? []).forEach((l, k) => {
1622
+ if (l.winders?.length)
1623
+ ledger.push(
1624
+ {
1625
+ kind: "stair",
1626
+ id: s.id,
1627
+ field: `winders(landing ${k + 1})`,
1628
+ value: l.winders.length,
1629
+ provenance: "derived",
1630
+ rule: "stair-winders-from-drawing"
1631
+ },
1632
+ {
1633
+ kind: "stair",
1634
+ id: s.id,
1635
+ field: `risers_form(landing ${k + 1})`,
1636
+ value: "solid",
1637
+ provenance: "default",
1638
+ rule: "stair-winders-solid"
1639
+ }
1640
+ );
1641
+ });
1588
1642
  const d = solid.dims;
1589
1643
  ledger.push(
1590
1644
  {
@@ -1892,6 +1946,15 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
1892
1946
  rule: "furniture-mount-default"
1893
1947
  });
1894
1948
  }
1949
+ for (const d of family ? T0_DEFAULTS[family] ?? [] : []) {
1950
+ ledger.push({
1951
+ kind: "furniture",
1952
+ field: `${d.field}(${f.category})`,
1953
+ value: d.value,
1954
+ provenance: "default",
1955
+ rule: d.rule
1956
+ });
1957
+ }
1895
1958
  const slots = family ? T0_MATERIALS[family] : void 0;
1896
1959
  if (slots?.length) {
1897
1960
  ledger.push({
@@ -1955,7 +2018,11 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
1955
2018
  yaw_deg: f.yawDeg,
1956
2019
  asset,
1957
2020
  ...f.room ? { room: f.room } : {},
1958
- ...parts && f.mirror ? { mirror: true } : {}
2021
+ ...parts && f.mirror ? { mirror: true } : {},
2022
+ // Hung on the wall, not standing (`isHung`): a fact of the piece as built, so a reader (the
2023
+ // replay's contact shadows, card RM8.8) needs neither the T0 tables nor the ledger, whose
2024
+ // per-piece rows name no storey. Absent on a standing piece.
2025
+ ...parts && family && isHung(family) ? { hung: true } : {}
1959
2026
  });
1960
2027
  });
1961
2028
  const roofZ = [e + tallest, e + tallest + ROOF_MM * MM3];
@@ -2146,6 +2213,23 @@ function buildMesh(scene, opts = {}) {
2146
2213
  },
2147
2214
  provenance: "default",
2148
2215
  rule: "ground-plane-viewer-only"
2216
+ },
2217
+ // Card RM8.8: the soft contact shadows the viewer draws are in no node and not in the GLB, so,
2218
+ // as the ground plane, they are said here, in every Mesh3D: each band's width rule and alphas.
2219
+ {
2220
+ kind: "shadow",
2221
+ field: "contact",
2222
+ value: {
2223
+ drawn: "viewer only",
2224
+ wall_band_mm: shadowRule(CONTACT_SHADOW.wall, "thickness"),
2225
+ furniture_band_mm: shadowRule(CONTACT_SHADOW.furniture, "smaller footprint side"),
2226
+ fence_band_mm: shadowRule(CONTACT_SHADOW.fence, "post"),
2227
+ stair_thickness_mm: CONTACT_SHADOW.stairThicknessMm,
2228
+ alpha: { ...CONTACT_SHADOW.alpha },
2229
+ alpha_dark: { ...CONTACT_SHADOW.alphaDark }
2230
+ },
2231
+ provenance: "default",
2232
+ rule: "contact-shadows-viewer-only"
2149
2233
  }
2150
2234
  ];
2151
2235
  const defaulted = /* @__PURE__ */ new Set();