ReferenceScripting APIMotionStageApi
MotionStageApi
interfaceThe scene's motes: found, spawned and destroyed, and their physics.
| Name | MotionStageApi |
|---|---|
| Kind | interface |
| Script reaches it as | stage, or import { stage } from "motion" · Mote.stage · Stage.stage · motion.stage |
| Since | 0.3 |
Syntax
interface MotionStageApi { … }declare const stage: MotionStageApi;Properties
| Name | Type | Description |
|---|---|---|
timeproperty | readonly number | The scene's time, seconds. |
motesproperty | readonly Mote[] | Every mote. |
gravityproperty | readonly Vector3 | The 2D world's gravity, pixels a second a second (y down). |
Methods
| Signature | Description |
|---|---|
spawn<M extends Mote>(cls: string | () => M, options?: { location?: Place; rotation?: number | number[] | Rotator; scale?: number | Place; name?: string; properties?: Record<string, unknown>; tags?: string[] }): Mmethod | Makes a mote of a class. |
destroy(mote: Mote): voidmethod | Takes a mote out of the scene. |
find<M extends Mote>(cls: string | () => M): M | nullmethod | The first mote of a class. |
findAll<M extends Mote>(cls: string | () => M): M[]method | Every mote of a class (its subclasses' too). |
withTag(tag: string): Mote[]method | Every mote with a tag. |
byId(id: string): Mote | nullmethod | A mote by its id. |
byName(name: string): Mote | nullmethod | A mote by its name. |
randomPointInView(): Vector3method | A random point on the scene, its pixels. |
castRay(from: Place, to: Place, options?: { world?: "2d" | "3d" }): Promise<MotionRayHit | null>method | The first mote's body a ray from one point to another meets, next turn. |
setGravity(v: Place, world?: "2d" | "3d"): voidmethod | Sets a world's gravity. |
join(a: string | Mote, b: string | Mote, joint?: MotionJointSpec): numbermethod | Joins two motes' bodies. |
unjoin(id: number): voidmethod | Lets a joint go. |
See also
Mote · Vector3 · MotionRayHit
Notes from the community
Written by creators and checked by the docs' editors. Not part of Motion's official reference.