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.

referencescontracts.md

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

Contracts

  • SkinnedMeshRenderer extends MeshRenderer (src/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts:49) is the only skinning component; _updateModelParams leaves the model undrawable until mesh, skeleton and skinningRoot all exist (:154-163), which is why the documented order assigns while enabled = false and enables last (docs/manual/skinning-code-first.md:13-21). The skeleton and skinningRoot setters both run _refreshBinding, validating before the old binding is replaced and then rebuilding submodels because bindSkeleton swapped the buffers or textures underneath them (:67-71, :82-87, :165-178, src/cocos/3d/models/skinning-model.ts:140-170).
  • Joint paths, never short names: Skeleton documents joints as paths relative to skinningRoot (src/cocos/3d/assets/skeleton.ts:31-32, :55-61) and every consumer resolves them through root.getChildByPath(path) (src/cocos/3d/models/skinning-validation.ts:13, src/cocos/3d/models/skinning-model.ts:161), while joints[i] stays index-paired with bindposes[i] (src/cocos/3d/assets/skeleton.ts:52-53, :63-73). AIR_E_SKINNING_JOINT_PATH throws only for a weighted joint whose path does not resolve (src/cocos/3d/models/skinning-validation.ts:11-18), the error carries code, resource, node, joint, path (:18), and an unweighted joint yields a null bone-space bound and is skipped (src/cocos/3d/assets/mesh.ts:754-756, docs/manual/skinning-code-first.md:9).
  • buildSkeletonTree(root, jointPaths) records bindposes[i] = root.getChildByPath(path).worldMatrix.clone().invert() and throws on a missing path (src/air/utils/skeleton-tree.ts:30-37, :31-34); realtime mode then multiplies the live joint world matrix by that inverse each frame (src/cocos/3d/models/skinning-model.ts:208-216), so the captured matrix is what makes the rest pose restorable. Node.worldMatrix updates itself first, so a detached rig still captures correctly (src/cocos/scene-graph/node.ts:1910-1913).
  • restoreBindPose(root, skeleton) inverts each bindpose back to world, converts to local against the parent's current world matrix and applies SRT, walking depth-first over a sorted copy of the index map (src/air/utils/restore-bind-pose.ts:33-36, :43-55); nothing is written back to the asset, so ordering is preserved (docs/guides/skinned-model.md:30, test/smoke/smoke-06-skeleton-utils.test.ts:81-84).
  • Two pose transports, one switch: the constructor defaults to BakedSkinningModel (src/cocos/3d/skinned-mesh-renderer/skinned-mesh-renderer.ts:101), setUseBakedAnimation(val, force) rebuilds the live model when it changes (:129-145), and _tryBindAnimation re-decides the mode from the root association (:197-202), so the call is a rebuild entry, not a persistent lock (docs/manual/skinning-code-first.md:44). Baked mode reads the pose from the clip's uploaded joint texture and never from the live joint transforms (src/cocos/3d/models/baked-skinning-model.ts:166-180, :114-125); realtime mode is the one that samples nodes (src/cocos/3d/models/skinning-model.ts:208-216), which is the difference the mode switch actually buys you.
  • Capacity is about the slots written, not the skeleton size: bindSkeleton compares UBOSkinning.JOINT_UNIFORM_CAPACITY (src/cocos/rendering/define.ts:653, fallback 30 at :600) against joints.length and takes the 256-wide realtime texture above it (src/cocos/3d/models/skinning-model.ts:143-145, :153, :84), and validateSkinningCapacity checks each jointMaps slot against that capacity, throwing AIR_E_SKINNING_CAPACITY (src/cocos/3d/models/skinning-validation.ts:25-41, docs/manual/skinning-code-first.md:54).
  • Mesh.morphRendering is a lifecycle field: null by default (src/cocos/3d/assets/mesh.ts:368), created inside initialize() only when struct.morph exists (:412, :571-573), which renderingSubMeshes triggers lazily (:359-362) and the mesh setter triggers first (src/cocos/3d/framework/mesh-renderer.ts:487-492, :1233-1249). Morph weights are a silent contract: setWeights(weights, subMeshIndex) returns without effect on an out-of-range index or a target-count mismatch (:695-706), setWeight likewise (:720-731), values only reach the GPU through the morph instance (:1309-1310), initial values come from the asset (:1260-1287), and reassigning mesh re-inits them (:491, reset note :475-479). enableMorph is a bare flag (:526-532, default true at :564); the instance is only built from the mesh setter and onLoad (:492, :577-583), so toggling it after binding does nothing until the mesh is reassigned.
  • Skinning and morph compose rather than compete: SkinningModel and BakedSkinningModel both extend MorphModel (src/cocos/3d/models/skinning-model.ts:97, src/cocos/3d/models/baked-skinning-model.ts:60), and _createModel substitutes MorphModel only when the type is still the base Model (src/cocos/3d/framework/mesh-renderer.ts:971-987), so a skinned sub-mesh keeps its morph macro patches (src/cocos/3d/assets/morph-rendering.ts:157-171).
  • The deprecated alias is real and shipped: SkinningModelComponent is SkinnedMeshRenderer re-exported with a cclegacy registration and a cc.SkinningModelComponent class alias (src/cocos/3d/skinned-mesh-renderer/deprecated.ts:32-34), alongside SkinningModelUnit (:39-41) and BatchedSkinningModelComponent (:46-48); the bundle's single export block carries all of them plus SkinnedMeshRenderer, Skeleton, Mesh, buildSkeletonTree and restoreBindPose (build/cocosair.module.js, currently :161574), while MorphRendering, createMorphRendering, Morph and AttributeName do not appear there, so morph data must be authored as a plain literal.
  • Evidence, stated plainly: under candidate fingerprint 2f089f6ce25eaccd (docs/evidence/examples-verified.json, file-level measuredAt 2026-10-04T05:52:32.537Z) the ids skinned-animation, gltf-skin, gltf-morph and mesh-morph-bounds are result: PASS, and examples/skinned-animation/main.js:195, :210-213, :273 are the browser-exercised build, bind and restore sequence; docs/manual/skinning-code-first.md:46 records 96 access-order combinations drawn in three browsers, and :31 limits that coverage to the tested single joint and the built-in effects.

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