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 aTweenwhose chain methods each push an action onto_actionsand returnthis;start()(:329) unions them into one_finalActionand registers it with the ActionManager. TheAnimationcomponent (src/cocos/animation/animation-component.ts:52) is@executionOrder(99)(:49) and delegatesplay/stop/pause/resume/crossFadeto an internal cross-fade controller. Both are advanced byTweenSystem/the director, not by user rAF (src/cocos/tween/tween-system.ts:76-87). play()returnsvoid, not a state.Animation.play(name?)(src/cocos/animation/animation-component.ts:209) early-returns when there is no name and nodefaultClip(:212-215), otherwise callscrossFade(name, 0)(:218). To get the live state usegetState(name), which is declared to returnAnimationStatebut actually returnsnullfor a missing name (:275-281) - the declared type omits| null.playOnLoadis false by default and plays instart(), notonLoad().playOnLoad = false(src/cocos/animation/animation-component.ts:133); when true,start()cross-fades the default clip (:179-183). Callingplay()yourself beforeapp.run(scene)is reset by the activation flow, so play from a componentstart()(docs/manual/animation-system.md:78).- Setting
wrapModeresets playback. TheAnimationState.wrapModesetter (src/cocos/animation/animation-state.ts:119) assignsthis.time = 0(:123) and setsrepeatCounttoInfinityfor a Loop mask or1otherwise (:125-129). Configure wrap before first play or when you intend to restart; never set it per frame.glTFclips default toWrapMode.NormalandGLTFInstance.setAnimationLoopmutates this same setter (docs/manual/animation-system.md:83-87). WrapModeis a numeric bitmask enum reachable only asAnimationClip.WrapMode.AnimationClip.WrapModeis a static alias of the enum (src/cocos/animation/animation-clip.ts:104); the enum itself (src/cocos/animation/types.ts:30-67) isNormal=1,Loop=2,ShouldWrap=4,Clamp=8,PingPong=22,Reverse=36, plusLoopReverse/PingPongReverse. There is no top-levelWrapModeexport.- Track classes are namespace-only.
VectorTrack,QuatTrack,RealTrack,ColorTrack,SizeTrack,ObjectTrack,TrackandTrackPathare exported fromsrc/cocos/animation/animation.ts:35-41into the frozenanimationnamespace object (build/cocosair.module.js, currently:57866-57889), and the single runtimeexport { ... }block (build/cocosair.module.js, currently:161574) containsanimationbut none of those class names. Import them asanimation.VectorTrack/animation.TrackPath; a bareimport { VectorTrack }fails at compile and run time. - A clip is code-first constructible.
new AnimationClip()(src/cocos/animation/animation-clip.ts:158) withname,duration,wrapMode, thenaddTrack(track)(:310, returns the new index);TrackPath.toProperty(name)(src/cocos/animation/tracks/track.ts:76) builds the property path, andtoHierarchy/toComponent/toElement(:98/:109/:87) address nested targets.tracksCount(:180),getTrack(:298),removeTrack(:323) andclearTracks(:333) manage the track list. - Tween node-state binding is on by default.
_isBindNodeState = true(src/cocos/tween/tween.ts:109); with aNodetarget, deactivating the node auto-pauses, reactivating auto-resumes, and destroying auto-removes the tween, so you do not need a manualstop()for lifecycle leaks. Opt out withbindNodeState(false)(:127). reverseTimehas 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 embeddedbyrelative-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 bareby(...).reverseTime()path is browser-verified; the embedded-sequence branch is not.createStepClockis a test driver with a hard dual-clock guard.begin()callsgame.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 runsdirector.tick(dt)and resolves on the nextDirector.EVENT_AFTER_DRAW(:99-100), rejecting afterstepTimeoutMs(default 2000) rather than silently succeeding (:89-92);end()callsgame.resume()(:103-107). Defaults areframeRate=60,stepTimeoutMs=2000(:63-64).- Pose graph and marionette are not published.
marionetteandprocedural-animationare 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 defaultAIR_FEATURESarray (tools/build/build.cjs:24-44), andAnimationGraphis 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,tweencarries a strongframe-diffbinding (calls 95, export-wrapper),Animation.playisverified/executed(prototype,no-runtime-error),AnimationClipandAnimationClip.WrapModeareverified(export-wrapper / data-property), andTween.reverseTimeisverifiedonly for the bare path (no-runtime-error, calls 1).createStepClockhas ZERO apiProof bindings in that file and nodocs/evidence/w08-step-clock.jsonexists on disk; its proof is the passing probe attools/debug/probes/step-clock-probe/main.jsrun bytools/verify/step-clock.cjs, not a committed evidence record (step-clock.md).