File: Renderer.md | Updated: 11/15/2025
Base class for renderers.
Constructs a new renderer.
backend | The backend the renderer is targeting (e.g. WebGPU or WebGL 2).
---|---
parameters | The configuration parameter.
Whether the default framebuffer should be transparent or opaque.
Default is true.
Whether the renderer should automatically clear the current rendering target before execute a render() call. The target can be the canvas (default framebuffer) or the current bound render target (custom framebuffer).
Default is true.
When autoClear is set to true, this property defines whether the renderer should clear the color buffer.
Default is true.
When autoClear is set to true, this property defines whether the renderer should clear the depth buffer.
Default is true.
When autoClear is set to true, this property defines whether the renderer should clear the stencil buffer.
Default is true.
A reference to the current backend.
The coordinate system of the renderer. The value of this property depends on the selected backend. Either THREE.WebGLCoordinateSystem or THREE.WebGPUCoordinateSystem.
The current color space of the renderer. When not producing screen output, the color space is always the working color space.
The current number of samples used for multi-sample anti-aliasing (MSAA).
When rendering to a custom render target, the number of samples of that render target is used. If the renderer needs an internal framebuffer target for tone mapping or color space conversion, the number of samples is set to 0.
The current tone mapping of the renderer. When not producing screen output, the tone mapping is always NoToneMapping.
The renderer's debug configuration.
Whether the default framebuffer should have a depth buffer or not.
Default is true.
A reference to the canvas element the renderer is drawing to. This value of this property will automatically be created by the renderer.
Enables or disables high precision for model-view and normal-view matrices. When enabled, will use CPU 64-bit precision for higher precision instead of GPU 32-bit for higher performance.
NOTE: 64-bit precision is not compatible with InstancedMesh and SkinnedMesh.
Returns whether high precision is enabled or not.
Holds a series of statistical information about the GPU memory and the rendering process. Useful for debugging and monitoring.
Returns whether the renderer has been initialized or not.
The inspector instance. The inspector can be any class that extends from InspectorBase.
Returns true if the rendering settings are set to screen output.
This flag can be used for type testing.
Default is true.
The node library defines how certain library objects like materials, lights or tone mapping functions are mapped to node types. This is required since although instances of classes like MeshBasicMaterial or PointLight can be part of the scene graph, they are internally represented as nodes for further processing.
A map-like data structure for managing lights.
Whether logarithmic depth buffer is enabled or not.
Default is false.
Returns true if a framebuffer target is needed to perform tone mapping or color space conversion. If this is the case, the renderer allocates an internal render target for that purpose.
A callback function that defines what should happen when a device/context lost occurs.
Whether the renderer should render opaque render objects or not.
Default is true.
Defines the output color space of the renderer.
Default is SRGBColorSpace.
Stores override nodes for specific transformations or calculations. These nodes can be used to replace default behavior in the rendering pipeline.
modelViewMatrix
Node | An override node for the model-view matrix.
---|---
modelNormalViewMatrix
Node | An override node for the model normal view matrix.
The number of samples used for multi-sample anti-aliasing (MSAA).
Default is 0.
The renderer's shadow configuration.
Whether the renderer should sort its render lists or not.
Note: Sorting is used to attempt to properly render objects that have some degree of transparency. By definition, sorting objects may not work in all cases. Depending on the needs of application, it may be necessary to turn off sorting and use other methods to deal with transparency rendering e.g. manually determining each object's rendering order.
Default is true.
Whether the default framebuffer should have a stencil buffer or not.
Default is false.
Defines the tone mapping of the renderer.
Default is NoToneMapping.
Defines the tone mapping exposure.
Default is 1.
Whether the renderer should render transparent render objects or not.
Default is true.
The renderer's XR manager.
Performs a manual clear operation. This method ignores autoClear properties.
color | Whether the color buffer should be cleared or not. Default is true.
---|---
depth | Whether the depth buffer should be cleared or not. Default is true.
stencil | Whether the stencil buffer should be cleared or not. Default is true.
Async version of Renderer#clear.
color | Whether the color buffer should be cleared or not. Default is true.
---|---
depth | Whether the depth buffer should be cleared or not. Default is true.
stencil | Whether the stencil buffer should be cleared or not. Default is true.
Deprecated: Yes
Returns: A Promise that resolves when the clear operation has been executed.
Performs a manual clear operation of the color buffer. This method ignores autoClear properties.
Async version of Renderer#clearColor.
Deprecated: Yes
Returns: A Promise that resolves when the clear operation has been executed.
Performs a manual clear operation of the depth buffer. This method ignores autoClear properties.
Async version of Renderer#clearDepth.
Deprecated: Yes
Returns: A Promise that resolves when the clear operation has been executed.
Performs a manual clear operation of the stencil buffer. This method ignores autoClear properties.
Async version of Renderer#clearStencil.
Deprecated: Yes
Returns: A Promise that resolves when the clear operation has been executed.
Alias for compileAsync().
scene | The scene or 3D object to precompile.
---|---
camera | The camera that is used to render the scene.
targetScene | If the first argument is a 3D object, this parameter must represent the scene the 3D object is going to be added.
Returns: A Promise that resolves when the compile has been finished.
Compiles all materials in the given scene. This can be useful to avoid a phenomenon which is called "shader compilation stutter", which occurs when rendering an object with a new shader for the first time.
If you want to add a 3D object to an existing scene, use the third optional parameter for applying the target scene. Note that the (target) scene's lighting and environment must be configured before calling this method.
scene | The scene or 3D object to precompile.
---|---
camera | The camera that is used to render the scene.
targetScene | If the first argument is a 3D object, this parameter must represent the scene the 3D object is going to be added. Default is null.
Returns: A Promise that resolves when the compile has been finished.
Execute a single or an array of compute nodes. This method can only be called if the renderer has been initialized.
computeNodes | The compute node(s).
---|---
dispatchSize |
Default is null.
Returns: A Promise that resolve when the compute has finished. Only returned when the renderer has not been initialized.
Execute a single or an array of compute nodes.
computeNodes | The compute node(s).
---|---
dispatchSize |
Default is null.
Returns: A Promise that resolve when the compute has finished.
Copies the current bound framebuffer into the given texture.
framebufferTexture | The texture.
---|---
rectangle | A two or four dimensional vector that defines the rectangular portion of the framebuffer that should be copied. Default is null.
Copies data of the given source texture into a destination texture.
srcTexture | The source texture.
---|---
dstTexture | The destination texture.
srcRegion | A bounding box which describes the source region. Can be two or three-dimensional. Default is null.
dstPosition | A vector that represents the origin of the destination region. Can be two or three-dimensional. Default is null.
srcLevel | The source mip level to copy from. Default is 0.
dstLevel | The destination mip level to copy to. Default is 0.
Frees all internal resources of the renderer. Call this method if the renderer is no longer in use by your app.
Returns the active cube face.
Returns: The active cube face.
Returns the active mipmap level.
Returns: The active mipmap level.
Returns the current animation loop callback.
Returns: The current animation loop callback.
Can be used to transfer buffer data from a storage buffer attribute from the GPU to the CPU in context of compute shaders.
attribute | The storage buffer attribute.
---|---
Returns: A promise that resolves with the buffer data when the data are ready.
Returns the current canvas target.
Returns: The current canvas target.
Returns the clear alpha.
Returns: The clear alpha.
Returns the clear color.
target | The method writes the result in this target object.
---|---
Returns: The clear color.
Returns the clear depth.
Returns: The clear depth.
Returns the clear stencil.
Returns: The clear stencil.
Returns the color buffer type.
Returns: The color buffer type.
Returns the rendering context.
Returns: The rendering context.
Returns the drawing buffer size in physical pixels. This method honors the pixel ratio.
target | The method writes the result in this target object.
---|---
Returns: The drawing buffer size.
Returns the MRT configuration.
Returns: The MRT configuration.
Returns the maximum available anisotropy for texture filtering.
Returns: The maximum available anisotropy.
Returns the current output target.
Returns: The current output render target. Returns null if no output target is set.
Returns the pixel ratio.
Returns: The pixel ratio.
Returns the current render object function.
Returns: The current render object function. Returns null if no function is set.
Returns the current render target.
Returns: The render target. Returns null if no render target is set.
Returns the scissor rectangle.
target | The method writes the result in this target object.
---|---
Returns: The scissor rectangle.
Returns the scissor test value.
Returns: Whether the scissor test should be enabled or not.
Returns the renderer's size in logical pixels. This method does not honor the pixel ratio.
target | The method writes the result in this target object.
---|---
Returns: The renderer's size in logical pixels.
Returns the viewport definition.
target | The method writes the result in this target object.
---|---
Returns: The viewport definition.
Checks if the given feature is supported by the selected backend. If the renderer has not been initialized, this method always returns false.
name | The feature's name.
---|---
Returns: Whether the feature is supported or not.
Checks if the given feature is supported by the selected backend.
name | The feature's name.
---|---
Deprecated: Yes
Returns: A Promise that resolves with a bool that indicates whether the feature is supported or not.
Returns true when the renderer has been initialized.
Returns: Whether the renderer has been initialized or not.
Initializes the renderer so it is ready for usage.
Returns: A Promise that resolves when the renderer has been initialized.
Initializes the given texture. Useful for preloading a texture rather than waiting until first render (which can cause noticeable lags due to decode and GPU upload overhead).
This method can only be used if the renderer has been initialized.
texture | The texture.
---|---
Initializes the given textures. Useful for preloading a texture rather than waiting until first render (which can cause noticeable lags due to decode and GPU upload overhead).
texture | The texture.
---|---
Deprecated: Yes
Returns: A Promise that resolves when the texture has been initialized.
This method performs an occlusion query for the given 3D object. It returns true if the given 3D object is fully occluded by other 3D objects in the scene.
object | The 3D object to test.
---|---
Returns: Whether the 3D object is fully occluded or not.
Reads pixel data from the given render target.
renderTarget | The render target to read from.
---|---
x | The x coordinate of the copy region's origin.
y | The y coordinate of the copy region's origin.
width | The width of the copy region.
height | The height of the copy region.
textureIndex | The texture index of a MRT render target. Default is 0.
faceIndex | The active cube face index. Default is 0.
Returns: A Promise that resolves when the read has been finished. The resolve provides the read data as a typed array.
Renders the scene or 3D object with the given camera. This method can only be called if the renderer has been initialized. When using render() inside an animation loop, it's guaranteed the renderer will be initialized. The animation loop must be defined with Renderer#setAnimationLoop though.
For all other use cases (like when using on-demand rendering), you must call Renderer#init before rendering.
The target of the method is the default framebuffer (meaning the canvas) or alternatively a render target when specified via setRenderTarget().
scene | The scene or 3D object to render.
---|---
camera | The camera to render the scene with.
Renders the scene in an async fashion.
scene | The scene or 3D object to render.
---|---
camera | The camera.
Deprecated: Yes
Returns: A Promise that resolves when the render has been finished.
This method represents the default render object function that manages the render lifecycle of the object.
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. Default is null.
passId | An optional ID for identifying the pass. Default is null.
Applications are advised to always define the animation loop with this method and not manually with requestAnimationFrame() for best compatibility.
callback | The application's animation loop.
---|---
Returns: A Promise that resolves when the set has been executed.
Sets the canvas target. The canvas target manages the HTML canvas or the offscreen canvas the renderer draws into.
canvasTarget | The canvas target.
---|---
Defines the clear alpha.
alpha | The clear alpha.
---|---
Defines the clear color and optionally the clear alpha.
color | The clear color.
---|---
alpha | The clear alpha. Default is 1.
Defines the clear depth.
depth | The clear depth.
---|---
Defines the clear stencil.
stencil | The clear stencil.
---|---
This method allows to define the drawing buffer size by specifying width, height and pixel ratio all at once. The size of the drawing buffer is computed with this formula:
size.x = width * pixelRatio;
size.y = height * pixelRatio;
width | The width in logical pixels.
---|---
height | The height in logical pixels.
pixelRatio | The pixel ratio.
Sets the given MRT configuration.
mrt | The MRT node to set.
---|---
Returns: A reference to this renderer.
Defines a manual sort function for the opaque render list. Pass null to use the default sort.
method | The sort function.
---|---
Sets the output render target for the renderer.
renderTarget | The render target to set as the output target.
---|---
Sets the given pixel ratio and resizes the canvas if necessary.
value | The pixel ratio. Default is 1.
---|---
Sets the given render object function. Calling this method overwrites the default implementation which is Renderer#renderObject. Defining a custom function can be useful if you want to modify the way objects are rendered. For example you can define things like "every object that has material of a certain type should perform a pre-pass with a special overwrite material". The custom function must always call renderObject() in its implementation.
Use null as the first argument to reset the state.
renderObjectFunction | The render object function.
---|---
Sets the given render target. Calling this method means the renderer does not target the default framebuffer (meaning the canvas) anymore but a custom framebuffer. Use null as the first argument to reset the state.
renderTarget | The render target to set.
---|---
activeCubeFace | The active cube face. Default is 0.
activeMipmapLevel | The active mipmap level. Default is 0.
Defines the scissor rectangle.
x | The horizontal coordinate for the lower left corner of the box in logical pixel unit. Instead of passing four arguments, the method also works with a single four-dimensional vector.
---|---
y | The vertical coordinate for the lower left corner of the box in logical pixel unit.
width | The width of the scissor box in logical pixel unit.
height | The height of the scissor box in logical pixel unit.
Defines the scissor test.
boolean | Whether the scissor test should be enabled or not.
---|---
Sets the size of the renderer.
width | The width in logical pixels.
---|---
height | The height in logical pixels.
updateStyle | Whether to update the style attribute of the canvas or not. Default is true.
Defines a manual sort function for the transparent render list. Pass null to use the default sort.
method | The sort function.
---|---
Defines the viewport.
x | The horizontal coordinate for the lower left corner of the viewport origin in logical pixel unit.
---|---
y | The vertical coordinate for the lower left corner of the viewport origin in logical pixel unit.
width | The width of the viewport in logical pixel unit.
height | The height of the viewport in logical pixel unit.
minDepth | The minimum depth value of the viewport. WebGPU only. Default is 0.
maxDepth | The maximum depth value of the viewport. WebGPU only. Default is 1.
Can be used to synchronize CPU operations with GPU tasks. So when this method is called, the CPU waits for the GPU to complete its operation (e.g. a compute task).
Deprecated: Yes
Returns: A Promise that resolves when synchronization has been finished.
Renderer options.
logarithmicDepthBuffer
boolean | Whether logarithmic depth buffer is enabled or not. Default is false.
---|---
alpha
boolean | Whether the default framebuffer (which represents the final contents of the canvas) should be transparent or opaque. Default is true.
depth
boolean | Whether the default framebuffer should have a depth buffer or not. Default is true.
stencil
boolean | Whether the default framebuffer should have a stencil buffer or not. Default is false.
antialias
boolean | Whether MSAA as the default anti-aliasing should be enabled or not. Default is false.
samples
number | When antialias is true, 4 samples are used by default. This parameter can set to any other integer value than 0 to overwrite the default. Default is 0.
getFallback
function | This callback function can be used to provide a fallback backend, if the primary backend can't be targeted. Default is null.
colorBufferType
number | Defines the type of color buffers. The default HalfFloatType is recommend for best quality. To save memory and bandwidth, UnsignedByteType might be used. This will reduce rendering quality though. Default is HalfFloatType.
multiview
boolean | If set to true, the renderer will use multiview during WebXR rendering if supported. Default is false.