Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@loaders.gl/draco

Package Overview
Dependencies
Maintainers
10
Versions
339
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/draco - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

dist/dist.min.js

@@ -1,1 +0,1 @@

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var o in r)("object"==typeof exports?exports:t)[o]=r[o]}}(window,(function(){return function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=3)}([function(t,e,r){"use strict";(function(t,o){r.d(e,"a",(function(){return i})),r.d(e,"b",(function(){return a})),r.d(e,"c",(function(){return s}));const n={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==t&&t,document:"undefined"!=typeof document&&document},i=n.global||n.self||n.window,a="object"!=typeof o||"[object process]"!==String(o)||o.browser,s="function"==typeof importScripts,c=void 0!==o&&o.version&&o.version.match(/v([0-9]*)/);c&&parseFloat(c[1])}).call(this,r(2),r(4))},function(t,e){},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){(function(e){const o=r(5),n="undefined"==typeof window?e:window;n.loaders=n.loaders||{},t.exports=Object.assign(n.loaders,o)}).call(this,r(2))},function(t,e){var r,o,n=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(t){if(r===setTimeout)return setTimeout(t,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(t){r=i}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(t){o=a}}();var c,d=[],u=!1,l=-1;function h(){u&&c&&(u=!1,c.length?d=c.concat(d):l=-1,d.length&&f())}function f(){if(!u){var t=s(h);u=!0;for(var e=d.length;e;){for(c=d,d=[];++l<e;)c&&c[l].run();l=-1,e=d.length}c=null,u=!1,function(t){if(o===clearTimeout)return clearTimeout(t);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(t);try{o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}(t)}}function y(t,e){this.fun=t,this.array=e}function A(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];d.push(new y(t,e)),1!==d.length||u||s(f)},y.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=A,n.addListener=A,n.once=A,n.off=A,n.removeListener=A,n.removeAllListeners=A,n.emit=A,n.prependListener=A,n.prependOnceListener=A,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},function(t,e,r){"use strict";r.r(e);var o=r(0),n=r(1);const i="2.0.0",a={};async function s(t,e=null,r={}){return e&&(t=function(t,e,r){const n=r.modules||{};if(n[t])return n[t];if(r.CDN)return function(t,e){if(!t)throw new Error(e||"loader assertion failed.")}(r.CDN.startsWith("http")),`${r.CDN}/${e}@${i}/dist/libs/${t}`;if(o.c)return`../src/libs/${t}`;return`modules/${e}/src/libs/${t}`}(t,e,r)),a[t]=a[t]||async function(t){if(t.endsWith("wasm")){const e=await fetch(t);return await e.arrayBuffer()}if(!o.b)return Object(n.requireFromFile)(t);if(o.c)return importScripts(t);const e=await fetch(t);return function(t,e){if(!o.b)return Object(n.requireFromString)(t,e);if(o.c)return eval.call(o.a,t),null;const r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch(e){r.text=t}return document.body.appendChild(r),null}(await e.text(),t)}(t),await a[t]}let c,d;async function u(t){const e=t.modules||{};return e.draco3d?{draco:e.draco3d.createDecoderModule()}:(c=c||async function(t){let e,r;switch(t.draco&&t.draco.decoderType){case"js":e=await s("draco_decoder.js","draco",t);break;case"wasm":default:[e,r]=await Promise.all([await s("draco_wasm_wrapper.js","draco",t),await s("draco_decoder.wasm","draco",t)])}return e=e||o.a.DracoDecoderModule,await function(t,e){const r={};e&&(r.wasmBinary=e);return new Promise(e=>{t({...r,onModuleLoaded:t=>e({draco:t})})})}(e,r)}(t),await c)}async function l(t){const e=t.modules||{};return e.draco3d?{draco:e.draco3d.createEncoderModule()}:(d=d||async function(t){let e=await s("draco_encoder.js","draco",t);return e=e||o.a.DracoEncoderModule,new Promise(t=>{e({onModuleLoaded:e=>t({draco:e})})})}(t),await d)}const h={TRIANGULAR_MESH:0,POINT_CLOUD:1},f={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},y={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class A{constructor(t){this.draco=t}destroy(){}destroyGeometry(t){t&&this.draco.destroy(t.dracoGeometry)}parseSync(t){const e=new this.draco.DecoderBuffer;e.Init(new Int8Array(t),t.byteLength);const r=new this.draco.Decoder,o={};let n,i,a;try{const t=r.GetEncodedGeometryType(e);switch(t){case this.draco.TRIANGULAR_MESH:i=new this.draco.Mesh,n=r.DecodeBufferToMesh(e,i),a={type:h.TRIANGULAR_MESH,faceCount:i.num_faces(),attributeCount:i.num_attributes(),vertexCount:i.num_points()};break;case this.draco.POINT_CLOUD:i=new this.draco.PointCloud,n=r.DecodeBufferToPointCloud(e,i),a={type:h.POINT_CLOUD,attributeCount:i.num_attributes(),vertexCount:i.num_points()};break;default:throw new Error("Unknown DRACO geometry type.")}if(!n.ok()||!i.ptr){const t=`DRACO decompression failed: ${n.error_msg()}`;throw i&&this.draco.destroy(i),new Error(t)}o.header={vertexCount:a.vertexCount},o.loaderData={header:a},this.extractDRACOGeometry(r,i,t,o)}finally{this.draco.destroy(r),this.draco.destroy(e)}return o}extractDRACOGeometry(t,e,r,o){const n=this.getAttributes(t,e),i=n.POSITION;if(!i)throw new Error("DRACO decompressor: No position attribute found.");return this.getPositionAttributeMetadata(i),r===this.draco.TRIANGULAR_MESH?(n.indices="TRIANGLE_STRIP"===this.drawMode?this.getMeshStripIndices(t,e):this.getMeshFaceIndices(t,e),o.mode="TRIANGLE_STRIP"===this.drawMode?5:4):o.mode=0,n.indices&&(o.indices={value:n.indices,size:1},delete n.indices),o.attributes=n,o}getPositionAttributeMetadata(t){this.metadata=this.metadata||{},this.metadata.attributes=this.metadata.attributes||{};const e=new this.draco.AttributeQuantizationTransform;if(e.InitFromAttribute(t)){this.metadata.attributes.position.isQuantized=!0,this.metadata.attributes.position.maxRange=e.range(),this.metadata.attributes.position.numQuantizationBits=e.quantization_bits(),this.metadata.attributes.position.minValues=new Float32Array(3);for(let t=0;t<3;++t)this.metadata.attributes.position.minValues[t]=e.min_value(t)}this.draco.destroy(e)}getAttributes(t,e){const r={},o=e.num_points();for(const n in f){const i=this.draco[n],a=t.GetAttributeId(e,i);if(-1!==a){const i=t.GetAttribute(e,a),{typedArray:s}=this.getAttributeTypedArray(t,e,i,n);r[f[n]]={value:s,size:s.length/o}}}return r}getMeshFaceIndices(t,e){const r=e.num_faces(),o=new Uint32Array(3*r),n=new this.draco.DracoInt32Array;for(let i=0;i<r;++i){t.GetFaceFromMesh(e,i,n);const r=3*i;o[r]=n.GetValue(0),o[r+1]=n.GetValue(1),o[r+2]=n.GetValue(2)}return this.draco.destroy(n),o}getMeshStripIndices(t,e){const r=new this.draco.DracoInt32Array;t.GetTriangleStripsFromMesh(e,r);const o=new Uint32Array(r.size());for(let t=0;t<r.size();++t)o[t]=r.GetValue(t);return this.draco.destroy(r),o}getAttributeTypedArray(t,e,r,o){if(0===r.ptr){throw new Error(`DRACO decode bad attribute ${o}`)}const n=y[r.data_type()],i=r.num_components(),a=e.num_points()*i;let s,c;switch(n){case Float32Array:s=new this.draco.DracoFloat32Array,t.GetAttributeFloatForAllPoints(e,r,s),c=new Float32Array(a);break;case Int8Array:s=new this.draco.DracoInt8Array,t.GetAttributeInt8ForAllPoints(e,r,s),c=new Int8Array(a);break;case Int16Array:s=new this.draco.DracoInt16Array,t.GetAttributeInt16ForAllPoints(e,r,s),c=new Int16Array(a);break;case Int32Array:s=new this.draco.DracoInt32Array,t.GetAttributeInt32ForAllPoints(e,r,s),c=new Int32Array(a);break;case Uint8Array:s=new this.draco.DracoUInt8Array,t.GetAttributeUInt8ForAllPoints(e,r,s),c=new Uint8Array(a);break;case Uint16Array:s=new this.draco.DracoUInt16Array,t.GetAttributeUInt16ForAllPoints(e,r,s),c=new Uint16Array(a);break;case Uint32Array:s=new this.draco.DracoUInt32Array,t.GetAttributeUInt32ForAllPoints(e,r,s),c=new Uint32Array(a);break;default:throw new Error("DRACO decoder: unexpected attribute type.")}for(let t=0;t<a;t++)c[t]=s.GetValue(t);return this.draco.destroy(s),{typedArray:c,components:i}}decode(t,e){return this.parseSync(t,e)}}const b={id:"draco",name:"Draco",version:"2.0.0",extensions:["drc"],mimeType:"application/octet-stream",binary:!0,test:"DRACO",options:{draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",workerUrl:"https://unpkg.com/@loaders.gl/draco@2.0.0/dist/draco-loader.worker.js",localWorkerUrl:"modules/draco/dist/draco-loader.worker.dev.js"}}},w={...b,parse:async function(t,e,r,o){const{draco:n}=await u(e),i=new A(n);try{return i.parseSync(t,e)}finally{i.destroy()}}};const p={POSITION:"POSITION",NORMAL:"NORMAL",COLOR_0:"COLOR",TEXCOORD_0:"TEX_COORD"};function m(){}function O(t){const e=t.size(),r=new ArrayBuffer(e),o=new Int8Array(r);for(let r=0;r<e;++r)o[r]=t.GetValue(r);return r}class I{constructor(t,e={}){this.draco=t,this.dracoEncoder=new this.draco.Encoder,this.dracoMeshBuilder=new this.draco.MeshBuilder,this.log=e.log||m}destroy(){this.destroyEncodedObject(this.dracoMeshBuilder),this.destroyEncodedObject(this.dracoEncoder),this.dracoMeshBuilder=null,this.dracoEncoder=null,this.draco=null}destroyEncodedObject(t){t&&this.draco.destroy(t)}encodeSync(t,e){return this._setOptions(e),e.pointcloud?this._encodePointCloud(t):this._encodeMesh(t)}_getAttributesFromMesh(t){const e={...t,...t.attributes};return t.indices&&(e.indices=t.indices),e}_encodePointCloud(t){const e=this._getAttributesFromMesh(t),r=this._createDracoPointCloud(e),o=new this.draco.DracoInt8Array;try{const t=this.dracoEncoder.EncodePointCloudToDracoBuffer(r,!1,o);if(!(t>0))throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${r.num_points()} points\n with ${r.num_attributes()} attributes into ${t} bytes`),O(o)}finally{this.destroyEncodedObject(o),this.destroyEncodedObject(r)}}_encodeMesh(t){const e=this._getAttributesFromMesh(t),r=this._createDracoMesh(e),o=new this.draco.DracoInt8Array;try{const t=this.dracoEncoder.EncodeMeshToDracoBuffer(r,o);if(t<=0)throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${r.num_points()} points\n with ${r.num_attributes()} attributes into ${t} bytes`),O(o)}finally{this.destroyEncodedObject(o),this.destroyEncodedObject(r)}}_setOptions(t={}){if("speed"in t&&this.dracoEncoder.SetSpeedOptions(...t.speed),"method"in t){const e=this.draco[t.method];this.dracoEncoder.SetEncodingMethod(e)}if("quantization"in t)for(const e in t.quantization){const r=t.quantization[e],o=this.draco[e];this.dracoEncoder.SetAttributeQuantization(o,r)}}_createDracoMesh(t){const e=new this.draco.Mesh;try{const r=this._getPositionAttribute(t);if(!r)throw new Error("positions");const o=r.length/3;for(let r in t){const n=t[r];r=p[r]||r,this._addAttributeToMesh(e,r,n,o)}}catch(t){throw this.destroyEncodedObject(e),t}return e}_createDracoPointCloud(t){const e=new this.draco.PointCloud;try{const r=this._getPositionAttribute(t);if(!r)throw new Error("positions");const o=r.length/3;for(let r in t){const n=t[r];r=p[r]||r,this._addAttributeToMesh(e,r,n,o)}}catch(t){throw this.destroyEncodedObject(e),t}return e}_addAttributeToMesh(t,e,r,o){if(!ArrayBuffer.isView(r))return;const n=this._getDracoAttributeType(e,r),i=r.length/o;if("indices"===n){const o=r.length/3;return this.log(`Adding attribute ${e}, size ${o}`),void this.dracoMeshBuilder.AddFacesToMesh(t,o,r)}switch(this.log(`Adding attribute ${e}, size ${i}`),r.constructor.name){case"Int8Array":this.dracoMeshBuilder.AddInt8Attribute(t,n,o,i,r);break;case"Int16Array":this.dracoMeshBuilder.AddInt16Attribute(t,n,o,i,r);break;case"Int32Array":this.dracoMeshBuilder.AddInt32Attribute(t,n,o,i,r);break;case"Uint8Array":case"Uint8ClampedArray":this.dracoMeshBuilder.AddUInt8Attribute(t,n,o,i,r);break;case"Uint16Array":this.dracoMeshBuilder.AddUInt16Attribute(t,n,o,i,r);break;case"Uint32Array":this.dracoMeshBuilder.AddUInt32Attribute(t,n,o,i,r);break;case"Float32Array":default:this.dracoMeshBuilder.AddFloatAttribute(t,n,o,i,r)}}_getDracoAttributeType(t,e){switch(t.toLowerCase()){case"indices":return"indices";case"position":case"positions":case"vertices":return this.draco.POSITION;case"normal":case"normals":return this.draco.NORMAL;case"color":case"colors":return this.draco.COLOR;case"texCoord":case"texCoords":return this.draco.TEX_COORD;default:return this.draco.GENERIC}}_getPositionAttribute(t){for(const e in t){const r=t[e];if(this._getDracoAttributeType(e,r)===this.draco.POSITION)return r}return null}}var _={name:"DRACO",extensions:["drc"],encode:async function(t,e){const{draco:r}=await l(e),o=new I(r);try{return o.encodeSync(t,e)}finally{o.destroy()}},options:{pointcloud:!1}};r.d(e,"DracoLoader",(function(){return w})),r.d(e,"DracoWorkerLoader",(function(){return b})),r.d(e,"DracoWriter",(function(){return _}))}])}));
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var o in r)("object"==typeof exports?exports:t)[o]=r[o]}}(window,(function(){return function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=3)}([function(t,e,r){"use strict";(function(t,o){r.d(e,"a",(function(){return i})),r.d(e,"b",(function(){return a})),r.d(e,"c",(function(){return s}));const n={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==t&&t,document:"undefined"!=typeof document&&document},i=n.global||n.self||n.window,a="object"!=typeof o||"[object process]"!==String(o)||o.browser,s="function"==typeof importScripts,c=void 0!==o&&o.version&&o.version.match(/v([0-9]*)/);c&&parseFloat(c[1])}).call(this,r(2),r(4))},function(t,e){},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){(function(e){const o=r(5),n="undefined"==typeof window?e:window;n.loaders=n.loaders||{},t.exports=Object.assign(n.loaders,o)}).call(this,r(2))},function(t,e){var r,o,n=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(t){if(r===setTimeout)return setTimeout(t,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(t){r=i}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(t){o=a}}();var c,d=[],u=!1,l=-1;function h(){u&&c&&(u=!1,c.length?d=c.concat(d):l=-1,d.length&&f())}function f(){if(!u){var t=s(h);u=!0;for(var e=d.length;e;){for(c=d,d=[];++l<e;)c&&c[l].run();l=-1,e=d.length}c=null,u=!1,function(t){if(o===clearTimeout)return clearTimeout(t);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(t);try{o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}(t)}}function y(t,e){this.fun=t,this.array=e}function b(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];d.push(new y(t,e)),1!==d.length||u||s(f)},y.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=b,n.addListener=b,n.once=b,n.off=b,n.removeListener=b,n.removeAllListeners=b,n.emit=b,n.prependListener=b,n.prependOnceListener=b,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},function(t,e,r){"use strict";r.r(e);var o=r(0),n=r(1);const i="2.0.0",a={};async function s(t,e=null,r={}){return e&&(t=function(t,e,r){const n=r.modules||{};if(n[t])return n[t];if(!o.b)return`modules/${e}/dist/libs/${t}`;if(r.CDN)return function(t,e){if(!t)throw new Error(e||"loader assertion failed.")}(r.CDN.startsWith("http")),`${r.CDN}/${e}@${i}/dist/libs/${t}`;if(o.c)return`../src/libs/${t}`;return`modules/${e}/src/libs/${t}`}(t,e,r)),a[t]=a[t]||async function(t){if(t.endsWith("wasm")){const e=await fetch(t);return await e.arrayBuffer()}if(!o.b)return Object(n.requireFromFile)(t);if(o.c)return importScripts(t);const e=await fetch(t);return function(t,e){if(!o.b)return Object(n.requireFromString)(t,e);if(o.c)return eval.call(o.a,t),null;const r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch(e){r.text=t}return document.body.appendChild(r),null}(await e.text(),t)}(t),await a[t]}let c,d;async function u(t){const e=t.modules||{};return e.draco3d?{draco:e.draco3d.createDecoderModule()}:(c=c||async function(t){let e,r;switch(t.draco&&t.draco.decoderType){case"js":e=await s("draco_decoder.js","draco",t);break;case"wasm":default:[e,r]=await Promise.all([await s("draco_wasm_wrapper.js","draco",t),await s("draco_decoder.wasm","draco",t)])}return e=e||o.a.DracoDecoderModule,await function(t,e){const r={};e&&(r.wasmBinary=e);return new Promise(e=>{t({...r,onModuleLoaded:t=>e({draco:t})})})}(e,r)}(t),await c)}async function l(t){const e=t.modules||{};return e.draco3d?{draco:e.draco3d.createEncoderModule()}:(d=d||async function(t){let e=await s("draco_encoder.js","draco",t);return e=e||o.a.DracoEncoderModule,new Promise(t=>{e({onModuleLoaded:e=>t({draco:e})})})}(t),await d)}const h={TRIANGULAR_MESH:0,POINT_CLOUD:1},f={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},y={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class b{constructor(t){this.draco=t}destroy(){}destroyGeometry(t){t&&this.draco.destroy(t.dracoGeometry)}parseSync(t){const e=new this.draco.DecoderBuffer;e.Init(new Int8Array(t),t.byteLength);const r=new this.draco.Decoder,o={};let n,i,a;try{const t=r.GetEncodedGeometryType(e);switch(t){case this.draco.TRIANGULAR_MESH:i=new this.draco.Mesh,n=r.DecodeBufferToMesh(e,i),a={type:h.TRIANGULAR_MESH,faceCount:i.num_faces(),attributeCount:i.num_attributes(),vertexCount:i.num_points()};break;case this.draco.POINT_CLOUD:i=new this.draco.PointCloud,n=r.DecodeBufferToPointCloud(e,i),a={type:h.POINT_CLOUD,attributeCount:i.num_attributes(),vertexCount:i.num_points()};break;default:throw new Error("Unknown DRACO geometry type.")}if(!n.ok()||!i.ptr){const t=`DRACO decompression failed: ${n.error_msg()}`;throw i&&this.draco.destroy(i),new Error(t)}o.header={vertexCount:a.vertexCount},o.loaderData={header:a},this.extractDRACOGeometry(r,i,t,o)}finally{this.draco.destroy(r),this.draco.destroy(e)}return o}extractDRACOGeometry(t,e,r,o){const n=this.getAttributes(t,e),i=n.POSITION;if(!i)throw new Error("DRACO decompressor: No position attribute found.");return this.getPositionAttributeMetadata(i),r===this.draco.TRIANGULAR_MESH?(n.indices="TRIANGLE_STRIP"===this.drawMode?this.getMeshStripIndices(t,e):this.getMeshFaceIndices(t,e),o.mode="TRIANGLE_STRIP"===this.drawMode?5:4):o.mode=0,n.indices&&(o.indices={value:n.indices,size:1},delete n.indices),o.attributes=n,o}getPositionAttributeMetadata(t){this.metadata=this.metadata||{},this.metadata.attributes=this.metadata.attributes||{};const e=new this.draco.AttributeQuantizationTransform;if(e.InitFromAttribute(t)){this.metadata.attributes.position.isQuantized=!0,this.metadata.attributes.position.maxRange=e.range(),this.metadata.attributes.position.numQuantizationBits=e.quantization_bits(),this.metadata.attributes.position.minValues=new Float32Array(3);for(let t=0;t<3;++t)this.metadata.attributes.position.minValues[t]=e.min_value(t)}this.draco.destroy(e)}getAttributes(t,e){const r={},o=e.num_points();for(const n in f){const i=this.draco[n],a=t.GetAttributeId(e,i);if(-1!==a){const i=t.GetAttribute(e,a),{typedArray:s}=this.getAttributeTypedArray(t,e,i,n);r[f[n]]={value:s,size:s.length/o}}}return r}getMeshFaceIndices(t,e){const r=e.num_faces(),o=new Uint32Array(3*r),n=new this.draco.DracoInt32Array;for(let i=0;i<r;++i){t.GetFaceFromMesh(e,i,n);const r=3*i;o[r]=n.GetValue(0),o[r+1]=n.GetValue(1),o[r+2]=n.GetValue(2)}return this.draco.destroy(n),o}getMeshStripIndices(t,e){const r=new this.draco.DracoInt32Array;t.GetTriangleStripsFromMesh(e,r);const o=new Uint32Array(r.size());for(let t=0;t<r.size();++t)o[t]=r.GetValue(t);return this.draco.destroy(r),o}getAttributeTypedArray(t,e,r,o){if(0===r.ptr){throw new Error(`DRACO decode bad attribute ${o}`)}const n=y[r.data_type()],i=r.num_components(),a=e.num_points()*i;let s,c;switch(n){case Float32Array:s=new this.draco.DracoFloat32Array,t.GetAttributeFloatForAllPoints(e,r,s),c=new Float32Array(a);break;case Int8Array:s=new this.draco.DracoInt8Array,t.GetAttributeInt8ForAllPoints(e,r,s),c=new Int8Array(a);break;case Int16Array:s=new this.draco.DracoInt16Array,t.GetAttributeInt16ForAllPoints(e,r,s),c=new Int16Array(a);break;case Int32Array:s=new this.draco.DracoInt32Array,t.GetAttributeInt32ForAllPoints(e,r,s),c=new Int32Array(a);break;case Uint8Array:s=new this.draco.DracoUInt8Array,t.GetAttributeUInt8ForAllPoints(e,r,s),c=new Uint8Array(a);break;case Uint16Array:s=new this.draco.DracoUInt16Array,t.GetAttributeUInt16ForAllPoints(e,r,s),c=new Uint16Array(a);break;case Uint32Array:s=new this.draco.DracoUInt32Array,t.GetAttributeUInt32ForAllPoints(e,r,s),c=new Uint32Array(a);break;default:throw new Error("DRACO decoder: unexpected attribute type.")}for(let t=0;t<a;t++)c[t]=s.GetValue(t);return this.draco.destroy(s),{typedArray:c,components:i}}decode(t,e){return this.parseSync(t,e)}}const A={id:"draco",name:"Draco",version:"2.0.0",extensions:["drc"],mimeType:"application/octet-stream",binary:!0,test:"DRACO",options:{draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",workerUrl:"https://unpkg.com/@loaders.gl/draco@2.0.0/dist/draco-loader.worker.js",localWorkerUrl:"modules/draco/dist/draco-loader.worker.dev.js"}}},w={...A,parse:async function(t,e,r,o){const{draco:n}=await u(e),i=new b(n);try{return i.parseSync(t,e)}finally{i.destroy()}}};const p={POSITION:"POSITION",NORMAL:"NORMAL",COLOR_0:"COLOR",TEXCOORD_0:"TEX_COORD"};function m(){}function O(t){const e=t.size(),r=new ArrayBuffer(e),o=new Int8Array(r);for(let r=0;r<e;++r)o[r]=t.GetValue(r);return r}class I{constructor(t,e={}){this.draco=t,this.dracoEncoder=new this.draco.Encoder,this.dracoMeshBuilder=new this.draco.MeshBuilder,this.log=e.log||m}destroy(){this.destroyEncodedObject(this.dracoMeshBuilder),this.destroyEncodedObject(this.dracoEncoder),this.dracoMeshBuilder=null,this.dracoEncoder=null,this.draco=null}destroyEncodedObject(t){t&&this.draco.destroy(t)}encodeSync(t,e){return this._setOptions(e),e.pointcloud?this._encodePointCloud(t):this._encodeMesh(t)}_getAttributesFromMesh(t){const e={...t,...t.attributes};return t.indices&&(e.indices=t.indices),e}_encodePointCloud(t){const e=this._getAttributesFromMesh(t),r=this._createDracoPointCloud(e),o=new this.draco.DracoInt8Array;try{const t=this.dracoEncoder.EncodePointCloudToDracoBuffer(r,!1,o);if(!(t>0))throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${r.num_points()} points\n with ${r.num_attributes()} attributes into ${t} bytes`),O(o)}finally{this.destroyEncodedObject(o),this.destroyEncodedObject(r)}}_encodeMesh(t){const e=this._getAttributesFromMesh(t),r=this._createDracoMesh(e),o=new this.draco.DracoInt8Array;try{const t=this.dracoEncoder.EncodeMeshToDracoBuffer(r,o);if(t<=0)throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${r.num_points()} points\n with ${r.num_attributes()} attributes into ${t} bytes`),O(o)}finally{this.destroyEncodedObject(o),this.destroyEncodedObject(r)}}_setOptions(t={}){if("speed"in t&&this.dracoEncoder.SetSpeedOptions(...t.speed),"method"in t){const e=this.draco[t.method];this.dracoEncoder.SetEncodingMethod(e)}if("quantization"in t)for(const e in t.quantization){const r=t.quantization[e],o=this.draco[e];this.dracoEncoder.SetAttributeQuantization(o,r)}}_createDracoMesh(t){const e=new this.draco.Mesh;try{const r=this._getPositionAttribute(t);if(!r)throw new Error("positions");const o=r.length/3;for(let r in t){const n=t[r];r=p[r]||r,this._addAttributeToMesh(e,r,n,o)}}catch(t){throw this.destroyEncodedObject(e),t}return e}_createDracoPointCloud(t){const e=new this.draco.PointCloud;try{const r=this._getPositionAttribute(t);if(!r)throw new Error("positions");const o=r.length/3;for(let r in t){const n=t[r];r=p[r]||r,this._addAttributeToMesh(e,r,n,o)}}catch(t){throw this.destroyEncodedObject(e),t}return e}_addAttributeToMesh(t,e,r,o){if(!ArrayBuffer.isView(r))return;const n=this._getDracoAttributeType(e,r),i=r.length/o;if("indices"===n){const o=r.length/3;return this.log(`Adding attribute ${e}, size ${o}`),void this.dracoMeshBuilder.AddFacesToMesh(t,o,r)}switch(this.log(`Adding attribute ${e}, size ${i}`),r.constructor.name){case"Int8Array":this.dracoMeshBuilder.AddInt8Attribute(t,n,o,i,r);break;case"Int16Array":this.dracoMeshBuilder.AddInt16Attribute(t,n,o,i,r);break;case"Int32Array":this.dracoMeshBuilder.AddInt32Attribute(t,n,o,i,r);break;case"Uint8Array":case"Uint8ClampedArray":this.dracoMeshBuilder.AddUInt8Attribute(t,n,o,i,r);break;case"Uint16Array":this.dracoMeshBuilder.AddUInt16Attribute(t,n,o,i,r);break;case"Uint32Array":this.dracoMeshBuilder.AddUInt32Attribute(t,n,o,i,r);break;case"Float32Array":default:this.dracoMeshBuilder.AddFloatAttribute(t,n,o,i,r)}}_getDracoAttributeType(t,e){switch(t.toLowerCase()){case"indices":return"indices";case"position":case"positions":case"vertices":return this.draco.POSITION;case"normal":case"normals":return this.draco.NORMAL;case"color":case"colors":return this.draco.COLOR;case"texCoord":case"texCoords":return this.draco.TEX_COORD;default:return this.draco.GENERIC}}_getPositionAttribute(t){for(const e in t){const r=t[e];if(this._getDracoAttributeType(e,r)===this.draco.POSITION)return r}return null}}var _={name:"DRACO",extensions:["drc"],encode:async function(t,e){const r=e&&e.draco||e||{},{draco:o}=await l(e||{}),n=new I(o);try{return n.encodeSync(t,r)}finally{n.destroy()}},options:{draco:{pointcloud:!1}}};r.d(e,"DracoLoader",(function(){return w})),r.d(e,"DracoWorkerLoader",(function(){return A})),r.d(e,"DracoWriter",(function(){return _}))}])}));

@@ -12,2 +12,4 @@ "use strict";

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

@@ -51,31 +53,38 @@

function parse(arrayBuffer, options, context, loader) {
var _ref, draco, dracoParser;
function parse(_x, _x2, _x3, _x4) {
return _parse.apply(this, arguments);
}
return _regenerator["default"].async(function parse$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return _regenerator["default"].awrap((0, _dracoModuleLoader.loadDracoDecoderModule)(options));
function _parse() {
_parse = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(arrayBuffer, options, context, loader) {
var _ref, draco, dracoParser;
case 2:
_ref = _context.sent;
draco = _ref.draco;
dracoParser = new _dracoParser["default"](draco);
_context.prev = 5;
return _context.abrupt("return", dracoParser.parseSync(arrayBuffer, options));
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return (0, _dracoModuleLoader.loadDracoDecoderModule)(options);
case 7:
_context.prev = 7;
dracoParser.destroy();
return _context.finish(7);
case 2:
_ref = _context.sent;
draco = _ref.draco;
dracoParser = new _dracoParser["default"](draco);
_context.prev = 5;
return _context.abrupt("return", dracoParser.parseSync(arrayBuffer, options));
case 10:
case "end":
return _context.stop();
case 7:
_context.prev = 7;
dracoParser.destroy();
return _context.finish(7);
case 10:
case "end":
return _context.stop();
}
}
}
}, null, null, [[5,, 7, 10]]);
}, _callee, null, [[5,, 7, 10]]);
}));
return _parse.apply(this, arguments);
}
//# sourceMappingURL=draco-loader.js.map

@@ -12,2 +12,4 @@ "use strict";

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _dracoModuleLoader = require("./lib/draco-module-loader");

@@ -22,3 +24,5 @@

options: {
pointcloud: false
draco: {
pointcloud: false
}
}

@@ -28,31 +32,39 @@ };

function encode(data, options) {
var _ref, draco, dracoBuilder;
function encode(_x, _x2) {
return _encode.apply(this, arguments);
}
return _regenerator["default"].async(function encode$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return _regenerator["default"].awrap((0, _dracoModuleLoader.loadDracoEncoderModule)(options));
function _encode() {
_encode = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(data, options) {
var dracoOptions, _ref, draco, dracoBuilder;
case 2:
_ref = _context.sent;
draco = _ref.draco;
dracoBuilder = new _dracoBuilder["default"](draco);
_context.prev = 5;
return _context.abrupt("return", dracoBuilder.encodeSync(data, options));
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
dracoOptions = options && options.draco || options || {};
_context.next = 3;
return (0, _dracoModuleLoader.loadDracoEncoderModule)(options || {});
case 7:
_context.prev = 7;
dracoBuilder.destroy();
return _context.finish(7);
case 3:
_ref = _context.sent;
draco = _ref.draco;
dracoBuilder = new _dracoBuilder["default"](draco);
_context.prev = 6;
return _context.abrupt("return", dracoBuilder.encodeSync(data, dracoOptions));
case 10:
case "end":
return _context.stop();
case 8:
_context.prev = 8;
dracoBuilder.destroy();
return _context.finish(8);
case 11:
case "end":
return _context.stop();
}
}
}
}, null, null, [[5,, 7, 10]]);
}, _callee, null, [[6,, 8, 11]]);
}));
return _encode.apply(this, arguments);
}
//# sourceMappingURL=draco-writer.js.map

