@pmndrs/bvh
    Preparing search index...

    Class BvhTraceNodes

    Our trace buffers in three's node system; see the file comment.

    const bvh = new BvhTraceNodes(renderer, sceneTrees); // each frame: sync.update(); sceneTrees.update(encoder); submit; bvh.update(); renderer.compute(...)

    Index
    closestPoint: (point: any, maxDistance?: any) => any

    (point, maxDistance = 1e30) => BvhClosestPointHit struct node: the scene's triangle point nearest to a world-space point (bvhClosestPoint). Throws unless made with queries: true.

    closestPointMasked: (point: any, maxDistance: any, mask: any) => any

    As closestPoint with a u32 instance mask; throws with rayMasks: false or without queries.

    module: Node

    The walk (bvhTraceClosest, bvhTraceAny, BvhRay, BvhHit, ...): include it in a wgslFn to call it from WGSL.

    nodeFormat: "f32" | "quantized"

    The source's node format, compiled into the walk.

    positionLayout: "vec4" | "packed"
    queries: boolean

    Whether the module has the spatial queries (queries: true).

    rayMasks: boolean
    storage: {
        nodes: StorageNode;
        positions: StorageNode | null;
        topLevel: StorageNode;
        triangles: StorageNode;
    }

    The storage nodes, for reading the layout directly (positions only for indexed leaves).

    traceAny: (origin: any, direction: any, tMin?: any, tMax?: any) => any

    (origin, direction, tMin = 0, tMax = 1e30) => bool node: anything in [tMin, tMax].

    traceAnyMasked: (
        origin: any,
        direction: any,
        tMin: any,
        tMax: any,
        mask: any,
    ) => any

    As traceAny with a u32 ray mask; throws with rayMasks: false.

    traceClosest: (origin: any, direction: any, tMin?: any, tMax?: any) => any

    (origin, direction, tMin = 0, tMax = 1e30) => BvhTraceHit struct node.

    traceClosestMasked: (
        origin: any,
        direction: any,
        tMin: any,
        tMax: any,
        mask: any,
    ) => any

    As traceClosest with a u32 ray mask; throws with rayMasks: false.

    triangleLeaves: "records" | "indexed"

    The source's triangle format, compiled into the walk.

    • get version(): number | undefined

      The version bound now (the source's at the last update).

      Returns number | undefined

    • Releases the stand-in attributes. The source's buffers are not destroyed (they are the source's).

      Returns void

    • three-mesh-bvh's getShapecastFn (PARITY 8.6): a scene shapecast whose box and triangle tests are three function nodes (BvhShapecastFnOptions: wgslFns, or TSL Fns with setLayout), compiled into the trace module's shapecast walk (the one traceModuleWgsl({ shapecast }) stamps for WGSL hooks: world space, every instance, node and triangle format). Returns a TSL function (shape?, mask?) => bool, true when the triangle hook stopped the cast; mask (a u32, default every instance) only with rayMasks. Needs queries: true (the walk's types and helpers).

      The hooks are functions of their own in the shader. A TSL Fn with a layout is cached across shaders by three, so its body must depend only on its arguments: pass per-call data as the shape. State a hook keeps between calls (a best distance, a count) needs a wgslFn writing its own var<private> or a storage buffer. The triangle hook may call the module's other walks (bvhTraceAny, bvhClosestPoint, ...); the bounds and keep hooks must not.

      Parameters

      Returns (...args: any[]) => any

    • Rebinds the storage nodes when the source's buffers were replaced (version changed, or a buffer object differs). Returns true when it rebound. Throws when three bound something other than our buffers to a stand-in it used (a three version whose internals differ; see threeInternals).

      Returns boolean