init function).
It serves as a bridge between your script and the Rive runtime, giving you access to:
- Update scheduling — Request that your node be updated on the next frame.
- Data (ViewModels) — Access the ViewModel data context bound to the node or the root artboard.
- Assets — Retrieve named assets (images, blobs, and audio) that have been added to the Rive file.
Methods
markNeedsUpdate
markNeedsUpdate from inside update() are ignored. Use it from init(), advance(), listener callbacks, or event handlers instead.
viewModel
rootViewModel
dataContext
image
drawImage.
See also ImageSampler.
Check out Scripting demos to see a working example.
blob
audio
Audio API.
canvas
canvas:resize(w, h) once the real size is known. While deferred,
canvas.image is nil and width/height report 0; calling
beginFrame() raises an error pointing to resize(). Check
canvas.width > 0 to gate work.
gpuCanvas
canvas:beginRenderPass(...). For MSAA, allocate the multisampled
color and depth textures yourself with GPUTexture.new({ sampleCount = N, renderTarget = true }) and pass them in the
descriptor.
The descriptor is optional. Omitting it (or passing width/height of
0) creates a deferred canvas with no backing texture — useful in
layout scripts that don’t know their size at init. Call
canvas:resize(w, h) once the real size is known. While deferred,
width/height report 0 and calling colorView() raises an error
pointing to resize(). Check canvas.width > 0 to gate work.