@blackbelt-technology/pi-dashboard-deck3d 0.0.0-stage → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/.pi/skills/deck3d/SKILL.md +227 -0
  2. package/.pi/skills/deck3d/examples/deck.json +388 -0
  3. package/.pi/skills/deck3d/examples/fixture.md +18 -0
  4. package/.pi/skills/deck3d/examples/snapshot-after.png +0 -0
  5. package/.pi/skills/deck3d/examples/snapshot-before.png +0 -0
  6. package/.pi/skills/deck3d/reference/effects.agent.md +78 -0
  7. package/.pi/skills/deck3d/reference/effects.md +1217 -0
  8. package/.pi/skills/deck3d/reference/ir-fields.agent.md +30 -0
  9. package/.pi/skills/deck3d/reference/ir-fields.md +246 -0
  10. package/README.md +177 -2
  11. package/assets/LICENSE-Poppins.txt +99 -0
  12. package/assets/Poppins-Bold.ttf +0 -0
  13. package/assets/props/LICENSES.txt +4 -0
  14. package/assets/props/brain.glb +0 -0
  15. package/assets/props/cloud.glb +0 -0
  16. package/assets/props/cube.glb +0 -0
  17. package/assets/props/database.glb +0 -0
  18. package/assets/props/laptop.glb +0 -0
  19. package/assets/props/manifest.json +119 -0
  20. package/assets/props/robot.glb +0 -0
  21. package/assets/props/server.glb +0 -0
  22. package/assets/props/shield.glb +0 -0
  23. package/bin/deck3d +49 -0
  24. package/dist/cli.js +10228 -0
  25. package/dist/harvest/harness.js +185718 -0
  26. package/dist/runtime.js +64597 -0
  27. package/fixtures/business-2031/build-deck.mjs +60 -0
  28. package/fixtures/business-2031/build-overrides.mjs +154 -0
  29. package/fixtures/business-2031/deck.json +4220 -0
  30. package/fixtures/business-2031/deck.md +470 -0
  31. package/fixtures/business-2031/fx/closing-mark.js +43 -0
  32. package/fixtures/business-2031/fx/closing-mark.meta.json +26 -0
  33. package/fixtures/business-2031/overrides.json +903 -0
  34. package/fixtures/harvest.md +23 -0
  35. package/fixtures/strategy-lab.json +891 -0
  36. package/fixtures/strategy-lab.md +85 -0
  37. package/package.json +80 -4
  38. package/scripts/build-cli.mjs +29 -0
  39. package/scripts/build-harvest.ts +8 -0
  40. package/scripts/build-runtime.mjs +22 -0
  41. package/scripts/gen-effects.ts +14 -0
  42. package/scripts/gen-ir-fields.ts +34 -0
  43. package/src/check/index.ts +315 -0
  44. package/src/check/rules.ts +393 -0
  45. package/src/cli-io.ts +23 -0
  46. package/src/cli.ts +823 -0
  47. package/src/fx/accent-cycle.meta.json +26 -0
  48. package/src/fx/accent-cycle.ts +8 -0
  49. package/src/fx/agent-depth.meta.json +42 -0
  50. package/src/fx/agent-depth.ts +62 -0
  51. package/src/fx/ascii.meta.json +35 -0
  52. package/src/fx/ascii.ts +4 -0
  53. package/src/fx/aurora.meta.json +26 -0
  54. package/src/fx/aurora.ts +18 -0
  55. package/src/fx/billboards.meta.json +34 -0
  56. package/src/fx/billboards.ts +67 -0
  57. package/src/fx/bloom.meta.json +26 -0
  58. package/src/fx/bloom.ts +4 -0
  59. package/src/fx/camera-drift.meta.json +26 -0
  60. package/src/fx/camera-drift.ts +8 -0
  61. package/src/fx/capital-flows.meta.json +30 -0
  62. package/src/fx/capital-flows.ts +64 -0
  63. package/src/fx/catalogue.ts +89 -0
  64. package/src/fx/chromatic-aberration.meta.json +32 -0
  65. package/src/fx/chromatic-aberration.ts +4 -0
  66. package/src/fx/city-grid.meta.json +37 -0
  67. package/src/fx/city-grid.ts +51 -0
  68. package/src/fx/clipped-solids.meta.json +49 -0
  69. package/src/fx/clipped-solids.ts +171 -0
  70. package/src/fx/cohort-grid.meta.json +48 -0
  71. package/src/fx/cohort-grid.ts +63 -0
  72. package/src/fx/compose.ts +114 -0
  73. package/src/fx/constellation.meta.json +51 -0
  74. package/src/fx/constellation.ts +103 -0
  75. package/src/fx/curve-flow.meta.json +40 -0
  76. package/src/fx/curve-flow.ts +63 -0
  77. package/src/fx/dashed-flow.meta.json +27 -0
  78. package/src/fx/dashed-flow.ts +8 -0
  79. package/src/fx/data-columns.meta.json +30 -0
  80. package/src/fx/data-columns.ts +18 -0
  81. package/src/fx/defaults.ts +92 -0
  82. package/src/fx/depth-of-field.meta.json +40 -0
  83. package/src/fx/depth-of-field.ts +4 -0
  84. package/src/fx/dolly.meta.json +26 -0
  85. package/src/fx/dolly.ts +4 -0
  86. package/src/fx/dot-screen.meta.json +35 -0
  87. package/src/fx/dot-screen.ts +4 -0
  88. package/src/fx/dynamic-instances.meta.json +40 -0
  89. package/src/fx/dynamic-instances.ts +57 -0
  90. package/src/fx/emissive.meta.json +26 -0
  91. package/src/fx/emissive.ts +8 -0
  92. package/src/fx/extruded-shapes.meta.json +62 -0
  93. package/src/fx/extruded-shapes.ts +133 -0
  94. package/src/fx/fab-wafer.meta.json +42 -0
  95. package/src/fx/fab-wafer.ts +72 -0
  96. package/src/fx/fade.meta.json +26 -0
  97. package/src/fx/fade.ts +4 -0
  98. package/src/fx/film.meta.json +26 -0
  99. package/src/fx/film.ts +4 -0
  100. package/src/fx/float.meta.json +26 -0
  101. package/src/fx/float.ts +8 -0
  102. package/src/fx/flythrough.meta.json +26 -0
  103. package/src/fx/flythrough.ts +4 -0
  104. package/src/fx/fog.meta.json +26 -0
  105. package/src/fx/fog.ts +8 -0
  106. package/src/fx/geo-fragments.meta.json +48 -0
  107. package/src/fx/geo-fragments.ts +59 -0
  108. package/src/fx/glass.meta.json +26 -0
  109. package/src/fx/glass.ts +8 -0
  110. package/src/fx/globe-arcs.meta.json +36 -0
  111. package/src/fx/globe-arcs.ts +67 -0
  112. package/src/fx/glow-tube.meta.json +26 -0
  113. package/src/fx/glow-tube.ts +8 -0
  114. package/src/fx/glyph-rain.meta.json +30 -0
  115. package/src/fx/glyph-rain.ts +18 -0
  116. package/src/fx/god-rays.meta.json +40 -0
  117. package/src/fx/god-rays.ts +4 -0
  118. package/src/fx/grid-horizon.meta.json +30 -0
  119. package/src/fx/grid-horizon.ts +18 -0
  120. package/src/fx/hex-grid.meta.json +29 -0
  121. package/src/fx/hex-grid.ts +18 -0
  122. package/src/fx/holo-fresnel.meta.json +26 -0
  123. package/src/fx/holo-fresnel.ts +8 -0
  124. package/src/fx/horizon-gates.meta.json +36 -0
  125. package/src/fx/horizon-gates.ts +60 -0
  126. package/src/fx/index.ts +258 -0
  127. package/src/fx/iridescent.meta.json +26 -0
  128. package/src/fx/iridescent.ts +8 -0
  129. package/src/fx/iris.meta.json +26 -0
  130. package/src/fx/iris.ts +4 -0
  131. package/src/fx/lightformers.meta.json +26 -0
  132. package/src/fx/lightformers.ts +8 -0
  133. package/src/fx/local.ts +200 -0
  134. package/src/fx/market-tape.meta.json +53 -0
  135. package/src/fx/market-tape.ts +97 -0
  136. package/src/fx/matcap.meta.json +26 -0
  137. package/src/fx/matcap.ts +8 -0
  138. package/src/fx/meta.schema.json +49 -0
  139. package/src/fx/metal.meta.json +26 -0
  140. package/src/fx/metal.ts +8 -0
  141. package/src/fx/mirror-floor.meta.json +26 -0
  142. package/src/fx/mirror-floor.ts +8 -0
  143. package/src/fx/neural-mesh.meta.json +54 -0
  144. package/src/fx/neural-mesh.ts +110 -0
  145. package/src/fx/orbit-agents.meta.json +36 -0
  146. package/src/fx/orbit-agents.ts +63 -0
  147. package/src/fx/orbit.meta.json +27 -0
  148. package/src/fx/orbit.ts +8 -0
  149. package/src/fx/outline.meta.json +43 -0
  150. package/src/fx/outline.ts +4 -0
  151. package/src/fx/paper-stack.meta.json +36 -0
  152. package/src/fx/paper-stack.ts +61 -0
  153. package/src/fx/particle-stream.meta.json +27 -0
  154. package/src/fx/particle-stream.ts +8 -0
  155. package/src/fx/particles.meta.json +26 -0
  156. package/src/fx/particles.ts +8 -0
  157. package/src/fx/pixelate.meta.json +28 -0
  158. package/src/fx/pixelate.ts +4 -0
  159. package/src/fx/points-on-geometry.meta.json +61 -0
  160. package/src/fx/points-on-geometry.ts +71 -0
  161. package/src/fx/proof-gate.meta.json +30 -0
  162. package/src/fx/proof-gate.ts +67 -0
  163. package/src/fx/rings.meta.json +27 -0
  164. package/src/fx/rings.ts +8 -0
  165. package/src/fx/room-ibl.meta.json +26 -0
  166. package/src/fx/room-ibl.ts +8 -0
  167. package/src/fx/sao.meta.json +32 -0
  168. package/src/fx/sao.ts +4 -0
  169. package/src/fx/scaffold.ts +172 -0
  170. package/src/fx/scatter.meta.json +49 -0
  171. package/src/fx/scatter.ts +74 -0
  172. package/src/fx/selective-bloom.meta.json +36 -0
  173. package/src/fx/selective-bloom.ts +4 -0
  174. package/src/fx/server-racks.meta.json +36 -0
  175. package/src/fx/server-racks.ts +54 -0
  176. package/src/fx/shader-particles.meta.json +46 -0
  177. package/src/fx/shader-particles.ts +75 -0
  178. package/src/fx/signal-pulse.meta.json +27 -0
  179. package/src/fx/signal-pulse.ts +8 -0
  180. package/src/fx/smaa.meta.json +19 -0
  181. package/src/fx/smaa.ts +4 -0
  182. package/src/fx/sobel.meta.json +24 -0
  183. package/src/fx/sobel.ts +4 -0
  184. package/src/fx/soft-shadows.meta.json +26 -0
  185. package/src/fx/soft-shadows.ts +8 -0
  186. package/src/fx/sprites.meta.json +40 -0
  187. package/src/fx/sprites.ts +57 -0
  188. package/src/fx/stagger-reveal.meta.json +26 -0
  189. package/src/fx/stagger-reveal.ts +8 -0
  190. package/src/fx/starfield.meta.json +32 -0
  191. package/src/fx/starfield.ts +18 -0
  192. package/src/fx/swarm.meta.json +27 -0
  193. package/src/fx/swarm.ts +8 -0
  194. package/src/fx/tessellate.meta.json +39 -0
  195. package/src/fx/tessellate.ts +79 -0
  196. package/src/fx/tokens.meta.json +27 -0
  197. package/src/fx/tokens.ts +8 -0
  198. package/src/fx/trail.meta.json +27 -0
  199. package/src/fx/trail.ts +8 -0
  200. package/src/fx/trust-ledger.meta.json +30 -0
  201. package/src/fx/trust-ledger.ts +47 -0
  202. package/src/fx/types.ts +83 -0
  203. package/src/fx/util.ts +108 -0
  204. package/src/fx/vault-glyphs.meta.json +37 -0
  205. package/src/fx/vault-glyphs.ts +55 -0
  206. package/src/fx/video-screen.meta.json +57 -0
  207. package/src/fx/video-screen.ts +99 -0
  208. package/src/fx/vignette.meta.json +32 -0
  209. package/src/fx/vignette.ts +4 -0
  210. package/src/fx/volume-cloud.meta.json +58 -0
  211. package/src/fx/volume-cloud.ts +87 -0
  212. package/src/fx/volume-perlin.meta.json +46 -0
  213. package/src/fx/volume-perlin.ts +82 -0
  214. package/src/fx/volumetric-spot.meta.json +26 -0
  215. package/src/fx/volumetric-spot.ts +8 -0
  216. package/src/fx/wireframe-overlay.meta.json +27 -0
  217. package/src/fx/wireframe-overlay.ts +8 -0
  218. package/src/ir/defaults.ts +62 -0
  219. package/src/ir/field-reference.ts +96 -0
  220. package/src/ir/hash.ts +34 -0
  221. package/src/ir/ids.ts +65 -0
  222. package/src/ir/merge.ts +155 -0
  223. package/src/ir/schema.json +1211 -0
  224. package/src/ir/types.ts +333 -0
  225. package/src/ir/validate.ts +196 -0
  226. package/src/parse/derive.ts +205 -0
  227. package/src/parse/harvest/bundle.ts +56 -0
  228. package/src/parse/harvest/harness.html +22 -0
  229. package/src/parse/harvest/harness.ts +191 -0
  230. package/src/parse/harvest/index.ts +169 -0
  231. package/src/parse/harvest/shapes.ts +75 -0
  232. package/src/parse/markdown.ts +215 -0
  233. package/src/props/embed.ts +92 -0
  234. package/src/props/fetch.ts +97 -0
  235. package/src/props/generate.ts +152 -0
  236. package/src/props/key.ts +13 -0
  237. package/src/props/search.ts +180 -0
  238. package/src/render/embed-video.ts +80 -0
  239. package/src/render/font.ts +86 -0
  240. package/src/render/index.ts +149 -0
  241. package/src/render/template.html +87 -0
  242. package/src/runtime/backgrounds.ts +146 -0
  243. package/src/runtime/builders.ts +808 -0
  244. package/src/runtime/camera.ts +73 -0
  245. package/src/runtime/hud.ts +887 -0
  246. package/src/runtime/index.ts +1168 -0
  247. package/src/runtime/local-fx.ts +151 -0
  248. package/src/runtime/materials.ts +136 -0
  249. package/src/runtime/measure.ts +73 -0
  250. package/src/runtime/node-geometry.ts +26 -0
  251. package/src/runtime/palette.ts +111 -0
  252. package/src/runtime/post.ts +649 -0
  253. package/src/runtime/props.ts +292 -0
  254. package/src/runtime/quality.ts +20 -0
  255. package/src/runtime/rng.ts +8 -0
  256. package/src/runtime/scene.ts +644 -0
  257. package/src/runtime/text.ts +174 -0
  258. package/src/runtime/types.ts +118 -0
  259. package/src/serve/index.ts +376 -0
  260. package/src/util/paths.ts +35 -0
