logo
ArcCamera

core

ArcCamera

Listens toMeshPrimitive
Free

Install with the CLI:

bjs download ArcCamera

ArcCamera

An orbit-style camera that frames the scene and smoothly follows a target entity.

What it does

ArcCamera is the shared camera substrate most arcade scenes build on: it creates a single arc-rotate camera through the renderer adapter and keeps it pointed at the right thing each frame. When follow is true it tracks the target entity (reading the target's live mesh position via the adapter); when false it centres restTarget (if set) or holds a captured "free" look point that targetOffset can pan. The System owns optional idle auto-rotation and locks zoom for fixed-camera games where controls are disabled. It listens for meshprimitive.created to learn target mesh handles, and emits camera lifecycle/motion events on the EventBus so sibling systems can react.

Use it in a scene

A scene is just data — a list of entities, each with its components. At startup the SceneLoader turns this JSON into a live world; edit the file and reload to rebuild it.

Fastest path

bjs download scene ArcCamera

Pulls this exact scene into your project and runs it — no copy-paste. Add --all to grab the components and assets it needs too.

Or build it from scratch with the bjs CLI:

  1. 1Scaffold a project
    npm create @babylonjsmarket/arcade@latest my-game

    World, renderer, and dev server — ready to run.

  2. 2Install dependencies
    cd my-game && npm install
  3. 3Add ArcCamera
    bjs download ArcCamera

    Copies its source into src/ so the scene resolves.

    First time? Run bjs login once.

  4. 4Paste the scene into src/scenes/arcade-room.ts and run
    npm run dev

    SceneLoader builds the world from the JSON; reload to rebuild.

JSON
{
  "Target": {
    "components": {
      "MeshPrimitive": {
        "primitive": "sphere",
        "diameter": 1.5,
        "position": [0, 1, 0]
      }
    }
  },
  "Camera": {
    "components": {
      "ArcCamera": {
        "target": "Target",
        "follow": true,
        "distance": 14,
        "minDistance": 5,
        "maxDistance": 40,
        "alpha": 1.5708,
        "beta": 1.0
      }
    }
  }
}

Props

  • target (string) — entity kept centred while follow is true.
  • restTarget (string) — entity centred when follow is false; if omitted, turning follow off leaves the camera free (holds its last look point, pannable).
  • follow (boolean, default true) — track target each frame, or fall back to restTarget/free mode.
  • distance (number, default 15) — orbit radius; also the locked radius when controlsEnabled is false.
  • minDistance / maxDistance (number, defaults 5 / 50) — zoom limits.
  • minBeta / maxBeta (number, defaults 0.1 / derived) — vertical orbit limits; maxBeta defaults near horizon unless allowBelowGround.
  • allowBelowGround (boolean, default false) — when true, widens the default maxBeta so the camera can drop below ground level.
  • alpha (number, default π/2) — initial horizontal orbit angle.
  • beta (number, default π/3) — initial vertical orbit angle.
  • inertia / panningInertia (number, defaults 0.9) — motion damping.
  • wheelPrecision (number, default 50) — mouse-wheel zoom sensitivity.
  • angularSensibility (number, default 1000) — mouse-orbit sensitivity.
  • speed (number, default 1) — camera movement speed.
  • targetOffset (Vec3, default [0,0,0]) — pans the view as an offset from the centre point; leave at zero to keep the followed target dead-centre.
  • autoRotate (boolean, default false) — slowly orbit when idle.
  • autoRotateSpeed (number, default 0.5) — idle auto-rotation rate.
  • controlsEnabled (boolean, default true) — when false the renderer detaches mouse controls (fixed-camera games); zoom is then driven by distance.

Events

  • emits arccamera.created when the camera is built, arccamera.rotated on orbit change, and arccamera.zoomed on radius change (arccamera.moved / arccamera.target.changed are defined for sibling use).
  • listens for meshprimitive.created to capture target mesh handles for following.

Dependencies

MeshPrimitive — the follow target needs a mesh so the System can read its world position (and resolve its live handle straight off the target's MeshPrimitiveComponent).

Notes

  • Renderer access is entirely through the adapter (this.world.renderercreateArcCamera, setCameraTarget, getCameraAngles, etc.), so the System stays renderer-agnostic.
  • The live camera handle is runtime-only (not serialized) and exposed via component.handle, backed by a WeakMap so it survives entity pooling/parking.
  • Following resolves the target's mesh handle directly from its MeshPrimitiveComponent, so it works even if the meshprimitive.created event fired before this System was ready.
  • With controlsEnabled false the radius is pinned to distance every frame, so the control panel owns zoom and it can't drift.

More like this

MeshPrimitive
AiPilot
Animation
Asteroid
Bullet
CameraFollow
CameraState6DOF
ChaseCamera6DOF
ChaseCameraTarget
DirectionalLight
EnemySpawner
EnvironmentTexture
FreighterCar
FreighterChain
FreighterHead
GameConfig
Health
HemisphericLight
Jump
KeyboardInput
KeyboardMover
Lifetime
LineOfSight
MachineGun
Mesh
Missile
MissileLauncher
MissionDirector
MouseInput
Movement
Obstacle
ObstacleField
OilBlob
Parts
Physics
PinballCamera
PlayerInput
PlayerWalkAnimator
RespawnTimer
RoundReset
Score
Shadow
ShipLoadout
ShooterCamera
SkeletonAnimator
SpaceShooterBullet
SpaceShooterHealth
SpaceShooterScore
Transform6DOF
TwinStickEnemy
WaveDirector
Waypoint
WaypointTrack

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search