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

/cocosair-2d-subsystems

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Build DragonBones, TiledMap, 2D/3D particles and billboards from runtime data. Use for raw asset strings, missing pixels, MotionStreak or Spine backend limits.

  • 12 files
  • 56.9 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/oahc09/cocosairjs/cocosair-2d-subsystems

Nothing lands on disk. Nothing to clean up.

Fork this Skill

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

referencesspine.md

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

Derived from src/exports/spine.ts, src/cocos/spine/index.ts, src/cocos/spine/skeleton.ts, src/cocos/spine/skeleton-data.ts, src/cocos/spine/skeleton-cache.ts, src/cocos/spine/assembler/simple.ts, src/cocos/spine/lib/spine-core.js, src/cocos/spine/lib/spine-core.d.ts, src/cocos/spine/lib/spine-define.ts, src/cocos/spine/lib/instantiated.ts, src/cocos/spine/lib/air-spine-instantiate-js.ts, cc.config.json module overrides, docs/notes/spine-asset-sourcing.md, docs/notes/port-spine-and-billboard-decisions.md, docs/manual/2d-assets-and-effects.md, docs/reference/web-features.md, build/cocosair.module.js (as of 2026-10-10).

What is actually shipped

Three names reach the application: sp (the namespace alias emitted as index$2 as sp), loadWasmModuleSpine, and through sp the real classes Skeleton, SkeletonData, SpineAnimationCacheMode, SpineMaterialType, SpineSocket, vertexEffectDelegate and the assembler. They resolve in the single export { ... } block of build/cocosair.module.js (currently :161574). Wiring is thin and official: src/exports/spine.ts:3 exports sp, :5 re-exports loadWasmModuleSpine, and src/cocos/spine/index.ts:48-52 re-exports ./skeleton, ./skeleton-data, ./vertex-effect-delegate, ./assembler and ./lib/spine-version, with :54 exporting the spine lib object itself.

That is the whole honest story: the code closure and the type surface are in, the runtime backend is not.

