@chanmeng666/archlang-3d 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,6 @@
1
1
  import {
2
+ FLOOR_LIFT_UM,
3
+ FLOOR_OVERLAP_MIN_UM2,
2
4
  T0_HEIGHT_MM,
3
5
  T0_HUNG_FROM_TOP,
4
6
  T0_MATERIALS,
@@ -12,6 +14,7 @@ import {
12
14
  isHandedAsset,
13
15
  isHung,
14
16
  mixedHeightJoints,
17
+ overlapArea,
15
18
  prism,
16
19
  rect,
17
20
  sectorBand,
@@ -19,11 +22,16 @@ import {
19
22
  t0Shells,
20
23
  wallOwnership,
21
24
  where
22
- } from "./chunk-WCWLYIVD.js";
25
+ } from "./chunk-6WCS4TAT.js";
23
26
  import {
27
+ FENCE_PALETTE,
28
+ GROUND_PLANE,
29
+ GROUND_SPLITS,
30
+ GROUND_TINT,
31
+ GROUND_WASH,
24
32
  STAIR_MATERIAL,
25
33
  floorFinish
26
- } from "./chunk-EQBMPXB5.js";
34
+ } from "./chunk-TNNJ7CAO.js";
27
35
 
28
36
  // src/adapter/adapt.ts
29
37
  import * as core from "@chanmeng666/archlang";
