logo

Babylon.js Market

PinballBuilder

pinball

PinballBuilder

1
Unlock

Install with the CLI:

bjs download PinballBuilder

PinballBuilder

Data-driven, in-game placer that spawns fully-wired pinball elements on request.

What it does

Listens for a family of pinballBuilder.add* events and spawns a complete entity at the requested table coordinates — MeshPrimitive + Shadow + Physics plus the matching behavior component — then emits pinballBuilder.entityAdded. It supports bumpers, walls, rails (elevated wires), ramps (tilted floor segments), spinners, and mouse-holes/saucers. It also drives freehand drawing: pinballBuilder.setDrawMode toggles draw mode (echoed via pinballBuilder.drawModeChanged), and pinballBuilder.drawPath smooths a raw pointer polyline (Ramer–Douglas–Peucker simplify → Catmull-Rom spline → uniform arc-length resample) and chains one rail/wall segment per interval to turn a freehand line into a clean curved track.

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 PinballBuilder

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

    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 }
      }
    },
    "Builder": {
      "tags": ["builder"],
      "components": {
        "PinballBuilder": { "defaultBumperPoints": 250, "defaultBumperDiameter": 1.78 }
      }
    }
  }
}

Props

  • defaultBumperPoints (number, default 250) — points awarded by a newly spawned pop-bumper when the request omits points.
  • defaultBumperDiameter (number, default 1.78) — diameter of a newly spawned pop-bumper when the request omits diameter.

(Per-kind id counters and the drawMode/drawKind flags are runtime state, not serialized inputs.)

Events

  • Emits pinballBuilder.entityAdded{ entityId, kind } after each spawn.
  • Emits pinballBuilder.drawModeChanged{ enabled, kind } after draw mode toggles.
  • Listens for pinballBuilder.addBumper, addWall, addRail, addRamp, addSpinner, addMouseHole — each with { x, z, ... } to spawn that element.
  • Listens for pinballBuilder.setDrawMode{ enabled, kind? }.
  • Listens for pinballBuilder.drawPath{ points: [{x,z}, ...], kind, ... }.

Dependencies

MeshPrimitive — the visible geometry of every spawned element. Bumper, Spinner, MouseHole — the behavior components attached to the matching spawns. PinballTable — the table coordinate space the requests are placed into. (Shadow + Physics from the arcade package are attached at spawn time via dynamic import.)

Notes

  • Element classes import from arcade lazily (dynamic import) so the file stays declaration-only on the surface and physics isn't pulled until something is spawned.
  • Spinners are spawned without Physics so the ball passes through; the Spinner system detects contact by XZ proximity.
  • A wall is a thick opaque perimeter box; a rail is a thin chrome wire suspended above the playfield; a ramp is an angled solid floor segment built into the playfield.

More like this

Bumper
MeshPrimitive
MouseHole
PinballBuilderInput
PinballTable
Spinner
Flipper
PinballCamera
PinballLayout
Plunger
PokerSeating

Was this page helpful?

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

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search