Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Module tests/unit/data/_shared/ladder-fold-contract

    Shared fold/residency contract for the four progressive LOD loaders (GSplats, Points, Lines, Mesh).

    All four now FOLD their ladder: concatenateMemoized builds one cumulative payload, drops the per-rung parts, and (where the geometry has one) releases the sub-loader's pooled accumulator. That is what took terminal residency from ~2x the geometry down toward ~1x (#2426, #2427, #2429).

    WHY THIS IS A STRUCTURAL ASSERTION AND NOT A HEAP MEASUREMENT. A before/after byte number cannot distinguish "released" from "not yet collected", drifts with unrelated changes, and — the point that actually matters — does not FAIL when someone regresses it. The fold's effect is a clean structural prediction (parts 100% + cumulative 100% -> cumulative only), so it is testable exactly. Byte measurements remain the right instrument for sizing the win; they are the wrong one for defending it.

    WHY SHARED. The pattern is duplicated four times over, and a regression in whichever loader gets touched next would otherwise be invisible — the other three would stay green. Parameterising one contract over all four means a fifth geometry, or a fold rewritten in one place, cannot quietly skip it.

    The three properties, and what each one catches:

    1. FOLDS TO A SINGLE PAYLOAD — the fold happened at all. Catches a loader that concatenates but forgets to drop the parts, which is the original ~2x bug.
    2. RESIDENCY REPORTS THE CUMULATIVE, IN LOGICAL LEVELS — ladderResidency() feeds the scene-wide budget, and it must report the merged payload's bytes against the LOGICAL rung count. Reporting loadedLODs.length (1, post-fold) would make the budget's mean-rung estimate read the whole merged blob as a single enormous next rung and stall refinement several rungs early.
    3. THE MULTI-PASS CLIMB ALSO FOLDS — exercises the real refinement shape, where each pass can build on the previous cumulative. The single-pass case concatenates only once and cannot expose retention between passes.
    FoldableLadderLoader
    LadderFoldSubject
    testLadderFoldContract