ACES Filmic tone mapping.
A source + destination blending equation.
Adds the two colors.
Additive animation blend mode. Can be used to layer motions on top of each other to build complex performances from smaller re-usable assets.
Represents additive blending.
AgX tone mapping.
Discards the red, green and blue components and reads just the alpha component.
Always pass.
Always pass.
Will always return true.
Anaglyph algorithm types.
TRUE
string
GREY
string
COLOUR
string
HALF_COLOUR
string
DUBOIS
string
OPTIMISED
string
COMPROMISE
string
Anaglyph color modes.
RED_CYAN
string
MAGENTA_CYAN
string
MAGENTA_GREEN
string
The skinned mesh shares the same world space as the skeleton.
Only back faces are rendered.
The depth value is inverted (1.0 - z) for visualization purposes.
Gives unfiltered shadow maps - fastest, but lowest quality.
A byte data type for textures.
Cineon tone mapping.
The last pixel of the texture stretches to the edge of the mesh.
Compatibility flags for features that may not be supported across all platforms.
Multiplies all colors by a constant alpha value.
Multiplies all colors by a constant color.
Reflection mapping for cube textures.
Refraction mapping for cube textures.
Reflection mapping for PMREM textures.
Culls back faces.
Culls front faces.
Culls both front and back faces.
Disables face culling.
Represents custom blending.
Custom tone mapping.
Expects a custom implementation by modifying shader code of the material's fragment shader.
Precomputed DFG LUT for Image-Based Lighting Resolution: 16x16 Samples: 4096 per texel Format: RG16F (2 half floats per texel: scale, bias)
Decrements the current stencil buffer value. Clamps to 0.
Decrements the current stencil buffer value. Wraps stencil buffer value to the maximum representable unsigned value when decrementing a stencil buffer value of 0.
The global default loading manager.
Reads each element as a single depth value, converts it to floating point, and clamps to the range [0,1].
Reads each element is a pair of depth and stencil values. The depth component of the pair is interpreted as in DepthFormat. The stencil component is interpreted based on the depth + stencil internal format.
The skinned mesh does not share the same world space as the skeleton. This is useful when a skeleton is shared across multiple skinned meshes.
Both front and back faces are rendered.
Multiplies all colors by the destination alpha value.
Multiplies all colors by the destination color.
The contents are intended to be respecified repeatedly by reading data from the 3D API, and used many times as the source for WebGL drawing and image specification commands.
The contents are intended to be respecified repeatedly by the application, and used many times as the source for drawing and image specification commands.
The contents are intended to be respecified repeatedly by reading data from the 3D API, and queried many times by the application.
Sentinel ray length the SSR pass writes for environment misses (no screen-space hit), set far above any real hit distance so a single magnitude test separates misses from hits and survives .max( 0 ).
Classification threshold for ENV_RAY_LENGTH: above this is an env miss, below a real hit. An order of magnitude under the sentinel, robust to fp16 storage and bilinear blending at borders.
Pass if the incoming value equals the texture value.
Pass if the incoming value equals the depth buffer value.
Will return true if the stencil reference value is equal to the current stencil value.
Reflection mapping for equirectangular textures.
Refraction mapping for equirectangular textures.
Fresnel reflectance for the Schlick approximation.
A float data type for textures.
Only front faces are rendered.
GLSL 1 shader code.
GLSL 3 shader code.
Pass if the incoming value is greater than the texture value.
Pass if the incoming value is greater than the depth buffer value.
Pass if the incoming value is greater than or equal to the texture value.
Pass if the incoming value is greater than or equal to the depth buffer value.
Will return true if the stencil reference value is greater than or equal to the current stencil value.
Will return true if the stencil reference value is greater than the current stencil value.
A half float data type for textures.
Increments the current stencil buffer value. Clamps to the maximum representable unsigned value.
Increments the current stencil buffer value. Wraps stencil buffer value to zero when incrementing the maximum representable unsigned value.
An int data type for textures.
Bezier interpolation mode for keyframe tracks.
Uses cubic Bezier curves with explicit 2D control points. Requires tangent data to be set on the track.
Discrete interpolation mode for keyframe tracks.
Linear interpolation mode for keyframe tracks.
Smooth interpolation mode for keyframe tracks.
Represents the different interpolation sampling modes.
Represents mouse buttons and interaction types in context of controls.
Inverts the current stencil buffer value bitwise.
The KHR_mesh_quantization extension allows these extra attribute component types
See:
Keeps the current value.
Pass if the incoming value is less than the texture value.
Pass if the incoming value is less than the depth buffer value.
Pass if the incoming value is less than or equal to the texture value.
Pass if the incoming value is less than or equal to the depth buffer value.
Will return true if the stencil reference value is less than or equal to the current stencil value.
Will return true if the stencil reference value is less than the current stencil value.
Returns the weighted average of the four texture elements that are closest to the specified texture coordinates, and can include items wrapped or repeated from other parts of a texture, depending on the values of wrapS and wrapT, and on the exact mapping.
Chooses the two mipmaps that most closely match the size of the pixel being textured and uses the LinearFilter criterion to produce a texture value from each mipmap. The final texture value is a weighted average of those two values.
Chooses the mipmap that most closely matches the size of the pixel being textured and uses the LinearFilter criterion (a weighted average of the four texels that are closest to the center of the pixel) to produce a texture value.
sRGB-linear color space.
Linear tone mapping.
Linear transfer function.
Animations are played once.
Animations are played with a chosen number of repetitions, alternately playing forward and backward.
Animations are played with a chosen number of repetitions, each time jumping from the end of the clip directly to its beginning.
Represents mouse buttons and interaction types in context of controls.
Represents material blending.
A blend equation that uses the maximum of source and destination.
A blend equation that uses the minimum of source and destination.
The texture will repeats to infinity, mirroring on each repeat.
Uses reflectivity to blend between the two colors.
Represents multiply blending.
Multiplies the environment map color with the surface color.
Returns the value of the texture element that is nearest (in Manhattan distance) to the specified texture coordinates.
Chooses the two mipmaps that most closely match the size of the pixel being textured and uses the NearestFilter criterion to produce a texture value from each mipmap. The final texture value is a weighted average of those two values.
Chooses the mipmap that most closely matches the size of the pixel being textured and uses the NearestFilter criterion (the texel nearest to the center of the pixel) to produce a texture value.
Neutral tone mapping.
Implementation based on the Khronos 3D Commerce Group standard tone mapping.
Never pass.
Never pass.
Will never return true.
No blending is performed which effectively disables alpha transparency.
No color space.
No normal map packing.
No tone mapping is applied.
Access types of a node. These are relevant for compute and storage usage.
READ_ONLY
string
Read-only access
WRITE_ONLY
string
Write-only access.
READ_WRITE
string
Read and write access.
Possible shader stages.
VERTEX
string
The vertex shader stage.
FRAGMENT
string
The fragment shader stage.
Data types of a node.
BOOLEAN
string
Boolean type.
INTEGER
string
Integer type.
FLOAT
string
Float type.
VECTOR2
string
Two-dimensional vector type.
VECTOR3
string
Three-dimensional vector type.
VECTOR4
string
Four-dimensional vector type.
MATRIX2
string
2x2 matrix type.
MATRIX3
string
3x3 matrix type.
MATRIX4
string
4x4 matrix type.
Update types of a node.
NONE
string
The update method is not executed.
FRAME
string
The update method is executed per frame.
RENDER
string
The update method is executed per render. A frame might be produced by multiple render calls so this value allows more detailed updates than FRAME.
OBJECT
string
The update method is executed per Object3D that uses the node for rendering.
Default animation blend mode.
The default blending.
Normal GA packing.
Normal RG packing.
Pass if the incoming value is not equal to the texture value.
Pass if the incoming value is not equal to the depth buffer value.
Will return true if the stencil reference value is not equal to the current stencil value.
Normal information is relative to the object orientation.
Creates an event that triggers a function before every frame.
The event will be bound to the declared TSL function Fn(); it must be declared within a Fn() or the JS function call must be inherited from one.
Creates an event that triggers a function before the material is updated.
The event will be bound to the declared TSL function Fn(); it must be declared within a Fn() or the JS function call must be inherited from one.
Creates an event that triggers a function before an object (Mesh|Sprite) is updated.
The event will be bound to the declared TSL function Fn(); it must be declared within a Fn() or the JS function call must be inherited from one.
Creates an event that triggers a function every frame.
The event will be bound to the declared TSL function Fn(); it must be declared within a Fn() or the JS function call must be inherited from one.
Creates an event that triggers a function when the first object that uses the material is rendered.
The event will be bound to the declared TSL function Fn(); it must be declared within a Fn() or the JS function call must be inherited from one.
Creates an event that triggers a function every time an object (Mesh|Sprite) is rendered.
The event will be bound to the declared TSL function Fn(); it must be declared within a Fn() or the JS function call must be inherited from one.
Multiplies all colors by 1.
Multiplies all colors by 1 minus a constant alpha value.
Multiplies all colors by 1 minus a constant color.
Multiplies all colors by 1 minus the destination alpha value.
Multiplies all colors by 1 minus each destination color.
Multiplies all colors by 1 minus the source alpha value.
Multiplies all colors by 1 minus each source color.
Filters shadow maps using the Percentage-Closer Filtering (PCF) algorithm.
Filters shadow maps using the Percentage-Closer Filtering (PCF) algorithm with better soft shadows especially when using low-resolution shadow maps.
EAC R11 UNORM format.
RGTC2 Red Green format.
RGTC1 Red format.
EAC RG11 UNORM format.
The depth value is packed into 32 bit RGBA.
Reads the red, green, blue and alpha components.
Reads the red, green, blue and alpha components. The texels are read as integers instead of floating point.
ASTC RGBA 10x10 format.
ASTC RGBA 10x5 format.
ASTC RGBA 10x6 format.
ASTC RGBA 10x8 format.
ASTC RGBA 12x10 format.
ASTC RGBA 12x12 format.
ASTC RGBA 4x4 format.
ASTC RGBA 5x4 format.
ASTC RGBA 5x5 format.
ASTC RGBA 6x5 format.
ASTC RGBA 6x6 format.
ASTC RGBA 8x5 format.
ASTC RGBA 8x6 format.
ASTC RGBA 8x8 format.
BPTC RGBA format.
ETC2 RGBA format.
PVRTC RGBA compression in 2-bit mode. One block for each 8×4 pixels.
PVRTC RGBA compression in 4-bit mode. One block for each 4×4 pixels.
A DXT1-compressed image in an RGB image format with a simple on/off alpha value.
A DXT3-compressed image in an RGBA image format. Compared to a 32-bit RGBA texture, it offers 4:1 compression.
A DXT5-compressed image in an RGBA image format. It also provides a 4:1 compression, but differs to the DXT3 compression in how the alpha compression is done.
The depth value is packed into 24 bit RGB.
Discards the alpha component and reads the red, green and blue component.
Discards the alpha component and reads the red, green and blue component. The texels are read as integers instead of floating point.
BPTC Signed RGB format.
BPTC Unsigned RGB format.
ETC1 RGB format.
ETC2 RGB format.
PVRTC RGB compression in 2-bit mode. One block for each 8×4 pixels.
PVRTC RGB compression in 4-bit mode. One block for each 4×4 pixels.
A DXT1-compressed image in an RGB image format.
The depth value is packed into 16 bit RG.
Discards the alpha, and blue components and reads the red, and green components.
Discards the alpha, and blue components and reads the red, and green components. The texels are read as integers instead of floating point.
Discards the green, blue and alpha components and reads just the red component.
Discards the green, blue and alpha components and reads just the red component. The texels are read as integers instead of floating point.
Reinhard tone mapping.
The texture will simply repeat to infinity.
Sets the stencil buffer value to the specified reference value.
A destination - source blending equation.
EAC R11 SNORM format.
RGTC2 Signed Red Green format.
RGTC1 Signed Red format.
EAC RG11 SNORM format.
sRGB color space.
sRGB transfer function.
UltraHDR Image Format - https://developer.android.com/media/platform/hdr-image-format
Short format brief:
[JPEG headers] [Metadata describing the MPF container and both SDR and gainmap images]
Each section is separated by a 0xFFXX byte followed by a descriptor byte (0xFFE0, 0xFFE1, 0xFFE2.) Binary image storages are prefixed with a unique 0xFFD8 16-bit descriptor.
A short data type for textures.
Multiplies all colors by the source alpha value.
Multiplies the RGB colors by the smaller of either the source alpha value or the value of 1 minus the destination alpha value. The alpha value is multiplied by 1.
Multiplies all colors by the source colors.
The contents are intended to be specified once by reading data from the 3D API, and used many times as the source for WebGL drawing and image specification commands.
The contents are intended to be specified once by the application, and used many times as the source for drawing and image specification commands.
The contents are intended to be specified once by reading data from the 3D API, and queried many times by the application.
The contents are intended to be specified once by reading data from the 3D API, and used at most a few times as the source for WebGL drawing and image specification commands.
The contents are intended to be specified once by the application, and used at most a few times as the source for drawing and image specification commands.
The contents are intended to be specified once by reading data from the 3D API, and queried at most a few times by the application
A source - destination blending equation.
Represents subtractive blending.
Represents touch interaction types in context of controls.
Normal information is relative to the underlying surface.
Represents the different timestamp query types.
For each vertex draw a triangle from the first vertex and the last two vertices.
For each vertex draw a triangle from the last three vertices.
For every three vertices draw a single triangle.
Maps textures using the geometry's UV coordinates.
An unsigned byte data type for textures.
An unsigned int 10_11_11 (packed) data type for textures.
An unsigned int 24_8 data type for textures.
An unsigned int 5_9_9_9 (packed) data type for textures.
An unsigned int data type for textures.
An unsigned short 4_4_4_4 (packed) data type for textures.
An unsigned short 5_5_5_1 (packed) data type for textures.
An unsigned short data type for textures.
References:
Filters shadow maps using the Variance Shadow Map (VSM) algorithm. When using VSMShadowMap all shadow receivers will also cast shadows.
WebGL coordinate system.
WebGPU coordinate system.
Wrap around ending for animations.
Zero curvature ending for animations.
Multiplies all colors by 0.
Zero slope ending for animations.
Sets the stencil buffer value to 0.
TSL object representing a varying property for the batching color vector.
The NYC masonry palette every tower is dressed from ( hex colours ): limestone-dominant with terracotta accents. Shared by the single-tower example and CityGenerator's building material so both stay in sync.
Calculates the closest points on two 3D lines. Used for perspective-correct line rendering and coordinates interpolation.
Performs a depth-aware blend between a base scene and a secondary effect (like godrays). This function uses a Poisson disk sampling pattern to detect depth discontinuities in the neighborhood of the current pixel. If an edge is detected, it shifts the sampling coordinate for the blend node away from the edge to prevent light leaking/haloing.
Disposes the shadow material for the given light source.
Equirectangular direction / UV / PDF helpers and MIS weighting shared by environment sampling code. Env-miss MIS integration lives in ImportanceSampledEnvironment.
Equirectangular parameterization helpers used with CDF importance sampling are adapted from three-gpu-pathtracer.
See:
TSL function that retrieves the batching color for a given instance ID from a colors texture.
TSL function that retrieves the indirect index for a given batch ID.
TSL function that retrieves and scales the morphed attribute (position or normal) texel value.
Specular dominant factor for parallax-corrected ray length. From REBLUR: A Hierarchical Recurrent Denoiser (NRD).
Importance-samples the GGX/VNDF specular lobe for one pixel and returns the reflected ray direction plus the Monte-Carlo weight to apply to the gathered radiance, along with the GGX terms the SSR env-miss MIS fallback needs.
Everything a single GGX reflection sample produces. reflectDir and sampleWeight drive the SSR ray-march and compositing; pdf, NdotV, alpha and f0 are the GGX terms the env-miss MIS fallback needs so the caller never re-derives microfacet math.
TSL object representing a varying property for the instanced color vector.
Varying node representing the accumulated distance along the line. Crucial for correctly computing dashed line intervals in fragment stage.
A node representing the outgoing light.
A node representing the total diffuse light.
A node representing the total specular light.
Trims the line segment to avoid rendering behind the camera near plane. Computes an interpolation factor (alpha) to clamp the segment's coordinate.
Deprecated: since r169. Use screenSize instead.
Varying node representing the world position of the segment end in view space. Used for distance and coordinate calculations across the fragment shader.
Varying node representing the interpolated world/view position of the current fragment. Used for line/ray distance checks under perspective projection.
Varying node representing the world position of the segment start in view space. Used for distance and coordinate calculations across the fragment shader.
A shadow filtering function performing basic filtering. This is in fact an unfiltered version of the shadow map with a binary [0,1] result.
inputs
The input parameter object.
depthTexture
A reference to the shadow map's texture data.
shadowCoord
The shadow coordinates.
Returns: The filtering result.
A shadow filtering function performing PCF filtering with Vogel disk sampling and IGN.
Uses 5 samples distributed via Vogel disk pattern, rotated per-pixel using Interleaved Gradient Noise (IGN) to break up banding artifacts. Combined with hardware PCF (4-tap filtering per sample), this effectively provides 20 filtered taps with better distribution.
inputs
The input parameter object.
depthTexture
A reference to the shadow map's texture data.
shadowCoord
The shadow coordinates.
shadow
The light shadow.
Returns: The filtering result.
A shadow filtering function performing PCF soft filtering.
inputs
The input parameter object.
depthTexture
A reference to the shadow map's texture data.
shadowCoord
The shadow coordinates.
shadow
The light shadow.
Returns: The filtering result.
A shadow filtering function for point lights using Vogel disk sampling and IGN.
Uses 5 samples distributed via Vogel disk pattern in tangent space around the sample direction, rotated per-pixel using Interleaved Gradient Noise (IGN).
inputs
The input parameter object.
depthTexture
A reference to the shadow cube map.
bd3D
The normalized direction from light to fragment.
dp
The depth value to compare against.
shadow
The light shadow.
Returns: The filtering result.
Add the given node to the current stack.
node
The node to add.
Returns: The node that was added to the stack.
A shadow filtering function performing VSM filtering.
inputs
The input parameter object.
depthTexture
A reference to the shadow map's texture data.
shadowCoord
The shadow coordinates.
Returns: The filtering result.
The base storey: a wall pierced by tall pointed-arch openings, extruded with thickness so the openings read as deep recesses.
A two-step projecting cornice / string-course band wrapping a face.
A low parapet wall capping the crown.
Horizontal terracotta bands at every floor line. Together with the projecting piers they form the facade grid; the gaps between them are the window openings, with glass set behind.
Bakes a list of instance groups into one non-indexed BufferGeometry. Each group is a base geometry ( position + normal + uv ), an array of Matrix4 placements and a partId written to a per-vertex attribute. Transforming straight into preallocated typed arrays avoids mergeGeometries' per-instance allocations; the result is one geometry, ready for a single draw call and the compute rasterizer.
ctx
Shared sampleBilinearTap inputs plus reprojICoord.
tapOffset
bilinearWeight
Returns a TSL function that samples texture-free analytic R² noise. Index 0 uses continuous screen pixels; other indices tile-shift with an R² sequence into a 64×64 period. Values are four independent R² dimensions hashed from the sample coordinates.
resolution
seed
Added to the coordinate hash so each pass gets an independent R² phase.
Default is 0.
Current and previous-frame camera matrices for temporal reprojection passes.
camera
Builds a 3D texture from a VOX chunk.
chunk
A VOX chunk loaded via VOXLoader.
Returns: The generated 3D texture.
Builds a face frame per footprint edge. Each frame is an orthonormal basis ( u along the edge, v up, n outward ) plus an origin and length, so all facade layout can happen in flat ( u, v ) space and bake to world with one matrix — the same authored piece then instances onto every face, including the diagonal chamfer.
A rectangle (centred at the origin in the XZ plane) with one corner cut at 45 degrees, returned as an ordered list of Vector2( x, z ). cornerX / cornerZ ( each ±1 ) pick which corner is cut, so the chamfer can be aimed outward to a block corner.
Builds a mesh from a VOX chunk.
chunk
A VOX chunk loaded via VOXLoader.
Returns: The generated mesh.
Returns the smallest power of two that is greater than or equal to the given number.
value
The value to find a POT for. Must be greater than 0.
Returns: The smallest power of two that is greater than or equal to the given number.
Clamps the given value between min and max.
value
The value to clamp.
min
The min value.
max
The max value.
Returns: The clamped value.
Scales the texture as large as possible within its surface without cropping or stretching the texture. The method preserves the original aspect ratio of the texture. Akin to CSS object-fit: contain
texture
The texture.
aspect
The texture's aspect ratio.
Returns: The updated texture.
Converts an array to a specific type.
array
The array to convert.
type
The constructor of a typed array that defines the new type.
Returns: The converted array.
Scales the texture to the smallest possible size to fill the surface, leaving no empty space. The method preserves the original aspect ratio of the texture. Akin to CSS object-fit: cover.
texture
The texture.
aspect
The texture's aspect ratio.
Returns: The updated texture.
The shared material every tower in a CityGenerator is dressed with: one flat masonry colour per lot, picked from a palette by hashing the lot's grid cell.
Creates a canvas element configured for block display.
This is a convenience function that creates a canvas element with display style set to 'block', which is commonly used in three.js rendering contexts to avoid inline element spacing issues.
Returns: A canvas element with display set to 'block'.
Helper to create an EventNode and add it to the stack.
type
The event type.
callback
The callback function.
The single material shared by every tree in a ForestGenerator. A plain MeshStandardNodeMaterial lit by the scene — only the surface is authored: deep shadowed green in the recesses rising to a bright, yellow-green sunlit crown, mottled into needle clumps by 3D noise, with a matching bump so the clumps catch the light. Half a million instanced blobs makes this mesh vertex-bound, so the regional colour drift is baked to a per-instance attribute ( no shader noise for it ), and the costly clump noise + bump are gated by distance — full detail on the near trees ( where it reads ), skipped on the far canopy ( where it is sub-pixel ).
from
distance within which every tree is drawn.
to
distance past which no tree is drawn.
Creates the appropriate node for instanced matrix transformations. Depending on buffer limits and storage capability, returns either a storage, buffer, or instanced interleaved attribute node.
builder
The current node builder.
instanceMatrix
The matrix buffer attribute.
count
The instance count.
Returns: The matrix node.
The road surface: wet asphalt with lane lines and crosswalks aligned to a CityGenerator layout. Apply it to a ground plane sized to the city.
The facade material: a single MeshStandardNodeMaterial that reads the baked per-vertex partId and reproduces every zone — procedural terracotta brickwork on the walls and piers, smooth dressed stone on the window frames and ornament, dark glazing, and grey AC units — all dressed with world-space weathering. One material covers the whole building ( and a whole city ), which is what makes it compute-rasterizer friendly. buildingBase is the tower's flat masonry colour as a TSL node: pass a uniform( Color ) for a single tower, or a per-fragment palette pick for a city, so the same material dresses both.
A simple bark material for a TreeGenerator mesh: a low-saturation brown with a faint, vertically-stretched grain, so trunks read near-black against bright fog.
parameters
barkColor ( a hex, THREE.Color or TSL node ).
Smoothly interpolate a number from x to y in a spring-like manner using a delta time to maintain frame rate independent movement. For details, see Frame rate independent damping using lerp.
x
The current point.
y
The target point.
lambda
A higher lambda value will make the movement more sudden, and a lower value will make the movement more gradual.
dt
Delta time in seconds.
Returns: The interpolated value.
Inverse-luminance compression for HDR variance clipping (Karis-style). Bright samples contribute less to neighbourhood moments so sun pixels do not inflate the YCoCg AABB and cause aggressive clipping flicker.
rgb
flickerSuppression
Converts degrees to radians.
degrees
A value in degrees.
Returns: The converted value in radians.
Denormalizes the given value according to the given typed array.
value
The value to denormalize.
array
The typed array that defines the data type of the value.
Returns: The denormalize (float) value in the range [0,1].
Enhances log/warn/error messages related to TSL.
params
The original message parameters.
Returns: The filtered and enhanced message parameters.
Logs an error message with the 'THREE.' prefix.
If a custom console function is set via setConsoleFunction(), it will be used instead of the native console.error. The first parameter is treated as the method name and is automatically prefixed with 'THREE.'.
params
The message components. The first param is used as the method name and prefixed with 'THREE.'.
Computes the Euclidean modulo of the given parameters that is ( ( n % m ) + m ) % m.
n
The first parameter.
m
The second parameter.
Returns: The Euclidean modulo.
Configures the texture to the default transformation. Akin to CSS object-fit: fill.
texture
The texture.
Returns: The updated texture.
Used for parsing AOS keyframe formats.
jsonKeys
A list of JSON keyframes.
times
This array will be filled with keyframe times by this function.
values
This array will be filled with keyframe values by this function.
valuePropertyName
The name of the property to use.
Returns the largest power of two that is less than or equal to the given number.
value
The value to find a POT for. Must be greater than 0.
Returns: The largest power of two that is less than or equal to the given number.
Returns a single precision floating point value (FP32) from the given half precision floating point value (FP16).
val
A half precision floating point value.
Returns: The FP32 value.
Computes an array of magic square values required to generate the noise texture.
size
The noise size.
Returns: The magic square values.
Generates the AO's noise texture for the given size.
size
The noise size.
Default is 5.
Returns: The generated noise texture.
Generate a UUID (universally unique identifier).
Returns: The UUID.
Determines how many bytes must be used to represent the texture.
width
The width of the texture.
height
The height of the texture.
format
The texture's format.
type
The texture's type.
Returns: The byte length.
Computes a cache key for the given render context. This key should identify the render target state so it is possible to configure the correct attachments in the respective backend.
renderContext
The render context.
Returns: The cache key.
Gets the currently set custom console function.
Returns: The custom console function, or null if not set.
Represents a discard shader operation in TSL.
inputs
The input parameter object.
lightDistance
The distance of the light's position to the current fragment position.
cutoffDistance
The light's cutoff distance.
decayExponent
The light's decay exponent.
Returns: The distance falloff.
Utility functions for parsing
Resolves or creates a compiled DataArrayTexture containing encoded vertex morph targets data for WebGL2/WebGPU.
geometry
The geometry to parse.
Returns: The resolved morph targets texture data mapping entry.
Parses the stack trace and filters out ignored files. Returns an array with function name, file, line, and column.
This function is usually called with the length in bytes of an array buffer. It returns an padded value which ensure chunk size alignment according to STD140 layout.
floatLength
The buffer length.
Returns: The padded length.
Returns the GPU format for the given texture.
texture
The texture.
device
The GPU device which is used for feature detection.
Returns: The GPU format.
Returns an array by which times and values can be sorted.
times
The keyframe time values.
Returns: The array.
Generates a layout for struct members. This function takes an object representing struct members and returns an array of member layouts. Each member layout includes the member's name, type, and whether it is atomic.
members
An object where keys are member names and values are either types (as strings) or objects with type and atomic properties.
Returns: An array of member layouts.
Retrieves or initializes the previous frame instance matrix node for motion vectors. Uses a WeakMap to cache previous frame instance matrices and their TSL nodes.
instancedMesh
The instanced mesh object.
instanceMatrix
The current matrix buffer attribute.
builder
The current node builder.
count
The instance count.
Returns: The previous frame instance matrix node.
Retrieves or initializes the previous frame skinned position node for motion vectors. Uses a WeakMap to cache previous frame bone matrix arrays and their TSL buffer nodes.
skinnedMesh
The skinned mesh.
bindMatrixNode
The bind matrix node.
bindMatrixInverseNode
The inverse bind matrix node.
skinIndexNode
The skin index attribute.
skinWeightNode
The skin weight attribute.
Returns: The skinned position from the previous frame.
Computes the skinned normal and tangent vectors by applying bone matrices based on weights.
boneMatrices
The bone matrices buffer or storage node.
normal
The normal vector in local space.
tangent
The tangent vector in local space.
bindMatrix
The bind matrix node.
bindMatrixInverse
The inverse bind matrix node.
skinIndex
The skin index attribute.
skinWeight
The skin weight attribute.
Returns: The skinned normal and tangent.
Computes the skinned position by applying bone matrices based on weights.
boneMatrices
The bone matrices buffer or storage node.
position
The vertex position to transform.
bindMatrix
The bind matrix node.
bindMatrixInverse
The inverse bind matrix node.
skinIndex
The skin index attribute.
skinWeight
The skin weight attribute.
Returns: The skinned position.
This function is called with a vector length and ensure the computed length matches a predefined stride (in this case 4).
vectorLength
The vector length.
Returns: The padded length.
Returns the MRT texture index for the given name.
textures
The textures of a MRT-configured render target.
name
The name of the MRT texture which index is requested.
Returns: The texture index.
Create a new set of uniforms for describing the curve modifier.
splineTexture
Which holds the curve description.
Returns: The uniforms object to be used in the shader.
Given the count of vectors and their vector length, this function computes a total length in bytes with buffer alignment according to STD140 layout.
count
The number of vectors.
vectorLength
The vector length.
Default is 4.
Returns: The padded length.
Returns a node that represents the z coordinate in view space for the current fragment. It's a different representation of the default depth value.
This value can be part of a computation that defines how the fog density increases when moving away from the camera.
builder
The current node builder.
Returns: The viewZ node.
Returns the percentage in the closed interval [0, 1] of the given value between the start and end point.
x
The start point
y
The end point.
value
A value between start and end.
Returns: The interpolation factor.
Returns true if the given number is a power of two.
value
The value to check.
Returns: Whether the given number is a power of two or not.
Returns true if the given object is a typed array.
array
The object to check.
Returns: Whether the given object is a typed array.
Returns a value linearly interpolated from two known points based on the given interval - t = 0 will return x and t = 1 will return y.
x
The start point
y
The end point.
t
The interpolation factor in the closed interval [0, 1].
Returns: The interpolated value.
Logs an informational message with the 'THREE.' prefix.
If a custom console function is set via setConsoleFunction(), it will be used instead of the native console.log. The first parameter is treated as the method name and is automatically prefixed with 'THREE.'.
params
The message components. The first param is used as the method name and prefixed with 'THREE.'.
Converts the keyframes of the given animation clip to an additive format.
targetClip
The clip to make additive.
referenceFrame
The reference frame.
Default is 0.
referenceClip
The reference clip.
Default is targetClip.
fps
The FPS.
Default is 30.
Returns: The updated clip which is now additive.
Performs a linear mapping from range <a1, a2> to range <b1, b2> for the given value. a2 must be greater than a1.
x
The value to be mapped.
a1
Minimum value for range A.
a2
Maximum value for range A.
b1
Minimum value for range B.
b2
Maximum value for range B.
Returns: The mapped value.
Normalizes the given value according to the given typed array.
value
The float value in the range [0,1] to normalize.
array
The typed array that defines the data type of the value.
Returns: The normalize value.
Picks one buildingPalette colour ( a hex number ) for a tower from its seed.
Returns a value that alternates between 0 and the given length parameter.
x
The value to pingpong.
length
The positive value the function will pingpong to.
Default is 1.
Returns: The alternated value.
Converts radians to degrees.
radians
A value in radians.
Returns: The converted value in degrees.
Returns a random float from <low, high> interval.
low
The lower value boundary.
high
The upper value boundary
Returns: A random float.
Returns a random integer from <-range/2, range/2> interval.
range
Defines the value range.
Returns: A random float.
Returns a random integer from <low, high> interval.
low
The lower value boundary.
high
The upper value boundary
Returns: A random integer.
c
Helper function to create a SampleNode wrapped as a node object.
callback
The function to be called when sampling. Should accept a UV node and return a value.
uv
The UV node to be used in the texture sampling.
Default is null.
Returns: The created SampleNode instance wrapped as a node object.
Returns a deterministic pseudo-random float in the interval [0, 1].
s
The integer seed.
Returns: A random float.
Sets a custom function to handle console output.
This allows external code to intercept and handle console.log, console.warn, and console.error calls made by three.js, which is useful for custom logging, testing, or debugging workflows.
fn
The function to handle console output. Should accept (type, message, ...params) where type is 'log', 'warn', or 'error'.
Assumes 2 cameras that are parallel and share an X-axis, and that the cameras' projection and world matrices have already been set. And that near and far planes are identical for both cameras. Visualization of this technique: https://computergraphics.stackexchange.com/a/4765
camera
The camera to update.
cameraL
The left camera.
cameraR
The right camera.
Sets the given quaternion from the Intrinsic Proper Euler Angles defined by the given angles and order.
Rotations are applied to the axes in the order specified by order: rotation by angle a is applied first, then by angle b, then by angle c.
q
The quaternion to set.
a
The rotation applied to the first axis, in radians.
b
The rotation applied to the second axis, in radians.
c
The rotation applied to the third axis, in radians.
order
A string specifying the axes order.
Sets up a construction-time WebGL fallback for WebGPU XR examples.
renderer
The initial renderer.
createFallbackRenderer
A function that returns a new renderer with a WebGL backend.
onFallback
A function that installs the new renderer in the app.
Shadow Render Object Function.
object
The 3D object to render.
scene
The scene containing the object.
_camera
The camera used for rendering.
geometry
The geometry of the object.
material
The material of the object.
group
The group the object belongs to.
params
Additional parameters for rendering.
A thin horizontal cap over a footprint's bounding box at height y. Its sides are pulled in behind the facade plane ( into the backing-wall shell ) so they never sit coplanar with the walls, spandrels or piers and z-fight.
A variation on smoothstep that has zero 1st and 2nd order derivatives at x=0 and x=1.
x
The value to evaluate based on its position between min and max.
min
The min value. Any x value below min will be 0. min must be lower than max.
max
The max value. Any x value above max will be 1. max must be greater than min.
Returns: The alternated value.
Returns a value in the range [0,1] that represents the percentage that x has moved between min and max, but smoothed or slowed down the closer x is to the min and max.
See Smoothstep for more details.
x
The value to evaluate based on its position between min and max.
min
The min value. Any x value below min will be 0. min must be lower than max.
max
The max value. Any x value above max will be 1. max must be greater than min.
Returns: The alternated value.
Sorts the given array by the previously computed order via getKeyframeOrder().
values
The values to sort.
stride
The stride.
order
The sort order.
Returns: The sorted values.
Creates a new clip, containing only the segment of the original clip between the given frames.
sourceClip
The values to sort.
name
The name of the clip.
startFrame
The start frame.
endFrame
The end frame.
fps
The FPS.
Default is 30.
Returns: The new sub clip.
Returns a half precision floating point value (FP16) from the given single precision floating point value (FP32).
val
A single precision floating point value.
Returns: The FP16 value.
Updates the world matrices for the given camera based on the parent 3D object.
camera
The camera to update.
parent
The parent 3D object.
Updates the given camera with the transformation of the XR camera and parent object.
camera
The camera to update.
cameraXR
The XR camera.
parent
The parent 3D object.
Logs a warning message with the 'THREE.' prefix.
If a custom console function is set via setConsoleFunction(), it will be used instead of the native console.warn. The first parameter is treated as the method name and is automatically prefixed with 'THREE.'.
params
The message components. The first param is used as the method name and prefixed with 'THREE.'.
Logs a warning message only once, preventing duplicate warnings.
This function maintains an internal cache of warning messages and will only output each unique warning message once. Useful for warnings that may be triggered repeatedly but should only be shown to the user once.
params
The warning message components.
c
Yields execution to the main thread to allow rendering and other tasks. Uses scheduler.yield() when available (Chrome 115+), falls back to requestAnimationFrame.
Represents the different interpolation sampling modes.
NORMAL
string
Normal sampling mode.
CENTROID
string
Centroid sampling mode.
SAMPLE
string
Sample-specific sampling mode.
FIRST
string
Flat interpolation using the first vertex.
EITHER
string
Flat interpolation using either vertex.
Represents the different interpolation sampling types.
PERSPECTIVE
string
Perspective-correct interpolation.
LINEAR
string
Linear interpolation.
FLAT
string
Flat interpolation.
This type represents mouse buttons and interaction types in context of controls.
MIDDLE
number
The left mouse button.
LEFT
number
The middle mouse button.
RIGHT
number
The right mouse button.
ROTATE
number
A rotate interaction.
DOLLY
number
A dolly interaction.
PAN
number
A pan interaction.
This type represents the different timestamp query types.
COMPUTE
string
A compute timestamp query.
RENDER
string
A render timestamp query.
This type represents touch interaction types in context of controls.
ROTATE
number
A rotate interaction.
PAN
number
A pan interaction.
DOLLY_PAN
number
The dolly-pan interaction.
DOLLY_ROTATE
number
A dolly-rotate interaction.
Debug configuration.
checkShaderErrors
boolean
Whether shader errors should be checked or not.
onShaderError
function
A callback function that is executed when a shader error happens. Only supported with WebGL 2 right now.
getShaderAsync
function
Allows the get the raw shader code for the given scene, camera and 3D object.
depth
Node.
Scene depth buffer for view-space edge stopping.
Default is null.
normal
Node.
View-space normals for geometric edge stopping.
Default is null.
metalRoughness
Node.
Roughness/metalness G-buffer for specular edge stopping.
Default is null.
diffuse
Node.
Scene base color (albedo) G-buffer for chromatic edge stopping.
Default is null.
raw
Node.
Unfiltered input (e.g. raw SSR/SSGI) for secondary sampling and temporal blend.
Default is null.
mode
DenoiseMode
Denoising kernel type.
Default is 'diffuse'.
accumulate
boolean
When true, temporally blend the spatially-denoised result (Karis-style) and write frame weight to alpha for feedback loops. When false, only spatial filtering is applied.
Default is true.
stochastic
boolean
When false, traces a single mirror reflection and softens roughness with a blur pass (first-generation SSR). When true, varies the reflection direction per pixel with stochastic GGX rays (second-generation SSR); higher quality on rough/glossy surfaces but noisier, so it expects a temporal/spatial denoiser downstream.
Default is false.
metalnessNode
Node.
Per-pixel metalness. Drives GGX reflection sampling and, with reflectNonMetals=false, the non-metal early-out.
Default is null.
roughnessNode
Node.
Per-pixel roughness. Drives GGX sampling and the blur mip selection.
Default is null.
reflectNonMetals
boolean
Only used when stochastic=false. When false, non-metallic surfaces are discarded for a noticeable performance gain; set true to also reflect dielectrics (e.g. marble, polished wood, plastic).
Default is false.
environmentNode
Texture
Equirectangular HDR environment map with CPU-side image.data (e.g. from RGBELoader). Not compatible with PMREM / scene.environment cubemaps.
Default is null.
envImportanceSampling
boolean
When true, precomputes env-luminance CDF tables and uses MIS for environment misses. Build-time only.
Default is false.
diffuseNode
Node
Scene diffuse / base color. Defaults to vec3(1) in the shader when omitted.
Default is null.
binaryRefine
boolean
Sub-step binary-search refinement of detected hits. Compile-time constant (baked into the shader at construction).
Default is false.
camera
Camera
Camera the scene is rendered with. Inferred from the color pass when omitted.
Default is null.
Shadow map configuration
enabled
boolean
Whether to globally enable shadows or not.
transmitted
boolean
Whether to enable light transmission through non-opaque materials.
type
number
The shadow map type.
diffuse for SSGI/scene colour; specular for SSR reflections.
Default is 'diffuse'.
hitPointReprojection
boolean
Parallax hit-point reprojection (specular mode only). Defaults to true in specular mode.
accumulate
boolean
When true, history is stored in this pass (classic temporal resolve). When false, use TemporalReprojectNode#setHistoryTexture to read history from another pass (e.g. denoise output).
Default is false.
XR configuration.
enabled
boolean
Whether to globally enable XR or not.
Animation loop parameter of renderer.setAnimationLoop().
time
A timestamp indicating the end time of the previous frame's rendering.
frame
A reference to the current XR frame. Only relevant when using XR rendering.
Callback for onError in loaders.
error
The error which occurred during the loading process.
Callback for onProgress in loaders.
event
An instance of ProgressEvent that represents the current loading status.
Callback for Renderer#setRenderObjectFunction.
object
The 3D object.
scene
The scene the 3D object belongs to.
camera
The camera the object should be rendered with.
geometry
The object's geometry.
material
The object's material.
group
Only relevant for objects using multiple materials. This represents a group entry from the respective BufferGeometry.
lightsNode
The current lights node.
clippingContext
The clipping context.
passId
An optional ID for identifying the pass.
Default is null.
Callback for Node#traverse.
node
The current node.