Open artokun opened 2 years ago
The TS example is a good idea, I will replace the JS examples with TS actually as it’s easy to derive JS from TS but not the other way around.
as for the GLSL import, that’s great that it works but I don’t think it’s needed in the library itself. It’s a user land thing. Besides you can use the /*glsl*/
decorator to get syntax highlighting for inline template strings.
Oh? didn't know about the decorator, i'll give that a try!
Hey, I am quite struggling with implementing your solution as I am not the best with Typescript but still trying to enforce it as it's a good practice. If you don't mind sharing - what exactly does your utility method getNonUniformArgs
do?
Also, how how would I implement useRef
directly on material layer itself - so I can change the props via useFrame?
I tried following but I am not getting anywhere.
const materialRef = useRef<CustomLayerProps>();
useFrame((state) =>
{
const { clock } = state;
materialRef .current!.time = 0.4 * clock.getElapsedTime();
});
return (
<mesh position={[2, 0, 0]}>
<sphereGeometry args={[4.25, 64, 64]} />
<LayerMaterial color="#434" lighting="standard">
<CustomLayer ref={materialRef} intensity={0.15} />
</LayerMaterial>
</mesh>
);
It took me a few hours to figure it out using the src
If you notice I import the .glsl directly. You can do this without ejecting by using the
@rescripts/cli
library. It gives you better syntax highlightingand the packlage.json to make the imports work
now you can load your glsl files