Advancing GLTF Scenes
Video Lecture
Section | Video Links | |
---|---|---|
Advancing GLTF Scenes : Part 1 | ||
Advancing GLTF Scenes : Part 2 |
Description
With this example, we will improve on our knowledge of Blender, Leva, importing models, the Object3D hierarchy, Environment and introduce the Drei ContactShadows
.
The glTF specification provides a way to describe whole scenes which may include a large hierarchy of other 3D objects, as well as lighting, animations, materials, textures, skeletons, morph targets, cameras and even other scenes.
This means that you can create almost your whole scene using a 3D modelling tool such a Blender, and import it into the Three.js scene with much less work that writing it all by hand.
However, while Threejs supports the glTF specification to a very high standard, and many 3D applications such as Blender, Maya, 3DS Max, etc., can also export the many features of glTF, there won't always be 100% compatibility between each implementation since each application is developed independently, uses different teams of people, and follows the priorities of different road maps and end use cases.
So you will have to fill in the gaps regardless. Needless to say, glTF is the best format to use in almost all use-cases where you want to import a model into Three.js.
We will begin this lesson by creating a new model in Blender. If you don't want to create the model in Blender, then you can download the final model as shown in this video from scene.zip. Then extract the contents into the folder ./public/models/
.
./src/App.jsx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
|
Working Example
Useful Links
glTFAdvanced (Working Example) | sbedit.net | |
GLTFLoader | threejs.org | sbcode.net |
MeshPhysicalMaterial | threejs.org | sbcode.net |
GitHub Branch
git clone https://github.com/Sean-Bradley/React-Three-Fiber-Boilerplate.git
cd React-Three-Fiber-Boilerplate
git checkout glTFAdvanced
npm install
npm start