Skip to content

[p5.js 2.0+ Bug Report]: orbitControl is not available on WEBGL p5.Graphics #9048

Description

@golanlevin

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:

  1. 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 WEBGL p5.Graphics, or
  • document that orbitControl() is intentionally only supported on the main renderer. (Why?)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions