/** * BrowserQuiltRenderer — QuiltRenderer that renders 48-view Looking Glass * quilts via per-tile camera transforms applied to a depth-displaced plane. * * Sprint 0a.2 deliverable. Two render paths share the same tile-camera math * coming out of {@link QuiltCompiler.compileQuilt}: * * 1. **GPU path (default in browser)** — three.js + `OffscreenCanvas` + * `WebGLRenderer` render each tile into an offscreen scene with a * displacement plane driven by the depth map. The composited quilt is * read back via `convertToBlob({ type: 'image/png' })`. * * 2. **Deterministic CPU path (default in headless / Node tests)** — same * tile-camera + displacement math implemented as a pure-JS rasterizer. * Output is encoded with the dependency-free PNG encoder so the bytes * are 100% reproducible across runtimes — required for the snapshot * hash determinism test (DoD: hash equal across runs on a 32×32 * fixture). * * The path is auto-selected: if `OffscreenCanvas` + `WebGLRenderer` are * usable, the GPU path runs; otherwise CPU. Both paths emit PNG-encoded * Uint8Array bytes from the {@link QuiltRenderer.render} entry. * * @see W.151: Quilt format = interchange standard for holographic images * @see P.151.01: Multi-View Camera Rig pattern * @see W.067a: Cross-platform stable hashes — pick a deterministic encoder. */ import type { QuiltRenderer } from '../createHologram'; import type { HologramSourceKind } from '../HologramBundle'; import { QuiltCompiler, type HoloComposition, type QuiltConfig } from '../QuiltCompiler'; export interface BrowserQuiltRendererConfig { /** * QuiltCompiler instance to use. Defaults to a fresh `new QuiltCompiler()`. * Inject for tests that want to verify the renderer calls * `compileQuilt(composition, overrides)` with the right overrides. */ compiler?: QuiltCompiler; /** * Composition to feed into `QuiltCompiler.compileQuilt`. Defaults to the * empty composition — the compiler then falls back to the @quilt trait * defaults in DEVICE_PRESETS. Tests use this to pin a small grid (e.g. * 3x2 / 6 views) for fast determinism checks. */ composition?: HoloComposition; /** Overrides forwarded to `compileQuilt` — most useful for tile-grid sizing */ overrides?: Partial; /** * Source-image decoder. The renderer needs the original image as RGBA8 * pixels to texture the displacement plane. Defaults to the same * `createImageBitmap`-based path as BrowserDepthProvider; tests inject a * deterministic synthetic decoder. */ imageDecoder?: (media: Uint8Array, sourceKind: HologramSourceKind) => Promise<{ data: Uint8ClampedArray; width: number; height: number; }>; /** * Force a specific render path. `'auto'` (default) probes browser APIs * and picks GPU when `OffscreenCanvas` + WebGL are available. */ path?: 'auto' | 'gpu' | 'cpu'; } export declare class BrowserQuiltRenderer implements QuiltRenderer { private readonly compiler; private readonly composition; private readonly overrides; private readonly imageDecoder; private readonly path; constructor(config?: BrowserQuiltRendererConfig); render(input: { depthMap: Float32Array; normalMap: Float32Array; width: number; height: number; frames: number; media: Uint8Array; sourceKind: HologramSourceKind; }): Promise; /** * Pick a tile rasterizer. The CPU path is always available; the GPU path * is used when OffscreenCanvas + WebGL are actually reachable. We do NOT * dynamically import three.js here — it's a hard dependency of the engine * package — but we DO probe for browser APIs at runtime so this same * provider runs (in CPU mode) inside Node tests + non-browser Workers. */ private selectTileRasterizer; } //# sourceMappingURL=BrowserQuiltRenderer.d.ts.map