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.

referencesquick-start.md

≈1.1k 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.

Environment: the HTML examples using /build/ require the AIR development server and an existing bundle. In npm applications use the installed package name and the application's own bundler/server; resolve docs and declarations from that package. Do not copy repository URLs into a consumer app. Browser behavior is verified only for explicitly tested snippets and candidates.

Quick Start

<canvas id="GameCanvas"></canvas>
<script type="importmap">
  { "imports": { "cocosair": "/build/cocosair.module.js" } }
</script>
<script type="module">
import { createAirApp, Scene, Node, Camera, Vec3, Color, Component,
         tween, Animation, AnimationClip, animation, createStepClock } from 'cocosair';

const app = await createAirApp({ canvas: '#GameCanvas' });   // #GameCanvas must exist before this import
const scene = new Scene('anim');
const camNode = new Node('Main Camera'); scene.addChild(camNode);
camNode.setPosition(new Vec3(2.4, 3.0, 7.4)); camNode.lookAt(new Vec3(0, 1.3, 0));
const camera = camNode.addComponent(Camera);
camera.clearFlags = Camera.ClearFlag.SOLID_COLOR; camera.clearColor = new Color(18, 22, 30, 255);

const node = new Node('Dancer'); scene.addChild(node); node.setPosition(new Vec3(0.6, 1.0, 0));

// 1) code-first tween: one chain == one sequence; call is zero-duration, to interpolates
tween(node)
    .to(1.2, { position: new Vec3(2.2, 1.0, 0) })   // props are a plain object; no string-path form
    .to(0.8, { position: new Vec3(2.2, 2.2, 0) })
    .repeatForever()
    .start();                                        // start() registers the union with the ActionManager

// 2) code-first clip: track classes live ONLY under the `animation` namespace
const clip = new AnimationClip();
clip.name = 'orbit'; clip.duration = 2.0;
clip.wrapMode = AnimationClip.WrapMode.Loop;         // WrapMode is a static on AnimationClip
const track = new animation.VectorTrack();
track.path = new animation.TrackPath().toProperty('position');
track.channels()[0].curve.assignSorted([[0, 0], [1, 0.9], [2, 0]]);
clip.addTrack(track);
const anim = node.addComponent(Animation);
anim.defaultClip = clip;
class Starter extends Component {                    // play() before app.run gets reset by activation
    start() { anim.play(clip.name); }
}
node.addComponent(Starter);

app.run(scene);

// 3) deterministic stepping for evidence: pause the real clock, then step one frame at a time
const clock = createStepClock();                     // frameRate 60, stepTimeoutMs 2000 by default
clock.begin();                                       // game.pause(): stops rAF, render, business clock, audio
for (let i = 0; i < 90; i++) { await clock.step(1 / 60); }   // throws if the real clock is running
clock.end();                                         // game.resume()
</script>

Per-frame geometry updates

Use this section for continuous mesh deformation in an existing app and scene. Component.update(dt) receives seconds from the native pacer. The example assumes an attached motionNode and an initialized dynamic mesh with matching typed-array geometry; its deformation changes one vertex while retaining the existing layout:

// Component is imported from the same AIR main entry as the rest of the app.
let elapsed = 0;
const restY = geometry.positions[1];
class MeshMotion extends Component {
    update(dt) {
        elapsed += dt;
        geometry.positions[1] = restY + Math.sin(elapsed) * 0.25;
        mesh.updateSubMesh(0, geometry);
    }
}
motionNode.addComponent(MeshMotion);

Keep the existing app/scene/camera and native loop. Read the tween or clip recipes when the task actually uses those APIs. For mesh setup, capacities and renderer synchronization use the dynamic-mesh checklist. During controlled browser checks use the step-clock contract; restore native pacing with end() afterward. Disabling or destroying the motion component stops its updates; mesh/material ownership remains with their creator.

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