Skip to content

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

@restcoser

Description

@restcoser

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);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions