Home Reference Source
import {OutlineEffect} from 'postprocessing/src/effects/OutlineEffect.js'
public class | source

OutlineEffect

Extends:

Effect → OutlineEffect

Indirect Implements:

An outline effect.

Constructor Summary

Public Constructor
public

constructor(scene: Scene, camera: Camera, options: Object)

Constructs a new outline effect.

Member Summary

Public Members
public get

Indicates whether the outlines should be blurred.

public set
public get

Indicates whether dithering is enabled.

public set

Enables or disables dithering.

public get

The blur kernel size.

public set
public

The pulse speed.

public

A dedicated render layer for selected objects.

public
public get

Indicates whether X-Ray outlines are enabled.

public set

Enables or disables X-Ray outlines.

Private Members
private

A blur pass.

private

A clear flag.

private

A clear pass.

private

A depth pass.

private

mainCamera: Camera

The main camera.

private

mainScene: Scene

The main scene.

private

A depth comparison mask pass.

private

An outline edge detection pass.

private

renderTargetBlurredEdges: WebGLRenderTarget

A render target for the blurred outline overlay.

private

renderTargetDepth: WebGLRenderTarget

A depth render target.

private

renderTargetEdges: WebGLRenderTarget

A render target for the edge detection.

private

renderTargetMask: WebGLRenderTarget

A render target for the outline mask.

private

resolution: Vector2

The original resolution.

private

selection: Object3D[]

A list of objects to outline.

private

The current animation time.

Method Summary

Public Methods
public

clearSelection(): OutlinePass

Clears the list of selected objects.

public

deselectObject(object: Object3D): OutlinePass

Deselects an object.

public

Returns the current resolution scale.

public

initialize(renderer: WebGLRenderer, alpha: Boolean)

Performs initialization tasks.

public

selectObject(object: Object3D): OutlinePass

Selects an object.

public

setPatternTexture(texture: Texture)

Sets the pattern texture.

public

Sets the resolution scale.

public

setSelection(objects: Object3D[]): OutlinePass

Clears the current selection and selects a list of objects.

public

setSize(width: Number, height: Number)

Updates the size of internal render targets.

public

update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, delta: Number)

Updates this effect.

Private Methods
private

Sets the visibility of all selected objects.

Inherited Summary

From class Effect
public

[key]: *

public

The effect attributes.

public

The blend mode of this effect.

public

Preprocessor macro definitions.

public

WebGL extensions that are required by this effect.

public

The fragment shader.

public

The name of this effect.

public

uniforms: Map<String, Uniform>

Shader uniforms.

public

The vertex shader.

public

Performs a shallow search for properties that define a dispose method and deletes them.

public

initialize(renderer: WebGLRenderer, alpha: Boolean)

Performs initialization tasks.

public

setDepthTexture(depthTexture: Texture, depthPacking: Number)

Sets the depth texture.

public

setSize(width: Number, height: Number)

Updates the size of this effect.

public

update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, delta: Number)

Updates the effect by performing supporting operations.

Public Constructors

public constructor(scene: Scene, camera: Camera, options: Object) source

Constructs a new outline effect.

If you want dark outlines, remember to adjust the blend function.

Override:

Effect#constructor

Params:

NameTypeAttributeDescription
scene Scene

The main scene.

camera Camera

The main camera.

options Object
  • optional

The options. See BlurPass and OutlineEdgesMaterial for additional parameters.

options.blendFunction BlendFunction
  • optional
  • default: BlendFunction.SCREEN

The blend function. Set this to BlendFunction.ALPHA for dark outlines.

options.patternTexture Number
  • optional
  • default: null

A pattern texture.

options.edgeStrength Number
  • optional
  • default: 1.0

The edge strength.

options.pulseSpeed Number
  • optional
  • default: 0.0

The pulse speed. A value of zero disables the pulse effect.

options.visibleEdgeColor Number
  • optional
  • default: 0xffffff

The color of visible edges.

options.hiddenEdgeColor Number
  • optional
  • default: 0x22090a

The color of hidden edges.

options.blur Boolean
  • optional
  • default: false