@@ -0,0 +1,47 @@
1
+ // trust-ledger — verification seals stacking into an append-only chain (topic: trust). Licence: MIT.
2
+ import type { FxContext, FxFactory, FxHandle, FxParams } from "./types.js";
3
+
4
+ export const create: FxFactory = function (ctx: FxContext, params: FxParams): FxHandle {
5
+ const { THREE, palette, quality, rng } = ctx;
6
+ const density = typeof params.density === "number" ? params.density : 1;
7
+ const count = Math.max(12, Math.round((quality.particles / 30) * density));
8
+
9
+ const geo = new THREE.BoxGeometry(1.5, 0.5, 1.5);
10
+ const mat = new THREE.MeshStandardMaterial({ color: palette.second, metalness: 0.6, roughness: 0.35, transparent: true, opacity: 0.6 });
11
+ const blocks = new THREE.InstancedMesh(geo, mat, count);
12
+
13
+ const seeds: Array<Record<string, number>> = [];
14
+ for (let i = 0; i < count; i++) {
15
+ seeds.push({ x: (i % 4 - 1.5) * 4.5, y: -5 + Math.floor(i / 4) * 1.1, ph: rng() * 6.283 });
16
+ }
17
+
18
+ const linkGeo = new THREE.CylinderGeometry(0.03, 0.03, 0.6, 6);
19
+ const linkMat = new THREE.MeshBasicMaterial({ color: palette.accent, transparent: true, opacity: 0.6 });
20
+ const links = new THREE.InstancedMesh(linkGeo, linkMat, count);
21
+
22
+ const group = new THREE.Group();
23
+ group.add(blocks, links);
24
+ group.position.set(0, 0, -6);
25
+ const holder = new THREE.Group();
26
+ holder.add(group);
27
+ holder.userData.count = count;
28
+
29
+ const m = new THREE.Matrix4();
30
+ const place = function (t: number) {
31
+ for (let i = 0; i < count; i++) {
32
+ const s = seeds[i];
33
+ const y = s.y + Math.sin(t * 0.35 + s.ph) * 0.12;
34
+ blocks.setMatrixAt(i, m.makeTranslation(s.x, y, 0));
35
+ links.setMatrixAt(i, m.makeTranslation(s.x, y + 0.8, 0));
36
+ }
37
+ blocks.instanceMatrix.needsUpdate = true;
38
+ links.instanceMatrix.needsUpdate = true;
39
+ };
40
+ place(0);
41
+
42
+ return {
43
+ object: holder,
44
+ tick: place,
45
+ dispose: function () { geo.dispose(); mat.dispose(); linkGeo.dispose(); linkMat.dispose(); },
46
+ };
47
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Effect corpus types — one interface every effect module implements, plus the
3
+ * metadata card schema (design D9). Cards are the LLM's typed catalogue.
4
+ */
5
+ import type * as THREE from "three";
6
+ import type { PaletteColors } from "../runtime/palette.js";
7
+ import type { QualityProfile } from "../runtime/quality.js";
8
+
9
+ export type FxKind = "background" | "post" | "material" | "light" | "motion" | "edge" | "transition";
10
+ export type FxMode = "dark" | "light" | "both";
11
+
12
+ export type FxParams = Record<string, number | string | boolean>;
13
+
14
+ /**
15
+ * Closed topic vocabulary (design D3). `parse` routes a content slide to the
16
+ * cheapest `background` card carrying the matched topic, so the list is a
17
+ * contract between the keyword table and the corpus — not free-form like
18
+ * `tags.content`.
19
+ */
20
+ export const FX_TOPICS = [
21
+ "ai",
22
+ "agents",
23
+ "geo",
24
+ "trust",
25
+ "security",
26
+ "compute",
27
+ "data",
28
+ "money",
29
+ "work",
30
+ "timeline",
31
+ "sales",
32
+ "process",
33
+ ] as const;
34
+ export type FxTopic = (typeof FX_TOPICS)[number];
35
+
36
+ export interface FxCard {
37
+ id: string;
38
+ kind: FxKind;
39
+ tags: { mood: string[]; content: string[]; topic?: FxTopic[] };
40
+ cost: number;
41
+ modes: FxMode;
42
+ /** JSON Schema (object) for the effect's `params`. */
43
+ params: Record<string, unknown>;
44
+ conflicts: string[];
45
+ source: string;
46
+ licence: string;
47
+ }
48
+
49
+ export interface FxContext {
50
+ THREE: typeof THREE;
51
+ palette: PaletteColors;
52
+ mode: "dark" | "light";
53
+ quality: QualityProfile;
54
+ /** Seeded LCG — the only randomness an effect may use (keeps render deterministic). */
55
+ rng: () => number;
56
+ /** Read-only metadata of the slide the effect is being built for. */
57
+ slide: { id: string; title: string; kind: string };
58
+ }
59
+
60
+ export interface FxHandle {
61
+ object?: THREE.Object3D;
62
+ /** A composer pass id (post effects) or other runtime hook name. */
63
+ pass?: string;
64
+ material?: THREE.Material;
65
+ tick?: (t: number) => void;
66
+ /**
67
+ * Slide settled (true) or the camera is flying / the slide is off-screen
68
+ * (false). Time-based media uses this to stay frozen until it is actually
69
+ * being looked at; a pinned time in `check` never sees a moving clip.
70
+ */
71
+ setActive?: (active: boolean) => void;
72
+ dispose: () => void;
73
+ }
74
+
75
+ export type FxFactory = (ctx: FxContext, params: FxParams) => FxHandle;
76
+
77
+ export interface FxEntry {
78
+ card: FxCard;
79
+ create: FxFactory;
80
+ }
81
+
82
+ /** SPDX ids the corpus admits (design D9). */
83
+ export const PERMISSIVE_LICENCES = ["MIT", "Zlib", "BSD-2-Clause", "BSD-3-Clause", "CC0-1.0", "Apache-2.0", "OFL-1.1"] as const;
package/src/fx/util.ts ADDED
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Shared helpers for corpus effect modules (Section 18). Everything here is
3
+ * deterministic: no `Math.random`, no wall clock, no DOM — the corpus gate
4
+ * constructs every card in plain Node.
5
+ */
6
+ import type * as THREE from "three";
7
+ import type { FxContext, FxParams } from "./types.js";
8
+
9
+ export const num = (p: FxParams, k: string, d: number): number => (typeof p[k] === "number" ? (p[k] as number) : d);
10
+ export const str = (p: FxParams, k: string, d: string): string => (typeof p[k] === "string" ? (p[k] as string) : d);
11
+ export const bool = (p: FxParams, k: string, d: boolean): boolean => (typeof p[k] === "boolean" ? (p[k] as boolean) : d);
12
+
13
+ /** Instance count for the tier: `high` ≈ `particles / divisor`, `low` lands at ≤ half. */
14
+ export const countFor = (ctx: FxContext, divisor: number, density = 1, min = 8): number =>
15
+ Math.max(min, Math.round((ctx.quality.particles / divisor) * density));
16
+
17
+ /**
18
+ * Soft radial sprite as a `DataTexture` (no canvas — the corpus gate runs
19
+ * without a DOM). White with alpha falloff so `PointsMaterial.color` tints it.
20
+ */
21
+ export function softSprite(T: typeof THREE, size = 32, hardness = 1): THREE.DataTexture {
22
+ const data = new Uint8Array(size * size * 4);
23
+ const r = size / 2;
24
+ for (let y = 0; y < size; y++) {
25
+ for (let x = 0; x < size; x++) {
26
+ const d = Math.hypot(x + 0.5 - r, y + 0.5 - r) / r;
27
+ const a = Math.max(0, 1 - d) ** hardness;
28
+ const i = (y * size + x) * 4;
29
+ data[i] = data[i + 1] = data[i + 2] = 255;
30
+ data[i + 3] = Math.round(a * 255);
31
+ }
32
+ }
33
+ const tex = new T.DataTexture(data, size, size);
34
+ tex.needsUpdate = true;
35
+ return tex;
36
+ }
37
+
38
+ /** Deterministic value noise on a 3D lattice, seeded from `rng` once. */
39
+ export function makeNoise3(rng: () => number): (x: number, y: number, z: number) => number {
40
+ const P = new Uint8Array(512);
41
+ const perm = Array.from({ length: 256 }, (_, i) => i);
42
+ for (let i = 255; i > 0; i--) {
43
+ const j = Math.floor(rng() * (i + 1));
44
+ [perm[i], perm[j]] = [perm[j], perm[i]];
45
+ }
46
+ for (let i = 0; i < 512; i++) P[i] = perm[i & 255];
47
+ const fade = (t: number) => t * t * t * (t * (t * 6 - 15) + 10);
48
+ const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
49
+ const grad = (h: number, x: number, y: number, z: number) => {
50
+ const u = h < 8 ? x : y;
51
+ const v = h < 4 ? y : h === 12 || h === 14 ? x : z;
52
+ return ((h & 1) === 0 ? u : -u) + ((h & 2) === 0 ? v : -v);
53
+ };
54
+ return (x, y, z) => {
55
+ const X = Math.floor(x) & 255;
56
+ const Y = Math.floor(y) & 255;
57
+ const Z = Math.floor(z) & 255;
58
+ x -= Math.floor(x);
59
+ y -= Math.floor(y);
60
+ z -= Math.floor(z);
61
+ const u = fade(x);
62
+ const v = fade(y);
63
+ const w = fade(z);
64
+ const A = P[X] + Y;
65
+ const AA = P[A] + Z;
66
+ const AB = P[A + 1] + Z;
67
+ const B = P[X + 1] + Y;
68
+ const BA = P[B] + Z;
69
+ const BB = P[B + 1] + Z;
70
+ return lerp(
71
+ lerp(lerp(grad(P[AA] & 15, x, y, z), grad(P[BA] & 15, x - 1, y, z), u), lerp(grad(P[AB] & 15, x, y - 1, z), grad(P[BB] & 15, x - 1, y - 1, z), u), v),
72
+ lerp(lerp(grad(P[AA + 1] & 15, x, y, z - 1), grad(P[BA + 1] & 15, x - 1, y, z - 1), u), lerp(grad(P[AB + 1] & 15, x, y - 1, z - 1), grad(P[BB + 1] & 15, x - 1, y - 1, z - 1), u), v),
73
+ w,
74
+ );
75
+ };
76
+ }
77
+
78
+ /** A seeded 3D noise volume as a `Data3DTexture` (red channel), for the volume raymarchers. */
79
+ export function noiseVolume(T: typeof THREE, rng: () => number, size: number, scale = 0.08, octaves = 3): THREE.Data3DTexture {
80
+ const noise = makeNoise3(rng);
81
+ const data = new Uint8Array(size * size * size);
82
+ const c = size / 2;
83
+ let i = 0;
84
+ for (let z = 0; z < size; z++) {
85
+ for (let y = 0; y < size; y++) {
86
+ for (let x = 0; x < size; x++) {
87
+ let v = 0;
88
+ let amp = 1;
89
+ let f = scale;
90
+ for (let o = 0; o < octaves; o++) {
91
+ v += noise(x * f, y * f, z * f) * amp;
92
+ amp *= 0.5;
93
+ f *= 2;
94
+ }
95
+ // Fade to zero at the box edges so the cloud never shows a hard cube.
96
+ const d = 1 - Math.hypot(x - c, y - c, z - c) / c;
97
+ data[i++] = Math.max(0, Math.min(255, Math.round((v * 0.5 + 0.5) * 255 * Math.max(0, d))));
98
+ }
99
+ }
100
+ }
101
+ const tex = new T.Data3DTexture(data, size, size, size);
102
+ tex.format = T.RedFormat;
103
+ tex.minFilter = T.LinearFilter;
104
+ tex.magFilter = T.LinearFilter;
105
+ tex.unpackAlignment = 1;
106
+ tex.needsUpdate = true;
107
+ return tex;
108
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "id": "vault-glyphs",
3
+ "kind": "background",
4
+ "tags": {
5
+ "mood": [
6
+ "secure",
7
+ "formal"
8
+ ],
9
+ "content": [
10
+ "security",
11
+ "compliance"
12
+ ],
13
+ "topic": [
14
+ "trust",
15
+ "security"
16
+ ]
17
+ },
18
+ "cost": 2,
19
+ "modes": "both",
20
+ "params": {
21
+ "density": {
22
+ "type": "number",
23
+ "default": 1,
24
+ "minimum": 0.2,
25
+ "maximum": 3
26
+ },
27
+ "speed": {
28
+ "type": "number",
29
+ "default": 1,
30
+ "minimum": 0,
31
+ "maximum": 3
32
+ }
33
+ },
34
+ "conflicts": [],
35
+ "source": "https://threejs.org/examples/#webgl_geometry_shapes",
36
+ "licence": "MIT"
37
+ }
@@ -0,0 +1,55 @@
1
+ import type { FxContext, FxFactory, FxHandle, FxParams } from "./types.js";
2
+
3
+ /** Concentric vault rings with orbiting seal glyphs (topics: trust, security). */
4
+ export const create: FxFactory = (ctx: FxContext, params: FxParams): FxHandle => {
5
+ const { THREE, palette, quality, rng } = ctx;
6
+ const density = typeof params.density === "number" ? params.density : 1;
7
+ const speed = typeof params.speed === "number" ? params.speed : 1;
8
+ const count = Math.max(8, Math.round((quality.particles / 40) * density));
9
+
10
+ const group = new THREE.Group();
11
+ const disposables: Array<{ dispose: () => void }> = [];
12
+ const ringMat = new THREE.MeshBasicMaterial({ color: palette.second, transparent: true, opacity: 0.3 });
13
+ disposables.push(ringMat);
14
+
15
+ for (let r = 0; r < 3; r++) {
16
+ const geo = new THREE.TorusGeometry(4 + r * 2.2, 0.06, 8, 96);
17
+ disposables.push(geo);
18
+ group.add(new THREE.Mesh(geo, ringMat));
19
+ }
20
+
21
+ const glyphGeo = new THREE.OctahedronGeometry(0.34, 0);
22
+ disposables.push(glyphGeo);
23
+ const glyphMat = new THREE.MeshStandardMaterial({ color: palette.accent, metalness: 0.8, roughness: 0.3 });
24
+ disposables.push(glyphMat);
25
+ const glyphs = new THREE.InstancedMesh(glyphGeo, glyphMat, count);
26
+ const seeds = Array.from({ length: count }, () => ({ r: 4 + Math.floor(rng() * 3) * 2.2, ph: rng() * Math.PI * 2, sp: 0.15 + rng() * 0.2 }));
27
+ group.add(glyphs);
28
+
29
+ const holder = new THREE.Group();
30
+ holder.add(group);
31
+ holder.userData.count = count;
32
+
33
+ const m = new THREE.Matrix4();
34
+ const place = (t: number) => {
35
+ seeds.forEach((s, i) => {
36
+ const a = s.ph + t * s.sp * speed;
37
+ m.makeRotationZ(a);
38
+ m.setPosition(Math.cos(a) * s.r, Math.sin(a) * s.r, 0);
39
+ glyphs.setMatrixAt(i, m);
40
+ });
41
+ glyphs.instanceMatrix.needsUpdate = true;
42
+ };
43
+ place(0);
44
+
45
+ return {
46
+ object: holder,
47
+ tick: (t) => {
48
+ place(t);
49
+ group.rotation.z = t * 0.02 * speed;
50
+ },
51
+ dispose: () => {
52
+ for (const d of disposables) d.dispose();
53
+ },
54
+ };
55
+ };
@@ -0,0 +1,57 @@
1
+ {
2
+ "id": "video-screen",
3
+ "kind": "background",
4
+ "tags": {
5
+ "mood": [
6
+ "product",
7
+ "demo"
8
+ ],
9
+ "content": [
10
+ "screen",
11
+ "recording",
12
+ "video"
13
+ ]
14
+ },
15
+ "cost": 3,
16
+ "modes": "both",
17
+ "params": {
18
+ "src": {
19
+ "type": "string",
20
+ "default": "",
21
+ "description": "Same-origin clip URL, relative to the deck (served by `deck3d serve`). A file:// source taints the canvas and cannot be uploaded as a texture."
22
+ },
23
+ "width": {
24
+ "type": "number",
25
+ "default": 7,
26
+ "minimum": 1,
27
+ "maximum": 20
28
+ },
29
+ "x": {
30
+ "type": "number",
31
+ "default": 4.6,
32
+ "minimum": -20,
33
+ "maximum": 20
34
+ },
35
+ "y": {
36
+ "type": "number",
37
+ "default": 0.8,
38
+ "minimum": -10,
39
+ "maximum": 10
40
+ },
41
+ "z": {
42
+ "type": "number",
43
+ "default": -1.5,
44
+ "minimum": -20,
45
+ "maximum": 10
46
+ },
47
+ "tilt": {
48
+ "type": "number",
49
+ "default": -0.12,
50
+ "minimum": -1.5,
51
+ "maximum": 1.5
52
+ }
53
+ },
54
+ "conflicts": [],
55
+ "source": "https://github.com/BlackBeltTechnology/pi-agent-dashboard",
56
+ "licence": "MIT"
57
+ }
@@ -0,0 +1,99 @@
1
+ // video-screen — a framed screen in the scene playing a looping clip. Licence: MIT.
2
+ //
3
+ // SPIKE (video layer). Three constraints shaped this:
4
+ // 1. The clip must be SAME-ORIGIN. A `file://` video taints the canvas and
5
+ // then `texImage2D` throws, so the source is served by `deck3d serve`'s
6
+ // asset route (or, later, an inlined `data:` URL under `--embed-video`).
7
+ // 2. The panel is UNLIT (`MeshBasicMaterial`): a screen recording must read
8
+ // as its own pixels, not as a surface being lit by the rig's key light.
9
+ // 3. Playback is gated by `setActive` — frozen while the camera flies, and
10
+ // started only once the slide settles, so a clip never plays off-screen.
11
+ import type { FxContext, FxFactory, FxHandle, FxParams } from "./types.js";
12
+
13
+ export const create: FxFactory = (ctx: FxContext, params: FxParams): FxHandle => {
14
+ const { THREE, palette } = ctx;
15
+ const src = typeof params.src === "string" ? params.src : "";
16
+ const width = typeof params.width === "number" ? params.width : 7;
17
+ const x = typeof params.x === "number" ? params.x : 4.6;
18
+ const y = typeof params.y === "number" ? params.y : 0.8;
19
+ const z = typeof params.z === "number" ? params.z : -1.5;
20
+ const tilt = typeof params.tilt === "number" ? params.tilt : -0.12;
21
+
22
+ const group = new THREE.Group();
23
+ group.position.set(x, y, z);
24
+ group.rotation.y = tilt;
25
+
26
+ // 16:9 until the clip reports its real aspect, then corrected in `tick`.
27
+ let aspect = 16 / 9;
28
+ const screen = new THREE.Mesh(
29
+ new THREE.PlaneGeometry(width, width / aspect),
30
+ new THREE.MeshBasicMaterial({ color: 0x000000, toneMapped: false }),
31
+ );
32
+ const bezel = new THREE.Mesh(
33
+ new THREE.BoxGeometry(width * 1.04, (width / aspect) * 1.06, 0.14),
34
+ new THREE.MeshStandardMaterial({ color: palette.second, metalness: 0.8, roughness: 0.35 }),
35
+ );
36
+ bezel.position.z = -0.09;
37
+ bezel.castShadow = true;
38
+ group.add(bezel, screen);
39
+
40
+ let video: HTMLVideoElement | null = null;
41
+ let texture: THREE.VideoTexture | null = null;
42
+ let sized = false;
43
+ let active = false;
44
+
45
+ // The corpus gate runs without a DOM; a card must still construct there.
46
+ if (src && typeof document !== "undefined") {
47
+ video = document.createElement("video");
48
+ video.src = src;
49
+ video.loop = true;
50
+ video.muted = true;
51
+ video.playsInline = true;
52
+ video.crossOrigin = "anonymous";
53
+ video.preload = "auto";
54
+ video.load();
55
+ texture = new THREE.VideoTexture(video);
56
+ texture.colorSpace = THREE.SRGBColorSpace;
57
+ (screen.material as THREE.MeshBasicMaterial).map = texture;
58
+ (screen.material as THREE.MeshBasicMaterial).color.set(0xffffff);
59
+ (screen.material as THREE.MeshBasicMaterial).needsUpdate = true;
60
+ }
61
+
62
+ /** Re-fit the panel once the clip reports its real dimensions. */
63
+ const fit = (): void => {
64
+ if (sized || !video?.videoWidth) return;
65
+ aspect = video.videoWidth / video.videoHeight;
66
+ const h = width / aspect;
67
+ screen.geometry.dispose();
68
+ screen.geometry = new THREE.PlaneGeometry(width, h);
69
+ bezel.geometry.dispose();
70
+ bezel.geometry = new THREE.BoxGeometry(width * 1.04, h * 1.06, 0.14);
71
+ sized = true;
72
+ };
73
+
74
+ return {
75
+ object: group,
76
+ tick: () => {
77
+ fit();
78
+ // A pinned time (`check`/`snapshot`) must show a stable frame, so the
79
+ // clip is only ever running while the slide is settled.
80
+ if (!video) return;
81
+ if (active && video.paused) void video.play().catch(() => undefined);
82
+ if (!active && !video.paused) video.pause();
83
+ },
84
+ setActive: (next: boolean) => {
85
+ active = next;
86
+ if (!video) return;
87
+ if (!next) video.pause();
88
+ },
89
+ dispose: () => {
90
+ video?.pause();
91
+ texture?.dispose();
92
+ screen.geometry.dispose();
93
+ (screen.material as THREE.Material).dispose();
94
+ bezel.geometry.dispose();
95
+ (bezel.material as THREE.Material).dispose();
96
+ if (video) video.src = "";
97
+ },
98
+ };
99
+ };
@@ -0,0 +1,32 @@
1
+ {
2
+ "id": "vignette",
3
+ "kind": "post",
4
+ "tags": {
5
+ "mood": [
6
+ "cinematic",
7
+ "calm"
8
+ ],
9
+ "content": [
10
+ "framing"
11
+ ]
12
+ },
13
+ "cost": 1,
14
+ "modes": "both",
15
+ "params": {
16
+ "darkness": {
17
+ "type": "number",
18
+ "default": 1.0,
19
+ "minimum": 0,
20
+ "maximum": 2
21
+ },
22
+ "offset": {
23
+ "type": "number",
24
+ "default": 1.0,
25
+ "minimum": 0,
26
+ "maximum": 2
27
+ }
28
+ },
29
+ "conflicts": [],
30
+ "source": "https://github.com/pmndrs/postprocessing",
31
+ "licence": "Zlib"
32
+ }
@@ -0,0 +1,4 @@
1
+ import type { FxFactory, FxHandle } from "./types.js";
2
+
3
+ /** Post pass marker; the runtime composer owns the actual pass stack. */
4
+ export const create: FxFactory = (): FxHandle => ({ pass: "vignette", dispose: () => {} });
@@ -0,0 +1,58 @@
1
+ {
2
+ "id": "volume-cloud",
3
+ "kind": "background",
4
+ "tags": {
5
+ "mood": [
6
+ "atmospheric",
7
+ "soft"
8
+ ],
9
+ "content": [
10
+ "cloud",
11
+ "fog",
12
+ "nebula"
13
+ ]
14
+ },
15
+ "cost": 4,
16
+ "modes": "both",
17
+ "params": {
18
+ "threshold": {
19
+ "type": "number",
20
+ "default": 0.25,
21
+ "minimum": 0,
22
+ "maximum": 1
23
+ },
24
+ "opacity": {
25
+ "type": "number",
26
+ "default": 0.12,
27
+ "minimum": 0.02,
28
+ "maximum": 1
29
+ },
30
+ "range": {
31
+ "type": "number",
32
+ "default": 0.1,
33
+ "minimum": 0.01,
34
+ "maximum": 0.5
35
+ },
36
+ "scale": {
37
+ "type": "number",
38
+ "default": 14,
39
+ "minimum": 4,
40
+ "maximum": 30
41
+ },
42
+ "drift": {
43
+ "type": "number",
44
+ "default": 1,
45
+ "minimum": 0,
46
+ "maximum": 3
47
+ },
48
+ "x": {
49
+ "type": "number",
50
+ "default": -4,
51
+ "minimum": -12,
52
+ "maximum": 12
53
+ }
54
+ },
55
+ "conflicts": [],
56
+ "source": "https://threejs.org/examples/#webgl_volume_cloud",
57
+ "licence": "MIT"
58
+ }
@@ -0,0 +1,87 @@
1
+ import type { FxContext, FxFactory, FxHandle, FxParams } from "./types.js";
2
+ import { noiseVolume, num } from "./util.js";
3
+
4
+ const VERT = [
5
+ "in vec3 position; uniform mat4 modelMatrix, modelViewMatrix, projectionMatrix; uniform vec3 cameraPos;",
6
+ "out vec3 vOrigin; out vec3 vDirection;",
7
+ "void main(){ vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);",
8
+ " vOrigin = vec3(inverse(modelMatrix) * vec4(cameraPos, 1.0)).xyz; vDirection = position - vOrigin;",
9
+ " gl_Position = projectionMatrix * mvPosition; }",
10
+ ].join("\n");
11
+
12
+ const FRAG = [
13
+ "precision highp float; precision highp sampler3D;",
14
+ "uniform mat4 modelViewMatrix, projectionMatrix; in vec3 vOrigin; in vec3 vDirection; out vec4 color;",
15
+ "uniform vec3 base; uniform sampler3D map; uniform float threshold, range, opacity, steps, frame;",
16
+ "vec2 hitBox(vec3 orig, vec3 dir){ const vec3 box_min = vec3(-0.5); const vec3 box_max = vec3(0.5);",
17
+ " vec3 inv_dir = 1.0 / dir; vec3 tmin_tmp = (box_min - orig) * inv_dir; vec3 tmax_tmp = (box_max - orig) * inv_dir;",
18
+ " vec3 tmin = min(tmin_tmp, tmax_tmp); vec3 tmax = max(tmin_tmp, tmax_tmp);",
19
+ " return vec2(max(tmin.x, max(tmin.y, tmin.z)), min(tmax.x, min(tmax.y, tmax.z))); }",
20
+ "float sample1(vec3 p){ return texture(map, p).r; }",
21
+ "float shading(vec3 coord){ float step = 0.01; return sample1(coord + vec3(-step)) - sample1(coord + vec3(step)); }",
22
+ // Deterministic per-pixel dither: a hash of the fragment coordinate, NOT a random number.
23
+ "float dither(vec2 co){ return fract(sin(dot(co, vec2(12.9898, 78.233))) * 43758.5453); }",
24
+ "void main(){ vec3 rayDir = normalize(vDirection); vec2 bounds = hitBox(vOrigin, rayDir); if (bounds.x > bounds.y) discard;",
25
+ " bounds.x = max(bounds.x, 0.0); vec3 p = vOrigin + bounds.x * rayDir; vec3 inc = 1.0 / abs(rayDir);",
26
+ " float delta = min(inc.x, min(inc.y, inc.z)) / steps; p += rayDir * dither(gl_FragCoord.xy) * delta;",
27
+ " vec4 ac = vec4(base, 0.0);",
28
+ " for (float t = bounds.x; t < bounds.y; t += delta) {",
29
+ " float d = sample1(p + 0.5); d = smoothstep(threshold - range, threshold + range, d) * opacity;",
30
+ " float col = shading(p + 0.5) * 3.0 + ((p.x + p.y) * 0.25) + 0.2;",
31
+ " ac.rgb += (1.0 - ac.a) * d * col; ac.a += (1.0 - ac.a) * d; if (ac.a >= 0.95) break; p += rayDir * delta; }",
32
+ " color = ac; if (color.a == 0.0) discard; }",
33
+ ].join("\n");
34
+
35
+ /**
36
+ * A raymarched noise cloud (three `webgl_volume_cloud`). The 3D texture is
37
+ * seeded from `ctx.rng`; step count scales with the tier so `low` costs a
38
+ * fraction of `high`. `userData.count` reports the steps for the tier test.
39
+ */
40
+ export const create: FxFactory = (ctx: FxContext, params: FxParams): FxHandle => {
41
+ const { THREE, palette, rng, quality } = ctx;
42
+ const size = quality.particles >= 1500 ? 64 : quality.particles >= 900 ? 48 : 32;
43
+ const steps = quality.particles >= 1500 ? 100 : quality.particles >= 900 ? 60 : 32;
44
+ const tex = noiseVolume(THREE, rng, size, 0.07, 3);
45
+ const geo = new THREE.BoxGeometry(1, 1, 1);
46
+ const mat = new THREE.RawShaderMaterial({
47
+ glslVersion: THREE.GLSL3,
48
+ uniforms: {
49
+ base: { value: new THREE.Color(palette.second) },
50
+ map: { value: tex },
51
+ cameraPos: { value: new THREE.Vector3() },
52
+ threshold: { value: num(params, "threshold", 0.25) },
53
+ opacity: { value: num(params, "opacity", 0.12) },
54
+ range: { value: num(params, "range", 0.1) },
55
+ steps: { value: steps },
56
+ frame: { value: 0 },
57
+ },
58
+ vertexShader: VERT,
59
+ fragmentShader: FRAG,
60
+ side: THREE.BackSide,
61
+ transparent: true,
62
+ });
63
+ const mesh = new THREE.Mesh(geo, mat);
64
+ mesh.scale.setScalar(num(params, "scale", 14));
65
+ mesh.position.set(num(params, "x", -4), 1, -9);
66
+ const drift = num(params, "drift", 1);
67
+ const holder = new THREE.Group();
68
+ holder.add(mesh);
69
+ holder.userData.count = steps;
70
+ const cam = new THREE.Vector3();
71
+ mesh.onBeforeRender = (_r, _s, camera) => {
72
+ mat.uniforms.cameraPos.value.copy(camera.getWorldPosition(cam));
73
+ };
74
+ return {
75
+ object: holder,
76
+ tick: (t) => {
77
+ mesh.rotation.y = t * 0.03 * drift;
78
+ mesh.rotation.x = Math.sin(t * 0.05 * drift) * 0.15;
79
+ mat.uniforms.frame.value = t;
80
+ },
81
+ dispose: () => {
82
+ tex.dispose();
83
+ geo.dispose();
84
+ mat.dispose();
85
+ },
86
+ };
87
+ };