UNPKG

@loaders.gl/draco

Version:

Framework-independent loader and writer for Draco compressed meshes and point clouds

49 lines 1.42 kB
// loaders.gl // SPDX-License-Identifier: MIT // Copyright (c) vis.gl contributors import { extractLoadLibraryOptions } from '@loaders.gl/worker-utils'; import { VERSION } from "./lib/utils/version.js"; import DracoParser from "./lib/draco-parser.js"; import { loadDracoDecoderModule } from "./lib/draco-module-loader.js"; /** * Worker loader for Draco3D compressed geometries */ export const DracoWorkerLoader = { dataType: null, batchType: null, name: 'Draco', id: 'draco', module: 'draco', // shapes: ['mesh'], version: VERSION, worker: true, extensions: ['drc'], mimeTypes: ['application/octet-stream'], binary: true, tests: ['DRACO'], options: { draco: { decoderType: typeof WebAssembly === 'object' ? 'wasm' : 'js', // 'js' for IE11 extraAttributes: {}, attributeNameEntry: undefined } } }; /** * Loader for Draco3D compressed geometries */ export const DracoLoader = { ...DracoWorkerLoader, parse }; async function parse(arrayBuffer, options) { const { draco } = await loadDracoDecoderModule(extractLoadLibraryOptions(options), options?.draco?.decoderType || 'wasm'); const dracoParser = new DracoParser(draco); try { return dracoParser.parseSync(arrayBuffer, options?.draco); } finally { dracoParser.destroy(); } } //# sourceMappingURL=draco-loader.js.map