Static ReadonlycpudepthSensing init fragment for XrSessionOptions requesting the
CPU path (readable buffer, sparse queries).
Static ReadonlygpudepthSensing init fragment requesting the GPU path (sampleable depth
texture for shader-side occlusion).
True once a depth format was negotiated at session creation.
The negotiated usage ('cpu-optimized' | 'gpu-optimized'), if any.
Accessing depthUsage on a session that wasn't granted the depth-sensing
feature throws InvalidStateError (rather than returning undefined), so
swallow it and report "not enabled".
CPU-readable depth for one view this frame, or null when unavailable. Query sparse points with depthInMeters; do not read the whole buffer per frame.
GPU depth texture for one view this frame, via the WebGPU XR binding, or
null when the binding/feature isn't present. Sample it in a compositing
shader (using normDepthBufferFromNormView) to occlude virtual fragments.
Real-world depth (meters) at normalized view coordinates (x, y) ∈ [0,1]².
WebXR depth sensing helper — the real world's per-pixel depth, used for occlusion (real objects hiding virtual ones) and physics-against-the-room.
Two paths, picked when the session is created (see XrDepth.cpuOptimized / XrDepth.gpuOptimized for the init fragment):
XRCPUDepthInformationwith a readable buffer and depthInMeters. Good for sparse queries (place a marker on the floor, test a few points) — a full-frame readback is too slow for per-pixel occlusion.GPUTexture(via the WebGPU XR binding) you can sample in a compositing shader to discard virtual fragments behind real geometry. This is the path for true occlusion, but it is the most experimental corner of WebGPU-WebXR and is not yet widely shipped — guard every call on the returned value.Part of the AR half of the WebXR integration — see TODO/webxr-integration.md.