In this article, we’ll cover how to render and configure 3D assets created in a 3D software program like Blender or Maya in a React project using r...
For further actions, you may consider blocking this person and/or reporting abuse
Nice one! Only issue I have is that I lose the textures when exporting the fbx animation to glb from Blender in the final step.
Any advice?
When you export the model as glb make sure you use this configurations.
I hope this fixes the problem.
Now only one problem remains.. the "position" property of the Model component doesn't seem to affect the position once the model is animating. Whenever I reload the app, the position will go back to the bottom of the model being in the center of the canvas.
I'm sorry I didn't understand what problem you are having with the Model position, If you still didn't figure it out, provide me with some more feedback, and I will try my best to help.
The "Model position={[0.2, -0.9, 0]}" positions the model as it should, when the model is not animating. However, as soon as I replace with the animated model, the position is somehow overridden and becomes [0,0,0]. I can see this behavior when I console.log(group.current.position).
Problem solved. By wrapping the group in a new parent group, and setting the position on the parent - I could solve the problem. The animation clearly reset the position of its group.
I never had a problem like that before, glad you solved it.
Indeed it did. The only config that differed was "Selected Objects". When I checked this option, it started working.
Thanks!
I had the same problem, when I exported from Blender to FBX I lost the textures, what I did is:
Hope this is not too late; I got a similar error earlier:
You wanna uncomment the line console.log(action) and check the logs. It should show an object, mine looks something like this:
Then you wanna change this line of code to match it
Awesome awesome awesome! Ty for making this post was really helpful for me as I plan on making a personal portfolio and this will go a long way.
Just in case this helps anyone, I also encountered issues with the textures for the head not showing up in the final model export. This is how I fixed:
Cool stuff! I'll bet you could cut React out of this entirely and just use (say) ColladaLoader with THREE.js to port the same content.
Thanks!, I had used GLTFLoader outside of React but I never used the ColladaLoader, Over all if you have a collada model (.dae) you need to use the ColladaLoader, or if you have a model with other format you need to use a loader that supports the file type/format.
You are very much right, you can load any model with the power of Three.js only, thank you for pointing that out.
i just follow your steps. When i compile "yarn start" then i receive this animation (character has no color). I don't know why. Can you please help fix this!
can you provide me with a link of a public Github repo that have your Code, and I will see if I can help.
Repo: github.com/leminhung/my-3d-model
This is my public github repo, Can you please clone repo and run this app to see the problems with color of animations.
Thank you so much!
Apparently when you added the animation to the model, the names of the materials changed, you need to generate a new
Model.js
file usinggltfjsx
.or you can use the code I did generate using
gltfjsx
.Ohh, problem was resolved. Thank you!
Uncaught Could not load ../public/breakDance.glb: Unexpected token < in JSON at position 0.
I'm getting this error and can't find a way to parse it as html. Need help!
I guess there is some issue with useGLTF function cuz when i inserted my avatar link it worked but it wasn't working when i used the path of .glb file in the useGLTF().
can you upload it into a public git repo and give me the link so I can see what the problem is, or you can see my shared code on codesandbox at codesandbox.io/s/3d-model-animatio... and try to find if you missed any thing.
Thanks for sharing, May I translate this article into Chinese?
Yeah no problem, you can translate the article.
Thanks, Simplified Chinese 如何使用 React 和 Three.js 在网站渲染自己的3D模型
Nice content, thanks for sharing it!
This is radical! Thanks for sharing.
Thank you, I appreciate that.
Genius. Thank you for this! It's simply awesome.
Thank you, I appreciate that.
This is solid and really helpful. Thanks !!
Thank you, glad this helped.
Hello Nourdine,
Thank you for this tutorial, but I have a problem.
Following your directions, I find myself facing errors regarding MeshLineGeometry & raycast
``Attempted import error: 'MeshLineGeometry' is not exported from 'meshline' (imported as 'MeshLineGeometry').
WARNING in ./node_modules/meshline/dist/index.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\Users\Edouard\Desktop\blender\3d\node_modules\meshline\src\index.ts' file: Error: ENOENT: no such file or directory, open 'C:\Users\Edouard\Desktop\blender\3d\node_modules\meshline\src\index.ts'
WARNING in [eslint]
src\Dd_text_withoutanim.js
Line 5:17: 'useRef' is defined but never used no-unused-vars
ERROR in ./node_modules/@react-three/drei/core/Trail.js 104:38-54
export 'MeshLineGeometry' (imported as 'MeshLineGeometry') was not found in 'meshline' (module has no exports)
ERROR in ./node_modules/@react-three/drei/core/Trail.js 107:18-34
export 'MeshLineMaterial' (imported as 'MeshLineMaterial') was not found in 'meshline' (module has no exports)
ERROR in ./node_modules/meshline/dist/index.js 1:0-35
Module not found: Error: Can't resolve './MeshLineGeometry' in 'C:\Users\Edouard\Desktop\blender\3d\node_modules\meshline\dist'
Did you mean 'MeshLineGeometry.js'?
BREAKING CHANGE: The request './MeshLineGeometry' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '.mjs' file, or a '.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
ERROR in ./node_modules/meshline/dist/index.js 2:0-35
Module not found: Error: Can't resolve './MeshLineMaterial' in 'C:\Users\Edouard\Desktop\blender\3d\node_modules\meshline\dist'
Did you mean 'MeshLineMaterial.js'?
BREAKING CHANGE: The request './MeshLineMaterial' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '.mjs' file, or a '.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
ERROR in ./node_modules/meshline/dist/index.js 3:0-26
Module not found: Error: Can't resolve './raycast' in 'C:\Users\Edouard\Desktop\blender\3d\node_modules\meshline\dist'
Did you mean 'raycast.js'?
BREAKING CHANGE: The request './raycast' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '.mjs' file, or a '.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.``
Here is my packages : "dependencies": {
"@react-three/drei": "^9.46.4",
"@react-three/fiber": "^8.9.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"three": "^0.147.0",
"three.meshline": "^1.4.0", }
Do you know how to fix these errors?
When I put "type": "module" in package, I find myself faced with new errors.
Thank you reading me :)
Uncaught Could not load ../../../assets/model-with-animations.glb: Unexpected token < in JSON at position 0
Canvas @ react-three-fiber.esm.js:141
renderWithHooks @ react-dom.development.js:16305
updateForwardRef @ react-dom.development.js:19226
beginWork @ react-dom.development.js:21636
callCallback @ react-dom.development.js:4164
invokeGuardedCallbackDev @ react-dom.development.js:4213
invokeGuardedCallback @ react-dom.development.js:4277
beginWork$1 @ react-dom.development.js:27451
performUnitOfWork @ react-dom.development.js:26557
workLoopSync @ react-dom.development.js:26466
renderRootSync @ react-dom.development.js:26434
recoverFromConcurrentError @ react-dom.development.js:25850
performConcurrentWorkOnRoot @ react-dom.development.js:25750
workLoop @ scheduler.development.js:266
flushWork @ scheduler.development.js:239
performWorkUntilDeadline @ scheduler.development.js:533
react-dom.development.js:18687 The above error occurred in the component:
Consider adding an error boundary to your tree to customize error handling behavior.
Visit reactjs.org/link/error-boundaries to learn more about error boundaries.
hallo, why cam't load model.glb sir
are you using create-react-app? or is it a custom webpack project?
using CRA sir
Hey,
did you manage to solve your problem?
I could not import FBX to Mixamo with textures, it lost textures. I already followed by your note about export fbx. Don't know what's wrong
Can you check on repo: github.com/xmannv/avatar3d
I have the same issue...
I resolved this by downgrading Blender to 2.93
Hey! My animated file just wont show up! I get the following error.
Uncaught TypeError: Cannot redefine property: Armature|mixamo.com|Layer0.001
I have tried generating new model.js file too. What could be the issue?
Thanks
Thanks for the article, it helps a lot. I'm totally new in threejs and webgl. So, if I want to replace some part of the glb model generated by Ready Player Me, to make a avatar customize game demo, could you please tell me how to change my code?
Here is my code demo: codesandbox.io/s/3d-model-animatio...
I was trying your codesandbox, but It doesn't seem to work, can you update it?
I have fixed all the issues, by my own, I will post my github repo with extra changes that I have done with a custom webpack 5 setup and with typescript.
Hi guys, I have created repo using webpack 5, typescript and what Nourdine posted in this article. Thanks for this Nourdine , it was amazing :) . Btw, for those who has issues with texture, you have to use blender version
2.9.3
, if not I will give you a different structureuseGLTF
from@react-three/drei
is expecting.Here is the repo: github.com/GRTO/avatar-three-js and this is how it looks avatar-three-js.vercel.app/
I used 3D model to convey my goodbyes to colleagues during pandemic WFH days :)
vishwakolkar.netlify.app/
Code: github.com/visikolkar/lg-farewell
This was so thoughtful and nice.
I´m 3d artist and fullstack web developer....i think that idea it´s great, but, what happens with textures??? About animations, i recommend create them in Mixamo if the model had good topology.
great post. do you have any idea render floorplan by react ?
Great article! Thanks for sharing & going to try this out over the weekend!
I lose the textures when I convert to fbx (the textures don't show in Mixamo...) - any idea why this happens?
Okay I resolved this by downgrading Blender to 2.93
Hello Nourdine, thanks for this awesome tutorial.
I think everything is ok, but i have no render on my app, could you help me ?
github.com/Athellan/3d-model/
Thanks !
It's cool but is a framework really useful for this kind of use?