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

/cocosair-physics

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Choose builtin, cannon or Box2D physics; wire rigid bodies, colliders and raycasts. Use for missing gravity, trigger filters, backend limits or material error 9642.

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

Nothing lands on disk. Nothing to clean up.

Fork this Skill

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

referencescommon-mistakes.md

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

Derived from the cocosair-physics 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] Calling createAirApp({}) and expecting gravity or stacking

Wrong:

const app = await createAirApp({ canvas: '#GameCanvas' });   // physics omitted
const body = node.addComponent(RigidBody);
body.type = ERigidBodyType.DYNAMIC;   // node floats forever: builtin has no integrator

Correct:

const app = await createAirApp({ canvas: '#GameCanvas', physics: 'cannon' });
const body = node.addComponent(RigidBody);
body.type = ERigidBodyType.DYNAMIC;   // gravity, falling and stacking are cannon backend facts

The omitted option normalizes to 'builtin' (src/air/app-config.ts:45), and builtin is a discrete collision detector, not a simulator (src/cocos/physics/cocos/builtin-world.ts:50-55); the sixty-step free-fall comparison is docs/notes/physics-3d-notes.md:376.

[HIGH] Setting only the collision group and losing every pair

Wrong:

crateCollider.setGroup(2);   // other colliders still mask 1 -> this body matches nothing

Correct:

crateCollider.setGroup(2);
otherColliders.forEach((c) => c.setMask(0xffffffff));   // mask half must accept the new group

Each pair is skipped unless group AND mask passes in both directions (src/cocos/physics/cocos/builtin-world.ts:183-186), and collisionMask defaults to PhysicsGroup.DEFAULT (docs/notes/physics-3d-notes.md:56-63); the silent zero-trigger state was measured in all three browsers.

[MEDIUM] Asking for a WASM backend that is not shipped

Wrong:

const app = await createAirApp({ canvas: '#GameCanvas', physics: 'ammo' });
import { PhysicsSystem } from 'cocosair';   // then expecting physx or box2d-wasm too

Correct:

const app = await createAirApp({ canvas: '#GameCanvas', physics: 'cannon' });   // the only two ids

AirPhysicsBackend is 'builtin' | 'cannon' (src/air/physics-backend.ts:21) and anything else throws AIR_E_PHYSICS_BACKEND (src/air/app-config.ts:46); ammo/bullet, physx and box2d-wasm import Emscripten assets that exist neither in the upstream snapshot nor in @cocos/box2d (docs/notes/physics-asset-sourcing.md:11-17).

[MEDIUM] Reading 3D backend identity from the flat selector export

Wrong:

import { selector } from 'cocosair';
console.log(selector.id);   // 'box2d' - this is the 2D selector, the name is taken

Correct:

console.log(PhysicsSystem.PHYSICS_BUILTIN, PhysicsSystem.instance.physicsWorld.constructor.name);
// true, 'BuiltInWorld' - runtime identity, not the flat export

Both namespaces export a member named selector and the aggregate flattens to the 2D one (docs/notes/physics-3d-notes.md:40-45); the singleton also does not exist until the app resolves (src/cocos/physics/framework/physics-system.ts:912).

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
[
  "dynamic bodies do not fall or stack",
  "triggers stop firing after changing collision groups",
  "choose builtin or cannon before startup",
  "query 2D bodies with raycasts or overlap tests",
  "physics material error 9642 appears"
]
owns
[
  "builtin-physics",
  "cannon",
  "box2d",
  "collision-filter",
  "rigid-body",
  "physics-queries"
]
not_for
[
  "camera pixel-to-ray conversion -> cocosair-camera",
  "node hierarchy and transforms -> cocosair-scene-graph",
  "non-physics startup errors -> cocosair-application"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "选择 builtin 或 cannon,并区分碰撞检测、运动积分和二维 Box2D 的能力。用于刚体、触发器、射线查询或物理后端问题。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-physics