Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace FadingFeature

Namespace with support functions for implementors of FadingFeature.

Hierarchy

Implemented by

Index

Properties

Optional defines

defines: any

Used internally for material shader defines.

Optional fadeFar

fadeFar: undefined | number

Distance to the camera (range: [0.0, 1.0]) from which the objects are transparent. A value of <= 0.0 disables fading.

Optional fadeNear

fadeNear: undefined | number

Distance to the camera (range: [0.0, 1.0]) from which the objects start fading out.

Optional needsUpdate

needsUpdate: undefined | false | true

Informs THREE.js to re-compile material shader (due to change in code or defines).

Optional onBeforeCompile

  • onBeforeCompile(fadingMaterial: FadingFeature, shader: Shader): void
  • This function should be called on implementors of FadingFeature in the onBeforeCompile callback of that material. It adds the required code to the shaders and declares the new uniforms that control fading based on view distance.

    Called before shader program compilation to generate vertex & fragment shader output code.

    Parameters

    • fadingMaterial: FadingFeature

      Material to add uniforms to.

    • shader: Shader

      [[THREE.WebGLShader]] containing the vertex and fragment shaders to add the special includes to.

    Returns void

Optional shaderDefines

shaderDefines: any

Used internally for material shader defines.

Optional shaderUniforms

shaderUniforms: UniformsType

Used internally for shader uniforms, holds references to material internal shader.uniforms.

Holds a reference to material's internal shader uniforms map. New custom feature based uniforms are injected using this reference, but also internal THREE.js shader uniforms will be available via this map after [[Material#onBeforeCompile]] callback is run with feature enabled.

see

needsUpdate

Optional transparent

transparent: undefined | false | true

Available in all materials in ThreeJS.

Optional uniformsNeedUpdate

uniformsNeedUpdate: undefined | false | true

Hidden ThreeJS value that is made public here. Required to add new uniforms to subclasses of [[THREE.MeshBasicMaterial]]/[[THREE.MeshStandardMaterial]], basically all materials that are not THREE.ShaderMaterial.

deprecated

Changes to this property are ignored.

Variables

Const DEFAULT_FADE_FAR

DEFAULT_FADE_FAR: number = -1.0

Const DEFAULT_FADE_NEAR

DEFAULT_FADE_NEAR: number = -1.0

Functions

addRenderHelper

  • addRenderHelper(object: Object3D, viewRanges: ViewRanges, fadeNear: number | undefined, fadeFar: number | undefined, updateUniforms: boolean, additionalCallback?: undefined | ((renderer: WebGLRenderer, material: Material & FadingFeature) => void)): void
  • As three.js is rendering the transparent objects last (internally), regardless of their renderOrder value, we set the transparent value to false in the [[onAfterRenderCall]]. In onBeforeRender, the function [[calculateDepthFromCameraDistance]] sets it to true if the fade distance value is less than 1.

    Parameters

    • object: Object3D

      [[THREE.Object3D]] to prepare for rendering.

    • viewRanges: ViewRanges

      The visibility ranges (clip planes and maximum visible distance) for actual camera setup.

    • fadeNear: number | undefined

      The fadeNear value to set in the material.

    • fadeFar: number | undefined

      The fadeFar value to set in the material.

    • updateUniforms: boolean

      If true, the fading uniforms are set. Not required if material is handling the uniforms already, like in a [[THREE.ShaderMaterial]].

    • Optional additionalCallback: undefined | ((renderer: WebGLRenderer, material: Material & FadingFeature) => void)

      If defined, this function will be called before the function will return.

    Returns void

isDefined

  • Checks if feature is defined based on feature params.

    Fading feature will be defined if fadeNear and fadeFar are defined, their values are not checked for reasonable values.

    Parameters

    Returns boolean

isEnabled

  • Checks if feature is enabled based on feature params.

    Fading feature will be disabled if fadeFar is undefined or fadeFar <= 0.0. This function is crucial for shader switching (chunks injection), whenever feature state changes between enabled/disabled. Current approach is to keep feature on (once enabled) whenever fading params are reasonable, even if it causes full fade in, no transparency.

    Parameters

    Returns boolean

patchGlobalShaderChunks

  • patchGlobalShaderChunks(): void

updateFadingFeature

Generated using TypeDoc