Skip to main content
Represents an image asset that can be drawn by the Renderer.

Fields

width

Width of the image, or 0 until it has decoded. Web runtimes and the CLI preview decode images after init runs, so read it when you use it, not once in init.

height

Height of the image, or 0 until it has decoded. Web runtimes and the CLI preview decode images after init runs, so read it when you use it, not once in init.

Methods

view

Returns a GPUTextureView for sampling this image in WGSL shaders. The view wraps the underlying GPU texture directly — no copy or decode. Requires a GPU context (only available when the file uses GPU canvases). An ImageAsset’s view samples its pixels once the image has decoded; on the web that is after init, so take the view once width is above 0.