@@ -279,13 +287,13 @@ function stairSolid(stair, z0, rise) {
279
287
  const width = Math.min(stair.width, extent);
280
288
  const c0 = lo + Math.round((extent - width) / 2);
281
289
  const c1 = c0 + width;
282
- const at = (t) => runCoordinate(f, Math.round(run * t / n));
283
- const section = [[at(0), z0]];
290
+ const at2 = (t) => runCoordinate(f, Math.round(run * t / n));
291
+ const section = [[at2(0), z0]];
284
292
  for (let t = 0; t < n; t++) {
285
293
  const h = riserTop(climbed + t + 1);
286
- section.push([at(t), h], [at(t + 1), h]);
294
+ section.push([at2(t), h], [at2(t + 1), h]);
287
295
  }
288
- section.push([at(n), z0]);
296
+ section.push([at2(n), z0]);
289
297
  const s = sideways(section, c0, c1, yRun);
290
298
  if (s) shells.push(s);
291
299
  else dropped++;
@@ -306,8 +314,97 @@ function stairSolid(stair, z0, rise) {
306
314
  return { shells, risers: R, landingTops, top: riserTop(R - 1), dropped };
307
315
  }
308
316
 
309
- // src/mesh/build.ts
317
+ // src/mesh/outdoor.ts
318
+ import { DEFAULT_THEME } from "@chanmeng666/archlang";
319
+ var OUTDOOR_MM = 50;
320
+ var FENCE_HEIGHT_MM = { picket: 1e3, panel: 1800, post: 1100 };
321
+ var CORE_POST_PITCH_MM = { picket: 600, panel: 1800, post: 1800 };
322
+ var CORE_POSTS_PER_RUN = [1, 60];
323
+ var FENCE_PROFILES = {
324
+ picket: {
325
+ post: 80,
326
+ rails: [
327
+ [20, 150, 220],
328
+ [20, 700, 770]
329
+ ],
330
+ pickets: [70, 20, 140]
331
+ },
332
+ panel: { post: 100, rails: [[40, 0, 1800]] },
333
+ post: { post: 100, rails: [[60, 1040, 1100]] }
334
+ };
335
+ var MAX_FENCE_REPEAT = 400;
310
336
  var MM = 1e3;
337
+ var tintOf = (surface) => GROUND_TINT[surface];
338
+ function groundColour(tint, theme = DEFAULT_THEME) {
339
+ const ch = (hex, i) => Number.parseInt(hex.slice(i, i + 2), 16);
340
+ const bg = theme.bg;
341
+ const wash = theme[tint];
342
+ const out = [1, 3, 5].map((i) => {
343
+ const v = ch(bg, i) - GROUND_WASH * (ch(bg, i) - ch(wash, i));
344
+ return Math.max(0, Math.min(255, v)).toString(16).padStart(2, "0");
345
+ });
346
+ return `#${out.join("")}`;
347
+ }
348
+ function outdoorColour(surface) {
349
+ const split = GROUND_SPLITS[surface];
350
+ if (split) return { srgb: split.srgb, rule: "outdoor-colour-3d" };
351
+ return { srgb: groundColour(tintOf(surface) ?? "paving"), rule: "outdoor-colour-theme" };
352
+ }
353
+ var fenceColour = (style) => (FENCE_PALETTE[style] ?? FENCE_PALETTE.picket).srgb;
354
+ var at = (a, b, f) => [
355
+ Math.round(a[0] + (b[0] - a[0]) * f),
356
+ Math.round(a[1] + (b[1] - a[1]) * f)
357
+ ];
358
+ function corePostCount(lenUm, style) {
359
+ const pitch = CORE_POST_PITCH_MM[style] ?? CORE_POST_PITCH_MM.picket;
360
+ const [lo, hi] = CORE_POSTS_PER_RUN;
361
+ return Math.max(lo, Math.min(hi, Math.round(lenUm / MM / pitch)));
362
+ }
363
+ function fenceRuns(f) {
364
+ const pts = f.points;
365
+ const all = [];
366
+ for (let i = 0; i + 1 < pts.length; i++) all.push([pts[i], pts[i + 1]]);
367
+ if (f.closed && pts.length > 2) all.push([pts[pts.length - 1], pts[0]]);
368
+ const runs = all.filter(([a, b]) => Math.hypot(b[0] - a[0], b[1] - a[1]) > 0);
369
+ return { runs, ring: f.closed && pts.length > 2 && runs.length > 1 };
370
+ }
371
+ function fencePosts(f) {
372
+ const { runs, ring } = fenceRuns(f);
373
+ const out = [];
374
+ runs.forEach(([a, b], i) => {
375
+ const n = corePostCount(Math.hypot(b[0] - a[0], b[1] - a[1]), f.style);
376
+ for (let k = 0; k < n; k++) out.push({ at: at(a, b, k / n), run: [a, b] });
377
+ if (i === runs.length - 1 && !ring) out.push({ at: b, run: [a, b] });
378
+ });
379
+ return out;
380
+ }
381
+ function fencePieces(f, profile, height) {
382
+ const out = [];
383
+ const box = (c, [a, b], w, d) => {
384
+ const len = Math.hypot(b[0] - a[0], b[1] - a[1]);
385
+ const ux = (b[0] - a[0]) / len;
386
+ const uy = (b[1] - a[1]) / len;
387
+ const p = (s) => [Math.round(c[0] + ux * s), Math.round(c[1] + uy * s)];
388
+ return slab2d(p(-w / 2), p(w / 2), d);
389
+ };
390
+ for (const p of fencePosts(f))
391
+ out.push({ poly: box(p.at, p.run, profile.post * MM, profile.post * MM), z: [0, height] });
392
+ for (const [a, b] of fenceRuns(f).runs) {
393
+ const len = Math.hypot(b[0] - a[0], b[1] - a[1]);
394
+ for (const [depth, z0, z1] of profile.rails)
395
+ out.push({ poly: slab2d(a, b, depth * MM), z: [Math.min(z0, height), Math.min(z1, height)] });
396
+ if (profile.pickets) {
397
+ const [w, d, pitch] = profile.pickets;
398
+ const m = Math.max(1, Math.min(MAX_FENCE_REPEAT, Math.ceil(len / (pitch * MM))));
399
+ const pw = Math.min(w * MM, len / m);
400
+ for (let j = 0; j < m; j++) out.push({ poly: box(at(a, b, (j + 0.5) / m), [a, b], pw, d * MM), z: [0, height] });
401
+ }
402
+ }
403
+ return out;
404
+ }
405
+
406
+ // src/mesh/build.ts
407
+ var MM2 = 1e3;
311
408
  var SLAB_MM = 200;
312
409
  var FLOOR_FINISH_MM = 5;
313
410
  var ROOF_MM = 150;
@@ -351,7 +448,11 @@ var STAGE = {
351
448
  window: "openings",
352
449
  opening: "openings",
353
450
  furniture: "fixtures",
354
- stair: "walls"
451
+ stair: "walls",
452
+ // The site (card RM8.3): its surfaces are laid out with the slab, before the rooms; a fence rises
453
+ // with the storey's walls.
454
+ outdoor: "brief",
455
+ fence: "walls"
355
456
  };
356
457
  var byText = (a, b) => a < b ? -1 : a > b ? 1 : 0;
357
458
  function along(a, b, d) {
@@ -498,7 +599,7 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
498
599
  "slab",
499
600
  "slab",
500
601
  0,
501
- slabRegion(lv.footprint, lv.floors, ledger).flatMap((r) => lessVoids(r.outer, lv.voids, "slab", ledger)).map((p) => prism2(p, e - SLAB_MM * MM, e)),
602
+ slabRegion(lv.footprint, lv.floors, ledger).flatMap((r) => lessVoids(r.outer, lv.voids, "slab", ledger)).map((p) => prism2(p, e - SLAB_MM * MM2, e)),
502
603
  { thickness_mm: SLAB_MM }
503
604
  );
504
605
  lv.floors.forEach((f, i) => {
@@ -517,15 +618,15 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
517
618
  "floor",
518
619
  f.id,
519
620
  i,
520
- pieces.map((p) => prism2(p, z0, z0 + FLOOR_FINISH_MM * MM)),
621
+ pieces.map((p) => prism2(p, z0, z0 + FLOOR_FINISH_MM * MM2)),
521
622
  {
522
623
  ...f.uses?.length ? { uses: f.uses.join(" ") } : {},
523
- ...f.lift ? { lift_mm: f.lift / MM } : {},
624
+ ...f.lift ? { lift_mm: f.lift / MM2 } : {},
524
625
  finish
525
626
  }
526
627
  );
527
628
  });
528
- const ceiling = above ? above.elevation - SLAB_MM * MM - e : 0;
629
+ const ceiling = above ? above.elevation - SLAB_MM * MM2 - e : 0;
529
630
  const slabAbove = above && ceiling > 0 ? slabRegion(above.footprint, above.floors, []).flatMap((r) => lessVoids(r.outer, above.voids, "slab", [])) : [];
530
631
  const stopped = (height, rings) => height > ceiling && ceiling > 0 && rings.every((r) => coveredBy(r, slabAbove));
