Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify compileShader return value signature #371

Open
hmans opened this issue Nov 30, 2022 · 0 comments
Open

Simplify compileShader return value signature #371

hmans opened this issue Nov 30, 2022 · 0 comments

Comments

@hmans
Copy link
Owner

hmans commented Nov 30, 2022

So far, compileShader returns a tuple with two objects:

const [shader, meta] = compileShader(...)

The shader object contains the typical properties expected by Three.js shader materials and related helpers (vertexShader, fragmentShader, uniforms).

The meta object contains additional properties like update (the per-frame callback).

This structure was chosen so you could easily plug the shader object into your favorite shader material helper in Three.js or R3F, without having to explicitly destructure it yourself.

But now that Shader Composer is no longer tightly coupled to Three.js, we have an opportunity to simplify the structure of the return value into a single object containing all properties:

const shader = compileShader(...)

Would this be a good idea? Who knows!

  • ✅ It would make the API less confusing
  • ⛔ Using SC in Three.js would be slightly more work for the user
    • On the other hand, the newly introduced @shader-composer/three package could provide a helper function that forms the returned object into something that can be spread into the relevant helpers like we're used to
  • ⛔ We currently don't know what using Shader Composer in other frameworks (eg. PlayCanvas) will look like, so it might be too early to make this change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant