Closed engmagdy87 closed 5 years ago
Hey, did you solve this problem? I get black 3D model without any texture.
Same to me. @dwqdaiwenqi Is this project maintainable?
Hey @lossen , I solved this issue by moving 3D model's files from src
folder to public
folder. Then I modified the code like this:
<MTLModel
enableZoom = {false}
position={{x:0,y:-100,z:0}}
rotation={this.state.rotation}
texPath="/3Dmodels/project2/"
mtl="/3Dmodels/project2/freedom.mtl"
src="/3Dmodels/project2/freedom.obj"
/>
The mtl
and obj
files are under public/3Dmodels/project2
folder. You don't have to write public
in the code while giving the path. Also, React allows serving static files without using import
through public
folder. After that, texture loaded correctly for me. I hope this helps.
Hey @aysenurbulbul , thanks for help! Yeah, from public folder textures loaded correctly. Did you try with urls instead of local paths? I need to load model from the server
@lossen , in my project I used only local files so I only tried it with dynamically changed local paths but since this package uses three.js and its OBJLoader supports loading from URLs as well, it may work. If your project requires more flexibility with 3D models, I suggest you to use three.js instead of this package. In fact, I used three.js then switched to babylon.js to serve 3D models in my project. Hope this helps.
the 3d object is gray and not affected with tex file here is the code https://codesandbox.io/embed/determined-lumiere-1omml