Home Reference Source
import {DepthPickingPass} from 'postprocessing'
public class | source

DepthPickingPass

Extends:

PassDepthSavePass → DepthPickingPass

Indirect Implements:

A depth picking pass.

Constructor Summary

Public Constructor
public

constructor(options: Object)

Constructs a new depth picking pass.

Member Summary

Public Members
public

Method Summary

Public Methods
public

readDepth(ndc: Vector2 | Vector3): Promise<Number>

Reads depth at a specific screen position.

public

render(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, outputBuffer: WebGLRenderTarget, deltaTime: Number, stencilTest: Boolean)

Copies depth and resolves depth picking promises.

public

setSize(width: Number, height: Number)

Updates the size of this pass.

Inherited Summary

From class Pass
public get

Indicates whether this pass should render to screen.

public set

Sets the render to screen flag.

public
this member was deprecated. Use isEnabled() and setEnabled() instead.

Indicates whether this pass is enabled.

public

The name of this pass.

public

Only relevant for subclassing.

public

Only relevant for subclassing.

protected

camera: Camera

The camera.

protected

scene: Scene

The scene to render.

public

Performs a shallow search for disposable properties and deletes them.

public

getDepthTexture(): Texture

Returns the current depth texture.

public

getFullscreenMaterial(): Material

Returns the current fullscreen material.

public

initialize(renderer: WebGLRenderer, alpha: Boolean, frameBufferType: Number)

Performs initialization tasks.

public

Indicates whether this pass is enabled.

public abstract

render(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, outputBuffer: WebGLRenderTarget, deltaTime: Number, stencilTest: Boolean)

Renders this pass.

public

setDepthTexture(depthTexture: Texture, depthPacking: Number)

Sets the depth texture.

public

setEnabled(enabled: Boolean)

Enables or disables this pass.

public

setSize(width: Number, height: Number)

Updates this pass with the renderer's size.

You may override this method in case you want to be informed about the size of the main frame buffer.

The EffectComposer calls this method before this pass is initialized and every time its own size is updated.

protected

setFullscreenMaterial(material: Material)

Sets the fullscreen material.

From class DepthSavePass
public get

depthPacking: Texture

The output depth packing.

public get

texture: Texture

The output depth texture.

public
public
public

renderTarget: WebGLRenderTarget

The render target.

public

render(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, outputBuffer: WebGLRenderTarget, deltaTime: Number, stencilTest: Boolean)

Copies depth from a depth texture.

public

setDepthTexture(depthTexture: Texture, depthPacking: Number)

Sets the depth texture.

public

setSize(width: Number, height: Number)

Updates the size of this pass.

Public Constructors

public constructor(options: Object) source

Constructs a new depth picking pass.

Override:

DepthSavePass#constructor

Params:

NameTypeAttributeDescription
options Object
  • optional

The options.

options.depthPacking Number
  • optional
  • default: RGBADepthPacking

The depth packing.

options.mode Number
  • optional
  • default: DepthCopyMode.SINGLE

The depth copy mode.

Public Members

public name: string source

The name of this pass.

Override:

Pass#name

Public Methods

public readDepth(ndc: Vector2 | Vector3): Promise<Number> source

Reads depth at a specific screen position.

Only one depth value can be picked per frame. Calling this method multiple times per frame will overwrite the picking coordinates. Unresolved promises will be abandoned.

Params:

NameTypeAttributeDescription
ndc Vector2 | Vector3

Normalized device coordinates. Only X and Y are relevant.

Return:

Promise<Number>

A promise that returns the depth on the next frame.

Example:

const ndc = new Vector3();

ndc.x = (pointerEvent.clientX / window.innerWidth) * 2.0 - 1.0;
ndc.y = -(pointerEvent.clientY / window.innerHeight) * 2.0 + 1.0;

const depth = await depthPickingPass.readDepth(ndc);
ndc.z = depth * 2.0 - 1.0;

const worldPosition = ndc.unproject(camera);

public render(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, outputBuffer: WebGLRenderTarget, deltaTime: Number, stencilTest: Boolean) source

Copies depth and resolves depth picking promises.

Override:

DepthSavePass#render

Params:

NameTypeAttributeDescription
renderer WebGLRenderer

The renderer.

inputBuffer WebGLRenderTarget

A frame buffer that contains the result of the previous pass.

outputBuffer WebGLRenderTarget

A frame buffer that serves as the output render target unless this pass renders to screen.

deltaTime Number
  • optional

The time between the last frame and the current one in seconds.

stencilTest Boolean
  • optional

Indicates whether a stencil mask is active.

public setSize(width: Number, height: Number) source

Updates the size of this pass.

Override:

DepthSavePass#setSize

Params:

NameTypeAttributeDescription
width Number

The width.

height Number

The height.