logo
PinballCamera

pinball

PinballCamera

Listens toPinballTable
1
Unlock

Install with the CLI:

bjs download PinballCamera

PinballCamera

Locks a fixed, table-fitted pinball view on top of a sibling ArcCamera.

What it does

Sits next to an ArcCamera on the same entity and takes over its framing. Each frame (until it succeeds once) it detaches the ArcRotateCamera's pointer controls and overrides its FOV — retrying because ArcCamera attaches controls lazily. It also listens for pinballTable.resized and recomputes the fit distance so the whole table frames neatly at any dimensions, padded by marginFactor. The fit is written to ArcCamera's distance (not the raw radius), so a tuning panel can still override zoom.

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 PinballCamera

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 PinballCamera
    bjs download PinballCamera

    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
{
  "entities": {
    "Table": {
      "components": {
        "PinballTable": { "width": 16, "depth": 33.2 }
      }
    },
    "Camera": {
      "components": {
        "ArcCamera": {
          "controlsEnabled": false,
          "distance": 55,
          "alpha": 1.5708,
          "beta": 0.55,
          "minBeta": 0.55,
          "maxBeta": 0.55
        },
        "PinballCamera": { "fov": 1.15, "lockControls": true, "marginFactor": 1.55 }
      }
    }
  }
}

Props

  • fov (number, default 1.15) — vertical FOV in radians applied to the active camera; also drives the fit math.
  • lockControls (boolean, default true) — if true, disables the ArcRotateCamera's pointer controls.
  • marginFactor (number, default 1.55) — multiplier on the computed fit distance, adding headroom around the table.

Events

  • Listens for pinballTable.resized — recomputes and applies the fit distance whenever the table changes.

Dependencies

ArcCamera — provides the camera handle and the distance field this drives; attach on the same entity. PinballTable — supplies the dimensions to frame against (via pinballTable.resized).

Notes

  • Does nothing on its own — there must be an active ArcRotateCamera for the lock and fit to grab.

More like this

ArcCamera
PinballTable
Bumper
CameraFollow
CameraState6DOF
ChaseCamera6DOF
ChaseCameraTarget
Flipper
MouseHole
PinballBuilder
PinballBuilderInput
PinballLayout
Plunger
ShooterCamera
Spinner

Was this page helpful?

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

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search