Skip to contentBlack Friday: Framescript for €79 instead of €99 with the code BF2026

Reference: the main entry

What a scene imports from framescript and calls, in the order the module exports it. Each entry has its signature, what it does, and the examples that use it; the types its signatures name are at the end.

Explained in The timeline, Placing steps in time, Conditions and remapped time, Values, Objects, Per-frame code and simulations, Inputs and controls, Assets and loading.

animation

TypeScript
function animation<Args extends ReadonlyArray<unknown>, A>(
  name: string,
  body: Body<A, Args>,
  declares?: AnimationDeclaration<Args>
): (...args: Args) => Step<A>

A reusable, named piece of timeline. Each call is a named span, so it shows as a bar and in the call chain of everything it runs.

  • name: The name shown on the bar.
  • body: The generator function; its arguments become the animation's.
  • declares: What the studio may know about the animation, which it reads from the source, and how long a call lasts.
  • Returns: A function that makes a step from the arguments.

Examples: basics/clips-and-labels, time/place

clip

TypeScript
function clip<A>(name: string, body: Body<A>): Step<A>
function clip<A, Inputs>(
  name: string,
  options: ClipOptions<Inputs>,
  body: Body<A, [context: ClipContext<InputValues<NoInfer<Inputs>>>]>
): Step<A>

A named scope on the timeline. Objects added inside are removed when it ends, and anything started with background inside is stopped.

With options, the clip declares inputs of its own, and its body is given their values.

  • name: The name shown on the clip's bar.
  • options: The clip's inputs, when it has any.
  • body: The generator function to run.
  • Returns: A step that runs the clip and returns the body's result.

Examples: camera/dolly-zoom, camera/frame, camera/look-at

effect

TypeScript
function effect<A>(value: Effect.Effect<A, unknown>): Step<A>

Runs raw Effect code inside a timeline. The studio shows it as one opaque span.

  • value: The effect to run. It must need no services.
  • Returns: A step with the effect's result.

Examples: inputs/inputs

timeline

TypeScript
function timeline<Inputs = Record<string, never>>(
  body: Body<void, [context: TimelineContext<Inputs>]>
): Timeline<Inputs>

Wraps the main generator of a scene. The whole timeline is one clip: what is added at the top level stays until the scene ends.

  • body: The generator function; it receives the stage and inputs.
  • Returns: The timeline.

Examples: text-reveals/typewriter, text/build-line, text/captions

video

TypeScript
function video<Inputs = Record<string, never>>(
  options: VideoOptions<Inputs>,
  main: Timeline<InputValues<NoInfer<Inputs>>>
): VideoDefinition<Inputs>

Declares a scene: its size, frame rate, input defaults and main timeline. It is the default export of a scene's file.

  • options: Width, height, frames per second and the inputs: plain defaults, or controls made with input.
  • main: The timeline to run; it is given the inputs' values.
  • Returns: The scene definition.

Examples: text-reveals/typewriter, text/build-line, text/captions

collection

TypeScript
function collection(
  options: CollectionOptions,
  videos: Readonly<Record<string, CollectedVideo>>
): CollectionDefinition

Declares a collection: several videos shown side by side under one playhead, each by its name. It is the default export of a collection's index.ts.

  • options: How the videos sit together.
  • videos: The videos by name, in the order they sit, each made with video(), most often imported from a sub-video's folder.
  • Returns: The collection.

Examples: composing/collection

custom

TypeScript
function custom(
  duration: number,
  fn: (progress: number, time: number) => void,
  options?: (() => void) | CustomOptions
): Step<void>

Per-frame code for anything the other steps cannot express. The function is called for every frame the span covers and must depend only on its arguments. A step that names what it writes has tracks like a tween; one that names nothing leaves no record.

  • duration: How long the span lasts, in seconds.
  • fn: Called with progress from 0 to 1 and the time since the start.
  • options: What the step says about itself: { rest, writes, label, curve }. A function is taken as rest. Without rest, frames after the span are given the function's last state.
  • Returns: A step that ends after the duration.

Examples: steps/custom-writes, values/numbers, values/utilities

label

TypeScript
function label(name: string, time?: number): Step<void>

Names a moment of the enclosing clip, so that steps can be pinned to it by name with until and place, and so that it shows on the timeline, where it can be dragged. With a time it is that many seconds from the start of the clip, a number the studio can edit; without one it is the moment the step is reached. It takes no time itself.

  • name: The label's name, unique in its clip.
  • time: Seconds from the start of the clip. Defaults to now.
  • Returns: A step that ends at once.

Examples: basics/clips-and-labels, time/place

until

TypeScript
function until(time: number | string): Step<void>

Waits until a time measured from the start of the enclosing clip, or until a label of it. What follows is pinned to that moment, whatever the steps before it take.

  • time: Seconds from the start of the clip, or a label's name.
  • Returns: A step that ends at that time.

Examples: basics/clips-and-labels, composing/play

wait

TypeScript
function wait(duration: number): Step<void>

Lets time pass.

  • duration: How long, in seconds.
  • Returns: A step that ends after that time.

Examples: text-reveals/typewriter, text/build-line, text/captions

simulate

TypeScript
function simulate(
  duration: number,
  options: SimulateOptions
): Step<void>

