[p5.js 2.0+ Bug Report]: orbitControl is not available on WEBGL p5.Graphics
@anme9922 is already working on this.
Since Aug 26, 2026.
- Dominant language
- JavaScript
- Stars
- 24k
- Forks
- 3.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 25
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- WebGPU
- p5.strands
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.3.2
Web browser and version
Chrome 149.0.7827.201
Operating system
MacOSX 15.6 (Sequoia)
Steps to reproduce this
orbitControl() is not exposed as pg.orbitControl() on a p5.Graphics created with createGraphics(w, h, WEBGL), even though using orbit-style controls on an offscreen WEBGL buffer is a reasonable/expected pattern.
Steps:
- Try my code snippet below.
Snippet:
The following code has an error on line 11, where indicated:
let pg;
function setup() {
createCanvas(400, 400);
pg = createGraphics(300, 300, WEBGL);
console.log(typeof pg.orbitControl); // reports undefined
}
function draw() {
pg.background(0);
pg.orbitControl(); // throws TypeError: pg.orbitControl is not a function
pg.box(100);
image(pg, 0, 0);
}
By contrast, the following code works just fine:
function setup() {
createCanvas(400, 400, WEBGL);
}
function draw() {
background(0);
orbitControl();
box(100);
}
As a workaround, I'm calling:
p5.prototype.orbitControl.call(pg, 1, 1, 1);
but I'm also manually supplying the pointer state that orbitControl() expects. That works, but it's a lot of extra code, and it relies on internals, so it is the kind of thing worth reporting. In my opinion, the recommended fixes are either:
- expose
orbitControl()on WEBGLp5.Graphics, or - document that
orbitControl()is intentionally only supported on the main renderer. (Why?)
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.