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.

referencesparticle-3d.md

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

Code First native 3D particles

Use createAirParticleSystem for emitters, lifetime, CPU trails and native CPU/GPU particle processors without Editor assets. It returns the original ParticleSystem; do not wrap it in another scene/player abstraction. ParticleSystem2D and its plist payload are a separate route. For fixed GPU shape transitions use morph fields.

These are current SDK helpers, not an assumption about older npm versions. Check the consumer's exports/declarations. The AIR aggregate exports the native classes; there is no independent particle AIR_FEATURES entry to turn on. Current focused browser coverage is WebGL2, not a full WebGPU or release matrix.

Configure before activation

After createAirApp(), with a Scene/Camera prepared:

import { createAirParticleSystem, ParticleSpace, ParticleShapeType } from 'cocosair.js';

const particles = createAirParticleSystem({
    parent: scene,
    configure(p) {
        p.capacity = 256;
        p.startLifetime.constant = 2;
        p.startSizeX.constant = 0.15;
        p.startSpeed.constant = 1.5;
        p.rateOverTime.constant = 40;
        p.simulationSpace = ParticleSpace.World;
        p.shapeModule!.enable = true;
        p.shapeModule!.shapeType = ParticleShapeType.Sphere;
        p.trailModule!.enable = true;
    },
});

configure runs synchronously on an inactive, unparented Node before native onLoad/onEnable. Do not activate/parent that node yourself. The helper creates native module objects and nonzero neutral defaults that otherwise came from serialized Editor data. It cleans a failed configuration and returns the original component on success. playOnAwake defaults true; set false in configure for explicit playback.

Use native CurveRange, GradientRange, Burst, and module properties. For a size curve, enable sizeOvertimeModule, set size.mode = ParticleCurveMode.Curve, then fill size.spline.assignSorted([[0,{value:1}], [1,{value:0}]]). CPU supports the native lifecycle modules, texture animation, noise/limits and trails; no per-particle Node or second player is needed.

useGPU:true requests native analytical GPU particles and curve textures. Unsupported devices throw AIR_PARTICLE_GPU_UNSUPPORTED; GPU trail/noise/velocity-limit configuration throws AIR_PARTICLE_GPU_MODULE. GPU mode is not arbitrary compute or a reusable force solver. Do not silently drop an unsupported module or hot-switch processors while preserving a live population; stop/clear first. Runtime GPU curve edits need particles.processor.updateMaterialParams() to repack textures.

Spaces, state and ownership

Local particles move with their emitter; World particles keep emitted world positions. Do not apply the emitter transform again to already-world coordinates. Custom space has no acceptance claim here. CPU trails may start disabled and be enabled later; the next native update initializes their owner/material/buffers before simulation. Verify actual trail geometry on that frame, not just an enable flag. Configure capacity/lifetime before activation because they affect native trail allocation.

pause() retains particles/time, play() resumes, stopEmitting() drains the population, and stop() clears it. play() after stop starts emission again. The component has no dispose handle: destroy particles.node and allow native deferred destruction. Original shared textures/materials/meshes remain caller-owned; do not destroy a shared asset once per component. There is no separate asset registration JSON requirement.

Set materials through setSharedMaterial(material,0): builtin-particle for CPU, builtin-particle-gpu for GPU. renderer.particleMaterial is not an activation-free substitute for configuring shared materials. Keep the selected shader/processor compatible. Deleting a material before its renderers detach can break other consumers.

Checkout example /particles-3d/ covers spray, embers, particle smoke, rain and snow; it is not volumetric smoke. tools/verify/particles.cjs checks real CPU/GPU pixels, size curves, local/world positions, delayed trail enable, pause/drain/replay, GPU buffer/texture deletion and reentry. A timer/count alone cannot prove rendering or release. Local Chromium subsets are not universal frame-rate, compositor or release evidence.

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