@pmndrs/bvh
    Preparing search index...

    Function refitOnCpu

    • Refits the tree in floats/words (one buffer, two views) in place from primitiveBoxes (PRIMITIVE_BOX_FLOATS per primitive), keeping its shape: each leaf slot gets the union of its primitives' boxes, each inner slot the union of its node's two slots. Empty primitive boxes (min > max) stay empty, and an empty slot is stored as a point at the largest float.

      order is refitOrderOf(parents, nodeCount), for a caller that refits the same tree again and again (it depends on the shape only); without it, it is worked out here.

      The nodes must be 64-byte f32 nodes. Quantized nodes (32 bytes, the scene default) are refit through an f32 copy: dequantizeNodes, refit, then quantizeNodeWords back. A node whose child counts or indices can't be an f32 node's (as quantized words read with the 64-byte stride) throws a RangeError before anything is written.

      Parameters

      • floats: Float32Array
      • words: Uint32Array
      • nodeWordOffset: number
      • nodeCount: number
      • parents: Uint32Array
      • primitiveBoxes: Float32Array
      • order: Uint32Array = ...

      Returns CpuRefitResult