@@ -11,4 +11,2 @@ "use strict";

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

@@ -18,2 +16,6 @@

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _loaderUtils = require("@loaders.gl/loader-utils");

@@ -28,125 +30,144 @@

function loadDracoDecoderModule(options) {
var modules;
return _regenerator["default"].async(function loadDracoDecoderModule$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
modules = options.modules || {};
function loadDracoDecoderModule(_x) {
return _loadDracoDecoderModule.apply(this, arguments);
}
if (!modules.draco3d) {
_context.next = 3;
break;
}
function _loadDracoDecoderModule() {
_loadDracoDecoderModule = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(options) {
var modules;
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
modules = options.modules || {};
return _context.abrupt("return", {
draco: modules.draco3d.createDecoderModule()
});
if (!modules.draco3d) {
_context.next = 3;
break;
}
case 3:
loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);
_context.next = 6;
return _regenerator["default"].awrap(loadDecoderPromise);
return _context.abrupt("return", {
draco: modules.draco3d.createDecoderModule()
});
case 6:
return _context.abrupt("return", _context.sent);
case 3:
loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);
_context.next = 6;
return loadDecoderPromise;
case 7:
case "end":
return _context.stop();
case 6:
return _context.abrupt("return", _context.sent);
case 7:
case "end":
return _context.stop();
}
}
}
});
}, _callee);
}));
return _loadDracoDecoderModule.apply(this, arguments);
}
function loadDracoEncoderModule(options) {
var modules;
return _regenerator["default"].async(function loadDracoEncoderModule$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
modules = options.modules || {};
function loadDracoEncoderModule(_x2) {
return _loadDracoEncoderModule.apply(this, arguments);
}
if (!modules.draco3d) {
_context2.next = 3;
break;
}
function _loadDracoEncoderModule() {
_loadDracoEncoderModule = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(options) {
var modules;
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
modules = options.modules || {};
return _context2.abrupt("return", {
draco: modules.draco3d.createEncoderModule()
});
if (!modules.draco3d) {
_context2.next = 3;
break;
}
case 3:
loadEncoderPromise = loadEncoderPromise || loadDracoEncoder(options);
_context2.next = 6;
return _regenerator["default"].awrap(loadEncoderPromise);
return _context2.abrupt("return", {
draco: modules.draco3d.createEncoderModule()
});
case 6:
return _context2.abrupt("return", _context2.sent);
case 3:
loadEncoderPromise = loadEncoderPromise || loadDracoEncoder(options);
_context2.next = 6;
return loadEncoderPromise;
case 7:
case "end":
return _context2.stop();
case 6:
return _context2.abrupt("return", _context2.sent);
case 7:
case "end":
return _context2.stop();
}
}
}
});
}, _callee2);
}));
return _loadDracoEncoderModule.apply(this, arguments);
}
function loadDracoDecoder(options) {
var DracoDecoderModule, wasmBinary, _ref, _ref2;
function loadDracoDecoder(_x3) {
return _loadDracoDecoder.apply(this, arguments);
}
return _regenerator["default"].async(function loadDracoDecoder$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = options.draco && options.draco.decoderType;
_context3.next = _context3.t0 === 'js' ? 3 : _context3.t0 === 'wasm' ? 7 : 7;
break;
function _loadDracoDecoder() {
_loadDracoDecoder = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(options) {
var DracoDecoderModule, wasmBinary, _ref, _ref2;
case 3:
_context3.next = 5;
return _regenerator["default"].awrap((0, _loaderUtils.loadLibrary)('draco_decoder.js', 'draco', options));
return _regenerator["default"].wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = options.draco && options.draco.decoderType;
_context3.next = _context3.t0 === 'js' ? 3 : _context3.t0 === 'wasm' ? 7 : 7;
break;
case 5:
DracoDecoderModule = _context3.sent;
return _context3.abrupt("break", 23);
case 3:
_context3.next = 5;
return (0, _loaderUtils.loadLibrary)('draco_decoder.js', 'draco', options);
case 7:
_context3.t1 = _regenerator["default"];
_context3.t2 = Promise;
_context3.next = 11;
return _regenerator["default"].awrap((0, _loaderUtils.loadLibrary)('draco_wasm_wrapper.js', 'draco', options));
case 5:
DracoDecoderModule = _context3.sent;
return _context3.abrupt("break", 21);
case 11:
_context3.t3 = _context3.sent;
_context3.next = 14;
return _regenerator["default"].awrap((0, _loaderUtils.loadLibrary)('draco_decoder.wasm', 'draco', options));
case 7:
_context3.t1 = Promise;
_context3.next = 10;
return (0, _loaderUtils.loadLibrary)('draco_wasm_wrapper.js', 'draco', options);
case 14:
_context3.t4 = _context3.sent;
_context3.t5 = [_context3.t3, _context3.t4];
_context3.t6 = _context3.t2.all.call(_context3.t2, _context3.t5);
_context3.next = 19;
return _context3.t1.awrap.call(_context3.t1, _context3.t6);
case 10:
_context3.t2 = _context3.sent;
_context3.next = 13;
return (0, _loaderUtils.loadLibrary)('draco_decoder.wasm', 'draco', options);
case 19:
_ref = _context3.sent;
_ref2 = (0, _slicedToArray2["default"])(_ref, 2);
DracoDecoderModule = _ref2[0];
wasmBinary = _ref2[1];
case 13:
_context3.t3 = _context3.sent;
_context3.t4 = [_context3.t2, _context3.t3];
_context3.next = 17;
return _context3.t1.all.call(_context3.t1, _context3.t4);
case 23:
DracoDecoderModule = DracoDecoderModule || _loaderUtils.global.DracoDecoderModule;
_context3.next = 26;
return _regenerator["default"].awrap(initializeDracoDecoder(DracoDecoderModule, wasmBinary));
case 17:
_ref = _context3.sent;
_ref2 = (0, _slicedToArray2["default"])(_ref, 2);
DracoDecoderModule = _ref2[0];
wasmBinary = _ref2[1];
case 26:
return _context3.abrupt("return", _context3.sent);
case 21:
DracoDecoderModule = DracoDecoderModule || _loaderUtils.global.DracoDecoderModule;
_context3.next = 24;
return initializeDracoDecoder(DracoDecoderModule, wasmBinary);
case 27:
case "end":
return _context3.stop();
case 24:
return _context3.abrupt("return", _context3.sent);
case 25:
case "end":
return _context3.stop();
}
}
}
});
}, _callee3);
}));
return _loadDracoDecoder.apply(this, arguments);
}

