@blackbelt-technology/pi-dashboard-deck3d 0.9.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/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
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slide space → scene, shared by the imported-pptx built-ins (design D4).
|
|
3
|
+
*
|
|
4
|
+
* The SLIDE FRAME is the slide aspect contain-fitted into the viewport —
|
|
5
|
+
* centred, the largest size that fits (`compare` crops with the same rule).
|
|
6
|
+
* A slide-space point at layer depth `d` maps to the scene point on the plane
|
|
7
|
+
* `d` units toward the camera from the settled target that projects onto the
|
|
8
|
+
* point's frame pixel from the settled pose. At rest every item therefore
|
|
9
|
+
* lands exactly on its mapped rect, whatever the viewport or slide aspect.
|
|
10
|
+
*/
|
|
11
|
+
import type * as THREE_NS from "three";
|
|
12
|
+
import type { FxView } from "./types.js";
|
|
13
|
+
|
|
14
|
+
export interface Frame {
|
|
15
|
+
x0: number;
|
|
16
|
+
y0: number;
|
|
17
|
+
w: number;
|
|
18
|
+
h: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Contain-fit `slideW × slideH` into `vw × vh` CSS px, centred. */
|
|
22
|
+
export function slideFrame(vw: number, vh: number, slideW: number, slideH: number): Frame {
|
|
23
|
+
const a = slideW / slideH;
|
|
24
|
+
if (vw / vh > a) {
|
|
25
|
+
const w = vh * a;
|
|
26
|
+
return { x0: (vw - w) / 2, y0: 0, w, h: vh };
|
|
27
|
+
}
|
|
28
|
+
const h = vw / a;
|
|
29
|
+
return { x0: 0, y0: (vh - h) / 2, w: vw, h };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Camera basis: origin, right, up, forward (unit vectors). */
|
|
33
|
+
export interface Basis {
|
|
34
|
+
origin: THREE_NS.Vector3;
|
|
35
|
+
right: THREE_NS.Vector3;
|
|
36
|
+
up: THREE_NS.Vector3;
|
|
37
|
+
forward: THREE_NS.Vector3;
|
|
38
|
+
/** Camera → target distance. */
|
|
39
|
+
distance: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Basis of the settled pose in the effect's parent space. */
|
|
43
|
+
export function poseBasis(THREE: typeof THREE_NS, view: FxView): Basis {
|
|
44
|
+
const origin = new THREE.Vector3(...view.pose.cam);
|
|
45
|
+
const target = new THREE.Vector3(...view.pose.target);
|
|
46
|
+
const forward = target.clone().sub(origin);
|
|
47
|
+
const distance = forward.length();
|
|
48
|
+
forward.normalize();
|
|
49
|
+
const right = new THREE.Vector3().crossVectors(forward, new THREE.Vector3(0, 1, 0)).normalize();
|
|
50
|
+
const up = new THREE.Vector3().crossVectors(right, forward).normalize();
|
|
51
|
+
return { origin, right, up, forward, distance };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Camera-local basis (the camera looks down −Z): for camera-pinned layers. */
|
|
55
|
+
export function cameraBasis(THREE: typeof THREE_NS, distance: number): Basis {
|
|
56
|
+
return {
|
|
57
|
+
origin: new THREE.Vector3(0, 0, 0),
|
|
58
|
+
right: new THREE.Vector3(1, 0, 0),
|
|
59
|
+
up: new THREE.Vector3(0, 1, 0),
|
|
60
|
+
forward: new THREE.Vector3(0, 0, -1),
|
|
61
|
+
distance,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface PlaneMap {
|
|
66
|
+
/** Scene point of slide-space `(sx, sy)` on this plane. */
|
|
67
|
+
point(sx: number, sy: number): THREE_NS.Vector3;
|
|
68
|
+
/** Scene units per slide unit on this plane. */
|
|
69
|
+
unit: number;
|
|
70
|
+
/** Centre of the slide frame on this plane. */
|
|
71
|
+
centre: THREE_NS.Vector3;
|
|
72
|
+
/** Frame size on this plane in scene units. */
|
|
73
|
+
width: number;
|
|
74
|
+
height: number;
|
|
75
|
+
/** Rotation that turns a +Z-facing XY plane to face the camera. */
|
|
76
|
+
quaternion: THREE_NS.Quaternion;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The plane `depth` units toward the camera from the target, mapped so the
|
|
81
|
+
* slide frame fills exactly its frame rect at viewport `vw × vh`.
|
|
82
|
+
*/
|
|
83
|
+
export function planeMap(
|
|
84
|
+
THREE: typeof THREE_NS,
|
|
85
|
+
basis: Basis,
|
|
86
|
+
fovDeg: number,
|
|
87
|
+
vw: number,
|
|
88
|
+
vh: number,
|
|
89
|
+
slide: { w: number; h: number },
|
|
90
|
+
depth: number,
|
|
91
|
+
): PlaneMap {
|
|
92
|
+
const D = Math.max(0.05, basis.distance - depth);
|
|
93
|
+
const halfH = D * Math.tan((fovDeg * Math.PI) / 360);
|
|
94
|
+
const halfW = halfH * (vw / vh);
|
|
95
|
+
const frame = slideFrame(vw, vh, slide.w, slide.h);
|
|
96
|
+
const base = basis.origin.clone().addScaledVector(basis.forward, D);
|
|
97
|
+
const point = (sx: number, sy: number): THREE_NS.Vector3 => {
|
|
98
|
+
const px = frame.x0 + (sx * frame.w) / slide.w;
|
|
99
|
+
const py = frame.y0 + (sy * frame.h) / slide.h;
|
|
100
|
+
const nx = (px / vw) * 2 - 1;
|
|
101
|
+
const ny = 1 - (py / vh) * 2;
|
|
102
|
+
return base.clone().addScaledVector(basis.right, nx * halfW).addScaledVector(basis.up, ny * halfH);
|
|
103
|
+
};
|
|
104
|
+
const perPx = (2 * halfH) / vh;
|
|
105
|
+
const m = new THREE.Matrix4().makeBasis(basis.right, basis.up, basis.forward.clone().negate());
|
|
106
|
+
return {
|
|
107
|
+
point,
|
|
108
|
+
unit: (perPx * frame.h) / slide.h,
|
|
109
|
+
centre: point(slide.w / 2, slide.h / 2),
|
|
110
|
+
width: perPx * frame.w,
|
|
111
|
+
height: perPx * frame.h,
|
|
112
|
+
quaternion: new THREE.Quaternion().setFromRotationMatrix(m),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Screen rect (CSS px) of scene points projected through `camera`. */
|
|
117
|
+
export function projectPoints(
|
|
118
|
+
points: THREE_NS.Vector3[],
|
|
119
|
+
camera: THREE_NS.Camera,
|
|
120
|
+
width: number,
|
|
121
|
+
height: number,
|
|
122
|
+
): { x: number; y: number; w: number; h: number } {
|
|
123
|
+
let minX = Number.POSITIVE_INFINITY;
|
|
124
|
+
let minY = Number.POSITIVE_INFINITY;
|
|
125
|
+
let maxX = Number.NEGATIVE_INFINITY;
|
|
126
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
127
|
+
for (const p of points) {
|
|
128
|
+
const v = p.clone().project(camera);
|
|
129
|
+
const x = ((v.x + 1) / 2) * width;
|
|
130
|
+
const y = ((1 - v.y) / 2) * height;
|
|
131
|
+
minX = Math.min(minX, x);
|
|
132
|
+
minY = Math.min(minY, y);
|
|
133
|
+
maxX = Math.max(maxX, x);
|
|
134
|
+
maxY = Math.max(maxY, y);
|
|
135
|
+
}
|
|
136
|
+
return { x: minX, y: minY, w: maxX - minX, h: maxY - minY };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Font-name → deck font asset id (`font-` + lowercase, non-alnum runs → `-`). */
|
|
140
|
+
export function fontAssetId(name: string): string {
|
|
141
|
+
return `font-${name.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
|
|
142
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic stub asset bundle for the imported-pptx built-ins: a sample
|
|
3
|
+
* layout, an outline, a polyline icon and a chrome image. Powers `fx preview`
|
|
4
|
+
* (copied to `assets/preview/`) and the `business-2031` coverage fixture
|
|
5
|
+
* (`fixtures/business-2031/assets/`). Generated, never hand-edited:
|
|
6
|
+
* `tsx scripts/gen-stub-assets.ts` rewrites both copies, and a test fails
|
|
7
|
+
* when they drift from this module.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { IconOutput } from "../art/icon.js";
|
|
11
|
+
import { encodePng } from "../art/png.js";
|
|
12
|
+
import type { Outline } from "../art/trace.js";
|
|
13
|
+
import type { Layout, LayoutItem } from "../pptx/types.js";
|
|
14
|
+
|
|
15
|
+
export const STUB_SLIDE = "s01";
|
|
16
|
+
|
|
17
|
+
const base = { rotation: 0, flipH: false, flipV: false };
|
|
18
|
+
const run = (text: string, size: number, color = "#161e23") => ({ text, size, bold: true, italic: false, underline: false, color, font: "Poppins" });
|
|
19
|
+
const para = (text: string, size: number, bullet?: string) => ({ align: "l" as const, lineSpacing: 1, spaceBefore: 0, spaceAfter: 12, level: 0, ...(bullet ? { bullet } : {}), runs: [run(text, size)] });
|
|
20
|
+
const text = (id: string, x: number, y: number, w: number, h: number, paragraphs: ReturnType<typeof para>[], placeholder?: string): LayoutItem => ({
|
|
21
|
+
id,
|
|
22
|
+
kind: "text",
|
|
23
|
+
rect: { x, y, w, h },
|
|
24
|
+
...base,
|
|
25
|
+
...(placeholder ? { placeholder } : {}),
|
|
26
|
+
anchor: "t",
|
|
27
|
+
insets: { l: 14.4, t: 7.2, r: 14.4, b: 7.2 },
|
|
28
|
+
vertical: false,
|
|
29
|
+
autofit: "none",
|
|
30
|
+
paragraphs,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export function stubLayout(): Layout {
|
|
34
|
+
return {
|
|
35
|
+
version: 1,
|
|
36
|
+
size: { w: 1920, h: 1080 },
|
|
37
|
+
theme: { colors: { dk1: "#161e23", lt1: "#ffffff", accent1: "#f67519", accent2: "#4472c4" }, fonts: { major: "Poppins", minor: "Poppins" } },
|
|
38
|
+
slides: [
|
|
39
|
+
{
|
|
40
|
+
id: STUB_SLIDE,
|
|
41
|
+
index: 1,
|
|
42
|
+
title: "Stub slide",
|
|
43
|
+
fingerprint: "stub",
|
|
44
|
+
background: { color: "#ffffff" },
|
|
45
|
+
items: [
|
|
46
|
+
text("s01-i001", 120, 80, 1100, 160, [para("Stub slide", 88)], "title"),
|
|
47
|
+
text("s01-i002", 120, 300, 900, 360, [para("First point", 48, "\u2022"), para("Second point", 48, "\u2022")]),
|
|
48
|
+
{ id: "s01-i003", kind: "rect", rect: { x: 120, y: 760, w: 600, h: 70 }, ...base, preset: "roundRect", fill: "#f67519", alpha: 1 },
|
|
49
|
+
{ id: "s01-i004", kind: "img", rect: { x: 1300, y: 300, w: 400, h: 400 }, ...base, media: "stub-chrome.png", asset: "stub-chrome", crop: { l: 0, t: 0, r: 0, b: 0 } },
|
|
50
|
+
{ id: "s01-i005", kind: "img", rect: { x: 1480, y: 100, w: 140, h: 140 }, ...base, media: "stub-chrome.png", asset: "stub-chrome", crop: { l: 0, t: 0, r: 0, b: 0 } },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function stubOutline(): Outline {
|
|
58
|
+
return {
|
|
59
|
+
version: 1,
|
|
60
|
+
width: 100,
|
|
61
|
+
height: 100,
|
|
62
|
+
polygons: [
|
|
63
|
+
{
|
|
64
|
+
color: "#f67519",
|
|
65
|
+
outer: [[0, 0], [100, 0], [100, 100], [0, 100]],
|
|
66
|
+
holes: [[[30, 30], [30, 70], [70, 70], [70, 30]]],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function stubIcon(): IconOutput {
|
|
73
|
+
return {
|
|
74
|
+
version: 1,
|
|
75
|
+
viewBox: [0, 0, 24, 24],
|
|
76
|
+
polylines: [
|
|
77
|
+
{ points: [[12, 3], [19, 7], [19, 17], [12, 21], [5, 17], [5, 7]], width: 2, closed: true },
|
|
78
|
+
{ points: [[8.5, 12.5], [11, 15], [16, 9]], width: 2, closed: false },
|
|
79
|
+
],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** 64×64 corner mark: opaque orange above the anti-diagonal, transparent below. */
|
|
84
|
+
export function stubChrome(): Uint8Array {
|
|
85
|
+
const n = 64;
|
|
86
|
+
const data = new Uint8Array(n * n * 4);
|
|
87
|
+
for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) if (x + y < n) data.set([0xf6, 0x75, 0x19, 255], (y * n + x) * 4);
|
|
88
|
+
return encodePng({ width: n, height: n, data });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const json = (v: unknown) => `${JSON.stringify(v, null, 2)}\n`;
|
|
92
|
+
|
|
93
|
+
/** File name → bytes, as written to both asset directories. */
|
|
94
|
+
export function stubFiles(): Record<string, string | Uint8Array> {
|
|
95
|
+
return {
|
|
96
|
+
"stub-layout.json": json(stubLayout()),
|
|
97
|
+
"stub-outline.json": json(stubOutline()),
|
|
98
|
+
"stub-icon.json": json(stubIcon()),
|
|
99
|
+
"stub-chrome.png": stubChrome(),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const STUB_ASSET_META: Array<{ id: string; file: string; mime: string }> = [
|
|
104
|
+
{ id: "stub-chrome", file: "stub-chrome.png", mime: "image/png" },
|
|
105
|
+
{ id: "stub-icon", file: "stub-icon.json", mime: "application/json" },
|
|
106
|
+
{ id: "stub-layout", file: "stub-layout.json", mime: "application/json" },
|
|
107
|
+
{ id: "stub-outline", file: "stub-outline.json", mime: "application/json" },
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
/** Params that make each built-in render the stub bundle (`fx preview`, fixture). */
|
|
111
|
+
export const STUB_PARAMS: Record<string, Record<string, unknown>> = {
|
|
112
|
+
"slide-layer": { layout: "stub-layout", slide: STUB_SLIDE, mode: "free" },
|
|
113
|
+
art3d: { outline: "stub-outline", scale: 3.2, sway: 0.3, sweep: true },
|
|
114
|
+
icon3d: { asset: "stub-icon", layout: "stub-layout", slide: STUB_SLIDE, item: "s01-i005", card: true },
|
|
115
|
+
"frame-chrome": { layers: [{ asset: "stub-chrome", anchor: "tl", size: 0.28 }, { asset: "stub-chrome", anchor: "br", size: 0.28 }] },
|
|
116
|
+
haze: {},
|
|
117
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "swing",
|
|
3
|
+
"kind": "transition",
|
|
4
|
+
"tags": {
|
|
5
|
+
"mood": [
|
|
6
|
+
"cinematic",
|
|
7
|
+
"energetic"
|
|
8
|
+
],
|
|
9
|
+
"content": [
|
|
10
|
+
"motion"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"cost": 1,
|
|
14
|
+
"modes": "both",
|
|
15
|
+
"params": {
|
|
16
|
+
"intensity": {
|
|
17
|
+
"type": "number",
|
|
18
|
+
"default": 1,
|
|
19
|
+
"minimum": 0,
|
|
20
|
+
"maximum": 2
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"conflicts": [],
|
|
24
|
+
"source": "https://threejs.org/examples/",
|
|
25
|
+
"licence": "MIT"
|
|
26
|
+
}
|
package/src/fx/swing.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FxFactory, FxHandle } from "./types.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Camera transition `swing`: dolly with a sideways arc away from the mid-point between the slides.
|
|
5
|
+
* Motion lives in `runtime/transition.ts` (`makeMotion`); this card only
|
|
6
|
+
* registers the id. Scale with the IR knob `transitionAmount`.
|
|
7
|
+
*/
|
|
8
|
+
export const create: FxFactory = (): FxHandle => ({ pass: "transition:swing", dispose: () => {} });
|
package/src/fx/types.ts
CHANGED
|
@@ -6,10 +6,15 @@ import type * as THREE from "three";
|
|
|
6
6
|
import type { PaletteColors } from "../runtime/palette.js";
|
|
7
7
|
import type { QualityProfile } from "../runtime/quality.js";
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* `layer` effects draw slide CONTENT on the content layer (above the backdrop
|
|
11
|
+
* pass) — the imported-pptx built-ins. They are exempt from `fx-content-layer`.
|
|
12
|
+
*/
|
|
13
|
+
export type FxKind = "background" | "post" | "material" | "light" | "motion" | "edge" | "transition" | "layer";
|
|
10
14
|
export type FxMode = "dark" | "light" | "both";
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
/** Scalar params drive panel controls; structured ones (lists, id maps) are deck.json-only. */
|
|
17
|
+
export type FxParams = Record<string, number | string | boolean | unknown[] | Record<string, unknown>>;
|
|
13
18
|
|
|
14
19
|
/**
|
|
15
20
|
* Closed topic vocabulary (design D3). `parse` routes a content slide to the
|
|
@@ -44,6 +49,17 @@ export interface FxCard {
|
|
|
44
49
|
conflicts: string[];
|
|
45
50
|
source: string;
|
|
46
51
|
licence: string;
|
|
52
|
+
/**
|
|
53
|
+
* When any effect composed on a slide declares it, the runtime builds none
|
|
54
|
+
* of that slide's native title, subtitle, bullet card or diagram, and
|
|
55
|
+
* `measure()` reports none of them (`slide-layer`).
|
|
56
|
+
*/
|
|
57
|
+
replacesContent?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Deck-scope only: created once per deck load, kept outside every slide
|
|
60
|
+
* group, driven by `FxHandle.transition` every frame (`frame-chrome`).
|
|
61
|
+
*/
|
|
62
|
+
persistent?: boolean;
|
|
47
63
|
}
|
|
48
64
|
|
|
49
65
|
export interface FxContext {
|
|
@@ -55,6 +71,42 @@ export interface FxContext {
|
|
|
55
71
|
rng: () => number;
|
|
56
72
|
/** Read-only metadata of the slide the effect is being built for. */
|
|
57
73
|
slide: { id: string; title: string; kind: string };
|
|
74
|
+
/** Read-only deck asset accessor; `get(id)` throws for an unknown id. */
|
|
75
|
+
assets: { get(id: string): unknown; has(id: string): boolean };
|
|
76
|
+
/** Camera access for `layer` and persistent corpus effects (absent for local effects). */
|
|
77
|
+
view?: FxView;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface FxView {
|
|
81
|
+
camera: THREE.PerspectiveCamera;
|
|
82
|
+
/**
|
|
83
|
+
* The slide's SETTLED camera pose in the effect's parent space (the slide
|
|
84
|
+
* group): where the camera rests and what it looks at. Placement derives from
|
|
85
|
+
* this, never from hardcoded numbers.
|
|
86
|
+
*/
|
|
87
|
+
pose: { cam: [number, number, number]; target: [number, number, number]; fov: number };
|
|
88
|
+
/** Current viewport in CSS px. */
|
|
89
|
+
viewport(): { width: number; height: number };
|
|
90
|
+
/** Persistent (deck-scope) effects only: every slide id, in deck order. */
|
|
91
|
+
deckSlideIds?: string[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Screen-space text record an effect registers with `measure()` (kind `layer-text`). */
|
|
95
|
+
export interface FxMeasure {
|
|
96
|
+
id: string;
|
|
97
|
+
text: string;
|
|
98
|
+
rect: { x: number; y: number; w: number; h: number };
|
|
99
|
+
capHeight: number;
|
|
100
|
+
color?: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Transition state handed to persistent effects every frame. */
|
|
104
|
+
export interface FxTransition {
|
|
105
|
+
/** Slide indices (0-based); equal when settled. */
|
|
106
|
+
from: number;
|
|
107
|
+
to: number;
|
|
108
|
+
/** Progress 0–1; 1 when settled. */
|
|
109
|
+
p: number;
|
|
58
110
|
}
|
|
59
111
|
|
|
60
112
|
export interface FxHandle {
|
|
@@ -69,6 +121,15 @@ export interface FxHandle {
|
|
|
69
121
|
* being looked at; a pinned time in `check` never sees a moving clip.
|
|
70
122
|
*/
|
|
71
123
|
setActive?: (active: boolean) => void;
|
|
124
|
+
/** Persistent effects only: called every frame with the transition state. */
|
|
125
|
+
transition?: (state: FxTransition) => void;
|
|
126
|
+
/**
|
|
127
|
+
* Text the effect draws, projected to CSS px through `camera` at the given
|
|
128
|
+
* viewport, so `check`'s fit/legibility/overlap/contrast rules apply to it.
|
|
129
|
+
*/
|
|
130
|
+
measure?: (camera: unknown, width: number, height: number) => FxMeasure[];
|
|
131
|
+
/** Font names the effect drew with a fallback (`__deck3d.fonts()`). */
|
|
132
|
+
fontFallbacks?: () => string[];
|
|
72
133
|
dispose: () => void;
|
|
73
134
|
}
|
|
74
135
|
|
package/src/ir/merge.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* Persisted `slides[]` is never mutated: `applyOverrides` returns a fresh
|
|
10
10
|
* merged view for the renderer, so re-parse always regenerates derived fields.
|
|
11
11
|
*/
|
|
12
|
+
import { isPersistentFx } from "../fx/persistent.js";
|
|
12
13
|
import type {
|
|
13
14
|
DeckIR,
|
|
14
15
|
Defaults,
|
|
@@ -82,8 +83,10 @@ export function applyOverrides(ir: DeckIR): MergedDeck {
|
|
|
82
83
|
}
|
|
83
84
|
// Effective effects: deck-level list first, then this slide's own list
|
|
84
85
|
// (a slide `effects` override replaces the derived list). Arrays replace —
|
|
85
|
-
// the objects are never merged.
|
|
86
|
-
|
|
86
|
+
// the objects are never merged. Persistent cards live at deck scope only:
|
|
87
|
+
// they are created once by the runtime, never prepended to a slide.
|
|
88
|
+
const deckLevel = (ir.overrides.effects ?? []).filter((e) => !isPersistentFx(e.id));
|
|
89
|
+
base.effects = [...clone(deckLevel), ...clone(base.effects ?? [])];
|
|
87
90
|
return base;
|
|
88
91
|
});
|
|
89
92
|
return { defaults, slides, effects: clone(ir.overrides.effects ?? []), props: clone(ir.overrides.props ?? []) };
|
package/src/ir/schema.json
CHANGED
|
@@ -176,8 +176,35 @@
|
|
|
176
176
|
},
|
|
177
177
|
"transition": {
|
|
178
178
|
"type": "string",
|
|
179
|
+
"enum": [
|
|
180
|
+
"dolly",
|
|
181
|
+
"swing",
|
|
182
|
+
"revolve",
|
|
183
|
+
"crane",
|
|
184
|
+
"bank",
|
|
185
|
+
"flythrough",
|
|
186
|
+
"fade",
|
|
187
|
+
"iris",
|
|
188
|
+
"path",
|
|
189
|
+
"cut"
|
|
190
|
+
],
|
|
179
191
|
"default": "dolly",
|
|
180
|
-
"description": "
|
|
192
|
+
"description": "Camera move played on slide change (a `transition` card id, or `cut`). `path` needs the slide's `cameraPath`."
|
|
193
|
+
},
|
|
194
|
+
"transitionCycle": {
|
|
195
|
+
"type": "array",
|
|
196
|
+
"minItems": 1,
|
|
197
|
+
"items": {
|
|
198
|
+
"$ref": "#/definitions/defaults/properties/transition"
|
|
199
|
+
},
|
|
200
|
+
"description": "Deck-level: slides without their own `transition` take `transitionCycle[slideIndex % length]`."
|
|
201
|
+
},
|
|
202
|
+
"transitionAmount": {
|
|
203
|
+
"type": "number",
|
|
204
|
+
"minimum": 0,
|
|
205
|
+
"maximum": 2,
|
|
206
|
+
"default": 1,
|
|
207
|
+
"description": "Scales the built-in camera move (offsets, roll, fov swing); 1 = stock, 0 = straight dolly."
|
|
181
208
|
},
|
|
182
209
|
"durationSec": {
|
|
183
210
|
"type": "number",
|
|
@@ -865,6 +892,34 @@
|
|
|
865
892
|
}
|
|
866
893
|
}
|
|
867
894
|
},
|
|
895
|
+
"asset": {
|
|
896
|
+
"type": "object",
|
|
897
|
+
"description": "One pinned deck asset.",
|
|
898
|
+
"additionalProperties": false,
|
|
899
|
+
"required": ["id", "path", "sha256", "mime"],
|
|
900
|
+
"properties": {
|
|
901
|
+
"id": {
|
|
902
|
+
"type": "string",
|
|
903
|
+
"pattern": "^[a-z0-9][a-z0-9._-]{0,127}$",
|
|
904
|
+
"description": "Asset id effects read it by. Font assets use `font-<name>`; only fonts may use that prefix."
|
|
905
|
+
},
|
|
906
|
+
"path": {
|
|
907
|
+
"type": "string",
|
|
908
|
+
"minLength": 1,
|
|
909
|
+
"description": "File path relative to the deck directory; must resolve inside it."
|
|
910
|
+
},
|
|
911
|
+
"sha256": {
|
|
912
|
+
"type": "string",
|
|
913
|
+
"pattern": "^[0-9a-f]{64}$",
|
|
914
|
+
"description": "Lowercase hex sha256 of the file bytes; a stale pin fails validate/render."
|
|
915
|
+
},
|
|
916
|
+
"mime": {
|
|
917
|
+
"type": "string",
|
|
918
|
+
"enum": ["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml", "application/json", "text/plain", "font/ttf", "font/otf"],
|
|
919
|
+
"description": "Content type; decides how the runtime decodes it (bitmap, parsed JSON, text, registered font family)."
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
},
|
|
868
923
|
"overrides": {
|
|
869
924
|
"type": "object",
|
|
870
925
|
"description": "The ONLY user-writable region. Objects deep-merge over derived values; arrays replace.",
|
|
@@ -887,6 +942,13 @@
|
|
|
887
942
|
"$ref": "#/definitions/prop"
|
|
888
943
|
}
|
|
889
944
|
},
|
|
945
|
+
"assets": {
|
|
946
|
+
"type": "array",
|
|
947
|
+
"description": "Pinned deck assets (images, JSON, text, fonts) embedded once into deck.html and read by effects through `ctx.assets.get(id)`. `pptx import` writes the `pptx-` entries.",
|
|
948
|
+
"items": {
|
|
949
|
+
"$ref": "#/definitions/asset"
|
|
950
|
+
}
|
|
951
|
+
},
|
|
890
952
|
"slides": {
|
|
891
953
|
"type": "object",
|
|
892
954
|
"description": "Per-slide overrides keyed by slide id.",
|
|
@@ -919,6 +981,9 @@
|
|
|
919
981
|
}
|
|
920
982
|
}
|
|
921
983
|
},
|
|
984
|
+
"cameraPath": {
|
|
985
|
+
"$ref": "#/definitions/cameraPath"
|
|
986
|
+
},
|
|
922
987
|
"cardOffset": {
|
|
923
988
|
"$ref": "#/definitions/cardOffset"
|
|
924
989
|
},
|
|
@@ -1092,8 +1157,11 @@
|
|
|
1092
1157
|
"description": "Override the title contour for this slide."
|
|
1093
1158
|
},
|
|
1094
1159
|
"transition": {
|
|
1095
|
-
"
|
|
1096
|
-
"description": "Override the
|
|
1160
|
+
"$ref": "#/definitions/defaults/properties/transition",
|
|
1161
|
+
"description": "Override the camera move for entering this slide."
|
|
1162
|
+
},
|
|
1163
|
+
"transitionAmount": {
|
|
1164
|
+
"$ref": "#/definitions/defaults/properties/transitionAmount"
|
|
1097
1165
|
}
|
|
1098
1166
|
}
|
|
1099
1167
|
}
|
|
@@ -1206,6 +1274,75 @@
|
|
|
1206
1274
|
}
|
|
1207
1275
|
}
|
|
1208
1276
|
}
|
|
1277
|
+
},
|
|
1278
|
+
"cameraPath": {
|
|
1279
|
+
"type": "object",
|
|
1280
|
+
"additionalProperties": false,
|
|
1281
|
+
"required": [
|
|
1282
|
+
"keys"
|
|
1283
|
+
],
|
|
1284
|
+
"description": "Keyframed camera move into this slide (requires `transition: \"path\"`). Keys sit in the travel frame from the leaving camera to this slide's camera; the end points are implied and pinned.",
|
|
1285
|
+
"properties": {
|
|
1286
|
+
"ease": {
|
|
1287
|
+
"type": "string",
|
|
1288
|
+
"enum": [
|
|
1289
|
+
"inOut",
|
|
1290
|
+
"in",
|
|
1291
|
+
"out",
|
|
1292
|
+
"linear"
|
|
1293
|
+
],
|
|
1294
|
+
"default": "inOut",
|
|
1295
|
+
"description": "Time easing along the path."
|
|
1296
|
+
},
|
|
1297
|
+
"keys": {
|
|
1298
|
+
"type": "array",
|
|
1299
|
+
"minItems": 1,
|
|
1300
|
+
"maxItems": 8,
|
|
1301
|
+
"description": "Path keys, `t` strictly increasing.",
|
|
1302
|
+
"items": {
|
|
1303
|
+
"type": "object",
|
|
1304
|
+
"additionalProperties": false,
|
|
1305
|
+
"required": [
|
|
1306
|
+
"t"
|
|
1307
|
+
],
|
|
1308
|
+
"properties": {
|
|
1309
|
+
"t": {
|
|
1310
|
+
"type": "number",
|
|
1311
|
+
"exclusiveMinimum": 0,
|
|
1312
|
+
"exclusiveMaximum": 1,
|
|
1313
|
+
"description": "Normalised path time."
|
|
1314
|
+
},
|
|
1315
|
+
"offset": {
|
|
1316
|
+
"type": "array",
|
|
1317
|
+
"items": {
|
|
1318
|
+
"type": "number"
|
|
1319
|
+
},
|
|
1320
|
+
"minItems": 3,
|
|
1321
|
+
"maxItems": 3,
|
|
1322
|
+
"description": "[right, up, forward] offset as fractions of the travel length."
|
|
1323
|
+
},
|
|
1324
|
+
"look": {
|
|
1325
|
+
"type": "number",
|
|
1326
|
+
"minimum": 0,
|
|
1327
|
+
"maximum": 1,
|
|
1328
|
+
"description": "0 = look at the leaving slide, 1 = at this slide."
|
|
1329
|
+
},
|
|
1330
|
+
"roll": {
|
|
1331
|
+
"type": "number",
|
|
1332
|
+
"minimum": -45,
|
|
1333
|
+
"maximum": 45,
|
|
1334
|
+
"description": "Camera roll in degrees."
|
|
1335
|
+
},
|
|
1336
|
+
"fov": {
|
|
1337
|
+
"type": "number",
|
|
1338
|
+
"minimum": 20,
|
|
1339
|
+
"maximum": 90,
|
|
1340
|
+
"description": "Vertical field of view in degrees."
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1209
1346
|
}
|
|
1210
1347
|
}
|
|
1211
1348
|
}
|
package/src/ir/types.ts
CHANGED
|
@@ -118,6 +118,10 @@ export interface Defaults extends CameraKnobs, LabelKnobs, CheckKnobs {
|
|
|
118
118
|
fog?: boolean;
|
|
119
119
|
backgroundIntensity?: number;
|
|
120
120
|
transition?: string;
|
|
121
|
+
/** Deck-level: slides without their own `transition` cycle through this list. */
|
|
122
|
+
transitionCycle?: string[];
|
|
123
|
+
/** Scales the canned camera motion (offsets, roll); 1 = stock. */
|
|
124
|
+
transitionAmount?: number;
|
|
121
125
|
durationSec?: number;
|
|
122
126
|
depthRelief?: number;
|
|
123
127
|
quality?: Quality;
|
|
@@ -224,10 +228,31 @@ export interface Slide {
|
|
|
224
228
|
durationSec?: number;
|
|
225
229
|
}
|
|
226
230
|
|
|
231
|
+
/** One pinned deck asset (`overrides.assets[i]`). */
|
|
232
|
+
export interface DeckAsset {
|
|
233
|
+
id: string;
|
|
234
|
+
/** Relative to the deck directory; must resolve inside it. */
|
|
235
|
+
path: string;
|
|
236
|
+
sha256: string;
|
|
237
|
+
mime: AssetMime;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export type AssetMime =
|
|
241
|
+
| "image/png"
|
|
242
|
+
| "image/jpeg"
|
|
243
|
+
| "image/gif"
|
|
244
|
+
| "image/webp"
|
|
245
|
+
| "image/svg+xml"
|
|
246
|
+
| "application/json"
|
|
247
|
+
| "text/plain"
|
|
248
|
+
| "font/ttf"
|
|
249
|
+
| "font/otf";
|
|
250
|
+
|
|
227
251
|
export interface Overrides {
|
|
228
252
|
deck?: Defaults;
|
|
229
253
|
effects?: EffectRef[];
|
|
230
254
|
props?: PropOverride[];
|
|
255
|
+
assets?: DeckAsset[];
|
|
231
256
|
slides?: Record<string, SlideOverride>;
|
|
232
257
|
nodes?: Record<string, NodeOverride>;
|
|
233
258
|
edges?: Record<string, EdgeOverride>;
|
|
@@ -239,6 +264,9 @@ export interface SlideOverride {
|
|
|
239
264
|
material?: Material;
|
|
240
265
|
titleEdge?: TitleEdge;
|
|
241
266
|
transition?: string;
|
|
267
|
+
transitionAmount?: number;
|
|
268
|
+
/** Keyframed camera move INTO this slide; requires `transition: "path"`. */
|
|
269
|
+
cameraPath?: CameraPath;
|
|
242
270
|
quality?: Quality;
|
|
243
271
|
scene?: string;
|
|
244
272
|
backgroundIntensity?: number;
|
|
@@ -312,6 +340,32 @@ export interface MergedDiagram extends Omit<Diagram, "nodes"> {
|
|
|
312
340
|
/** A slide with overrides applied. Render-only. */
|
|
313
341
|
export interface MergedSlide extends Omit<Slide, "diagram"> {
|
|
314
342
|
diagram: MergedDiagram;
|
|
343
|
+
/** Folded in from `overrides.slides[id]` by `applyOverrides`. */
|
|
344
|
+
transition?: string;
|
|
345
|
+
transitionAmount?: number;
|
|
346
|
+
cameraPath?: CameraPath;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export type PathEase = "inOut" | "in" | "out" | "linear";
|
|
350
|
+
|
|
351
|
+
/** One camera key in the travel frame (from-camera → to-camera). */
|
|
352
|
+
export interface PathKey {
|
|
353
|
+
/** Normalised path time, strictly inside (0, 1). */
|
|
354
|
+
t: number;
|
|
355
|
+
/** `[right, up, forward]` offset as fractions of the travel length. */
|
|
356
|
+
offset?: [number, number, number];
|
|
357
|
+
/** 0 = look at the leaving slide, 1 = at the arriving slide. */
|
|
358
|
+
look?: number;
|
|
359
|
+
/** Camera roll, degrees. */
|
|
360
|
+
roll?: number;
|
|
361
|
+
/** Vertical field of view, degrees. */
|
|
362
|
+
fov?: number;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** Keyframed camera move into a slide; end points are implied and pinned. */
|
|
366
|
+
export interface CameraPath {
|
|
367
|
+
keys: PathKey[];
|
|
368
|
+
ease?: PathEase;
|
|
315
369
|
}
|
|
316
370
|
|
|
317
371
|
/** A fully merged view: derived values with overrides applied. Render-only. */
|