Skip to main content

Class: Depth

Defined in: src/depth/Depth.ts:30

Constructors​

Constructor​

new Depth(): Depth

Defined in: src/depth/Depth.ts:109

Depth is a lightweight manager based on three.js to simply prototyping with Depth in WebXR.

Returns​

Depth

Properties​

cpuDepthData​

cpuDepthData: XRCPUDepthInformation[] = []

Defined in: src/depth/Depth.ts:42


depthArray​

depthArray: DepthArray[] = []

Defined in: src/depth/Depth.ts:44


depthCameraPositions​

depthCameraPositions: Vector3[] = []

Defined in: src/depth/Depth.ts:86


depthCameraRotations​

depthCameraRotations: Quaternion[] = []

Defined in: src/depth/Depth.ts:87


depthDataFormat?​

optional depthDataFormat: XRDepthDataFormat

Defined in: src/depth/Depth.ts:45


depthMesh?​

optional depthMesh: DepthMesh

Defined in: src/depth/Depth.ts:46


depthProjectionInverseMatrices​

depthProjectionInverseMatrices: Matrix4[] = []

Defined in: src/depth/Depth.ts:83


depthProjectionMatrices​

depthProjectionMatrices: Matrix4[] = []

Defined in: src/depth/Depth.ts:82


depthViewMatrices​

depthViewMatrices: Matrix4[] = []

Defined in: src/depth/Depth.ts:84


depthViewProjectionMatrices​

depthViewProjectionMatrices: Matrix4[] = []

Defined in: src/depth/Depth.ts:85


enabled​

enabled: boolean = false

Defined in: src/depth/Depth.ts:40


gpuDepthData​

gpuDepthData: XRWebGLDepthInformation[] = []

Defined in: src/depth/Depth.ts:43


height​

height: number = DEFAULT_DEPTH_HEIGHT

Defined in: src/depth/Depth.ts:50


normDepthBufferFromNormViewMatrices​

normDepthBufferFromNormViewMatrices: Matrix4[] = []

Defined in: src/depth/Depth.ts:93

Transforms from normalized view coordinates to normalized depth buffer coordinates. Identity when matchDepthView is true.


occludableShaders​

occludableShaders: Set<Shader>

Defined in: src/depth/Depth.ts:75


options​

options: DepthOptions

Defined in: src/depth/Depth.ts:48


view​

view: XRView[] = []

Defined in: src/depth/Depth.ts:41


width​

width: number = DEFAULT_DEPTH_WIDTH

Defined in: src/depth/Depth.ts:49


instance?​

static optional instance: Depth

Defined in: src/depth/Depth.ts:31

Accessors​

rawValueToMeters​

Get Signature​

get rawValueToMeters(): number

Defined in: src/depth/Depth.ts:51

Returns​

number

Methods​

debugLog()​

debugLog(): void

Defined in: src/depth/Depth.ts:647

Returns​

void


dispose()​

dispose(): void

Defined in: src/depth/Depth.ts:686

Releases depth resources at terminal Core teardown, not on XR exit.

Returns​

void


getDepth()​

getDepth(u, v, viewId): number

Defined in: src/depth/Depth.ts:250

Retrieves the depth at normalized coordinates (u, v). Note: The UV coordinates are with respect to the user's view, not the depth camera view.

Parameters​

u​

number

Normalized horizontal coordinate, origin at the bottom left of the view, growing right.

v​

number

Normalized vertical coordinate, origin at the bottom left of the view, growing up.

viewId​

number = 0

View index to query (default 0). Requesting viewId > 0 enables secondary view updates.

Returns​

number

Depth value at the specified coordinates.


getProjectedDepthViewPositionFromWorldPosition()​

getProjectedDepthViewPositionFromWorldPosition(position, target, viewId): Vector3

Defined in: src/depth/Depth.ts:270

Projects the given world position to depth camera's clip space and then to the depth camera's view space using the depth.

Parameters​

position​

Vector3

The world position to project.

target​

Vector3 = ...

Optional target vector.

viewId​

number = 0

View index to query (default 0).

Returns​

Vector3

The depth camera view space position.


getTexture()​

getTexture(viewId): ExternalTexture | DataTexture | undefined

Defined in: src/depth/Depth.ts:527

Parameters​

viewId​

number

Returns​

ExternalTexture | DataTexture | undefined


getVertex()​

getVertex(u, v, viewId): Vector3 | null

Defined in: src/depth/Depth.ts:316

Retrieves the depth at normalized coordinates (u, v). Note: The UV coordinates are with respect to the user's view, not the depth camera view.

Parameters​

u​

number

Normalized horizontal coordinate, origin at the bottom left of the view, growing right.

v​

number

Normalized vertical coordinate, origin at the bottom left of the view, growing up.

viewId​

number = 0

View index to query (default 0). Requesting viewId > 0 enables secondary view updates.

Returns​

Vector3 | null

Vertex at (u, v)


init()​

init(camera, options, renderer, registry, scene): void | Promise<void>

Defined in: src/depth/Depth.ts:119

Initialize Depth manager.

Parameters​

camera​

PerspectiveCamera

options​

DepthOptions

renderer​

SupportedRenderer

registry​

Registry

scene​

Scene

Returns​

void | Promise<void>


pauseDepth()​

pauseDepth(client): void

Defined in: src/depth/Depth.ts:664

Parameters​

client​

object

Returns​

void


renderOcclusionPass()​

renderOcclusionPass(): void

Defined in: src/depth/Depth.ts:621

Returns​

void


resumeDepth()​

resumeDepth(client): void

Defined in: src/depth/Depth.ts:659

Parameters​

client​

object

Returns​

void


setShadowOpacity()​

setShadowOpacity(opacity): void

Defined in: src/depth/Depth.ts:538

Updates the shadow opacity on the depth mesh material when active.

Parameters​

opacity​

number

Returns​

void


update()​

update(frame?): void

Defined in: src/depth/Depth.ts:548

Parameters​

frame?​

XRFrame

Returns​

void


updateCPUDepthData()​

updateCPUDepthData(depthData, viewId, depthDataFormat): void

Defined in: src/depth/Depth.ts:405

Parameters​

depthData​

XRCPUDepthInformation

viewId​

number

depthDataFormat​

XRDepthDataFormat

Returns​

void


updateFullResolutionDepthMesh()​

updateFullResolutionDepthMesh(): void

Defined in: src/depth/Depth.ts:672

Manually updates the depth mesh geometry using the cached depth.

Returns​

void


updateGPUDepthData()​

updateGPUDepthData(depthData, viewId): void

Defined in: src/depth/Depth.ts:442

Parameters​

depthData​

XRWebGLDepthInformation

viewId​

number

Returns​

void


updateLocalDepth()​

updateLocalDepth(frame): void

Defined in: src/depth/Depth.ts:558

Parameters​

frame​

XRFrame

Returns​

void