ReferenceScripting APIVector3
Vector3
classA point or direction in 3D (a 2D mote's z is its depth).
| Name | Vector3 |
|---|---|
| Kind | class |
| Script reaches it as | import { Vector3 } from "motion" · MeshComponent.bone() · Mote.location · Mote.scale · Mote.velocity · MotionStageApi.randomPointInView() · MotionStageApi.gravity |
| Since | 0.3 |
Syntax
class Vector3 { … }Properties
| Name | Type | Description |
|---|---|---|
xproperty | number | Across. |
yproperty | number | Down (2D) or up (3D). |
zproperty | number | Toward you. |
zeroproperty | readonly Vector3 | (0, 0, 0). |
lengthproperty | readonly number | How long it is. |
Methods
| Signature | Description |
|---|---|
new Vector3(x?: number, y?: number, z?: number): Vector3constructor | A new vector. |
add(v: Vector3): Vector3method | This plus another. |
sub(v: Vector3): Vector3method | This less another. |
scale(k: number): Vector3method | This times a number. |
dot(v: Vector3): numbermethod | The dot product with another. |
cross(v: Vector3): Vector3method | The cross product with another. |
normalised(): Vector3method | The same direction, 1 long. |
lerp(v: Vector3, t: number): Vector3method | Between this and another, t of the way. |
withZ(z: number): Vector3method | The same with another z. |
toArray(): [number, number, number]method | As [x, y, z]. |
Notes from the community
Written by creators and checked by the docs' editors. Not part of Motion's official reference.