Documentation
    Preparing search index...

    A §15 tween: the builder and the playing object in one.

    Configuration methods (to, from, ease, delay, repeat, yoyo, speed, authority, onComplete) return this and are legal only before Tween.play; calling one afterwards throws, because start values, bindings, and property claims are all fixed at play time and a late change would silently mean something different than it reads. Playback controls (play, pause, resume, advance, seek, stop) return this too, so §15's chain reads exactly as written.

    localTime                              (seconds, advanced by `advance`)
      ├── delay ──┤├── duration ──┤├── duration ──┤ …  repeat + 1 cycles
    

    advance(dt) adds dt * speed. Time inside the delay produces progress 0 (the start pose is written, so from() is visible immediately). Beyond the delay, local time folds into [0, duration] once per cycle; with Tween.yoyo every odd cycle is reflected, so the tween walks back to its start value. repeat(Infinity) makes the total duration infinite and the tween never finishes.

    A completing advance clamps local time to exactly the total duration, which is why a tween lands exactly on its end value at t = duration rather than wherever the last delta happened to overshoot to.

    Tween.play claims every property it animates. Claiming one another tween already holds emits a development warning and revokes the earlier tween's claim on that property only — the earlier tween keeps animating everything else, and is effectively stopped only if it loses all of its properties. Tween.stop and natural completion release claims.

    Properties inside a node's transform are additionally gated on §42 authority: see Tween.authority for how the node is found, and the class body for what a refusal does.

    Index
    • get finished(): boolean

      Whether an advance has carried local time to Tween.totalDuration.

      A playback fact, not a time fact: Tween.seek never sets or clears it, so scrubbing a finished tween back inspects its earlier values without pretending it is running again, and scrubbing an unfinished tween past its end does not silently consume the completion its next advance owes. Restarting a finished tween is deliberately not offered — build a new tween, or let a Timeline (§16) own repeated playback.

      Returns boolean

    • get totalDuration(): number

      delay + duration × (repeat + 1) seconds — the local time at which the tween finishes. Infinity for repeat(Infinity), and just the delay for a zero-duration tween (where 0 × Infinity would otherwise be NaN).

      Returns number

    • Advances local time by deltaSeconds × speed and writes the resulting values. Called by the fixed-step AnimationSystem (plan P4-1); a tween never advances itself and never reads a clock (§33).

      A no-op unless the tween is "running" and unfinished. The advance that reaches Tween.totalDuration clamps local time to it, writes the exact end values, frees the properties it held, and fires Tween.onComplete — in that order, so the callback observes the final pose.

      Parameters

      • deltaSeconds: number

      Returns this

      FourError INVALID_APPLICATION_STATE — the delta is negative or non-finite.

    • Declares which node's §42 authority gates this tween's transform writes.

      The inference is honest about its limits. When the tween's target is a Node, the node is found automatically and nothing needs declaring. But §15's own example animates node.position — a bare Vector3 — and a math object carries no back-reference to the node that owns it, so animate(node.transform.position) cannot infer the node and its transform writes are ungated unless this method is called:

      animate(node.transform.position).to({ x: 10 }, 1).authority(node).play();
      

      A declared node gates only the properties that actually resolve inside its transform (identity-tested against transform and its authored members); declaring a node for a tween that touches no transform of that node is inert rather than an error, since a tween may legitimately animate a mix.

      Parameters

      Returns this

      FourError INVALID_APPLICATION_STATE — called after Tween.play.

    • Seconds of local time to consume before progress starts. The start pose is written throughout the delay, so a delayed tween holds its start values rather than leaving the property wherever it was.

      Parameters

      • seconds: number

      Returns this

      FourError INVALID_APPLICATION_STATE — called after Tween.play, or the delay is negative or non-finite.

    • Overrides the start values that would otherwise be captured from the live properties at Tween.play.

      Values are cloned at play, so the objects passed here stay the caller's. Paths may be a subset of Tween.to's; anything omitted is still captured live. A path that is not in to is a mistake and throws at play (it cannot be caught here — from may legally be chained before to).

      Parameters

      Returns this

      FourError INVALID_APPLICATION_STATE — called after Tween.play.

    • Callback for the advance that finishes the tween. It fires exactly once — after the final values are written and the property claims released — and never for Tween.seek, matching §16's rule that "seek and scrubbing suppress" event callbacks.

      Parameters

      • callback: () => void

      Returns this

      FourError INVALID_APPLICATION_STATE — called after Tween.play.

    • Resolves bindings, captures start values, claims properties (§16), and starts playback at local time 0 — writing the start pose immediately, so Tween.from takes effect without waiting for an advance.

      A no-op on a tween that is not "idle": replaying is seek(0) plus Tween.resume, and silently re-capturing start values from a half-animated property would make playback depend on when play was called rather than on local time.

      Returns this

      FourError INVALID_APPLICATION_STATE — Tween.to was never called; a Tween.from path is not among the animated properties; or a supplied value's type does not match the bound property's.

      FourError from createBinding — a path does not resolve, or its value type has no adapter.

    • Number of additional cycles after the first, so repeat(1) plays twice and repeat(0) (the default) plays once. Infinity never finishes.

      Parameters

      • count: number

      Returns this

      FourError INVALID_APPLICATION_STATE — called after Tween.play, or the count is not a non-negative integer or Infinity.

    • Positions playback at localTimeSeconds and writes the values for that time. Pure: seeking to the same time twice writes identical values, and seeking backwards is as valid as forwards (§16 scrubbing).

      Neither Tween.state nor Tween.finished changes — a paused tween stays paused, a finished one stays finished — so a seek is only ever an evaluation, never a playback decision. onComplete therefore never fires from a seek (§16: "seek and scrubbing suppress them by default"); seeking past the end does not consume the completion that the next advance still owes.

      A "stopped" tween repositions but writes nothing: it released its properties. A "finished" one still writes, which is what scrubbing means; if another tween has since claimed those properties, that scrub competes with it unwarned — stop a finished tween you intend to keep scrubbing past.

      Parameters

      • localTimeSeconds: number

      Returns this

      FourError INVALID_APPLICATION_STATE — the tween has never been played (no start values exist yet), or the time is negative or non-finite.

    • Multiplier applied to every Tween.advance delta.

      Must be positive and finite. Reverse playback is deliberately not spelled speed(-1): §16 lists "reversing" as a Timeline requirement, and a negative multiplier here would make "the advance that finishes the tween" ambiguous. Scrub backwards with Tween.seek instead.

      Parameters

      • multiplier: number

      Returns this

      FourError INVALID_APPLICATION_STATE — called after Tween.play, or the multiplier is not finite and > 0.

    • Stops the tween and releases its property claims, leaving every animated value exactly where the last write put it. A stopped tween never writes again, and the properties it held are free for another tween to claim without a §16 conflict warning.

      A no-op on an "idle" tween, which holds nothing.

      Returns this

    • Declares the properties to animate and the cycle length in seconds (§7a — never milliseconds).

      Callable once. A second call throws rather than guessing whether it meant "add properties" or "append a second segment": sequencing is §16's Timeline, not a tween's job.

      Parameters

      Returns this

      FourError INVALID_APPLICATION_STATE — called after Tween.play, called twice, or given a negative or non-finite duration.

    • Reflects every odd cycle, so a repeating tween walks back to its start value instead of jumping. Easing is applied after the reflection, which is what makes an eased yoyo symmetric in shape.

      Parameters

      • enabled: boolean = true

      Returns this

      FourError INVALID_APPLICATION_STATE — called after Tween.play.