[p5.js 2.0 Bug Report]: p5.Graphics.model() is not a function when used on secondary WEBGL p5.Graphics canvas
Open
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:
- Create a supplementary WEBGL canvas, here "graphics2"
- Try to load a model and display it on that canvas
- 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
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.
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