Used internally for material shader defines.
Distance to the camera (range: [0.0, 1.0]
) from which the objects are transparent. A value
of <= 0.0 disables fading.
Distance to the camera (range: [0.0, 1.0]
) from which the objects start fading out.
Informs THREE.js to re-compile material shader (due to change in code or defines).
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.
Material to add uniforms to.
[[THREE.WebGLShader]] containing the vertex and fragment shaders to add the special includes to.
Used internally for material shader defines.
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.
Available in all materials in ThreeJS.
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.
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.
[[THREE.Object3D]] to prepare for rendering.
The visibility ranges (clip planes and maximum visible distance) for actual camera setup.
The fadeNear value to set in the material.
The fadeFar value to set in the material.
If true
, the fading uniforms are set. Not required if material is
handling the uniforms already, like in a [[THREE.ShaderMaterial]].
If defined, this function will be called before the function will return.
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.
FadingFeature.
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.
FadingFeature.
Patch the THREE.ShaderChunk on first call with some extra shader chunks.
Update the internals of the FadingFeature
depending on the value of fadeNear. The
fading feature will be disabled if fadeFar <= 0.0.
FadingFeature
Generated using TypeDoc
Namespace with support functions for implementors of
FadingFeature
.