logo
CabinetLink

interaction

CabinetLink

Free

Install with the CLI:

bjs download CabinetLink

Click a cabinet to walk over to it; double-click to start its game.

What it does

CabinetLinkComponent sits on a cabinet (a Mesh GLB or a MeshPrimitive box). CabinetLinkSystem listens for pointer clicks on the canvas and ray-picks through the renderer adapter. A single click emits firstpersoncamera.goto with a spot in front of the machine, so a FirstPersonCamera player walks there. A second click on the same cabinet within a short window emits cabinetlink.launch with the cabinet's game key and route. The host app decides what launching means; this component never touches a router.

With launchDistance set, a confirming click from too far away emits cabinetlink.launch.outofrange instead, and the walk the first click started keeps going. With interactive: false the cabinet is scenery: clicks still walk you over, but nothing launches.

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 CabinetLink

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

    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": {
    "Player": {
      "tags": ["player"],
      "components": {
        "FirstPersonCamera": {
          "position": [0, 6],
          "yaw": 3.1416,
          "eyeHeight": 1.7
        }
      }
    },
    "Cabinet": {
      "components": {
        "MeshPrimitive": {
          "primitive": "box",
          "width": 1,
          "height": 2,
          "depth": 1,
          "position": [0, 1, 0]
        },
        "Obstacle": { "halfWidth": 0.5, "halfDepth": 0.5 },
        "CabinetLink": {
          "game": "frogger",
          "title": "Frogger",
          "facing": 0,
          "standoff": 1.4,
          "launchDistance": 2.5
        }
      }
    }
  }
}

Props

  • game (string) — the game key this cabinet fronts.
  • route (string, default /games/<game>/) — where a launch should go.
  • title (string, default = game) — a label for HUDs.
  • standPoint ([x, z], optional) — exact spot to walk to. Without it the player stands standoff metres in front of the cabinet along facing.
  • standoff (number) — metres in front of the cabinet to stand.
  • facing (radians) — the cabinet's yaw; match the mesh's Y rotation. 0 faces +Z.
  • interactive (boolean, default true) — false means clicks walk you over but never launch.
  • launchDistance (number, optional) — how close the player must be for a double-click to launch.

Events

  • emits cabinetlink.focused — a cabinet was single-clicked.
  • emits firstpersoncamera.goto { x, z, yaw } — walk the player to the cabinet.
  • emits cabinetlink.launch { game, route, ... } — start the game.
  • emits cabinetlink.launch.outofrange { entityId, game, title, distance, launchDistance } — the player was too far away.
  • listens firstpersoncamera.created — learns the walking camera's handle, to read where the player stands.

Dependencies

Mesh, MeshPrimitive — it picks against whichever one the cabinet carries. Pair it with FirstPersonCamera, which does the walking.

More like this

Was this page helpful?

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

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search