@chanmeng666/archlang-3d 0.8.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,32 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.8.1] - 2026-11-15
6
+
7
+ The core peer range stays `^1.61.0` (`MIN_CORE`): nothing below reads a core export that 1.61.0 lacks.
8
+
9
+ ### Fixed
10
+
11
+ - A contact-shadow band no longer crosses a narrow slot into the wall beyond it (card RM8.8b): where
12
+ another wall face stands parallel to a band's own and facing it closer than two bands, each of the
13
+ two bands takes half the gap. In the stress plan with a doorway leaving a 100 mm slot in a thicker
14
+ wall, the 188 mm bands crossed the slot and showed 13 mm beyond the far face; in
15
+ `hexagon-pavilion` the drum's and the east and west spokes' bands crossed the 52 mm between them.
16
+ No other shipped plan's bands move, so the key frames, posters and videos are unchanged; the
17
+ Mesh3D and GLB are untouched (the bands are the viewer's).
18
+ - `npm -w packages/archlang-3d run e2e -- <file>` now filters both of its passes (card RM8.8b): npm
19
+ appended the filter to the frame-budget pass only, so every other e2e file ran regardless. The
20
+ script is one runner (`scripts/e2e.ts`) that gives each pass the filters that select its files and
21
+ skips a pass they select none of; with no filter it runs the same two passes as before.
22
+
23
+ ### Changed
24
+
25
+ - The contact shadows' lookups cost less on a long thin plan and on a many-sided room (card RM8.8b):
26
+ the faces are listed in near-square grid cells, about two a face, and a cell lists a face only when
27
+ the two overlap (an exact test), not every face whose box reaches it. Tests a lookup makes fall
28
+ from 36.9 to 4.6 on a row of 400 rooms, and from 545.5 to 62.2 on a 2880-sided round room. The
29
+ bands are byte for byte the same.
30
+
5
31
  ## [0.8.0] - 2026-11-14
6
32
 
7
33
  The core peer range rises to `^1.61.0` (`MIN_CORE`): the winder treads below are cut on the core's `winderTreads`, new in core 1.61.0, as the stairs read `treadCount` from 1.57.0. The read stays feature-detected, so a core below the floor still builds every plan, a `winders` landing level (`stair-winders-not-read`). The sixteen new families' generators and the new floor and ground finishes come into use only with a core that knows their words, 1.61.0; an older core never hands them a piece.
package/dist/browser.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  faceParts,
5
5
  joinedGroups,
6
6
  wallOutline
7
- } from "./chunk-MXKKNJPU.js";
7
+ } from "./chunk-JQTG6BDR.js";
8
8
  import {
9
9
  PRESET_LABELS,
10
10
  PREVIEW_ABOUT_URL,
@@ -3905,7 +3905,7 @@ function floorLifts(floors, overlaps) {
3905
3905
  }
3906
3906
 
3907
3907
  // package.json
3908
- var version = "0.8.0";
3908
+ var version = "0.8.1";
3909
3909
 
3910
3910
  // src/scene3d/build.ts
3911
3911
  import * as core2 from "@chanmeng666/archlang";
@@ -24,7 +24,7 @@ import {
24
24
  t0Shells,
25
25
  wallOwnership,
26
26
  where
27
- } from "./chunk-B4PZWWSP.js";
27
+ } from "./chunk-33J3YGNF.js";
28
28
  import {
29
29
  CONTACT_SHADOW,
30
30
  FENCE_PALETTE,
@@ -493,13 +493,27 @@ function contains(f, q) {
493
493
  const s3 = cross(f.a[0] - f.c[0], f.a[1] - f.c[1], q[0] - f.c[0], q[1] - f.c[1]);
494
494
  return s1 >= 0 && s2 >= 0 && s3 >= 0 || s1 <= 0 && s2 <= 0 && s3 <= 0;
495
495
  }
496
- var GRID_MAX = 64;
496
+ var CELLS_PER_TRI = 2;
497
+ var CELLS_MAX = 1 << 16;
498
+ function overlaps(t, x0, z0, x1, z1) {
499
+ return Math.max(t.a[0], t.b[0], t.c[0]) >= x0 && Math.min(t.a[0], t.b[0], t.c[0]) <= x1 && Math.max(t.a[1], t.b[1], t.c[1]) >= z0 && Math.min(t.a[1], t.b[1], t.c[1]) <= z1 && !separates(t.a, t.b, t.c, x0, z0, x1, z1) && !separates(t.b, t.c, t.a, x0, z0, x1, z1) && !separates(t.c, t.a, t.b, x0, z0, x1, z1);
500
+ }
501
+ function separates(p, q, r, x0, z0, x1, z1) {
502
+ const ux = q[0] - p[0];
503
+ const uz = q[1] - p[1];
504
+ const side = Math.sign(cross(ux, uz, r[0] - p[0], r[1] - p[1]));
505
+ if (side === 0) return false;
506
+ return side * cross(ux, uz, x0 - p[0], z0 - p[1]) < 0 && side * cross(ux, uz, x1 - p[0], z0 - p[1]) < 0 && side * cross(ux, uz, x1 - p[0], z1 - p[1]) < 0 && side * cross(ux, uz, x0 - p[0], z1 - p[1]) < 0;
507
+ }
497
508
  var TriGrid = class {
509
+ /** The grid's corner, its cells' size and their count across and down (µm; read by the tests). */
498
510
  x0;
499
511
  z0;
500
512
  w;
501
513
  h;
502
- k;
514
+ kx;
515
+ kz;
516
+ /** Each cell's triangles (a hole where a cell has none). */
503
517
  cells;
504
518
  constructor(tris) {
505
519
  let [x0, z0, x1, z1] = [Infinity, Infinity, -Infinity, -Infinity];
@@ -510,18 +524,43 @@ var TriGrid = class {
510
524
  if (p[1] < z0) z0 = p[1];
511
525
  if (p[1] > z1) z1 = p[1];
512
526
  }
513
- this.k = tris.length === 0 ? 0 : Math.max(1, Math.min(GRID_MAX, Math.ceil(Math.sqrt(tris.length))));
514
527
  this.x0 = x0;
515
528
  this.z0 = z0;
516
- this.w = this.k === 0 ? 1 : Math.max(1, Math.ceil((x1 - x0 + 1) / this.k));
517
- this.h = this.k === 0 ? 1 : Math.max(1, Math.ceil((z1 - z0 + 1) / this.k));
518
- this.cells = Array.from({ length: this.k * this.k }, () => []);
529
+ if (tris.length === 0) {
530
+ [this.kx, this.kz, this.w, this.h] = [0, 0, 1, 1];
531
+ this.cells = [];
532
+ return;
533
+ }
534
+ const sx = x1 - x0 + 1;
535
+ const sz = z1 - z0 + 1;
536
+ const target = Math.min(CELLS_MAX, CELLS_PER_TRI * tris.length);
537
+ const s = Math.sqrt(sx * sz / target);
538
+ this.kx = Math.max(1, Math.min(target, Math.ceil(sx / s)));
539
+ this.kz = Math.max(1, Math.min(Math.floor(CELLS_MAX / this.kx), Math.ceil(sz / s)));
540
+ this.w = Math.max(1, Math.ceil(sx / this.kx));
541
+ this.h = Math.max(1, Math.ceil(sz / this.kz));
542
+ this.cells = new Array(this.kx * this.kz);
519
543
  for (const t of tris) {
520
- const xs = [t.a[0], t.b[0], t.c[0]];
521
- const zs = [t.a[1], t.b[1], t.c[1]];
522
- const [i0, i1] = [this.col(Math.min(...xs)), this.col(Math.max(...xs))];
523
- const [j0, j1] = [this.row(Math.min(...zs)), this.row(Math.max(...zs))];
524
- for (let j = j0; j <= j1; j++) for (let i = i0; i <= i1; i++) this.cells[j * this.k + i]?.push(t);
544
+ const i0 = this.col(Math.min(t.a[0], t.b[0], t.c[0]));
545
+ const i1 = this.col(Math.max(t.a[0], t.b[0], t.c[0]));
546
+ const j0 = this.row(Math.min(t.a[1], t.b[1], t.c[1]));
547
+ const j1 = this.row(Math.max(t.a[1], t.b[1], t.c[1]));
548
+ for (let j = j0; j <= j1; j++) {
549
+ const cz0 = this.z0 + j * this.h;
550
+ const cz1 = cz0 + this.h;
551
+ const [lo, hi] = rowExtent(t, cz0, cz1);
552
+ const ilo = this.col(lo);
553
+ const ihi = this.col(hi);
554
+ const to = Math.min(i1, ihi + 1);
555
+ for (let i = Math.max(i0, ilo - 1); i <= to; i++) {
556
+ const cx0 = this.x0 + i * this.w;
557
+ if (!(i > ilo && i < ihi || overlaps(t, cx0, cz0, cx0 + this.w, cz1))) continue;
558
+ const c = j * this.kx + i;
559
+ const list = this.cells[c];
560
+ if (list) list.push(t);
561
+ else this.cells[c] = [t];
562
+ }
563
+ }
525
564
  }
526
565
  }
527
566
  col(x) {
@@ -531,23 +570,43 @@ var TriGrid = class {
531
570
  return Math.floor((z - this.z0) / this.h);
532
571
  }
533
572
  at(q) {
534
- if (this.k === 0) return [];
573
+ if (this.kx === 0) return [];
535
574
  const i = this.col(q[0]);
536
575
  const j = this.row(q[1]);
537
- if (i < 0 || j < 0 || i >= this.k || j >= this.k) return [];
538
- return this.cells[j * this.k + i] ?? [];
576
+ if (i < 0 || j < 0 || i >= this.kx || j >= this.kz) return [];
577
+ return this.cells[j * this.kx + i] ?? [];
539
578
  }
540
579
  /** The triangles in the cells a plan box covers, each once (callers sort what they derive). */
541
580
  near(x0, z0, x1, z1) {
542
- if (this.k === 0) return [];
543
- const clamp = (v) => Math.max(0, Math.min(this.k - 1, v));
581
+ if (this.kx === 0) return [];
582
+ const ci = (v) => Math.max(0, Math.min(this.kx - 1, v));
583
+ const cj = (v) => Math.max(0, Math.min(this.kz - 1, v));
544
584
  const seen = /* @__PURE__ */ new Set();
545
- for (let j = clamp(this.row(z0)); j <= clamp(this.row(z1)); j++)
546
- for (let i = clamp(this.col(x0)); i <= clamp(this.col(x1)); i++)
547
- for (const t of this.cells[j * this.k + i] ?? []) seen.add(t);
585
+ for (let j = cj(this.row(z0)); j <= cj(this.row(z1)); j++)
586
+ for (let i = ci(this.col(x0)); i <= ci(this.col(x1)); i++)
587
+ for (const t of this.cells[j * this.kx + i] ?? []) seen.add(t);
548
588
  return [...seen];
549
589
  }
550
590
  };
591
+ function rowExtent(t, z0, z1) {
592
+ let lo = Infinity;
593
+ let hi = -Infinity;
594
+ const take = (x) => {
595
+ if (x < lo) lo = x;
596
+ if (x > hi) hi = x;
597
+ };
598
+ const ps = [t.a, t.b, t.c];
599
+ for (const p of ps) if (p[1] >= z0 && p[1] <= z1) take(p[0]);
600
+ for (let k = 0; k < 3; k++) {
601
+ const p = ps[k];
602
+ const q = ps[(k + 1) % 3];
603
+ if (p[1] === q[1]) continue;
604
+ for (const z of [z0, z1])
605
+ if ((p[1] - z) * (q[1] - z) < 0) take(p[0] + (q[0] - p[0]) * (z - p[1]) / (q[1] - p[1]));
606
+ }
607
+ if (lo > hi) return [Math.min(t.a[0], t.b[0], t.c[0]), Math.max(t.a[0], t.b[0], t.c[0])];
608
+ return [lo, hi];
609
+ }
551
610
  function flatFaces(n, up, y, out) {
552
611
  const p = n.positions;
553
612
  for (let i = 0; i < n.indices.length; i += 3) {
@@ -561,6 +620,87 @@ function flatFaces(n, up, y, out) {
561
620
  if (up ? turn < 0 : turn > 0) out.push({ a, b, c, y: ya });
562
621
  }
563
622
  }
623
+ function narrowed(segs, band) {
624
+ const groups = /* @__PURE__ */ new Map();
625
+ for (const s of segs) {
626
+ const l = planLine(s.a[0], s.a[1], s.b[0], s.b[1]);
627
+ const key = `${l.dx},${l.dz}`;
628
+ const g = groups.get(key);
629
+ if (g) g.push(s);
630
+ else groups.set(key, [s]);
631
+ }
632
+ const near = /* @__PURE__ */ new Map();
633
+ const along = (s, o) => {
634
+ const dx = s.b[0] - s.a[0];
635
+ const dz = s.b[1] - s.a[1];
636
+ const l2 = dx * dx + dz * dz;
637
+ const ta = ((o.a[0] - s.a[0]) * dx + (o.a[1] - s.a[1]) * dz) / l2;
638
+ const tb = ((o.b[0] - s.a[0]) * dx + (o.b[1] - s.a[1]) * dz) / l2;
639
+ const t0 = Math.max(0, Math.min(ta, tb));
640
+ const t1 = Math.min(1, Math.max(ta, tb));
641
+ return t1 > t0 ? [t0, t1] : void 0;
642
+ };
643
+ const note = (s, o, w) => {
644
+ if (w >= band(s)) return;
645
+ const t = along(s, o);
646
+ if (!t) return;
647
+ const list = near.get(s);
648
+ if (list) list.push({ t0: t[0], t1: t[1], w });
649
+ else near.set(s, [{ t0: t[0], t1: t[1], w }]);
650
+ };
651
+ for (const key of [...groups.keys()].sort()) {
652
+ const g = groups.get(key);
653
+ if (g.length < 2) continue;
654
+ const [dx, dz] = key.split(",").map(Number);
655
+ const len = lengthOf(dx, dz);
656
+ let widest = 0;
657
+ for (const s of g) widest = Math.max(widest, band(s));
658
+ const reach = 2e3 * widest;
659
+ const items = g.map((s) => {
660
+ const [ta, tb] = [(dx * s.a[0] + dz * s.a[1]) / len, (dx * s.b[0] + dz * s.b[1]) / len];
661
+ return { s, off: (dx * s.a[1] - dz * s.a[0]) / len, lo: Math.min(ta, tb), hi: Math.max(ta, tb) };
662
+ }).sort((p, q) => p.lo - q.lo || p.off - q.off);
663
+ let active = [];
664
+ for (const it of items) {
665
+ active = active.filter((o) => o.hi > it.lo);
666
+ for (const o of active) {
667
+ if (Math.abs(o.off - it.off) > reach) continue;
668
+ const [s, t] = [it.s, o.s];
669
+ const fs = frame(s);
670
+ const ft = frame(t);
671
+ if (fs.d[0] * ft.d[0] + fs.d[1] * ft.d[1] >= 0) continue;
672
+ const ex = t.a[0] - s.a[0];
673
+ const ez = t.a[1] - s.a[1];
674
+ if (cross(fs.d[0], fs.d[1], ex, ez) >= 0) continue;
675
+ const c = BigInt(fs.d[0]) * BigInt(ez) - BigInt(fs.d[1]) * BigInt(ex);
676
+ const w = Math.max(0, -Number(c) / fs.len / 2e3);
677
+ note(s, t, w);
678
+ note(t, s, w);
679
+ }
680
+ active.push(it);
681
+ }
682
+ }
683
+ return segs.flatMap((s) => {
684
+ const list = near.get(s);
685
+ if (!list) return [s];
686
+ const own = band(s);
687
+ const ts = [.../* @__PURE__ */ new Set([0, 1, ...list.flatMap((c) => [c.t0, c.t1])])].sort((x, y) => x - y);
688
+ const f = frame(s);
689
+ const at = (t) => t === 0 ? s.a : t === 1 ? s.b : [whole(s.a[0] + f.d[0] * t), whole(s.a[1] + f.d[1] * t)];
690
+ const out = [];
691
+ for (let k = 0; k + 1 < ts.length; k++) {
692
+ const [t0, t1] = [ts[k], ts[k + 1]];
693
+ const m = (t0 + t1) / 2;
694
+ let w = own;
695
+ for (const c of list) if (c.t0 <= m && m <= c.t1 && c.w < w) w = c.w;
696
+ const last = out[out.length - 1];
697
+ const lw = last ? last.w ?? own : void 0;
698
+ if (last && lw === w) last.b = at(t1);
699
+ else out.push({ a: at(t0), b: at(t1), node: s.node, ...w < own ? { w } : {} });
700
+ }
701
+ return out.filter((p) => p.a[0] !== p.b[0] || p.a[1] !== p.b[1]);
702
+ });
703
+ }
564
704
  function outline(tris) {
565
705
  const lines = /* @__PURE__ */ new Map();
566
706
  for (const { node, p } of tris) {
@@ -661,6 +801,9 @@ var scaled = (v, mm) => [
661
801
  var plus = (p, o) => [p[0] + o[0], p[1] + o[1]];
662
802
  var MAX_FAN = 8;
663
803
  function contactShadows(nodes, ground, lines) {
804
+ return contactShadowsWith(nodes, ground, lines, (tris) => new TriGrid(tris));
805
+ }
806
+ function contactShadowsWith(nodes, ground, lines, lookup) {
664
807
  const counts = {
665
808
  edges: 0,
666
809
  convex: 0,
@@ -685,7 +828,7 @@ function contactShadows(nodes, ground, lines) {
685
828
  for (const [n] of here)
686
829
  if (n.kind === "floor" || n.kind === "slab" || n.kind === "outdoor" || n.flat === true)
687
830
  flatFaces(n, true, void 0, faces);
688
- const receivers = new TriGrid(faces);
831
+ const receivers = lookup(faces);
689
832
  const groundY = level === lowest ? ground?.y : void 0;
690
833
  const over = (qs) => {
691
834
  let best;
@@ -729,7 +872,7 @@ function contactShadows(nodes, ground, lines) {
729
872
  for (const [n] of walls) e = Math.min(e, yRange(n)[0]);
730
873
  const tris = [];
731
874
  for (const [n, i] of walls) downFaces(n, i, e, tris);
732
- const solid = new TriGrid(tris.map((t) => ({ a: t.p[0], b: t.p[1], c: t.p[2], y: e, node: t.node })));
875
+ const solid = lookup(tris.map((t) => ({ a: t.p[0], b: t.p[1], c: t.p[2], y: e, node: t.node })));
733
876
  const inSolid = (q) => {
734
877
  counts.probes++;
735
878
  for (const f of solid.at(q)) {
@@ -738,7 +881,7 @@ function contactShadows(nodes, ground, lines) {
738
881
  }
739
882
  return false;
740
883
  };
741
- const segs = outline(tris).flatMap((s) => {
884
+ const cutSegs = outline(tris).flatMap((s) => {
742
885
  const f = frame(s);
743
886
  const ts = [0, 1];
744
887
  const [bx0, bx1] = [Math.min(s.a[0], s.b[0]), Math.max(s.a[0], s.b[0])];
@@ -778,7 +921,8 @@ function contactShadows(nodes, ground, lines) {
778
921
  if (from !== void 0) kept.push({ a: at(from), b: s.b, node: s.node });
779
922
  return kept.filter((k) => k.a[0] !== k.b[0] || k.a[1] !== k.b[1]);
780
923
  });
781
- const bandOf = (s) => nodes[s.node]?.band ?? 0;
924
+ const bandOf = (s) => s.w ?? nodes[s.node]?.band ?? 0;
925
+ const segs = narrowed(cutSegs, bandOf);
782
926
  const pk = (p) => `${p[0]},${p[1]}`;
783
927
  const ending = /* @__PURE__ */ new Map();
784
928
  const starting = /* @__PURE__ */ new Map();
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ARCHLANG_3D_VERSION,
3
3
  validateScene3D
4
- } from "./chunk-B4PZWWSP.js";
4
+ } from "./chunk-33J3YGNF.js";
5
5
  import {
6
6
  PREVIEW_LABEL,
7
7
  PREVIEW_LIMITS,
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  DOOR_POSES,
4
4
  adaptPlan,
5
5
  buildMesh
6
- } from "./chunk-WARUDAOQ.js";
6
+ } from "./chunk-CYSES7C3.js";
7
7
  import {
8
8
  SWIFTSHADER_ARGS,
9
9
  checkGlb,
@@ -13,11 +13,11 @@ import {
13
13
  renderReplay,
14
14
  replayHtml,
15
15
  writeGlb
16
- } from "./chunk-MCASL4MM.js";
16
+ } from "./chunk-WOEJKIXN.js";
17
17
  import {
18
18
  ARCHLANG_3D_VERSION,
19
19
  replayFacts
20
- } from "./chunk-B4PZWWSP.js";
20
+ } from "./chunk-33J3YGNF.js";
21
21
  import "./chunk-VMVKI2WQ.js";
22
22
  import {
23
23
  storeysOf,
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  contactFade,
3
3
  contactShadows
4
- } from "./chunk-MXKKNJPU.js";
4
+ } from "./chunk-JQTG6BDR.js";
5
5
  import {
6
6
  CORE_POSTS_PER_RUN,
7
7
  CORE_POST_PITCH_MM,
@@ -32,7 +32,7 @@ import {
32
32
  stairRisers,
33
33
  stairSolid,
34
34
  storeyTrim
35
- } from "./chunk-WARUDAOQ.js";
35
+ } from "./chunk-CYSES7C3.js";
36
36
  import {
37
37
  ARCHLANG_3D_VERSION,
38
38
  FLOOR_LIFT_UM,
@@ -67,7 +67,7 @@ import {
67
67
  umPoint,
68
68
  validateScene3D,
69
69
  wallOwnership
70
- } from "./chunk-B4PZWWSP.js";
70
+ } from "./chunk-33J3YGNF.js";
71
71
  import {
72
72
  CONTACT_SHADOW,
73
73
  ELEVATION_AZIMUTH,
package/dist/node.js CHANGED
@@ -20,10 +20,10 @@ import {
20
20
  signedVolume,
21
21
  viewerScript,
22
22
  writeGlb
23
- } from "./chunk-MCASL4MM.js";
23
+ } from "./chunk-WOEJKIXN.js";
24
24
  import {
25
25
  replayFacts
26
- } from "./chunk-B4PZWWSP.js";
26
+ } from "./chunk-33J3YGNF.js";
27
27
  import {
28
28
  PREVIEW_ABOUT_URL,
29
29
  PREVIEW_LABEL,