@@ -172,31 +193,38 @@

function loadDracoEncoder(options) {
var DracoEncoderModule;
return _regenerator["default"].async(function loadDracoEncoder$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return _regenerator["default"].awrap((0, _loaderUtils.loadLibrary)('draco_encoder.js', 'draco', options));
function loadDracoEncoder(_x4) {
return _loadDracoEncoder.apply(this, arguments);
}
case 2:
DracoEncoderModule = _context4.sent;
DracoEncoderModule = DracoEncoderModule || _loaderUtils.global.DracoEncoderModule;
return _context4.abrupt("return", new Promise(function (resolve) {
DracoEncoderModule({
onModuleLoaded: function onModuleLoaded(draco) {
return resolve({
draco: draco
});
}
});
}));
function _loadDracoEncoder() {
_loadDracoEncoder = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(options) {
var DracoEncoderModule;
return _regenerator["default"].wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return (0, _loaderUtils.loadLibrary)('draco_encoder.js', 'draco', options);
case 5:
case "end":
return _context4.stop();
case 2:
DracoEncoderModule = _context4.sent;
DracoEncoderModule = DracoEncoderModule || _loaderUtils.global.DracoEncoderModule;
return _context4.abrupt("return", new Promise(function (resolve) {
DracoEncoderModule({
onModuleLoaded: function onModuleLoaded(draco) {
return resolve({
draco: draco
});
}
});
}));
case 5:
case "end":
return _context4.stop();
}
}
}
});
}, _callee4);
}));
return _loadDracoEncoder.apply(this, arguments);
}
//# sourceMappingURL=draco-module-loader.js.map

