[p5.js 2.0 Bug Report]: p5.strands global variables not available/working correctly in instance mode
Open
@saurabh24thakur is already working on this.
Since Feb 28, 2026.
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
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();
}
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.
Assessment
This issue has not been assessed yet.