UNPKG

@softrobot/loaders.gl-draco

Version:

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

73 lines (64 loc) 3.12 kB
import _regeneratorRuntime from "@babel/runtime/regenerator"; import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; import _typeof from "@babel/runtime/helpers/esm/typeof"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } import { VERSION } from './lib/utils/version'; import { loadDracoDecoderModule } from './lib/draco-module-loader'; import DracoParser from './lib/draco-parser'; export var DracoWorkerLoader = { name: 'Draco', id: 'draco', module: 'draco', version: VERSION, worker: true, extensions: ['drc'], mimeTypes: ['application/octet-stream'], binary: true, tests: ['DRACO'], options: { draco: { decoderType: (typeof WebAssembly === "undefined" ? "undefined" : _typeof(WebAssembly)) === 'object' ? 'wasm' : 'js', libraryPath: "libs/", extraAttributes: {} } } }; export var DracoLoader = _objectSpread(_objectSpread({}, DracoWorkerLoader), {}, { parse: parse }); function parse(_x, _x2, _x3, _x4) { return _parse.apply(this, arguments); } function _parse() { _parse = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(arrayBuffer, options, context, loader) { var _yield$loadDracoDecod, draco, dracoParser; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return loadDracoDecoderModule(options); case 2: _yield$loadDracoDecod = _context.sent; draco = _yield$loadDracoDecod.draco; dracoParser = new DracoParser(draco); _context.prev = 5; return _context.abrupt("return", dracoParser.parseSync(arrayBuffer, _objectSpread({ extraAttributes: options.draco && options.draco.extraAttributes || null }, options.parseOptions || {}))); case 7: _context.prev = 7; dracoParser.destroy(); return _context.finish(7); case 10: case "end": return _context.stop(); } } }, _callee, null, [[5,, 7, 10]]); })); return _parse.apply(this, arguments); } //# sourceMappingURL=draco-loader.js.map