DRACO Loader
Video Lecture
Description
Tip
This course was updated in 2024. For the newer content, please visit GLTF Draco
The DRACO loader is used to load geometry compressed with the Draco library.
Draco is an open source library for compressing and decompressing 3D meshes and point clouds.
glTF files can also be compressed using the DRACO library, and they can also be loaded using the glTF loader. We can configure the glTF loader to use the DRACOLoader to decompress the file in such cases.
Caveat, compressing a file doesn't necessarily mean that the file will be presented in the scene faster. While compressed geometry can result in a significantly smaller file size, the client browsers CPU will use more time decoding the file, and also need to download additional libraries into a web worker to run the decompression process.
See below example showing that the compressed file appears later in the scene than the uncompressed version.
All files and applications are different, you will need to test using compression or not if you want to know if compression will benefit your application or not.
Compressed (DRACO) |
Uncompressed |
Resources
The 3D models used in this lesson can be easily created using Blender. If you don't want to use blender to create the models, then you can download them from the zip file named models4.zip
. Extract the models4.zip
contents into the ./dist/client/models/
folder.
Note
Since Three release 148, you will find the Draco libraries in the .\node_modules\three\examples\jsm\libs\draco\
folder.
Tip
Instead of hosting the Draco decoder libs yourself, you may find it easier to download them from a CDN.
E.g.,
const draco = new DRACOLoader();
draco.setDecoderConfig({ type: 'js' });
draco.setDecoderPath('https://www.gstatic.com/draco/v1/decoders/');
Lesson Script
./src/client/client.ts
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 |
|
Useful Links
DRACOLoader (Official Documentation)