Motion that depends on the frame before: particles, something that chases something else. A frame is drawn from its time alone and cannot ask what the last one looked like, so the rule is run once, when the scene is run, in even steps from a seed, and every state it gives is kept. Drawing a frame then looks its state up. Every frame is the same on every run and whichever frame was drawn before it.

  • duration: How long it runs, in seconds.
  • options: The state's size, the rule that moves it on, what shows it, and { step, seed, start, blend, writes, label, rest }.
  • Returns: A step that ends after the duration.

Examples: time/simulate

across

TypeScript
function across(step: Step<unknown> | Body<unknown>): Step<void>

Starts a step that carries on when the clip it was started in has ended: a camera move from one section into the next, a drift, anything that belongs to two clips at once. It is written once, where it starts, and what follows does not wait for it, as with background; unlike background, the end of the clip does not end it. It ends by itself, or with the scene. Its bar on the timeline reaches across the clips it spans.

  • step: The step, or a generator function of steps.
  • Returns: A step that ends at once.

Examples: time/across

all

TypeScript
function all<Steps extends ReadonlyArray<Step<unknown>>>(
  ...steps: Steps
): Step<Results<Steps>>
function all(...steps: ReadonlyArray<Maybe>): Step<Array<unknown>>

Runs steps at the same time and ends when the longest ends.

  • steps: The steps to run together.
  • Returns: A step with every step's result, in order.

Examples: composing/components, shapes/morph-path, text/counter

background

TypeScript
function background(step: Maybe | Body<unknown>): Step<void>

Starts a step without waiting for it. It runs alongside what follows and is stopped when the enclosing clip ends.

  • step: A step, or a generator function to run as one.
  • Returns: A step that ends at once.

Examples: camera/handheld, time/across, time/repeat-and-forever

delay

TypeScript
function delay<A>(duration: number, step: Step<A>): Step<A>

Runs a step after a wait, as a single step.

  • duration: How long to wait first, in seconds.
  • step: The step to run.
  • Returns: A step with the step's result.

Examples: time/distribute, basics/tweens, motion/keeps-its-speed

distribute

TypeScript
function distribute(
  count: number,
  options: number | StaggerOptions
): Array<number>

The start offsets stagger gives a number of steps, as plain numbers: for a delay, a position or anything else that should spread the same way.

  • count: How many there are.
  • options: The interval in seconds, or the stagger options.
  • Returns: One offset in seconds for each, in order.

Examples: time/distribute

forever

TypeScript
function forever(step: Step<unknown>): Step<never>

Runs a step again and again without end. It belongs inside background, which stops it when the clip ends.

  • step: The step to repeat.
  • Returns: A step that never ends by itself.

Examples: time/repeat-and-forever, sound/voice

lasting

TypeScript
function lasting<A>(seconds: number, step: Step<A>): Step<A>

Says how long a step lasts when that cannot be read from it, so that other steps can be placed against its end. The step still takes what it takes; a length that turns out wrong is reported.

  • seconds: The step's length.
  • step: The step.
  • Returns: The same step, with its length known.

Examples: time/place

place

TypeScript
function place<A>(position: Position, step: Step<A>): Step<A>

Places a step among the steps beside it, in a sequence or an all, instead of letting it follow the flow: at a time of the group, at a label, together with the step before or so long after its start, so long after its end, or, with a negative number, so long before its end, so that the two overlap. In an all, before starts it that long before the others end. Every number is a literal the studio can edit.

  • position: Where the step starts.
  • step: The step.
  • Returns: The step, placed.

Examples: footage/sound-mix, footage/cut-title, time/place

repeat

TypeScript
function repeat(times: number, step: Step<unknown>): Step<void>

Runs a step a number of times, one after another. Each pass runs the step afresh, so relative values build on the pass before.

  • times: How many times to run it.
  • step: The step to repeat.
  • Returns: A step that ends after the last pass.

Examples: values/relative-and-keyframes, composing/inset, time/repeat-and-forever

sequence

TypeScript
function sequence<Steps extends ReadonlyArray<Step<unknown>>>(
  ...steps: Steps
): Step<Results<Steps>>
function sequence(...steps: ReadonlyArray<Maybe>): Step<Array<unknown>>

Runs steps one after another, as a single step. Useful inside all and stagger.

  • steps: The steps to run in order.
  • Returns: A step with every step's result, in order.

Examples: text-reveals/reveals, sound/tones, basics/when-code-runs

stagger

TypeScript
function stagger<Steps extends ReadonlyArray<Step<unknown>>>(
  options: number | StaggerOptions,
  ...steps: Steps
): Step<Results<Steps>>
function stagger(
  options: number | StaggerOptions,
  ...steps: ReadonlyArray<Maybe>
): Step<Array<unknown>>

Runs steps together, each starting a little after the one before.

  • options: The interval in seconds, or the stagger options.
  • steps: The steps to stagger.
  • Returns: A step with every step's result, in order.

Examples: motion/stagger-grid, sound/filter-and-delay, kit/code-parts

when

TypeScript
function when<T, A>(
  value: T | null | undefined | false,
  step: Step<A> | ((value: T) => Step<A>)
): Step<A | void>

A step that is only taken when something is there. Given a value that is undefined, null or false, it does nothing and takes no time; otherwise it is the step, or what the function makes of the value, which is then known to be there.

  • value: What decides: a condition, or an object that may be missing.
  • step: The step, or a function from the value to the step.
  • Returns: The step, or one that does nothing.

Examples: basics/show-hide-order

need

TypeScript
function need<T>(value: T | null | undefined, what?: string): T

A value that has to be there. Indexing a list gives a value that may be missing; where the code knows better, this says so, and fails with a message that names what was missing when the code was wrong.

  • value: The value, such as an entry of a list.
  • what: What it is, for the message.
  • Returns: The value, known to be there.

Examples: time/distribute, basics/show-hide-order

input

TypeScript
const input: { slider; number; color; text; choice; toggle }

Makes an input a control: something the studio shows as a field of its kind and a person can turn. Each takes the default and then what the kind needs, with a label and a group. Turning it in the studio rewrites the default where it is written here.

Examples: controls/kinds, controls/grading, sound/character/shaper

input.slider

TypeScript
function input.slider(
  value: number,
  options: ControlOptions &
    NumberLimits & {
      readonly min: number
      readonly max: number
    }
): Control<number>

A number between two limits, chosen with a slider.

  • value: The default.
  • options: min and max, a step, a label and a group.
  • Returns: The control.

Examples: controls/kinds, controls/grading, sound/character/shaper

input.number

TypeScript
function input.number(
  value: number,
  options?: ControlOptions & NumberLimits
): Control<number>

A number that is typed or dragged.

  • value: The default.
  • options: Optional min, max and step, a label and a group.
  • Returns: The control.

Examples: controls/kinds, ui/controls, sound/pitch/grains

input.color

TypeScript
function input.color(
  value: string,
  options?: ControlOptions
): Control<string>

A colour, as a string such as "#ff6467".

  • value: The default.
  • options: A label and a group.
  • Returns: The control.

Examples: controls/kinds, controls/sections, inputs/inputs

input.text

TypeScript
function input.text(
  value: string,
  options?: ControlOptions
): Control<string>

A text.

  • value: The default.
  • options: A label and a group.
  • Returns: The control.

Examples: controls/kinds, controls/sections, ui/controls

input.choice

TypeScript
function input.choice<const Option extends string>(
  value: NoInfer<Option>,
  options: ControlOptions & {
    readonly options: ReadonlyArray<Option>
  }
): Control<Option>

One of a list of words.

  • value: The default, one of the options.
  • options: options, the words to choose from, a label and a group.
  • Returns: The control.

Examples: controls/kinds, ui/controls, sound/filters/sweep

input.toggle

TypeScript
function input.toggle(
  value: boolean,
  options?: ControlOptions
): Control<boolean>

Yes or no.

  • value: The default.
  • options: A label and a group.
  • Returns: The control.

Examples: controls/kinds, controls/grading, export/sections

later

TypeScript
function later<A>(build: () => Step<A>): Step<A>

A step that is built when it plays, not when it is written: the function is called at that moment and what it returns is run. It is how a step reads something that an earlier step has set.

  • build: Makes the step, at the moment it plays.
  • Returns: The step.

Examples: basics/when-code-runs

state

TypeScript
function state<T>(initial: T): State<T>

Makes a value that steps share and set as they play.

  • initial: The value it starts with.
  • Returns: The state.

Examples: basics/when-code-runs

hide

TypeScript
function hide<T extends Seen>(
  object: T | null | undefined,
  exit?: Maybe
): Step<unknown>

Takes an object out of the picture: from this moment it is not drawn and cannot be picked, and it stays where and as it was, so that show brings it back unchanged. Given a step, such as an exit, the step is played first and the object is hidden when it has ended.

  • object: The object, or nothing, in which case nothing is done.
  • exit: A step to play before the object goes.
  • Returns: A step as long as the exit, or one that ends at once.

Examples: basics/show-hide-order

show

TypeScript
function show<T extends Seen>(
  object: T | null | undefined,
  entrance?: Maybe
): Step<unknown>

Puts an object in the picture: from this moment it is drawn, and can be picked. Given a step, such as an entrance, the object is shown and the step is played. Whether an object is visible is a track like any other, so the timeline shows from when to when it is.

  • object: The object, or nothing, in which case nothing is done.
  • entrance: A step to play once the object is there.
  • Returns: A step as long as the entrance, or one that ends at once.

Examples: basics/show-hide-order

allow

TypeScript
function allow<
  T extends {
    userData: Record<string, unknown>
  },
>(object: T, rules: CheckRule | ReadonlyArray<CheckRule>, reason: string): T
function allow<A>(
  step: Step<A>,
  rules: CheckRule | ReadonlyArray<CheckRule>,
  reason: string
): Step<A>

Lets an object or a step off one or more rules of the check, on purpose: a text drawn over another in a transition, one that runs off the frame as it leaves, a title that fades in by design, a whip pan that snaps or a drift its clip cuts off. The page of the rules says which rules an object, a text or a step may be let off; one that makes a video broken whatever the reason never is. check lists every exception with its reason.

  • object: The object, such as a text, or the step.
  • rules: The rule or rules it is let off.
  • reason: Why, as a person reads it; never empty.
  • Returns: The object or the step.

Examples: text/allow-taste, ui/comments, time/across

add

TypeScript
function add<T extends object>(
  object: T,
  props?: Props<T>,
  options?: AddOptions
): Step<T>

Puts a three.js object into the world from now until the enclosing clip ends, and returns the same object.

  • object: The object to add.
  • props: Initial values, in a place the studio can edit.
  • options: Where to attach the object.
  • Returns: A step with the object.

Examples: text-reveals/typewriter, text/build-line, text/captions

camera

TypeScript
function camera(object: object): Step<void>

Makes a camera the one the scene is seen through, from now on.

  • object: A camera that was added.
  • Returns: A step that ends at once.

Examples: text-reveals/typewriter, text/build-line, text/captions

remove

TypeScript
function remove(object: object): Step<void>

Takes an object off the timeline before its clip ends.

  • object: An object that was added.
  • Returns: A step that ends at once.

Examples: basics/show-hide-order

behind

TypeScript
function behind<T extends object>(object: T, of?: object): T

Draws an object, and everything under it, behind another: before it, whichever is nearer the camera. Without another, it is drawn before everything that was not told otherwise.

  • object: The object to draw behind.
  • of: The object it is behind.
  • Returns: The object.

Examples: basics/show-hide-order

inFront

TypeScript
function inFront<T extends object>(object: T, of?: object): T

Draws an object, and everything under it, in front of another: after it, whichever is nearer the camera. Without another, it is drawn after everything that was not told otherwise.

  • object: The object to draw in front.
  • of: The object it is in front of.
  • Returns: The object.

Examples: basics/show-hide-order

by

TypeScript
function by(amount: number): Relative

A value that many adds to the current one. Unlike an arrow function, the amount is a literal the studio can edit.

  • amount: How much to add to each component.
  • Returns: The relative value.

Examples: values/relative-and-keyframes, layout/stacks, time/repeat-and-forever

scaleBy

TypeScript
function scaleBy(amount: number): Relative

A value that multiplies the current one.

  • amount: The factor for each component.
  • Returns: The relative value.

Examples: values/relative-and-keyframes

from

TypeScript
function from<T extends object>(
  target: T | null | undefined,
  props: PropsOf<T>,
  duration: number | SpringEasing,
  options?: TweenOptions
): Step<void>

Animates properties of a target from the given values to their current ones: the entrance form. Before it starts, the target rests at the given values.

  • target: The object whose properties change.
  • props: The values to start from.
  • duration: How long it takes in seconds, or a physical spring.
  • options: An easing, or { ease, delay, repeat, yoyo, times }; after a physical spring, the same without an easing.
  • Returns: A step that ends when the animation does.

Examples: basics/tweens, layout/stacks, effects/viewport

fromTo

TypeScript
function fromTo<T extends object>(
  target: T | null | undefined,
  fromProps: PropsOf<T>,
  toProps: PropsOf<T>,
  duration: number | SpringEasing,
  options?: TweenOptions
): Step<void>

Animates properties of a target between two given sets of values.

  • target: The object whose properties change.
  • fromProps: The values to start from.
  • toProps: The values to reach.
  • duration: How long it takes in seconds, or a physical spring.
  • options: An easing, or { ease, delay, repeat, yoyo, times }; after a physical spring, the same without an easing.
  • Returns: A step that ends when the animation does.

Examples: basics/tweens

inertia

TypeScript
function inertia<T extends object>(
  target: T | null | undefined,
  speeds: {
    readonly [K in keyof T]?: number | "keep"
  },
  options?: InertiaOptions
): Step<void>

Lets properties coast from the speed they have and come to rest, the way a thing that was thrown or dragged slides on. Where each stops follows from its speed and from how quickly it loses it; the way there is one ordinary segment.

  • target: The object whose properties coast.
  • speeds: For each property, its speed in units a second, or "keep" for the speed the tween before it left it with.
  • options: { timeConstant, min, max }.
  • Returns: A step that ends when everything is at rest.

Examples: motion/keeps-its-speed

set

TypeScript
function set<T extends object>(
  target: T | null | undefined,
  props: PropsOf<T>
): Step<void>

Changes properties of a target instantly, at the current time.

  • target: The object whose properties change.
  • props: The values to set.
  • Returns: A step that ends at once.

Examples: sound/tones, sound/filter-and-delay, sound/instruments/color-noise

tween

TypeScript
function tween<T extends object>(
  target: T | null | undefined,
  props: PropsOf<T>,
  duration: number | SpringEasing,
  options?: TweenOptions
): Step<void>

Animates properties of a target from their current values to the given ones. A value can be a number, an array of keyframes, by(n), or a function of the current value. An array of keyframes is the whole way: its first entry is where the property starts, in place of its current value, and its last where it ends.

  • target: The object whose properties change.
  • props: The values to reach.
  • duration: How long it takes in seconds, or a spring given by its physics, which brings its own duration and is the easing.
  • options: An easing, or { ease, delay, repeat, yoyo, times, carry }. After a physical spring the options count too, all but an easing, which is left out with a warning.
  • Returns: A step that ends when the animation does.

Examples: text/allow-taste, composing/preview, shapes/morph-path

freeze

TypeScript
function freeze<A>(
  steps: Step<A> | Body<A>,
  options: FreezeOptions
): Step<A>

Runs steps with one moment held: they run as written up to it, stand still for a while, and carry on as written.

  • steps: A step, or a generator function of steps.
  • options: Which moment is held and for how long.
  • Returns: A step that takes as long as the steps, plus the hold.

Examples: time/warp

warp

TypeScript
function warp<A>(
  curve: Easing | ((progress: number) => number),
  steps: Step<A> | Body<A>,
  options?: WarpOptions
): Step<A>

Runs steps on remapped time: slow motion, a speed ramp, a hold. The steps are written at normal speed; the time curve says, for how far the scene is through the warp (0 to 1), how far the steps are through their own time. A slope below 1 is slow motion and a flat part stands still. ramp and hold make such curves, and any easing that never goes down is one. What starts in background inside the warp is remapped with it.

  • curve: The time curve.
  • steps: A step, or a generator function of steps.
  • options: Extra length for the warp.
  • Returns: A step that takes as long as the steps, plus extend.

Examples: time/warp

load

TypeScript
const load: {
  texture
  environment
  font
  gltf
  sequence
  video
  audio
  lut
  svg
  typeface
  asset
}

Loads assets. Loading takes real time but no video time, and a loaded asset stays cached across re-runs of the timeline. Every load takes "@assets/<path>" for the file at that path in the nearest assets folder on the opened video's way up to its source.

Examples: composing/components, footage/cut, components/Badge

load.texture

TypeScript
function load.texture<T = unknown>(url: string): Step<T>

Loads an image as a three.js texture. A .ktx2 file is transcoded for the graphics card, with the colour space and mipmaps the file carries.

  • url: The image's URL.
  • Returns: A step with the texture.

Examples: composing/components, components/Badge, images/picture

load.environment

TypeScript
function load.environment<T = unknown>(url: string): Step<T>

Loads surroundings for an environment: an equirectangular picture with more range than a screen has, as an .hdr or .exr file.

  • url: The file's URL.
  • Returns: A step with the texture.

Examples: loading/assets

load.font

TypeScript
function load.font(url: string): Step<string>

Loads a font file for text: a .woff, .ttf or .otf. The step gives the file's address back once the file is known to be there, to hand to a text as its font.

  • url: The font file's URL.
  • Returns: A step with the font's URL.

Examples: loading/assets

load.gltf

TypeScript
function load.gltf<T = unknown>(url: string): Step<T>

Loads a glTF model, as a .gltf or .glb file. What comes back has the model as scene, to pass to add, and its own animation clips as animations, which playClip in framescript/motion plays. Meshes compressed with Draco and .ktx2 textures in the model are decoded.

  • url: The model's URL.
  • Returns: A step with the loaded glTF.

Examples: loading/assets

load.sequence

TypeScript
function load.sequence<T = unknown>(
  pattern: string,
  range: {
    readonly from?: number
    readonly to: number
  }
): Step<Array<T>>

Loads a numbered set of pictures, such as the frames of a rendered animation, as textures in order.

  • pattern: The pictures' address, with a run of # where the number stands: "/frames/walk-###.png" is walk-001.png and so on.
  • range: The number of the last picture and, if it is not 1, of the first.
  • Returns: A step with the textures, the first picture first.

Examples: loading/assets

load.video

TypeScript
function load.video<T extends VideoAsset = VideoAsset>(
  path: string
): Step<T>

Loads a video file, for playMedia and cut from framescript/media. Its texture shows the frame the video is at and is used as the map of any material.

  • path: The file's path in the video's media/ folder, such as "interview/take-2.mp4"; a shared asset as "@assets/<path>"; or, beginning with a slash, its URL.
  • Returns: A step with the video: its texture, duration, width, height and the times of its frames.

Examples: footage/cut, footage/over, footage/video-file

load.audio

TypeScript
function load.audio<T extends AudioAsset = AudioAsset>(
  path: string
): Step<T>

Loads a sound file, for playMedia and cut from framescript/media.

  • path: The file's path in the video's media/ folder, such as "music/theme.wav"; a shared asset as "@assets/<path>"; or, beginning with a slash, its URL.
  • Returns: A step with the sound: its duration and its samples.

Examples: footage/sound-file, footage/sound-mix, sound/hear/on-the-beat

load.lut

TypeScript
function load.lut<T = unknown>(url: string): Step<T>

Loads a colour lookup table, as a .cube file a grading program wrote, for the lookup effect.

  • url: The file's URL.
  • Returns: A step with the table.

Examples: effects/more-effects

load.svg

TypeScript
function load.svg<T = unknown>(url: string): Step<T>

Loads an SVG file as its paths, for the helpers in framescript/shapes that fill it, give it depth or draw its outlines on.

  • url: The SVG file's URL.
  • Returns: A step with the drawing.

Examples: shapes/solid, loading/assets, shapes/svg-outline

load.typeface

TypeScript
function load.typeface<T = unknown>(url: string): Step<T>

Loads a typeface in three.js's JSON format, for extrudeText in framescript/shapes.

  • url: The typeface file's URL.
  • Returns: A step with the typeface.

Examples: shapes/solid

load.asset

TypeScript
function load.asset<T = unknown>(
  kind: string,
  url: string,
  options?: unknown
): Step<T>

Loads an asset of a kind the host knows how to load.

  • kind: The kind of asset.
  • url: The asset's URL.
  • options: Options passed to the loader and part of the cache key.
  • Returns: A step with the loaded asset.

Types

AddOptions

TypeScript
interface AddOptions {
  /** An added object to attach it under, instead of the scene. */
  readonly parent?: object
  /**
   * Draws the object, and everything under it, into a picture of its own
   * that is laid into the frame as one image. Its `opacity` then fades that
   * picture: where two of its parts overlap, the one behind does not show
   * through the one in front while it fades. A `blur` of the object blurs
   * the same picture. The picture stands at the depth of the object's
   * origin: something solid that is nearer the camera than that covers it,
   * and it is drawn over everything that is further.
   */
  readonly flatten?: boolean
}

AnimationDeclaration

TypeScript
interface AnimationDeclaration<
  Args extends ReadonlyArray<unknown> = ReadonlyArray<unknown>,
> {
  /**
   * The name of the entry, in the options object that is the generator's last
   * parameter, that sets how long the animation takes. With it, the studio
   * can resize a call to the animation by dragging its bar.
   */
  readonly duration?: string
  /**
   * How long a call lasts, worked out from its arguments, for an animation
   * whose length does not depend on what happens inside it. With it, other
   * steps can be placed against the end of a call before it has run.
   */
  readonly lasts?: (...args: Args) => number | undefined
}

Body

TypeScript
type Body<A, Args extends ReadonlyArray<unknown> = []> = (
  ...args: Args
) => Generator<unknown, A, never>

CheckRule

TypeScript
type CheckRule = keyof typeof CHECK_RULES

ClipContext

TypeScript
interface ClipContext<Inputs> {
  /** The values of the clip's inputs. */
  readonly inputs: Inputs
}

ClipOptions

TypeScript
interface ClipOptions<Inputs> {
  /**
   * The clip's own inputs: plain defaults, or controls made with `input`.
   * The studio lists them under the clip's name.
   */
  readonly inputs?: Inputs
}

CollectedVideo

TypeScript
interface CollectedVideo {
  readonly options: VideoOptions<unknown>
  readonly main: unknown
}

CollectionDefinition

TypeScript
interface CollectionDefinition {
  readonly kind: "collection"
  readonly options: CollectionOptions
  /** Its videos, in the order given. */
  readonly members: ReadonlyArray<CollectionMember>
}

CollectionMember

TypeScript
interface CollectionMember {
  readonly name: string
  readonly video: VideoDefinition<never>
}

CollectionOptions

TypeScript
interface CollectionOptions {
  /**
   * In one row, the default, or in a grid of `columns` across, row after
   * row in the members' order.
   */
  readonly layout?: "row" | "grid"
  /** How many videos a grid holds across; three unless given. */
  readonly columns?: number
  /** The space between neighbouring videos, in pixels; 40 unless given. */
  readonly gap?: number
}

Control

TypeScript
interface Control<Value> extends ControlOptions, NumberLimits {
  readonly [CONTROL]: true
  readonly kind: ControlKind
  /** The default: what the input is when nothing overrides it. */
  readonly value: Value
  /** For a choice: what can be chosen. */
  readonly options?: ReadonlyArray<string>
}

ControlKind

TypeScript
type ControlKind =
  | "slider"
  | "number"
  | "color"
  | "text"
  | "choice"
  | "toggle"

ControlOptions

TypeScript
interface ControlOptions {
  /** What the control is called in the studio. Its name when absent. */
  readonly label?: string
  /** A heading the control stands under, with the others of its group. */
  readonly group?: string
}

CustomOptions

TypeScript
interface CustomOptions {
  /**
   * For a function that holds something only while its span runs, such as
   * a constraint: called for every frame outside the span to put back what
   * the function changed.
   */
  readonly rest?: () => void
  /**
   * What the function writes. The properties get tracks: their values are
   * recorded along the step, so the inspector shows them at the playhead
   * and a later tween takes over from where the function left them. The
   * values are recorded when the step starts, from the function's
   * arguments alone. Name everything the function writes: after its span
   * the tracks hold what it left, and the function is not called again.
   */
  readonly writes?: ReadonlyArray<CustomWrite>
  /** A name for the step's bar on the timeline. */
  readonly label?: string
  /**
   * A curve to draw on the bar, to show how the step moves: one of the
   * named easings, or a `cubicBezier(...)`.
   */
  readonly curve?: Easing
}

CustomWrite

TypeScript
interface CustomWrite {
  /** The object the function writes to, as a tween would be given it. */
  readonly target: object
  /** The names of the properties it writes there. */
  readonly keys: ReadonlyArray<string>
  /**
   * The added object the target belongs to, when it is no part of one by
   * itself: the mesh whose material a clipping plane cuts. The properties
   * are then listed under that object, and selecting it shows them.
   */
  readonly of?: object
  /** What the target is called in the property's path. `custom` if absent. */
  readonly name?: string
}

DrawFrame

TypeScript
type DrawFrame = (renderer: never, scene: never, camera: never) => void

Easing

TypeScript
interface Easing {
  (progress: number): number
  readonly easing: EasingData
}

EasingData

TypeScript
interface EasingData {
  readonly name: string
  readonly params: ReadonlyArray<number>
  /**
   * For an easing on remapped time (`warp`): the easing it had before, and
   * the time curve it was remapped by. `params` then holds the part of the
   * time curve the easing covers, as two numbers from 0 to 1.
   */
  readonly inner?: EasingData
  readonly curve?: EasingData
}

FreezeOptions

TypeScript
interface FreezeOptions {
  /** The moment of the steps' own time that is held, in seconds. */
  readonly at: number
  /** How long it is held, in seconds; everything after is that much later. */
  readonly duration: number
}

InertiaOptions

TypeScript
interface InertiaOptions {
  /**
   * How quickly it loses its speed: the time in seconds in which it loses
   * about two thirds of it. Defaults to 0.35.
   */
  readonly timeConstant?: number
  /** A value it does not go below. */
  readonly min?: number
  /** A value it does not go above. */
  readonly max?: number
}

InputValues

TypeScript
type InputValues<Declared> = {
  readonly [Name in keyof Declared]: [Declared[Name]] extends [never]
    ? never
    : Declared[Name] extends Control<infer Value>
      ? Value
      : Declared[Name]
}

Maybe

TypeScript
type Maybe<A = unknown> = Step<A> | null | undefined | false

NumberLimits

TypeScript
interface NumberLimits {
  /** The smallest value. */
  readonly min?: number
  /** The largest value. */
  readonly max?: number
  /** The distance between two values that can be chosen. */
  readonly step?: number
}

Position

TypeScript
interface Position {
  /** Seconds from the start of the group the step is in. */
  readonly time?: number
  /**
   * Seconds after the step before has ended. A negative number starts it
   * that long before the step before ends, so the two overlap; the step
   * before must then be one whose length is known before it runs.
   */
  readonly after?: number
  /** Seconds after the step before has started: 0 starts them together. */
  readonly with?: number
  /** A label of the clip to start at. `offset` is added to its time. */
  readonly label?: string
  /** Seconds added to the label's time; negative is before it. */
  readonly offset?: number
  /**
   * In `all`: seconds before the end of the longest of the other steps,
   * which must be ones whose length is known before they run.
   */
  readonly before?: number
  /**
   * A cut, as `cut` from `framescript/media` made it, to start on one of its
   * parts: the step starts when that part starts, wherever the parts
   * before it have moved it. `offset` is added to the part's start. The
   * cut is in the same group, or has started before it.
   */
  readonly cut?: Step<unknown>
  /** Which part of the cut, counted from 0. Defaults to 0. */
  readonly part?: number
}

Props

TypeScript
type Props<T> = {
  readonly [Key in keyof T as Entry<T[Key]> extends never ? never : Key]?:
    | Entry<T[Key]>
    | ReadonlyArray<Entry<T[Key]>>
} & (T extends Marked<"isObject3D">
  ? {
      readonly opacity?: Entry<number> | ReadonlyArray<Entry<number>>
    }
  : unknown)

PropsOf

TypeScript
type PropsOf<T> = [keyof Props<T>] extends [never] ? never : Props<T>

Random

TypeScript
interface Random {
  /** The next number, from 0 up to but not including 1. */
  (): number
  /** A number between two bounds. */
  range(min: number, max: number): number
  /** One item of a list. */
  pick<T>(items: ReadonlyArray<T>): T
  /** A shuffled copy of a list. */
  shuffle<T>(items: ReadonlyArray<T>): Array<T>
}

Relative

TypeScript
interface Relative {
  readonly relative: "add" | "multiply"
  readonly amount: number
}

SimulateOptions

TypeScript
interface SimulateOptions {
  /** How many numbers the state holds. */
  readonly size: number
  /**
   * The longest time between two steps, in seconds. Defaults to a sixtieth
   * of a second. The steps are spread evenly over the duration, so the
   * last one lands on its end.
   */
  readonly step?: number
  /** The seed of the random numbers the rule is given. Defaults to 1. */
  readonly seed?: number
  /**
   * Fills in the state before the first step. Without it, the state starts
   * as zeros.
   */
  readonly start?: (state: Float32Array, random: Random) => void
  /**
   * Moves the state one step on: it reads the state as the step before left
   * it and writes the new one in place. It may read anything else in the
   * scene, which is where the timeline has put it at that moment.
   */
  readonly rule: (
    state: Float32Array,
    dt: number,
    time: number,
    random: Random
  ) => void
  /**
   * Shows a state: writes it to the objects it stands for. It is called
   * for every frame drawn and must depend only on its arguments.
   */
  readonly draw: (state: Float32Array, since: number) => void
  /**
   * Whether a frame between two steps is given the state blended between
   * them, which suits anything that moves smoothly. With `false`, `draw`
   * is given the state of the step before and, as `since`, the time that
   * has passed after it, which suits a state with things that appear and
   * disappear. Defaults to `true`.
   */
  readonly blend?: boolean
  /**
   * What `draw` writes that a tween could write too. Those properties get
   * tracks, as with `custom`: a segment for each step.
   */
  readonly writes?: ReadonlyArray<CustomWrite>
  /** A name for the step's bar on the timeline. */
  readonly label?: string
  /**
   * For a simulation that shows only while its span runs: called for every
   * frame outside it to put back what `draw` changed. Without it, frames
   * after the span are given the last state.
   */
  readonly rest?: () => void
}

SpringEasing

TypeScript
interface SpringEasing extends Easing {
  /** The settle time in seconds; only set for a spring given by its physics. */
  readonly settle?: number
}

Stage

TypeScript
interface Stage extends VideoSettings {
  /** The root three.js scene. Set fog, environment and background on it. */
  readonly scene: object
  /**
   * A function that draws each frame in place of the one render, for
   * example through an effect composer with bloom or depth of field. Pass
   * parameters are ordinary objects, so they can be tween targets. Left
   * unset, a frame is one render of the scene.
   */
  draw?: DrawFrame
  /**
   * Set this to free what `draw` holds, such as an effect composer's render
   * targets. It is called when the run is replaced by a newer one.
   */
  dispose?: () => void
}