The BLOCKED chain, end to end

  1. The web path has only a wasm/asm backend. src/cocos/spine/lib/spine-core.js is 177 lines containing enums and stubs (MixBlend, MathUtils and friends) with zero occurrences of SpineWasmUtil or wasmUtil; the complete type face, including class wasmUtil, lives in src/cocos/spine/lib/spine-core.d.ts (1498 lines) as a declaration-only artifact. docs/notes/spine-asset-sourcing.md:16-20 records those measurements against the upstream baseline.
  2. Real injection happens only after emscripten instantiation. src/cocos/spine/lib/spine-define.ts:91-94 is overrideClass(wasm), which assigns spine.wasmUtil = wasm.SpineWasmUtil, sets spine.wasmUtil.wasm = wasm and calls spineWasmInit(); :328-329 expose overrideSpineDefine(wasm). Nothing in the default AIR build ever calls them.
  3. The emscripten artifacts are absent from the snapshot. docs/notes/spine-asset-sourcing.md:25-34 checks four sources - cocos/spine/lib/, the repository external/ root, native/external/emscripten/ (the target of the external:emscripten/* virtual modules) and installed @cocos/* packages - and finds no .wasm, .asm.js or .js.mem in any of them.
  4. The build swaps the entry rather than failing. The module override table in cc.config.json maps cocos/spine/lib/spine-instantiate.ts to src/cocos/spine/lib/air-spine-instantiate-js.ts; the four official files spine-instantiate.ts, spine-instantiate-3.8.ts, spine-instantiate-4.2.ts, spine-instantiate-dynamic.ts stay byte-identical in the repository but outside the default closure. Without the override, rollup fails on the missing external file.
  5. The shim degrades every call. src/cocos/spine/lib/air-spine-instantiate-js.ts:26-52 installs spine.wasmUtil as a table whose methods are all noopThenNull (:31-34: warn once, return null) and whose wasm field is { HEAPU8: new Uint8Array(0) } (:36). Stubbed names, :37-50: spineWasmInit, spineWasmDestroy, freeStoreMemory, createStoreMemory, querySpineSkeletonDataByUUID, createSpineSkeletonDataWithJson, createSpineSkeletonDataWithBinary, registerSpineSkeletonDataWithUUID, destroySpineSkeletonDataWithUUID, destroySpineSkeleton, getCurrentListenerID, getCurrentEventType, getCurrentTrackEntry, getCurrentEvent. :54 runs the install at import time; :56-64 exports waitForSpineWasmInstantiation() which optionally applies _CC_SPINE_VERSION through setSpineVersion when the build exposes it, warns and resolves.
  6. The warning exists because the upstream call sites have no guards. src/cocos/spine/skeleton-data.ts:212 calls querySpineSkeletonDataByUUID bare, :224 calls createSpineSkeletonDataWithJson, the binary branch at :226-234 calls createStoreMemory, indexes spine.wasmUtil.wasm.HEAPU8 and calls createSpineSkeletonDataWithBinary; src/cocos/spine/skeleton-cache.ts:173 caches spine.wasmUtil.wasm.HEAPU8 at module scope and :383, :473 call destroySpineSkeleton; src/cocos/spine/assembler/simple.ts:180 touches HEAPU8 directly. The stub object exists precisely so those lines keep type-checking and evaluating.

Observable result: SkeletonData.getRuntimeData() (src/cocos/spine/skeleton-data.ts:199-237) returns null - the cache lookup misses, the json branch gets null, the binary branch writes into a zero-length HEAPU8 view and still gets null - and Skeleton._updateSkeletonData() returns at src/cocos/spine/skeleton.ts:791 (if (!this._runtimeData) return;) with no exception, no log beyond the one warning, and no draw list. The node, the component and the editor-visible properties all behave normally, which is why the failure reads as "the skeleton is silently empty".

loadWasmModuleSpine is not a fix

src/cocos/spine/index.ts:127-136 gates everything on BUILD && LOAD_SPINE_MANUALLY; the flag is declared false in cc.config.json, so the default build returns Promise.resolve() immediately and never reaches waitForSpineWasmInstantiation. Even with the flag on, the awaited function is the shim at :56-64, which resolves after warning. Separately, src/cocos/spine/lib/instantiated.ts:30-32 registers waitForSpineWasmInstantiation on the game post-infrastructure delegate when !JSB && (!BUILD || !LOAD_SPINE_MANUALLY), and src/cocos/game/game.ts:499 declares that delegate with :817 dispatching it, so in a normal web boot the warning fires once during startup whether or not you ever add a skeleton. Treat "awaited the spine loader and it resolved" as no evidence at all; docs/reference/web-features.md:13 is the general rule - source present, bundled and deployed assets are three different claims.

API that is already written against

Useful when an unblocked build arrives, and accurate today for anything that does not touch wasmUtil.

  • sp.SkeletonData (src/cocos/spine/skeleton-data.ts:40-41, registered as sp.SkeletonData) is an Asset. skeletonJsonStr (:54-59) is the raw text, skeletonJson (:65-79) accepts a JSON string or a parsed object, resets the cache, and when the uuid is still empty takes it from value.skeleton.hash (:76-77) - the manual-creation channel, so set the json before anything that keys off the uuid. atlasText (:85-91) resets as well. textures: Texture2D[] (:99) and textureNames: string[] (:108) must be parallel and non-empty, scale (:126) multiplies the runtime data, _nativeAsset (:131-137) is the binary-skeleton payload consumed at :226-234. getSkinsEnum() (:242) and isEmpty() (:307-308) are pure-JS helpers; getRuntimeData(quiet) (:199-237) errors with no textures found! when frames are missing (:204) which is the one failure that does print.
  • sp.Skeleton (src/cocos/spine/skeleton.ts:206, :210) extends UIRenderer, so it batches with the 2D pipeline and inherits srcBlendFactor and dstBlendFactor from src/cocos/2d/framework/ui-renderer.ts:246-247. Cache mode enum SpineAnimationCacheMode is UNSET = -1, REALTIME = 0, SHARED_CACHE = 1, PRIVATE_CACHE = 2 (:75-90); the field default is REALTIME (:234) and defaultCacheMode is :487-493. premultipliedAlpha defaults to true (:228, accessor :500-503). loop defaults to true (:515), timeScale (:522-527) multiplies against the module constant timeScale = 1.0 (:64). defaultSkin (:217) and defaultAnimation (:219) are applied in _updateSkeletonData in skin-then-animation order (:800-811), and the socket helper attaches at :816.
  • Playback and inspection surface, all in src/cocos/spine/skeleton.ts: animation getter and setter (:625-636, the setter being setAnimation(0, value, this.loop)), getState() (:697), setAnimation (:945), addAnimation (:999), findAnimation (:1023), getCurrent (:1037), clearAnimation (:753), clearAnimations (:764), setSkin (:1059), setSlotsRange (:879), getAttachment (:902), setAttachment (:920), getTextureAtlas (:935), findBone (:1468), findSlot (:1485), setMix (:1502), querySockets (:1621), isAnimationCached (:1377), setAnimationCacheMode (:1392), invalidAnimationCache (:1449), setToSetupPose (:1436), setBonesToSetupPose (:1422), setSlotsToSetupPose (:1408), debug toggles debugSlots (:582), debugBones (:596), debugMesh (:610), customMaterial (:643). Lifecycle: __preload pulls the runtime data (:674-681), onEnable registers with SkeletonSystem (:705-710), onDisable (:715-719), onDestroy (:721-728).
  • Supporting enums: ATTACHMENT_TYPE with REGION = 0, BOUNDING_BOX = 1, MESH = 2, SKINNED_MESH = 3 (src/cocos/spine/index.ts:74-79), SpineMaterialType.COLORED_TEXTURED = 0 and TWO_COLORED = 1 (src/cocos/spine/skeleton.ts:127-128), and AnimationEventType START = 0 through EVENT = 5 (src/cocos/spine/index.ts:87-122).
  • Events use the 3.x listener family, not the 2.x registrar. registerSpineEventHandler and unregisterSpineEventHandler match nothing in src/cocos/spine; the entry points are setStartListener (src/cocos/spine/skeleton.ts:1781), setInterruptListener (:1791), setEndListener (:1801), setDisposeListener (:1811), setCompleteListener (:1821), setEventListener (:1831) and the six per-track variants setTrackStartListener (:1842) through setTrackEventListener (:1904), each taking a spine.TrackEntry that only the real backend can hand out. _ensureListener (:1768-1774) allocates the TrackEntryListeners and passes its id to the instance, onDestroy removes it (:723), realtime dispatch reads this._listener.start at :1121-1122 and complete / end at :1154-1157, and the cached path binds through src/cocos/spine/skeleton-cache.ts:257-268. So no spine callback can fire today, and the reason is the missing backend rather than a missing method.

Unblock checklist

docs/notes/spine-asset-sourcing.md:43-47 states it in order: obtain the emscripten artifacts matching the baseline (per version, spine.wasm.js, spine.wasm, spine.asm.js, spine.js.mem), place them as deployed assets next to the bundle instead of inside it, then delete the spine override rule and src/cocos/spine/lib/air-spine-instantiate-js.ts to return to official behaviour, and only then add a spine-basic example with the json, atlas and texture trio loaded by loadRemote plus animation, skin and event assertions and a three-browser matrix. :51-56 records the owner closure: the same external-binary gap as the physics and webgpu backends, closed as "product surface verified, example surface not delivered", with the shim kept deliberately. docs/notes/port-spine-and-billboard-decisions.md:5 is the ruling itself. docs/manual/2d-assets-and-effects.md carries the subsystem table row that says export surface present, browser evidence none.

Nothing above changes if you set LOAD_SPINE_MANUALLY to true in a private build; it only moves which warning you get.

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 DragonBones assets from raw JSON strings",
  "TiledMap edits do not redraw or resolve objects",
  "particles compute but render no pixels; createAirParticleSystem 3D emitters/trails CPU/GPU",
  "Spine skeleton stays blank without an error",
  "billboard or motion trail is invisible"
]
owns
[
  "dragonbones",
  "tiledmap",
  "particle-2d",
  "billboard",
  "motion-streak",
  "spine-limits"
]
not_for
[
  "basic UI layout and controls -> cocosair-ui-2d",
  "3D skeleton deformation -> cocosair-skinning-morph",
  "remote asset caching -> cocosair-assets"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "配置 Spine、DragonBones、TiledMap、二维粒子和 Billboard 的原生运行时契约。用于资源构造、空白画面或子系统能力边界问题。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-2d-subsystems