Fyrestar / THREE.extendMaterial

Extending built-in materials, instances of ShaderMaterial and shader objects of onBeforeCompile.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using with react-three-fiber

FettahAud opened this issue · comments

I am trying to use it with R3F but got this error even in the console I'm getting the class.

Any suggestions??

image

This is a result of the way this library tries to interact with THREE rather than specifically to do with react-three-fibre

You'd need to either bring this libraries source into your own source and import the relevant THREE modules where they are used

I arrived here because I'm trying to extend a built in material and pass my own uniform (time) into the extended shader, I've not used this library just yet so I don't have source I can share, but happy to do that once I finish adapting it. I'll probably fork this repo once I figure it out, if that's helpful to you

The heart of the issue you are facing here is because your bundler (Webpack?) cannot find extendMaterial on the imported module THREE. Which is correct.

This library tries to add this method to THREE (the global) at runtime, so, it is not aware of THREE at bundle time. That is what this message is telling you, your bundler isn't able to import extendMaterial from THREE, because extendMaterial is not present on THREE as far as your bundler is concerned.