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

/cocosair-math

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Compute vectors, matrices, quaternions, colors and easing. Use for out-first math, frozen Vec3.UP errors, transform composition, rotation units or Mat4.invert.

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

Nothing lands on disk. Nothing to clean up.

Fork this Skill

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

referencesquick-start.md

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

Derived from the cocosair-math 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, Quat, Mat4, Color, math, easing, lerp, clamp01 } from 'cocosair'; // page alias, not the package name

const app = await createAirApp({ canvas: '#GameCanvas' }); // canvas must exist before this import
const scene = new Scene('Main');
const camNode = new Node('Main Camera');
scene.addChild(camNode);
camNode.setPosition(new Vec3(0, 1.5, 5));
camNode.setRotationFromEuler(-15, 0, 0);   // DEGREES; composed by Quat.fromEuler in YZX order
const camera = camNode.addComponent(Camera);
camera.projection = Camera.ProjectionType.PERSPECTIVE;
const box = new Node('Box');
scene.addChild(box);

const scratch = new Vec3();                       // owned by this scope only, so in-place writes are safe
const dir = Vec3.normalize(scratch, Vec3.RIGHT);  // statics write the first argument; Vec3.RIGHT is only READ
const rot = new Quat();
const local = new Mat4();
Quat.fromEuler(rot, 0, 30, 0);                    // degrees in, quaternion out
Mat4.fromSRT(local, rot, scratch, Vec3.ONE);      // scale -> rotation -> translation, i.e. out = T * R * S
box.matrix = local;                               // the Node.matrix setter decomposes it back with Mat4.toSRT

const tint = new Color(255, 128, 0, 255);         // channels are 0-255 bytes, not 0-1 floats
tint.fromHEX('#ff8000');
console.log(tint.toCSS('rgba'));                  // "rgba(255,128,0,1.00)"

const y = lerp(0, 2, easing.cubicInOut(clamp01(0.5))); // easing is a top-level namespace, not math.ease*
box.setPosition(dir.x * 2, y, dir.z);
console.assert(math.equals(y, 1), 'midpoint of the cubic curve maps to the midpoint of the range');

app.run(scene);
</script>

Entry choice, the importmap alias and the install are owned by cocosair-project-setup; createAirApp/run by cocosair-application.

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
[
  "normalize or project a direction",
  "compose or decompose a transform matrix",
  "choose quaternion rotation and angle units",
  "convert colors or calculate easing and deterministic random",
  "writing a frozen vector constant throws"
]
owns
[
  "vector-math",
  "matrix-transforms",
  "quaternion",
  "color-values",
  "easing",
  "deterministic-random"
]
not_for
[
  "screen and world camera conversion -> cocosair-camera",
  "native tween playback -> cocosair-animation-tween",
  "node parenting and lifecycle -> cocosair-scene-graph"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "使用 Cocos 数学类型进行向量、矩阵、四元数、颜色和插值计算。用于坐标变换、旋转、颜色处理、缓动或确定性随机。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-math