@@ -8,3 +8,5 @@ import { loadDracoEncoderModule } from './lib/draco-module-loader';

options: {
pointcloud: false
draco: {
pointcloud: false
}
}

@@ -14,9 +16,10 @@ };

async function encode(data, options) {
const dracoOptions = options && options.draco || options || {};
const {
draco
} = await loadDracoEncoderModule(options);
} = await loadDracoEncoderModule(options || {});
const dracoBuilder = new DRACOBuilder(draco);
try {
return dracoBuilder.encodeSync(data, options);
return dracoBuilder.encodeSync(data, dracoOptions);
} finally {

@@ -23,0 +26,0 @@ dracoBuilder.destroy();

import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

@@ -33,31 +34,38 @@ import _typeof from "@babel/runtime/helpers/esm/typeof";

function parse(arrayBuffer, options, context, loader) {
var _ref, draco, dracoParser;
function parse(_x, _x2, _x3, _x4) {
return _parse.apply(this, arguments);
}
return _regeneratorRuntime.async(function parse$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return _regeneratorRuntime.awrap(loadDracoDecoderModule(options));
function _parse() {
_parse = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(arrayBuffer, options, context, loader) {
var _ref, draco, dracoParser;
case 2:
_ref = _context.sent;
draco = _ref.draco;
dracoParser = new DracoParser(draco);
_context.prev = 5;
return _context.abrupt("return", dracoParser.parseSync(arrayBuffer, options));
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return loadDracoDecoderModule(options);
case 7:
_context.prev = 7;
dracoParser.destroy();
return _context.finish(7);
case 2:
_ref = _context.sent;
draco = _ref.draco;
dracoParser = new DracoParser(draco);
_context.prev = 5;
return _context.abrupt("return", dracoParser.parseSync(arrayBuffer, options));
case 10:
case "end":
return _context.stop();
case 7:
_context.prev = 7;
dracoParser.destroy();
return _context.finish(7);
case 10:
case "end":
return _context.stop();
}
}
}
}, null, null, [[5,, 7, 10]]);
}, _callee, null, [[5,, 7, 10]]);
}));
return _parse.apply(this, arguments);
}
//# sourceMappingURL=draco-loader.js.map
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import { loadDracoEncoderModule } from './lib/draco-module-loader';

