logo

Babylon.js Market

PinballBuilderInput

pinball

PinballBuilderInput

1
Unlock

Install with the CLI:

bjs download PinballBuilderInput

PinballBuilderInput

Canvas-side pointer capture that feeds PinballBuilder's freehand drawing.

What it does

The counterpart to PinballBuilder's draw mode. On pinballBuilder.setDrawMode with enabled: true it attaches pointer listeners to the rendering canvas; on enabled: false it detaches them. While drawing, it projects each pointer sample onto the playfield mesh via the renderer's screen-point pick (filtered by pickMeshPrefix), drops samples closer than minSampleDistance to reduce jitter, and accumulates an XZ polyline. On pointer release it emits pinballBuilder.drawPath with the captured points for PinballBuilder to smooth and chain into rails or walls. It's a parameter-free singleton concern — declaring one component instance activates the system.

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 PinballBuilderInput

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

    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": {
    "Playfield": {
      "components": {
        "MeshPrimitive": {
          "primitive": "box",
          "width": 16, "height": 0.2, "depth": 33.2,
          "position": [0, -0.1, 0],
          "material": { "diffuseColor": [0.12, 0.13, 0.2] }
        }
      }
    },
    "Builder": {
      "tags": ["builder"],
      "components": {
        "PinballBuilder": {},
        "PinballBuilderInput": { "pickMeshPrefix": "mesh_Playfield", "minSampleDistance": 0.05 }
      }
    }
  }
}

Props

  • pickMeshPrefix (string, default 'mesh_Playfield') — prefix of the pickable target mesh's Babylon name; only samples that hit a matching mesh are kept.
  • minSampleDistance (number, default 0.05) — minimum XZ distance between successive samples; closer moves are discarded as jitter.

Events

  • Emits pinballBuilder.drawPath{ points, kind } on pointer release (only when at least 2 points were captured).
  • Listens for pinballBuilder.setDrawMode{ enabled, kind? } to attach/detach the canvas listeners and set the draw kind.

Dependencies

PinballBuilder — emits the setDrawMode toggle this listens for and consumes the drawPath polyline this produces. Pair them on the same Builder entity.

Notes

  • The pickMeshPrefix must match the playfield mesh's actual Babylon name prefix, or projection finds nothing and no path is captured.
  • Listeners are torn down on system shutdown, so leaving draw mode on won't leak handlers.

More like this

PinballBuilder
Bumper
FlightIntent
Flipper
Jump
KeyboardInput
KeyboardMover
MouseHole
PinballCamera
PinballLayout
PinballTable
PlayerFlightInput
PlayerInput
PlayerInputBridge
Plunger
PokerInput
PokerSeating
Spinner

Was this page helpful?

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

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search