531
632
  const stopLedger = (kind, id) => {
@@ -533,7 +634,7 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
533
634
  kind,
534
635
  id,
535
636
  field: `top_mm(L${lv.level})`,
536
- value: ceiling / MM,
637
+ value: ceiling / MM2,
537
638
  provenance: "derived",
538
639
  rule: "stops-under-slab-above"
539
640
  });
@@ -553,7 +654,7 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
553
654
  kind: "stair",
554
655
  id: s.id,
555
656
  field: "rise_mm",
556
- value: lv.storeyHeight / MM,
657
+ value: lv.storeyHeight / MM2,
557
658
  provenance: "default",
558
659
  rule: "stair-rise-storey-height"
559
660
  });
@@ -574,7 +675,7 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
574
675
  if (s.dir === "down" && !partnered && above)
575
676
  climbs.push({ s, order: lv.stairs.length + i, rise: above.elevation - e, from: "above" });
576
677
  });
577
- const stairFloor = e + FLOOR_FINISH_MM * MM;
678
+ const stairFloor = e + FLOOR_FINISH_MM * MM2;
578
679
  for (const { s, order, rise, from } of climbs) {
579
680
  const solid = stairSolid(s, stairFloor, rise);
580
681
  if (!solid) {
@@ -611,10 +712,10 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
611
712
  });
612
713
  node("stair", s.id, order, [...solid.shells, ...Array.from({ length: solid.dropped }, () => null)], {
613
714
  dir: s.dir,
614
- width_mm: s.width / MM,
715
+ width_mm: s.width / MM2,
615
716
  flights: s.flights?.length ?? 0,
616
717
  risers: solid.risers,
617
- rise_mm: rise / MM,
718
+ rise_mm: rise / MM2,
618
719
  ...from === "above" ? { from_storey_above: true } : {}
619
720
  });
620
721
  }
@@ -633,7 +734,7 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
633
734
  kind: o.kind,
634
735
  id: o.id,
635
736
  field: `head_mm(L${lv.level})`,
636
- value: ceiling / MM,
737
+ value: ceiling / MM2,
637
738
  provenance: "derived",
638
739
  rule: "head-at-slab-above"
639
740
  });
@@ -665,8 +766,8 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
665
766
  }
666
767
  node("wall", w.id, i, shells, {
667
768
  ...w.category ? { category: w.category } : {},
668
- height_mm: w.height / MM,
669
- thickness_mm: w.thickness / MM
769
+ height_mm: w.height / MM2,
770
+ thickness_mm: w.thickness / MM2
670
771
  });
671
772
  });
