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

/cocosair-skinning-morph

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Bind skeletons, restore bind poses and drive morph weights. Use for realtime/baked deformation, AIR_E_SKINNING_JOINT_PATH or AIR_E_SKINNING_CAPACITY.

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

Nothing lands on disk. Nothing to clean up.

Fork this Skill

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

referencescommon-mistakes.md

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

Derived from the cocosair-skinning-morph 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.

Common Mistakes

[HIGH] Writing joint short names instead of full paths

Wrong:

skeleton.joints = ['bone0', 'bone1', 'bone2'];    // node names, not root-relative paths
renderer.skeleton = skeleton;                     // AIR_E_SKINNING_JOINT_PATH on joint 1

Correct:

const skeleton = buildSkeletonTree(armature, ['bone0', 'bone0/bone1', 'bone0/bone1/bone2']);
renderer.skeleton = skeleton;                     // paths resolve with getChildByPath from the root

Skeleton.joints is documented as paths relative to skinningRoot (src/cocos/3d/assets/skeleton.ts:31-32) and every consumer resolves them that way (src/cocos/3d/models/skinning-validation.ts:13); the rule comes from the recorded V0.1 regression in docs/guides/skinned-model.md:9-12.

[HIGH] Editing skeleton nodes after opting into baked animation

Wrong:

renderer.setUseBakedAnimation(true);
bone1.setRotationFromEuler(0, 0, 30);   // nothing moves: the pose comes from the clip texture

Correct:

renderer.setUseBakedAnimation(false);   // realtime mode samples the live joint nodes each frame
bone1.setRotationFromEuler(0, 0, 30);   // keep baked mode only if a clip drives the pose instead

setUseBakedAnimation swaps the model type and rebuilds it (src/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts:129-145), a baked model binds its pose to the texture uploaded from an AnimationClip (src/cocos/3d/models/baked-skinning-model.ts:166-180), and only realtime mode multiplies live joint world matrices by the bindpose (src/cocos/3d/models/skinning-model.ts:208-216, manual note docs/manual/skinning-code-first.md:35, :44).

[MEDIUM] Expecting restoreBindPose to reorder the joints array

Wrong:

restoreBindPose(armature, skeleton);
skeleton.joints.sort((a, b) => a.split('/').length - b.split('/').length);  // bindposes now misaligned

Correct:

restoreBindPose(armature, skeleton);   // the depth sort runs over a copy of the indices
const path0 = skeleton.joints[0];      // still paired with skeleton.bindposes[0]

The helper sorts a joints.map(...) copy so ancestors restore before descendants (src/air/utils/restore-bind-pose.ts:33-36) and writes nothing back to the asset (:36-56); docs/guides/skinned-model.md:30 states the pairing and test/smoke/smoke-06-skeleton-utils.test.ts:81-84 pins it.

[MEDIUM] Treating a morph weight call as proof it applied

Wrong:

renderer.setWeights([0.5], 0);   // sub-mesh 0 has two targets: silent no-op
renderer.enableMorph = false;
renderer.enableMorph = true;     // nothing rebuilt the morph instance

Correct:

const targets = mesh.struct.morph.subMeshMorphs[0].targets.length;
const weights = new Array(targets).fill(0); weights[0] = 0.5;
renderer.setWeights(weights, 0);  // length must equal that sub-mesh's target count
renderer.mesh = mesh;             // reassign to rebuild the instance after toggling enableMorph

setWeights returns early on a bad index or a length mismatch (src/cocos/3d/framework/mesh-renderer.ts:697-703), values only upload through the instance built by _watchMorphInMesh (:1233-1249, :1309-1310), and that runs only from the mesh setter and onLoad (:492, :577-583), so enableMorph alone (:526-532) rebuilds nothing.

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
[
  "build or bind a skeleton from joint paths",
  "a skinned mesh stays in its rest pose",
  "bone edits stop working in baked mode",
  "restore the captured bind pose",
  "morph weight changes appear to be ignored"
]
owns
[
  "skeletal-skinning",
  "joint-paths",
  "bind-pose",
  "baked-pose",
  "joint-capacity",
  "morph-weights"
]
not_for
[
  "glTF loading and decoder deployment -> cocosair-gltf",
  "clip playback and tweens -> cocosair-animation-tween",
  "generic mesh buffer authoring -> cocosair-primitives-mesh"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "配置骨骼路径、蒙皮、绑定姿态、Morph 权重和烘焙动画。用于骨骼变形、绑定姿态恢复或 Morph 问题。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-skinning-morph