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

    Module data/tolerance-computer

    Canonical tolerance computer used by all geometry-specific spatial-index loaders.

    THE RULE A MAINTAINER NEEDS, in one sentence: the writer's published barrier set says which rule matches the chunk BOUNDS; the scene's discrete flag says which gate the RENDERER applies; when they disagree the fetch window follows the renderer. Everything below is that sentence applied per geometry type.

    Displayed dimensions always get infinite tolerance (1e10) regardless of type. Hidden (non-displayed) dimensions split by geometry:

    • Points: maxRadius for spatial dims (selected via the spatialExtendDims option, the per-dimension flag array carried by EffectiveRadiusConfig), the shared quarter-cell discreteDimTolerance otherwise. Points never ask about barrier-ness at all — see computePointsHiddenTolerance.
    • Lines: 0 for spatial dims (segment bounding boxes already include line width extent); discreteDimTolerance for barrier dims, or discreteDimMembershipTolerance when the caller is the projection-clipping slab (discreteRole: 'membership').
    • GSplats: three cases, not two, derived in computeGSplatsHiddenTolerance — barrier dims take the quarter-cell reach, genuinely continuous ones the float-safety epsilon gsplatsContinuousDimTolerance (deliberately NOT a reach: the chunk bounds already carry the truncation_radius · σ expansion the projection kernel attenuates to zero at), and a dim the writer's published set OMITS while the scene declares it discrete takes the half-cell membership window.
    • Mesh: step × meshSlabTolerance (default one cell) for continuous dims, and the half-cell MEMBERSHIP rule for barrier ones — the only type whose barrier arm is not the quarter-cell query reach, because a mesh is whole-node resident and BOTH of its arms are visibility gates. See the mesh note below; it is the one arm where copying a neighbour silently renders nothing.

    The quarter-cell barrier reach and the half-cell membership gate are two different numbers on purpose; DISCRETE_TOLERANCE_FRACTION is where that is argued. "Is this dim a barrier?" is answered once per dimension by isBarrierDim, which consults the writer's published set for GSPLATS ONLY — see its docstring for why the seam stops there.

    Called from SpatialQueryBuilder (geometry-aware QUERY path), from data-processor-lines.ts (lines projection clipping, MEMBERSHIP role), and from data-processor-mesh.ts (mesh slab membership — mesh has no query role at all).

    Every existing strategy is derived from that type's per-element extent, and a mesh has none: a triangle's extent comes from its own three vertices (docs/specs/MESH_NODE_SPEC.md §2.2). Both halves of the mesh arm are therefore chosen rather than inherited, and each has a specific failure mode if copied:

    • Not Lines' 0 for spatial dims. Lines get away with zero because segment clipping interpolates through the slab — a segment crossing the slice yields an intersection even at zero thickness. Mesh culls whole triangles with no interpolation, so a tolerance of 0 reduces membership to exact float equality with the slice plane and the node renders nothing. This is the single most tempting wrong answer here, because Lines is the nearest structural sibling.
    • Not the quarter-cell query reach for discrete dims. Mesh's slab test is a MEMBERSHIP gate applied after fetch (the node is whole-node resident, §7), not a chunk-fetch reach, so it wants the half-cell — exactly like the lines clipping slab. The 'query' default is deliberately < 0.5 × step and would drop on-grid geometry.

    Be honest about what the continuous arm means: with per-vertex cull there is no such thing as a true planar cut, so a continuous hidden spatial dimension renders a thick slab ("the surface near this slice"), and the slab thickness is the only control. A mesh whose hidden dims are continuous and spatial is a poor fit for this node type until exact nD clipping exists (§9). The dominant real case is discrete — a mesh's hidden dimensions are almost always time or channel.

    DimensionInfo
    ToleranceOptions
    discreteDimTolerance
    discreteDimMembershipTolerance
    gsplatsContinuousDimTolerance
    computeTolerance