Load a 3D Model Using the Three.js OBJ Loader

  Рет қаралды 77,229

Learn Threejs

Learn Threejs

Күн бұрын

In this tutorial I teach you how to build a 3D model viewer using three.js obj loader and mtlloader libraries.
Written tutorial:
www.learnthree...
View it on Github:
github.com/lea...

Пікірлер: 61
@hamzaakhtar959
@hamzaakhtar959 3 жыл бұрын
Been struggling for 5 hours and just by watching this video was able to fix it. Respect! Would also love to see one in React as well.
@davidpicarazzi
@davidpicarazzi 4 жыл бұрын
Would you be able to explain the npm install part? I've never done this step before. How come I can't just double click the index.html file and see it that way?
@vincent-paolocorputty4060
@vincent-paolocorputty4060 3 жыл бұрын
Just type npm install in your terminal
@sivakumarthuvarahan5617
@sivakumarthuvarahan5617 5 жыл бұрын
Thank you for your tutorials, able to load r2-d2 model, but unable to load other models. Any reason? Thanks
@babali840
@babali840 5 жыл бұрын
I had the same prolblem and i have resolved it by creating a local serveur to upload my html and obj files like below threejs.org/docs/#manual/en/introduction/How-to-run-things-locally
@fabisierra7655
@fabisierra7655 3 жыл бұрын
@@babali840 hi! do you know if is something like that for upload to Django?
@Kloud9Creative
@Kloud9Creative 6 жыл бұрын
Any reason why I'm getting "Uncaught TypeError: THREE.OrbitControls is not a constructor" ?Is there a finished branch in the repo? finished just shows the animating green cube, and the tutorial here just throws errors: www.learnthreejs.com/load-3d-model-using-three-js-obj-loader/
@thiagosalesdev
@thiagosalesdev 2 жыл бұрын
Thanks!!!
@mineturtle1841
@mineturtle1841 3 жыл бұрын
Very helpful thanks
@JoshBowman1
@JoshBowman1 6 жыл бұрын
I've downloaded your Github repository and have everything loading the correct way, but I always get MTLLoader is not a constructor error whenever I try to load texture. If I comment out the texture code the R2D2 model loads and i can see it without texture.
@nguyenduc6288
@nguyenduc6288 5 жыл бұрын
you should check the modules see if they were all imported
@ravivora757
@ravivora757 4 жыл бұрын
have you any idea about.. changing materials and textures in real time using three.js
@one_way_tech
@one_way_tech 2 жыл бұрын
i like it
@professionalservices1094
@professionalservices1094 6 ай бұрын
Thank god man, you didnt waste even one extra second mixing a tutorial with a class. I just needed to get up and running and this was what I needed. Fantastic.
@one_way_tech
@one_way_tech 2 жыл бұрын
alu kuat alu hebat
@eljefe400
@eljefe400 6 жыл бұрын
these are awesome tutorials. Thanks
@ems_
@ems_ 6 жыл бұрын
Maaaan! This is a great tutorial👍. I have a question: How would I be able to move the object? I would add an event handler. When forward arrow is pressed, object.position.z += 5; How to reach the object from outside of the callback function? Keep up the good work buddy 👍
@learnthreejs2184
@learnthreejs2184 6 жыл бұрын
Hey Mohammed, Assign the object to a variable, then create an event listener on your arrow key to bump the position X amount of units. Here's something to get you started: 1. Create the global variable, so make sure it is outside of any function. Even the very top if fine. var 3dModel; 2. Assign the object to the variable once it finished loading, this is inside of your objLoader callback function 3dModel = object; 3. Create the event listener with a function to do what you'd like. function move3DObject() { // 38 is the number assigned to your forward arrow key if (38 === e.which) { 3dModel.position.z += 5; } } document.addEventListener('keyup', 'move3DObject'); *** I didn't get a chance to test this, but it should do the trick. Cheers!
@ems_
@ems_ 6 жыл бұрын
Hey, Thank you for the reply. I really appreciate it. Yes. It is working. I came across this method before I read your reply. Here is a thing that I am not sure of (and probably would make a great video tutorial). Whenever I try to console.log(3dModel) anywhere in the code it is undefined. unless I use a setTimeout function for few seconds than it is returned what I expect. I am (in a way or another) new to Javascript, I don't get the idea of synchronous interpreting. If you have time, making a great video tutorial would be so great. Keep up the good work.👏 looking forward to the next video. You can consider me a #1 fan 👍🏻 cheers, M.
@mikelemon5109
@mikelemon5109 Жыл бұрын
Hey nice tut I'm trying to run it in 2023 but after doing the npm install and just double clicking the index.html file in the examples folder of the obj viewer demo doesn't work and the written tutorial web is 404, any chance for a quick explanation of how to run it?
@LeoniVoltz
@LeoniVoltz 2 жыл бұрын
What do you mean by "install the dependencies and start the server" in min 1:28. Do I need a server to view the 3D object? I am struggeling now since one day with that, becuase I am quite new to coding and did never had to install a server or sth like that. When I open it, I get a blank page and I have read that I somehow need a server. what would be the easiest way to get that fixed? I just want to view a 3D object :(
@Meltdown_Gaming
@Meltdown_Gaming 2 жыл бұрын
2:43
@serhiip5206
@serhiip5206 2 жыл бұрын
Fetch API cannot load URL scheme "file" is not supported.
@uixmat
@uixmat 4 жыл бұрын
Great tutorial but my model gives the following error in console: [.WebGL=0x7fc0e80ab600]GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to access out of range vertices in attribute 1
@Dan2000kr
@Dan2000kr 5 жыл бұрын
Dude, you are awesome! I get really fascinating when I see people like you, that use time for making such content!
@priyankahegde
@priyankahegde 4 жыл бұрын
Thank you for this great tutorial. I tried the code you shared to render r2-d2.obj and i get a blank canvas when i refresh the browser page. Is there something missing in the video when i try it with the latest branch ?
@MrAer85
@MrAer85 3 жыл бұрын
You are my hero. Not messing with npm for now (maybe later). I am just trying to get some code running on an xamp. This has got me back on track.
@ritikkatkam2845
@ritikkatkam2845 3 жыл бұрын
Sir ... i downloaded the code from your github it works but this is not working if I add other 3D obj files in assets folder can you please tell me whats wrong
@anaymittal7720
@anaymittal7720 2 жыл бұрын
2:42 is where the video actually starts :)
@ravivora757
@ravivora757 4 жыл бұрын
thanks man.
@deanrezaei5107
@deanrezaei5107 2 жыл бұрын
awesome video. Thanks
@marc9169
@marc9169 4 жыл бұрын
I can't make it work, the console says: Failed to load resource: the server responded with a status of 404 (Not Found). Anyone can help me pls?
@nguyenduc6288
@nguyenduc6288 5 жыл бұрын
what type of object is the model when it's imported? is it possible to get the mesh and the material objects of the model? I imported the model but was unable to get its mesh or anything from it to do further calculation
@subhashchandra2107
@subhashchandra2107 4 жыл бұрын
Hey , from where you downloaded this obj and mtl files?
@nishagharpure5342
@nishagharpure5342 3 жыл бұрын
I have a human obj file and I want to change its waist, bust, etc according to form input. What should I do?
@lliammcbean6819
@lliammcbean6819 3 жыл бұрын
This is low key a big ask. Ideally I would say load different models for preset sizes. Geometry and vertices are manilpulatable within the vertex shader of the object but I have never heard of applying a custom shader to a model.
@ivanenzhaev2373
@ivanenzhaev2373 5 жыл бұрын
Maybe has someone a link on simple example how to load an object from OBJ using Three.js and TypeScript?
@lliammcbean6819
@lliammcbean6819 3 жыл бұрын
No. This is as simple as it gets.
@mariocabrera6766
@mariocabrera6766 4 жыл бұрын
Thank you bro, I'll have extra points for this
@artyombelluyan8605
@artyombelluyan8605 6 жыл бұрын
Hello my freand. Thanks for the video tutorial. Sorry for my bad english, i have a querstion. How make a buttons "cam 1" "cam 2" "cam3" & click to button change camera positon froм object?.The buttons are responsible for the camera position.
@sirlock1945
@sirlock1945 5 жыл бұрын
Yes you can.
@michelecattellani2157
@michelecattellani2157 3 жыл бұрын
Man we need more of this. Thank you a lot
@dgpham3909
@dgpham3909 6 жыл бұрын
I pulled the code from github and run the server. But it doesn't render the object like in the video. The object look black and i hardly see anything
@RigvedDeshpandeArt
@RigvedDeshpandeArt 6 жыл бұрын
Does your scene have a light? Try creating a point light and adding it to your scene. var light = new THREE.PointLight( 0xff0000, 1, 100 ); light.position.set( 50, 50, 50 ); scene.add(light); Hope this helps!
@moeminkhant2995
@moeminkhant2995 4 жыл бұрын
download the github file and run it. but nothing comeup any idea whyy?
@moeminkhant2995
@moeminkhant2995 4 жыл бұрын
or this only work with server?
@fabisierra7655
@fabisierra7655 3 жыл бұрын
@@moeminkhant2995 a little late, but, yes, only run with server :)
@mayankkumargiri4312
@mayankkumargiri4312 6 жыл бұрын
Thanks a lot. Nice tutorial.
@ministryofhumor
@ministryofhumor 6 жыл бұрын
How to apply a cubemap/reflections of skybox on the object?
@chasercode1349
@chasercode1349 6 жыл бұрын
var textureSkyCube=new THREE.CubeTextureLoader().setPath("images/sky/").load(["lf.jpg","rt.jpg","up.jpg","dn.jpg","ft.jpg","bk.jpg"]); and add material var mat=new THREE.MeshPhongMaterial({ color:0x00253C, shininess:80, envMap:textureSkyCube, reflectivity:0.8, combine:THREE.MixOperation, });
@葛袁军
@葛袁军 6 жыл бұрын
One question: how to import OBJLoader as a es6 module?
@DesignByAdrian
@DesignByAdrian 6 жыл бұрын
This is currently a mess and you need to do some web pack magic: github.com/mrdoob/three.js/issues/9562#issuecomment-394542093
@babali840
@babali840 5 жыл бұрын
Do not forget to create a server, il will allows javascript to read local files ;) threejs.org/docs/#manual/en/introduction/How-to-run-things-locally
@abdulbasitikram871
@abdulbasitikram871 6 жыл бұрын
Great tutoral sir. i have question for you sir. how can i access or get layers of .obj file in three js?? means how can i change the color of .obj file in three js please sir answer
@MuffinMan0521
@MuffinMan0521 6 жыл бұрын
You can use the chrome console inspector to see what's available to you and change properties to see what they do. The object loader will give you a THREE.Group, from there you can enumerate the children and then use material.color.setHex(0xFFF) syntax to set a color of a particular child.
@abdulbasitikram871
@abdulbasitikram871 6 жыл бұрын
MuffinMan0521 Very Thank u brother, actually i want to get data of .obj materials in three.JS . i am working on a project that design 3d custom product. so i want to access materials layers which i build in 3d max design. if customer want to edit design of any part of shirt etc.. i just want to get or fetch data. Like... dyo.blksport.com/ Please do some help
@abdulbasitikram871
@abdulbasitikram871 6 жыл бұрын
Also I cant's find Three.Group There in my console?
@MuffinMan0521
@MuffinMan0521 6 жыл бұрын
I suggest asking on stackoverflow. I'm not sure.
@abdulbasitikram871
@abdulbasitikram871 6 жыл бұрын
MuffinMan0521 Thanks for helping bro
@6B26asyGKDo
@6B26asyGKDo 4 жыл бұрын
every tutorial I watch about this is completely useless, and their stupid github files DO NOT WORK
@zanepokemaster
@zanepokemaster 4 жыл бұрын
I'm ion the same boat, what's going on?
Display your own 3D Model with Javascript | three.js
13:49
Mike Smith
Рет қаралды 47 М.
React Three Fiber (R3F) - The Basics
1:10:56
rithmic
Рет қаралды 74 М.
The Joker wanted to stand at the front, but unexpectedly was beaten up by Officer Rabbit
00:12
Ozoda - Lada ( Official Music Video 2024 )
06:07
Ozoda
Рет қаралды 18 МЛН
18.7: Loading OBJ Model - WebGL and p5.js Tutorial
7:14
The Coding Train
Рет қаралды 66 М.
WebGL:  Loader OBJ
38:09
Konstantin Bondarenko
Рет қаралды 887
The Value of Source Code
17:46
Philomatics
Рет қаралды 49 М.
I Remade YouTube From Scratch Using Just Bash
17:51
icitry
Рет қаралды 13 М.
Being Competent With Coding Is More Fun
11:13
TheVimeagen
Рет қаралды 87 М.
THREE.js: Loading a Model
10:07
Robot Bobby
Рет қаралды 5 М.
Enable3D - Javascript 3D engine with physics
14:59
Genka
Рет қаралды 17 М.
I wish I knew this before using React Three Fiber
28:23
Rabbit Hole Syndrome
Рет қаралды 124 М.