AbstractThe height of this render target in pixels.
The width of this render target in pixels.
Bind this render target as the active draw destination. All subsequent draw calls will render into this target until unbind is called. No-op by default: only the GPU renderers' own targets override it.
Clear the render target contents.
Release all resources held by this render target. The target must not be used after calling destroy.
Resize the render target's backing storage to the given dimensions.
new width in pixels
new height in pixels
Creates a Blob object representing the image contained in this render target.
a string indicating the image format (default "image/png")
Optionalquality: number
a number between 0 and 1 for lossy formats (e.g. image/jpeg)
a Promise resolving to a Blob
Returns a data URL containing a representation of the current contents.
a string indicating the image format (default "image/png")
Optionalquality: number
a number between 0 and 1 for lossy formats (e.g. image/jpeg)
a Promise resolving to a data URL string
Creates an ImageBitmap object from the current contents of this render target.
a Promise resolving to an ImageBitmap
Read back pixel data from this render target.
The portable form, and the one anything backend-agnostic should use. Synchronous readback is NOT portable: WebGPU can only map a buffer asynchronously, so its render targets cannot answer until a frame has been awaited. A CanvasRenderTarget also offers CanvasRenderTarget#getImageData, which answers at once.
Optionalx: number
x coordinate of the top-left corner (default 0)
Optionaly: number
y coordinate of the top-left corner (default 0)
Optionalwidth: number
width of the area to read (default full width)
Optionalheight: number
height of the area to read (default full height)
the pixel data
Unbind this render target, restoring the default (screen) output. No-op by default: only the GPU renderers' own targets override it.
The base class of an offscreen render target: a surface the engine can draw into, clear, resize and read back, whatever the renderer.
The one to create yourself is CanvasRenderTarget, a 2D canvas: draw something into it once (a texture, a background, a fog map) and reuse it every frame. The WebGL and WebGPU renderers keep render targets of their own for post effects (a framebuffer, a GPU texture); those are internal.