The @loaders.gl/draco
module handles compressing and decompressing of 3D meshes and point clouds with DRACO.
npm install @loaders.gl/core @loaders.gl/draco
Loader |
---|
DracoLoader |
DracoWorkerLoader |
DracoWriter |
See point cloud / mesh category.
Draco support requires the Draco libraries, which are quite big (see table below). By default, these will be loaded from CDN but can optionally be bundled and supplied by the application through the top-level options.modules
option:
Bundling the entire draco3d
library:
import draco from 'draco3d';
import {setLoaderOptions} from '@loaders.gl/core';
setLoaderOptions({
modules: {
draco3d
}
});
Bundling only the WebAssembly decoder
import {setLoaderOptions} from '@loaders.gl/core';
setLoaderOptions({
modules: {
'draco_wasm_wrapper.js': require('@loaders.gl/draco/libs/draco_wasm_wrapper.js'),
'draco_decoder.wasm': require('@loaders.gl/draco/libs/draco_decoder.wasm') // NOTE: importing `wasm` requires bundler config
}
});
Library | Import | Install | Size | Description |
---|---|---|---|---|
options.libs.draco3d | require('draco3d') | npm install draco3d | ~1.5MB | The full Draco library (encode + decode, web assembly + IE11 javascript fallback). |
options.libs['draco_decoder.wasm'] | ArrayBuffer | ~320K | manual copy | Web Assembly Decoder (access using draco_wasm_wrapper.js ) |
options.libs['draco_wasm_wrapper.js'] | require('.../draco_decoder.js') | ~64K | manual copy | JavaScript wrapper for draco_decoder.wasm |
options.libs['draco_decoder.js'] | require('.../draco_decoder.js') | ~790K | manual copy | JavaScript decoder (fallback for IE11) |
options.libs['draco_encoder.js'] | require('.../draco_encode.js') | ~900K | manual copy | Encoder part of the library |
Remarks
draco_decoder.wasm
and draco_wasm_wrapper.js
, and still rely on the default setup to load the IE11 fallback library and the encoder code from CDN when needed.wasm
files) must be imported/loaded as binary data (ArrayBuffer
). An option for webpack users is the arraybuffer-loader
webpack "loader".Based on Draco examples, under the Apache 2.0 license.