@pmndrs/bvh
    Preparing search index...

    Class GpuRays

    Picking and batches of rays over a TraceSource, on the GPU. Rays are packed RAY_FLOATS floats each (packRays): origin, tMin, direction (normalized), tMax, the walk's BvhRay.

    const rays = await GpuRays.create(device, trees);          // a SceneTrees, or uploadTraceScene's buffers
    const hit = await rays.pick([0, 1, 5], [0, 0, -1]);       // one ray: a GpuRayHit or null
    const batch = await rays.traceClosest(packRays(list));      // thousands: batch.hit(i)
    

    A SceneTrees is traced as of its last update that was submitted.

    Index
    device: GPUDevice
    source: TraceSource

    What the rays are traced over.

    • get pending(): boolean

      True while a trace is in flight or queued (a frame loop can skip its trace then).

      Returns boolean

    • The walk's work per ray: the counted walk (counters: true, the same walk with step counters, so the same hits) over rays, for heat maps and tools. Its kernel is compiled at the first call; its times mean little (it writes more per ray), so measure speed with traceClosest or traceAny.

      Parameters

      Returns Promise<GpuWalkCounts>

    • Frees the buffers and the kernel's uniforms at once; traces still queued reject.

      Returns void

    • One ray from origin along direction (normalized here): its closest hit, or null.

      Parameters

      • origin: ArrayLike<number>
      • direction: ArrayLike<number>
      • options: GpuPickOptions = {}

      Returns Promise<GpuRayHit | null>

    • Destroys the buffers once the traces already asked for have finished (a page swapping scenes retires the old one).

      Returns Promise<void>