processing/p5.js★ 23,941

Fix #8756: Allow computed array indexing on non-storage vectors

Mergedopened · merged · #8768

About processing/p5.js

p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. Looking for p5.js 2.0? http://beta.p5js.org

  • art
  • creative-coding
  • design
  • education
  • graphics
  • html
  • javascript
  • learning

The change

<!-- Thank you for contributing! Please use this pull request (PR) template. In the description field of this PR, include "resolves #XXXX" tagging the issue you are fixing. If this PR addresses the issue but doesn't completely resolve it (ie the issue should remain open after your PR is merged), write "addresses #XXXX". --> Resolves #8756 Changes: <!-- Add here what changes were made in this pull request and if possible provide links showcasing the changes. --> This PR fixes the bug where get() could only be used on storage buffers in p5.strands, preventing array indexing (arr[0]) on non-storage vectors like those returned from helper functions. Root Cause: The transpiler converted ALL computed member access (arr[0]) to .get() calls, but the get() method in strands_node.js had a guard that only allowed it for storage buffers, throwing "get() can only be used on storage buffers" for non-storage vectors. • src/strands/strands_node.js • src/strands/strands_transpiler.js • src/webgl/strands_glslBackend.js (Added ARRAY_ACCESS handler, missing from GLSL backend - flagged by @Nixxx19 ). • test/unit/webgpu/p5.Shader.js Screenshots of the change: <!-- If applicable, add screenshots depicting the changes. --> PR Checklist <!-- To check any option, replace the "○" with a "✓". Be sure to check out how it looks in the Preview tab! Feel free to remove any portion of the template that is not relevant for your issue. --> • ✓ npm run lint passes • ✓ [Inline reference] is included / updated • ✓ [Unit tests] are included / updated [Inline reference]: https://p5js.org/contribute/contributing_to_the_p5js_reference/ [Unit tests]: https://github.com/processing/p5.js/tree/main/contributor_docs#unit-tests

Referenced issues