@@ -9,35 +10,45 @@ import DRACOBuilder from './lib/draco-builder';

options: {
pointcloud: false
draco: {
pointcloud: false
}
}
};
function encode(data, options) {
var _ref, draco, dracoBuilder;
function encode(_x, _x2) {
return _encode.apply(this, arguments);
}
return _regeneratorRuntime.async(function encode$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return _regeneratorRuntime.awrap(loadDracoEncoderModule(options));
function _encode() {
_encode = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(data, options) {
var dracoOptions, _ref, draco, dracoBuilder;
case 2:
_ref = _context.sent;
draco = _ref.draco;
dracoBuilder = new DRACOBuilder(draco);
_context.prev = 5;
return _context.abrupt("return", dracoBuilder.encodeSync(data, options));
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
dracoOptions = options && options.draco || options || {};
_context.next = 3;
return loadDracoEncoderModule(options || {});
case 7:
_context.prev = 7;
dracoBuilder.destroy();
return _context.finish(7);
case 3:
_ref = _context.sent;
draco = _ref.draco;
dracoBuilder = new DRACOBuilder(draco);
_context.prev = 6;
return _context.abrupt("return", dracoBuilder.encodeSync(data, dracoOptions));
case 10:
case "end":
return _context.stop();
case 8:
_context.prev = 8;
dracoBuilder.destroy();
return _context.finish(8);
case 11:
case "end":
return _context.stop();
}
}
}
}, null, null, [[5,, 7, 10]]);
}, _callee, null, [[6,, 8, 11]]);
}));
return _encode.apply(this, arguments);
}
//# sourceMappingURL=draco-writer.js.map