672
773
  (lv.demolished ?? []).forEach((w, i) => {
@@ -677,9 +778,9 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
677
778
  w.body.map((p) => prism2(p, e, e + w.height)),
678
779
  {
679
780
  ...w.category ? { category: w.category } : {},
680
- height_mm: w.height / MM,
781
+ height_mm: w.height / MM2,
681
782
  status: "demolish",
682
- thickness_mm: w.thickness / MM
783
+ thickness_mm: w.thickness / MM2
683
784
  },
684
785
  "demolish"
685
786
  );
@@ -687,12 +788,12 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
687
788
  lv.openings.forEach((o, i) => {
688
789
  const [j0, j1] = o.jambs;
689
790
  const head = Math.min(o.head, hostHeight.get(o.host) ?? o.head);
690
- const extras = { host: o.host, width_mm: o.width / MM, sill_mm: o.sill / MM, head_mm: o.head / MM };
791
+ const extras = { host: o.host, width_mm: o.width / MM2, sill_mm: o.sill / MM2, head_mm: o.head / MM2 };
691
792
  if (o.kind === "door") {
692
793
  const z0 = e + o.sill;
693
794
  const swung = o.leaves?.every((l) => l.length === 3) ? o.leaves : void 0;
694
795
  if (doors === "plan" && swung) {
695
- const open = swung.map(([h, f, end]) => openLeaf(h, f, end, LEAF_MM * MM));
796
+ const open = swung.map(([h, f, end]) => openLeaf(h, f, end, LEAF_MM * MM2));
696
797
  const through = open.some((leaf) => leafThroughWall(leaf, lv.walls));
697
798
  if (through) {
698
799
  ledger.push({
@@ -729,19 +830,19 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
729
830
  "door",
730
831
  o.id,
731
832
  i,
732
- leaves.map(([h, f]) => prism2(slab2d(h, f, LEAF_MM * MM), z0, e + head)),
833
+ leaves.map(([h, f]) => prism2(slab2d(h, f, LEAF_MM * MM2), z0, e + head)),
733
834
  { ...extras, door_kind: o.doorKind ?? "hinged", pose: "closed" }
734
835
  );
735
836
  } else if (o.kind === "window") {
736
837
  const z0 = e + o.sill;
737
838
  const z1 = e + head;
738
- const fw = FRAME_WIDTH_MM * MM;
739
- const fd = FRAME_DEPTH_MM * MM;
839
+ const fw = FRAME_WIDTH_MM * MM2;
840
+ const fd = FRAME_DEPTH_MM * MM2;
740
841
  const sector = cutSector(o.cut, o.jambs, o.centre);
741
842
  if (sector) {
742
843
  const band = (depth, f0, f1) => sectorBand(sector, -depth / 2, depth / 2, f0, f1);
743
844
  const f = Math.min(0.5, fw / (sector.r * Math.abs(sector.sweep)));
744
- node("window", o.id, i, [prism2(band(GLASS_MM * MM), z0, z1)], extras, "glass");
845
+ node("window", o.id, i, [prism2(band(GLASS_MM * MM2), z0, z1)], extras, "glass");
745
846
  node(
746
847
  "window",
747
848
  o.id,
@@ -761,7 +862,7 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
761
862
  const q = insideCut(p, o.cut);
762
863
  return q ? prism2(q, a, b) : null;
763
864
  };
764
- node("window", o.id, i, [fit(slab2d(j0, j1, GLASS_MM * MM), z0, z1)], extras, "glass");
865
+ node("window", o.id, i, [fit(slab2d(j0, j1, GLASS_MM * MM2), z0, z1)], extras, "glass");
765
866
  node(
766
867
  "window",
767
868
  o.id,
@@ -777,7 +878,7 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
777
878
  );
778
879
  }
779
880
  });
780
- const floorTop = e + FLOOR_FINISH_MM * MM;
881
+ const floorTop = e + FLOOR_FINISH_MM * MM2;
781
882
  const tallest = lv.walls.reduce((m, w) => Math.max(m, w.height), 0) || lv.storeyHeight;
782
883
  const tallestBuilt = lv.walls.reduce((m, w) => Math.max(m, wallHeight.get(w.id) ?? w.height), 0) || lv.storeyHeight;
783
884
  lv.furniture.forEach((f, i) => {
@@ -832,12 +933,12 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
832
933
  kind: "furniture",
833
934
  id: f.id,
834
935
  field: "mount_mm",
835
- value: (low - floorTop) / MM,
936
+ value: (low - floorTop) / MM2,
836
937
  provenance: "default",
837
938
  rule: "furniture-mount-from-top"
838
939
  });
839
940
  }
840
- if (floorTop + h * MM > e + tallestBuilt) {
941
+ if (floorTop + h * MM2 > e + tallestBuilt) {
841
942
  ledger.push({
842
943
  kind: "furniture",
843
944
  id: f.id,
@@ -847,7 +948,7 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
847
948
  rule: "furniture-hung-above-walls"
848
949
  });
849
950
  }
850
- } else if (parts && family && floorTop + h * MM > e + tallestBuilt) {
951
+ } else if (parts && family && floorTop + h * MM2 > e + tallestBuilt) {
851
952
  ledger.push({
852
953
  kind: "furniture",
853
954
  id: f.id,
@@ -860,7 +961,7 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
860
961
  const [cx, cy] = f.centre;
861
962
  const box = rect(cx - f.size.w / 2, cy - f.size.d / 2, cx + f.size.w / 2, cy + f.size.d / 2);
862
963
  if (parts) holesLeftOut += parts.holesDropped;
863
- const shells = parts ? parts.shells : [prism2(box, floorTop, floorTop + h * MM)];
964
+ const shells = parts ? parts.shells : [prism2(box, floorTop, floorTop + h * MM2)];
864
965
  node("furniture", f.id, i, shells, {
865
966
  category: f.category,
866
967
  yaw_deg: f.yawDeg,
@@ -869,7 +970,7 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
869
970
  ...parts && f.mirror ? { mirror: true } : {}
870
971
  });
871
972
  });
872
- const roofZ = [e + tallest, e + tallest + ROOF_MM * MM];
973
+ const roofZ = [e + tallest, e + tallest + ROOF_MM * MM2];
873
974
  lv.roofs.forEach((r, i) => {
874
975
  node("roof", r.id, i, [prism2({ outer: r.ring }, ...roofZ)], { form: r.form });
875
976
  });
@@ -890,6 +991,134 @@ function levelNodes(lv, ledger, defaulted, isTop, doors, below, above) {
890
991
  { form: "flat" }
891
992
  );
892
993
  }
994
+ const slabHere = slabRegion(lv.footprint, lv.floors, []).flatMap((r) => lessVoids(r.outer, lv.voids, "slab", []));
995
+ const over = (p, q) => overlapArea(p, q) > FLOOR_OVERLAP_MIN_UM2;
996
+ const steps = /* @__PURE__ */ new Map();
997
+ lv.outdoor.forEach((o, i) => {
998
+ const earlier = lv.outdoor.slice(0, i).filter((p) => over(p.polygon, o.polygon));
999
+ const onSlab = slabHere.some((s) => over(s, o.polygon));
1000
+ const floorsUnder = lv.floors.filter((f) => over(f.polygon, o.polygon));
1001
+ const taken = /* @__PURE__ */ new Set([
1002
+ ...onSlab ? [0] : [],
1003
+ ...floorsUnder.flatMap((f) => [f.lift ?? 0, (f.lift ?? 0) + FLOOR_FINISH_MM * MM2]),
1004
+ ...earlier.map((p) => (steps.get(p.id) ?? 0) * FLOOR_LIFT_UM)
1005
+ ]);
1006
+ let step = Math.max(onSlab ? 1 : 0, ...earlier.map((p) => 1 + (steps.get(p.id) ?? 0)));
1007
+ while (taken.has(step * FLOOR_LIFT_UM)) step++;
1008
+ steps.set(o.id, step);
1009
+ const lift = step * FLOOR_LIFT_UM;
1010
+ if (lift > 0) {
1011
+ ledger.push({
1012
+ kind: "outdoor",
1013
+ id: o.id,
1014
+ field: "lift_mm",
1015
+ value: lift / MM2,
1016
+ provenance: "derived",
1017
+ rule: "outdoor-overlap-lift"
1018
+ });
1019
+ }
1020
+ if (!defaulted.has("outdoor:thickness")) {
1021
+ defaulted.add("outdoor:thickness");
1022
+ ledger.push({
1023
+ kind: "outdoor",
1024
+ field: "thickness_mm",
1025
+ value: OUTDOOR_MM,
1026
+ provenance: "default",
1027
+ rule: "outdoor-thickness-default"
1028
+ });
1029
+ ledger.push({
1030
+ kind: "outdoor",
1031
+ field: "wash",
1032
+ value: GROUND_WASH,
1033
+ provenance: "default",
1034
+ rule: "outdoor-colour-wash"
1035
+ });
1036
+ }
1037
+ const colour = outdoorColour(o.surface);
1038
+ if (!defaulted.has(`outdoor:${o.surface}`)) {
1039
+ defaulted.add(`outdoor:${o.surface}`);
1040
+ ledger.push({
1041
+ kind: "outdoor",
1042
+ field: `colour(${o.surface})`,
1043
+ value: colour.srgb,
1044
+ provenance: "default",
1045
+ rule: tintOf(o.surface) ? colour.rule : "outdoor-surface-unknown"
1046
+ });
1047
+ }
1048
+ if (o.rail?.length) {
1049
+ ledger.push({
1050
+ kind: "outdoor",
1051
+ id: o.id,
1052
+ field: "rail",
1053
+ value: "omitted",
1054
+ provenance: "default",
1055
+ rule: "outdoor-rail-omitted"
1056
+ });
1057
+ }
1058
+ node("outdoor", o.id, i, [prism2(o.polygon, e - OUTDOOR_MM * MM2 + lift, e + lift)], {
1059
+ surface: o.surface,
1060
+ colour: colour.srgb,
1061
+ thickness_mm: OUTDOOR_MM,
1062
+ ...lift > 0 ? { lift_mm: lift / MM2 } : {}
1063
+ });
1064
+ });
1065
+ lv.fences.forEach((f, i) => {
1066
+ const known = f.style in FENCE_PROFILES;
1067
+ const style = known ? f.style : "picket";
1068
+ const profile = FENCE_PROFILES[style];
1069
+ const height = FENCE_HEIGHT_MM[style];
1070
+ const pieces = fencePieces({ ...f, style }, profile, height);
1071
+ if (pieces.length === 0) {
1072
+ ledger.push({
1073
+ kind: "fence",
1074
+ id: f.id,
1075
+ field: "geometry",
1076
+ value: "omitted",
1077
+ provenance: "derived",
1078
+ rule: "fence-no-run"
1079
+ });
1080
+ return;
1081
+ }
1082
+ if (!defaulted.has(`fence:${f.style}`)) {
1083
+ defaulted.add(`fence:${f.style}`);
1084
+ ledger.push(
1085
+ {
1086
+ kind: "fence",
1087
+ field: `height_mm(${f.style})`,
1088
+ value: height,
1089
+ provenance: "default",
1090
+ rule: known ? "fence-height-default" : "fence-style-unknown"
1091
+ },
1092
+ {
1093
+ kind: "fence",
1094
+ field: `profile(${f.style})`,
1095
+ value: {
1096
+ post_mm: profile.post,
1097
+ // The core's own spacing: a post on every tick it draws (`fencePosts`).
1098
+ post_pitch_mm: CORE_POST_PITCH_MM[style],
1099
+ rails_mm: profile.rails.map((r) => [...r]),
1100
+ ...profile.pickets ? { pickets_mm: [...profile.pickets] } : {}
1101
+ },
1102
+ provenance: "default",
1103
+ rule: "fence-profile-default"
1104
+ },
1105
+ {
1106
+ kind: "fence",
1107
+ field: `colour(${f.style})`,
1108
+ value: fenceColour(f.style),
1109
+ provenance: "default",
1110
+ rule: "fence-colour-default"
1111
+ }
1112
+ );
1113
+ }
1114
+ node(
1115
+ "fence",
1116
+ f.id,
1117
+ i,
1118
+ pieces.map((p) => prism2(p.poly, e + p.z[0] * MM2, e + p.z[1] * MM2)),
1119
+ { style: f.style, colour: fenceColour(f.style), height_mm: height, closed: f.closed }
1120
+ );
1121
+ });
893
1122
  return out;
894
1123
  }
895
1124
  function buildMesh(scene, opts = {}) {
@@ -914,16 +1143,22 @@ function buildMesh(scene, opts = {}) {
914
1143
  },
915
1144
  { kind: "door", field: "leaf_mm", value: LEAF_MM, provenance: "default", rule: "door-leaf-40" },
916
1145
  { kind: "roof", field: "thickness_mm", value: ROOF_MM, provenance: "default", rule: "roof-flat-150" },
917
- // Narrowed by card X3 (was `m1-omits-stairs-outdoor-fences`, kind `stair`): stairs are built.
918
- ...["outdoor", "fence"].map(
919
- (kind) => ({
920
- kind,
921
- field: "geometry",
922
- value: "omitted",
923
- provenance: "default",
924
- rule: "m1-omits-outdoor-fences"
925
- })
926
- )
1146
+ // Card RM8.3 builds outdoor surfaces and fences (it replaced the two `m1-omits-outdoor-fences`
1147
+ // rows here; their defaults are ledgered per kind and style where they are built). The ground
1148
+ // plane the viewer draws round the building is in no node, so it is said here, in every Mesh3D.
1149
+ {
1150
+ kind: "ground",
1151
+ field: "plane",
1152
+ value: {
1153
+ drawn: "viewer only",
1154
+ level: scene.levels[0]?.level ?? 0,
1155
+ margin_mm: GROUND_PLANE.marginMm,
1156
+ colour: GROUND_PLANE.light,
1157
+ colour_dark: GROUND_PLANE.dark
1158
+ },
1159
+ provenance: "default",
1160
+ rule: "ground-plane-viewer-only"
1161
+ }
927
1162
  ];
928
1163
  const defaulted = /* @__PURE__ */ new Set();
929
1164
  const top = scene.levels.length - 1;
@@ -943,6 +1178,19 @@ export {
943
1178
  slabRegion,
944
1179
  stairRisers,
945
1180
  stairSolid,
1181
+ OUTDOOR_MM,
1182
+ FENCE_HEIGHT_MM,
1183
+ CORE_POST_PITCH_MM,
1184
+ CORE_POSTS_PER_RUN,
1185
+ FENCE_PROFILES,
1186
+ MAX_FENCE_REPEAT,
1187
+ groundColour,
1188
+ outdoorColour,
1189
+ fenceColour,
1190
+ corePostCount,
1191
+ fenceRuns,
1192
+ fencePosts,
1193
+ fencePieces,
946
1194
  FURNITURE_HEIGHT_MM,
947
1195
  DOOR_POSES,
948
1196
  openLeaf,
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  DOOR_POSES,
4
4
  adaptPlan,
5
5
  buildMesh
6
- } from "./chunk-L2CX7KWM.js";
6
+ } from "./chunk-VXGQYUMN.js";
7
7
  import {
8
8
  SWIFTSHADER_ARGS,
9
9
  checkGlb,
@@ -13,18 +13,18 @@ import {
13
13
  renderReplay,
14
14
  replayHtml,
15
15
  writeGlb
16
- } from "./chunk-OWZWBKMI.js";
16
+ } from "./chunk-LMFD5NP4.js";
17
17
  import {
18
18
  ARCHLANG_3D_VERSION,
19
19
  replayFacts
20
- } from "./chunk-WCWLYIVD.js";
21
- import "./chunk-4SQ5YKKX.js";
20
+ } from "./chunk-6WCS4TAT.js";
21
+ import "./chunk-CX6IVI7I.js";
22
22
  import {
23
23
  storeysOf,
24
24
  timeline,
25
25
  viewLabel,
26
26
  viewMesh
27
- } from "./chunk-EQBMPXB5.js";
27
+ } from "./chunk-TNNJ7CAO.js";
28
28
 
