Cookbook — Spark (Gaussian Splats) · cb-spark
Owner directive (2026-07-10), canonical. "For now, generate with the Holonprint Loop with gaussian splatting, lenis, tailwind, react, next, use webgl … just execute what is being said in official doc." [src: wiki/development/prompts-archive/by-topic/knowledge-management-and-concept-modeling.md:498]
Official docs
| item | pin | reference |
|---|---|---|
@sparkjsdev/spark | 2.1.0 [src: HOS-Instance/packages/engine/package.json:17] | https://sparkjs.dev/docs |
peer: three | 0.183.2 | see cb-threejs |
Cookbook rule per the owner order: implementations follow the official docs exactly; the patterns below are our proven applications of them, not replacements.
Our proven patterns
fileBytesloader with byte-true progress. Stream the.splatoverfetch+res.body.getReader(), emit(id, loadedBytes, totalBytes)per chunk, concatenate, then constructnew SplatMesh({ fileBytes, fileName, onLoad })and awaitonLoad. Spark decodes the packed-splat layout natively whenfileNameends in.splat. [src: HOS-Instance/packages/engine/src/engine/loader.ts:108]- Packed
.splatrecord contract (32 bytes, little-endian):f32×3 position · f32×3 scale · u8×4 color(rgba) · u8×4 rotation(qw,qx,qy,qz mapped q*128+128)— written by the offline generators, consumed by Spark. [src: HOS-Instance/packages/engine/src/engine/contracts.ts:154] - One
SparkRendererin the scene. Create it once with the sharedWebGLRendererandscene.add(spark); allSplatMeshes render through it. [src: HOS-Instance/packages/engine/src/engine/renderer.ts:44] - Manifest-driven tiered assets. Every asset declares
files/bytes/countperdesktop|mobiletier plus its world AABB and owning chapter; the loader sumstotalBytes/totalCountfor budget checks. [src: HOS-Instance/packages/engine/src/engine/contracts.ts:17] - Dispose-safe mid-flight loads. Cache slots carry a
disposedflag; ifdispose(id)lands while bytes are in flight, the built mesh is immediately disposed and the promise rejects — no orphan GPU memory. [src: HOS-Instance/packages/engine/src/engine/loader.ts:147] - Chapter slabs. Each chapter owns a disjoint world-space slab along −Z so adjacent chapters can be co-resident without overlap; camera flies mostly along −Z. [src: HOS-Instance/packages/engine/src/engine/contracts.ts:166]
- Dual-position morph plan (Spatial Site v2, planned). Letterform sceneries are baked with two positions per splat (scenery pose / Arabic-letterform pose per the owner order [src: wiki/development/prompts-archive/by-topic/knowledge-management-and-concept-modeling.md:481]) and morphed by scroll progress — see pb-001-spatial-site-loop step 4.
Gotchas
- Never trust
content-lengthalone — prefer the manifest's declaredbytes, fall back to the header, else to running total. [src: HOS-Instance/packages/engine/src/engine/loader.ts:119] - The loader deliberately does NOT add meshes to the scene — placement belongs to the director's
ChapterContext. [src: HOS-Instance/packages/engine/src/engine/loader.ts:53] - Eviction is a soft budget: unmount chapters ≥2 away, farthest first, only while resident count exceeds
SPLAT_BUDGET[tier]. [src: HOS-Instance/packages/engine/src/engine/director.ts:182]
Budgets
SPLAT_BUDGET = { desktop: 700_000, mobile: 300_000 } visible-splat ceilings [src: HOS-Instance/packages/engine/src/engine/contracts.ts:149] — thresholds governed by bm-002-splat-budget; frame budgets by bm-001-web-perf.
Composition
- uses: cb-threejs (peer runtime) · gaussian-splatting · spark-renderer
- used-by: pb-001-spatial-site-loop (steps 3–6) · cb-patterns-royal-orbit · schema-holonprint (method
gaussian-splatting)