Whether the outline should be blurred.

options.xRay Boolean
  • optional
  • default: true

Whether hidden parts of selected objects should be visible.

Public Members

public get blur: Boolean source

Indicates whether the outlines should be blurred.

public set blur: Boolean source

public get dithering: Boolean source

Indicates whether dithering is enabled.

public set dithering: Boolean source

Enables or disables dithering.

public get kernelSize: KernelSize source

The blur kernel size.

public set kernelSize: KernelSize source

public pulseSpeed: Number source

The pulse speed. A value of zero disables the pulse effect.

public selectionLayer: Number source

A dedicated render layer for selected objects.

This layer is set to 10 by default. If this collides with your own custom layers, please change it to a free layer before rendering!

public vertexShader: * source

The vertex shader.

Override:

Effect#vertexShader

public get xRay: Boolean source

Indicates whether X-Ray outlines are enabled.

public set xRay: Boolean source

Enables or disables X-Ray outlines.

You'll need to call EffectPass#recompile after changing this value.

Private Members

private blurPass: BlurPass source

A blur pass.

private clear: Boolean source

A clear flag.

private clearPass: ClearPass source

A clear pass.

private depthPass: DepthPass source

A depth pass.

private mainCamera: Camera source

The main camera.

private mainScene: Scene source

The main scene.

private maskPass: RenderPass source

A depth comparison mask pass.

private outlineEdgesPass: ShaderPass source

An outline edge detection pass.

private renderTargetBlurredEdges: WebGLRenderTarget source

A render target for the blurred outline overlay.

private renderTargetDepth: WebGLRenderTarget source

A depth render target.

private renderTargetEdges: WebGLRenderTarget source

A render target for the edge detection.

private renderTargetMask: WebGLRenderTarget source

A render target for the outline mask.

private resolution: Vector2 source

The original resolution.

private selection: Object3D[] source

A list of objects to outline.

private time: Number source

The current animation time.

Public Methods

public clearSelection(): OutlinePass source

Clears the list of selected objects.

Return:

OutlinePass

This pass.

public deselectObject(object: Object3D): OutlinePass source

Deselects an object.

Params:

NameTypeAttributeDescription
object Object3D

The object that should no longer be outlined.

Return:

OutlinePass

This pass.

public getResolutionScale(): Number source

Returns the current resolution scale.

Return:

Number

The resolution scale.

public initialize(renderer: WebGLRenderer, alpha: Boolean) source

Performs initialization tasks.

Override:

Effect#initialize

Params:

NameTypeAttributeDescription
renderer WebGLRenderer

The renderer.

alpha Boolean

Whether the renderer uses the alpha channel or not.

public selectObject(object: Object3D): OutlinePass source

Selects an object.

Params:

NameTypeAttributeDescription
object Object3D

The object that should be outlined.

Return:

OutlinePass

This pass.

public setPatternTexture(texture: Texture) source

Sets the pattern texture.

You'll need to call EffectPass#recompile after changing the texture.

Params:

NameTypeAttributeDescription
texture Texture

The new texture.

public setResolutionScale(scale: Number) source

Sets the resolution scale.

Params:

NameTypeAttributeDescription
scale Number

The new resolution scale.

public setSelection(objects: Object3D[]): OutlinePass source

Clears the current selection and selects a list of objects.

Params:

NameTypeAttributeDescription
objects Object3D[]

The objects that should be outlined. This array will be copied.

Return:

OutlinePass

This pass.

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

Updates the size of internal render targets.

Override:

Effect#setSize

Params:

NameTypeAttributeDescription
width Number

The width.

height Number

The height.

public update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, delta: Number) source

Updates this effect.

Override:

Effect#update

Params:

NameTypeAttributeDescription
renderer WebGLRenderer

The renderer.

inputBuffer WebGLRenderTarget

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

delta Number
  • optional

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

Private Methods

private setSelectionVisible(visible: Boolean) source

Sets the visibility of all selected objects.

Params:

NameTypeAttributeDescription
visible Boolean

Whether the selected objects should be visible.