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

/cocosair-camera

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Configure Camera projection, viewports, framing and screen/world conversion. Use for split-screen, pointer rays, wrong screenToWorld results or AIR_E_ORTHO_WIDTH.

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

Nothing lands on disk. Nothing to clean up.

Fork this Skill

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

referencesquick-start.md

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

Derived from the cocosair-camera 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.

Environment: the HTML examples using /build/ require the AIR development server and an existing bundle. In npm applications use the installed package name and the application's own bundler/server; resolve docs and declarations from that package. Do not copy repository URLs into a consumer app. Browser behavior is verified only for explicitly tested snippets and candidates.

Quick Start

<canvas id="GameCanvas"></canvas>
<script type="importmap">
  { "imports": { "cocosair": "/build/cocosair.module.js" } }
</script>
<script type="module">
import { createAirApp, Scene, Node, Camera, MeshRenderer, Material, Layers, Vec3, Color, primitives, utils, frameObject } from 'cocosair'; // page alias, not the package name

const app = await createAirApp({ canvas: '#GameCanvas' }); // canvas must exist before this import
const scene = new Scene('Main');

const camNode = new Node('Main Camera');
scene.addChild(camNode);
camNode.setPosition(new Vec3(0, 2.2, 6.5));
camNode.lookAt(new Vec3(0, 0.6, 0));              // orientation follows the node; lookAt once at this position

const camera = camNode.addComponent(Camera);       // component owns the render-scene Camera (camera.camera)
camera.projection = Camera.ProjectionType.PERSPECTIVE;
camera.fov = 45;                                  // degrees, vertical axis by default
camera.near = 0.1;
camera.far = 1000;
camera.clearFlags = Camera.ClearFlag.SOLID_COLOR;
camera.clearColor = new Color(28, 36, 52, 255);
camera.priority = 0;                              // lower priority draws first

const modelRoot = new Node('Model');              // frameObject measures this node's MeshRenderer bounds
modelRoot.layer = Layers.Enum.DEFAULT;            // must be contained in camera.visibility or it is culled
scene.addChild(modelRoot);
modelRoot.setPosition(new Vec3(0, 0.6, 0));
const renderer = modelRoot.addComponent(MeshRenderer);
renderer.mesh = utils.createMesh(primitives.box({ width: 1, height: 1, length: 1 }));
const material = new Material();
material.initialize({ effectName: 'builtin-standard' });
renderer.material = material;

frameObject(camera, modelRoot);                  // puts the camera on the boundsCenter->cameraPos ray at the fit distance and lookAt(boundsCenter)
app.run(scene);                                  // frameObject ran before run, so it used aspect = 1; see Contracts
</script>

Entry choice, the importmap alias and install are owned by cocosair-project-setup; createAirApp/run by cocosair-application; node transform and layer bits by cocosair-scene-graph.

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
[
  "switch perspective and orthographic views",
  "fit a loaded model in view",
  "stack cameras or create split-screen views",
  "convert pointer pixels to a world ray",
  "screenToWorld results or orthographic width are wrong"
]
owns
[
  "projection",
  "viewport",
  "camera-framing",
  "screen-world",
  "camera-order",
  "oblique-plane"
]
not_for
[
  "register node layer bits -> cocosair-scene-graph",
  "offscreen render targets -> cocosair-rendering",
  "physics collision queries -> cocosair-physics"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "配置相机投影、视口、可见层和多相机顺序,并进行坐标转换、射线拾取与模型取景。用于相机配置或屏幕与世界坐标问题。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-camera