import type { Document, Material, Mesh, Node as GltfNode } from '@gltf-transform/core'; import type { Bounds, Mat4, Vec3 } from './math'; /** A GLB the splitter reads, with the facts needed to account for it. */ export type SplitModel = { key: string; sha256: string; bytes: number; document: Document; /** Bundle-relative path when the model came from a Scene document. */ uri?: string; }; /** One mesh-bearing node, with its transform resolved all the way to scene space. */ export type SplitItem = { key: string; name: string; model: SplitModel; node: GltfNode; mesh: Mesh; world: Mat4; bounds: Bounds; triangles: number; /** Original GPU instance, expanded for spatial planning and regrouped per cell. */ instanceIndex?: number; }; /** The geometry of one primitive that lies inside one grid cell, in cell-local float32. */ export type SplitFragment = { item: SplitItem; primitiveIndex: number; material: Material | null; /** Semantic -> flat float array with `components` per vertex. */ attributes: Map; indices: Uint32Array; }; export type SplitCell = { cx: number; cz: number; id: string; /** The cell's grid rectangle on the ground plane. */ grid: Bounds; /** Whole nodes owned by this cell, in stable source order. */ wholeItems: SplitItem[]; /** Geometry fragments clipped to this cell, in stable source order. */ fragments: SplitFragment[]; /** Tight bounds of everything the cell holds. */ bounds: Bounds; core: boolean; }; export type SplitOptions = { cellSizeM?: number; coreRadiusM?: number; spawn?: Vec3; streamRadiusM?: number; encoding?: 'meshopt' | 'none'; textures?: 'keep' | 'ktx2'; /** Directory that remembers encoded textures by content, so repeat splits skip the encoder. */ textureCacheDir?: string; title?: string; sceneId?: string; profile?: string; }; export type CellReport = { id: string; cx: number; cz: number; group: string; core: boolean; uri: string; sha256: string; bytes: number; /** Shared KTX2 files this cell references (each also used by other cells). */ textureBytes: number; triangles: number; nodes: number; fragments: number; textures: number; decodedMiB: number; bounds: Bounds; priority: number; distanceToSpawnM: number; }; export type SplitReport = { schemaVersion: 'helix.scene-split-report/1'; input: { kind: 'glb' | 'scene'; path: string; sha256: string; bytes: number; }; output: { scene: string; sceneId: string; revision: string; integritySha256: string; }; grid: { cellSizeM: number; origin: [number, number]; cells: number; populatedCells: number; }; spawn: { position: Vec3; groundBelowM: number | null; inCore: boolean; }; core: { radiusM: number; justification: string; cells: number; bytes: number; triangles: number; decodedMiB: number; }; eager: { before: { bytes: number; decodedMiB: number; resources: number; }; after: { bytes: number; decodedMiB: number; resources: number; }; }; cells: { count: number; bytes: { min: number; median: number; p90: number; max: number; total: number; }; triangles: { min: number; median: number; max: number; total: number; }; }; budget: { memoryBudgetMiB: number; streamRadiusM: number; validatorCommitmentMiB: number; peakWindowMiB: number; peakWindowAt: Vec3; }; geometry: { sourceTriangles: number; outputTriangles: number; splitItems: number; wholeItems: number; clippedTriangles: number; }; totals: { inputBytes: number; outputChunkBytes: number; outputSharedTextureBytes: number; outputPackageBytes: number; }; encoding: { geometry: string; textures: string; }; farCoverage: string; retained: { nodes: number; groups: string[]; hlodClusters: number; }; warnings: string[]; cellTable: CellReport[]; };