@chanmeng666/archlang-3d 0.6.0 → 0.8.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.
@@ -47,28 +47,76 @@ var PALETTE = {
47
47
  water: m("#a3c6d0", 0.1, 0, 0.7)
48
48
  };
49
49
  var STAIR_MATERIAL = "wood";
50
+ var STAIR_RAIL_MATERIAL = "wood_dark";
51
+ var DOOR_OAK = m("#c2a27e", 0.7);
52
+ var FRAME_BRONZE = m("#55534f", 0.5);
50
53
  var KIND_PALETTE = {
51
54
  slab: m("#bdb6ab", 0.9),
52
55
  column: m("#e6e1d8", 0.85),
53
56
  wall: m("#f2f0eb", 0.9),
54
- door: m("#c2a27e", 0.7),
55
- "window:frame": m("#55534f", 0.5),
57
+ door: DOOR_OAK,
58
+ "window:frame": FRAME_BRONZE,
56
59
  "window:glass": m("#bcd6e0", 0.05, 0, 0.4),
60
+ // The trim (card RM8.6): a window's reveal in its frame's bronze, its exterior sill in the pale
61
+ // stone and its interior board in the oak of the palette; a cased opening's lining and casing in
62
+ // the doors' oak (a door's own lining and casing are `door`). Drafting defaults, ledgered once per
63
+ // Mesh3D as `trim-material-default` from `TRIM_MATERIAL`.
64
+ "window:reveal": FRAME_BRONZE,
65
+ "window:sill": PALETTE.stone,
66
+ "window:board": PALETTE.wood,
67
+ "opening:lining": DOOR_OAK,
68
+ "opening:casing": DOOR_OAK,
57
69
  opening: m("#e6e1d8", 0.85),
58
70
  furniture: m("#d6cec1", 0.9),
59
71
  roof: m("#9c958a", 0.9),
60
72
  "wall:demolish": m("#c8553d", 0.9, 0, 0.3),
61
73
  // A stair (card X3): the core gives it no material, so the ledgered default (`STAIR_MATERIAL`,
62
74
  // `stair-material-default`): that slot's own entry, never a second copy of its colour.
63
- stair: PALETTE[STAIR_MATERIAL]
75
+ stair: PALETTE[STAIR_MATERIAL],
76
+ "stair:rail": PALETTE[STAIR_RAIL_MATERIAL]
77
+ };
78
+ var TRIM_MATERIAL = {
79
+ "door:lining": { material: "door", srgb: KIND_PALETTE.door.srgb },
80
+ "door:casing": { material: "door", srgb: KIND_PALETTE.door.srgb },
81
+ "opening:lining": { material: "opening:lining", srgb: KIND_PALETTE["opening:lining"].srgb },
82
+ "opening:casing": { material: "opening:casing", srgb: KIND_PALETTE["opening:casing"].srgb },
83
+ "window:reveal": { material: "window:reveal", srgb: KIND_PALETTE["window:reveal"].srgb },
84
+ "window:sill": { material: "window:sill", srgb: KIND_PALETTE["window:sill"].srgb },
85
+ "window:board": { material: "window:board", srgb: KIND_PALETTE["window:board"].srgb }
64
86
  };
65
87
  var WALL_CAP_SRGB = "#8f877d";
66
- var FLOOR_FINISHES = ["timber", "tile", "neutral"];
88
+ var FLOOR_FINISHES = [
89
+ "timber",
90
+ "tile",
91
+ "neutral",
92
+ "carpeting",
93
+ "stone",
94
+ "deck",
95
+ "paving",
96
+ "concrete"
97
+ ];
67
98
  var FINISH_PALETTE = {
68
99
  timber: m("#cdb596", 0.6),
69
100
  tile: m("#e3e1db", 0.35),
70
- neutral: m("#e8e2d7", 0.9)
101
+ neutral: m("#e8e2d7", 0.9),
102
+ carpeting: PALETTE.wool,
103
+ stone: PALETTE.stone,
104
+ deck: PALETTE.wood,
105
+ paving: m("#ab9f87", 0.85),
106
+ concrete: m("#c9c5be", 0.6)
107
+ };
108
+ var FLOOR_WORD_FINISH = {
109
+ tile: "tile",
110
+ paving: "paving",
111
+ deck: "deck",
112
+ concrete: "concrete",
113
+ timber: "timber",
114
+ carpeting: "carpeting",
115
+ stone: "stone"
71
116
  };
