Documentation - v20.0.0-dev
    Preparing search index...

    Reads a BoxTree in its shared buffer, from any thread, while its writer (the BoxTreeWorker) changes it: a query walks the tree as it is, and stops at what a write in progress left unlinked (a freed node, a child past the views). It may then miss a leaf for that instant.

    The leaves hold ids (in the scene's tree, a part's or a sprite's: see LeafIds): the queries give them, their objects are the caller's.

    Its views (f32, i32) have a fixed length, made again when the writer grew the buffer: V8 reads a view that tracks a growable buffer's length 4 to 5 times slower.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _f32: Float32Array

    Float32 view of the whole buffer, as long as it was when last read.

    _i32: Int32Array

    Int32 view of the whole buffer, as long as it was when last read.

    buffer: SharedArrayBuffer

    The tree's nodes: grown by its writer, the same buffer.

    isBoxTree: true

    Tells a BoxTree (a reader, the BoxTree or its BoxTreeStructure) apart.

    Accessors

    • get f32(): Float32Array

      Float32 view of the whole buffer; made again when it grew.

      Returns Float32Array

    • get i32(): Int32Array

      Int32 view of the whole buffer; made again when it grew.

      Returns Int32Array

    • get root(): number

      The root node, or -1 when the tree is empty.

      Returns number

    Methods

    • Views of a fixed length on the whole buffer (see the class).

      Returns void

    • Nodes traverse visits with these options.

      Parameters

      • options: { leavesOnly?: boolean; maxDepth?: number } = {}

      Returns number

    • The root's box; empty without leaves.

      Parameters

      Returns Box3

    • The leaves whose box holds the point, the nearest box centre first.

      Parameters

      • point: Vector3
      • boxExpansion: number = 0

      Returns BoxTreeIntersection[]

    • The leaves whose box the ray crosses, nearest entry first.

      Parameters

      • ray: Ray
      • boxExpansion: number = 0

        Grows every box by this much on each side.

      • onlyFirst: boolean = true

        Only the leaf whose box the ray enters first (default): the boxes the ray enters farther than it are not walked.

      Returns BoxTreeIntersection[]

    • Calls callback on each node, depth first from the root.

      Parameters

      • callback: (node: BoxTreeNode, index: number, depth: number) => void
      • options: { leavesOnly?: boolean; maxDepth?: number } = {}

      Returns void