@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/post.ts
CHANGED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
* - nothing here allocates per frame beyond what three's own passes do.
|
|
15
15
|
*/
|
|
16
16
|
import * as THREE from "three";
|
|
17
|
-
import { EffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js";
|
|
18
17
|
import { BokehPass } from "three/examples/jsm/postprocessing/BokehPass.js";
|
|
18
|
+
import { EffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js";
|
|
19
19
|
import { FilmPass } from "three/examples/jsm/postprocessing/FilmPass.js";
|
|
20
20
|
import { OutlinePass } from "three/examples/jsm/postprocessing/OutlinePass.js";
|
|
21
21
|
import { OutputPass } from "three/examples/jsm/postprocessing/OutputPass.js";
|
|
22
|
-
import {
|
|
22
|
+
import { FullScreenQuad, Pass } from "three/examples/jsm/postprocessing/Pass.js";
|
|
23
23
|
import { SAOPass } from "three/examples/jsm/postprocessing/SAOPass.js";
|
|
24
24
|
import { ShaderPass } from "three/examples/jsm/postprocessing/ShaderPass.js";
|
|
25
25
|
import { SMAAPass } from "three/examples/jsm/postprocessing/SMAAPass.js";
|
|
@@ -193,6 +193,9 @@ class DeterministicFilmPass extends FilmPass {
|
|
|
193
193
|
* uses, so the mask respects the same depth isolation as the main pass.
|
|
194
194
|
*/
|
|
195
195
|
class SelectiveBloomPass extends Pass {
|
|
196
|
+
private readonly scene: THREE.Scene;
|
|
197
|
+
private readonly camera: THREE.Camera;
|
|
198
|
+
private readonly draw: (renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera) => void;
|
|
196
199
|
private readonly target: THREE.WebGLRenderTarget;
|
|
197
200
|
private readonly bloom: UnrealBloomPass;
|
|
198
201
|
private readonly mix: ShaderPass;
|
|
@@ -201,11 +204,14 @@ class SelectiveBloomPass extends Pass {
|
|
|
201
204
|
selected = new Set<THREE.Object3D>();
|
|
202
205
|
|
|
203
206
|
constructor(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
+
scene: THREE.Scene,
|
|
208
|
+
camera: THREE.Camera,
|
|
209
|
+
draw: (renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.Camera) => void,
|
|
207
210
|
) {
|
|
208
211
|
super();
|
|
212
|
+
this.scene = scene;
|
|
213
|
+
this.camera = camera;
|
|
214
|
+
this.draw = draw;
|
|
209
215
|
this.target = new THREE.WebGLRenderTarget(1, 1, { type: THREE.HalfFloatType });
|
|
210
216
|
this.bloom = new UnrealBloomPass(new THREE.Vector2(1, 1), 0.9, 0.5, 0.15);
|
|
211
217
|
this.mix = new ShaderPass(AddShader);
|
package/src/runtime/scene.ts
CHANGED
|
@@ -38,6 +38,8 @@ export interface SceneRig {
|
|
|
38
38
|
shadowCamera: () => { left: number; right: number; top: number; bottom: number; near: number; far: number; pos: [number, number, number]; castShadow: boolean };
|
|
39
39
|
/** Whether backdrop geometry is in the reflection, for `debug.look()`. */
|
|
40
40
|
reflectsBackdrop: () => boolean;
|
|
41
|
+
/** Layer mask of the floor reflection's camera (0 when there is no mirror). */
|
|
42
|
+
mirrorMask: () => number;
|
|
41
43
|
/** Live floor roughness (0 = mirror), read off the shader, for `debug.look()`. */
|
|
42
44
|
floorMatte: () => number;
|
|
43
45
|
/** Live reflection strength (1 = full mirror), read off the shader, for `debug.look()`. */
|
|
@@ -221,6 +223,20 @@ interface RigParts {
|
|
|
221
223
|
*/
|
|
222
224
|
export const BACKDROP_LAYER = 1;
|
|
223
225
|
const CONTENT_LAYER = 0;
|
|
226
|
+
/**
|
|
227
|
+
* Drawn in the content pass but never seen by the floor reflection's camera
|
|
228
|
+
* (its mask is content + optionally backdrop): persistent deck chrome lives
|
|
229
|
+
* here, so the camera-pinned frame never mirrors into the floor.
|
|
230
|
+
*/
|
|
231
|
+
export const OVERLAY_LAYER = 2;
|
|
232
|
+
|
|
233
|
+
/** Put `object` and everything under it on the overlay layer. */
|
|
234
|
+
export function markOverlay(object: THREE.Object3D): void {
|
|
235
|
+
object.traverse((n) => {
|
|
236
|
+
n.layers.set(OVERLAY_LAYER);
|
|
237
|
+
n.userData.overlay = true;
|
|
238
|
+
});
|
|
239
|
+
}
|
|
224
240
|
|
|
225
241
|
/** Put `object` and everything under it on the backdrop layer. */
|
|
226
242
|
export function markBackdrop(object: THREE.Object3D): void {
|
|
@@ -299,6 +315,7 @@ function renderLayered(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera
|
|
|
299
315
|
renderer.autoClear = false;
|
|
300
316
|
scene.background = null;
|
|
301
317
|
camera.layers.set(CONTENT_LAYER);
|
|
318
|
+
camera.layers.enable(OVERLAY_LAYER);
|
|
302
319
|
// The casters are visible to THIS camera: refresh the map here, for the
|
|
303
320
|
// content-on-content shadows in this pass and the floor in the next frame.
|
|
304
321
|
renderer.shadowMap.needsUpdate = true;
|
|
@@ -313,11 +330,16 @@ function renderLayered(renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera
|
|
|
313
330
|
* Reports as `RenderPass` in `effects().active` so the pass names stay stable.
|
|
314
331
|
*/
|
|
315
332
|
class BackdropRenderPass extends Pass {
|
|
333
|
+
private readonly rigScene: THREE.Scene;
|
|
334
|
+
private readonly rigCamera: THREE.Camera;
|
|
335
|
+
|
|
316
336
|
constructor(
|
|
317
|
-
|
|
318
|
-
|
|
337
|
+
rigScene: THREE.Scene,
|
|
338
|
+
rigCamera: THREE.Camera,
|
|
319
339
|
) {
|
|
320
340
|
super();
|
|
341
|
+
this.rigScene = rigScene;
|
|
342
|
+
this.rigCamera = rigCamera;
|
|
321
343
|
this.clear = true;
|
|
322
344
|
this.needsSwap = false;
|
|
323
345
|
}
|
|
@@ -412,6 +434,7 @@ export function createSceneRig(profile: QualityProfile): SceneRig {
|
|
|
412
434
|
rimColor: () => r.rimLight.color,
|
|
413
435
|
floorMode: () => floorNow,
|
|
414
436
|
reflectsBackdrop: () => backdropReflected,
|
|
437
|
+
mirrorMask: () => r.mirror?.camera.layers.mask ?? 0,
|
|
415
438
|
// Read from the uniform, not from the config that was meant to set it: a
|
|
416
439
|
// knob that stages a value without reaching the frame must still fail.
|
|
417
440
|
floorMatte: () => (r.mirror ? mirrorUniforms(r.mirror).matte.value : 0),
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Camera motions between slides — pure functions, no renderer.
|
|
3
|
+
*
|
|
4
|
+
* `makeMotion(kind, from, to, opts)` is built ONCE when a move starts and
|
|
5
|
+
* returns `u ∈ [0,1] → Sample`. The runtime only advances `u`, so a pinned
|
|
6
|
+
* clock (`setTime`) gives the same pose every time, and a reversed move is
|
|
7
|
+
* `u → 1 − u` on the same curve.
|
|
8
|
+
*
|
|
9
|
+
* - `dolly` / `swing` / `fade` / `cut` keep the pre-change formulas exactly.
|
|
10
|
+
* - `revolve` / `crane` / `bank` / `flythrough` are canned key lists fed through
|
|
11
|
+
* the same path code as the author's `path` (`cameraPath`).
|
|
12
|
+
* - Keys live in the TRAVEL FRAME (from-camera → to-camera): `offset = [r, u, f]`
|
|
13
|
+
* as fractions of the travel length, so a path reads the same on any rail or
|
|
14
|
+
* spacing. The end points are implied and pinned, so every move lands
|
|
15
|
+
* exactly on the anchor.
|
|
16
|
+
*/
|
|
17
|
+
import * as THREE from "three";
|
|
18
|
+
import type { CameraPath, PathEase, PathKey } from "../ir/types.js";
|
|
19
|
+
|
|
20
|
+
export type { CameraPath, PathEase, PathKey };
|
|
21
|
+
|
|
22
|
+
export const TRANSITION_IDS = ["dolly", "swing", "revolve", "crane", "bank", "flythrough", "fade", "iris", "path", "cut"] as const;
|
|
23
|
+
export type TransitionId = (typeof TRANSITION_IDS)[number];
|
|
24
|
+
|
|
25
|
+
export interface Pose {
|
|
26
|
+
pos: THREE.Vector3;
|
|
27
|
+
target: THREE.Vector3;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Sample {
|
|
31
|
+
pos: THREE.Vector3;
|
|
32
|
+
target: THREE.Vector3;
|
|
33
|
+
/** Roll in radians. */
|
|
34
|
+
roll: number;
|
|
35
|
+
/** Field of view in degrees. */
|
|
36
|
+
fov: number;
|
|
37
|
+
/** Screen cover 0..1 (`fade`: opacity, `iris`: closed fraction). */
|
|
38
|
+
cover: number;
|
|
39
|
+
overlay: "none" | "fade" | "iris";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type Motion = (u: number) => Sample;
|
|
43
|
+
|
|
44
|
+
export interface MotionOptions {
|
|
45
|
+
/** Scales canned offsets and rolls (card param, default 1). */
|
|
46
|
+
amount?: number;
|
|
47
|
+
/** Author path for `path`. */
|
|
48
|
+
path?: CameraPath;
|
|
49
|
+
/** Deck field of view, restored at the ends. */
|
|
50
|
+
baseFov?: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const EASES: Record<PathEase, (t: number) => number> = {
|
|
54
|
+
inOut: (t) => (t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2),
|
|
55
|
+
in: (t) => t * t * t,
|
|
56
|
+
out: (t) => 1 - (1 - t) ** 3,
|
|
57
|
+
linear: (t) => t,
|
|
58
|
+
};
|
|
59
|
+
export const easeInOut = EASES.inOut;
|
|
60
|
+
|
|
61
|
+
const smooth = (x: number) => x * x * (3 - 2 * x);
|
|
62
|
+
const clamp01 = (x: number) => Math.min(1, Math.max(0, x));
|
|
63
|
+
|
|
64
|
+
/** Piecewise-smoothstep through `(t, v)` stops (sorted by t). */
|
|
65
|
+
function interp(stops: Array<[number, number]>, x: number): number {
|
|
66
|
+
if (x <= stops[0][0]) return stops[0][1];
|
|
67
|
+
for (let i = 1; i < stops.length; i++) {
|
|
68
|
+
const [t1, v1] = stops[i];
|
|
69
|
+
const [t0, v0] = stops[i - 1];
|
|
70
|
+
if (x <= t1) return v0 + (v1 - v0) * smooth(t1 > t0 ? (x - t0) / (t1 - t0) : 1);
|
|
71
|
+
}
|
|
72
|
+
return stops[stops.length - 1][1];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Canned key lists for the built-in flying kinds (amount = 1). */
|
|
76
|
+
export function cannedKeys(kind: TransitionId): PathKey[] | null {
|
|
77
|
+
switch (kind) {
|
|
78
|
+
case "revolve":
|
|
79
|
+
// Swing wide to the travel-right side, lock onto the arriving slide early
|
|
80
|
+
// and arc in around it.
|
|
81
|
+
return [
|
|
82
|
+
{ t: 0.35, offset: [0.32, 0.06, -0.05], look: 0.75 },
|
|
83
|
+
{ t: 0.7, offset: [0.22, 0.03, 0.08], look: 1 },
|
|
84
|
+
];
|
|
85
|
+
case "crane":
|
|
86
|
+
return [{ t: 0.5, offset: [0, 0.3, 0], look: 0.5 }];
|
|
87
|
+
case "bank":
|
|
88
|
+
return [
|
|
89
|
+
{ t: 0.35, offset: [0.06, 0, 0], roll: 8 },
|
|
90
|
+
{ t: 0.7, offset: [0.03, 0, 0], roll: 3 },
|
|
91
|
+
];
|
|
92
|
+
case "flythrough":
|
|
93
|
+
return [{ t: 0.5, offset: [-0.04, -0.035, 0], roll: -4, fov: 52 }];
|
|
94
|
+
default:
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function scaleKeys(keys: PathKey[], amount: number, baseFov: number): PathKey[] {
|
|
100
|
+
return keys.map((k) => ({
|
|
101
|
+
...k,
|
|
102
|
+
offset: k.offset ? [k.offset[0] * amount, k.offset[1] * amount, k.offset[2] * amount] : undefined,
|
|
103
|
+
roll: k.roll === undefined ? undefined : k.roll * amount,
|
|
104
|
+
fov: k.fov === undefined ? undefined : baseFov + (k.fov - baseFov) * amount,
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** The travel frame: forward along the move, up = world up orthogonalised. */
|
|
109
|
+
export function travelFrame(from: THREE.Vector3, to: THREE.Vector3): { F: THREE.Vector3; U: THREE.Vector3; R: THREE.Vector3; L: number } {
|
|
110
|
+
const d = to.clone().sub(from);
|
|
111
|
+
const L = d.length();
|
|
112
|
+
const F = L > 1e-9 ? d.divideScalar(L) : new THREE.Vector3(0, 0, -1);
|
|
113
|
+
const U = new THREE.Vector3(0, 1, 0);
|
|
114
|
+
U.addScaledVector(F, -U.dot(F));
|
|
115
|
+
if (U.lengthSq() < 1e-9) U.set(0, 0, 1).addScaledVector(F, -F.z);
|
|
116
|
+
U.normalize();
|
|
117
|
+
const R = F.clone().cross(U).normalize();
|
|
118
|
+
return { F, U, R, L };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function pathMotion(from: Pose, to: Pose, keys: PathKey[], ease: (t: number) => number, baseFov: number): Motion {
|
|
122
|
+
const { F, U, R, L } = travelFrame(from.pos, to.pos);
|
|
123
|
+
const sorted = [...keys].sort((a, b) => a.t - b.t);
|
|
124
|
+
const pts = [from.pos.clone()];
|
|
125
|
+
for (const k of sorted) {
|
|
126
|
+
const [r, u, f] = k.offset ?? [0, 0, 0];
|
|
127
|
+
pts.push(
|
|
128
|
+
from.pos
|
|
129
|
+
.clone()
|
|
130
|
+
.lerp(to.pos, k.t)
|
|
131
|
+
.addScaledVector(R, r * L)
|
|
132
|
+
.addScaledVector(U, u * L)
|
|
133
|
+
.addScaledVector(F, f * L),
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
pts.push(to.pos.clone());
|
|
137
|
+
const curve = new THREE.CatmullRomCurve3(pts, false, "centripetal");
|
|
138
|
+
const looks: Array<[number, number]> = [[0, 0], ...sorted.filter((k) => k.look !== undefined).map((k) => [k.t, k.look!] as [number, number]), [1, 1]];
|
|
139
|
+
const rolls: Array<[number, number]> = [[0, 0], ...sorted.filter((k) => k.roll !== undefined).map((k) => [k.t, k.roll!] as [number, number]), [1, 0]];
|
|
140
|
+
const fovs: Array<[number, number]> = [[0, baseFov], ...sorted.filter((k) => k.fov !== undefined).map((k) => [k.t, k.fov!] as [number, number]), [1, baseFov]];
|
|
141
|
+
const authoredLook = looks.length > 2;
|
|
142
|
+
return (u) => {
|
|
143
|
+
const x = clamp01(u);
|
|
144
|
+
const e = ease(x);
|
|
145
|
+
const pos = x <= 0 ? from.pos.clone() : x >= 1 ? to.pos.clone() : curve.getPointAt(e);
|
|
146
|
+
const w = authoredLook ? interp(looks, e) : e;
|
|
147
|
+
return {
|
|
148
|
+
pos,
|
|
149
|
+
target: from.target.clone().lerp(to.target, w),
|
|
150
|
+
roll: x >= 1 ? 0 : THREE.MathUtils.degToRad(interp(rolls, e)),
|
|
151
|
+
fov: x >= 1 ? baseFov : interp(fovs, e),
|
|
152
|
+
cover: 0,
|
|
153
|
+
overlay: "none",
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Build the motion for one move. `from` is the live camera pose (a move may
|
|
160
|
+
* start mid-flight), `to` the arriving anchor (`pos` = camera, `target`).
|
|
161
|
+
*/
|
|
162
|
+
export function makeMotion(kind: string, from: Pose, to: Pose, opts: MotionOptions = {}): Motion {
|
|
163
|
+
const baseFov = opts.baseFov ?? 42;
|
|
164
|
+
const amount = opts.amount ?? 1;
|
|
165
|
+
const flat = (pos: THREE.Vector3, target: THREE.Vector3, cover = 0, overlay: Sample["overlay"] = "none"): Sample => ({
|
|
166
|
+
pos,
|
|
167
|
+
target,
|
|
168
|
+
roll: 0,
|
|
169
|
+
fov: baseFov,
|
|
170
|
+
cover,
|
|
171
|
+
overlay,
|
|
172
|
+
});
|
|
173
|
+
switch (kind) {
|
|
174
|
+
case "cut":
|
|
175
|
+
return () => flat(to.pos.clone(), to.target.clone());
|
|
176
|
+
case "fade":
|
|
177
|
+
case "iris":
|
|
178
|
+
return (u) => {
|
|
179
|
+
const x = clamp01(u);
|
|
180
|
+
const after = x >= 0.5;
|
|
181
|
+
// Fully covered at the mid-point, where the camera switches.
|
|
182
|
+
const cover = x >= 1 ? 0 : smooth(1 - Math.abs(2 * x - 1));
|
|
183
|
+
return flat((after ? to : from).pos.clone(), (after ? to : from).target.clone(), cover, kind);
|
|
184
|
+
};
|
|
185
|
+
case "swing": {
|
|
186
|
+
const mid = from.target.clone().add(to.target).multiplyScalar(0.5);
|
|
187
|
+
return (u) => {
|
|
188
|
+
const x = clamp01(u);
|
|
189
|
+
const k = easeInOut(x);
|
|
190
|
+
const pos = from.pos.clone().lerp(to.pos, k);
|
|
191
|
+
const out = pos.clone().sub(mid).normalize();
|
|
192
|
+
pos.addScaledVector(out, Math.sin(x * Math.PI) * 6 * amount);
|
|
193
|
+
return flat(pos, from.target.clone().lerp(to.target, k));
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
case "path":
|
|
197
|
+
if (opts.path && opts.path.keys.length) return pathMotion(from, to, opts.path.keys, EASES[opts.path.ease ?? "inOut"], baseFov);
|
|
198
|
+
break;
|
|
199
|
+
default: {
|
|
200
|
+
const keys = cannedKeys(kind as TransitionId);
|
|
201
|
+
if (keys) return pathMotion(from, to, scaleKeys(keys, amount, baseFov), easeInOut, baseFov);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// dolly, and any unknown id (validate rejects those; the runtime stays safe).
|
|
205
|
+
return (u) => {
|
|
206
|
+
const k = easeInOut(clamp01(u));
|
|
207
|
+
return flat(from.pos.clone().lerp(to.pos, k), from.target.clone().lerp(to.target, k));
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Play a motion backwards: same curve, time 1 → 0. */
|
|
212
|
+
export const reversed =
|
|
213
|
+
(m: Motion): Motion =>
|
|
214
|
+
(u) =>
|
|
215
|
+
m(1 - u);
|
|
216
|
+
|
|
217
|
+
/** Effective transition for slide `index`: own override, else the cycle, else the deck default. */
|
|
218
|
+
export function resolveTransition(own: string | undefined, index: number, cycle: string[] | undefined, fallback: string | undefined): string {
|
|
219
|
+
if (own) return own;
|
|
220
|
+
if (cycle && cycle.length) return cycle[index % cycle.length];
|
|
221
|
+
return fallback ?? "dolly";
|
|
222
|
+
}
|
package/src/runtime/types.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface Deck3dApi {
|
|
|
27
27
|
setTime: (seconds: number) => void;
|
|
28
28
|
ready: () => Promise<void>;
|
|
29
29
|
measure: () => Measurement[];
|
|
30
|
+
/** Fonts the deck drew with a fallback (sorted, de-duplicated). */
|
|
31
|
+
fonts: () => { fallbacks: string[] };
|
|
30
32
|
peaks: () => number[];
|
|
31
33
|
effects: () => {
|
|
32
34
|
active: string[];
|
|
@@ -36,6 +38,14 @@ export interface Deck3dApi {
|
|
|
36
38
|
errors: Array<{ slide: string; effectId: string; phase: "create" | "tick" | "dispose" }>;
|
|
37
39
|
};
|
|
38
40
|
debug: {
|
|
41
|
+
/** Apply an effect param edit on the current slide, as the configurator does. */
|
|
42
|
+
applyParams: (id: string, patch: Record<string, unknown>) => void;
|
|
43
|
+
/** Pin the transition `from → to` (1-based) at progress `p` and draw that frame. */
|
|
44
|
+
transitionAt: (from1: number, to1: number, p: number) => void;
|
|
45
|
+
/** Persistent effects: parent ("scene" = outside every slide group) and layer masks. */
|
|
46
|
+
persistent: () => Array<{ id: string; parent: "scene" | "other" | "none"; masks: number[]; mirrorMask: number; state: unknown }>;
|
|
47
|
+
/** Layer effects of the current slide with their optional debug state. */
|
|
48
|
+
layers: () => Array<{ id: string; dead: boolean; state: unknown }>;
|
|
39
49
|
titleGlyphs: () => number;
|
|
40
50
|
liftedMessage: () => string | null;
|
|
41
51
|
look: () => {
|
|
@@ -90,13 +100,14 @@ export interface Deck3dApi {
|
|
|
90
100
|
sceneNodes: () => number;
|
|
91
101
|
anchors: () => Array<{ pos: [number, number, number]; rotY: number }>;
|
|
92
102
|
/** Every registered post pass: enabled for the current slide, and the params it was last applied with. */
|
|
93
|
-
post: () => Array<{ id: string; enabled: boolean; params: Record<string,
|
|
103
|
+
post: () => Array<{ id: string; enabled: boolean; params: Record<string, unknown> }>;
|
|
94
104
|
};
|
|
95
105
|
current: () => number;
|
|
96
106
|
}
|
|
97
107
|
|
|
98
108
|
export interface Measurement {
|
|
99
|
-
|
|
109
|
+
/** `layer-text`: a text item drawn by `slide-layer` (id = layout item id). */
|
|
110
|
+
kind: "title" | "label" | "node" | "layer-text";
|
|
100
111
|
id: string;
|
|
101
112
|
text: string;
|
|
102
113
|
rect: { x: number; y: number; w: number; h: number };
|