117
+ function wordFinish(word) {
118
+ return word !== void 0 && Object.hasOwn(FLOOR_WORD_FINISH, word) ? FLOOR_WORD_FINISH[word] : void 0;
119
+ }
72
120
  var FLOOR_FINISH_RULES = [
73
121
  ["tile", ["bath", "wc", "utility"]],
74
122
  ["timber", ["living", "dining", "bedroom", "office", "hall", "circulation"]],
@@ -87,18 +135,23 @@ var GROUND_TINT = {
87
135
  water: "water",
88
136
  driveway: "paving",
89
137
  patio: "paving",
90
- balcony: "paving"
138
+ balcony: "paving",
139
+ sand: "paving",
140
+ soil: "paving"
91
141
  };
92
142
  var GROUND_WASH = 6;
93
143
  var SITE_PALETTE = {
94
144
  gravel: m("#cbc3b4", 0.95),
95
- tarmac: m("#8c8984", 0.85)
145
+ tarmac: m("#8c8984", 0.85),
146
+ sand: m("#dcc9a3", 0.95)
96
147
  };
97
148
  var GROUND_SPLITS = {
98
149
  planting: PALETTE.foliage,
99
150
  deck: PALETTE.wood,
100
151
  gravel: SITE_PALETTE.gravel,
101
- driveway: SITE_PALETTE.tarmac
152
+ driveway: SITE_PALETTE.tarmac,
153
+ sand: SITE_PALETTE.sand,
154
+ soil: PALETTE.soil
102
155
  };
103
156
  var GROUND_ROUGHNESS = { lawn: 0.95, paving: 0.85, water: 0.1 };
104
157
  var FENCE_PALETTE = {
@@ -107,6 +160,18 @@ var FENCE_PALETTE = {
107
160
  post: PALETTE.wood_dark
108
161
  };
109
162
  var GROUND_PLANE = { light: "#e2ddd3", dark: "#16293d", marginMm: 6e3 };
163
+ var CONTACT_SHADOW = {
164
+ wall: { of: 0.75, minMm: 80, maxMm: 200 },
165
+ furniture: { of: 0.12, minMm: 30, maxMm: 120 },
166
+ fence: { of: 1.5, minMm: 40, maxMm: 120 },
167
+ stairThicknessMm: 100,
168
+ alpha: { floor: 0.2, corner: 0.12, furniture: 0.18 },
169
+ alphaDark: { floor: 0.3, corner: 0.18, furniture: 0.27 },
170
+ liftMm: 1
171
+ };
172
+ function contactBandMm(rule, size) {
173
+ return Math.min(rule.maxMm, Math.max(rule.minMm, Math.round(rule.of * size)));
174
+ }
110
175
  function siteColour(own, theme, toward) {
111
176
  if (theme === "light") return own;
112
177
  const mix = (i) => {
@@ -306,7 +371,7 @@ function timeline(mesh) {
306
371
  if (isGhost(n)) rise = [a, w];
307
372
  else if (wallRise.has(n.key)) rise = wallRise.get(n.key);
308
373
  else if (thingRise.has(n.key)) rise = thingRise.get(n.key);
309
- else if (n.kind === "door" || n.kind === "window")
374
+ else if (n.kind === "door" || n.kind === "window" || n.kind === "opening")
310
375
  rise = hostRise.get(`${n.level}/${String(n.extras.host)}`) ?? [a, w];
311
376
  else if (isFlat(n)) {
312
377
  const at = appearOf.get(n.key) ?? a;
@@ -608,14 +673,41 @@ function targetBounds(box) {
608
673
  };
609
674
  }
610
675
 
676
+ // src/mesh/c16.ts
677
+ var C16 = [
678
+ 1,
679
+ 0.9238795325112867,
680
+ Math.SQRT1_2,
681
+ 0.3826834323650898,
682
+ 0,
683
+ -0.3826834323650898,
684
+ -Math.SQRT1_2,
685
+ -0.9238795325112867,
686
+ -1,
687
+ -0.9238795325112867,
688
+ -Math.SQRT1_2,
689
+ -0.3826834323650898,
690
+ 0,
691
+ 0.3826834323650898,
692
+ Math.SQRT1_2,
693
+ 0.9238795325112867
694
+ ];
695
+ var S16 = C16.map((_, k) => C16[(k + 12) % 16]);
696
+
611
697
  export {
698
+ C16,
699
+ S16,
612
700
  MATERIAL_SLOTS,
613
701
  PALETTE,
614
702
  STAIR_MATERIAL,
703
+ STAIR_RAIL_MATERIAL,
615
704
  KIND_PALETTE,
705
+ TRIM_MATERIAL,
616
706
  WALL_CAP_SRGB,
617
707
  FLOOR_FINISHES,
618
708
  FINISH_PALETTE,
709
+ FLOOR_WORD_FINISH,
710
+ wordFinish,
619
711
  FLOOR_FINISH_RULES,
620
712
  floorFinish,
621
713
  GROUND_TINT,
@@ -625,6 +717,8 @@ export {
625
717
  GROUND_ROUGHNESS,
626
718
  FENCE_PALETTE,
627
719
  GROUND_PLANE,
720
+ CONTACT_SHADOW,
721
+ contactBandMm,
628
722
  siteColour,
629
723
  linearRgb,
630
724
  slotColour,
@@ -1,13 +1,14 @@
1
1
  import {
2
2
  ARCHLANG_3D_VERSION,
3
3
  validateScene3D
4
- } from "./chunk-6WCS4TAT.js";
4
+ } from "./chunk-B4PZWWSP.js";
5
5
  import {
6
6
  PREVIEW_LABEL,
7
7
  PREVIEW_LIMITS,
8
8
  VIEW_CONTROLS_LABEL,
9
+ noticeLevelLabel,
9
10
  replayPayload
10
- } from "./chunk-CX6IVI7I.js";
11
+ } from "./chunk-VMVKI2WQ.js";
11
12
  import {
12
13
  FENCE_PALETTE,
13
14
  FINISH_PALETTE,
@@ -20,7 +21,7 @@ import {
20
21
  keyFrames,
21
22
  linearRgb,
22
23
  slotGroups
23
- } from "./chunk-TNNJ7CAO.js";
24
+ } from "./chunk-LNIVDMPG.js";
24
25
 
25
26
  // src/world.ts
26
27
  import { readFileSync, realpathSync, statSync } from "node:fs";
@@ -141,7 +142,9 @@ ${readFileSync2(join(dir, "LICENSE"), "utf8")}`;
141
142
  }
142
143
  var escapeHtml = (s) => s.replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c]);
143
144
  async function replayHtml(mesh, opts) {
144
- const payload = replayPayload(mesh, opts);
145
+ const { notices: given, ...payloadOpts } = opts;
146
+ const notices = given ?? [];
147
+ const payload = replayPayload(mesh, payloadOpts);
145
148
  const json = JSON.stringify(payload).replace(/</g, "\\u003c");
146
149
  const script = (await viewerScript()).replace(/<\/script/gi, "<\\/script");
147
150
  const bg = payload.theme === "dark" ? "#0f2235" : "#f7f5f0";
@@ -170,7 +173,10 @@ canvas:focus-visible{outline:2px solid ${fg};outline-offset:2px}
170
173
  .archlang-views button{font:inherit;font-size:13px;padding:2px 10px;border:1px solid ${fg};border-radius:4px;background:transparent;color:${fg};cursor:pointer}
171
174
  .archlang-views button[aria-pressed=true]{background:${fg};color:${bg}}
172
175
  .archlang-views-storeys{display:inline-flex;align-items:center;gap:4px;margin-left:8px}
173
- .archlang-views-hint{flex-basis:100%;text-align:center;font-size:12px;opacity:.8}
176
+ .archlang-views-hint{flex-basis:100%;text-align:center;font-size:12px;opacity:.8}${notices.length > 0 ? `
177
+ .archlang-notices{display:grid;gap:4px;width:min(720px,90vw)}
178
+ .archlang-notices p{opacity:1;padding:6px 10px;border-left:3px solid #b45309;background:rgba(180,83,9,.08)}
179
+ .archlang-notices code{font-size:11.5px;margin-right:6px}` : ""}
174
180
  </style>
175
181
  </head>
176
182
  <body>
@@ -180,7 +186,10 @@ canvas:focus-visible{outline:2px solid ${fg};outline-offset:2px}
180
186
  <div id="archlang-replay-strip" role="group" aria-label="Plan facts" hidden></div>` : ""}
181
187
  </div>
182
188
  <input id="archlang-replay-t" type="range" min="0" max="1" step="0.001" value="0" aria-label="Replay position">
183
- <div id="archlang-replay-views"></div>
189
+ <div id="archlang-replay-views"></div>${notices.length > 0 ? `
190
+ <div class="archlang-notices" role="note">
191
+ ${notices.map((n) => `<p>${n.level === void 0 ? "" : `${noticeLevelLabel(n.level)} `}<code>${escapeHtml(n.code)}</code> ${escapeHtml(n.message)}</p>`).join("\n")}
192
+ </div>` : ""}
184
193
  <p>${escapeHtml(PREVIEW_LABEL)}</p>
185
194
  <p>${escapeHtml(PREVIEW_LIMITS)}</p>
186
195
  </main>
@@ -354,7 +363,9 @@ var GLB_GENERATOR = `archlang-3d ${ARCHLANG_3D_VERSION}`;
354
363
  function bodyMaterialName(n) {
355
364
  if (n.kind === "floor") return `floor:${FLOOR_FINISHES.find((f) => f === n.extras.finish) ?? "neutral"}`;
356
365
  if (n.kind === "wall" && n.part === "demolish") return "wall:demolish";
357
- if (n.kind === "window" && (n.part === "glass" || n.part === "frame")) return `window:${n.part}`;
366
+ if (n.kind === "window" && n.part && `window:${n.part}` in KIND_PALETTE) return `window:${n.part}`;
367
+ if ((n.kind === "opening" || n.kind === "stair") && n.part && `${n.kind}:${n.part}` in KIND_PALETTE)
368
+ return `${n.kind}:${n.part}`;
358
369
  if (n.kind === "outdoor") return `outdoor:${String(n.extras.surface)}`;
359
370
  if (n.kind === "fence") return `fence:${String(n.extras.style)}`;
360
371
  return n.kind;