@@ -1,4 +0,5 @@

import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

@@ -12,124 +13,144 @@ 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; }

var loadEncoderPromise;
export function loadDracoDecoderModule(options) {
var modules;
return _regeneratorRuntime.async(function loadDracoDecoderModule$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
modules = options.modules || {};
export function loadDracoDecoderModule(_x) {
return _loadDracoDecoderModule.apply(this, arguments);
}
if (!modules.draco3d) {
_context.next = 3;
break;
}
function _loadDracoDecoderModule() {
_loadDracoDecoderModule = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(options) {
var modules;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
modules = options.modules || {};
return _context.abrupt("return", {
draco: modules.draco3d.createDecoderModule()
});
if (!modules.draco3d) {
_context.next = 3;
break;
}
case 3:
loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);
_context.next = 6;
return _regeneratorRuntime.awrap(loadDecoderPromise);
return _context.abrupt("return", {
draco: modules.draco3d.createDecoderModule()
});
case 6:
return _context.abrupt("return", _context.sent);
case 3:
loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);
_context.next = 6;
return loadDecoderPromise;
case 7:
case "end":
return _context.stop();
case 6:
return _context.abrupt("return", _context.sent);
case 7:
case "end":
return _context.stop();
}
}
}
});
}, _callee);
}));
return _loadDracoDecoderModule.apply(this, arguments);
}
export function loadDracoEncoderModule(options) {
var modules;
return _regeneratorRuntime.async(function loadDracoEncoderModule$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
modules = options.modules || {};
if (!modules.draco3d) {
_context2.next = 3;
break;
}
export function loadDracoEncoderModule(_x2) {
return _loadDracoEncoderModule.apply(this, arguments);
}
return _context2.abrupt("return", {
draco: modules.draco3d.createEncoderModule()
});
function _loadDracoEncoderModule() {
_loadDracoEncoderModule = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2(options) {
var modules;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
modules = options.modules || {};
case 3:
loadEncoderPromise = loadEncoderPromise || loadDracoEncoder(options);
_context2.next = 6;
return _regeneratorRuntime.awrap(loadEncoderPromise);
if (!modules.draco3d) {
_context2.next = 3;
break;
}
case 6:
return _context2.abrupt("return", _context2.sent);
return _context2.abrupt("return", {
draco: modules.draco3d.createEncoderModule()
});
case 7:
case "end":
return _context2.stop();
case 3:
loadEncoderPromise = loadEncoderPromise || loadDracoEncoder(options);
_context2.next = 6;
return loadEncoderPromise;
case 6:
return _context2.abrupt("return", _context2.sent);
case 7:
case "end":
return _context2.stop();
}
}
}
});
}, _callee2);
}));
return _loadDracoEncoderModule.apply(this, arguments);
}
function loadDracoDecoder(options) {
var DracoDecoderModule, wasmBinary, _ref, _ref2;
function loadDracoDecoder(_x3) {
return _loadDracoDecoder.apply(this, arguments);
}
return _regeneratorRuntime.async(function loadDracoDecoder$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = options.draco && options.draco.decoderType;
_context3.next = _context3.t0 === 'js' ? 3 : _context3.t0 === 'wasm' ? 7 : 7;
break;
function _loadDracoDecoder() {
_loadDracoDecoder = _asyncToGenerator(_regeneratorRuntime.mark(function _callee3(options) {
var DracoDecoderModule, wasmBinary, _ref, _ref2;
case 3:
_context3.next = 5;
return _regeneratorRuntime.awrap(loadLibrary('draco_decoder.js', 'draco', options));
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = options.draco && options.draco.decoderType;
_context3.next = _context3.t0 === 'js' ? 3 : _context3.t0 === 'wasm' ? 7 : 7;
break;
case 5:
DracoDecoderModule = _context3.sent;
return _context3.abrupt("break", 23);
case 3:
_context3.next = 5;
return loadLibrary('draco_decoder.js', 'draco', options);
case 7:
_context3.t1 = _regeneratorRuntime;
_context3.t2 = Promise;
_context3.next = 11;
return _regeneratorRuntime.awrap(loadLibrary('draco_wasm_wrapper.js', 'draco', options));
case 5:
DracoDecoderModule = _context3.sent;
return _context3.abrupt("break", 21);
case 11:
_context3.t3 = _context3.sent;
_context3.next = 14;
return _regeneratorRuntime.awrap(loadLibrary('draco_decoder.wasm', 'draco', options));
case 7:
_context3.t1 = Promise;
_context3.next = 10;
return loadLibrary('draco_wasm_wrapper.js', 'draco', options);
case 14:
_context3.t4 = _context3.sent;
_context3.t5 = [_context3.t3, _context3.t4];
_context3.t6 = _context3.t2.all.call(_context3.t2, _context3.t5);
_context3.next = 19;
return _context3.t1.awrap.call(_context3.t1, _context3.t6);
case 10:
_context3.t2 = _context3.sent;
_context3.next = 13;
return loadLibrary('draco_decoder.wasm', 'draco', options);
case 19:
_ref = _context3.sent;
_ref2 = _slicedToArray(_ref, 2);
DracoDecoderModule = _ref2[0];
wasmBinary = _ref2[1];
case 13:
_context3.t3 = _context3.sent;
_context3.t4 = [_context3.t2, _context3.t3];
_context3.next = 17;
return _context3.t1.all.call(_context3.t1, _context3.t4);
case 23:
DracoDecoderModule = DracoDecoderModule || global.DracoDecoderModule;
_context3.next = 26;
return _regeneratorRuntime.awrap(initializeDracoDecoder(DracoDecoderModule, wasmBinary));
case 17:
_ref = _context3.sent;
_ref2 = _slicedToArray(_ref, 2);
DracoDecoderModule = _ref2[0];
wasmBinary = _ref2[1];
case 26:
return _context3.abrupt("return", _context3.sent);
case 21:
DracoDecoderModule = DracoDecoderModule || global.DracoDecoderModule;
_context3.next = 24;
return initializeDracoDecoder(DracoDecoderModule, wasmBinary);
case 27:
case "end":
return _context3.stop();
case 24:
return _context3.abrupt("return", _context3.sent);
case 25:
case "end":
return _context3.stop();
}
}
}
});
}, _callee3);
}));
return _loadDracoDecoder.apply(this, arguments);
}

