/** * DRAW CALLS — what the renderer will submit for this GLB, measured locally. * * WHY A CREATOR NEEDS THIS BEFORE UPLOADING. Draw calls are the one publish ceiling that no DCC tool displays. * Blender shows objects, materials and triangles; a glTF viewer shows nodes and meshes. None of them shows the * number the platform actually judges, so a creator can look at a "clean" file in every tool they own and still * be refused. Learning that after a 9 MB upload is the round trip this preflight exists to remove. * * WHY THIS IS A SECOND IMPLEMENTATION, DELIBERATELY. The authoritative copy is `asset-verification.ts` in * helix-backend-api, mirrored into universal-item-validator-worker and held there by the `glb-parser-sync` CI * check. It cannot import this module, and this module cannot be the one it calls: both of those hosts consume * this package from npm, so a measurement added here reaches them only after a release of * `@hypersoniclabs/helix-cli` and a lockfile bump in two repositories — which would mean the server could not * enforce the budget in the same change that defines it. The server gate is the one that counts; this one * exists to be EARLY, and it is pinned to the same numbers by `draw-calls.spec.ts`. * * If the two ever disagree, the server is right and this is the bug. The body below is a verbatim port; keep * it that way. */ /** One material's share of the submissions, for naming worst offenders. */ export interface DrawCallOffender { material: string; drawCalls: number; triangles: number; } export interface DrawCallBreakdown { /** GPU submissions: mesh primitives, once per node that instantiates the mesh. */ drawCalls: number; /** * Distinct materials bound by drawn geometry. This is the FLOOR `drawCalls` can reach by merging geometry * alone — below it you must atlas. */ boundMaterials: number; /** * `drawCalls - boundMaterials`: submissions removable by merging geometry that already shares a material, at * zero visual cost. The single most useful number to hand a creator, because it is the part of the overage * that costs them nothing to fix. */ mergeable: number; /** Materials bound by the most primitives, worst first, capped at 5. */ offenders: DrawCallOffender[]; /** True when the JSON chunk could not be read; callers must not gate on a guess. */ unreadable: boolean; /** * True when `drawCalls` counts render-state BATCHES (a vehicle, which the web runtime batches across parts) * rather than primitives per node. `offenders` still lists primitives per material. */ batched?: boolean; } /** * Count what the renderer will submit for this GLB. * * Instancing rules, stated because they are the whole difference between this * number and a naive primitive count: * - A mesh referenced by N nodes is drawn N times. Four wheel nodes sharing one * wheel mesh are four draws, and a creator who "deduplicated" them has saved * bytes, not batches. * - A mesh referenced by NO node is not in the scene graph and is not drawn. It * is still shipped bytes, which the file-size ceiling already judges. * - `EXT_mesh_gpu_instancing` collapses its node's copies into one submission, * which is exactly what per-node counting already yields. * - Points and lines still submit; they are counted as draws and carry no * triangles. */ export declare function measureDrawCalls(buffer: Buffer, kind?: string): DrawCallBreakdown;