Repository navigation
Support ** in p5.strands and error on unsupported operators - #9375
Open
harshiltewari2004 wants to merge 1 commit into
Open
harshiltewari2004 wants to merge 1 commit into
harshiltewari2004 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #9252
Changes:
replaceBinaryOperator(src/strands/strands_transpiler.js) now maps**topow, soa ** bbecomesa.pow(b). This also covers**=, since compound assignments go through the same function.StrandsNode.prototype.pow(src/strands/strands_api.js), which builds apow()function call node rather than a binary operator, since GLSL and WGSL have no**operator. This resolves the TODO.defaultcase that throws a strands error naming the operator (e.g.&,<<), instead of crashing with.undefined is not a function/reading 'startsWith'inside the transpiler. This was the second option in the issue; happy to drop it into a separate PR if you'd rather keep this one to**only.Tests (new
exponentiation operator (#9252)suite intest/unit/webgl/p5.Shader.js):v ** 2renders the same aspow(v, 2)v **= 2worksunsupported operatorAll three failed before the source change and pass after. The change is in the backend-independent transpiler, so I only added WebGL tests; happy to add WebGPU ones too.
npx vitest run: everything passes excepttest/unit/webgpu/p5.Shader.js→ "handle passing a value from a vertex hook to a fragment hook with swizzle assignment", which also fails on a cleanmain.PR Checklist
npm run lintpasses