From 594835863000a82028ab157eac21dd8d80d72d29 Mon Sep 17 00:00:00 2001 From: Will Eastcott Date: Thu, 11 Jun 2026 15:25:02 +0100 Subject: [PATCH 1/6] docs: restructure Cameras section into multi-page, workflow-agnostic docs Following the pattern established by the shadows page rewrite (#1037), this restructures the Cameras section from a single Editor-focused page into a full multi-page section with Engine/Editor/React/Web Components tabs throughout: - index.md: rewritten as a section overview covering camera creation, render target clearing, and links to all subpages - projection.md (new): perspective vs orthographic, FOV, clip planes, aspect ratio, and frustum culling - tone-mapping.md (new): per-camera tone mapping curves, gamma correction, and physically based exposure - multiple-cameras.md (new): priority, viewports, layers, camera stacking, and render targets - camera-controls.md (new): the engine's camera-controls.mjs script (orbit/fly/pan) across all workflows - screen-and-world.md (new): screenToWorld/worldToScreen patterns All engine facts verified against engine source. Japanese translations mirrored for all pages. Sidebar updated with the new pages. Co-Authored-By: Claude Fable 5 --- .../graphics/cameras/camera-controls.md | 112 ++++++++++++++++++ docs/user-manual/graphics/cameras/index.md | 91 +++++++++++--- .../graphics/cameras/multiple-cameras.md | 103 ++++++++++++++++ .../graphics/cameras/projection.md | 94 +++++++++++++++ .../graphics/cameras/screen-and-world.md | 50 ++++++++ .../graphics/cameras/tone-mapping.md | 95 +++++++++++++++ .../graphics/cameras/camera-controls.md | 112 ++++++++++++++++++ .../user-manual/graphics/cameras/index.md | 91 +++++++++++--- .../graphics/cameras/multiple-cameras.md | 103 ++++++++++++++++ .../graphics/cameras/projection.md | 94 +++++++++++++++ .../graphics/cameras/screen-and-world.md | 50 ++++++++ .../graphics/cameras/tone-mapping.md | 95 +++++++++++++++ sidebars.js | 7 +- 13 files changed, 1062 insertions(+), 35 deletions(-) create mode 100644 docs/user-manual/graphics/cameras/camera-controls.md create mode 100644 docs/user-manual/graphics/cameras/multiple-cameras.md create mode 100644 docs/user-manual/graphics/cameras/projection.md create mode 100644 docs/user-manual/graphics/cameras/screen-and-world.md create mode 100644 docs/user-manual/graphics/cameras/tone-mapping.md create mode 100644 i18n/ja/docusaurus-plugin-content-docs/current/user-manual/graphics/cameras/camera-controls.md create mode 100644 i18n/ja/docusaurus-plugin-content-docs/current/user-manual/graphics/cameras/multiple-cameras.md create mode 100644 i18n/ja/docusaurus-plugin-content-docs/current/user-manual/graphics/cameras/projection.md create mode 100644 i18n/ja/docusaurus-plugin-content-docs/current/user-manual/graphics/cameras/screen-and-world.md create mode 100644 i18n/ja/docusaurus-plugin-content-docs/current/user-manual/graphics/cameras/tone-mapping.md diff --git a/docs/user-manual/graphics/cameras/camera-controls.md b/docs/user-manual/graphics/cameras/camera-controls.md new file mode 100644 index 00000000000..9ab831e0499 --- /dev/null +++ b/docs/user-manual/graphics/cameras/camera-controls.md @@ -0,0 +1,112 @@ +--- +title: Camera Controls +description: Add orbit, fly, and pan navigation to any camera with the engine's ready-made camera-controls script, with mouse, touch, and gamepad support. +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +Most applications need some way for the user to move the camera. Rather than writing this from scratch, you can use the `CameraControls` script that ships with the engine at [`scripts/esm/camera-controls.mjs`](https://github.com/playcanvas/engine/blob/main/scripts/esm/camera-controls.mjs). It provides production-quality navigation with a single script: + +* **Orbit** — left mouse drag rotates around a focus point, right mouse drag pans, and the mouse wheel zooms. +* **Fly** — WASD keys move the camera freely while the mouse looks around. +* **Touch and gamepad** — multi-touch gestures and gamepad input are supported out of the box. + +Attach the script to a camera entity: + + + + +```javascript +// Load the script (here from the CDN; you can also bundle it with your app) +const asset = new pc.Asset('camera-controls', 'script', { + url: 'https://cdn.jsdelivr.net/npm/playcanvas/scripts/esm/camera-controls.mjs' +}); +app.assets.add(asset); +app.assets.load(asset); + +asset.ready(() => { + // Attach it to the camera entity + camera.addComponent('script'); + camera.script.create('cameraControls', { + properties: { + focusPoint: new pc.Vec3(0, 1, 0) + } + }); +}); +``` + +If you build your app with a bundler, you can import the script class directly instead: + +```javascript +import { CameraControls } from 'playcanvas/scripts/esm/camera-controls.mjs'; + +camera.addComponent('script'); +camera.script.create(CameraControls); +``` + + + + +Add `camera-controls.mjs` to your project as a script asset (copy it from the [engine repository](https://github.com/playcanvas/engine/blob/main/scripts/esm/camera-controls.mjs)). Then select your camera entity, add a [Script Component](/user-manual/editor/scenes/components/script) and add the **cameraControls** script to it. The script's attributes can then be tuned in the Inspector. + + + + +```jsx +import { CameraControls } from 'playcanvas/scripts/esm/camera-controls.mjs'; +import { Script } from '@playcanvas/react/components'; + + + +