File: CanvasTarget.md | Updated: 11/15/2025
CanvasTarget is a class that represents the final output destination of the renderer.
Constructs a new CanvasTarget.
domElement | The canvas element to render to.
---|---
The color texture of the default framebuffer.
The depth texture of the default framebuffer.
A reference to the canvas element the renderer is drawing to. This value of this property will automatically be created by the renderer.
Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
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 pixel ratio.
Returns: The pixel ratio.
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.
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 pixel ratio and resizes the canvas if necessary.
value | The pixel ratio. Default is 1.
---|---
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 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.