@chanmeng666/archlang-3d 0.7.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.
package/dist/browser.js CHANGED
@@ -1,3 +1,10 @@
1
+ import {
2
+ contactFade,
3
+ contactShadows,
4
+ faceParts,
5
+ joinedGroups,
6
+ wallOutline
7
+ } from "./chunk-MXKKNJPU.js";
1
8
  import {
2
9
  PRESET_LABELS,
3
10
  PREVIEW_ABOUT_URL,
@@ -6,11 +13,13 @@ import {
6
13
  PREVIEW_LIMITS,
7
14
  VIEW_CONTROLS_LABEL,
8
15
  VIEW_HINT,
16
+ noticeLevelLabel,
9
17
  replayPayload,
10
18
  viewBoxOf,
11
19
  viewToolbar
12
- } from "./chunk-FHBR2U5Z.js";
20
+ } from "./chunk-VMVKI2WQ.js";
13
21
  import {
22
+ CONTACT_SHADOW,
14
23
  ELEVATION_RANGE,
15
24
  END_AZIMUTH,
16
25
  END_FOV,
@@ -36,7 +45,7 @@ import {
36
45
  stripAt,
37
46
  takenLens,
38
47
  targetBounds
39
- } from "./chunk-TI4RYEOL.js";
48
+ } from "./chunk-LNIVDMPG.js";
40
49
 
41
50
  // src/replay/mount.ts