29
29
  // src/cli/run.ts
30
30
  import { readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
@@ -1,5 +1,5 @@
1
1
  import { World } from '@chanmeng666/archlang';
2
- import { B as ReplayView, R as ReplayFacts } from './strip-Nt7eJ-4E.js';
2
+ import { T as ReplayView, R as ReplayFacts } from './strip-CA-IAT0N.js';
3
3
 
4
4
  /**
5
5
  * The metrics strip's numbers (card G4), read from the core's public `describe()` and `lint()` for
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
+ import * as _chanmeng666_archlang from '@chanmeng666/archlang';
1
2
  import { ResolvedPlan, RWall, Point, JoinedCut, loopsToPolygons, World, Diagnostic } from '@chanmeng666/archlang';
2
3
  export { Point } from '@chanmeng666/archlang';
3
- import { a as Scene3D, F as Floor, P as Polygon, M as Mesh3D, b as Pt, c as Shell, d as Ring3, A as Assumption, e as StairFlight, f as Stair, g as MaterialSlot, h as Furniture } from './strip-Nt7eJ-4E.js';
4
- export { D as DoorKind, E as EXPLODE_GAP_MM, i as FINISH_PALETTE, j as FIXTURE_FAMILIES, k as FLOOR_FINISHES, l as FLOOR_FINISH_RULES, m as Fence, n as FloorFinish, K as KIND_PALETTE, o as KindMaterial, L as Level, p as MATERIAL_SLOTS, q as MeshNode, r as Meta, N as NodeKind, t as NodeState, O as Opening, u as Outdoor, v as PALETTE, w as PHASE, x as Provenance, y as ReplayEvent, R as ReplayFacts, z as ReplayState, B as ReplayView, C as Roof, G as STAIR_MATERIAL, H as STOP_LEAD, I as Side, J as SlotMaterial, Q as Source, T as Stage, U as StairLanding, S as StripItem, V as Um, W as WALL_CAP_SRGB, X as Wall, Y as authoringOrder, Z as ease, _ as explodeLifts, $ as finishColour, a0 as floorFinish, a1 as keyFrames, a2 as linearRgb, a3 as slotColour, a4 as slotGroups, a5 as stateAt, a6 as storeysOf, s as stripAt, a7 as timeline, a8 as viewLabel, a9 as viewMesh } from './strip-Nt7eJ-4E.js';
5
- export { F as FactsOptions, r as replayFacts } from './facts-BRIFxHL_.js';
6
- export { B as Box, E as ELEVATION_AZIMUTH, a as ELEVATION_RANGE, b as END_AZIMUTH, c as END_FOV, d as EndCamera, F as FILL, e as FrameCamera, O as Orbit, f as PRESET_NAMES, P as PresetName, S as START_FOV, V as Vec3, g as ViewScene, Z as ZOOM, h as boxOfNodes, i as cameraAtStop, j as cameraStops, k as corners, l as coverage, m as distanceLimits, n as drawingFrame, o as endElevation, p as fitEndCamera, q as frameCamera, r as pivotAbove, s as presetCamera, t as projectBox, u as settledLift, v as stopCount, w as takenLens, x as targetBounds } from './camera-DVOiag0F.js';
4
+ import { a as Scene3D, F as Floor, P as Polygon, M as Mesh3D, b as Pt, c as Shell, d as Ring3, A as Assumption, e as StairFlight, f as Stair, g as MaterialSlot, h as Furniture, i as Fence, G as GroundTint } from './strip-CA-IAT0N.js';
5
+ export { D as DoorKind, E as EXPLODE_GAP_MM, j as FENCE_PALETTE, k as FINISH_PALETTE, l as FIXTURE_FAMILIES, m as FLOOR_FINISHES, n as FLOOR_FINISH_RULES, o as FloorFinish, p as GROUND_PLANE, q as GROUND_ROUGHNESS, r as GROUND_SPLITS, t as GROUND_TINT, u as GROUND_WASH, K as KIND_PALETTE, v as KindMaterial, L as Level, w as MATERIAL_SLOTS, x as MeshNode, y as Meta, N as NodeKind, z as NodeState, O as Opening, B as Outdoor, C as PALETTE, H as PHASE, I as Provenance, J as ReplayEvent, R as ReplayFacts, Q as ReplayState, T as ReplayView, U as Roof, V as SITE_PALETTE, W as STAIR_MATERIAL, X as STOP_LEAD, Y as Side, Z as SlotMaterial, _ as Source, $ as Stage, a0 as StairLanding, S as StripItem, a1 as Um, a2 as WALL_CAP_SRGB, a3 as Wall, a4 as authoringOrder, a5 as ease, a6 as explodeLifts, a7 as finishColour, a8 as floorFinish, a9 as keyFrames, aa as linearRgb, ab as siteColour, ac as slotColour, ad as slotGroups, ae as stateAt, af as storeysOf, s as stripAt, ag as timeline, ah as viewLabel, ai as viewMesh } from './strip-CA-IAT0N.js';
6
+ export { F as FactsOptions, r as replayFacts } from './facts-Dje5wcHh.js';
7
+ export { B as Box, E as ELEVATION_AZIMUTH, a as ELEVATION_RANGE, b as END_AZIMUTH, c as END_FOV, d as EndCamera, F as FILL, e as FrameCamera, O as Orbit, f as PRESET_NAMES, P as PresetName, S as START_FOV, V as Vec3, g as ViewScene, Z as ZOOM, h as boxOfNodes, i as cameraAtStop, j as cameraStops, k as corners, l as coverage, m as distanceLimits, n as drawingFrame, o as endElevation, p as fitEndCamera, q as frameCamera, r as pivotAbove, s as presetCamera, t as projectBox, u as settledLift, v as stopCount, w as takenLens, x as targetBounds } from './camera-DcyxtBjK.js';
7
8
 
8
9
  /** The package's own version, stamped into `meta.tool`. */
9
10
  declare const ARCHLANG_3D_VERSION: string;
@@ -496,4 +497,69 @@ declare function t0Shells(f: Furniture, floor: number): {
496
497
  holesDropped: number;
497
498
  } | null;
498
499
 
499
- export { ARCHLANG_3D_VERSION, type AdaptOptions, type AdaptResult, Assumption, type BuildOptions, type CutSector, DOOR_POSES, type DoorPose, FLOOR_LIFT_UM, FLOOR_OVERLAP_MIN_UM2, FURNITURE_HEIGHT_MM, Floor, type FloorOverlap, Furniture, MIN_CORE, MaterialSlot, Mesh3D, type MeshOptions, type MixedHeightJoint, type OwnedWall, type Ownership, type Part, type Piece, Polygon, Pt, type Refusal, type RefusalCode, type Ring, Ring3, Scene3D, type SectionShape, Shell, Stair, StairFlight, type StairSolid, type Storey, T0_FAMILIES, T0_HANDED, T0_HEIGHT_MM, T0_HUNG_FROM_TOP, T0_MATERIALS, T0_MOUNT_MM, type ValidationIssue, type Warning3D, adaptPlan, assetFor, buildMesh, buildScene3D, clipToConvex, cutSector, floorLifts, floorOverlaps, handedAt, insideCut, mixedHeightJoints, openLeaf, overlapArea, partShell, piecesOf, piecesTouch, prism, rectsOf, sectionRing, sectorBand, slab2d, slabRegion, stairRisers, stairSolid, t0LocalParts, t0Shells, um, umPoint, validateScene3D, wallOwnership };
500
+ /** An outdoor surface's slab, mm: thin, its top at the storey's floor level. */
501
+ declare const OUTDOOR_MM = 50;
502
+ /** A fence's height by style, mm: drafting defaults (a front-garden picket, a pool panel, a post-and-rail). */
503
+ declare const FENCE_HEIGHT_MM: Readonly<Record<string, number>>;
504
+ /**
505
+ * The core's post spacing per style, mm (`POST_PITCH`, `src/elements/fence.ts`, not exported): it
506
+ * draws `postCount` = round(run / pitch), clamped to 1…60, divisions on each straight run, a tick at
507
+ * each division and one at an open fence's far end. The 3D posts stand exactly on those ticks
508
+ * (`fencePosts`); `test/outdoor.test.ts` holds them to the ticks the core draws, across the corpus.
509
+ */
510
+ declare const CORE_POST_PITCH_MM: Readonly<Record<string, number>>;
511
+ /** The core's clamp on a run's divisions (`MIN_POSTS`, `MAX_POSTS`). */
512
+ declare const CORE_POSTS_PER_RUN: readonly [1, 60];
513
+ /**
514
+ * Each style's profile, mm: what stands along a run. A square post stands on every tick the core
515
+ * draws (`CORE_POST_PITCH_MM`); a picket fence adds two rails and its pickets, a panel fence one board
516
+ * the whole height, a post-and-rail fence one rail along the top: the core draws the three as dense
517
+ * ticks, a double line and posts on a single rail.
518
+ */
519
+ interface FenceProfile {
520
+ post: number;
521
+ /** Boards along the run: [depth across it, bottom, top], mm above the base. */
522
+ rails: ReadonlyArray<readonly [number, number, number]>;
523
+ /** Pickets: [width along the run, depth across it, pitch], mm, or none. */
524
+ pickets?: readonly [number, number, number];
525
+ }
526
+ declare const FENCE_PROFILES: Readonly<Record<string, FenceProfile>>;
527
+ /** The most pickets one run takes, whatever its length. */
528
+ declare const MAX_FENCE_REPEAT = 400;
529
+ /** The theme's tint laid on `GROUND_WASH` times over its paper (`materials.ts`). */
530
+ declare function groundColour(tint: GroundTint, theme?: _chanmeng666_archlang.Theme): string;
531
+ /** A surface's 3D colour and where it came from (the ledger's rule). */
532
+ declare function outdoorColour(surface: string): {
533
+ srgb: string;
534
+ rule: "outdoor-colour-theme" | "outdoor-colour-3d";
535
+ };
536
+ /** A fence's colour (its style's, or a picket's for a style this package does not know). */
537
+ declare const fenceColour: (style: string) => string;
538
+ /** The core's `postCount`: a run's divisions for a style (`CORE_POST_PITCH_MM`). */
539
+ declare function corePostCount(lenUm: number, style: string): number;
540
+ /**
541
+ * A fence's runs as the core draws them (`fenceSegments`, then `render`): consecutive points, plus
542
+ * the closing run of a closed fence of three points or more, zero-length runs left out; and whether
543
+ * the runs close into a ring (then the last run's far end is the first run's start, and an open
544
+ * fence's last run takes a post at its far end).
545
+ */
546
+ declare function fenceRuns(f: Pick<Fence, "points" | "closed">): {
547
+ runs: Array<[Pt, Pt]>;
548
+ ring: boolean;
549
+ };
550
+ /** Where the core draws a fence's ticks, so where its posts stand (µm, the plan point, its run). */
551
+ declare function fencePosts(f: Pick<Fence, "points" | "closed" | "style">): Array<{
552
+ at: Pt;
553
+ run: [Pt, Pt];
554
+ }>;
555
+ /**
556
+ * A fence's plan pieces, each with its [bottom, top] in mm above its base: a post on every tick the
557
+ * core draws (`fencePosts`), and per run its rails and its pickets, each a box aligned with the run.
558
+ * A fence with no run of positive length has no piece.
559
+ */
560
+ declare function fencePieces(f: Pick<Fence, "points" | "closed" | "style">, profile: FenceProfile, height: number): Array<{
561
+ poly: Polygon;
562
+ z: readonly [number, number];
563
+ }>;
564
+
565
+ export { ARCHLANG_3D_VERSION, type AdaptOptions, type AdaptResult, Assumption, type BuildOptions, CORE_POSTS_PER_RUN, CORE_POST_PITCH_MM, type CutSector, DOOR_POSES, type DoorPose, FENCE_HEIGHT_MM, FENCE_PROFILES, FLOOR_LIFT_UM, FLOOR_OVERLAP_MIN_UM2, FURNITURE_HEIGHT_MM, Fence, type FenceProfile, Floor, type FloorOverlap, Furniture, GroundTint, MAX_FENCE_REPEAT, MIN_CORE, MaterialSlot, Mesh3D, type MeshOptions, type MixedHeightJoint, OUTDOOR_MM, type OwnedWall, type Ownership, type Part, type Piece, Polygon, Pt, type Refusal, type RefusalCode, type Ring, Ring3, Scene3D, type SectionShape, Shell, Stair, StairFlight, type StairSolid, type Storey, T0_FAMILIES, T0_HANDED, T0_HEIGHT_MM, T0_HUNG_FROM_TOP, T0_MATERIALS, T0_MOUNT_MM, type ValidationIssue, type Warning3D, adaptPlan, assetFor, buildMesh, buildScene3D, clipToConvex, corePostCount, cutSector, fenceColour, fencePieces, fencePosts, fenceRuns, floorLifts, floorOverlaps, groundColour, handedAt, insideCut, mixedHeightJoints, openLeaf, outdoorColour, overlapArea, partShell, piecesOf, piecesTouch, prism, rectsOf, sectionRing, sectorBand, slab2d, slabRegion, stairRisers, stairSolid, t0LocalParts, t0Shells, um, umPoint, validateScene3D, wallOwnership };