StaggerOptions

TypeScript
interface StaggerOptions {
  /**
   * Seconds between one start and the next: for a grid, for each cell of
   * distance; with `places`, for each scene unit of distance.
   */
  readonly each?: number
  /** Seconds across all starts, divided evenly. Use instead of `each`. */
  readonly amount?: number
  /**
   * Which step starts first. Defaults to `"start"`. A number is the step's
   * index. With `grid`, a pair is a cell as `[row, column]`; with `places`,
   * a pair or a triple is a point in the scene.
   */
  readonly from?:
    | "start"
    | "end"
    | "center"
    | "edges"
    | number
    | readonly [number, number]
    | readonly [number, number, number]
  /** Spreads the starts along an easing instead of evenly. */
  readonly ease?: Easing | ((progress: number) => number)
  /**
   * Says that the steps are the cells of a grid, row after row, as
   * `[rows, columns]`. A step then starts by how far its cell is from the
   * one `from` names, so that a wall of cards starts as a wave.
   */
  readonly grid?: readonly [rows: number, columns: number]
  /**
   * With `grid`: counts the distance along one direction only. `"x"`
   * starts column after column, `"y"` row after row.
   */
  readonly axis?: "x" | "y"
  /**
   * Where each step's thing is, in step order: points, or the objects
   * themselves. A step then starts by how far its place is from the point
   * `from` names, whatever the arrangement.
   */
  readonly places?: ReadonlyArray<StaggerPlace>
}

StaggerPlace

TypeScript
type StaggerPlace =
  | readonly [x: number, y: number, z?: number]
  | {
      readonly position: {
        readonly x: number
        readonly y: number
        readonly z: number
      }
    }

State

TypeScript
interface State<T> {
  /**
   * The value as it is now. Read it where the code runs when the steps
   * play: in a generator, after the step that sets it, or inside `later`.
   */
  readonly value: T
  /**
   * A step that gives the state a new value when it plays.
   *
   * @param next - The value, or a function from the current one.
   * @returns A step that ends at once.
   */
  set(next: T | ((current: T) => T)): Step<void>
}

Step

TypeScript
interface Step<A> {
  readonly [result]?: A
  [Symbol.iterator](): Iterator<unknown, A>
}

Timeline

TypeScript
interface Timeline<Inputs> {
  readonly run: (context: TimelineContext<Inputs>) => Step<void>
}

TimelineContext

TypeScript
interface TimelineContext<Inputs> {
  /** The scene everything is added to, and the scene's settings. */
  readonly stage: Stage
  /** The scene's inputs: its defaults, overridden for this render. */
  readonly inputs: Inputs
}

TweenOptions

TypeScript
type TweenOptions = EasingInput | TweenSettings

TweenSettings

TypeScript
interface TweenSettings {
  /** The easing of each leg. Defaults to `easeOut`. */
  readonly ease?: EasingInput
  /** Seconds to wait before starting, as part of the same span. */
  readonly delay?: number
  /** How many more times to play. `Infinity` belongs inside `background`. */
  readonly repeat?: number
  /** Play every second pass backwards. */
  readonly yoyo?: boolean
  /**
   * Where each keyframe sits, from 0 to 1: one entry for each keyframe,
   * the first included. Evenly spaced by default.
   */
  readonly times?: ReadonlyArray<number>
  /**
   * Starts at the speed the property has at that moment, from the tween
   * before it or one it interrupts, instead of from rest, so that there is
   * no kink. A spring keeps its feel; any other easing is replaced by one
   * that slows from that speed to rest. A spring given by its physics does
   * this without being asked.
   */
  readonly carry?: boolean
}

Value

TypeScript
type Value = number | ReadonlyArray<number>

VideoDefinition

TypeScript
interface VideoDefinition<Inputs = Record<string, never>> {
  readonly options: VideoOptions<Inputs>
  readonly main: Timeline<InputValues<Inputs>>
}

VideoOptions

TypeScript
interface VideoOptions<Inputs> extends VideoSettings {
  readonly inputs?: Inputs
  /**
   * What is done to the scene's whole sound: `{ effects, loudness,
   * ceiling }`.
   */
  readonly sound?: {
    /**
     * The effects the sum of everything is sent through, in order. They
     * are made with the functions of `framescript/sound`.
     */
    readonly effects?: ReadonlyArray<SoundEffect>
    /**
     * How loud the scene is to be as a whole: its integrated loudness in
     * LUFS, from -40 to -5, such as -14. The mix is brought to it by one
     * gain, worked out from the whole of it.
     */
    readonly loudness?: number
    /**
     * The true peak the mix is held under, in decibels against full
     * scale, from -20 to 0, by a limiter that looks ahead. -1 when a
     * loudness is named and no ceiling.
     */
    readonly ceiling?: number
  }
}

VideoSettings

TypeScript
interface VideoSettings {
  readonly width: number
  readonly height: number
  readonly fps: number
}

WarpOptions

TypeScript
interface WarpOptions {
  /**
   * Seconds the warp takes on top of what its steps take. The time curve
   * then covers the longer stretch, so a hold can stop time without the
   * rest having to hurry.
   */
  readonly extend?: number
}