Registry / storage / draco3d

draco3d

JSON →
library1.5.7jsnpmunverified

Draco3D is a library for compressing and decompressing 3D geometric meshes and point clouds, developed by Google to improve storage and transmission of 3D graphics. The NPM package version 1.5.7 provides Node.js bindings for the Draco encoder and decoder. It supports compression of points, connectivity, texture coordinates, normals, and other generic attributes. Differentiating from raw 3D formats, Draco significantly reduces file sizes while maintaining visual fidelity. The library is released as C++/JavaScript source code, with the NPM package offering pre-built decoders for Node.js and browser usage. Release cadence is stable with periodic updates aligned with the main Draco repository.

npm install draco3d
INSTALL
IMPORT
SIG · DRACO3D
D
draco3d
storagejavascriptv1.5.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DracoEncoderModule
import { DracoEncoderModule } from 'draco3d'
const DracoEncoderModule = require('draco3d/draco_encoder_node')
ESM import works with Node.js 14+; require() from subpath is not officially supported.
DracoDecoderModule
import { DracoDecoderModule } from 'draco3d'
const DracoDecoderModule = require('draco3d/draco_decoder_node')
Same as encoder; prefer named exports from main package entry.
draco_encoder
import draco_encoder from 'draco3d/draco_encoder_node.js'
import { draco_encoder } from 'draco3d'
For Node.js-specific binary module, import the subpath directly for full module; named export may not include binary.
draco_decoder
import draco_decoder from 'draco3d/draco_decoder_node.js'
import { draco_decoder } from 'draco3d'
Same as encoder; subpath import ensures Node.js binary is used.

Demonstrates basic Draco decode and encode using Node.js: reads a .drc file, decodes to mesh, re-encodes with default settings, and writes output.

import { DracoEncoderModule, DracoDecoderModule } from 'draco3d'; import fs from 'fs'; (async () => { const encoder = await DracoEncoderModule(); const decoder = await DracoDecoderModule(); // Example: decode a .drc file const compressedData = fs.readFileSync('bunny.drc'); const decoderModule = decoder; const buffer = new decoderModule.DecoderBuffer(); buffer.Init(compressedData, compressedData.length); const dec = new decoderModule.Decoder(); const geometryType = dec.GetEncodedGeometryType(buffer); let mesh = null; if (geometryType === decoderModule.TRIANGULAR_MESH) { mesh = new decoderModule.Mesh(); const status = dec.DecodeBufferToMesh(buffer, mesh); if (!status.ok()) throw new Error('Decode failed'); } // Encode mesh with different settings const enc = new encoderModule.Encoder(); const encodedData = enc.EncodeMeshToDracoBuffer(mesh); fs.writeFileSync('output.drc', Buffer.from(encodedData)); console.log('Done'); decoderModule.destroy(mesh); decoderModule.destroy(dec); decoderModule.destroy(buffer); })();
Debug
Known issues
gotchaDraco modules are async; must use await or then() to get the module instance.
fix
Use `const encoder = await DracoEncoderModule();` or wrap in async function.
affects: >=1.3.0
breakingIn draco3d@1.5.0, the main exports changed from CommonJS to ESM. CommonJS require() may still work but is deprecated.
fix
Use ES module import syntax or set { type: 'module' } in package.json. For CJS, use dynamic import: `const { DracoEncoderModule } = await import('draco3d');`.
affects: >=1.5.0
deprecatedThe old direct require('draco3d/draco_encoder_node') without the .js extension is deprecated in favor of the main package entry.
fix
Use `import { DracoEncoderModule } from 'draco3d'` instead.
affects: >=1.5.0
gotchaMemory management must be handled manually; not freeing decoder/encoder objects can cause leaks.
fix
Call `DecoderModule.destroy(instance)` or use wrappers that manage memory.
affects: >=1.0.0
Errors
Common errors & fixes
Error: DracoDecoderModule is not a constructor
Treating the module as a synchronous class instead of an async factory function.
fix
Use `const decoder = await DracoDecoderModule();` then use `new decoder.Decoder();`.
TypeError: Cannot read property 'Init' of undefined
Forgot to create a DecoderBuffer instance; the buffer method is on the module, not the decoder.
fix
Create buffer via `const buffer = new decoder.DecoderBuffer();` then call `buffer.Init(data, length);`.
Module not found: Can't resolve 'draco3d'
Installed draco3d but used wrong import path or bundler configuration (e.g., Webpack without fallback).
fix
Ensure draco3d is in node_modules and import from 'draco3d'. In bundlers, you may need to add fallback for 'fs' and 'path'.
Upgrade
Version history
1.5.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
14
Resources
draco3d — npm install draco3d · libregistry