pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.73k stars 312 forks source link

Edit the js file to import the gltf model ? #19

Closed Franckapik closed 4 years ago

Franckapik commented 4 years ago

Hi! First of all, thank you a lot for this beautiful work ! I would like to know is there is a reason why i should edit the react component model.js to import the gltf model instead of using directly the url as the example ?

Example : const { nodes, materials } = useLoader(GLTFLoader, '/model.gltf')

My project : import model from "./model.gltf) const { nodes, materials } = useLoader(GLTFLoader, model)

Thank you ! F.

drcmda commented 4 years ago

it's the same, you can do it as you like. if you console.log your import it's most likely a url anyway, just hashed. it's better that way, you get to control caching and the asset doesn't have to be part of /public. perhaps this should also be the default, but some build tools maybe can't handle "gltf"?

Franckapik commented 4 years ago

Maybe! In my recat project i don't know why it doesn't work when i place the gltf file in/public folder... But i will continue with this kind of import ... Thank you for your help on this !!

drcmda commented 4 years ago

public isn't part of the bundle, cra for instance explicitely forbids importing anything outside of src. that#s the main difference, /public isn't poart of the bundle and it's fetched via root path, import is a splitbundle.

Franckapik commented 4 years ago

Oh ok, so i understand ! I enjoy that you are there just to ask another question... I use React Three Fiber, if i want to use Bump and displacement map, i should edit the js file to add it on material because it's not imported in gltf file ? There is only normal map in gltf, isn't it ?