@@ -155,31 +176,38 @@

function loadDracoEncoder(options) {
var DracoEncoderModule;
return _regeneratorRuntime.async(function loadDracoEncoder$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return _regeneratorRuntime.awrap(loadLibrary('draco_encoder.js', 'draco', options));
function loadDracoEncoder(_x4) {
return _loadDracoEncoder.apply(this, arguments);
}
case 2:
DracoEncoderModule = _context4.sent;
DracoEncoderModule = DracoEncoderModule || global.DracoEncoderModule;
return _context4.abrupt("return", new Promise(function (resolve) {
DracoEncoderModule({
onModuleLoaded: function onModuleLoaded(draco) {
return resolve({
draco: draco
});
}
});
}));
function _loadDracoEncoder() {
_loadDracoEncoder = _asyncToGenerator(_regeneratorRuntime.mark(function _callee4(options) {
var DracoEncoderModule;
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return loadLibrary('draco_encoder.js', 'draco', options);
case 5:
case "end":
return _context4.stop();
case 2:
DracoEncoderModule = _context4.sent;
DracoEncoderModule = DracoEncoderModule || global.DracoEncoderModule;
return _context4.abrupt("return", new Promise(function (resolve) {
DracoEncoderModule({
onModuleLoaded: function onModuleLoaded(draco) {
return resolve({
draco: draco
});
}
});
}));
case 5:
case "end":
return _context4.stop();
}
}
}
});
}, _callee4);
}));
return _loadDracoEncoder.apply(this, arguments);
}
//# sourceMappingURL=draco-module-loader.js.map
{
"name": "@loaders.gl/draco",
"version": "2.0.0",
"version": "2.0.1",
"description": "Framework-independent loader and writer for Draco compressed meshes and point clouds",

@@ -42,6 +42,6 @@ "license": "MIT",

"@babel/runtime": "^7.3.1",
"@loaders.gl/loader-utils": "2.0.0",
"@loaders.gl/loader-utils": "2.0.1",
"draco3d": "^1.3.4"
},
"gitHead": "addaa8e2e634bd0c9e96da200d0388f62a669666"
"gitHead": "ae0763bd05bbe9b14aedf2a99e5873db16739bb7"
}

@@ -9,9 +9,11 @@ import {loadDracoEncoderModule} from './lib/draco-module-loader';

options: {
pointcloud: false // Set to true if pointcloud (mode: 0, no indices)
// Draco Compression Parameters
// method: 'MESH_EDGEBREAKER_ENCODING',
// speed: [5, 5],
// quantization: {
// POSITION: 10
// }
draco: {
pointcloud: false // Set to true if pointcloud (mode: 0, no indices)
// Draco Compression Parameters
// method: 'MESH_EDGEBREAKER_ENCODING',
// speed: [5, 5],
// quantization: {
// POSITION: 10
// }
}
}

@@ -21,7 +23,11 @@ };

async function encode(data, options) {
// DEPRECATED - remove support for options
const dracoOptions = (options && options.draco) || options || {};
// Dynamically load draco
const {draco} = await loadDracoEncoderModule(options);
const {draco} = await loadDracoEncoderModule(options || {});
const dracoBuilder = new DRACOBuilder(draco);
try {
return dracoBuilder.encodeSync(data, options);
return dracoBuilder.encodeSync(data, dracoOptions);
} finally {

@@ -28,0 +34,0 @@ dracoBuilder.destroy();

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc