@blackbelt-technology/pi-dashboard-deck3d 0.8.0 → 0.10.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/.pi/skills/deck3d/SKILL.agent.md +78 -0
- package/.pi/skills/deck3d/SKILL.md +68 -0
- package/.pi/skills/deck3d/reference/effects.md +185 -2
- package/.pi/skills/deck3d/reference/ir-fields.md +26 -3
- package/.pi/skills/deck3d-from-pptx/SKILL.md +134 -0
- package/.pi/skills/deck3d-from-pptx/reference/steps.md +72 -0
- package/README.md +30 -2
- package/assets/preview/stub-chrome.png +0 -0
- package/assets/preview/stub-icon.json +59 -0
- package/assets/preview/stub-layout.json +195 -0
- package/assets/preview/stub-outline.json +48 -0
- package/dist/cli.js +11780 -5934
- package/dist/harvest/harness.js +4 -4
- package/dist/runtime.js +5916 -4007
- package/fixtures/business-2031/assets/stub-chrome.png +0 -0
- package/fixtures/business-2031/assets/stub-icon.json +59 -0
- package/fixtures/business-2031/assets/stub-layout.json +195 -0
- package/fixtures/business-2031/assets/stub-outline.json +48 -0
- package/fixtures/business-2031/build-overrides.mjs +58 -13
- package/fixtures/business-2031/deck.agent.md +60 -0
- package/fixtures/business-2031/deck.json +133 -8
- package/fixtures/business-2031/overrides.json +133 -8
- package/package.json +8 -4
- package/scripts/gen-stub-assets.ts +31 -0
- package/src/art/cutout.ts +97 -0
- package/src/art/decode.ts +169 -0
- package/src/art/icon.ts +380 -0
- package/src/art/png.ts +232 -0
- package/src/art/trace.ts +288 -0
- package/src/check/rules.ts +13 -8
- package/src/cli.ts +313 -51
- package/src/compare/index.ts +131 -0
- package/src/compare/ssim.ts +91 -0
- package/src/fx/art-geometry.ts +137 -0
- package/src/fx/art3d.meta.json +30 -0
- package/src/fx/art3d.ts +131 -0
- package/src/fx/bank.meta.json +26 -0
- package/src/fx/bank.ts +8 -0
- package/src/fx/compose.ts +5 -4
- package/src/fx/crane.meta.json +26 -0
- package/src/fx/crane.ts +8 -0
- package/src/fx/dolly.ts +5 -1
- package/src/fx/fade.ts +5 -1
- package/src/fx/flythrough.ts +5 -1
- package/src/fx/frame-chrome.meta.json +17 -0
- package/src/fx/frame-chrome.ts +134 -0
- package/src/fx/haze.meta.json +19 -0
- package/src/fx/haze.ts +91 -0
- package/src/fx/icon3d.meta.json +21 -0
- package/src/fx/icon3d.ts +167 -0
- package/src/fx/index.ts +96 -66
- package/src/fx/iris.ts +5 -1
- package/src/fx/meta.schema.json +10 -2
- package/src/fx/path.meta.json +25 -0
- package/src/fx/path.ts +8 -0
- package/src/fx/persistent.ts +11 -0
- package/src/fx/revolve.meta.json +26 -0
- package/src/fx/revolve.ts +8 -0
- package/src/fx/slide-layer.meta.json +26 -0
- package/src/fx/slide-layer.ts +557 -0
- package/src/fx/slide-space.ts +142 -0
- package/src/fx/stub-assets.ts +117 -0
- package/src/fx/swing.meta.json +26 -0
- package/src/fx/swing.ts +8 -0
- package/src/fx/types.ts +63 -2
- package/src/ir/merge.ts +5 -2
- package/src/ir/schema.json +140 -3
- package/src/ir/types.ts +54 -0
- package/src/ir/validate.ts +91 -3
- package/src/parse/harvest/index.ts +4 -1
- package/src/parse/markdown.ts +38 -7
- package/src/pptx/baseline.ts +183 -0
- package/src/pptx/extract.ts +161 -0
- package/src/pptx/fallback.ts +70 -0
- package/src/pptx/import.ts +256 -0
- package/src/pptx/master.ts +135 -0
- package/src/pptx/media.ts +81 -0
- package/src/pptx/package.ts +109 -0
- package/src/pptx/ref.ts +100 -0
- package/src/pptx/shapes.ts +276 -0
- package/src/pptx/stage.ts +82 -0
- package/src/pptx/text.ts +202 -0
- package/src/pptx/theme.ts +194 -0
- package/src/pptx/types.ts +159 -0
- package/src/pptx/xfrm.ts +93 -0
- package/src/pptx/xml.ts +106 -0
- package/src/pptx/zip.ts +239 -0
- package/src/render/assets.ts +57 -0
- package/src/render/build.ts +75 -0
- package/src/render/index.ts +7 -2
- package/src/render/template.html +1 -1
- package/src/runtime/assets.ts +75 -0
- package/src/runtime/fade.ts +110 -0
- package/src/runtime/hud.ts +37 -9
- package/src/runtime/index.ts +431 -67
- package/src/runtime/post.ts +11 -5
- package/src/runtime/scene.ts +25 -2
- package/src/runtime/transition.ts +222 -0
- package/src/runtime/types.ts +13 -2
- package/src/serve/index.ts +199 -16
- package/src/util/cleanup.ts +13 -0
- package/src/util/confine.ts +15 -0
- package/src/variants/pick.ts +282 -0
- package/src/variants/render.ts +179 -0
- package/src/variants/schema.json +48 -0
- package/src/variants/style.ts +318 -0
package/src/runtime/index.ts
CHANGED
|
@@ -8,11 +8,14 @@ import type { Font } from "opentype.js";
|
|
|
8
8
|
import * as THREE from "three";
|
|
9
9
|
import { composeEffects, QUALITY_BUDGET } from "../fx/compose.js";
|
|
10
10
|
import { REGISTRY } from "../fx/index.js";
|
|
11
|
-
import
|
|
11
|
+
import { isPersistentFx } from "../fx/persistent.js";
|
|
12
|
+
import type { FxContext, FxHandle, FxParams, FxView } from "../fx/types.js";
|
|
12
13
|
import type { Layout } from "../ir/types.js";
|
|
14
|
+
import { type AssetAccessor, type EmbeddedAsset, loadDeckAssets, makeAccessor } from "./assets.js";
|
|
13
15
|
import { type Animator, backgroundFor } from "./backgrounds.js";
|
|
14
16
|
import { buildDiagram, type DiagramBuild } from "./builders.js";
|
|
15
17
|
import { anchorFor, cullRadius } from "./camera.js";
|
|
18
|
+
import { createFader, fadeWindow } from "./fade.js";
|
|
16
19
|
import { createHud, type SlidePatch } from "./hud.js";
|
|
17
20
|
import { createLocalEffect, type LocalFxError, type LocalHandle, localCards, localFxRegistry } from "./local-fx.js";
|
|
18
21
|
import { diagramMaterial, titleEdgeMaterial, titleMaterial } from "./materials.js";
|
|
@@ -22,8 +25,9 @@ import type { PartName } from "./post.js";
|
|
|
22
25
|
import { applyProps, createPropMaterials, loadPropModels, type PropLayer, type PropMaterials } from "./props.js";
|
|
23
26
|
import { type QualityProfile, qualityProfile } from "./quality.js";
|
|
24
27
|
import { makeRng } from "./rng.js";
|
|
25
|
-
import { createSceneRig, markBackdrop, sortAboveVeil } from "./scene.js";
|
|
28
|
+
import { createSceneRig, markBackdrop, markOverlay, sortAboveVeil } from "./scene.js";
|
|
26
29
|
import { buildTitle, bulletTexture, loadFont } from "./text.js";
|
|
30
|
+
import { easeInOut, type Motion, makeMotion, resolveTransition, reversed, type Sample } from "./transition.js";
|
|
27
31
|
import "./types.js";
|
|
28
32
|
import type { Deck3dApi, Measurement, RuntimeDeck, SlideConfig } from "./types.js";
|
|
29
33
|
|
|
@@ -38,7 +42,15 @@ interface LabelRef {
|
|
|
38
42
|
color?: string;
|
|
39
43
|
}
|
|
40
44
|
|
|
45
|
+
/** A corpus `layer` effect (or additive background) instantiated on a slide. */
|
|
46
|
+
interface LayerFx {
|
|
47
|
+
id: string;
|
|
48
|
+
handle: FxHandle;
|
|
49
|
+
dead: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
41
52
|
interface SlideBuild {
|
|
53
|
+
layerFx: LayerFx[];
|
|
42
54
|
group: THREE.Group;
|
|
43
55
|
anchor: ReturnType<typeof anchorFor>;
|
|
44
56
|
diagram: DiagramBuild | null;
|
|
@@ -186,8 +198,15 @@ export function fxSeedFor(slideId: string): number {
|
|
|
186
198
|
return (h >>> 0) % 233280;
|
|
187
199
|
}
|
|
188
200
|
|
|
201
|
+
/** Decoded deck assets; filled by `boot()` before any slide is built. */
|
|
202
|
+
let deckAssets: AssetAccessor = makeAccessor(new Map());
|
|
203
|
+
/** The rig camera, for `layer` / persistent effects' `ctx.view`. */
|
|
204
|
+
let viewCamera: THREE.PerspectiveCamera | null = null;
|
|
205
|
+
/** The deck's resting field of view (transitions may animate the live one). */
|
|
206
|
+
let restFov = 42;
|
|
207
|
+
|
|
189
208
|
/** The context every effect (corpus or local) is constructed with. */
|
|
190
|
-
function fxContextFor(slide: DeckSlide, P: PaletteColors, profile: QualityProfile, mode: "dark" | "light"): FxContext {
|
|
209
|
+
function fxContextFor(slide: DeckSlide, P: PaletteColors, profile: QualityProfile, mode: "dark" | "light", view?: FxView): FxContext {
|
|
191
210
|
return {
|
|
192
211
|
THREE,
|
|
193
212
|
palette: P,
|
|
@@ -195,9 +214,71 @@ function fxContextFor(slide: DeckSlide, P: PaletteColors, profile: QualityProfil
|
|
|
195
214
|
quality: profile,
|
|
196
215
|
rng: makeRng(fxSeedFor(slide.id)),
|
|
197
216
|
slide: { id: slide.id, title: slide.title, kind: slide.kind ?? "content" },
|
|
217
|
+
assets: deckAssets,
|
|
218
|
+
...(view ? { view } : {}),
|
|
198
219
|
};
|
|
199
220
|
}
|
|
200
221
|
|
|
222
|
+
const viewport = () => ({ width: window.innerWidth, height: window.innerHeight });
|
|
223
|
+
|
|
224
|
+
/** `ctx.view` for a slide: its settled pose in slide-group space (`camera.ts` contract). */
|
|
225
|
+
function slideView(cfg: SlideConfig): FxView | undefined {
|
|
226
|
+
if (!viewCamera) return undefined;
|
|
227
|
+
return { camera: viewCamera, pose: { cam: [0.6, 0.6, cfg.camera?.distance ?? 9], target: [0, 0, 0], fov: restFov }, viewport };
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Background cards that ADD to the slide's backdrop instead of being its one
|
|
232
|
+
* scene background (`backgroundFromEffects` builds only the first). `haze`
|
|
233
|
+
* fades whatever world is behind the slide, so it must coexist with it.
|
|
234
|
+
*/
|
|
235
|
+
const ADDITIVE_BACKGROUNDS = new Set(["haze"]);
|
|
236
|
+
|
|
237
|
+
function isLayerRef(id: string): boolean {
|
|
238
|
+
const card = REGISTRY[id]?.card;
|
|
239
|
+
return !!card && !card.persistent && (card.kind === "layer" || ADDITIVE_BACKGROUNDS.has(id));
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** Run one entry point of a corpus layer/persistent effect; a throw disables it. */
|
|
243
|
+
function guardFx(fx: LayerFx, slideId: string, phase: LocalFxError["phase"], fn: (h: FxHandle) => void): void {
|
|
244
|
+
if (fx.dead) return;
|
|
245
|
+
try {
|
|
246
|
+
fn(fx.handle);
|
|
247
|
+
} catch (err) {
|
|
248
|
+
fx.dead = phase !== "dispose";
|
|
249
|
+
localFxErrors.push({ slide: slideId, effectId: fx.id, phase });
|
|
250
|
+
console.error(`effect ${fx.id} failed in ${phase} on slide ${slideId}:`, err);
|
|
251
|
+
if (fx.dead) (fx.handle.object as THREE.Object3D | undefined)?.parent?.remove(fx.handle.object as THREE.Object3D);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Instantiate the slide's corpus `layer` effects (and additive backgrounds). */
|
|
256
|
+
function layerEffectsFor(slide: DeckSlide, P: PaletteColors, profile: QualityProfile, mode: "dark" | "light", g: THREE.Group, cfg: SlideConfig): LayerFx[] {
|
|
257
|
+
const out: LayerFx[] = [];
|
|
258
|
+
for (const ref of effectsOf(slide)) {
|
|
259
|
+
if (!isLayerRef(ref.id)) continue;
|
|
260
|
+
const entry = REGISTRY[ref.id];
|
|
261
|
+
let handle: FxHandle;
|
|
262
|
+
try {
|
|
263
|
+
handle = entry.create(fxContextFor(slide, P, profile, mode, slideView(cfg)), paramsFor(slide.id, ref));
|
|
264
|
+
} catch (err) {
|
|
265
|
+
localFxErrors.push({ slide: slide.id, effectId: ref.id, phase: "create" });
|
|
266
|
+
console.error(`effect ${ref.id} failed in create on slide ${slide.id}:`, err);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
const object = handle.object as THREE.Object3D | undefined;
|
|
270
|
+
if (object) {
|
|
271
|
+
if (entry.card.kind === "background") {
|
|
272
|
+
markBackdrop(object);
|
|
273
|
+
sortAboveVeil(object);
|
|
274
|
+
}
|
|
275
|
+
g.add(object);
|
|
276
|
+
}
|
|
277
|
+
out.push({ id: ref.id, handle, dead: false });
|
|
278
|
+
}
|
|
279
|
+
return out;
|
|
280
|
+
}
|
|
281
|
+
|
|
201
282
|
/**
|
|
202
283
|
* Live per-effect parameter edits from the configurator, keyed
|
|
203
284
|
* `<slideId>|<effectId>`. The authored `ref.params` stay untouched so an
|
|
@@ -240,7 +321,7 @@ const LIFT_PARAM = { type: "number", default: 0, minimum: -6, maximum: 8 } as co
|
|
|
240
321
|
function backgroundFromEffects(slide: DeckSlide, P: PaletteColors, profile: QualityProfile, mode: "dark" | "light"): Animator | null {
|
|
241
322
|
for (const ref of effectsOf(slide)) {
|
|
242
323
|
const entry = REGISTRY[ref.id];
|
|
243
|
-
if (entry?.card.kind !== "background") continue;
|
|
324
|
+
if (entry?.card.kind !== "background" || ADDITIVE_BACKGROUNDS.has(ref.id)) continue;
|
|
244
325
|
const params = paramsFor(slide.id, ref);
|
|
245
326
|
const handle = entry.create(fxContextFor(slide, P, profile, mode), params);
|
|
246
327
|
if (!handle.object) continue;
|
|
@@ -313,6 +394,9 @@ function buildSlideGroup(
|
|
|
313
394
|
patch?: SlideConfig,
|
|
314
395
|
): SlideBuild {
|
|
315
396
|
const cfg = patch ? { ...effective(deck.defaults, slide), ...patch } : effective(deck.defaults, slide);
|
|
397
|
+
// Own override > deck `transitionCycle` > deck default — recorded so the HUD
|
|
398
|
+
// and `debug` see the move that will actually play.
|
|
399
|
+
cfg.transition = resolveTransition(patch?.transition ?? slide.transition, index, deck.defaults.transitionCycle, deck.defaults.transition);
|
|
316
400
|
const P = resolvePalette(cfg);
|
|
317
401
|
const g = new THREE.Group();
|
|
318
402
|
const anchor = anchorFor(index, cfg.camera?.distance, cfg.spacing, cfg.rail, deck.slides.length);
|
|
@@ -320,14 +404,25 @@ function buildSlideGroup(
|
|
|
320
404
|
g.rotation.y = anchor.rotY;
|
|
321
405
|
const labels: LabelRef[] = [];
|
|
322
406
|
const isTitle = slide.kind === "title";
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
407
|
+
const profile = qualityProfile(cfg.quality ?? deck.defaults.quality);
|
|
408
|
+
const mode = (cfg.mode ?? "dark") as "dark" | "light";
|
|
409
|
+
// Layer effects are constructed BEFORE the native content is decided: a
|
|
410
|
+
// `replacesContent` effect (slide-layer) draws the slide's content itself,
|
|
411
|
+
// so the native title, card and diagram are neither built nor measured —
|
|
412
|
+
// but only when that effect actually BUILT. One that threw in `create` (a
|
|
413
|
+
// missing layout, a bad slide id) leaves the native slide in place instead
|
|
414
|
+
// of a blank one.
|
|
415
|
+
const layerFx = layerEffectsFor(slide, P, profile, mode, g, cfg);
|
|
416
|
+
const replaced = layerFx.some((fx) => REGISTRY[fx.id]?.card.replacesContent === true);
|
|
417
|
+
let diagram: DiagramBuild | null = null;
|
|
418
|
+
if (!replaced) {
|
|
419
|
+
addTitle(g, slide, isTitle, font, P, cfg, labels);
|
|
420
|
+
addBody(g, slide, isTitle, P, cfg);
|
|
421
|
+
diagram = addDiagram(g, slide, font, P, cfg, labels);
|
|
422
|
+
}
|
|
326
423
|
const props = applyProps(deck, slide.id, g, diagram, models, propMaterials);
|
|
327
424
|
if (props) props.group.userData.part = "props";
|
|
328
425
|
const nodes = diagram?.nodes ? Object.entries(diagram.nodes).map(([id, object]) => ({ id, object })) : [];
|
|
329
|
-
const profile = qualityProfile(cfg.quality ?? deck.defaults.quality);
|
|
330
|
-
const mode = (cfg.mode ?? "dark") as "dark" | "light";
|
|
331
426
|
const background = backgroundFromEffects(slide, P, profile, mode) ?? backgroundFor(slide.scene, P, profile) ?? null;
|
|
332
427
|
if (background) {
|
|
333
428
|
background.g.position.z = -2;
|
|
@@ -347,7 +442,7 @@ function buildSlideGroup(
|
|
|
347
442
|
limit: QUALITY_BUDGET[quality],
|
|
348
443
|
...(warning ? { warning } : {}),
|
|
349
444
|
};
|
|
350
|
-
return { group: g, anchor, diagram, background, props, labels, nodes, cfg, palette: P, skipped, budget, localFx };
|
|
445
|
+
return { group: g, anchor, diagram, background, props, labels, nodes, cfg, palette: P, skipped, budget, localFx, layerFx };
|
|
351
446
|
}
|
|
352
447
|
|
|
353
448
|
async function boot(): Promise<void> {
|
|
@@ -363,6 +458,19 @@ async function boot(): Promise<void> {
|
|
|
363
458
|
// (even at `quality: low`) is honoured per slide by the post stack.
|
|
364
459
|
const rig = createSceneRig(qualityProfile(deck.defaults.quality));
|
|
365
460
|
document.body.appendChild(rig.renderer.domElement);
|
|
461
|
+
viewCamera = rig.camera;
|
|
462
|
+
restFov = rig.camera.fov;
|
|
463
|
+
rig.resize(window.innerWidth, window.innerHeight);
|
|
464
|
+
// Every deck asset is decoded BEFORE a slide is built, so effects read them
|
|
465
|
+
// synchronously and `ready()` (the api only exists after boot) implies it.
|
|
466
|
+
const assetLoad = await loadDeckAssets((window as unknown as { __DECK_ASSETS?: EmbeddedAsset[] }).__DECK_ASSETS);
|
|
467
|
+
deckAssets = assetLoad.accessor;
|
|
468
|
+
const baseFov = rig.camera.fov;
|
|
469
|
+
// Screen cover for `fade` / `iris`: a DOM layer over the canvas (under the
|
|
470
|
+
// HUD, appended later), so it covers bloom and post passes alike.
|
|
471
|
+
const cover = document.createElement("div");
|
|
472
|
+
cover.style.cssText = "position:fixed;inset:0;pointer-events:none;display:none";
|
|
473
|
+
document.body.appendChild(cover);
|
|
366
474
|
|
|
367
475
|
const propModels = await loadPropModels(deck);
|
|
368
476
|
const propMaterials = createPropMaterials(resolvePalette(deck.defaults), deck.defaults);
|
|
@@ -372,7 +480,7 @@ async function boot(): Promise<void> {
|
|
|
372
480
|
g.userData.index = i;
|
|
373
481
|
});
|
|
374
482
|
|
|
375
|
-
const camState = { pos: new THREE.Vector3(), target: new THREE.Vector3() };
|
|
483
|
+
const camState = { pos: new THREE.Vector3(), target: new THREE.Vector3(), roll: 0, fov: 0, cover: 0, overlay: "none" as Sample["overlay"] };
|
|
376
484
|
let cur = 0;
|
|
377
485
|
let frozen: number | null = null;
|
|
378
486
|
const clock = new THREE.Clock();
|
|
@@ -382,11 +490,22 @@ async function boot(): Promise<void> {
|
|
|
382
490
|
t: number;
|
|
383
491
|
mode: string;
|
|
384
492
|
dur: number;
|
|
385
|
-
|
|
493
|
+
/** Pose at normalised time, built once in `goTo` (deterministic). */
|
|
494
|
+
motion: Motion;
|
|
495
|
+
/** Slide being left; kept visible for the whole move. */
|
|
496
|
+
leaving: number;
|
|
497
|
+
/**
|
|
498
|
+
* Cross-fade: `whole` = the entire slide group fades (it was culled before
|
|
499
|
+
* / will be culled after the move); otherwise only its local fx do (they
|
|
500
|
+
* are created at the start and disposed at landing — the pop-in / flash).
|
|
501
|
+
*/
|
|
502
|
+
fade: { inWhole: boolean; outWhole: boolean };
|
|
386
503
|
/** Set only when the two slides differ in palette; drives the look morph. */
|
|
387
504
|
look?: { from: PaletteColors; to: PaletteColors; cfg: SlideConfig };
|
|
388
505
|
};
|
|
389
506
|
let anim: Anim | null = null;
|
|
507
|
+
/** Debug hold: pins an in-flight transition at this progress (`debug.transitionAt`). */
|
|
508
|
+
let holdT: number | null = null;
|
|
390
509
|
/** Slide whose local fx are reclaimed once the in-flight transition lands. */
|
|
391
510
|
let pendingDispose: number | null = null;
|
|
392
511
|
|
|
@@ -427,15 +546,97 @@ async function boot(): Promise<void> {
|
|
|
427
546
|
* a clip never runs off-screen and a pinned time renders a stable frame.
|
|
428
547
|
*/
|
|
429
548
|
function settle(active: number | null): void {
|
|
430
|
-
for (let i = 0; i < builds.length; i++)
|
|
549
|
+
for (let i = 0; i < builds.length; i++) {
|
|
550
|
+
builds[i]?.background?.setActive?.(i === active);
|
|
551
|
+
for (const fx of builds[i]?.layerFx ?? []) guardFx(fx, deck.slides[i].id, "tick", (h) => h.setActive?.(i === active));
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/** Tick slide `i`'s layer effects. */
|
|
556
|
+
function tickLayers(i: number, t: number): void {
|
|
557
|
+
for (const fx of builds[i]?.layerFx ?? []) guardFx(fx, deck.slides[i].id, "tick", (h) => h.tick?.(t));
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function disposeLayers(build: SlideBuild, slideId: string): void {
|
|
561
|
+
for (const fx of build.layerFx) {
|
|
562
|
+
guardFx({ ...fx, dead: false }, slideId, "dispose", (h) => h.dispose());
|
|
563
|
+
const o = fx.handle.object as THREE.Object3D | undefined;
|
|
564
|
+
o?.parent?.remove(o);
|
|
565
|
+
}
|
|
566
|
+
build.layerFx = [];
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// ── persistent (deck-scope) effects ────────────────────────────────────────
|
|
570
|
+
/** Live deck-scope persistent ids (the configurator may change them). */
|
|
571
|
+
let persistentIds = (deck.effects ?? []).filter((e) => isPersistentFx(e.id)).map((e) => e.id);
|
|
572
|
+
let persistent: LayerFx[] = [];
|
|
573
|
+
|
|
574
|
+
function buildPersistent(): void {
|
|
575
|
+
for (const fx of persistent) {
|
|
576
|
+
guardFx({ ...fx, dead: false }, "deck", "dispose", (h) => h.dispose());
|
|
577
|
+
const o = fx.handle.object as THREE.Object3D | undefined;
|
|
578
|
+
o?.parent?.remove(o);
|
|
579
|
+
}
|
|
580
|
+
persistent = [];
|
|
581
|
+
const P = resolvePalette(deck.defaults);
|
|
582
|
+
const profile = qualityProfile(deck.defaults.quality);
|
|
583
|
+
const mode = (deck.defaults.mode ?? "dark") as "dark" | "light";
|
|
584
|
+
const authored = new Map((deck.effects ?? []).map((e) => [e.id, e]));
|
|
585
|
+
const deckSlide = { id: "deck", title: "", kind: "deck", effects: [] } as unknown as DeckSlide;
|
|
586
|
+
const view: FxView = { camera: rig.camera, pose: { cam: [0, 0, 0], target: [0, 0, -1], fov: restFov }, viewport, deckSlideIds: deck.slides.map((s) => s.id) };
|
|
587
|
+
for (const id of persistentIds) {
|
|
588
|
+
const entry = REGISTRY[id];
|
|
589
|
+
if (!entry) continue;
|
|
590
|
+
let handle: FxHandle;
|
|
591
|
+
try {
|
|
592
|
+
handle = entry.create(fxContextFor(deckSlide, P, profile, mode, view), paramsFor("deck", authored.get(id) ?? { id }));
|
|
593
|
+
} catch (err) {
|
|
594
|
+
localFxErrors.push({ slide: "deck", effectId: id, phase: "create" });
|
|
595
|
+
console.error(`persistent effect ${id} failed in create:`, err);
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
const object = handle.object as THREE.Object3D | undefined;
|
|
599
|
+
if (object) {
|
|
600
|
+
object.userData.persistent = id;
|
|
601
|
+
rig.scene.add(object);
|
|
602
|
+
markOverlay(object);
|
|
603
|
+
}
|
|
604
|
+
persistent.push({ id, handle, dead: false });
|
|
605
|
+
}
|
|
431
606
|
}
|
|
432
607
|
|
|
608
|
+
/** Drive every persistent effect: transition state, then its clock. */
|
|
609
|
+
function drivePersistent(t: number): void {
|
|
610
|
+
const state = anim ? { from: anim.leaving, to: cur, p: anim.t } : { from: cur, to: cur, p: 1 };
|
|
611
|
+
for (const fx of persistent) {
|
|
612
|
+
guardFx(fx, "deck", "tick", (h) => {
|
|
613
|
+
h.transition?.(state);
|
|
614
|
+
h.tick?.(t);
|
|
615
|
+
});
|
|
616
|
+
// Effects may add children in tick; keep the whole subtree off the mirror.
|
|
617
|
+
const o = fx.handle.object as THREE.Object3D | undefined;
|
|
618
|
+
if (o) markOverlay(o);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/** Back to a still lens: no roll, deck fov, no screen cover. */
|
|
623
|
+
function resetLens(): void {
|
|
624
|
+
camState.roll = 0;
|
|
625
|
+
camState.fov = baseFov;
|
|
626
|
+
camState.cover = 0;
|
|
627
|
+
camState.overlay = "none";
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
const fader = createFader();
|
|
631
|
+
|
|
433
632
|
function snapTo(i: number): void {
|
|
633
|
+
fader.clear();
|
|
434
634
|
cur = i;
|
|
435
635
|
settle(i);
|
|
436
636
|
const a = builds[i].anchor;
|
|
437
637
|
camState.pos.copy(a.cam);
|
|
438
638
|
camState.target.copy(a.target);
|
|
639
|
+
resetLens();
|
|
439
640
|
anim = null;
|
|
440
641
|
rig.camera.position.copy(camState.pos);
|
|
441
642
|
rig.camera.lookAt(camState.target);
|
|
@@ -443,25 +644,17 @@ async function boot(): Promise<void> {
|
|
|
443
644
|
syncPost();
|
|
444
645
|
}
|
|
445
646
|
|
|
446
|
-
const ease = (t: number) => (t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2);
|
|
447
|
-
|
|
448
647
|
function stepAnim(dt: number): void {
|
|
449
648
|
if (!anim) return;
|
|
450
|
-
anim.t = Math.min(1, anim.t + dt / anim.dur);
|
|
451
|
-
const k =
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
camState.target.lerpVectors(anim.from.target, anim.to.target, k);
|
|
460
|
-
if (anim.mode === "swing") {
|
|
461
|
-
const out = camState.pos.clone().sub(anim.mid).normalize();
|
|
462
|
-
camState.pos.addScaledVector(out, Math.sin(anim.t * Math.PI) * 6);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
649
|
+
anim.t = holdT ?? Math.min(1, anim.t + dt / anim.dur);
|
|
650
|
+
const k = easeInOut(anim.t);
|
|
651
|
+
const s = anim.motion(anim.t);
|
|
652
|
+
camState.pos.copy(s.pos);
|
|
653
|
+
camState.target.copy(s.target);
|
|
654
|
+
camState.roll = s.roll;
|
|
655
|
+
camState.fov = s.fov;
|
|
656
|
+
camState.cover = s.cover;
|
|
657
|
+
camState.overlay = s.overlay;
|
|
465
658
|
if (anim.look) {
|
|
466
659
|
const l = anim.look;
|
|
467
660
|
rig.applyLook(anim.t >= 1 ? l.to : mixPalette(l.from, l.to, k), l.cfg, qualityProfile(l.cfg.quality));
|
|
@@ -542,9 +735,14 @@ async function boot(): Promise<void> {
|
|
|
542
735
|
}
|
|
543
736
|
|
|
544
737
|
function goTo(i: number): void {
|
|
738
|
+
holdT = null;
|
|
545
739
|
const target = ((i % builds.length) + builds.length) % builds.length;
|
|
546
740
|
reviveLocalFx(target);
|
|
547
|
-
|
|
741
|
+
// Back navigation plays the LEAVING slide's move reversed, so back and
|
|
742
|
+
// forward are mirror images (wrap-around from the first slide counts as back).
|
|
743
|
+
const back = i < cur;
|
|
744
|
+
const owner = back ? cur : target;
|
|
745
|
+
const mode = builds[owner].cfg.transition ?? "dolly";
|
|
548
746
|
// A cut leaves the old slide instantly, so its fx can go now. A fly does
|
|
549
747
|
// NOT: the outgoing slide stays in frame for the whole move, and disposing
|
|
550
748
|
// here stripped its backdrop the moment the camera started rolling while
|
|
@@ -561,15 +759,25 @@ async function boot(): Promise<void> {
|
|
|
561
759
|
// Same palette ⇒ nothing to morph, so the look is applied once as before.
|
|
562
760
|
const morph = JSON.stringify(fromPalette) !== JSON.stringify(toPalette);
|
|
563
761
|
settle(null); // camera about to fly: freeze time-based media
|
|
762
|
+
const toPose = { pos: builds[target].anchor.cam.clone(), target: builds[target].anchor.target.clone() };
|
|
763
|
+
const opts = { amount: builds[owner].cfg.transitionAmount ?? 1, path: deck.slides[owner].cameraPath, baseFov };
|
|
764
|
+
const motion = back ? reversed(makeMotion(mode, toPose, from, opts)) : makeMotion(mode, from, toPose, opts);
|
|
564
765
|
anim = {
|
|
565
766
|
from,
|
|
566
767
|
to: builds[target].anchor,
|
|
567
768
|
t: 0,
|
|
568
769
|
mode,
|
|
569
|
-
dur: builds[
|
|
570
|
-
|
|
770
|
+
dur: builds[owner].cfg.durationSec ?? 1.4,
|
|
771
|
+
motion,
|
|
772
|
+
leaving: cur,
|
|
773
|
+
fade: {
|
|
774
|
+
inWhole: !builds[target].group.visible,
|
|
775
|
+
outWhole: builds[cur].group.position.distanceTo(toPose.pos) >= cullRadius(railState.spacing, railState.rail),
|
|
776
|
+
},
|
|
571
777
|
look: morph ? { from: fromPalette, to: toPalette, cfg: builds[target].cfg } : undefined,
|
|
572
778
|
};
|
|
779
|
+
builds[anim.leaving].group.visible = true;
|
|
780
|
+
builds[target].group.visible = true;
|
|
573
781
|
cur = target;
|
|
574
782
|
if (!morph) rig.applyLook(toPalette, builds[target].cfg, qualityProfile(builds[target].cfg.quality));
|
|
575
783
|
syncPost();
|
|
@@ -593,7 +801,11 @@ async function boot(): Promise<void> {
|
|
|
593
801
|
function cullNeighbours(): void {
|
|
594
802
|
const cp = rig.camera.position;
|
|
595
803
|
rig.world.children.forEach((g) => {
|
|
596
|
-
|
|
804
|
+
// Both ends of an in-flight move stay up: a wide path (revolve, crane)
|
|
805
|
+
// can carry the camera past the cull radius of either slide.
|
|
806
|
+
// The fader owns their visibility while the move runs.
|
|
807
|
+
const held = anim !== null && (g.userData.index === cur || g.userData.index === anim.leaving);
|
|
808
|
+
if (!held) g.visible = g.position.distanceTo(cp) < cullRadius(railState.spacing, railState.rail);
|
|
597
809
|
});
|
|
598
810
|
}
|
|
599
811
|
|
|
@@ -621,6 +833,8 @@ async function boot(): Promise<void> {
|
|
|
621
833
|
slide.background?.tick(t * 0.7);
|
|
622
834
|
slide.props?.tick(t);
|
|
623
835
|
for (const handle of slide.localFx) handle.tick(t);
|
|
836
|
+
tickLayers(cur, t);
|
|
837
|
+
drivePersistent(t);
|
|
624
838
|
rig.followTarget(camState.target);
|
|
625
839
|
cullNeighbours();
|
|
626
840
|
billboardLabels();
|
|
@@ -635,6 +849,9 @@ async function boot(): Promise<void> {
|
|
|
635
849
|
*/
|
|
636
850
|
function poseAt(t: number): void {
|
|
637
851
|
anim = null; // a deterministic time cancels any in-flight transition
|
|
852
|
+
holdT = null;
|
|
853
|
+
fader.clear();
|
|
854
|
+
resetLens();
|
|
638
855
|
const a = builds[cur].anchor;
|
|
639
856
|
camState.pos.copy(a.cam);
|
|
640
857
|
camState.target.copy(a.target);
|
|
@@ -649,6 +866,59 @@ async function boot(): Promise<void> {
|
|
|
649
866
|
poseAt(t);
|
|
650
867
|
}
|
|
651
868
|
|
|
869
|
+
/** Roll, field of view and screen cover from the current motion sample. */
|
|
870
|
+
function applyLens(): void {
|
|
871
|
+
if (camState.roll !== 0) rig.camera.rotateZ(camState.roll);
|
|
872
|
+
const fov = camState.fov || baseFov;
|
|
873
|
+
if (rig.camera.fov !== fov) {
|
|
874
|
+
rig.camera.fov = fov;
|
|
875
|
+
rig.camera.updateProjectionMatrix();
|
|
876
|
+
}
|
|
877
|
+
if (camState.overlay === "none" || camState.cover <= 0) {
|
|
878
|
+
cover.style.display = "none";
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
const bg = builds[cur].palette.bg;
|
|
882
|
+
cover.style.display = "block";
|
|
883
|
+
if (camState.overlay === "fade") {
|
|
884
|
+
cover.style.background = bg;
|
|
885
|
+
cover.style.opacity = String(camState.cover);
|
|
886
|
+
} else {
|
|
887
|
+
// Iris: an opening circle; radius reaches the far corner when open.
|
|
888
|
+
const r = (1 - camState.cover) * Math.hypot(window.innerWidth, window.innerHeight) * 0.5;
|
|
889
|
+
cover.style.opacity = "1";
|
|
890
|
+
cover.style.background = `radial-gradient(circle at 50% 50%, transparent ${r.toFixed(1)}px, ${bg} ${(r + 1).toFixed(1)}px)`;
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
/** Roots of slide `i` to fade: the whole group, or its backdrop (local fx + background) still inside it. */
|
|
895
|
+
function fadeRoots(i: number, whole: boolean): THREE.Object3D[] {
|
|
896
|
+
const g = builds[i]?.group;
|
|
897
|
+
if (!g) return [];
|
|
898
|
+
if (whole) return [g];
|
|
899
|
+
// A camera-pinned overlay re-parents itself to the scene and runs its own
|
|
900
|
+
// out/in animation; leave it alone.
|
|
901
|
+
const inside = (o: THREE.Object3D) => {
|
|
902
|
+
for (let p = o.parent; p; p = p.parent) if (p === g) return true;
|
|
903
|
+
return false;
|
|
904
|
+
};
|
|
905
|
+
const fx = (builds[i].localFx ?? []).map((h) => h.object as THREE.Object3D | undefined).filter((o): o is THREE.Object3D => !!o && inside(o));
|
|
906
|
+
// Registry backgrounds too: fading only the local fx left e.g. a
|
|
907
|
+
// `video-screen` bezel standing alone while its fx frame faded.
|
|
908
|
+
return [...new Set([...fx, ...g.children.filter((c) => c.userData.backdrop)])];
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/** Arriving slide fades in over 10–70 % of the move, the leaving one out over 5–60 %. */
|
|
912
|
+
function fadeWeights(): Map<THREE.Object3D, number> {
|
|
913
|
+
const w = new Map<THREE.Object3D, number>();
|
|
914
|
+
if (!anim) return w;
|
|
915
|
+
const out = 1 - fadeWindow(anim.t, 0.05, 0.6);
|
|
916
|
+
const inn = fadeWindow(anim.t, 0.1, 0.7);
|
|
917
|
+
if (anim.leaving !== cur) for (const r of fadeRoots(anim.leaving, anim.fade.outWhole)) w.set(r, out);
|
|
918
|
+
for (const r of fadeRoots(cur, anim.fade.inWhole)) w.set(r, inn);
|
|
919
|
+
return w;
|
|
920
|
+
}
|
|
921
|
+
|
|
652
922
|
const tmp = new THREE.Vector3();
|
|
653
923
|
function frame(): void {
|
|
654
924
|
const dt = frozen === null ? clock.getDelta() : 1 / 60;
|
|
@@ -662,18 +932,24 @@ async function boot(): Promise<void> {
|
|
|
662
932
|
// backdrop stayed on screen well after the move was "done".
|
|
663
933
|
rig.camera.position.lerp(tmp, frozen === null && anim === null ? 0.2 : 1);
|
|
664
934
|
rig.camera.lookAt(camState.target);
|
|
665
|
-
|
|
935
|
+
applyLens();
|
|
666
936
|
rig.followTarget(camState.target);
|
|
667
937
|
builds[cur].diagram?.tick(t);
|
|
668
938
|
builds[cur].background?.tick(t * 0.7);
|
|
669
939
|
builds[cur].props?.tick(t);
|
|
670
940
|
for (const handle of builds[cur].localFx) handle.tick(t);
|
|
941
|
+
tickLayers(cur, t);
|
|
671
942
|
// The outgoing slide is still in frame during a fly: tick it too, or its
|
|
672
943
|
// backdrop freezes into a still the moment the camera moves.
|
|
673
944
|
if (pendingDispose !== null && pendingDispose !== cur) {
|
|
674
945
|
for (const handle of builds[pendingDispose]?.localFx ?? []) handle.tick(t);
|
|
675
946
|
builds[pendingDispose]?.background?.tick(t * 0.7);
|
|
947
|
+
tickLayers(pendingDispose, t);
|
|
676
948
|
}
|
|
949
|
+
drivePersistent(t);
|
|
950
|
+
// After the ticks (effects write their own opacity there), before culling.
|
|
951
|
+
fader.apply(fadeWeights());
|
|
952
|
+
cullNeighbours();
|
|
677
953
|
billboardLabels();
|
|
678
954
|
rig.render(t);
|
|
679
955
|
if (document.hidden) setTimeout(frame, 66);
|
|
@@ -729,9 +1005,24 @@ async function boot(): Promise<void> {
|
|
|
729
1005
|
const rect = projectRect(node.object, rig.camera, width, height);
|
|
730
1006
|
if (rect) out.push({ kind: "node", id: node.id, text: "", rect, capHeight: 0, hit: null });
|
|
731
1007
|
}
|
|
1008
|
+
// Text drawn by layer effects (slide-layer), so check's rules apply to it.
|
|
1009
|
+
rig.camera.updateMatrixWorld();
|
|
1010
|
+
for (const fx of builds[cur].layerFx) {
|
|
1011
|
+
if (fx.dead || !fx.handle.measure) continue;
|
|
1012
|
+
for (const m of fx.handle.measure(rig.camera, width, height)) {
|
|
1013
|
+
out.push({ kind: "layer-text", id: m.id, text: m.text, rect: m.rect, capHeight: m.capHeight, hit: null, color: m.color ?? null });
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
732
1016
|
return out;
|
|
733
1017
|
}
|
|
734
1018
|
|
|
1019
|
+
/** Sorted, de-duplicated font names any layer effect drew with a fallback. */
|
|
1020
|
+
function fonts(): { fallbacks: string[] } {
|
|
1021
|
+
const names = new Set<string>();
|
|
1022
|
+
for (const b of builds) for (const fx of b.layerFx) for (const n of fx.handle.fontFallbacks?.() ?? []) names.add(n);
|
|
1023
|
+
return { fallbacks: [...names].sort() };
|
|
1024
|
+
}
|
|
1025
|
+
|
|
735
1026
|
function peaks(): number[] {
|
|
736
1027
|
const diagram = deck.slides[cur]?.diagram;
|
|
737
1028
|
if (diagram?.kind === "sequence" && diagram.messages) return diagram.messages.map((_, k) => k * 1.1);
|
|
@@ -790,6 +1081,7 @@ async function boot(): Promise<void> {
|
|
|
790
1081
|
cfg.spacing = railState.spacing;
|
|
791
1082
|
|
|
792
1083
|
disposeLocalFx(i);
|
|
1084
|
+
disposeLayers(previous, deck.slides[i].id);
|
|
793
1085
|
rig.world.remove(previous.group);
|
|
794
1086
|
|
|
795
1087
|
// Props are tinted from the palette too, so they get materials derived
|
|
@@ -806,6 +1098,7 @@ async function boot(): Promise<void> {
|
|
|
806
1098
|
// a value the view never honours.
|
|
807
1099
|
camState.pos.copy(rebuilt.anchor.cam);
|
|
808
1100
|
camState.target.copy(rebuilt.anchor.target);
|
|
1101
|
+
resetLens();
|
|
809
1102
|
anim = null;
|
|
810
1103
|
rig.camera.position.copy(camState.pos);
|
|
811
1104
|
rig.camera.lookAt(camState.target);
|
|
@@ -821,15 +1114,59 @@ async function boot(): Promise<void> {
|
|
|
821
1114
|
* Configurator. Built after the slides so it can read the composed effect
|
|
822
1115
|
* list, and given callbacks that re-apply the look WITHOUT touching `__DECK`.
|
|
823
1116
|
*/
|
|
1117
|
+
/**
|
|
1118
|
+
* One effect param edit on the current slide — the configurator's path, also
|
|
1119
|
+
* reachable as `debug.applyParams`.
|
|
1120
|
+
*/
|
|
1121
|
+
function applyParamEdit(id: string, patch: FxParams): void {
|
|
1122
|
+
const slide = deck.slides[cur];
|
|
1123
|
+
const key = `${slide.id}|${id}`;
|
|
1124
|
+
fxParamEdits[key] = { ...(fxParamEdits[key] ?? {}), ...(patch) };
|
|
1125
|
+
const build = builds[cur];
|
|
1126
|
+
const profile = qualityProfile(build.cfg.quality ?? deck.defaults.quality);
|
|
1127
|
+
const mode = (build.cfg.mode ?? "dark") as "dark" | "light";
|
|
1128
|
+
if (isPersistentFx(id)) {
|
|
1129
|
+
// One deck-wide instance: params live under the "deck" key.
|
|
1130
|
+
fxParamEdits[`deck|${id}`] = { ...(fxParamEdits[`deck|${id}`] ?? {}), ...(patch) };
|
|
1131
|
+
buildPersistent();
|
|
1132
|
+
} else if (isLayerRef(id)) {
|
|
1133
|
+
// A layer effect may REPLACE the native content: rebuild the whole slide
|
|
1134
|
+
// (the boot path), which keeps the native content when the replacement
|
|
1135
|
+
// fails to construct instead of leaving the slide blank.
|
|
1136
|
+
rebuildSlide(cur, {}, false);
|
|
1137
|
+
} else if (id.startsWith("local:")) {
|
|
1138
|
+
// Dispose and rebuild every local handle: they share one array and the
|
|
1139
|
+
// factory is the only place params are read.
|
|
1140
|
+
disposeLocalFx(cur);
|
|
1141
|
+
build.localFx = localEffectsFor(slide, build.palette, profile, mode, build.group, cur);
|
|
1142
|
+
} else {
|
|
1143
|
+
if (build.background) {
|
|
1144
|
+
build.group.remove(build.background.g);
|
|
1145
|
+
disposeTree(build.background.g);
|
|
1146
|
+
}
|
|
1147
|
+
const next = backgroundFromEffects(slide, build.palette, profile, mode);
|
|
1148
|
+
build.background = next;
|
|
1149
|
+
if (next) {
|
|
1150
|
+
next.g.position.z = -2;
|
|
1151
|
+
markBackdrop(next.g);
|
|
1152
|
+
sortAboveVeil(next.g);
|
|
1153
|
+
build.group.add(next.g);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
syncPost();
|
|
1157
|
+
rig.render();
|
|
1158
|
+
}
|
|
1159
|
+
|
|
824
1160
|
const hud = createHud({
|
|
825
1161
|
slides: deck.slides.map((s) => ({ id: s.id, title: s.title, effects: [...(s.effects ?? [])] })),
|
|
826
1162
|
// Everything the deck can instantiate: the corpus, plus the `local:`
|
|
827
1163
|
// modules embedded in THIS file. The panel offers exactly this.
|
|
828
1164
|
catalogue: [
|
|
829
|
-
...Object.values(REGISTRY).map((e) => ({ id: e.card.id, kind: e.card.kind as string })),
|
|
1165
|
+
...Object.values(REGISTRY).map((e) => ({ id: e.card.id, kind: e.card.kind as string, ...(e.card.persistent ? { persistent: true } : {}) })),
|
|
830
1166
|
...Object.values(localCards()).map((c) => ({ id: `local:${c.id}`, kind: c.kind as string })),
|
|
831
1167
|
],
|
|
832
1168
|
deckEffects: (deck.effects ?? []).map((e) => e.id),
|
|
1169
|
+
persistentEffects: () => [...persistentIds],
|
|
833
1170
|
defaults: deck.defaults,
|
|
834
1171
|
overridden: overriddenKeys(),
|
|
835
1172
|
derivedHash: (window.__DECK as unknown as { derivedHash?: string }).derivedHash ?? "",
|
|
@@ -862,6 +1199,12 @@ async function boot(): Promise<void> {
|
|
|
862
1199
|
if (Object.keys(schema).length === 0) continue;
|
|
863
1200
|
out.push({ id: ref.id, schema, values: paramsFor(slide.id, ref) });
|
|
864
1201
|
}
|
|
1202
|
+
// Deck-wide persistent cards carry their params under the "deck" key.
|
|
1203
|
+
const authored = new Map((deck.effects ?? []).map((e) => [e.id, e]));
|
|
1204
|
+
for (const id of persistentIds) {
|
|
1205
|
+
const schema = (REGISTRY[id]?.card.params ?? {}) as Record<string, unknown>;
|
|
1206
|
+
if (Object.keys(schema).length) out.push({ id, schema, values: paramsFor("deck", authored.get(id) ?? { id }) });
|
|
1207
|
+
}
|
|
865
1208
|
return out;
|
|
866
1209
|
},
|
|
867
1210
|
/** Re-instantiate ONE effect of the current slide under edited params. */
|
|
@@ -872,42 +1215,23 @@ async function boot(): Promise<void> {
|
|
|
872
1215
|
const key = `${slideId}|${id}`;
|
|
873
1216
|
fxParamEdits[key] = { ...(fxParamEdits[key] ?? {}), ...(patch as FxParams) };
|
|
874
1217
|
},
|
|
875
|
-
applyEffectParams: (id, patch) =>
|
|
876
|
-
const slide = deck.slides[cur];
|
|
877
|
-
const key = `${slide.id}|${id}`;
|
|
878
|
-
fxParamEdits[key] = { ...(fxParamEdits[key] ?? {}), ...(patch as FxParams) };
|
|
879
|
-
const build = builds[cur];
|
|
880
|
-
const profile = qualityProfile(build.cfg.quality ?? deck.defaults.quality);
|
|
881
|
-
const mode = (build.cfg.mode ?? "dark") as "dark" | "light";
|
|
882
|
-
if (id.startsWith("local:")) {
|
|
883
|
-
// Dispose and rebuild every local handle: they share one array and the
|
|
884
|
-
// factory is the only place params are read.
|
|
885
|
-
disposeLocalFx(cur);
|
|
886
|
-
build.localFx = localEffectsFor(slide, build.palette, profile, mode, build.group, cur);
|
|
887
|
-
} else {
|
|
888
|
-
if (build.background) {
|
|
889
|
-
build.group.remove(build.background.g);
|
|
890
|
-
disposeTree(build.background.g);
|
|
891
|
-
}
|
|
892
|
-
const next = backgroundFromEffects(slide, build.palette, profile, mode);
|
|
893
|
-
build.background = next;
|
|
894
|
-
if (next) {
|
|
895
|
-
next.g.position.z = -2;
|
|
896
|
-
markBackdrop(next.g);
|
|
897
|
-
sortAboveVeil(next.g);
|
|
898
|
-
build.group.add(next.g);
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
syncPost();
|
|
902
|
-
rig.render();
|
|
903
|
-
},
|
|
1218
|
+
applyEffectParams: (id, patch) => applyParamEdit(id, patch as FxParams),
|
|
904
1219
|
/**
|
|
905
1220
|
* Recompose the current slide. Flipping `background.visible` used to stand
|
|
906
1221
|
* in for this, which reached neither the post stack nor the `local:`
|
|
907
1222
|
* modules — a removed `post` card kept rendering until a reload.
|
|
908
1223
|
*/
|
|
909
|
-
applyEffects: (ids) => {
|
|
910
|
-
|
|
1224
|
+
applyEffects: (ids, scope) => {
|
|
1225
|
+
// Persistent cards are deck-wide singletons: a deck-scope list decides
|
|
1226
|
+
// the set (re-created once), and they never enter a slide's list.
|
|
1227
|
+
if (scope === "deck") {
|
|
1228
|
+
const next = ids.filter(isPersistentFx);
|
|
1229
|
+
if (next.join("\u0000") !== persistentIds.join("\u0000")) {
|
|
1230
|
+
persistentIds = next;
|
|
1231
|
+
buildPersistent();
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
fxSetEdits[deck.slides[cur].id] = ids.filter((id) => !isPersistentFx(id));
|
|
911
1235
|
rebuildSlide(cur, {}, true);
|
|
912
1236
|
},
|
|
913
1237
|
});
|
|
@@ -973,6 +1297,7 @@ async function boot(): Promise<void> {
|
|
|
973
1297
|
const i = hashIndex();
|
|
974
1298
|
if (i !== null) navTo(i, false);
|
|
975
1299
|
});
|
|
1300
|
+
buildPersistent();
|
|
976
1301
|
snapTo(hashIndex() ?? 0);
|
|
977
1302
|
|
|
978
1303
|
const api: Deck3dApi = {
|
|
@@ -985,6 +1310,7 @@ async function boot(): Promise<void> {
|
|
|
985
1310
|
setTime: (seconds: number) => applyTime(seconds),
|
|
986
1311
|
ready: () => Promise.resolve(),
|
|
987
1312
|
measure,
|
|
1313
|
+
fonts,
|
|
988
1314
|
peaks,
|
|
989
1315
|
effects: () => ({
|
|
990
1316
|
active: rig.passNames(),
|
|
@@ -993,6 +1319,44 @@ async function boot(): Promise<void> {
|
|
|
993
1319
|
errors: localFxErrors.map((e) => ({ ...e })),
|
|
994
1320
|
}),
|
|
995
1321
|
debug: {
|
|
1322
|
+
/** Apply an effect param edit on the current slide, exactly as the configurator does. */
|
|
1323
|
+
applyParams: (id: string, patch: Record<string, unknown>) => applyParamEdit(id, patch as FxParams),
|
|
1324
|
+
/**
|
|
1325
|
+
* Pin a transition `from → to` (1-based) at progress `p` and draw it:
|
|
1326
|
+
* mid-flight probes (parallax, chrome fly-out) and `compare --transition`.
|
|
1327
|
+
*/
|
|
1328
|
+
transitionAt: (from1: number, to1: number, p: number) => {
|
|
1329
|
+
frozen = frozen ?? 0;
|
|
1330
|
+
snapTo(Math.max(0, Math.min(builds.length - 1, from1 - 1)));
|
|
1331
|
+
goTo(Math.max(0, Math.min(builds.length - 1, to1 - 1)));
|
|
1332
|
+
holdT = Math.min(1, Math.max(0, p));
|
|
1333
|
+
stepAnim(0);
|
|
1334
|
+
rig.camera.position.copy(camState.pos);
|
|
1335
|
+
rig.camera.lookAt(camState.target);
|
|
1336
|
+
applyLens();
|
|
1337
|
+
fader.apply(fadeWeights());
|
|
1338
|
+
tickLayers(cur, frozen);
|
|
1339
|
+
if (anim) tickLayers(anim.leaving, frozen);
|
|
1340
|
+
drivePersistent(frozen);
|
|
1341
|
+
rig.render(frozen);
|
|
1342
|
+
},
|
|
1343
|
+
/** Persistent effects: id, parent kind and per-node layer masks (+ the mirror's). */
|
|
1344
|
+
persistent: () =>
|
|
1345
|
+
persistent.map((fx) => {
|
|
1346
|
+
const o = fx.handle.object as THREE.Object3D | undefined;
|
|
1347
|
+
const masks: number[] = [];
|
|
1348
|
+
o?.traverse((n) => masks.push(n.layers.mask));
|
|
1349
|
+
return {
|
|
1350
|
+
id: fx.id,
|
|
1351
|
+
parent: o?.parent === rig.scene ? "scene" : o?.parent ? "other" : "none",
|
|
1352
|
+
masks,
|
|
1353
|
+
mirrorMask: rig.mirrorMask(),
|
|
1354
|
+
state: (fx.handle as { debug?: () => unknown }).debug?.() ?? null,
|
|
1355
|
+
};
|
|
1356
|
+
}),
|
|
1357
|
+
/** Layer effects on the current slide, with their optional debug state. */
|
|
1358
|
+
layers: () =>
|
|
1359
|
+
builds[cur].layerFx.map((fx) => ({ id: fx.id, dead: fx.dead, state: (fx.handle as { debug?: () => unknown }).debug?.() ?? null })),
|
|
996
1360
|
titleGlyphs: () => {
|
|
997
1361
|
const title = builds[cur].labels.find((l) => l.kind === "title");
|
|
998
1362
|
if (!title) return 0;
|