Skip to main content

Geometry compression module

Move geometry efficiently without changing its meaning.

The Draco module decodes and encodes compressed meshes and point clouds. It supports render-ready mesh objects, Mesh Arrow tables, worker execution, and the glTF compression extension path.

A layered 3D format stack

Choose the delivery layer. Keep the data path.

A scene file, a tiled world, and a compressed payload solve different problems. loaders.gl keeps those boundaries visible while providing the readers needed to move between them.

Application-facing results

scenegraphtile contentMesh / point-listTextureLevel

Compression as a pipeline stage

Decode for rendering, or keep the columns.

Draco is a payload codec, not the application data model. The loader can return typed geometry for a renderer or Arrow-compatible columns for processing and conversion.

Inputs

Compressed meshes and point clouds

Outputs

Mesh objects or Mesh Arrow tables

Execution

Main thread, worker, and stateful batch encoding

Composition

glTF KHR_draco_mesh_compression payloads

Detailed guide

Draco module details

The sections below cover installation, loaders, writers, batch encoding, worker behavior, and glTF integration.

The Draco loaders in @loaders.gl/scene handle compressing and decompressing of 3D meshes and point clouds with DRACO.

Installation​

npm install @loaders.gl/core @loaders.gl/scene

The injectable draco3d npm backend is an optionalDependency. The default loader and writer use vendored runtimes and work with npm install --omit=optional. If you omit optional dependencies and want to inject options.modules.draco3d, install draco3d explicitly.

The scene root exports loader metadata and public Draco types. Import DracoLoaderWithParser from @loaders.gl/scene/draco for direct parsing, and import writers and encoding helpers from @loaders.gl/scene/draco. Bundled runtime URL helpers use @loaders.gl/scene/draco (an ESM entry point).

Loaders and Writers​

LoaderDescription
DracoLoaderLoads Draco meshes and point clouds as Mesh objects or Mesh Arrow tables.
DracoWriterEncodes Draco meshes and point clouds from Mesh or Mesh Arrow table data.

encodeDracoInBatches accepts an async or synchronous iterator of geometry batches. With worker: true it leases one worker for the full iterator and keeps one Draco encoder alive, which is useful for large exports and stateful batch pipelines. With worker: false it uses the same lifecycle locally.

The glTF writer exposes the same capability through {gltf: {draco: {enabled: true}}}. This is asynchronous because the official Draco encoder is WebAssembly-backed; use GLTFWriter.encode rather than encodeSync. The writer appends KHR_draco_mesh_compression payloads to a single buffer and leaves the original accessors in place for compatibility.

Additional APIs​

See the Mesh Arrow table and point cloud / mesh category documentation.

Dependencies​

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
}
});

Using the bundled WebAssembly decoder and encoder assets:

import {setLoaderOptions} from '@loaders.gl/core';
import {getDracoLibraryOptions} from '@loaders.gl/scene/draco';
setLoaderOptions(getDracoLibraryOptions());
LibraryImportInstallSizeDescription
options.modules.draco3drequire('draco3d')npm install draco3d~1.5MBThe full Draco library (encode + decode, web assembly + IE11 javascript fallback).
options.modules['draco_decoder.wasm']ArrayBuffer~320Kmanual copyWeb Assembly Decoder (access using draco_wasm_wrapper.js)
options.modules['draco_wasm_wrapper.js']require('.../draco_decoder.js')~64Kmanual copyJavaScript wrapper for draco_decoder.wasm
options.modules['draco_decoder.js']require('.../draco_decoder.js')~790Kmanual copyJavaScript decoder (JavaScript fallback)
options.modules['draco_encoder.js']require('.../draco_encode.js')~900Kmanual copyEncoder part of the library

Remarks

  • Due to the size of the Draco libraries, a reasonable strategy for applications that wish to bundle their dependencies (e.g to avoid relying on a potentially flaky CDN) might be to bundle and supply only draco_decoder.wasm and draco_wasm_wrapper.js, and still rely on the default setup to load the JavaScript fallback library and the encoder code from CDN when needed.
  • Web Assembly code (wasm files) must be imported/loaded as binary data (ArrayBuffer). An option for webpack users is the arraybuffer-loader webpack "loader".

Attributions​

Based on the Google Draco 1.5.7 release under the Apache 2.0 license. Every vendored runtime asset is recorded with its upstream URL and SHA-256 checksum in src/libs/README.md.

Draco roadmap

The Draco module now supports glTF-optimized decoding, retained quantization metadata, selective extraction, encoding diagnostics, and batch encoding. The remaining planned work is tracked as compatibility and lifecycle improvements rather than a worker-pool abstraction.

AreaCurrent direction
Presetsgltf, webgpu, and balanced profiles provide explicit, reproducible defaults.
ConformanceKeep cross-runtime fixtures for full and glTF decoder builds.
InteroperabilityPreserve names, normalized flags, transforms, and metadata across Arrow/Draco round trips.
MemoryReuse initialized runtimes and process batches sequentially; worker pooling is tracked separately.
CompatibilityRetain legacy writer/loader entry points while steering new code to encodeDraco and typed reports.

The browser encoder uses the versioned Draco 1.5.7 wrapper and WebAssembly pair. This keeps the default writer path independent of the Node-only draco3d package entry point; applications that need offline or worker-local loading can opt into the checked-in assets with useLocalLibraries.

Sources and credits​

See the package source and license inventory and the project-wide Attributions and Credits.