Cocos AIR camera
Stop once you can answer the task. Do not read another same-topic reference for the same question.
Scope: Camera projection, framing, viewports, draw order and screen/world conversion.
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
- Add a camera or change projection
- Fit a loaded model into view
- Split-screen or picture-in-picture views
- Choose camera draw order and visible layers
- Convert pointer pixels to a world ray
- Clip a mirror or water view at an oblique plane
Exact API and symptom mappings: triggers.
Contracts
Use component conversion methods and left-bottom framebuffer pixels. worldToScreen and screenToWorld use different depth conventions; prefer a ray for picking. Camera visibility must include the node layer.
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] Use framebuffer pixels without dividing by devicePixelRatio.
- [HIGH] Component and render-camera argument orders differ.
- [MEDIUM] Draw order follows priority, not creation order.
Read relevant wrong/right examples before implementation.
Reference map
- Frame or clip a view? - Projection and bounds
- Stack multiple views? - Priority, clear and layers
- Pointer to world? - Pixels, rays and depth