{"id":47422,"library":"draco3d","title":"Draco3D","description":"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.","status":"active","version":"1.5.7","language":"javascript","source_language":"en","source_url":"https://github.com/google/draco","tags":["javascript","geometry","compression","mesh","point cloud"],"install":[{"cmd":"npm install draco3d","lang":"bash","label":"npm"},{"cmd":"yarn add draco3d","lang":"bash","label":"yarn"},{"cmd":"pnpm add draco3d","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import works with Node.js 14+; require() from subpath is not officially supported.","wrong":"const DracoEncoderModule = require('draco3d/draco_encoder_node')","symbol":"DracoEncoderModule","correct":"import { DracoEncoderModule } from 'draco3d'"},{"note":"Same as encoder; prefer named exports from main package entry.","wrong":"const DracoDecoderModule = require('draco3d/draco_decoder_node')","symbol":"DracoDecoderModule","correct":"import { DracoDecoderModule } from 'draco3d'"},{"note":"For Node.js-specific binary module, import the subpath directly for full module; named export may not include binary.","wrong":"import { draco_encoder } from 'draco3d'","symbol":"draco_encoder","correct":"import draco_encoder from 'draco3d/draco_encoder_node.js'"},{"note":"Same as encoder; subpath import ensures Node.js binary is used.","wrong":"import { draco_decoder } from 'draco3d'","symbol":"draco_decoder","correct":"import draco_decoder from 'draco3d/draco_decoder_node.js'"}],"quickstart":{"code":"import { DracoEncoderModule, DracoDecoderModule } from 'draco3d';\nimport fs from 'fs';\n\n(async () => {\n  const encoder = await DracoEncoderModule();\n  const decoder = await DracoDecoderModule();\n\n  // Example: decode a .drc file\n  const compressedData = fs.readFileSync('bunny.drc');\n  const decoderModule = decoder;\n  const buffer = new decoderModule.DecoderBuffer();\n  buffer.Init(compressedData, compressedData.length);\n  const dec = new decoderModule.Decoder();\n  const geometryType = dec.GetEncodedGeometryType(buffer);\n  let mesh = null;\n  if (geometryType === decoderModule.TRIANGULAR_MESH) {\n    mesh = new decoderModule.Mesh();\n    const status = dec.DecodeBufferToMesh(buffer, mesh);\n    if (!status.ok()) throw new Error('Decode failed');\n  }\n  // Encode mesh with different settings\n  const enc = new encoderModule.Encoder();\n  const encodedData = enc.EncodeMeshToDracoBuffer(mesh);\n  fs.writeFileSync('output.drc', Buffer.from(encodedData));\n  console.log('Done');\n  decoderModule.destroy(mesh);\n  decoderModule.destroy(dec);\n  decoderModule.destroy(buffer);\n})();","lang":"javascript","description":"Demonstrates basic Draco decode and encode using Node.js: reads a .drc file, decodes to mesh, re-encodes with default settings, and writes output."},"warnings":[{"fix":"Use `const encoder = await DracoEncoderModule();` or wrap in async function.","message":"Draco modules are async; must use await or then() to get the module instance.","severity":"gotcha","affected_versions":">=1.3.0"},{"fix":"Use ES module import syntax or set { type: 'module' } in package.json. For CJS, use dynamic import: `const { DracoEncoderModule } = await import('draco3d');`.","message":"In draco3d@1.5.0, the main exports changed from CommonJS to ESM. CommonJS require() may still work but is deprecated.","severity":"breaking","affected_versions":">=1.5.0"},{"fix":"Use `import { DracoEncoderModule } from 'draco3d'` instead.","message":"The old direct require('draco3d/draco_encoder_node') without the .js extension is deprecated in favor of the main package entry.","severity":"deprecated","affected_versions":">=1.5.0"},{"fix":"Call `DecoderModule.destroy(instance)` or use wrappers that manage memory.","message":"Memory management must be handled manually; not freeing decoder/encoder objects can cause leaks.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'/javascript':74 '1.5.7':31 '3d':10,25,57 'align':98 'attribut':53 'bind':34 'browser':89 'built':84 'c':73 'cadenc':92 'cloud':15,109 'code':76 'compress':7,43,106 'connect':46 'coordin':48 'decod':40,85 'decompress':9 'develop':16 'differenti':54 'draco':37,59,102 'draco3d':1,2 'encod':38 'fidel':67 'file':62 'format':58 'generic':52 'geometr':11 'geometri':105 'googl':18 'graphic':26 'improv':20 'javascript':104 'librari':5,69 'main':101 'maintain':65 'mesh':12,107 'node.js':33,87 'normal':49 'npm':28,79 'offer':81 'packag':29,80 'period':96 'point':14,45,108 'pre':83 'pre-built':82 'provid':32 'raw':56 'reduc':61 'releas':71,91 'repositori':103 'signific':60 'size':63 'sourc':75 'stabl':94 'storag':21 'support':42 'textur':47 'transmiss':23 'updat':97 'usag':90 'version':30 'visual':66","created_at":"2026-06-07T16:51:26.311943+00:00","updated_at":"2026-06-07T16:51:26.311943+00:00","problems":[{"fix":"Use `const decoder = await DracoDecoderModule();` then use `new decoder.Decoder();`.","cause":"Treating the module as a synchronous class instead of an async factory function.","error":"Error: DracoDecoderModule is not a constructor"},{"fix":"Create buffer via `const buffer = new decoder.DecoderBuffer();` then call `buffer.Init(data, length);`.","cause":"Forgot to create a DecoderBuffer instance; the buffer method is on the module, not the decoder.","error":"TypeError: Cannot read property 'Init' of undefined"},{"fix":"Ensure draco3d is in node_modules and import from 'draco3d'. In bundlers, you may need to add fallback for 'fs' and 'path'.","cause":"Installed draco3d but used wrong import path or bundler configuration (e.g., Webpack without fallback).","error":"Module not found: Can't resolve 'draco3d'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/google/draco#readme","github":"https://github.com/google/draco","docs":null,"changelog":null,"pypi":null,"npm":"draco3d","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}