Cocos AIR primitives and mesh authoring
Stop once you can answer the task. Do not read another same-topic reference for the same question.
Scope: Procedural shape geometry, Mesh layouts, attribute access and renderer hooks.
Environment: use package imports in apps; source paths require an AIR checkout. See context.
Quick Start
For complete setup and teardown, read Quick Start.
Siblings: direct dependencies; reuse loaded skills.
Triggers
- Generate primitive shapes without Creator assets
- Validate AIR_E_PRIMITIVE_DESCRIPTOR and segment limits
- Transform or wireframe geometry on the CPU
- Build a Primitive asset or custom Mesh struct
- Read or copy vertex attributes and indices
- Update dynamic mesh buffers after creation
- Set a renderer instanced attribute
Exact API and symptom mappings: triggers.
Contracts
Geometry is not a renderer: attach a MeshRenderer and material under a visible camera. Validate descriptor limits and vertex/index layouts; keep mesh ownership explicit.
Read references/contracts.md only when the task needs exact option rules, limits, error behavior or source annotations. Prefer the topic references below for a narrower question.
Common Mistakes
- [HIGH] Convert IGeometry with utils.createMesh before assigning mesh.
- [HIGH] Descriptor shapes are only box, sphere, cylinder and cone.
- [HIGH] primitives.cone takes radius, height, then optional options.
- [MEDIUM] Descriptor includeNormal does not strip a channel.
- [MEDIUM] Use AttributeName for mesh attribute reads.
Read relevant wrong/right examples before implementation.
Reference map
- Which shape API? - Signatures and defaults
- How are buffers laid out? - Formats and reads
- Why is a shape rejected? - Descriptor limits
- Dynamic mesh missing or stale? - Creation, updates and visibility