42
51
  import {
@@ -44,12 +53,14 @@ import {
44
53
  BufferGeometry,
45
54
  Color,
46
55
  DirectionalLight,
56
+ DoubleSide,
47
57
  EdgesGeometry,
48
58
  Group,
49
59
  HemisphereLight,
50
60
  LineBasicMaterial,
51
61
  LineSegments,
52
62
  Mesh,
63
+ MeshBasicMaterial,
53
64
  MeshLambertMaterial,
54
65
  NeutralToneMapping,
55
66
  OrthographicCamera,
@@ -77,476 +88,6 @@ function paintStrip(el, items) {
77
88
  el.replaceChildren(...nodes);
78
89
  }
79
90
 
80
- // src/replay/wall-lines.ts
81
- function takesWallLines(n) {
82
- return n.kind === "wall" && n.part === void 0 || n.kind === "column";
83
- }
84
- var EXACT = 2 ** 26;
85
- function det(a, b, c, d) {
86
- if (Math.abs(a) < EXACT && Math.abs(b) < EXACT && Math.abs(c) < EXACT && Math.abs(d) < EXACT) return a * d - b * c;
87
- const r = BigInt(a) * BigInt(d) - BigInt(b) * BigInt(c);
88
- return r > 0n ? 1 : r < 0n ? -1 : 0;
89
- }
90
- function detKey(a, b, c, d) {
91
- if (Math.abs(a) < EXACT && Math.abs(b) < EXACT && Math.abs(c) < EXACT && Math.abs(d) < EXACT)
92
- return String(a * d - b * c);
93
- return (BigInt(a) * BigInt(d) - BigInt(b) * BigInt(c)).toString();
94
- }
95
- function gcd(a, b) {
96
- let x = Math.abs(a);
97
- let y = Math.abs(b);
98
- while (y !== 0) [x, y] = [y, x % y];
99
- return x;
100
- }
101
- function nearlyFlat(p, q, fp, fq) {
102
- const d = BigInt(p[0]) * BigInt(q[0]) + BigInt(p[1]) * BigInt(q[1]);
103
- const c = BigInt(p[0]) * BigInt(q[1]) - BigInt(p[1]) * BigInt(q[0]);
104
- const s = fp * fq > 0 ? d : -d;
105
- return s > 0n && s * s > 3n * c * c;
106
- }
107
- function planLine(x0, z0, x1, z1) {
108
- let dx = x1 - x0;
109
- let dz = z1 - z0;
110
- const g = gcd(dx, dz);
111
- dx /= g;
112
- dz /= g;
113
- if (dx < 0 || dx === 0 && dz < 0) {
114
- dx = 0 - dx;
115
- dz = 0 - dz;
116
- }
117
- return { dx, dz, key: `${dx},${dz},${detKey(dx, dz, x0, z0)}` };
118
- }
119
- var lexLess = (a, b) => {
120
- for (let i = 0; i < a.length; i++) {
121
- const d = a[i] - b[i];
122
- if (d !== 0) return d;
123
- }
124
- return 0;
125
- };
126
- var sortedKeys = (m) => [...m.keys()].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
127
- var sortedUnique = (xs) => {
128
- const s = [...xs].sort((a, b) => a - b);
129
- let n = 0;
130
- for (let i = 0; i < s.length; i++) if (i === 0 || s[i] !== s[n - 1]) s[n++] = s[i];
131
- s.length = n;
132
- return s;
133
- };
134
- function extent(xs) {
135
- let lo = Infinity;
136
- let hi = -Infinity;
137
- for (const x of xs) {
138
- if (x < lo) lo = x;
139
- if (x > hi) hi = x;
140
- }
141
- return [lo, hi];
142
- }
143
- function lastRaised(nodes, rank) {
144
- let best = -1;
145
- for (const n of nodes) {
146
- if (best < 0) best = n;
147
- else {
148
- const rn = rank?.[n] ?? 0;
149
- const rb = rank?.[best] ?? 0;
150
- if (rn > rb || rn === rb && n < best) best = n;
151
- }
152
- }
153
- return best;
154
- }
155
- function byStorey(nodes) {
156
- const storeys = /* @__PURE__ */ new Map();
157
- nodes.forEach((n, i) => {
158
- if (!takesWallLines(n)) return;
159
- const level = /^L(-?\d+)\//.exec(n.key)?.[1] ?? "";
160
- const members = storeys.get(level);
161
- if (members) members.push(i);
162
- else storeys.set(level, [i]);
163
- });
164
- return sortedKeys(storeys).map((k) => storeys.get(k) ?? []);
165
- }
166
- function wallOutline(nodes, rank) {
167
- const faces = wallFaces(nodes);
168
- const drawn = nodes.map((n, i) => takesWallLines(n) ? { ...n, ...withFaces(n, faces[i]) } : n);
169
- return { faces, lines: linesOf(drawn, rank) };
170
- }
171
- function linesOf(nodes, rank) {
172
- const out = nodes.map((n) => takesWallLines(n) ? [] : void 0);
173
- const segs = nodes.map(() => []);
174
- for (const members of byStorey(nodes)) storeyLines(nodes, members, segs, rank);
175
- segs.forEach((list, i) => {
176
- if (!out[i]) return;
177
- const sorted = list.map((s) => lexLess(s.slice(0, 3), s.slice(3)) <= 0 ? s : [s[3], s[4], s[5], s[0], s[1], s[2]]).sort(lexLess);
178
- out[i] = sorted.flat();
179
- });
180
- return out;
181
- }
182
- function sweep(items, visit) {
183
- const byStart = items.map((it, i) => [it, i]).sort((a, b) => a[0].t0 - b[0].t0 || a[1] - b[1]);
184
- const ts = sortedUnique(items.flatMap((e) => [e.t0, e.t1]));
185
- let next = 0;
186
- let on = [];
187
- for (let j = 0; j + 1 < ts.length; j++) {
188
- const t0 = ts[j];
189
- const t1 = ts[j + 1];
190
- if (on.some((e) => e.t1 <= t0)) on = on.filter((e) => e.t1 > t0);
191
- while (next < byStart.length && byStart[next]?.[0].t0 <= t0) on.push(byStart[next++]?.[0]);
192
- if (on.length > 0) visit(t0, t1, on);
193
- }
194
- }
195
- function storeyLines(nodes, members, segs, rank) {
196
- const buckets = /* @__PURE__ */ new Map();
197
- const lines = /* @__PURE__ */ new Map();
198
- const dirs = /* @__PURE__ */ new Map();
199
- const pairs = /* @__PURE__ */ new Map();
200
- const push = (plane, line, e) => {
201
- const key = `${plane}|${line}`;
202
- const b = buckets.get(key);
203
- if (b) b.edges.push(e);
204
- else buckets.set(key, { line, plane, edges: [e] });
205
- };
206
- const pair = (plane, p, q, node) => {
207
- const fwd = lexLess(p, q) < 0;
208
- const [a, b] = fwd ? [p, q] : [q, p];
209
- const key = `${plane}|${a[0]},${a[1]},${a[2]}|${b[0]},${b[1]},${b[2]}`;
210
- const was = pairs.get(key);
211
- if (was) {
212
- was.net += fwd ? 1 : -1;
213
- was.nodes.push(node);
214
- } else pairs.set(key, { a, b, net: fwd ? 1 : -1, nodes: [node] });
215
- };
216
- const horizontal = (y, pl, p, q) => {
217
- const key = `h${y}:${pl.key}`;
218
- let at = lines.get(key);
219
- if (!at) {
220
- at = { kind: "horizontal", y, alongX: pl.dx !== 0, other: /* @__PURE__ */ new Map() };
221
- lines.set(key, at);
222
- }
223
- if (at.kind === "horizontal") {
224
- for (const r of [p, q]) {
225
- const [x, , z] = r;
226
- if (at.alongX) at.other.set(x, z);
227
- else at.other.set(z, x);
228
- }
229
- }
230
- return key;
231
- };
232
- const along = (pl, p) => pl.dx !== 0 ? p[0] : p[2];
233
- const edge = (t0, t1, node, f) => t0 < t1 ? { t0, t1, k: 1, node, f } : { t0: t1, t1: t0, k: -1, node, f };
234
- for (const ni of members) {
235
- const n = nodes[ni];
236
- const P = (v) => [
237
- Math.round(n.positions[v * 3]),
238
- Math.round(n.positions[v * 3 + 1]),
239
- Math.round(n.positions[v * 3 + 2])
240
- ];
241
- for (let i = 0; i + 2 < n.indices.length; i += 3) {
242
- const tri = [P(n.indices[i]), P(n.indices[i + 1]), P(n.indices[i + 2])];
243
- const [a, b, c] = tri;
244
- const ax = a[0];
245
- const ay = a[1];
246
- const az = a[2];
247
- const sides = [
248
- [a, b],
249
- [b, c],
250
- [c, a]
251
- ];
252
- if (ay === b[1] && ay === c[1]) {
253
- if (det(b[0] - ax, b[2] - az, c[0] - ax, c[2] - az) === 0)
254
- continue;
255
- const plane2 = `H${ay}`;
256
- for (const [p, q] of sides) {
257
- if (p[0] === q[0] && p[2] === q[2]) continue;
258
- const pl2 = planLine(p[0], p[2], q[0], q[2]);
259
- push(plane2, horizontal(ay, pl2, p, q), edge(along(pl2, p), along(pl2, q), ni, 0));
260
- }
261
- continue;
262
- }
263
- const flatInPlan = det(b[0] - ax, b[2] - az, c[0] - ax, c[2] - az) === 0;
264
- if (!flatInPlan) {
265
- for (const [p, q] of sides) segs[ni].push([...p, ...q]);
266
- continue;
267
- }
268
- const far = a[0] !== b[0] || a[2] !== b[2] ? b : c;
269
- if (far[0] === ax && far[2] === az) continue;
270
- const pl = planLine(ax, az, far[0], far[2]);
271
- const plane = `V${pl.key}`;
272
- if (!dirs.has(plane)) dirs.set(plane, [pl.dx, pl.dz]);
273
- const s = (p) => along(pl, p);
274
- const turn = det(s(b) - s(a), b[1] - ay, s(c) - s(a), c[1] - ay);
275
- if (turn === 0) continue;
276
- const f = turn > 0 ? 1 : -1;
277
- for (const [p, q] of sides) {
278
- if (p[0] === q[0] && p[2] === q[2]) {
279
- if (p[1] === q[1]) continue;
280
- const key = `v${p[0]},${p[2]}`;
281
- if (!lines.has(key)) lines.set(key, { kind: "vertical", x: p[0], z: p[2] });
282
- push(plane, key, edge(p[1], q[1], ni, f));
283
- } else if (p[1] === q[1]) {
284
- push(plane, horizontal(p[1], pl, p, q), edge(along(pl, p), along(pl, q), ni, f));
285
- } else pair(plane, p, q, ni);
286
- }
287
- }
288
- }
289
- const bounds = /* @__PURE__ */ new Map();
290
- for (const key of sortedKeys(buckets)) {
291
- const { line, plane, edges } = buckets.get(key);
292
- const [e0, e1] = edges;
293
- if (edges.length === 2 && e1 && e0.t0 === e1.t0 && e0.t1 === e1.t1 && e0.k !== e1.k) continue;
294
- sweep(edges, (t0, t1, on) => {
295
- let m = 0;
296
- for (const e of on) m += e.k;
297
- if (m === 0) return;
298
- const nets = /* @__PURE__ */ new Map();
299
- for (const e of on) nets.set(e.node, (nets.get(e.node) ?? 0) + e.k);
300
- const by = sortedUnique(on.filter((e) => nets.get(e.node) !== 0).map((e) => e.node));
301
- const fs = sortedUnique(on.filter((e) => e.k === Math.sign(m)).map((e) => e.f));
302
- const b = { t0, t1, nodes: by, plane, f: fs.length === 1 ? fs[0] : 0 };
303
- const list = bounds.get(line);
304
- if (list) list.push(b);
305
- else bounds.set(line, [b]);
306
- });
307
- }
308
- for (const line of sortedKeys(bounds)) {
309
- const list = bounds.get(line);
310
- const at = lines.get(line);
311
- const runs = [];
312
- sweep(list, (t0, t1, on) => {
313
- if (at.kind === "vertical" && on.length === 2) {
314
- const [p, q] = on;
315
- const dp = dirs.get(p.plane);
316
- const dq = dirs.get(q.plane);
317
- if (dp && dq && p.f !== 0 && q.f !== 0 && nearlyFlat(dp, dq, p.f, q.f)) return;
318
- }
319
- const node = lastRaised(
320
- on.flatMap((b) => b.nodes),
321
- rank
322
- );
323
- const last = runs[runs.length - 1];
324
- if (last && last.t1 === t0 && last.node === node) last.t1 = t1;
325
- else runs.push({ t0, t1, node });
326
- });
327
- for (const r of runs) {
328
- const end = (t) => {
329
- if (at.kind === "vertical") return [at.x, t, at.z];
330
- const o = at.other.get(t);
331
- return at.alongX ? [t, at.y, o] : [o, at.y, t];
332
- };
333
- segs[r.node].push([...end(r.t0), ...end(r.t1)]);
334
- }
335
- }
336
- for (const key of sortedKeys(pairs)) {
337
- const { a, b, net, nodes: by } = pairs.get(key);
338
- if (net === 0) continue;
339
- segs[lastRaised(by, rank)].push([...a, ...b]);
340
- }
341
- }
342
- function joinedGroups(fixes, standing) {
343
- const up = /* @__PURE__ */ new Map();
344
- fixes.forEach((f, i) => {
345
- if (f && f.group >= 0) up.set(f.group, (up.get(f.group) ?? true) && standing(i));
346
- });
347
- const out = /* @__PURE__ */ new Set();
348
- for (const [g, v] of up) if (v) out.add(g);
349
- return out;
350
- }
351
- function wallFaces(nodes) {
352
- const out = nodes.map(
353
- (n) => takesWallLines(n) ? { hide: [], add: [], alone: [], joined: [], group: -1 } : void 0
354
- );
355
- const root = nodes.map((_, i) => i);
356
- const find = (i) => {
357
- let r = i;
358
- while (root[r] !== r) r = root[r];
359
- while (root[i] !== r) [i, root[i]] = [root[i], r];
360
- return r;
361
- };
362
- const join = (a, b) => {
363
- const ra = find(a);
364
- const rb = find(b);
365
- if (ra < rb) root[rb] = ra;
366
- else if (rb < ra) root[ra] = rb;
367
- };
368
- const shared = /* @__PURE__ */ new Set();
369
- for (const members of byStorey(nodes)) storeyFaces(nodes, members, out, join, shared);
370
- out.forEach((f, i) => {
371
- if (!f) return;
372
- f.hide.sort((a, b) => a - b);
373
- if (shared.has(i)) f.group = find(i);
374
- });
375
- return out;
376
- }
377
- function faceParts(n, fix) {
378
- if (!fix) return { positions: n.positions, base: [...n.indices], alone: [], joined: [] };
379
- const hidden = new Set(fix.hide);
380
- const base = [];
381
- for (let i = 0; i + 2 < n.indices.length; i += 3) {
382
- if (!hidden.has(i / 3)) base.push(n.indices[i], n.indices[i + 1], n.indices[i + 2]);
383
- }
384
- let v = n.positions.length / 3;
385
- const run = (flat, to = []) => {
386
- for (let k = 0; k < flat.length / 3; k++) to.push(v++);
387
- return to;
388
- };
389
- run(fix.add, base);
390
- const alone = run(fix.alone);
391
- const joined = run(fix.joined);
392
- return { positions: n.positions.concat(fix.add, fix.alone, fix.joined), base, alone, joined };
393
- }
394
- function withFaces(n, fix, mode = "joined") {
395
- if (!fix) return { positions: n.positions, indices: n.indices };
396
- const parts = faceParts(n, fix);
397
- return { positions: parts.positions, indices: parts.base.concat(mode === "joined" ? parts.joined : parts.alone) };
398
- }
399
- function contested(tris) {
400
- const boxes = tris.map((t) => {
401
- const [s0, s1] = extent(t.s);
402
- const [y0, y1] = extent(t.p.map((q) => q[1]));
403
- return { s0, s1, y0, y1, f: t.f };
404
- });
405
- boxes.sort((a, b) => a.s0 - b.s0);
406
- let up = [];
407
- let down = [];
408
- for (const b of boxes) {
409
- if (up.some((o) => o.s1 <= b.s0)) up = up.filter((o) => o.s1 > b.s0);
410
- if (down.some((o) => o.s1 <= b.s0)) down = down.filter((o) => o.s1 > b.s0);
411
- const other = b.f > 0 ? down : up;
412
- if (other.some((o) => Math.min(o.y1, b.y1) > Math.max(o.y0, b.y0))) return true;
413
- (b.f > 0 ? up : down).push(b);
414
- }
415
- return false;
416
- }
417
- function storeyFaces(nodes, members, out, join, shared) {
418
- const planes = /* @__PURE__ */ new Map();
419
- for (const ni of members) {
420
- const n = nodes[ni];
421
- const P = (v) => [
422
- Math.round(n.positions[v * 3]),
423
- Math.round(n.positions[v * 3 + 1]),
424
- Math.round(n.positions[v * 3 + 2])
425
- ];
426
- for (let i = 0; i + 2 < n.indices.length; i += 3) {
427
- const a = P(n.indices[i]);
428
- const b = P(n.indices[i + 1]);
429
- const c = P(n.indices[i + 2]);
430
- const ax = a[0];
431
- const ay = a[1];
432
- const az = a[2];
433
- if (ay === b[1] && ay === c[1]) continue;
434
- if (det(b[0] - ax, b[2] - az, c[0] - ax, c[2] - az) !== 0)
435
- continue;
436
- const far = a[0] !== b[0] || a[2] !== b[2] ? b : c;
437
- if (far[0] === ax && far[2] === az) continue;
438
- const pl = planLine(ax, az, far[0], far[2]);
439
- const along = (p) => pl.dx !== 0 ? p[0] : p[2];
440
- const s = [along(a), along(b), along(c)];
441
- const turn = det(
442
- s[1] - s[0],
443
- b[1] - ay,
444
- s[2] - s[0],
445
- c[1] - ay
446
- );
447
- if (turn === 0) continue;
448
- const key = `V${pl.key}`;
449
- const t = { node: ni, tri: i / 3, p: [a, b, c], f: turn > 0 ? 1 : -1, s };
450
- const plane = planes.get(key);
451
- if (plane) plane.tris.push(t);
452
- else planes.set(key, { pl, tris: [t] });
453
- }
454
- }
455
- for (const key of sortedKeys(planes)) {
456
- const { tris } = planes.get(key);
457
- if (!contested(tris)) continue;
458
- const S = sortedUnique(tris.flatMap((t) => t.s));
459
- const Y = sortedUnique(tris.flatMap((t) => t.p.map((q) => q[1])));
460
- const where = /* @__PURE__ */ new Map();
461
- for (const t of tris) for (let k = 0; k < 3; k++) where.set(t.s[k], t.p[k]);
462
- const sAt = new Map(S.map((s, i) => [s, i]));
463
- const yAt = new Map(Y.map((y, j) => [y, j]));
464
- const ny = Y.length - 1;
465
- const steps = S.map(() => []);
466
- for (const t of tris) {
467
- for (let k = 0; k < 3; k++) {
468
- const p = t.p[k];
469
- const q = t.p[(k + 1) % 3];
470
- if (p[0] !== q[0] || p[2] !== q[2] || p[1] === q[1]) continue;
471
- const i = sAt.get(t.s[k]);
472
- const lo = Math.min(p[1], q[1]);
473
- const hi = Math.max(p[1], q[1]);
474
- steps[i].push([
475
- t.node,
476
- yAt.get(lo),
477
- yAt.get(hi),
478
- q[1] > p[1] ? 1 : -1
479
- ]);
480
- }
481
- }
482
- const wind = /* @__PURE__ */ new Map();
483
- const nonzero = /* @__PURE__ */ new Map();
484
- let live = [];
485
- const total = new Int32Array(ny);
486
- const cell = (to, s0, s1, j, facing) => {
487
- const y0 = Y[j];
488
- const y1 = Y[j + 1];
489
- const at = (s, y) => {
490
- const q = where.get(s);
491
- return [q[0], y, q[2]];
492
- };
493
- const [p00, p10, p11, p01] = [at(s0, y0), at(s1, y0), at(s1, y1), at(s0, y1)];
494
- if (facing > 0) to.push(...p00, ...p10, ...p11, ...p00, ...p11, ...p01);
495
- else to.push(...p00, ...p11, ...p10, ...p00, ...p01, ...p11);
496
- };
497
- for (let i = 0; i + 1 < S.length; i++) {
498
- const here = steps[i];
499
- for (const [o, j0, j1, d] of here) {
500
- let w = wind.get(o);
501
- if (!w) {
502
- w = new Int32Array(ny);
503
- wind.set(o, w);
504
- }
505
- let nz = nonzero.get(o) ?? 0;
506
- for (let j = j0; j < j1; j++) {
507
- const was = w[j];
508
- const now = was - d;
509
- w[j] = now;
510
- total[j] = total[j] - d;
511
- if (was === 0) nz++;
512
- else if (now === 0) nz--;
513
- }
514
- nonzero.set(o, nz);
515
- }
516
- if (here.length > 0) {
517
- for (const o of [...wind.keys()]) {
518
- if (nonzero.get(o) === 0) {
519
- wind.delete(o);
520
- nonzero.delete(o);
521
- }
522
- }
523
- live = [...wind.keys()].sort((a, b) => a - b);
524
- }
525
- const s0 = S[i];
526
- const s1 = S[i + 1];
527
- for (let j = 0; j < ny; j++) {
528
- const over = live.filter((o) => wind.get(o)[j] !== 0);
529
- if (over.length === 0) continue;
530
- if (over.length === 1) {
531
- const o = over[0];
532
- cell(out[o].add, s0, s1, j, wind.get(o)[j]);
533
- continue;
534
- }
535
- for (const o of over) {
536
- cell(out[o].alone, s0, s1, j, wind.get(o)[j]);
537
- shared.add(o);
538
- join(o, over[0]);
539
- }
540
- const sum = total[j];
541
- if (sum === 0) continue;
542
- const owner = over.find((o) => Math.sign(wind.get(o)[j]) === Math.sign(sum));
543
- cell(out[owner].joined, s0, s1, j, sum);
544
- }
545
- }
546
- for (const t of tris) out[t.node].hide.push(t.tri);
547
- }
548
- }
549
-
550
91
  // src/replay/mount.ts
551
92
  var KEY_TURN_DEG = 5;
552
93
  var KEY_DOLLY = 0.9;
@@ -797,6 +338,59 @@ function mountReplay(out, p, strip, opts = {}) {
797
338
  ground.visible = false;
798
339
  scene.add(ground);
799
340
  }
341
+ const shadowAlpha = p.theme === "light" ? CONTACT_SHADOW.alpha : CONTACT_SHADOW.alphaDark;
342
+ const shadowLayers = [];
343
+ const eventOf = new Map(p.events.map((e) => [e.key, e]));
344
+ let castEvents = [];
345
+ if (p.shadows !== false) {
346
+ const baked = contactShadows(p.nodes, p.ground, outlines);
347
+ castEvents = baked.casters.map((keys) => {
348
+ let last;
349
+ for (const k of keys) {
350
+ const ev = eventOf.get(k);
351
+ if (ev && (!last || ev.riseTo > last.riseTo)) last = ev;
352
+ }
353
+ return last;
354
+ });
355
+ const liftOf = new Map(p.nodes.map((n) => [n.key, n.lift ?? 0]));
356
+ for (const l of baked.layers) {
357
+ const pos = new Float32Array(l.positions.length);
358
+ for (let i = 0; i < l.positions.length; i++) pos[i] = l.positions[i] / 1e3;
359
+ const alpha = new BufferAttribute(new Float32Array(l.weight.length * 4), 4);
360
+ const geo = new BufferGeometry();
361
+ geo.setAttribute("position", new BufferAttribute(pos, 3));
362
+ geo.setAttribute("color", alpha);
363
+ geo.setIndex(l.indices);
364
+ const mat = new MeshBasicMaterial({
365
+ color: 16777215,
366
+ vertexColors: true,
367
+ transparent: true,
368
+ depthWrite: false,
369
+ side: DoubleSide,
370
+ polygonOffset: true,
371
+ polygonOffsetFactor: 0,
372
+ polygonOffsetUnits: -2
373
+ });
374
+ owned.push(geo, mat);
375
+ const mesh = new Mesh(geo, mat);
376
+ mesh.renderOrder = -0.5;
377
+ mesh.visible = false;
378
+ const group = new Group();
379
+ group.add(mesh);
380
+ scene.add(group);
381
+ const key2 = baked.casters[l.caster[0]]?.[0] ?? "";
382
+ shadowLayers.push({
383
+ mesh,
384
+ group,
385
+ alpha,
386
+ weight: l.weight,
387
+ caster: l.caster,
388
+ scale: l.cls === "corner" ? shadowAlpha.corner : l.cls === "halo" ? shadowAlpha.furniture : shadowAlpha.floor,
389
+ key: key2,
390
+ lift: liftOf.get(key2) ?? 0
391
+ });
392
+ }
393
+ }
800
394
  const ortho = new OrthographicCamera(-ow / 2, ow / 2, oh / 2, -oh / 2, 1, top + 1e5);
801
395
  ortho.up.set(0, 0, -1);
802
396
  ortho.position.set(cx, top + 5e4, cz);
@@ -911,6 +505,26 @@ function mountReplay(out, p, strip, opts = {}) {
911
505
  if (alone) alone.visible = !t2;
912
506
  if (joined) joined.visible = t2;
913
507
  }
508
+ if (shadowLayers.length > 0) {
509
+ const u = Math.min(1, Math.max(0, t));
510
+ const fades = castEvents.map((ev) => contactFade(ev, u));
511
+ for (const sl of shadowLayers) {
512
+ const a = sl.alpha.array;
513
+ let changed = false;
514
+ let any = false;
515
+ for (let i = 0; i < sl.weight.length; i++) {
516
+ const v = Math.fround(sl.weight[i] * sl.scale * fades[sl.caster[i]]);
517
+ if (a[i * 4 + 3] !== v) {
518
+ a[i * 4 + 3] = v;
519
+ changed = true;
520
+ }
521
+ if (v > 0) any = true;
522
+ }
523
+ if (changed) sl.alpha.needsUpdate = true;
524
+ sl.mesh.visible = any && (storeyOf.get(sl.key) ?? 0) < shown;
525
+ sl.group.position.y = settledLift(sl.lift, s.settle);
526
+ }
527
+ }
914
528
  let cam = ortho;
915
529
  if (holder === "free" && controls) {
916
530
  const dist = persp.position.distanceTo(controls.target);
@@ -1182,6 +796,7 @@ export {
1182
796
  VIEW_CONTROLS_LABEL,
1183
797
  VIEW_HINT,
1184
798
  mountReplay,
799
+ noticeLevelLabel,
1185
800
  paintStrip,
1186
801
  replayPayload,
1187
802
  stripAt,
@@ -1,4 +1,4 @@
1
- import { Q as ReplayEvent, T as ReplayState } from './strip-Sdsm54Qw.js';
1
+ import { a3 as ReplayEvent, a4 as ReplayState } from './payload-DwiB2P7x.js';
2
2
 
3
3
  /**
4
4
  * The replay's end camera as plain maths (card A3, look notes round 1): the viewer and the tests