processing / processing/p5.js

[p5.js 2.0 Bug Report]: p5.Graphics.model() is not a function when used on secondary WEBGL p5.Graphics canvas

Open
#8,671 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:Core Area:WebGL p5.js 2.0+
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
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)
p5.js version

v2.2.1, v2.2.3 (beta)

Web browser and version

Chrome, 146.0.7680.154

Operating system

Windows 11 Version 25H2 (Build 26200.7840)

Steps to reproduce this
Steps:
  1. Create a supplementary WEBGL canvas, here "graphics2"
  2. Try to load a model and display it on that canvas
  3. following error: TypeError: graphics2.model is not a function
    (TypeError: graphics2.model is not a function
    at (anonymous function) (/sketch.js:14:15))
    workaround: use graphics2._renderer.model() instead -> so I guess the model() function is not "exposed" properly for p5.Graphics objects?
Snippet:

(can also be accessed under my p5js.org sketches here)


let graphics2;
let model1;

function setup() {
  createCanvas(400, 400);
  graphics2 = createGraphics(300,300,WEBGL)
  model1 = loadModel("meeple1.obj")
    .then(mdl => {
      graphics2.noStroke();
    graphics2.background("#FFEEC2");
    graphics2.scale(10);
    graphics2.fill("#b4936d");
    graphics2.rotate(TAU/2);
    graphics2._renderer.model(mdl); // graphics2.model outputs error that .model is not a function, only works like this
    graphics2.box(4); //box works
  });
}

function draw() {
  background("#583961");
  image(graphics2, 10, 10, width-20, height-20);
}

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.

Research direction

Start by reproducing the secondary WEBGL p5.Graphics example from the issue or linked sketch, comparing graphics2.model(mdl) with the current graphics2._renderer.model(mdl) workaround. Trace how p5.Graphics exposes rendering methods and verify that model() works on the supplementary canvas while existing calls such as box() continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.