Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Franckapik opened this issue May 7, 2020 · 4 comments
Closed

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

Franckapik opened this issue May 7, 2020 · 4 comments

Comments

@Franckapik
Copy link

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
Copy link
Member

drcmda commented May 7, 2020

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
Copy link
Author

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
Copy link
Member

drcmda commented May 11, 2020

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
Copy link
Author

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants