Index of every page on this site: llms.txt
All skills
oahc09 avatar

/cocosair-animation-tween

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Animate tweens and AnimationClip tracks with one step clock. Use to loop a sequence on a target, reverseTime, clean up playback or diagnose unavailable pose graphs.

  • 9 files
  • 52.5 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/oahc09/cocosairjs/cocosair-animation-tween

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescontracts.md

≈1.5k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Derived from the cocosair-animation-tween skill and its canonical docs/source pointers; reorganized on 2026-10-11. Source annotations below identify repository inputs, not files guaranteed to ship to npm consumers.

Contracts

  • Two animation routes, one clock. tween(target) (src/cocos/tween/tween.ts:922) returns a Tween whose chain methods each push an action onto _actions and return this; start() (:329) unions them into one _finalAction and registers it with the ActionManager. The Animation component (src/cocos/animation/animation-component.ts:52) is @executionOrder(99) (:49) and delegates play/stop/pause/resume/crossFade to an internal cross-fade controller. Both are advanced by TweenSystem/the director, not by user rAF (src/cocos/tween/tween-system.ts:76-87).
  • play() returns void, not a state. Animation.play(name?) (src/cocos/animation/animation-component.ts:209) early-returns when there is no name and no defaultClip (:212-215), otherwise calls crossFade(name, 0) (:218). To get the live state use getState(name), which is declared to return AnimationState but actually returns null for a missing name (:275-281) - the declared type omits | null.
  • playOnLoad is false by default and plays in start(), not onLoad(). playOnLoad = false (src/cocos/animation/animation-component.ts:133); when true, start() cross-fades the default clip (:179-183). Calling play() yourself before app.run(scene) is reset by the activation flow, so play from a component start() (docs/manual/animation-system.md:78).
  • Setting wrapMode resets playback. The AnimationState.wrapMode setter (src/cocos/animation/animation-state.ts:119) assigns this.time = 0 (:123) and sets repeatCount to Infinity for a Loop mask or 1 otherwise (:125-129). Configure wrap before first play or when you intend to restart; never set it per frame. glTF clips default to WrapMode.Normal and GLTFInstance.setAnimationLoop mutates this same setter (docs/manual/animation-system.md:83-87).
  • WrapMode is a numeric bitmask enum reachable only as AnimationClip.WrapMode. AnimationClip.WrapMode is a static alias of the enum (src/cocos/animation/animation-clip.ts:104); the enum itself (src/cocos/animation/types.ts:30-67) is Normal=1, Loop=2, ShouldWrap=4, Clamp=8, PingPong=22, Reverse=36, plus LoopReverse/PingPongReverse. There is no top-level WrapMode export.
  • Track classes are namespace-only. VectorTrack, QuatTrack, RealTrack, ColorTrack, SizeTrack, ObjectTrack, Track and TrackPath are exported from src/cocos/animation/animation.ts:35-41 into the frozen animation namespace object (build/cocosair.module.js, currently :57866-57889), and the single runtime export { ... } block (build/cocosair.module.js, currently :161574) contains animation but none of those class names. Import them as animation.VectorTrack / animation.TrackPath; a bare import { VectorTrack } fails at compile and run time.
  • A clip is code-first constructible. new AnimationClip() (src/cocos/animation/animation-clip.ts:158) with name, duration, wrapMode, then addTrack(track) (:310, returns the new index); TrackPath.toProperty(name) (src/cocos/animation/tracks/track.ts:76) builds the property path, and toHierarchy/toComponent/toElement (:98/:109/:87) address nested targets. tracksCount (:180), getTrack (:298), removeTrack (:323) and clearTracks (:333) manage the track list.
  • Tween node-state binding is on by default. _isBindNodeState = true (src/cocos/tween/tween.ts:109); with a Node target, deactivating the node auto-pauses, reactivating auto-resumes, and destroying auto-removes the tween, so you do not need a manual stop() for lifecycle leaks. Opt out with bindNodeState(false) (:127).
  • reverseTime has a documented open defect on the embedded branch. reverseTime(embedTween?) (src/cocos/tween/tween.ts:715) reverses the previous action when called bare, but wrapping an embedded by relative-move sequence lands on the wrong end point (docs/reference/api-scenario-gap-matrix.md:483-485, GAP-T1: start x=3, offset +2, expected x=3, observed x=5). The bare by(...).reverseTime() path is browser-verified; the embedded-sequence branch is not.
  • createStepClock is a test driver with a hard dual-clock guard. begin() calls game.pause() and is idempotent (src/air/step-clock.ts:80-84); step(dt = 1/frameRate) first asserts the game is paused and throws an Error containing "dual clock" if it is not (:68-75, :85-86), then runs director.tick(dt) and resolves on the next Director.EVENT_AFTER_DRAW (:99-100), rejecting after stepTimeoutMs (default 2000) rather than silently succeeding (:89-92); end() calls game.resume() (:103-107). Defaults are frameRate=60, stepTimeoutMs=2000 (:63-64).
  • Pose graph and marionette are not published. marionette and procedural-animation are declared feature units with empty module lists (src/cc.config.json:59-70) and are virtual-module-overridden to empty stubs when their flags are off (:437-450); neither is in the default AIR_FEATURES array (tools/build/build.cjs:24-44), and AnimationGraph is absent from the export block (build/cocosair.module.js, currently :161574). An owner ruling keeps them out of the default release (docs/notes/pose-graph-notes.md:151-155).
  • Browser evidence, stated plainly. In docs/evidence/examples-verified.json, tween carries a strong frame-diff binding (calls 95, export-wrapper), Animation.play is verified/executed (prototype, no-runtime-error), AnimationClip and AnimationClip.WrapMode are verified (export-wrapper / data-property), and Tween.reverseTime is verified only for the bare path (no-runtime-error, calls 1). createStepClock has ZERO apiProof bindings in that file and no docs/evidence/w08-step-clock.json exists on disk; its proof is the passing probe at tools/debug/probes/step-clock-probe/main.js run by tools/verify/step-clock.cjs, not a committed evidence record (step-clock.md).

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at ed38648. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
layer
subsystem
All 1 allowed tools
Read Edit Write Bash
Other metadata
compatibility
Cocos AIR source checkout or installed cocosair.js package. Browser rendering requires WebGL 2; source tooling requires Node.js >=18. Use the host-provided tools and user-authorized workspace.
when_to_use
[
  "move or rotate a node over time",
  "a clip plays once instead of looping",
  "a tween will not reverse",
  "track classes fail to import by name",
  "step deterministic frames without a second live clock"
]
owns
[
  "tween",
  "animation-clip",
  "track-path",
  "wrap-mode",
  "step-clock",
  "pose-graph-limits"
]
not_for
[
  "glTF loading and instance setup -> cocosair-gltf",
  "skeletal binding and morph weights -> cocosair-skinning-morph",
  "scalar easing calculations -> cocosair-math"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "使用 AnimationClip、Animation 和 tween,管理播放模式、组合及单一时钟。用于动画播放、补间回收或确定性步进问题。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-animation-tween