Motion
Get Motion

ReferenceScripting APIMotionStageApi

MotionStageApi

interface

The scene's motes: found, spawned and destroyed, and their physics.

NameMotionStageApi
Kindinterface
Script reaches it asstage, or import { stage } from "motion" · Mote.stage · Stage.stage · motion.stage
Since0.3

Syntax

interface MotionStageApi { … }declare const stage: MotionStageApi;

Properties

NameTypeDescription
timepropertyreadonly numberThe scene's time, seconds.
motespropertyreadonly Mote[]Every mote.
gravitypropertyreadonly Vector3The 2D world's gravity, pixels a second a second (y down).

Methods

SignatureDescription
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[] }): MmethodMakes a mote of a class.
destroy(mote: Mote): voidmethodTakes a mote out of the scene.
find<M extends Mote>(cls: string | () => M): M | nullmethodThe first mote of a class.
findAll<M extends Mote>(cls: string | () => M): M[]methodEvery mote of a class (its subclasses' too).
withTag(tag: string): Mote[]methodEvery mote with a tag.
byId(id: string): Mote | nullmethodA mote by its id.
byName(name: string): Mote | nullmethodA mote by its name.
randomPointInView(): Vector3methodA random point on the scene, its pixels.
castRay(from: Place, to: Place, options?: { world?: "2d" | "3d" }): Promise<MotionRayHit | null>methodThe first mote's body a ray from one point to another meets, next turn.
setGravity(v: Place, world?: "2d" | "3d"): voidmethodSets a world's gravity.
join(a: string | Mote, b: string | Mote, joint?: MotionJointSpec): numbermethodJoins two motes' bodies.
unjoin(id: number): voidmethodLets a joint go.

See also

Mote · Vector3 · MotionRayHit