Motion
Get Motion

ReferenceScripting APIVector3

Vector3

class

A point or direction in 3D (a 2D mote's z is its depth).

NameVector3
Kindclass
Script reaches it asimport { Vector3 } from "motion" · MeshComponent.bone() · Mote.location · Mote.scale · Mote.velocity · MotionStageApi.randomPointInView() · MotionStageApi.gravity
Since0.3

Syntax

class Vector3 { … }

Properties

NameTypeDescription
xpropertynumberAcross.
ypropertynumberDown (2D) or up (3D).
zpropertynumberToward you.
zeropropertyreadonly Vector3(0, 0, 0).
lengthpropertyreadonly numberHow long it is.

Methods

SignatureDescription
new Vector3(x?: number, y?: number, z?: number): Vector3constructorA new vector.
add(v: Vector3): Vector3methodThis plus another.
sub(v: Vector3): Vector3methodThis less another.
scale(k: number): Vector3methodThis times a number.
dot(v: Vector3): numbermethodThe dot product with another.
cross(v: Vector3): Vector3methodThe cross product with another.
normalised(): Vector3methodThe same direction, 1 long.
lerp(v: Vector3, t: number): Vector3methodBetween this and another, t of the way.
withZ(z: number): Vector3methodThe same with another z.
toArray(): [number, number, number]methodAs [x, y, z].