Motion
Get Motion

ReferenceScripting APIMotionMaths

MotionMaths

interface

Maths for code, as the logic graph's nodes have it (scene.maths, or import { maths } from "motion").

NameMotionMaths
Kindinterface
Script reaches it asmaths, or import { maths } from "motion" · MotionScene.maths · motion.maths
Since0.4

Syntax

interface MotionMaths { … }declare const maths: MotionMaths;

Methods

SignatureDescription
noise(x: number, seed?: number): numbermethodPerlin noise along a line: smooth, -1 to 1, the same for the same x and seed.
noise2(x: number, y: number, seed?: number): numbermethodSmooth noise over a plane, 0 to 1.
smoothstep(e0: number, e1: number, x: number): numbermethod0 below e0, 1 above e1, smooth between.
remap(v: number, a0: number, a1: number, b0: number, b1: number, clamp?: boolean): numbermethodA value from one range to another.
lerp(a: number, b: number, t: number): numbermethodBetween a and b, t of the way.
clamp(v: number, lo: number, hi: number): numbermethodA value kept within lo and hi.
ease(name: Easing & string, t: number): numbermethodHow far along an easing is: as scene.animate eases.
wrap(v: number, lo: number, hi: number): numbermethodA value wrapped round to stay within lo and hi.
pingPong(t: number, length: number): numbermethodT going up to length and back down, again and again.
damp(current: number, target: number, smoothing: number, dt: number): numbermethodA value followed toward a target, the same whatever the frame rate.
degrees(radians: number): numbermethodRadians as degrees.
radians(degrees: number): numbermethodDegrees as radians.