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.

storage
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.

ESM import works with Node.js 14+; require() from subpath is not officially supported.

import { DracoEncoderModule } from 'draco3d'

Same as encoder; prefer named exports from main package entry.

import { DracoDecoderModule } from 'draco3d'

For Node.js-specific binary module, import the subpath directly for full module; named export may not include binary.

import draco_encoder from 'draco3d/draco_encoder_node.js'

Same as encoder; subpath import ensures Node.js binary is used.

import draco_decoder from 'draco3d/draco_decoder_node.js'

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 footguns
gotchaDraco modules are async; must use await or then() to get the module instance.
breakingIn draco3d@1.5.0, the main exports changed from CommonJS to ESM. CommonJS require() may still work but is deprecated.
deprecatedThe old direct require('draco3d/draco_encoder_node') without the .js extension is deprecated in favor of the main package entry.
gotchaMemory management must be handled manually; not freeing decoder/encoder objects can cause leaks.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
15 hits · last 30 days
gptbot
3
amazonbot
3
bytedance
2
ahrefsbot
1
Resources