Skip to content

[p5.js 2.0 Bug Report]: build*Shader methods don't work yet in instance mode #8520

@davepagurek

Description

@davepagurek

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.1

Web browser and version

All

Operating system

All

Steps to reproduce this

Steps:

To use .modify() in instance mode, you have to call it like this:

baseMaterialShader.modify(({ p5 }) => {
  p5.getWorldInputs((inputs) => {
    inputs.position.x += 5
    return inputs
  })
}, { p5 })

Currently, the new build*Shader methods don't pass along the second context object:

p5.js/src/webgl/material.js

Lines 708 to 710 in 276a96a

fn.buildFilterShader = function (callback) {
return this.baseFilterShader().modify(callback);
};

It needs to do so to be able to support that syntax, e.g.:

buildMaterialShader(({ p5 }) => {
  p5.getWorldInputs((inputs) => {
    inputs.position.x += 5
    return inputs
  })
}, { p5 })

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions