Skip to content

[p5.js 2.0 Bug Report]: p5.strands global variables not available/working correctly in instance mode #8575

@christophseibel

Description

@christophseibel

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

2.2.2

Web browser and version

Safari 26.3

Operating system

MacOSX

Steps to reproduce this

Problem:

the p5.js global variables that are being made available as uniforms dont work correctly in instance mode. the snipet code throws this error on runtime:

Unhandled Promise Rejection: TypeError: p53.mouseX.div is not a function. (In 'p53.mouseX.div(p53.width)', 'p53.mouseX.div' is undefined)

this does NOT seem to be an error with the mouse variable, if you rearrange the variables:

    let mouse = p5.vec2([p5.displayWidth / p5.mouseY, p5.mouseY / p5.height]);

you get the same error thrown at you.

using the variables without the "p5" instance as prefix weirdly works

Snippet:

  function testShader({ p5 }: { p5: p5 }) {
    p5.filterColor.begin();
    let mouse = p5.vec2([p5.mouseX / p5.width, p5.mouseY / p5.height]);
    p5.filterColor.set([mouse, 0, 1]);
    p5.filterColor.end();
  }

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions