-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
The useMirroredUniform
hook is used to "synchronise"/"mirror" a JS value from React onto the GPU.
useUniformValue | useMirroredUniform | |
---|---|---|
mutable .value | ✅ | ❌ |
reacts to change in parameters (schema, value) | ❌ | ✅ |
function Component(props: { color: d.v3f }) {
// The uniform will be updated with the latest value of `props.color`
// on every React render.
const color = useMirroredUniform(d.vec3f, props.color);
const { ref } = useRender({
fragment: () => {
'kernel';
return d.vec4f(color.$, 1);
},
});
return <canvas ref={ref}></canvas>
}
Doing the same with useUniformValue would require manually syncing the value either in a useEffect, or on every frame.
Metadata
Metadata
Assignees
Labels
No labels