@blackbelt-technology/pi-dashboard-deck3d 0.9.0 → 0.11.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.
Files changed (105) hide show
  1. package/.pi/skills/deck3d/SKILL.agent.md +78 -0
  2. package/.pi/skills/deck3d/SKILL.md +68 -0
  3. package/.pi/skills/deck3d/reference/effects.md +185 -2
  4. package/.pi/skills/deck3d/reference/ir-fields.md +26 -3
  5. package/.pi/skills/deck3d-from-pptx/SKILL.md +134 -0
  6. package/.pi/skills/deck3d-from-pptx/reference/steps.md +72 -0
  7. package/README.md +30 -2
  8. package/assets/preview/stub-chrome.png +0 -0
  9. package/assets/preview/stub-icon.json +59 -0
  10. package/assets/preview/stub-layout.json +195 -0
  11. package/assets/preview/stub-outline.json +48 -0
  12. package/dist/cli.js +11780 -5934
  13. package/dist/runtime.js +5916 -4007
  14. package/fixtures/business-2031/assets/stub-chrome.png +0 -0
  15. package/fixtures/business-2031/assets/stub-icon.json +59 -0
  16. package/fixtures/business-2031/assets/stub-layout.json +195 -0
  17. package/fixtures/business-2031/assets/stub-outline.json +48 -0
  18. package/fixtures/business-2031/build-overrides.mjs +58 -13
  19. package/fixtures/business-2031/deck.agent.md +60 -0
  20. package/fixtures/business-2031/deck.json +133 -8
  21. package/fixtures/business-2031/overrides.json +133 -8
  22. package/package.json +8 -4
  23. package/scripts/gen-stub-assets.ts +31 -0
  24. package/src/art/cutout.ts +97 -0
  25. package/src/art/decode.ts +169 -0
  26. package/src/art/icon.ts +380 -0
  27. package/src/art/png.ts +232 -0
  28. package/src/art/trace.ts +288 -0
  29. package/src/check/rules.ts +13 -8
  30. package/src/cli.ts +313 -51
  31. package/src/compare/index.ts +131 -0
  32. package/src/compare/ssim.ts +91 -0
  33. package/src/fx/art-geometry.ts +137 -0
  34. package/src/fx/art3d.meta.json +30 -0
  35. package/src/fx/art3d.ts +131 -0
  36. package/src/fx/bank.meta.json +26 -0
  37. package/src/fx/bank.ts +8 -0
  38. package/src/fx/compose.ts +5 -4
  39. package/src/fx/crane.meta.json +26 -0
  40. package/src/fx/crane.ts +8 -0
  41. package/src/fx/dolly.ts +5 -1
  42. package/src/fx/fade.ts +5 -1
  43. package/src/fx/flythrough.ts +5 -1
  44. package/src/fx/frame-chrome.meta.json +17 -0
  45. package/src/fx/frame-chrome.ts +134 -0
  46. package/src/fx/haze.meta.json +19 -0
  47. package/src/fx/haze.ts +91 -0
  48. package/src/fx/icon3d.meta.json +21 -0
  49. package/src/fx/icon3d.ts +167 -0
  50. package/src/fx/index.ts +96 -66
  51. package/src/fx/iris.ts +5 -1
  52. package/src/fx/meta.schema.json +10 -2
  53. package/src/fx/path.meta.json +25 -0
  54. package/src/fx/path.ts +8 -0
  55. package/src/fx/persistent.ts +11 -0
  56. package/src/fx/revolve.meta.json +26 -0
  57. package/src/fx/revolve.ts +8 -0
  58. package/src/fx/slide-layer.meta.json +26 -0
  59. package/src/fx/slide-layer.ts +557 -0
  60. package/src/fx/slide-space.ts +142 -0
  61. package/src/fx/stub-assets.ts +117 -0
  62. package/src/fx/swing.meta.json +26 -0
  63. package/src/fx/swing.ts +8 -0
  64. package/src/fx/types.ts +63 -2
  65. package/src/ir/merge.ts +5 -2
  66. package/src/ir/schema.json +140 -3
  67. package/src/ir/types.ts +54 -0
  68. package/src/ir/validate.ts +91 -3
  69. package/src/parse/harvest/index.ts +4 -1
  70. package/src/parse/markdown.ts +38 -7
  71. package/src/pptx/baseline.ts +183 -0
  72. package/src/pptx/extract.ts +161 -0
  73. package/src/pptx/fallback.ts +70 -0
  74. package/src/pptx/import.ts +256 -0
  75. package/src/pptx/master.ts +135 -0
  76. package/src/pptx/media.ts +81 -0
  77. package/src/pptx/package.ts +109 -0
  78. package/src/pptx/ref.ts +100 -0
  79. package/src/pptx/shapes.ts +276 -0
  80. package/src/pptx/stage.ts +82 -0
  81. package/src/pptx/text.ts +202 -0
  82. package/src/pptx/theme.ts +194 -0
  83. package/src/pptx/types.ts +159 -0
  84. package/src/pptx/xfrm.ts +93 -0
  85. package/src/pptx/xml.ts +106 -0
  86. package/src/pptx/zip.ts +239 -0
  87. package/src/render/assets.ts +57 -0
  88. package/src/render/build.ts +75 -0
  89. package/src/render/index.ts +7 -2
  90. package/src/render/template.html +1 -1
  91. package/src/runtime/assets.ts +75 -0
  92. package/src/runtime/fade.ts +110 -0
  93. package/src/runtime/hud.ts +37 -9
  94. package/src/runtime/index.ts +431 -67
  95. package/src/runtime/post.ts +11 -5
  96. package/src/runtime/scene.ts +25 -2
  97. package/src/runtime/transition.ts +222 -0
  98. package/src/runtime/types.ts +13 -2
  99. package/src/serve/index.ts +199 -16
  100. package/src/util/cleanup.ts +13 -0
  101. package/src/util/confine.ts +15 -0
  102. package/src/variants/pick.ts +282 -0
  103. package/src/variants/render.ts +179 -0
  104. package/src/variants/schema.json +48 -0
  105. package/src/variants/style.ts +318 -0
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Geometry for `art3d` / `icon3d` (design D4): outline polygons → extrusion,
3
+ * polylines → capsule tubes. Both repair what breaks three.js shading:
4
+ * duplicate and collinear vertices are removed BEFORE extruding, and a final
5
+ * pass replaces any vertex normal that is not unit length (a zero-length
6
+ * normal makes `MeshStandardMaterial` render NaN black).
7
+ */
8
+ import type * as THREE_NS from "three";
9
+ import type { Outline, Pt } from "../art/trace.js";
10
+
11
+ type T3 = typeof THREE_NS;
12
+
13
+ /** Remove consecutive duplicates (incl. a repeated closing vertex) and collinear vertices. */
14
+ export function cleanRing(ring: Pt[], eps = 1e-6): Pt[] {
15
+ let pts = ring.filter((p, i) => i === 0 || Math.hypot(p[0] - ring[i - 1][0], p[1] - ring[i - 1][1]) > eps);
16
+ while (pts.length > 1 && Math.hypot(pts[0][0] - pts[pts.length - 1][0], pts[0][1] - pts[pts.length - 1][1]) <= eps) pts = pts.slice(0, -1);
17
+ let changed = true;
18
+ while (changed && pts.length > 3) {
19
+ changed = false;
20
+ for (let i = 0; i < pts.length; i++) {
21
+ const a = pts[(i - 1 + pts.length) % pts.length];
22
+ const b = pts[i];
23
+ const c = pts[(i + 1) % pts.length];
24
+ if (Math.abs((b[0] - a[0]) * (c[1] - b[1]) - (b[1] - a[1]) * (c[0] - b[0])) <= eps) {
25
+ pts = pts.filter((_, k) => k !== i);
26
+ changed = true;
27
+ break;
28
+ }
29
+ }
30
+ }
31
+ return pts;
32
+ }
33
+
34
+ export interface ExtrudeOptions {
35
+ depth: number;
36
+ bevel: number;
37
+ /** Source-pixel → world scale and centre (outline y points down). */
38
+ scale: number;
39
+ cx: number;
40
+ cy: number;
41
+ }
42
+
43
+ /** Replace every non-unit normal with the face normal (or +Z for a degenerate face). */
44
+ export function repairNormals(geom: THREE_NS.BufferGeometry): number {
45
+ const pos = geom.getAttribute("position");
46
+ let nor = geom.getAttribute("normal");
47
+ if (!nor) {
48
+ geom.computeVertexNormals();
49
+ nor = geom.getAttribute("normal");
50
+ }
51
+ let fixed = 0;
52
+ const n = nor.count;
53
+ for (let i = 0; i < n; i++) {
54
+ const x = nor.getX(i);
55
+ const y = nor.getY(i);
56
+ const z = nor.getZ(i);
57
+ const len = Math.hypot(x, y, z);
58
+ if (Number.isFinite(len) && Math.abs(len - 1) <= 1e-6) continue;
59
+ fixed++;
60
+ if (Number.isFinite(len) && len > 1e-12) {
61
+ nor.setXYZ(i, x / len, y / len, z / len);
62
+ continue;
63
+ }
64
+ // Face normal of the triangle this vertex belongs to.
65
+ const t = i - (i % 3);
66
+ if (t + 2 < pos.count) {
67
+ const ax = pos.getX(t + 1) - pos.getX(t);
68
+ const ay = pos.getY(t + 1) - pos.getY(t);
69
+ const az = pos.getZ(t + 1) - pos.getZ(t);
70
+ const bx = pos.getX(t + 2) - pos.getX(t);
71
+ const by = pos.getY(t + 2) - pos.getY(t);
72
+ const bz = pos.getZ(t + 2) - pos.getZ(t);
73
+ const fx = ay * bz - az * by;
74
+ const fy = az * bx - ax * bz;
75
+ const fz = ax * by - ay * bx;
76
+ const fl = Math.hypot(fx, fy, fz);
77
+ if (fl > 1e-12) {
78
+ nor.setXYZ(i, fx / fl, fy / fl, fz / fl);
79
+ continue;
80
+ }
81
+ }
82
+ nor.setXYZ(i, 0, 0, 1);
83
+ }
84
+ nor.needsUpdate = true;
85
+ return fixed;
86
+ }
87
+
88
+ /** One extruded polygon (holes open) as a geometry in world units, centred and y-up. */
89
+ export function extrudePolygon(THREE: T3, outer: Pt[], holes: Pt[][], o: ExtrudeOptions): THREE_NS.BufferGeometry | undefined {
90
+ const map = (p: Pt) => new THREE.Vector2((p[0] - o.cx) * o.scale, -(p[1] - o.cy) * o.scale);
91
+ const o2 = cleanRing(outer);
92
+ if (o2.length < 3) return undefined;
93
+ const shape = new THREE.Shape(o2.map(map));
94
+ for (const h of holes) {
95
+ const h2 = cleanRing(h);
96
+ if (h2.length >= 3) shape.holes.push(new THREE.Path(h2.map(map)));
97
+ }
98
+ const bevel = Math.min(o.bevel, o.depth / 2);
99
+ const geom = new THREE.ExtrudeGeometry(shape, {
100
+ depth: o.depth,
101
+ bevelEnabled: bevel > 0,
102
+ bevelThickness: bevel,
103
+ bevelSize: bevel * 0.8,
104
+ bevelSegments: 2,
105
+ curveSegments: 1,
106
+ steps: 1,
107
+ });
108
+ geom.translate(0, 0, -o.depth / 2);
109
+ repairNormals(geom);
110
+ return geom;
111
+ }
112
+
113
+ /** Bounding box of every outer ring, in source pixels. */
114
+ export function outlineBounds(outline: Outline): { minX: number; minY: number; maxX: number; maxY: number } {
115
+ let minX = Number.POSITIVE_INFINITY;
116
+ let minY = Number.POSITIVE_INFINITY;
117
+ let maxX = Number.NEGATIVE_INFINITY;
118
+ let maxY = Number.NEGATIVE_INFINITY;
119
+ for (const p of outline.polygons) {
120
+ for (const [x, y] of p.outer) {
121
+ minX = Math.min(minX, x);
122
+ minY = Math.min(minY, y);
123
+ maxX = Math.max(maxX, x);
124
+ maxY = Math.max(maxY, y);
125
+ }
126
+ }
127
+ return { minX, minY, maxX, maxY };
128
+ }
129
+
130
+ /** Matrix placing a unit-length capsule (cylinder along +Y) between two points. */
131
+ export function segmentMatrix(THREE: T3, a: THREE_NS.Vector3, b: THREE_NS.Vector3, radius: number): THREE_NS.Matrix4 {
132
+ const dir = b.clone().sub(a);
133
+ const len = dir.length();
134
+ const mid = a.clone().add(b).multiplyScalar(0.5);
135
+ const q = new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 1, 0), len > 1e-9 ? dir.normalize() : new THREE.Vector3(0, 1, 0));
136
+ return new THREE.Matrix4().compose(mid, q, new THREE.Vector3(radius, Math.max(len, 1e-6), radius));
137
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "id": "art3d",
3
+ "kind": "layer",
4
+ "tags": { "mood": ["bold", "branded"], "content": ["logo", "wordmark", "traced-art"] },
5
+ "cost": 1,
6
+ "modes": "both",
7
+ "params": {
8
+ "outline": { "type": "string" },
9
+ "item": { "type": "string" },
10
+ "layout": { "type": "string", "default": "pptx-layout" },
11
+ "slide": { "type": "string" },
12
+ "depth": { "type": "number", "default": 0.25, "minimum": 0.01, "maximum": 2 },
13
+ "bevel": { "type": "number", "default": 0.03, "minimum": 0, "maximum": 0.5 },
14
+ "scale": { "type": "number", "default": 4, "minimum": 0.1, "maximum": 20 },
15
+ "x": { "type": "number", "default": 0, "minimum": -12, "maximum": 12 },
16
+ "y": { "type": "number", "default": 0, "minimum": -8, "maximum": 8 },
17
+ "z": { "type": "number", "default": 0.4, "minimum": -4, "maximum": 6 },
18
+ "depthOffset": { "type": "number", "default": 0.4, "minimum": -2, "maximum": 3 },
19
+ "sway": { "type": "number", "default": 0, "minimum": 0, "maximum": 1 },
20
+ "speed": { "type": "number", "default": 0.6, "minimum": 0, "maximum": 4 },
21
+ "sweep": { "type": "boolean", "default": false },
22
+ "metalness": { "type": "number", "default": 0.25, "minimum": 0, "maximum": 1 },
23
+ "roughness": { "type": "number", "default": 0.4, "minimum": 0, "maximum": 1 },
24
+ "gradient": { "type": "array", "default": [] },
25
+ "colors": { "type": "object", "default": {} }
26
+ },
27
+ "conflicts": [],
28
+ "source": "https://github.com/BlackBeltTechnology/pi-agent-dashboard/tree/develop/packages/deck3d/src/fx/art3d.ts",
29
+ "licence": "MIT"
30
+ }
@@ -0,0 +1,131 @@
1
+ /**
2
+ * `art3d` — extrudes an outline asset (polygons with holes, as written by
3
+ * `art trace`) into the slide. Holes render open; vertex normals are always
4
+ * unit length (art-geometry.ts). Optional vertical gradient, sway and a sweep
5
+ * highlight. Placement is either free (`x y z scale`, scene units) or taken
6
+ * from a layout item so the extrusion sits exactly on the flat art's rect.
7
+ */
8
+ import type * as THREE_NS from "three";
9
+ import type { Outline } from "../art/trace.js";
10
+ import type { Layout, LayoutItem } from "../pptx/types.js";
11
+ import { extrudePolygon, outlineBounds } from "./art-geometry.js";
12
+ import { planeMap, poseBasis } from "./slide-space.js";
13
+ import type { FxContext, FxFactory, FxHandle, FxParams } from "./types.js";
14
+
15
+ const num = (v: unknown, d: number): number => (typeof v === "number" && Number.isFinite(v) ? v : d);
16
+
17
+ export const create: FxFactory = (ctx: FxContext, params: FxParams): FxHandle => {
18
+ const THREE = ctx.THREE;
19
+ const outline = ctx.assets.get(String(params.outline)) as Outline;
20
+ if (!outline?.polygons) throw new Error(`art3d: asset '${String(params.outline)}' is not an outline`);
21
+ const depth = num(params.depth, 0.25);
22
+ const bevel = num(params.bevel, 0.03);
23
+ const sway = num(params.sway, 0);
24
+ const speed = num(params.speed, 0.6);
25
+ const sweep = params.sweep === true;
26
+ const gradient = Array.isArray(params.gradient) ? (params.gradient as string[]) : undefined;
27
+ const colors = (params.colors as Record<string, string> | undefined) ?? {};
28
+ const b = outlineBounds(outline);
29
+ const w = Math.max(1, b.maxX - b.minX);
30
+ const h = Math.max(1, b.maxY - b.minY);
31
+ const cx = (b.minX + b.maxX) / 2;
32
+ const cy = (b.minY + b.maxY) / 2;
33
+
34
+ // Placement: a layout item's rect (projected like slide-layer) or free x/y/z/scale.
35
+ let scale = num(params.scale, 4) / Math.max(w, h);
36
+ let position = new THREE.Vector3(num(params.x, 0), num(params.y, 0), num(params.z, 0.4));
37
+ const item = typeof params.item === "string" ? findItem(ctx, params) : undefined;
38
+ if (item && ctx.view) {
39
+ const layout = ctx.assets.get(String(params.layout ?? "pptx-layout")) as Layout;
40
+ const basis = poseBasis(THREE, ctx.view);
41
+ const { width, height } = ctx.view.viewport();
42
+ const map = planeMap(THREE, basis, ctx.view.pose.fov, width, height, layout.size, num(params.depthOffset, 0.4));
43
+ scale = (Math.min(item.rect.w / w, item.rect.h / h) * map.unit) || scale;
44
+ position = map.point(item.rect.x + item.rect.w / 2, item.rect.y + item.rect.h / 2);
45
+ }
46
+
47
+ const root = new THREE.Group();
48
+ root.position.copy(position);
49
+ const mats: THREE_NS.Material[] = [];
50
+ const geoms: THREE_NS.BufferGeometry[] = [];
51
+ const sweepUniform = { value: 0 };
52
+ const topY = (h / 2) * scale;
53
+ for (const poly of outline.polygons) {
54
+ const geom = extrudePolygon(THREE, poly.outer, poly.holes, { depth, bevel, scale, cx, cy });
55
+ if (!geom) continue;
56
+ const base = new THREE.Color(colors[poly.color] ?? poly.color);
57
+ if (gradient && gradient.length >= 2) {
58
+ const top = new THREE.Color(gradient[0]);
59
+ const bottom = new THREE.Color(gradient[1]);
60
+ const pos = geom.getAttribute("position");
61
+ const col = new Float32Array(pos.count * 3);
62
+ for (let i = 0; i < pos.count; i++) {
63
+ const k = Math.min(1, Math.max(0, (topY - pos.getY(i)) / (2 * topY || 1)));
64
+ const c = top.clone().lerp(bottom, k);
65
+ col.set([c.r, c.g, c.b], i * 3);
66
+ }
67
+ geom.setAttribute("color", new THREE.BufferAttribute(col, 3));
68
+ }
69
+ const mat = new THREE.MeshStandardMaterial({
70
+ color: gradient ? 0xffffff : base,
71
+ vertexColors: !!gradient,
72
+ metalness: num(params.metalness, 0.25),
73
+ roughness: num(params.roughness, 0.4),
74
+ envMapIntensity: 0.8,
75
+ });
76
+ if (sweep) {
77
+ mat.onBeforeCompile = (shader) => {
78
+ shader.uniforms.uSweep = sweepUniform;
79
+ shader.fragmentShader = shader.fragmentShader
80
+ .replace("#include <common>", "#include <common>\nuniform float uSweep;\nvarying vec3 vSweepPos;")
81
+ .replace("#include <emissivemap_fragment>", "#include <emissivemap_fragment>\ntotalEmissiveRadiance += vec3(1.0) * smoothstep(0.12, 0.0, abs(vSweepPos.x - uSweep)) * 0.6;");
82
+ shader.vertexShader = shader.vertexShader
83
+ .replace("#include <common>", "#include <common>\nvarying vec3 vSweepPos;")
84
+ .replace("#include <begin_vertex>", "#include <begin_vertex>\nvSweepPos = position;");
85
+ };
86
+ }
87
+ const mesh = new THREE.Mesh(geom, mat);
88
+ mesh.castShadow = false;
89
+ root.add(mesh);
90
+ mats.push(mat);
91
+ geoms.push(geom);
92
+ }
93
+
94
+ // Probe for tests: screen-space centre of every hole (CSS px), at the current camera.
95
+ const holeCentres = outline.polygons.flatMap((poly) =>
96
+ poly.holes.map((h) => {
97
+ const xs = h.map((p) => p[0]);
98
+ const ys = h.map((p) => p[1]);
99
+ return new THREE.Vector3(((Math.min(...xs) + Math.max(...xs)) / 2 - cx) * scale, -((Math.min(...ys) + Math.max(...ys)) / 2 - cy) * scale, 0);
100
+ }),
101
+ );
102
+ return {
103
+ object: root,
104
+ debug: () => {
105
+ const view = ctx.view;
106
+ if (!view) return null;
107
+ const { width, height } = view.viewport();
108
+ root.updateWorldMatrix(true, true);
109
+ return {
110
+ holes: holeCentres.map((c) => {
111
+ const v = root.localToWorld(c.clone()).project(view.camera);
112
+ return { x: ((v.x + 1) / 2) * width, y: ((1 - v.y) / 2) * height };
113
+ }),
114
+ };
115
+ },
116
+ tick: (t: number) => {
117
+ if (sway) root.rotation.y = Math.sin(t * speed) * sway;
118
+ if (sweep) sweepUniform.value = ((t * speed * 0.5) % 2) * (w * scale) - w * scale;
119
+ },
120
+ dispose: () => {
121
+ for (const g of geoms) g.dispose();
122
+ for (const m of mats) m.dispose();
123
+ },
124
+ } as FxHandle;
125
+ };
126
+
127
+ function findItem(ctx: FxContext, params: FxParams): LayoutItem | undefined {
128
+ const layout = ctx.assets.get(String(params.layout ?? "pptx-layout")) as Layout;
129
+ const slide = layout.slides.find((s) => s.id === (typeof params.slide === "string" ? params.slide : ctx.slide.id));
130
+ return slide?.items.find((i) => i.id === params.item);
131
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "id": "bank",
3
+ "kind": "transition",
4
+ "tags": {
5
+ "mood": [
6
+ "cinematic",
7
+ "energetic"
8
+ ],
9
+ "content": [
10
+ "motion"
11
+ ]
12
+ },
13
+ "cost": 2,
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/bank.ts ADDED
@@ -0,0 +1,8 @@
1
+ import type { FxFactory, FxHandle } from "./types.js";
2
+
3
+ /**
4
+ * Camera transition `bank`: dolly that rolls the camera into the move and back out (about 8 degrees).
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:bank", dispose: () => {} });
package/src/fx/compose.ts CHANGED
@@ -87,14 +87,14 @@ export interface ParamViolation {
87
87
  message: string;
88
88
  }
89
89
 
90
- function paramViolations(slideId: string, index: number, ref: EffectRef, local: LocalCards): ParamViolation[] {
90
+ function paramViolations(scope: string, index: number, ref: EffectRef, local: LocalCards): ParamViolation[] {
91
91
  const c = card(ref.id, local);
92
92
  if (!c) return [];
93
93
  const out: ParamViolation[] = [];
94
94
  for (const [name, value] of Object.entries(ref.params ?? {})) {
95
95
  const schema = c.params[name] as { minimum?: number; maximum?: number } | undefined;
96
96
  if (!schema || typeof value !== "number") continue;
97
- const base = `overrides.slides["${slideId}"].effects[${index}].params.${name}`;
97
+ const base = `${scope}[${index}].params.${name}`;
98
98
  if (schema.minimum !== undefined && value < schema.minimum) out.push({ path: base, message: `${value} < minimum ${schema.minimum}` });
99
99
  if (schema.maximum !== undefined && value > schema.maximum) out.push({ path: base, message: `${value} > maximum ${schema.maximum}` });
100
100
  }
@@ -103,12 +103,13 @@ function paramViolations(slideId: string, index: number, ref: EffectRef, local:
103
103
 
104
104
  /** Validate `overrides.slides[id].effects[i].params` against the card schemas. */
105
105
  export function validateEffectParams(
106
- ir: { overrides?: { slides?: Record<string, { effects?: EffectRef[] }> } },
106
+ ir: { overrides?: { effects?: EffectRef[]; slides?: Record<string, { effects?: EffectRef[] }> } },
107
107
  local: LocalCards = {},
108
108
  ): ParamViolation[] {
109
109
  const out: ParamViolation[] = [];
110
+ (ir.overrides?.effects ?? []).forEach((ref, i) => out.push(...paramViolations("overrides.effects", i, ref, local)));
110
111
  for (const [slideId, slide] of Object.entries(ir.overrides?.slides ?? {})) {
111
- (slide.effects ?? []).forEach((ref, i) => out.push(...paramViolations(slideId, i, ref, local)));
112
+ (slide.effects ?? []).forEach((ref, i) => out.push(...paramViolations(`overrides.slides["${slideId}"].effects`, i, ref, local)));
112
113
  }
113
114
  return out;
114
115
  }
@@ -0,0 +1,26 @@
1
+ {
2
+ "id": "crane",
3
+ "kind": "transition",
4
+ "tags": {
5
+ "mood": [
6
+ "cinematic",
7
+ "calm"
8
+ ],
9
+ "content": [
10
+ "motion"
11
+ ]
12
+ },
13
+ "cost": 2,
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
+ }
@@ -0,0 +1,8 @@
1
+ import type { FxFactory, FxHandle } from "./types.js";
2
+
3
+ /**
4
+ * Camera transition `crane`: rises above the gap like a crane shot, then descends onto the slide.
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:crane", dispose: () => {} });
package/src/fx/dolly.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import type { FxFactory, FxHandle } from "./types.js";
2
2
 
3
- /** Transition id; the runtime camera picks the matching interpolation. */
3
+ /**
4
+ * Camera transition `dolly`: straight eased move to the arriving slide's anchor.
5
+ * Motion lives in `runtime/transition.ts` (`makeMotion`); this card only
6
+ * registers the id. Scale with the IR knob `transitionAmount`.
7
+ */
4
8
  export const create: FxFactory = (): FxHandle => ({ pass: "transition:dolly", dispose: () => {} });
package/src/fx/fade.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import type { FxFactory, FxHandle } from "./types.js";
2
2
 
3
- /** Transition id; the runtime camera picks the matching interpolation. */
3
+ /**
4
+ * Camera transition `fade`: covers the screen with the palette background, switches the camera while covered, uncovers.
5
+ * Motion lives in `runtime/transition.ts` (`makeMotion`); this card only
6
+ * registers the id. Scale with the IR knob `transitionAmount`.
7
+ */
4
8
  export const create: FxFactory = (): FxHandle => ({ pass: "transition:fade", dispose: () => {} });
@@ -1,4 +1,8 @@
1
1
  import type { FxFactory, FxHandle } from "./types.js";
2
2
 
3
- /** Transition id; the runtime camera picks the matching interpolation. */
3
+ /**
4
+ * Camera transition `flythrough`: low pass through the gap between the slides with a gentle bank and a wider lens.
5
+ * Motion lives in `runtime/transition.ts` (`makeMotion`); this card only
6
+ * registers the id. Scale with the IR knob `transitionAmount`.
7
+ */
4
8
  export const create: FxFactory = (): FxHandle => ({ pass: "transition:flythrough", dispose: () => {} });
@@ -0,0 +1,17 @@
1
+ {
2
+ "id": "frame-chrome",
3
+ "kind": "layer",
4
+ "tags": { "mood": ["branded", "framed"], "content": ["master", "corner-art", "persistent"] },
5
+ "cost": 1,
6
+ "modes": "both",
7
+ "persistent": true,
8
+ "params": {
9
+ "opacity": { "type": "number", "default": 1, "minimum": 0, "maximum": 1 },
10
+ "scale": { "type": "number", "default": 1, "minimum": 0.2, "maximum": 3 },
11
+ "layers": { "type": "array", "default": [] },
12
+ "suppress": { "type": "array", "default": [] }
13
+ },
14
+ "conflicts": [],
15
+ "source": "https://github.com/BlackBeltTechnology/pi-agent-dashboard/tree/develop/packages/deck3d/src/fx/frame-chrome.ts",
16
+ "licence": "MIT"
17
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * `frame-chrome` — persistent, camera-pinned image layers (master corner art)
3
+ * that fly out of the frame while the camera moves and back in before it ends
4
+ * (design D4, spec deck3d-slide-layers "Persistent effects and frame-chrome").
5
+ *
6
+ * Created once per deck (outside every slide group), driven every frame by
7
+ * `transition({ from, to, p })`. Each layer carries a settled "hidden" state
8
+ * (1 on a `suppress`ed slide, else 0) at both ends of a move; between them its
9
+ * offset follows lerp(hiddenFrom, hiddenTo, ease(p)) plus a tent dip that
10
+ * leaves and re-enters the frame — so the chrome is never absent at BOTH the
11
+ * start and the end of a move, and each layer rises monotonically then falls.
12
+ */
13
+ import type * as THREE_NS from "three";
14
+ import type { FxContext, FxFactory, FxHandle, FxParams, FxTransition } from "./types.js";
15
+
16
+ interface LayerSpec {
17
+ asset: string;
18
+ anchor?: "tl" | "tr" | "bl" | "br";
19
+ /** Layer height as a fraction of viewport height. */
20
+ size?: number;
21
+ /** Fly-out vector, in viewport heights. */
22
+ fly?: [number, number];
23
+ /** 0–0.5: share of the move before this layer starts leaving. */
24
+ delay?: number;
25
+ /** Speed multiplier of the layer's own timeline (>= 1 finishes earlier). */
26
+ speed?: number;
27
+ ease?: "inOut" | "in" | "out" | "linear";
28
+ }
29
+
30
+ const DIST = 1.5;
31
+ const EASES = {
32
+ inOut: (x: number) => (x < 0.5 ? 2 * x * x : 1 - (-2 * x + 2) ** 2 / 2),
33
+ in: (x: number) => x * x,
34
+ out: (x: number) => 1 - (1 - x) ** 2,
35
+ linear: (x: number) => x,
36
+ };
37
+ const clamp01 = (v: number) => Math.min(1, Math.max(0, v));
38
+
39
+ export const create: FxFactory = (ctx: FxContext, params: FxParams): FxHandle => {
40
+ const THREE = ctx.THREE;
41
+ if (!ctx.view) throw new Error("frame-chrome needs the runtime view (persistent corpus effect)");
42
+ const view = ctx.view;
43
+ const specs = (Array.isArray(params.layers) ? params.layers : []) as LayerSpec[];
44
+ const suppress = new Set(Array.isArray(params.suppress) ? (params.suppress as string[]) : []);
45
+ const ids = view.deckSlideIds ?? [];
46
+ const opacity = Math.min(1, Math.max(0, typeof params.opacity === "number" ? params.opacity : 1));
47
+ const sizeScale = Math.min(3, Math.max(0.2, typeof params.scale === "number" ? params.scale : 1));
48
+ const hiddenAt = (index: number) => (suppress.has(ids[index] ?? "") ? 1 : 0);
49
+
50
+ const root = new THREE.Group();
51
+ root.matrixAutoUpdate = false;
52
+ root.userData.part = "chrome";
53
+ const planes: Array<{ spec: LayerSpec; mesh: THREE_NS.Mesh; aspect: number; offset: number }> = [];
54
+ for (const spec of specs) {
55
+ const img = ctx.assets.get(spec.asset) as HTMLImageElement;
56
+ const tex = new THREE.Texture(img);
57
+ tex.colorSpace = THREE.SRGBColorSpace;
58
+ tex.needsUpdate = true;
59
+ const mat = new THREE.MeshBasicMaterial({ map: tex, transparent: true, opacity, depthTest: false, depthWrite: false, toneMapped: false, fog: false });
60
+ const mesh = new THREE.Mesh(new THREE.PlaneGeometry(1, 1), mat);
61
+ mesh.renderOrder = 1000;
62
+ root.add(mesh);
63
+ planes.push({ spec, mesh, aspect: (img.naturalWidth || 1) / (img.naturalHeight || 1), offset: 0 });
64
+ }
65
+
66
+ let state: FxTransition = { from: 0, to: 0, p: 1 };
67
+
68
+ /**
69
+ * Hidden fraction (0 = at rest in frame, 1 = fully out) for the current
70
+ * state. Both ends visible: an out-and-back bump sin(π·q). Otherwise the
71
+ * layer simply travels between the two settled states (0 ↔ 1).
72
+ */
73
+ function offsetOf(spec: LayerSpec): number {
74
+ const a = hiddenAt(state.from);
75
+ const b = hiddenAt(state.to);
76
+ if (state.from === state.to || state.p >= 1) return b;
77
+ if (state.p <= 0) return a;
78
+ const delay = clamp01(spec.delay ?? 0);
79
+ const speed = Math.max(0.2, spec.speed ?? 1);
80
+ const q = clamp01(((state.p - delay) / Math.max(1e-6, 1 - delay)) * speed);
81
+ const eased = EASES[spec.ease ?? "inOut"](q);
82
+ if (a === 0 && b === 0) return Math.sin(Math.PI * eased);
83
+ return a + (b - a) * eased;
84
+ }
85
+
86
+ function place(): void {
87
+ const { width, height } = view.viewport();
88
+ const cam = view.camera as THREE_NS.PerspectiveCamera;
89
+ const visH = 2 * DIST * Math.tan((cam.fov * Math.PI) / 360);
90
+ const visW = visH * (width / height);
91
+ for (const p of planes) {
92
+ const h = (p.spec.size ?? 0.3) * sizeScale * visH;
93
+ const w = h * p.aspect;
94
+ const anchor = p.spec.anchor ?? "tl";
95
+ const left = anchor === "tl" || anchor === "bl";
96
+ const top = anchor === "tl" || anchor === "tr";
97
+ const fly = p.spec.fly ?? [left ? -0.5 : 0.5, top ? 0.5 : -0.5];
98
+ const x = (left ? -visW / 2 + w / 2 : visW / 2 - w / 2) + fly[0] * visH * p.offset;
99
+ const y = (top ? visH / 2 - h / 2 : -visH / 2 + h / 2) + fly[1] * visH * p.offset;
100
+ p.mesh.position.set(x, y, -DIST);
101
+ p.mesh.scale.set(w, h, 1);
102
+ }
103
+ }
104
+
105
+ function pin(): void {
106
+ view.camera.updateMatrixWorld();
107
+ root.matrix.copy(view.camera.matrixWorld);
108
+ root.matrixWorldNeedsUpdate = true;
109
+ }
110
+
111
+ const apply = (): void => {
112
+ for (const p of planes) p.offset = offsetOf(p.spec);
113
+ place();
114
+ pin();
115
+ };
116
+ apply();
117
+
118
+ return {
119
+ object: root,
120
+ transition: (s) => {
121
+ state = s;
122
+ apply();
123
+ },
124
+ tick: () => apply(),
125
+ debug: () => ({ offsets: planes.map((p) => p.offset), from: state.from, to: state.to, p: state.p }),
126
+ dispose: () => {
127
+ for (const p of planes) {
128
+ (p.mesh.material as THREE_NS.MeshBasicMaterial).map?.dispose();
129
+ (p.mesh.material as THREE_NS.Material).dispose();
130
+ p.mesh.geometry.dispose();
131
+ }
132
+ },
133
+ } as FxHandle;
134
+ };
@@ -0,0 +1,19 @@
1
+ {
2
+ "id": "haze",
3
+ "kind": "background",
4
+ "tags": { "mood": ["soft", "atmospheric"], "content": ["depth", "backdrop-fade"] },
5
+ "cost": 1,
6
+ "modes": "both",
7
+ "params": {
8
+ "layers": { "type": "number", "default": 4, "minimum": 1, "maximum": 8 },
9
+ "near": { "type": "number", "default": 6, "minimum": 1, "maximum": 30 },
10
+ "far": { "type": "number", "default": 26, "minimum": 2, "maximum": 60 },
11
+ "density": { "type": "number", "default": 0.5, "minimum": 0, "maximum": 1 },
12
+ "drift": { "type": "number", "default": 0.15, "minimum": 0, "maximum": 2 },
13
+ "floor": { "type": "number", "default": -2.6, "minimum": -10, "maximum": 4 },
14
+ "color": { "type": "string" }
15
+ },
16
+ "conflicts": [],
17
+ "source": "https://github.com/BlackBeltTechnology/pi-agent-dashboard/tree/develop/packages/deck3d/src/fx/haze.ts",
18
+ "licence": "MIT"
19
+ }