Open
Description
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
- On the other hand, the newly introduced
- ⛔ 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