playcanvas / playcanvas/engine

Add configurable mouse button mappings to camera-controls.mjs

Open
#8,440 0 comments 0 reactions 1 assignee View on GitHub

@kpal81xd is already working on this.

Since Feb 4, 2026.

area: input
Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

Summary

The camera-controls.mjs script has hardcoded mouse button mappings that cannot be overridden or customized. This makes it difficult to use the script in applications that need to reserve certain mouse buttons for other functionality (e.g., painting, selection, custom interactions).

Current Behavior

Mouse button behavior is hardcoded in the update() method (lines 730-736):

  • LMB (button 0) → orbit mode
  • MMB (button 1) → orbit mode
  • RMB (button 2) → fly mode
  • Scroll wheel → orbit mode (zoom)

There is no way to:

  1. Change which button triggers orbit vs fly mode
  2. Disable a specific button so an application can handle it
  3. Swap button mappings (e.g., orbit with RMB, leave LMB for app use)

Use Case

I want to build an application where:

  • LMB - orbit camera (handled by camera-controls)
  • RMB - custom painting/interaction (handled by my app)

Similar to how the gaussian-splatting/paint.example.mjs example works, but that example uses the older orbit-camera.js script which has a separate input script that can be disabled.

Proposed Solution

Add configurable properties to control button mappings:

/**

  • Mouse button for orbit mode. Set to -1 to disable.
  • @type {number}
  • @default 0 (LMB)
    */
    orbitButton = 0;

/**

  • Mouse button for fly mode. Set to -1 to disable.
  • @type {number}
  • @default 2 (RMB)
    */
    flyButton = 2;

/**

  • Mouse button for pan (in orbit mode). Set to -1 to disable.
  • @type {number}
  • @default 1 (MMB)
    */
    panButton = 1;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.