Three.js Importing Models Tutorial | How to Import GLTF Models in Three.js

  Рет қаралды 55,924

Suboptimal Engineer

Suboptimal Engineer

Күн бұрын

In this coding tutorial, we go over importing GLTF models in Three JS. We start off by learning when it is useful to import 3D models. Then we go over the different file formats for 3D models like GLTF, OBJ, and FBX. Finally, we find a model on Sketchfab and learn how to import it into our Three.js scene.
📖 Code - github.com/SuboptimalEng/thre...
🐦 Twitter - / suboptimaleng
💻 GitHub - github.com/SuboptimalEng
🌎 Website - suboptimaleng.com
== [ Credits ] ==
zixisun02 - sketchfab.com/zixisun51
Shiba by zixisun02 - sketchfab.com/3d-models/shiba...
Caterina Zamai - www.artstation.com/zaccate
Hand Anatomy by Caterina Zamai - sketchfab.com/3d-models/hand-...
== [ Resources ] ==
Three.js - threejs.org
Three.js Tutorials - sbcode.net/threejs
== [ Timestamps ] ==
00:00 Intro to Three.js
00:30 Why Use 3D Models?
01:49 File Formats for 3D Models
02:43 Find Model in Sketchfab
03:46 Import GLTF Model
05:03 Transform + Scale Model
05:37 Animate Model
== [ Tags ] ==
#suboptimal #metaverse #threejs

Пікірлер: 51
@sele-nap
@sele-nap 2 жыл бұрын
Thanks for the follow up videos! it's super clear and helps me a lot :)
@Aastha-gl2wo
@Aastha-gl2wo Ай бұрын
Thanks for the awesome tutorial on importing 3D models in three.js! 🚀
@developerenn
@developerenn 2 жыл бұрын
This channel is goldmine!
@user-di6nv8cs7k
@user-di6nv8cs7k 2 жыл бұрын
Thank's for this tutorial, it made my model appear!
@SuboptimalEng
@SuboptimalEng 2 жыл бұрын
Glad it helped!
@cyraxvisuals6203
@cyraxvisuals6203 Жыл бұрын
textures import cleanly as well? normal etc
@maxhoffmann1298
@maxhoffmann1298 Жыл бұрын
Why does the scene from "07-import-model" keep reloading after 30 seconds or so?
@matthewbaynham6286
@matthewbaynham6286 Жыл бұрын
The folders on your GitHub doesn't match what is on the video.
@petero.oyebanji959
@petero.oyebanji959 Жыл бұрын
Love the tutorial man! Is there a way to put this on a iOS simulator for an app
@SuboptimalEng
@SuboptimalEng Жыл бұрын
Thanks Peter! I’m not sure what you mean by put it in an iOS simulator. I know the Unity game engine makes it easy to make 3D games on mobile.
@petero.oyebanji959
@petero.oyebanji959 Жыл бұрын
@@SuboptimalEng like rather than on the local hist it would be on a react native emulator
@natialo
@natialo 2 жыл бұрын
Thanks for this bro
@SuboptimalEng
@SuboptimalEng 2 жыл бұрын
Glad the video could help Olaitan 😊
@bestapps4709
@bestapps4709 11 ай бұрын
How to let it more shiness, metalness to appear alive?
@johncena-qr4yg
@johncena-qr4yg 2 жыл бұрын
how to change width and height of that canvas to (512x512)? how to remove left top corner fps stats?
@sikeplayz
@sikeplayz Жыл бұрын
hey did u fixed this?
@mr.pushkin6213
@mr.pushkin6213 Жыл бұрын
I am having so much trouble with this it's just not working...
@dclxviclan
@dclxviclan Жыл бұрын
Cool bro
@tundeakinola8122
@tundeakinola8122 Жыл бұрын
Pls how does one import the downloaded model into React.js? Do u have a video for that?
@suhaanbhandary4009
@suhaanbhandary4009 Жыл бұрын
Eg of a cube model: import CubeModel from './cube.gltf';
@dungcuyeu
@dungcuyeu 11 ай бұрын
​@@suhaanbhandary4009😮
@vegetagod2013
@vegetagod2013 2 жыл бұрын
I use VITE for react and THREE JS ...but when I try to deploy it in netlify the build fails ....it says.. [vite]: Rollup failed to import 'three' from scr/lib/... but the deployment build is working locally ..please help
@SuboptimalEng
@SuboptimalEng 2 жыл бұрын
Unfortunately, I’m not familiar with Netlify. I’ve mainly use GitHub pages.
@vegetagod2013
@vegetagod2013 2 жыл бұрын
@@SuboptimalEng When I use Github Pages the GLTF models dosent loads up but it atleast deploys ...so can you make a tutorial to deploy or u have any solution ...cause i am using the same THREE.js and React(Vite) setup
@JFKTLA
@JFKTLA 2 жыл бұрын
what if i have a glb would this still work
@SuboptimalEng
@SuboptimalEng 2 жыл бұрын
According to the Three.js docs the GLTF loader should also work on GLB files.
@IllusiveMediaYT
@IllusiveMediaYT 2 жыл бұрын
What is your VSCode Theme?
@SuboptimalEng
@SuboptimalEng 2 жыл бұрын
It’s a custom variant of the Gruvbox dark theme. You can find more details in my Dotfiles repository on GitHub.
@vedantkanoujia
@vedantkanoujia Жыл бұрын
import shirt model success but not textures fix please
@Ddddddddyu
@Ddddddddyu Жыл бұрын
i have same problem, have you find solve for it ?
@onemorechris
@onemorechris Жыл бұрын
several days trying to get a model to appear in a webpage 😭. I think your tutorial as as clear and simple as this is going to get and i still can’t get it to work. when i download all your code, i get weird errors about accessing main.jsx.
@SuboptimalEng
@SuboptimalEng Жыл бұрын
It didn’t work after you followed the instructions on the readme?
@onemorechris
@onemorechris Жыл бұрын
@@SuboptimalEng i didn’t fully understand it. i think it might be something wrong with another part of my code as i was getting similar errors before. i think what i’m trying to do is beyond my abilities sadly
@SuboptimalEng
@SuboptimalEng Жыл бұрын
@@onemorechris don't say that! Most programmers struggle with coding all the time! Hope you figure out the bug.
@onemorechris
@onemorechris Жыл бұрын
@@SuboptimalEng lol. i’ll try again another day. nice tutorial either way 👍
@deuldmarinho3434
@deuldmarinho3434 Жыл бұрын
hi bro I really need your help every-time I scroll the page the fbx model despair from the de scene what can i do to stop this problem here is the code: const clock = new THREE.Clock(); let mixer; const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); const pt = new THREE.Vector3(0, 1, 2); camera.lookAt(pt); const renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); camera.position.setZ(40); renderer.render(scene, camera); //Background // Lights scene.fog = new THREE.Fog( 0xa0a0a0, 200, 1000 ); const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444 ); hemiLight.position.set( 0, 200, 0 ); scene.add( hemiLight ); const dirLight = new THREE.DirectionalLight( 0xffffff ); dirLight.position.set( 0, 200, 100 ); dirLight.castShadow = true; dirLight.shadow.camera.top = 180; dirLight.shadow.camera.bottom = - 100; dirLight.shadow.camera.left = - 120; dirLight.shadow.camera.right = 120; scene.add( dirLight ); // Helpers const controls = new OrbitControls(camera, renderer.domElement); controls.target.set(4.5, 0, 4.5 ); controls.enablePan = false; controls.maxPolarAngle = Math.PI/2; controls.enableDamping = true; controls.noPan = true; controls.noKeys = true; controls.noZoom = true; controls.enableZoom = false; // Scroll Animation function moveCamera() { const t = document.body.getBoundingClientRect().top; const currentTimeline = window.pageYOffset/3000 const rx= currentTimeline*Math.PI*2 camera.rotation.set(rx,0,0) camera.position.z = t * -100; camera.position.x = t * 0; camera.position.y = t * 0; } document.body.onscroll = moveCamera; moveCamera(); //load model const loader = new FBXLoader(); loader.load( 'assets/Strut Walking.fbx', function ( object ) { mixer = new THREE.AnimationMixer( object ); const action = mixer.clipAction( object.animations[ 0 ] ); action.play(); object.traverse( function ( child ) { if ( child.type == 'SkinnedMesh' ) { child.frustumCulled = false; } } ); scene.add( object ); } ); function animate() { requestAnimationFrame(animate); const delta = clock.getDelta(); if ( mixer ) mixer.update( delta ); renderer.render( scene, camera ); controls.update(); renderer.render(scene,camera); } animate()
@corretorortografico5534
@corretorortografico5534 Жыл бұрын
I don't know what's happening in my project. It keeps sending this error message: JSON.parse: unexpected character at line 1 column 1 of the JSON data. Can someone help?
@cyberprank7549
@cyberprank7549 Жыл бұрын
Hello, did you find a solution to this problem?
@corretorortografico5534
@corretorortografico5534 Жыл бұрын
@@cyberprank7549 Hi, I don't remember it very well, but I believe that I wasn't able to import other file resources. So I used a HTTP server. It's very simple to create one, since you can do it with a simple command
@corretorortografico5534
@corretorortografico5534 Жыл бұрын
@@cyberprank7549 Also, there's a pretty awesome guy who recommends the use of a bundler named Parcel. I really don't know what a bundler is, but it really helped. Take a look
@cyberprank7549
@cyberprank7549 Жыл бұрын
@@corretorortografico5534 And I am using a faucet Parcel. Unfortunately, nothing works.
@cyberprank7549
@cyberprank7549 Жыл бұрын
@@corretorortografico5534 100% loaded index.js:24 SyntaxError: Unexpected token '
@sergdomina
@sergdomina Жыл бұрын
dont work, model dont upload
@TRUE043
@TRUE043 Жыл бұрын
I don't call it a tutorial, not all of you are able to show, a project from a to z, always parts. It doesn't make you want to move on, maybe it's done on purpose. Result me, and others are having a hard time, because of selfish people, who do anything, I'm very angry, I haven't seen a tutorial, complete, a file is always missing, not the right version, more compatible file, zoom part, part from start or end. You do it on purpose, you are disgusted people, so keep your programming to yourself. I'm tired of wasting my time with guys who don't even know how to do a complete tutorial from A to z, and without skimming over.👎👎👎👎👎👎👎
@muhannsh4393
@muhannsh4393 Жыл бұрын
I feel you man, but our guy here is doing his best to make those tutorials, and I'm sure he thinks that every one made it so far have the knowledge to do all the previous things! Believe I'm totally new to there.js I'm just starting now! Cheers ^.^
@SamuelQueen-re8bc
@SamuelQueen-re8bc 11 ай бұрын
he has other tutorials that lead up to this point. there's no need to insult people just because you are too lazy to figure it out and want everything handed to you
Three.js Font Loader Tutorial | How to Load Fonts in a Three.js Scene
4:36
Suboptimal Engineer
Рет қаралды 9 М.
Three.js Setup Guide Tutorial | Getting Started with React + Three.js
9:13
Suboptimal Engineer
Рет қаралды 28 М.
where is the ball to play this?😳⚽
00:13
LOL
Рет қаралды 13 МЛН
Free AI - ADVANCED 3D Models From Images - Ready For Printing!
12:25
Three.js Crash Course for Absolute Beginners - 3D in the Browser
43:14
Working with Three.js Particle Systems - They're AWESOME!
32:21
DesignCourse
Рет қаралды 115 М.
Getting Started with Three.js: A Beginner's Tutorial
17:44
Robot Bobby
Рет қаралды 3 М.
React Three Fiber tutorial - 3D Product Configurator
51:27
Wawa Sensei
Рет қаралды 41 М.
What is WebGPU?
14:09
Suboptimal Engineer
Рет қаралды 55 М.
Import Blender Scene To Three JS - Using ThreeJS Editor
4:49
Class Outside
Рет қаралды 30 М.
📱 SAMSUNG, ЧТО С ЛИЦОМ? 🤡
0:46
Яблочный Маньяк
Рет қаралды 935 М.
Я Создал Новый Айфон!
0:59
FLV
Рет қаралды 3,2 МЛН
Купите ЭТОТ БЮДЖЕТНИК вместо флагманов от Samsung, Xiaomi и Apple!
13:03
Thebox - о технике и гаджетах
Рет қаралды 67 М.
Apple. 10 Интересных Фактов
24:26
Dameoz
Рет қаралды 69 М.
Apple, как вас уделал Тюменский бренд CaseGuru? Конец удивил #caseguru #кейсгуру #наушники
0:54
CaseGuru / Наушники / Пылесосы / Смарт-часы /
Рет қаралды 3,9 МЛН
Обманет ли МЕНЯ компьютерный мастер?
20:48
Харчевников
Рет қаралды 125 М.