update
function update<Tag>(instance, props): Effect<false | void, never, Runner>;
Function: update()
function update<Tag>(instance, props): Effect<false | void, never, Runner>;Defined in: packages/motion/src/Scene.ts:721
Set an entity's data immediately, with no animation.
Type Parameters
| Type Parameter |
|---|
Tag extends | "Audio" | "Line" | "Path" | "Rect" | "Circle" | "Ellipse" | "Text" | "Group" | "Hud" | "Image" | "Camera" |
Parameters
| Parameter | Type | Description |
|---|---|---|
instance | Instance<Tag> | Handle to update. |
props | Updater<EntityByTag<Tag>> | New data, or (current) => next. |
Returns
Effect<false | void, never, Runner>
Remarks
A hard cut on the current frame — the counterpart to the animators, which
interpolate. Use it to set something up before animating (jolt the camera,
then spring it back), or to change a field no animator covers, like
text, visible, or a Path's commands.
Pass an object to replace the data, or a function to derive it from the current values — the function form is preferred, since it reads and writes atomically.
Updating a destroyed entity is a no-op returning false, not an error.
Data missing a required field (a partial object from untyped code) dies
naming the instance and the missing fields, rather than corrupting it.
Example
Retitle a label and jolt the camera, both on this frame.
yield* Scene.update(label, (d) => ({ ...d, text: "done" }));
yield* Scene.update(camera, (d) => ({
...d,
position: Entity.vec3({ ...d.position, x: 22 }),
}));