@blackbelt-technology/pi-dashboard-deck3d 0.0.0-stage → 0.9.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,51 @@
1
+ import type { FxContext, FxFactory, FxHandle, FxParams } from "./types.js";
2
+
3
+ /** Instanced skyline of towers on a ground plane (topics: work, sales). */
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(24, Math.round((quality.particles / 8) * density));
9
+
10
+ const geo = new THREE.BoxGeometry(1, 1, 1);
11
+ const mat = new THREE.MeshStandardMaterial({ color: palette.second, metalness: 0.5, roughness: 0.6, transparent: true, opacity: 0.75 });
12
+ const towers = new THREE.InstancedMesh(geo, mat, count);
13
+ const m = new THREE.Matrix4();
14
+ const heights: number[] = [];
15
+ const side = Math.ceil(Math.sqrt(count));
16
+
17
+ for (let i = 0; i < count; i++) {
18
+ const h = 0.6 + rng() * 5;
19
+ heights.push(h);
20
+ const x = ((i % side) - side / 2) * 2.4 + (rng() - 0.5) * 0.6;
21
+ const z = (Math.floor(i / side) - side / 2) * 2.4 + (rng() - 0.5) * 0.6;
22
+ m.makeScale(0.9, h, 0.9);
23
+ m.setPosition(x, -6 + h / 2, z);
24
+ towers.setMatrixAt(i, m);
25
+ }
26
+ towers.instanceMatrix.needsUpdate = true;
27
+
28
+ const group = new THREE.Group();
29
+ group.add(towers);
30
+ group.rotation.x = 0.12;
31
+ // The runtime pins the RETURNED object's z, so the scene's own depth
32
+ // offset lives one level below it.
33
+ const holder = new THREE.Group();
34
+ group.position.set(0, -2, -0);
35
+ holder.add(group);
36
+ holder.userData.count = count;
37
+
38
+ return {
39
+ object: holder,
40
+ tick: (t) => {
41
+ group.rotation.y = Math.sin(t * 0.04 * speed) * 0.25;
42
+ // A slow breathing skyline reads as a living city without per-frame churn.
43
+ const k = 1 + Math.sin(t * 0.5 * speed) * 0.04;
44
+ towers.scale.y = k;
45
+ },
46
+ dispose: () => {
47
+ geo.dispose();
48
+ mat.dispose();
49
+ },
50
+ };
51
+ };
@@ -0,0 +1,49 @@
1
+ {
2
+ "id": "clipped-solids",
3
+ "kind": "background",
4
+ "tags": {
5
+ "mood": [
6
+ "technical",
7
+ "sculptural"
8
+ ],
9
+ "content": [
10
+ "cut",
11
+ "section",
12
+ "reveal"
13
+ ]
14
+ },
15
+ "cost": 3,
16
+ "modes": "both",
17
+ "params": {
18
+ "mode": {
19
+ "type": "string",
20
+ "default": "caps",
21
+ "enum": [
22
+ "planes",
23
+ "intersection",
24
+ "caps"
25
+ ]
26
+ },
27
+ "size": {
28
+ "type": "number",
29
+ "default": 1,
30
+ "minimum": 0.4,
31
+ "maximum": 2.5
32
+ },
33
+ "x": {
34
+ "type": "number",
35
+ "default": 5,
36
+ "minimum": -12,
37
+ "maximum": 12
38
+ },
39
+ "speed": {
40
+ "type": "number",
41
+ "default": 1,
42
+ "minimum": 0,
43
+ "maximum": 3
44
+ }
45
+ },
46
+ "conflicts": [],
47
+ "source": "https://threejs.org/examples/#webgl_clipping_stencil",
48
+ "licence": "MIT"
49
+ }
@@ -0,0 +1,171 @@
1
+ import type { FxContext, FxFactory, FxHandle, FxParams } from "./types.js";
2
+ import { num, str } from "./util.js";
3
+
4
+ /**
5
+ * Solids sliced by slowly turning clip planes (three `webgl_clipping_advanced`,
6
+ * `_intersection`, `_stencil` folded into one card via `mode`):
7
+ * - `planes` — one plane slices the solid (union clip);
8
+ * - `intersection` — `clipIntersection`: three planes carve ONE octant out;
9
+ * - `caps` — the same octant cut, with stencil caps closing the cut.
10
+ * The plane normals all lean to -z so the carved octant sits on the +z
11
+ * (camera-facing) corner, and turn about the view axis so it stays there.
12
+ * Clip planes are WORLD-space and the slide group sits anywhere along the
13
+ * rail, so `tick` rebuilds them from the holder's world matrix. Caps are
14
+ * ordinary children of the holder: each frame the world plane is mapped into
15
+ * holder space and the cap is posed there. (A "world-space root" whose
16
+ * `.matrix` is the holder's inverse does NOT work: with `matrixAutoUpdate`
17
+ * off, assigning `.matrix` never flags `matrixWorldNeedsUpdate`, so three kept
18
+ * the first frame's world matrix and the caps sat off the plane — a sliver.)
19
+ */
20
+ export const create: FxFactory = (ctx: FxContext, params: FxParams): FxHandle => {
21
+ const { THREE, palette, rng } = ctx;
22
+ const mode = str(params, "mode", "caps");
23
+ const speed = num(params, "speed", 1);
24
+ const size = num(params, "size", 1);
25
+ // One centred solid, like the example: the planes meet at its centre, so
26
+ // the carve always lands on it. Quality buys mesh detail, not more solids.
27
+ const segments = ctx.quality.particles >= 1500 ? 160 : ctx.quality.particles >= 900 ? 110 : 64;
28
+ const count = segments;
29
+ const carve = mode !== "planes";
30
+ const PLANES = carve ? 3 : 1;
31
+
32
+ const planes = Array.from({ length: PLANES }, () => new THREE.Plane(new THREE.Vector3(0, -1, 0), 0));
33
+ // Negated copies of the planes: a cap must be KEPT where the other planes
34
+ // are positive (inside the carved octant), which union clipping expresses
35
+ // as "clip by the negated plane".
36
+ const negated = planes.map(() => new THREE.Plane());
37
+ // three discards a plane's NEGATIVE side, so normals leaning to -z put the
38
+ // carved octant (negative of all three) on the +z, camera-facing corner.
39
+ const axes = carve
40
+ ? [new THREE.Vector3(0.75, 0.3, -0.6), new THREE.Vector3(-0.5, 0.55, -0.65), new THREE.Vector3(0.15, -0.7, -0.7)].map((v) => v.normalize())
41
+ : [new THREE.Vector3(0.6, 0.5, -0.62).normalize()];
42
+ const VIEW = new THREE.Vector3(0, 0, 1);
43
+ const geo = new THREE.TorusKnotGeometry(2.4 * size, 0.9 * size, segments, Math.max(8, segments >> 3));
44
+ const mat = new THREE.MeshStandardMaterial({
45
+ color: palette.second,
46
+ metalness: 0.6,
47
+ roughness: 0.35,
48
+ side: THREE.DoubleSide,
49
+ clippingPlanes: planes,
50
+ clipIntersection: carve,
51
+ clipShadows: true,
52
+ });
53
+
54
+ const group = new THREE.Group();
55
+ const solids: THREE.Group[] = [];
56
+ const stencilMats: THREE.Material[] = [];
57
+ const CENTRE = new THREE.Vector3(num(params, "x", 5), 0.5, -7);
58
+ {
59
+ const solid = new THREE.Group();
60
+ solid.position.copy(CENTRE);
61
+ solid.userData.spin = 0.25 + rng() * 0.3;
62
+ solid.userData.phase = rng() * 6.28;
63
+ const mesh = new THREE.Mesh(geo, mat);
64
+ mesh.renderOrder = PLANES + 1;
65
+ solid.add(mesh);
66
+ if (mode === "caps") {
67
+ // Per plane p: the solid CLIPPED BY p (so it is open exactly at that cut)
68
+ // writes the stencil — back faces increment, front faces decrement — and
69
+ // the count is non-zero only on p's cross-section, where the cap draws.
70
+ // (Reading this the other way round — clip by the OTHER planes — puts
71
+ // the cap on every cut except p's.)
72
+ for (let p = 0; p < PLANES; p++) {
73
+ const own = [planes[p]];
74
+ const stencil = (side: THREE.Side, op: THREE.StencilOp) =>
75
+ new THREE.MeshBasicMaterial({
76
+ depthWrite: false,
77
+ depthTest: false,
78
+ colorWrite: false,
79
+ stencilWrite: true,
80
+ stencilFunc: THREE.AlwaysStencilFunc,
81
+ side,
82
+ clippingPlanes: own,
83
+ stencilFail: op,
84
+ stencilZFail: op,
85
+ stencilZPass: op,
86
+ });
87
+ const front = stencil(THREE.FrontSide, THREE.DecrementWrapStencilOp);
88
+ const back = stencil(THREE.BackSide, THREE.IncrementWrapStencilOp);
89
+ stencilMats.push(front, back);
90
+ const f = new THREE.Mesh(geo, front);
91
+ const b = new THREE.Mesh(geo, back);
92
+ f.renderOrder = b.renderOrder = p + 1;
93
+ solid.add(f, b);
94
+ }
95
+ }
96
+ group.add(solid);
97
+ solids.push(solid);
98
+ }
99
+
100
+ // One cap per plane, posed in holder space each tick. Each cap is clipped
101
+ // by the OTHER planes so it stops at their cuts.
102
+ const capMats: THREE.Material[] = [];
103
+ const capGeo = new THREE.PlaneGeometry(40, 40);
104
+ const caps: THREE.Mesh[] = [];
105
+ if (mode === "caps") {
106
+ for (let p = 0; p < PLANES; p++) {
107
+ const capMat = new THREE.MeshStandardMaterial({
108
+ color: palette.accent,
109
+ metalness: 0.3,
110
+ roughness: 0.6,
111
+ side: THREE.DoubleSide,
112
+ clippingPlanes: negated.filter((_, k) => k !== p),
113
+ stencilWrite: true,
114
+ stencilRef: 0,
115
+ stencilFunc: THREE.NotEqualStencilFunc,
116
+ stencilFail: THREE.ReplaceStencilOp,
117
+ stencilZFail: THREE.ReplaceStencilOp,
118
+ stencilZPass: THREE.ReplaceStencilOp,
119
+ });
120
+ capMats.push(capMat);
121
+ const cap = new THREE.Mesh(capGeo, capMat);
122
+ cap.renderOrder = p + 1.1;
123
+ cap.onAfterRender = (renderer) => renderer.clearStencil();
124
+ group.add(cap);
125
+ caps.push(cap);
126
+ }
127
+ }
128
+
129
+ const holder = new THREE.Group();
130
+ holder.add(group);
131
+ holder.userData.count = count;
132
+
133
+ const q = new THREE.Quaternion();
134
+ const n = new THREE.Vector3();
135
+ const centre = new THREE.Vector3();
136
+ const inv = new THREE.Matrix4();
137
+ const local = new THREE.Plane();
138
+ const Z = new THREE.Vector3(0, 0, 1);
139
+ return {
140
+ object: holder,
141
+ tick: (t) => {
142
+ holder.updateWorldMatrix(true, false);
143
+ for (const s of solids) s.rotation.set(t * 0.3 * speed * s.userData.spin + s.userData.phase, t * 0.5 * speed * s.userData.spin, 0);
144
+ // The planes turn about the field's centre, in world space.
145
+ centre.copy(CENTRE).applyMatrix4(holder.matrixWorld);
146
+ q.setFromAxisAngle(VIEW, t * 0.2 * speed);
147
+ for (let p = 0; p < PLANES; p++) {
148
+ n.copy(axes[p]).applyQuaternion(q);
149
+ planes[p].setFromNormalAndCoplanarPoint(n, centre);
150
+ negated[p].copy(planes[p]).negate();
151
+ }
152
+ if (caps.length) {
153
+ inv.copy(holder.matrixWorld).invert();
154
+ for (let p = 0; p < PLANES; p++) {
155
+ // World plane → holder space; the cap's +Z faces AGAINST the normal,
156
+ // i.e. toward the removed half-space, where the viewer sees the cut.
157
+ local.copy(planes[p]).applyMatrix4(inv);
158
+ local.coplanarPoint(caps[p].position);
159
+ caps[p].quaternion.setFromUnitVectors(Z, n.copy(local.normal).negate());
160
+ }
161
+ }
162
+ },
163
+ dispose: () => {
164
+ geo.dispose();
165
+ mat.dispose();
166
+ for (const m of capMats) m.dispose();
167
+ capGeo.dispose();
168
+ for (const m of stencilMats) m.dispose();
169
+ },
170
+ };
171
+ };
@@ -0,0 +1,48 @@
1
+ {
2
+ "id": "cohort-grid",
3
+ "kind": "background",
4
+ "tags": {
5
+ "mood": [
6
+ "human",
7
+ "ordered"
8
+ ],
9
+ "content": [
10
+ "cohort",
11
+ "split"
12
+ ],
13
+ "topic": [
14
+ "work"
15
+ ]
16
+ },
17
+ "cost": 3,
18
+ "modes": "both",
19
+ "params": {
20
+ "density": {
21
+ "type": "number",
22
+ "default": 1,
23
+ "minimum": 0.2,
24
+ "maximum": 3
25
+ },
26
+ "cycleSpeed": {
27
+ "type": "number",
28
+ "default": 0.12,
29
+ "minimum": 0,
30
+ "maximum": 1
31
+ },
32
+ "cycleDepth": {
33
+ "type": "number",
34
+ "default": 0.6,
35
+ "minimum": 0,
36
+ "maximum": 1
37
+ },
38
+ "share": {
39
+ "type": "number",
40
+ "default": 0.5,
41
+ "minimum": 0,
42
+ "maximum": 1
43
+ }
44
+ },
45
+ "conflicts": [],
46
+ "source": "https://github.com/BlackBeltTechnology/pi-agent-dashboard",
47
+ "licence": "MIT"
48
+ }
@@ -0,0 +1,63 @@
1
+ // cohort-grid — a ranked grid of figures split into two cohorts (topic: work). Licence: MIT.
2
+ import type * as ThreeNS from "three";
3
+ import type { FxContext, FxFactory, FxHandle, FxParams } from "./types.js";
4
+
5
+ export const create: FxFactory = function (ctx: FxContext, params: FxParams): FxHandle {
6
+ const { THREE, palette, quality } = ctx;
7
+ const density = typeof params.density === "number" ? params.density : 1;
8
+ const cycleSpeed = typeof params.cycleSpeed === "number" ? params.cycleSpeed : 0.12;
9
+ const cycleDepth = typeof params.cycleDepth === "number" ? params.cycleDepth : 0.6;
10
+ const share = typeof params.share === "number" ? params.share : 0.5;
11
+ const count = Math.max(40, Math.min(100, Math.round(100 * density * (quality.particles >= 900 ? 1 : 0.45))));
12
+
13
+ const geo = new THREE.CapsuleGeometry(0.16, 0.42, 4, 8);
14
+ const upskilled = new THREE.MeshStandardMaterial({ color: palette.accent, metalness: 0.4, roughness: 0.5 });
15
+ const rest = new THREE.MeshStandardMaterial({ color: palette.second, metalness: 0.3, roughness: 0.7, transparent: true, opacity: 0.55 });
16
+
17
+ // The split is the message, so it is proportional — the deck supplies it via `share`.
18
+ const marked = Math.round(count * share);
19
+ const a = new THREE.InstancedMesh(geo, upskilled, marked);
20
+ const b = new THREE.InstancedMesh(geo, rest, count - marked);
21
+
22
+ const cols = 20;
23
+ const m = new THREE.Matrix4();
24
+ const place = function (mesh: ThreeNS.InstancedMesh, from: number, n: number) {
25
+ for (let i = 0; i < n; i++) {
26
+ const idx = from + i;
27
+ m.makeTranslation(((idx % cols) - cols / 2) * 0.95, Math.floor(idx / cols) * 0.95 - 3, 0);
28
+ mesh.setMatrixAt(i, m);
29
+ }
30
+ mesh.instanceMatrix.needsUpdate = true;
31
+ };
32
+ place(a, 0, marked);
33
+ place(b, marked, count - marked);
34
+
35
+ const group = new THREE.Group();
36
+ group.add(a, b);
37
+ group.position.set(0, 0, -11);
38
+ const holder = new THREE.Group();
39
+ holder.add(group);
40
+ holder.userData.count = count;
41
+
42
+ // Colour cycling is a slow, deliberate sweep between the two palette
43
+ // colours the two cohorts already use — NOT a per-figure re-roll, which
44
+ // reads as random flicker.
45
+ const from = new THREE.Color(palette.accent);
46
+ const to = new THREE.Color(palette.second);
47
+ const litA = new THREE.Color();
48
+ const litB = new THREE.Color();
49
+
50
+ return {
51
+ object: holder,
52
+ tick: function (t) {
53
+ group.rotation.y = Math.sin(t * 0.16) * 0.2;
54
+ a.position.y = Math.sin(t * 0.6) * 0.08;
55
+ // Half-amplitude around each cohort's own colour, in antiphase, so the
56
+ // split stays legible while the field breathes.
57
+ const k = (Math.sin(t * cycleSpeed * 6.283) * 0.5 + 0.5) * cycleDepth;
58
+ upskilled.color.copy(litA.copy(from).lerp(to, k * 0.5));
59
+ rest.color.copy(litB.copy(to).lerp(from, k * 0.5));
60
+ },
61
+ dispose: function () { geo.dispose(); upskilled.dispose(); rest.dispose(); },
62
+ };
63
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Effect composition (design D9): conflicts, mode gating, quality budget.
3
+ * Pure — shared by the render CLI and the corpus tests.
4
+ */
5
+ import type { EffectRef, Quality } from "../ir/types.js";
6
+ import { REGISTRY } from "./index.js";
7
+ import type { FxCard, FxMode } from "./types.js";
8
+
9
+ export const QUALITY_BUDGET: Record<Quality, number> = { low: 6, medium: 12, high: 20 };
10
+
11
+ export interface SkippedEffect {
12
+ id: string;
13
+ reason: string;
14
+ }
15
+
16
+ export interface Composition {
17
+ active: EffectRef[];
18
+ skipped: SkippedEffect[];
19
+ warnings: string[];
20
+ /** Non-empty ⇒ render must fail, naming the ids and slide. */
21
+ conflicts: string[];
22
+ }
23
+
24
+ /** Cards for `local:<name>` ids, keyed by BARE name (as embedded by `render`). */
25
+ export type LocalCards = Record<string, FxCard>;
26
+
27
+ /**
28
+ * A `local:` id resolves through the embedded cards, so a per-deck effect takes
29
+ * part in conflict / mode / budget gating exactly like a corpus one.
30
+ */
31
+ function card(id: string, local: LocalCards = {}): FxCard | undefined {
32
+ if (id.startsWith("local:")) return local[id.slice("local:".length)];
33
+ return REGISTRY[id]?.card;
34
+ }
35
+
36
+ function modeAllows(modes: FxMode, mode: "dark" | "light"): boolean {
37
+ return modes === "both" || modes === mode;
38
+ }
39
+
40
+ function conflictPairs(ids: string[], slideId: string, local: LocalCards): string[] {
41
+ const conflicts: string[] = [];
42
+ for (const id of ids) {
43
+ for (const other of card(id, local)?.conflicts ?? []) {
44
+ if (!ids.includes(other)) continue;
45
+ const detail = `${[id, other].sort().join(" + ")} slide ${slideId}`;
46
+ if (!conflicts.includes(detail)) conflicts.push(detail);
47
+ }
48
+ }
49
+ return conflicts;
50
+ }
51
+
52
+ export function composeEffects(
53
+ effects: EffectRef[] | undefined,
54
+ mode: "dark" | "light",
55
+ quality: Quality,
56
+ slideId: string,
57
+ local: LocalCards = {},
58
+ ): Composition {
59
+ const active: EffectRef[] = [];
60
+ const skipped: SkippedEffect[] = [];
61
+ const warnings: string[] = [];
62
+
63
+ for (const ref of effects ?? []) {
64
+ const c = card(ref.id, local);
65
+ if (!c) {
66
+ skipped.push({ id: ref.id, reason: "unknown" });
67
+ warnings.push(`warn unknown effect ${ref.id} slide ${slideId}`);
68
+ continue;
69
+ }
70
+ if (!modeAllows(c.modes, mode)) {
71
+ skipped.push({ id: ref.id, reason: `${c.modes} only` });
72
+ warnings.push(`warn skipped ${ref.id} (${c.modes} only) slide ${slideId}`);
73
+ continue;
74
+ }
75
+ active.push(ref);
76
+ }
77
+
78
+ const sum = active.reduce((total, e) => total + (card(e.id, local)?.cost ?? 0), 0);
79
+ if (sum > QUALITY_BUDGET[quality]) warnings.push(`warn budget slide ${slideId} ${sum} > ${QUALITY_BUDGET[quality]}`);
80
+
81
+ return { active, skipped, warnings, conflicts: conflictPairs(active.map((e) => e.id), slideId, local) };
82
+ }
83
+
84
+ /** Param-bounds violations for `validate` (E24). */
85
+ export interface ParamViolation {
86
+ path: string;
87
+ message: string;
88
+ }
89
+
90
+ function paramViolations(slideId: string, index: number, ref: EffectRef, local: LocalCards): ParamViolation[] {
91
+ const c = card(ref.id, local);
92
+ if (!c) return [];
93
+ const out: ParamViolation[] = [];
94
+ for (const [name, value] of Object.entries(ref.params ?? {})) {
95
+ const schema = c.params[name] as { minimum?: number; maximum?: number } | undefined;
96
+ if (!schema || typeof value !== "number") continue;
97
+ const base = `overrides.slides["${slideId}"].effects[${index}].params.${name}`;
98
+ if (schema.minimum !== undefined && value < schema.minimum) out.push({ path: base, message: `${value} < minimum ${schema.minimum}` });
99
+ if (schema.maximum !== undefined && value > schema.maximum) out.push({ path: base, message: `${value} > maximum ${schema.maximum}` });
100
+ }
101
+ return out;
102
+ }
103
+
104
+ /** Validate `overrides.slides[id].effects[i].params` against the card schemas. */
105
+ export function validateEffectParams(
106
+ ir: { overrides?: { slides?: Record<string, { effects?: EffectRef[] }> } },
107
+ local: LocalCards = {},
108
+ ): ParamViolation[] {
109
+ const out: ParamViolation[] = [];
110
+ for (const [slideId, slide] of Object.entries(ir.overrides?.slides ?? {})) {
111
+ (slide.effects ?? []).forEach((ref, i) => out.push(...paramViolations(slideId, i, ref, local)));
112
+ }
113
+ return out;
114
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "id": "constellation",
3
+ "kind": "background",
4
+ "tags": {
5
+ "mood": [
6
+ "calm",
7
+ "network"
8
+ ],
9
+ "content": [
10
+ "network",
11
+ "agents"
12
+ ],
13
+ "topic": [
14
+ "timeline"
15
+ ]
16
+ },
17
+ "cost": 2,
18
+ "modes": "both",
19
+ "params": {
20
+ "density": {
21
+ "type": "number",
22
+ "default": 0.5,
23
+ "minimum": 0.1,
24
+ "maximum": 1.5
25
+ },
26
+ "speed": {
27
+ "type": "number",
28
+ "default": 1,
29
+ "minimum": 0,
30
+ "maximum": 3
31
+ },
32
+ "linkDistance": {
33
+ "type": "number",
34
+ "default": 3.2,
35
+ "minimum": 1,
36
+ "maximum": 8
37
+ },
38
+ "nodeShape": {
39
+ "type": "string",
40
+ "default": "point",
41
+ "enum": [
42
+ "point",
43
+ "sphere",
44
+ "cube"
45
+ ]
46
+ }
47
+ },
48
+ "conflicts": [],
49
+ "source": "https://threejs.org/examples/#webgl_buffergeometry_drawrange",
50
+ "licence": "MIT"
51
+ }
@@ -0,0 +1,103 @@
1
+ import type { FxContext, FxFactory, FxHandle, FxParams } from "./types.js";
2
+ import { countFor, num, str } from "./util.js";
3
+
4
+ /**
5
+ * Drifting nodes that link to neighbours within reach (three
6
+ * `webgl_buffergeometry_drawrange`). Each node's position is a pure function
7
+ * of `t` (a triangle-wave bounce inside the box), so the frame is
8
+ * deterministic; the link buffer is rebuilt per tick and `drawRange` trims it.
9
+ * `nodeShape` = point | sphere | cube — sphere/cube use one instanced mesh.
10
+ */
11
+ export const create: FxFactory = (ctx: FxContext, params: FxParams): FxHandle => {
12
+ const { THREE, palette, rng } = ctx;
13
+ const count = countFor(ctx, 5, num(params, "density", 0.5) * 2, 24);
14
+ const speed = num(params, "speed", 1);
15
+ const reach = num(params, "linkDistance", 3.2);
16
+ const shape = str(params, "nodeShape", "point");
17
+ const HALF = new THREE.Vector3(14, 6, 6);
18
+
19
+ const origin = new Float32Array(count * 3);
20
+ const vel = new Float32Array(count * 3);
21
+ for (let i = 0; i < count * 3; i++) {
22
+ origin[i] = (rng() - 0.5) * 2 * [HALF.x, HALF.y, HALF.z][i % 3];
23
+ vel[i] = (rng() - 0.5) * 0.8;
24
+ }
25
+ const positions = new Float32Array(count * 3);
26
+ const nodeGeo = new THREE.BufferGeometry();
27
+ nodeGeo.setAttribute("position", new THREE.BufferAttribute(positions, 3));
28
+
29
+ const group = new THREE.Group();
30
+ let points: THREE.Points | null = null;
31
+ let inst: THREE.InstancedMesh | null = null;
32
+ const nodeMat: THREE.Material =
33
+ shape === "point"
34
+ ? new THREE.PointsMaterial({ color: palette.accent, size: 0.16, transparent: true, opacity: 0.9, depthWrite: false })
35
+ : new THREE.MeshStandardMaterial({ color: palette.accent, metalness: 0.5, roughness: 0.4 });
36
+ const instGeo = shape === "cube" ? new THREE.BoxGeometry(0.22, 0.22, 0.22) : new THREE.SphereGeometry(0.12, 10, 8);
37
+ if (shape === "point") {
38
+ points = new THREE.Points(nodeGeo, nodeMat);
39
+ group.add(points);
40
+ } else {
41
+ inst = new THREE.InstancedMesh(instGeo, nodeMat, count);
42
+ group.add(inst);
43
+ }
44
+
45
+ const maxLinks = count * count;
46
+ const linkPos = new Float32Array(maxLinks * 3);
47
+ const linkGeo = new THREE.BufferGeometry();
48
+ linkGeo.setAttribute("position", new THREE.BufferAttribute(linkPos, 3).setUsage(THREE.DynamicDrawUsage));
49
+ const linkMat = new THREE.LineBasicMaterial({ color: palette.second, transparent: true, opacity: 0.35, depthWrite: false });
50
+ const lines = new THREE.LineSegments(linkGeo, linkMat);
51
+ group.add(lines);
52
+ group.position.z = -4;
53
+
54
+ const holder = new THREE.Group();
55
+ holder.add(group);
56
+ holder.userData.count = count;
57
+
58
+ // Triangle wave: bounces between -h and +h without integrating anything.
59
+ const bounce = (x: number, h: number) => {
60
+ const p = 4 * h;
61
+ const m = ((((x + h) % p) + p) % p);
62
+ return m < 2 * h ? m - h : 3 * h - m;
63
+ };
64
+ const m4 = new THREE.Matrix4();
65
+ const r2 = reach * reach;
66
+ return {
67
+ object: holder,
68
+ tick: (t) => {
69
+ const half = [HALF.x, HALF.y, HALF.z];
70
+ for (let i = 0; i < count * 3; i++) positions[i] = bounce(origin[i] + vel[i] * t * speed, half[i % 3]);
71
+ if (points) nodeGeo.attributes.position.needsUpdate = true;
72
+ if (inst) {
73
+ for (let i = 0; i < count; i++) inst.setMatrixAt(i, m4.makeTranslation(positions[i * 3], positions[i * 3 + 1], positions[i * 3 + 2]));
74
+ inst.instanceMatrix.needsUpdate = true;
75
+ }
76
+ let n = 0;
77
+ for (let i = 0; i < count; i++) {
78
+ for (let j = i + 1; j < count; j++) {
79
+ const dx = positions[i * 3] - positions[j * 3];
80
+ const dy = positions[i * 3 + 1] - positions[j * 3 + 1];
81
+ const dz = positions[i * 3 + 2] - positions[j * 3 + 2];
82
+ if (dx * dx + dy * dy + dz * dz > r2) continue;
83
+ linkPos[n++] = positions[i * 3];
84
+ linkPos[n++] = positions[i * 3 + 1];
85
+ linkPos[n++] = positions[i * 3 + 2];
86
+ linkPos[n++] = positions[j * 3];
87
+ linkPos[n++] = positions[j * 3 + 1];
88
+ linkPos[n++] = positions[j * 3 + 2];
89
+ }
90
+ }
91
+ linkGeo.setDrawRange(0, n / 3);
92
+ linkGeo.attributes.position.needsUpdate = true;
93
+ group.rotation.y = Math.sin(t * 0.05) * 0.15;
94
+ },
95
+ dispose: () => {
96
+ nodeGeo.dispose();
97
+ instGeo.dispose();
98
+ nodeMat.dispose();
99
+ linkGeo.dispose();
100
+ linkMat.dispose();
101
+ },
102
+ };
103
+ };