@loaders.gl/draco 4.0.0-alpha.9 → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/dist.min.js +3 -3
  2. package/dist/dist.min.js.map +2 -2
  3. package/dist/draco-loader.d.ts +0 -1
  4. package/dist/draco-loader.d.ts.map +1 -1
  5. package/dist/draco-worker-node.js +51 -51
  6. package/dist/draco-worker-node.js.map +3 -3
  7. package/dist/draco-worker.js +1 -1
  8. package/dist/draco-worker.js.map +2 -2
  9. package/dist/draco-writer-worker-node.js +46 -46
  10. package/dist/draco-writer-worker-node.js.map +3 -3
  11. package/dist/draco-writer-worker.js +3 -3
  12. package/dist/draco-writer-worker.js.map +2 -2
  13. package/dist/es5/draco-loader.js +1 -3
  14. package/dist/es5/draco-loader.js.map +1 -1
  15. package/dist/es5/index.js +13 -3
  16. package/dist/es5/index.js.map +1 -1
  17. package/dist/es5/lib/draco-module-loader.js +17 -10
  18. package/dist/es5/lib/draco-module-loader.js.map +1 -1
  19. package/dist/es5/lib/utils/version.js +1 -1
  20. package/dist/es5/lib/utils/version.js.map +1 -1
  21. package/dist/es5/libs/draco_decoder.wasm +0 -0
  22. package/dist/es5/libs/draco_encoder.js +52 -0
  23. package/dist/es5/libs/draco_wasm_wrapper.js +117 -0
  24. package/dist/esm/draco-loader.js +0 -1
  25. package/dist/esm/draco-loader.js.map +1 -1
  26. package/dist/esm/index.js +1 -1
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/lib/draco-module-loader.js +16 -8
  29. package/dist/esm/lib/draco-module-loader.js.map +1 -1
  30. package/dist/esm/lib/utils/version.js +1 -1
  31. package/dist/esm/lib/utils/version.js.map +1 -1
  32. package/dist/esm/libs/draco_decoder.wasm +0 -0
  33. package/dist/esm/libs/draco_encoder.js +52 -0
  34. package/dist/esm/libs/draco_wasm_wrapper.js +117 -0
  35. package/dist/index.d.ts +1 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/lib/draco-module-loader.d.ts +13 -0
  38. package/dist/lib/draco-module-loader.d.ts.map +1 -1
  39. package/dist/libs/draco_decoder.wasm +0 -0
  40. package/dist/libs/draco_encoder.js +52 -0
  41. package/dist/libs/draco_wasm_wrapper.js +117 -0
  42. package/package.json +8 -7
  43. package/src/draco-loader.ts +0 -2
  44. package/src/index.ts +3 -3
  45. package/src/lib/draco-module-loader.ts +42 -10
  46. package/src/libs/draco_decoder.wasm +0 -0
  47. package/src/libs/draco_encoder.js +52 -0
  48. package/src/libs/draco_wasm_wrapper.js +117 -0
  49. package/dist/bundle.js +0 -5
  50. package/dist/draco-loader.js +0 -29
  51. package/dist/draco-writer.js +0 -44
  52. package/dist/draco3d/draco3d-types.js +0 -51
  53. package/dist/index.js +0 -47
  54. package/dist/lib/draco-builder.js +0 -338
  55. package/dist/lib/draco-module-loader.js +0 -93
  56. package/dist/lib/draco-parser.js +0 -476
  57. package/dist/lib/draco-types.js +0 -3
  58. package/dist/lib/utils/get-draco-schema.js +0 -42
  59. package/dist/lib/utils/version.js +0 -7
  60. package/dist/workers/draco-worker-node.js +0 -7
  61. package/dist/workers/draco-worker.js +0 -5
  62. package/dist/workers/draco-writer-worker-node.js +0 -28
  63. package/dist/workers/draco-writer-worker.js +0 -26
@@ -1,4 +1,4 @@
1
- (()=>{var L=Object.create;var b=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var $=t=>b(t,"__esModule",{value:!0});var q=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var U=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of v(e))!V.call(t,o)&&o!=="default"&&b(t,o,{get:()=>e[o],enumerable:!(r=x(e,o))||r.enumerable});return t},j=t=>U($(b(t!=null?L(F(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var R=q(()=>{});var w="4.0.0-alpha.9";function O(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var c={self:typeof self!="undefined"&&self,window:typeof window!="undefined"&&window,global:typeof global!="undefined"&&global,document:typeof document!="undefined"&&document},ie=c.self||c.window||c.global||{},de=c.window||c.self||c.global||{},k=c.global||c.self||c.window||{},ce=c.document||{};var h=typeof process!="object"||String(process)!=="[object process]"||process.browser,g=typeof importScripts=="function",le=typeof window!="undefined"&&typeof window.orientation!="undefined",T=typeof process!="undefined"&&process.version&&/v([0-9]*)/.exec(process.version),ue=T&&parseFloat(T[1])||0;function M(t,e=!0,r){let o=r||new Set;if(t){if(P(t))o.add(t);else if(P(t.buffer))o.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let a in t)M(t[a],e,o)}}return r===void 0?Array.from(o):[]}function P(t){return t?t instanceof ArrayBuffer||typeof MessagePort!="undefined"&&t instanceof MessagePort||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap||typeof OffscreenCanvas!="undefined"&&t instanceof OffscreenCanvas:!1}function f(){let parentPort;try{eval("globalThis.parentPort = require('worker_threads').parentPort"),parentPort=globalThis.parentPort}catch{}return parentPort}var _=new Map,u=class{static inWorkerThread(){return typeof self!="undefined"||Boolean(f())}static set onmessage(e){function r(a){let s=f(),{type:i,payload:n}=s?a:a.data;e(i,n)}let o=f();o?(o.on("message",r),o.on("exit",()=>console.debug("Node worker closing"))):globalThis.onmessage=r}static addEventListener(e){let r=_.get(e);r||(r=a=>{if(!G(a))return;let s=f(),{type:i,payload:n}=s?a:a.data;e(i,n)}),f()?console.error("not implemented"):globalThis.addEventListener("message",r)}static removeEventListener(e){let r=_.get(e);_.delete(e),f()?console.error("not implemented"):globalThis.removeEventListener("message",r)}static postMessage(e,r){let o={source:"loaders.gl",type:e,payload:r},a=M(r),s=f();s?s.postMessage(o,a):globalThis.postMessage(o,a)}};function G(t){let{type:e,data:r}=t;return e==="message"&&r&&typeof r.source=="string"&&r.source.startsWith("loaders.gl")}var p=j(R());var z="beta",Q=typeof w!="undefined"?w:z,E={};async function A(t,e=null,r={}){return e&&(t=I(t,e,r)),E[t]=E[t]||H(t),await E[t]}function I(t,e,r){if(t.startsWith("http"))return t;let o=r.modules||{};return o[t]?o[t]:h?r.CDN?(O(r.CDN.startsWith("http")),`${r.CDN}/${e}@${Q}/dist/libs/${t}`):g?`../src/libs/${t}`:`modules/${e}/src/libs/${t}`:`modules/${e}/dist/libs/${t}`}async function H(t){if(t.endsWith("wasm"))return await(await fetch(t)).arrayBuffer();if(!h)try{return p&&p.requireFromFile&&await p.requireFromFile(t)}catch{return null}if(g)return importScripts(t);let r=await(await fetch(t)).text();return X(r,t)}function X(t,e){if(!h)return p.requireFromString&&p.requireFromString(t,e);if(g)return eval.call(k,t),null;let r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}var W={POSITION:"POSITION",NORMAL:"NORMAL",COLOR_0:"COLOR",TEXCOORD_0:"TEX_COORD"},J=()=>{},m=class{constructor(e){this.draco=e,this.dracoEncoder=new this.draco.Encoder,this.dracoMeshBuilder=new this.draco.MeshBuilder,this.dracoMetadataBuilder=new this.draco.MetadataBuilder}destroy(){this.destroyEncodedObject(this.dracoMeshBuilder),this.destroyEncodedObject(this.dracoEncoder),this.destroyEncodedObject(this.dracoMetadataBuilder),this.dracoMeshBuilder=null,this.dracoEncoder=null,this.draco=null}destroyEncodedObject(e){e&&this.draco.destroy(e)}encodeSync(e,r={}){return this.log=J,this._setOptions(r),r.pointcloud?this._encodePointCloud(e,r):this._encodeMesh(e,r)}_getAttributesFromMesh(e){let r={...e,...e.attributes};return e.indices&&(r.indices=e.indices),r}_encodePointCloud(e,r){let o=new this.draco.PointCloud;r.metadata&&this._addGeometryMetadata(o,r.metadata);let a=this._getAttributesFromMesh(e);this._createDracoPointCloud(o,a,r);let s=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodePointCloudToDracoBuffer(o,!1,s);if(!(i>0))throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${o.num_points()} points
2
- with ${o.num_attributes()} attributes into ${i} bytes`),B(s)}finally{this.destroyEncodedObject(s),this.destroyEncodedObject(o)}}_encodeMesh(e,r){let o=new this.draco.Mesh;r.metadata&&this._addGeometryMetadata(o,r.metadata);let a=this._getAttributesFromMesh(e);this._createDracoMesh(o,a,r);let s=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodeMeshToDracoBuffer(o,s);if(i<=0)throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${o.num_points()} points
3
- with ${o.num_attributes()} attributes into ${i} bytes`),B(s)}finally{this.destroyEncodedObject(s),this.destroyEncodedObject(o)}}_setOptions(e){if("speed"in e&&this.dracoEncoder.SetSpeedOptions(...e.speed),"method"in e){let r=this.draco[e.method||"MESH_SEQUENTIAL_ENCODING"];this.dracoEncoder.SetEncodingMethod(r)}if("quantization"in e)for(let r in e.quantization){let o=e.quantization[r],a=this.draco[r];this.dracoEncoder.SetAttributeQuantization(a,o)}}_createDracoMesh(e,r,o){let a=o.attributesMetadata||{};try{let s=this._getPositionAttribute(r);if(!s)throw new Error("positions");let i=s.length/3;for(let n in r){let d=r[n];n=W[n]||n;let l=this._addAttributeToMesh(e,n,d,i);l!==-1&&this._addAttributeMetadata(e,l,{name:n,...a[n]||{}})}}catch(s){throw this.destroyEncodedObject(e),s}return e}_createDracoPointCloud(e,r,o){let a=o.attributesMetadata||{};try{let s=this._getPositionAttribute(r);if(!s)throw new Error("positions");let i=s.length/3;for(let n in r){let d=r[n];n=W[n]||n;let l=this._addAttributeToMesh(e,n,d,i);l!==-1&&this._addAttributeMetadata(e,l,{name:n,...a[n]||{}})}}catch(s){throw this.destroyEncodedObject(e),s}return e}_addAttributeToMesh(e,r,o,a){if(!ArrayBuffer.isView(o))return-1;let s=this._getDracoAttributeType(r),i=o.length/a;if(s==="indices"){let l=o.length/3;return this.log(`Adding attribute ${r}, size ${l}`),this.dracoMeshBuilder.AddFacesToMesh(e,l,o),-1}this.log(`Adding attribute ${r}, size ${i}`);let n=this.dracoMeshBuilder,{buffer:d}=o;switch(o.constructor){case Int8Array:return n.AddInt8Attribute(e,s,a,i,new Int8Array(d));case Int16Array:return n.AddInt16Attribute(e,s,a,i,new Int16Array(d));case Int32Array:return n.AddInt32Attribute(e,s,a,i,new Int32Array(d));case Uint8Array:case Uint8ClampedArray:return n.AddUInt8Attribute(e,s,a,i,new Uint8Array(d));case Uint16Array:return n.AddUInt16Attribute(e,s,a,i,new Uint16Array(d));case Uint32Array:return n.AddUInt32Attribute(e,s,a,i,new Uint32Array(d));case Float32Array:default:return n.AddFloatAttribute(e,s,a,i,new Float32Array(d))}}_getDracoAttributeType(e){switch(e.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(e){for(let r in e){let o=e[r];if(this._getDracoAttributeType(r)===this.draco.POSITION)return o}return null}_addGeometryMetadata(e,r){let o=new this.draco.Metadata;this._populateDracoMetadata(o,r),this.dracoMeshBuilder.AddMetadata(e,o)}_addAttributeMetadata(e,r,o){let a=new this.draco.Metadata;this._populateDracoMetadata(a,o),this.dracoMeshBuilder.SetMetadataForAttribute(e,r,a)}_populateDracoMetadata(e,r){for(let[o,a]of K(r))switch(typeof a){case"number":Math.trunc(a)===a?this.dracoMetadataBuilder.AddIntEntry(e,o,a):this.dracoMetadataBuilder.AddDoubleEntry(e,o,a);break;case"object":a instanceof Int32Array&&this.dracoMetadataBuilder.AddIntEntryArray(e,o,a,a.length);break;case"string":default:this.dracoMetadataBuilder.AddStringEntry(e,o,a)}}};function B(t){let e=t.size(),r=new ArrayBuffer(e),o=new Int8Array(r);for(let a=0;a<e;++a)o[a]=t.GetValue(a);return r}function K(t){return t.entries&&!t.hasOwnProperty("entries")?t.entries():Object.entries(t)}var Y="1.5.5",Z="1.4.1",D=`https://www.gstatic.com/draco/versioned/decoders/${Y}`,Te=`${D}/draco_decoder.js`,Pe=`${D}/draco_wasm_wrapper.js`,Re=`${D}/draco_decoder.wasm`,ee=`https://raw.githubusercontent.com/google/draco/${Z}/javascript/draco_encoder.js`;var y;async function S(t){let e=t.modules||{};return e.draco3d?y=y||e.draco3d.createEncoderModule({}).then(r=>({draco:r})):y=y||re(t),await y}async function re(t){let e=await A(ee,"draco",t);return e=e||globalThis.DracoEncoderModule,new Promise(r=>{e({onModuleLoaded:o=>r({draco:o})})})}var N="4.0.0-alpha.9";var te={pointcloud:!1,attributeNameEntry:"name"},C={name:"DRACO",id:"draco",module:"draco",version:N,extensions:["drc"],encode:oe,options:{draco:te}};async function oe(t,e={}){let{draco:r}=await S(e),o=new m(r);try{return o.encodeSync(t,e.draco)}finally{o.destroy()}}(()=>{!u.inWorkerThread()||(u.onmessage=async(t,e)=>{switch(t){case"process":try{let{input:r,options:o}=e,a=await C.encode(r,o);u.postMessage("done",{result:a})}catch(r){let o=r instanceof Error?r.message:"";u.postMessage("error",{error:o})}break;default:}})})();})();
1
+ (()=>{var N=Object.create;var b=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var q=t=>b(t,"__esModule",{value:!0});var G=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var j=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of F(e))!V.call(t,o)&&o!=="default"&&b(t,o,{get:()=>e[o],enumerable:!(r=v(e,o))||r.enumerable});return t},z=t=>j(q(b(t!=null?N($(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var C=G(()=>{});function U(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.0.0-beta.1"),globalThis._loadersgl_.version}var O=U();function T(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var c={self:typeof self!="undefined"&&self,window:typeof window!="undefined"&&window,global:typeof global!="undefined"&&global,document:typeof document!="undefined"&&document},ce=c.self||c.window||c.global||{},le=c.window||c.self||c.global||{},k=c.global||c.self||c.window||{},ue=c.document||{};var g=typeof process!="object"||String(process)!=="[object process]"||process.browser,m=typeof importScripts=="function",fe=typeof window!="undefined"&&typeof window.orientation!="undefined",R=typeof process!="undefined"&&process.version&&/v([0-9]*)/.exec(process.version),pe=R&&parseFloat(R[1])||0;function w(t,e=!0,r){let o=r||new Set;if(t){if(B(t))o.add(t);else if(B(t.buffer))o.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let a in t)w(t[a],e,o)}}return r===void 0?Array.from(o):[]}function B(t){return t?t instanceof ArrayBuffer||typeof MessagePort!="undefined"&&t instanceof MessagePort||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap||typeof OffscreenCanvas!="undefined"&&t instanceof OffscreenCanvas:!1}function y(){let parentPort;try{eval("globalThis.parentPort = require('worker_threads').parentPort"),parentPort=globalThis.parentPort}catch{}return parentPort}var A=new Map,p=class{static inWorkerThread(){return typeof self!="undefined"||Boolean(y())}static set onmessage(e){function r(a){let s=y(),{type:i,payload:n}=s?a:a.data;e(i,n)}let o=y();o?(o.on("message",r),o.on("exit",()=>console.debug("Node worker closing"))):globalThis.onmessage=r}static addEventListener(e){let r=A.get(e);r||(r=a=>{if(!K(a))return;let s=y(),{type:i,payload:n}=s?a:a.data;e(i,n)}),y()?console.error("not implemented"):globalThis.addEventListener("message",r)}static removeEventListener(e){let r=A.get(e);A.delete(e),y()?console.error("not implemented"):globalThis.removeEventListener("message",r)}static postMessage(e,r){let o={source:"loaders.gl",type:e,payload:r},a=w(r),s=y();s?s.postMessage(o,a):globalThis.postMessage(o,a)}};function K(t){let{type:e,data:r}=t;return e==="message"&&r&&typeof r.source=="string"&&r.source.startsWith("loaders.gl")}var u=z(C());var D={};async function M(t,e=null,r={},o=null){return e&&(t=P(t,e,r,o)),D[t]=D[t]||X(t),await D[t]}function P(t,e,r={},o=null){if(!r.useLocalLibraries&&t.startsWith("http"))return t;o=o||t;let a=r.modules||{};return a[o]?a[o]:g?r.CDN?(T(r.CDN.startsWith("http")),`${r.CDN}/${e}@${O}/dist/libs/${o}`):m?`../src/libs/${o}`:`modules/${e}/src/libs/${o}`:`modules/${e}/dist/libs/${o}`}async function X(t){if(t.endsWith("wasm"))return await H(t);if(!g)try{return u&&u.requireFromFile&&await u.requireFromFile(t)}catch{return null}if(m)return importScripts(t);let e=await J(t);return Q(e,t)}function Q(t,e){if(!g)return u.requireFromString&&u.requireFromString(t,e);if(m)return eval.call(k,t),null;let r=document.createElement("script");r.id=e;try{r.appendChild(document.createTextNode(t))}catch{r.text=t}return document.body.appendChild(r),null}async function H(t){return!u.readFileAsArrayBuffer||t.startsWith("http")?await(await fetch(t)).arrayBuffer():await u.readFileAsArrayBuffer(t)}async function J(t){return!u.readFileAsText||t.startsWith("http")?await(await fetch(t)).text():await u.readFileAsText(t)}var W={POSITION:"POSITION",NORMAL:"NORMAL",COLOR_0:"COLOR",TEXCOORD_0:"TEX_COORD"},Y=()=>{},E=class{constructor(e){this.draco=e,this.dracoEncoder=new this.draco.Encoder,this.dracoMeshBuilder=new this.draco.MeshBuilder,this.dracoMetadataBuilder=new this.draco.MetadataBuilder}destroy(){this.destroyEncodedObject(this.dracoMeshBuilder),this.destroyEncodedObject(this.dracoEncoder),this.destroyEncodedObject(this.dracoMetadataBuilder),this.dracoMeshBuilder=null,this.dracoEncoder=null,this.draco=null}destroyEncodedObject(e){e&&this.draco.destroy(e)}encodeSync(e,r={}){return this.log=Y,this._setOptions(r),r.pointcloud?this._encodePointCloud(e,r):this._encodeMesh(e,r)}_getAttributesFromMesh(e){let r={...e,...e.attributes};return e.indices&&(r.indices=e.indices),r}_encodePointCloud(e,r){let o=new this.draco.PointCloud;r.metadata&&this._addGeometryMetadata(o,r.metadata);let a=this._getAttributesFromMesh(e);this._createDracoPointCloud(o,a,r);let s=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodePointCloudToDracoBuffer(o,!1,s);if(!(i>0))throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${o.num_points()} points
2
+ with ${o.num_attributes()} attributes into ${i} bytes`),I(s)}finally{this.destroyEncodedObject(s),this.destroyEncodedObject(o)}}_encodeMesh(e,r){let o=new this.draco.Mesh;r.metadata&&this._addGeometryMetadata(o,r.metadata);let a=this._getAttributesFromMesh(e);this._createDracoMesh(o,a,r);let s=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodeMeshToDracoBuffer(o,s);if(i<=0)throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${o.num_points()} points
3
+ with ${o.num_attributes()} attributes into ${i} bytes`),I(s)}finally{this.destroyEncodedObject(s),this.destroyEncodedObject(o)}}_setOptions(e){if("speed"in e&&this.dracoEncoder.SetSpeedOptions(...e.speed),"method"in e){let r=this.draco[e.method||"MESH_SEQUENTIAL_ENCODING"];this.dracoEncoder.SetEncodingMethod(r)}if("quantization"in e)for(let r in e.quantization){let o=e.quantization[r],a=this.draco[r];this.dracoEncoder.SetAttributeQuantization(a,o)}}_createDracoMesh(e,r,o){let a=o.attributesMetadata||{};try{let s=this._getPositionAttribute(r);if(!s)throw new Error("positions");let i=s.length/3;for(let n in r){let d=r[n];n=W[n]||n;let f=this._addAttributeToMesh(e,n,d,i);f!==-1&&this._addAttributeMetadata(e,f,{name:n,...a[n]||{}})}}catch(s){throw this.destroyEncodedObject(e),s}return e}_createDracoPointCloud(e,r,o){let a=o.attributesMetadata||{};try{let s=this._getPositionAttribute(r);if(!s)throw new Error("positions");let i=s.length/3;for(let n in r){let d=r[n];n=W[n]||n;let f=this._addAttributeToMesh(e,n,d,i);f!==-1&&this._addAttributeMetadata(e,f,{name:n,...a[n]||{}})}}catch(s){throw this.destroyEncodedObject(e),s}return e}_addAttributeToMesh(e,r,o,a){if(!ArrayBuffer.isView(o))return-1;let s=this._getDracoAttributeType(r),i=o.length/a;if(s==="indices"){let f=o.length/3;return this.log(`Adding attribute ${r}, size ${f}`),this.dracoMeshBuilder.AddFacesToMesh(e,f,o),-1}this.log(`Adding attribute ${r}, size ${i}`);let n=this.dracoMeshBuilder,{buffer:d}=o;switch(o.constructor){case Int8Array:return n.AddInt8Attribute(e,s,a,i,new Int8Array(d));case Int16Array:return n.AddInt16Attribute(e,s,a,i,new Int16Array(d));case Int32Array:return n.AddInt32Attribute(e,s,a,i,new Int32Array(d));case Uint8Array:case Uint8ClampedArray:return n.AddUInt8Attribute(e,s,a,i,new Uint8Array(d));case Uint16Array:return n.AddUInt16Attribute(e,s,a,i,new Uint16Array(d));case Uint32Array:return n.AddUInt32Attribute(e,s,a,i,new Uint32Array(d));case Float32Array:default:return n.AddFloatAttribute(e,s,a,i,new Float32Array(d))}}_getDracoAttributeType(e){switch(e.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(e){for(let r in e){let o=e[r];if(this._getDracoAttributeType(r)===this.draco.POSITION)return o}return null}_addGeometryMetadata(e,r){let o=new this.draco.Metadata;this._populateDracoMetadata(o,r),this.dracoMeshBuilder.AddMetadata(e,o)}_addAttributeMetadata(e,r,o){let a=new this.draco.Metadata;this._populateDracoMetadata(a,o),this.dracoMeshBuilder.SetMetadataForAttribute(e,r,a)}_populateDracoMetadata(e,r){for(let[o,a]of Z(r))switch(typeof a){case"number":Math.trunc(a)===a?this.dracoMetadataBuilder.AddIntEntry(e,o,a):this.dracoMetadataBuilder.AddDoubleEntry(e,o,a);break;case"object":a instanceof Int32Array&&this.dracoMetadataBuilder.AddIntEntryArray(e,o,a,a.length);break;case"string":default:this.dracoMetadataBuilder.AddStringEntry(e,o,a)}}};function I(t){let e=t.size(),r=new ArrayBuffer(e),o=new Int8Array(r);for(let a=0;a<e;++a)o[a]=t.GetValue(a);return r}function Z(t){return t.entries&&!t.hasOwnProperty("entries")?t.entries():Object.entries(t)}var ee="1.5.6",re="1.4.1",_=`https://www.gstatic.com/draco/versioned/decoders/${ee}`,l={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},te={[l.DECODER]:`${_}/${l.DECODER}`,[l.DECODER_WASM]:`${_}/${l.DECODER_WASM}`,[l.FALLBACK_DECODER]:`${_}/${l.FALLBACK_DECODER}`,[l.ENCODER]:`https://raw.githubusercontent.com/google/draco/${re}/javascript/${l.ENCODER}`};var h;async function L(t){let e=t.modules||{};return e.draco3d?h=h||e.draco3d.createEncoderModule({}).then(r=>({draco:r})):h=h||oe(t),await h}async function oe(t){let e=await M(te[l.ENCODER],"draco",t,l.ENCODER);return e=e||globalThis.DracoEncoderModule,new Promise(r=>{e({onModuleLoaded:o=>r({draco:o})})})}var x="4.0.0-beta.1";var ae={pointcloud:!1,attributeNameEntry:"name"},S={name:"DRACO",id:"draco",module:"draco",version:x,extensions:["drc"],encode:se,options:{draco:ae}};async function se(t,e={}){let{draco:r}=await L(e),o=new E(r);try{return o.encodeSync(t,e.draco)}finally{o.destroy()}}(()=>{!p.inWorkerThread()||(p.onmessage=async(t,e)=>{switch(t){case"process":try{let{input:r,options:o}=e,a=await S.encode(r,o);p.postMessage("done",{result:a})}catch(r){let o=r instanceof Error?r.message:"";p.postMessage("error",{error:o})}break;default:}})})();})();
4
4
  //# sourceMappingURL=draco-writer-worker.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../worker-utils/src/lib/node/require-utils.node", "../../worker-utils/src/lib/env-utils/version.ts", "../../worker-utils/src/lib/env-utils/assert.ts", "../../worker-utils/src/lib/env-utils/globals.ts", "../../worker-utils/src/lib/worker-utils/get-transfer-list.ts", "../../worker-utils/src/lib/worker-farm/worker-body.ts", "../../worker-utils/src/lib/library-utils/library-utils.ts", "../src/lib/draco-builder.ts", "../src/lib/draco-module-loader.ts", "../src/lib/utils/version.ts", "../src/draco-writer.ts", "../src/workers/draco-writer-worker.ts"],
4
- "sourcesContent": ["", "// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n\n// Change to `latest` on production branches\nconst DEFAULT_VERSION = 'beta';\ndeclare let __VERSION__: string;\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : DEFAULT_VERSION;\nif (typeof __VERSION__ === 'undefined') {\n // eslint-disable-next-line\n console.error(\n 'loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.'\n );\n}\n", "// Replacement for the external assert method to reduce bundle size\n// Note: We don't use the second \"message\" argument in calling code,\n// so no need to support it here\n\n/** Throws an `Error` with the optional `message` if `condition` is falsy */\nexport function assert(condition: any, message?: string): void {\n if (!condition) {\n throw new Error(message || 'loaders.gl assertion failed.');\n }\n}\n", "// Purpose: include this in your module to avoids adding dependencies on\n// micro modules like 'global' and 'is-browser';\n\n/* eslint-disable no-restricted-globals */\nconst globals = {\n self: typeof self !== 'undefined' && self,\n window: typeof window !== 'undefined' && window,\n global: typeof global !== 'undefined' && global,\n document: typeof document !== 'undefined' && document\n};\n\nconst self_: {[key: string]: any} = globals.self || globals.window || globals.global || {};\nconst window_: {[key: string]: any} = globals.window || globals.self || globals.global || {};\nconst global_: {[key: string]: any} = globals.global || globals.self || globals.window || {};\nconst document_: {[key: string]: any} = globals.document || {};\n\nexport {self_ as self, window_ as window, global_ as global, document_ as document};\n\n/** true if running in the browser, false if running in Node.js */\nexport const isBrowser: boolean =\n // @ts-ignore process.browser\n typeof process !== 'object' || String(process) !== '[object process]' || process.browser;\n\n/** true if running on a worker thread */\nexport const isWorker: boolean = typeof importScripts === 'function';\n\n/** true if running on a mobile device */\nexport const isMobile: boolean =\n typeof window !== 'undefined' && typeof window.orientation !== 'undefined';\n\n// Extract node major version\nconst matches =\n typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version);\n\n/** Version of Node.js if running under Node, otherwise 0 */\nexport const nodeVersion: number = (matches && parseFloat(matches[1])) || 0;\n", "// NOTE - there is a copy of this function is both in core and loader-utils\n// core does not need all the utils in loader-utils, just this one.\n\n/**\n * Returns an array of Transferrable objects that can be used with postMessage\n * https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage\n * @param object data to be sent via postMessage\n * @param recursive - not for application use\n * @param transfers - not for application use\n * @returns a transfer list that can be passed to postMessage\n */\nexport function getTransferList(\n object: any,\n recursive: boolean = true,\n transfers?: Set<any>\n): Transferable[] {\n // Make sure that items in the transfer list is unique\n const transfersSet = transfers || new Set();\n\n if (!object) {\n // ignore\n } else if (isTransferable(object)) {\n transfersSet.add(object);\n } else if (isTransferable(object.buffer)) {\n // Typed array\n transfersSet.add(object.buffer);\n } else if (ArrayBuffer.isView(object)) {\n // object is a TypeArray viewing into a SharedArrayBuffer (not transferable)\n // Do not iterate through the content in this case\n } else if (recursive && typeof object === 'object') {\n for (const key in object) {\n // Avoid perf hit - only go one level deep\n getTransferList(object[key], recursive, transfersSet);\n }\n }\n\n // If transfers is defined, is internal recursive call\n // Otherwise it's called by the user\n return transfers === undefined ? Array.from(transfersSet) : [];\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Transferable\nfunction isTransferable(object: unknown) {\n if (!object) {\n return false;\n }\n if (object instanceof ArrayBuffer) {\n return true;\n }\n if (typeof MessagePort !== 'undefined' && object instanceof MessagePort) {\n return true;\n }\n if (typeof ImageBitmap !== 'undefined' && object instanceof ImageBitmap) {\n return true;\n }\n // @ts-ignore\n if (typeof OffscreenCanvas !== 'undefined' && object instanceof OffscreenCanvas) {\n return true;\n }\n return false;\n}\n\n/**\n * Recursively drop non serializable values like functions and regexps.\n * @param object\n */\nexport function getTransferListForWriter(object: object | null): object {\n if (object === null) {\n return {};\n }\n const clone = Object.assign({}, object);\n\n Object.keys(clone).forEach((key) => {\n // Typed Arrays and Arrays are passed with no change\n if (\n typeof object[key] === 'object' &&\n !ArrayBuffer.isView(object[key]) &&\n !(object[key] instanceof Array)\n ) {\n clone[key] = getTransferListForWriter(object[key]);\n } else if (typeof clone[key] === 'function' || clone[key] instanceof RegExp) {\n clone[key] = {};\n } else {\n clone[key] = object[key];\n }\n });\n\n return clone;\n}\n", "import type {WorkerMessageData, WorkerMessageType, WorkerMessagePayload} from '../../types';\nimport {getTransferList} from '../worker-utils/get-transfer-list';\n\n/** Vile hack to defeat over-zealous bundlers from stripping out the require */\nfunction getParentPort() {\n // const isNode = globalThis.process;\n let parentPort;\n try {\n // prettier-ignore\n eval('globalThis.parentPort = require(\\'worker_threads\\').parentPort'); // eslint-disable-line no-eval\n parentPort = globalThis.parentPort;\n // eslint-disable-next-line no-empty\n } catch {}\n return parentPort;\n}\n\nconst onMessageWrapperMap = new Map();\n\n/**\n * Type safe wrapper for worker code\n */\nexport default class WorkerBody {\n /** Check that we are actually in a worker thread */\n static inWorkerThread(): boolean {\n return typeof self !== 'undefined' || Boolean(getParentPort());\n }\n\n /*\n * (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n */\n static set onmessage(onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any) {\n function handleMessage(message) {\n // Confusingly the message itself also has a 'type' field which is always set to 'message'\n const parentPort = getParentPort();\n const {type, payload} = parentPort ? message : message.data;\n // if (!isKnownMessage(message)) {\n // return;\n // }\n onMessage(type, payload);\n }\n\n const parentPort = getParentPort();\n if (parentPort) {\n parentPort.on('message', handleMessage);\n // if (message == 'exit') { parentPort.unref(); }\n // eslint-disable-next-line\n parentPort.on('exit', () => console.debug('Node worker closing'));\n } else {\n // eslint-disable-next-line no-restricted-globals\n globalThis.onmessage = handleMessage;\n }\n }\n\n static addEventListener(\n onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n ) {\n let onMessageWrapper = onMessageWrapperMap.get(onMessage);\n\n if (!onMessageWrapper) {\n onMessageWrapper = (message: MessageEvent<any>) => {\n if (!isKnownMessage(message)) {\n return;\n }\n\n // Confusingly in the browser, the message itself also has a 'type' field which is always set to 'message'\n const parentPort = getParentPort();\n const {type, payload} = parentPort ? message : message.data;\n onMessage(type, payload);\n };\n }\n\n const parentPort = getParentPort();\n if (parentPort) {\n console.error('not implemented'); // eslint-disable-line\n } else {\n globalThis.addEventListener('message', onMessageWrapper);\n }\n }\n\n static removeEventListener(\n onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n ) {\n const onMessageWrapper = onMessageWrapperMap.get(onMessage);\n onMessageWrapperMap.delete(onMessage);\n const parentPort = getParentPort();\n if (parentPort) {\n console.error('not implemented'); // eslint-disable-line\n } else {\n globalThis.removeEventListener('message', onMessageWrapper);\n }\n }\n\n /**\n * Send a message from a worker to creating thread (main thread)\n * @param type\n * @param payload\n */\n static postMessage(type: WorkerMessageType, payload: WorkerMessagePayload): void {\n const data: WorkerMessageData = {source: 'loaders.gl', type, payload};\n // console.log('posting message', data);\n const transferList = getTransferList(payload);\n\n const parentPort = getParentPort();\n if (parentPort) {\n parentPort.postMessage(data, transferList);\n // console.log('posted message', data);\n } else {\n // @ts-ignore\n globalThis.postMessage(data, transferList);\n }\n }\n}\n\n// Filter out noise messages sent to workers\nfunction isKnownMessage(message: MessageEvent<any>) {\n const {type, data} = message;\n return (\n type === 'message' &&\n data &&\n typeof data.source === 'string' &&\n data.source.startsWith('loaders.gl')\n );\n}\n", "/* global importScripts */\nimport {global, isBrowser, isWorker} from '../env-utils/globals';\nimport * as node from '../node/require-utils.node';\nimport {assert} from '../env-utils/assert';\nimport {VERSION as __VERSION__} from '../env-utils/version';\n\n/**\n * TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...\n * 'beta' on beta branch, 'latest' on prod branch\n */\nconst LATEST = 'beta';\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : LATEST;\n\nconst loadLibraryPromises: Record<string, Promise<any>> = {}; // promises\n\n/**\n * Dynamically loads a library (\"module\")\n *\n * - wasm library: Array buffer is returned\n * - js library: Parse JS is returned\n *\n * Method depends on environment\n * - browser - script element is created and installed on document\n * - worker - eval is called on global context\n * - node - file is required\n *\n * @param libraryUrl\n * @param moduleName\n * @param options\n */\nexport async function loadLibrary(\n libraryUrl: string,\n moduleName: string | null = null,\n options: object = {}\n): Promise<any> {\n if (moduleName) {\n libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);\n }\n\n // Ensure libraries are only loaded once\n\n loadLibraryPromises[libraryUrl] =\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);\n return await loadLibraryPromises[libraryUrl];\n}\n\n// TODO - sort out how to resolve paths for main/worker and dev/prod\nexport function getLibraryUrl(library: string, moduleName?: string, options?: any): string {\n // Check if already a URL\n if (library.startsWith('http')) {\n return library;\n }\n\n // Allow application to import and supply libraries through `options.modules`\n const modules = options.modules || {};\n if (modules[library]) {\n return modules[library];\n }\n\n // Load from local files, not from CDN scripts in Node.js\n // TODO - needs to locate the modules directory when installed!\n if (!isBrowser) {\n return `modules/${moduleName}/dist/libs/${library}`;\n }\n\n // In browser, load from external scripts\n if (options.CDN) {\n assert(options.CDN.startsWith('http'));\n return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${library}`;\n }\n\n // TODO - loading inside workers requires paths relative to worker script location...\n if (isWorker) {\n return `../src/libs/${library}`;\n }\n\n return `modules/${moduleName}/src/libs/${library}`;\n}\n\nasync function loadLibraryFromFile(libraryUrl: string): Promise<any> {\n if (libraryUrl.endsWith('wasm')) {\n const response = await fetch(libraryUrl);\n return await response.arrayBuffer();\n }\n\n if (!isBrowser) {\n try {\n return node && node.requireFromFile && (await node.requireFromFile(libraryUrl));\n } catch {\n return null;\n }\n }\n if (isWorker) {\n return importScripts(libraryUrl);\n }\n // TODO - fix - should be more secure than string parsing since observes CORS\n // if (isBrowser) {\n // return await loadScriptFromFile(libraryUrl);\n // }\n\n const response = await fetch(libraryUrl);\n const scriptSource = await response.text();\n return loadLibraryFromString(scriptSource, libraryUrl);\n}\n\n/*\nasync function loadScriptFromFile(libraryUrl) {\n const script = document.createElement('script');\n script.src = libraryUrl;\n return await new Promise((resolve, reject) => {\n script.onload = data => {\n resolve(data);\n };\n script.onerror = reject;\n });\n}\n*/\n\n// TODO - Needs security audit...\n// - Raw eval call\n// - Potentially bypasses CORS\n// Upside is that this separates fetching and parsing\n// we could create a`LibraryLoader` or`ModuleLoader`\nfunction loadLibraryFromString(scriptSource: string, id: string): null | any {\n if (!isBrowser) {\n return node.requireFromString && node.requireFromString(scriptSource, id);\n }\n\n if (isWorker) {\n // Use lvalue trick to make eval run in global scope\n eval.call(global, scriptSource); // eslint-disable-line no-eval\n // https://stackoverflow.com/questions/9107240/1-evalthis-vs-evalthis-in-javascript\n // http://perfectionkills.com/global-eval-what-are-the-options/\n return null;\n }\n\n const script = document.createElement('script');\n script.id = id;\n // most browsers like a separate text node but some throw an error. The second method covers those.\n try {\n script.appendChild(document.createTextNode(scriptSource));\n } catch (e) {\n script.text = scriptSource;\n }\n document.body.appendChild(script);\n return null;\n}\n\n// TODO - technique for module injection into worker, from THREE.DracoLoader...\n/*\nfunction combineWorkerWithLibrary(worker, jsContent) {\n var fn = wWorker.toString();\n var body = [\n '// injected',\n jsContent,\n '',\n '// worker',\n fn.substring(fn.indexOf('{') + 1, fn.lastIndexOf('}'))\n ].join('\\n');\n this.workerSourceURL = URL.createObjectURL(new Blob([body]));\n}\n*/\n", "/* eslint-disable camelcase */\n// This code is inspired by example code in the DRACO repository\nimport type {\n Draco3D,\n DracoInt8Array,\n Encoder,\n Mesh,\n MeshBuilder,\n PointCloud,\n Metadata,\n MetadataBuilder,\n draco_GeometryAttribute_Type\n} from '../draco3d/draco3d-types';\n\nimport type {TypedArray} from '@loaders.gl/schema';\nimport type {DracoMesh} from './draco-types';\n\nexport type DracoBuildOptions = {\n pointcloud?: boolean;\n metadata?: {[key: string]: string};\n attributesMetadata?: {};\n log?: any;\n\n // draco encoding options\n speed?: [number, number];\n method?: string;\n quantization?: {[attributeName: string]: number};\n};\n\n// Native Draco attribute names to GLTF attribute names.\nconst GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP = {\n POSITION: 'POSITION',\n NORMAL: 'NORMAL',\n COLOR_0: 'COLOR',\n TEXCOORD_0: 'TEX_COORD'\n};\n\nconst noop = () => {};\n\nexport default class DracoBuilder {\n draco: Draco3D;\n dracoEncoder: Encoder;\n dracoMeshBuilder: MeshBuilder;\n dracoMetadataBuilder: MetadataBuilder;\n log: any;\n\n // draco - the draco decoder, either import `draco3d` or load dynamically\n constructor(draco: Draco3D) {\n this.draco = draco;\n this.dracoEncoder = new this.draco.Encoder();\n this.dracoMeshBuilder = new this.draco.MeshBuilder();\n this.dracoMetadataBuilder = new this.draco.MetadataBuilder();\n }\n\n destroy(): void {\n this.destroyEncodedObject(this.dracoMeshBuilder);\n this.destroyEncodedObject(this.dracoEncoder);\n this.destroyEncodedObject(this.dracoMetadataBuilder);\n // @ts-ignore\n this.dracoMeshBuilder = null;\n // @ts-ignore\n this.dracoEncoder = null;\n // @ts-ignore\n this.draco = null;\n }\n\n // TBD - when does this need to be called?\n destroyEncodedObject(object): void {\n if (object) {\n this.draco.destroy(object);\n }\n }\n\n /**\n * Encode mesh or point cloud\n * @param mesh =({})\n * @param options\n */\n encodeSync(mesh: DracoMesh, options: DracoBuildOptions = {}): ArrayBuffer {\n this.log = noop; // TODO\n this._setOptions(options);\n\n return options.pointcloud\n ? this._encodePointCloud(mesh, options)\n : this._encodeMesh(mesh, options);\n }\n\n // PRIVATE\n\n _getAttributesFromMesh(mesh: DracoMesh) {\n // TODO - Change the encodePointCloud interface instead?\n const attributes = {...mesh, ...mesh.attributes};\n // Fold indices into the attributes\n if (mesh.indices) {\n attributes.indices = mesh.indices;\n }\n return attributes;\n }\n\n _encodePointCloud(pointcloud: DracoMesh, options: DracoBuildOptions): ArrayBuffer {\n const dracoPointCloud = new this.draco.PointCloud();\n\n if (options.metadata) {\n this._addGeometryMetadata(dracoPointCloud, options.metadata);\n }\n\n const attributes = this._getAttributesFromMesh(pointcloud);\n\n // Build a `DracoPointCloud` from the input data\n this._createDracoPointCloud(dracoPointCloud, attributes, options);\n\n const dracoData = new this.draco.DracoInt8Array();\n\n try {\n const encodedLen = this.dracoEncoder.EncodePointCloudToDracoBuffer(\n dracoPointCloud,\n false,\n dracoData\n );\n\n if (!(encodedLen > 0)) {\n throw new Error('Draco encoding failed.');\n }\n\n this.log(`DRACO encoded ${dracoPointCloud.num_points()} points\n with ${dracoPointCloud.num_attributes()} attributes into ${encodedLen} bytes`);\n\n return dracoInt8ArrayToArrayBuffer(dracoData);\n } finally {\n this.destroyEncodedObject(dracoData);\n this.destroyEncodedObject(dracoPointCloud);\n }\n }\n\n _encodeMesh(mesh: DracoMesh, options: DracoBuildOptions): ArrayBuffer {\n const dracoMesh = new this.draco.Mesh();\n\n if (options.metadata) {\n this._addGeometryMetadata(dracoMesh, options.metadata);\n }\n\n const attributes = this._getAttributesFromMesh(mesh);\n\n // Build a `DracoMesh` from the input data\n this._createDracoMesh(dracoMesh, attributes, options);\n\n const dracoData = new this.draco.DracoInt8Array();\n\n try {\n const encodedLen = this.dracoEncoder.EncodeMeshToDracoBuffer(dracoMesh, dracoData);\n if (encodedLen <= 0) {\n throw new Error('Draco encoding failed.');\n }\n\n this.log(`DRACO encoded ${dracoMesh.num_points()} points\n with ${dracoMesh.num_attributes()} attributes into ${encodedLen} bytes`);\n\n return dracoInt8ArrayToArrayBuffer(dracoData);\n } finally {\n this.destroyEncodedObject(dracoData);\n this.destroyEncodedObject(dracoMesh);\n }\n }\n\n /**\n * Set encoding options.\n * @param {{speed?: any; method?: any; quantization?: any;}} options\n */\n _setOptions(options: DracoBuildOptions): void {\n if ('speed' in options) {\n // @ts-ignore\n this.dracoEncoder.SetSpeedOptions(...options.speed);\n }\n if ('method' in options) {\n const dracoMethod = this.draco[options.method || 'MESH_SEQUENTIAL_ENCODING'];\n // assert(dracoMethod)\n this.dracoEncoder.SetEncodingMethod(dracoMethod);\n }\n if ('quantization' in options) {\n for (const attribute in options.quantization) {\n const bits = options.quantization[attribute];\n const dracoPosition = this.draco[attribute];\n this.dracoEncoder.SetAttributeQuantization(dracoPosition, bits);\n }\n }\n }\n\n /**\n * @param {Mesh} dracoMesh\n * @param {object} attributes\n * @returns {Mesh}\n */\n _createDracoMesh(dracoMesh: Mesh, attributes, options: DracoBuildOptions): Mesh {\n const optionalMetadata = options.attributesMetadata || {};\n\n try {\n const positions = this._getPositionAttribute(attributes);\n if (!positions) {\n throw new Error('positions');\n }\n const vertexCount = positions.length / 3;\n\n for (let attributeName in attributes) {\n const attribute = attributes[attributeName];\n attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[attributeName] || attributeName;\n const uniqueId = this._addAttributeToMesh(dracoMesh, attributeName, attribute, vertexCount);\n\n if (uniqueId !== -1) {\n this._addAttributeMetadata(dracoMesh, uniqueId, {\n name: attributeName,\n ...(optionalMetadata[attributeName] || {})\n });\n }\n }\n } catch (error) {\n this.destroyEncodedObject(dracoMesh);\n throw error;\n }\n\n return dracoMesh;\n }\n\n /**\n * @param {} dracoPointCloud\n * @param {object} attributes\n */\n _createDracoPointCloud(\n dracoPointCloud: PointCloud,\n attributes: object,\n options: DracoBuildOptions\n ): PointCloud {\n const optionalMetadata = options.attributesMetadata || {};\n\n try {\n const positions = this._getPositionAttribute(attributes);\n if (!positions) {\n throw new Error('positions');\n }\n const vertexCount = positions.length / 3;\n\n for (let attributeName in attributes) {\n const attribute = attributes[attributeName];\n attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[attributeName] || attributeName;\n const uniqueId = this._addAttributeToMesh(\n dracoPointCloud,\n attributeName,\n attribute,\n vertexCount\n );\n if (uniqueId !== -1) {\n this._addAttributeMetadata(dracoPointCloud, uniqueId, {\n name: attributeName,\n ...(optionalMetadata[attributeName] || {})\n });\n }\n }\n } catch (error) {\n this.destroyEncodedObject(dracoPointCloud);\n throw error;\n }\n\n return dracoPointCloud;\n }\n\n /**\n * @param mesh\n * @param attributeName\n * @param attribute\n * @param vertexCount\n */\n _addAttributeToMesh(\n mesh: PointCloud,\n attributeName: string,\n attribute: TypedArray,\n vertexCount: number\n ) {\n if (!ArrayBuffer.isView(attribute)) {\n return -1;\n }\n\n const type = this._getDracoAttributeType(attributeName);\n // @ts-ignore TODO/fix types\n const size = attribute.length / vertexCount;\n\n if (type === 'indices') {\n // @ts-ignore TODO/fix types\n const numFaces = attribute.length / 3;\n this.log(`Adding attribute ${attributeName}, size ${numFaces}`);\n\n // @ts-ignore assumes mesh is a Mesh, not a point cloud\n this.dracoMeshBuilder.AddFacesToMesh(mesh, numFaces, attribute);\n return -1;\n }\n\n this.log(`Adding attribute ${attributeName}, size ${size}`);\n\n const builder = this.dracoMeshBuilder;\n const {buffer} = attribute;\n\n switch (attribute.constructor) {\n case Int8Array:\n return builder.AddInt8Attribute(mesh, type, vertexCount, size, new Int8Array(buffer));\n\n case Int16Array:\n return builder.AddInt16Attribute(mesh, type, vertexCount, size, new Int16Array(buffer));\n\n case Int32Array:\n return builder.AddInt32Attribute(mesh, type, vertexCount, size, new Int32Array(buffer));\n case Uint8Array:\n case Uint8ClampedArray:\n return builder.AddUInt8Attribute(mesh, type, vertexCount, size, new Uint8Array(buffer));\n\n case Uint16Array:\n return builder.AddUInt16Attribute(mesh, type, vertexCount, size, new Uint16Array(buffer));\n\n case Uint32Array:\n return builder.AddUInt32Attribute(mesh, type, vertexCount, size, new Uint32Array(buffer));\n\n case Float32Array:\n default:\n return builder.AddFloatAttribute(mesh, type, vertexCount, size, new Float32Array(buffer));\n }\n }\n\n /**\n * DRACO can compress attributes of know type better\n * TODO - expose an attribute type map?\n * @param attributeName\n */\n _getDracoAttributeType(attributeName: string): draco_GeometryAttribute_Type | 'indices' {\n switch (attributeName.toLowerCase()) {\n case 'indices':\n return 'indices';\n case 'position':\n case 'positions':\n case 'vertices':\n return this.draco.POSITION;\n case 'normal':\n case 'normals':\n return this.draco.NORMAL;\n case 'color':\n case 'colors':\n return this.draco.COLOR;\n case 'texcoord':\n case 'texcoords':\n return this.draco.TEX_COORD;\n default:\n return this.draco.GENERIC;\n }\n }\n\n _getPositionAttribute(attributes) {\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n const dracoType = this._getDracoAttributeType(attributeName);\n if (dracoType === this.draco.POSITION) {\n return attribute;\n }\n }\n return null;\n }\n\n /**\n * Add metadata for the geometry.\n * @param dracoGeometry - WASM Draco Object\n * @param metadata\n */\n _addGeometryMetadata(dracoGeometry: PointCloud, metadata: {[key: string]: string}) {\n const dracoMetadata = new this.draco.Metadata();\n this._populateDracoMetadata(dracoMetadata, metadata);\n this.dracoMeshBuilder.AddMetadata(dracoGeometry, dracoMetadata);\n }\n\n /**\n * Add metadata for an attribute to geometry.\n * @param dracoGeometry - WASM Draco Object\n * @param uniqueAttributeId\n * @param metadata\n */\n _addAttributeMetadata(\n dracoGeometry: PointCloud,\n uniqueAttributeId: number,\n metadata: Map<string, string> | {[key: string]: string}\n ) {\n // Note: Draco JS IDL doesn't seem to expose draco.AttributeMetadata, however it seems to\n // create such objects automatically from draco.Metadata object.\n const dracoAttributeMetadata = new this.draco.Metadata();\n this._populateDracoMetadata(dracoAttributeMetadata, metadata);\n // Draco3d doc note: Directly add attribute metadata to geometry.\n // You can do this without explicitly adding |GeometryMetadata| to mesh.\n this.dracoMeshBuilder.SetMetadataForAttribute(\n dracoGeometry,\n uniqueAttributeId,\n dracoAttributeMetadata\n );\n }\n\n /**\n * Add contents of object or map to a WASM Draco Metadata Object\n * @param dracoMetadata - WASM Draco Object\n * @param metadata\n */\n _populateDracoMetadata(\n dracoMetadata: Metadata,\n metadata: Map<string, string> | {[key: string]: string}\n ) {\n for (const [key, value] of getEntries(metadata)) {\n switch (typeof value) {\n case 'number':\n if (Math.trunc(value) === value) {\n this.dracoMetadataBuilder.AddIntEntry(dracoMetadata, key, value);\n } else {\n this.dracoMetadataBuilder.AddDoubleEntry(dracoMetadata, key, value);\n }\n break;\n case 'object':\n if (value instanceof Int32Array) {\n this.dracoMetadataBuilder.AddIntEntryArray(dracoMetadata, key, value, value.length);\n }\n break;\n case 'string':\n default:\n this.dracoMetadataBuilder.AddStringEntry(dracoMetadata, key, value);\n }\n }\n }\n}\n\n// HELPER FUNCTIONS\n\n/**\n * Copy encoded data to buffer\n * @param dracoData\n */\nfunction dracoInt8ArrayToArrayBuffer(dracoData: DracoInt8Array) {\n const byteLength = dracoData.size();\n const outputBuffer = new ArrayBuffer(byteLength);\n const outputData = new Int8Array(outputBuffer);\n for (let i = 0; i < byteLength; ++i) {\n outputData[i] = dracoData.GetValue(i);\n }\n return outputBuffer;\n}\n\n/** Enable iteration over either an object or a map */\nfunction getEntries(container) {\n const hasEntriesFunc = container.entries && !container.hasOwnProperty('entries');\n return hasEntriesFunc ? container.entries() : Object.entries(container);\n}\n", "// Dynamic DRACO module loading inspired by THREE.DRACOLoader\n// https://github.com/mrdoob/three.js/blob/398c4f39ebdb8b23eefd4a7a5ec49ec0c96c7462/examples/jsm/loaders/DRACOLoader.js\n// by Don McCurdy / https://www.donmccurdy.com / MIT license\n\nimport {loadLibrary} from '@loaders.gl/worker-utils';\n\nconst DRACO_DECODER_VERSION = '1.5.5';\nconst DRACO_ENCODER_VERSION = '1.4.1';\n\nconst STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;\n\nconst DRACO_JS_DECODER_URL = `${STATIC_DECODER_URL}/draco_decoder.js`;\nconst DRACO_WASM_WRAPPER_URL = `${STATIC_DECODER_URL}/draco_wasm_wrapper.js`;\nconst DRACO_WASM_DECODER_URL = `${STATIC_DECODER_URL}/draco_decoder.wasm`;\n\nconst DRACO_ENCODER_URL = `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/draco_encoder.js`;\n\nlet loadDecoderPromise;\nlet loadEncoderPromise;\n\nexport async function loadDracoDecoderModule(options) {\n const modules = options.modules || {};\n\n // Check if a bundled draco3d library has been supplied by application\n if (modules.draco3d) {\n loadDecoderPromise =\n loadDecoderPromise ||\n modules.draco3d.createDecoderModule({}).then((draco) => {\n return {draco};\n });\n } else {\n // If not, dynamically load the WASM script from our CDN\n loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);\n }\n return await loadDecoderPromise;\n}\n\nexport async function loadDracoEncoderModule(options) {\n const modules = options.modules || {};\n\n // Check if a bundled draco3d library has been supplied by application\n if (modules.draco3d) {\n loadEncoderPromise =\n loadEncoderPromise ||\n modules.draco3d.createEncoderModule({}).then((draco) => {\n return {draco};\n });\n } else {\n // If not, dynamically load the WASM script from our CDN\n loadEncoderPromise = loadEncoderPromise || loadDracoEncoder(options);\n }\n return await loadEncoderPromise;\n}\n\n// DRACO DECODER LOADING\n\nasync function loadDracoDecoder(options) {\n let DracoDecoderModule;\n let wasmBinary;\n switch (options.draco && options.draco.decoderType) {\n case 'js':\n DracoDecoderModule = await loadLibrary(DRACO_JS_DECODER_URL, 'draco', options);\n break;\n\n case 'wasm':\n default:\n [DracoDecoderModule, wasmBinary] = await Promise.all([\n await loadLibrary(DRACO_WASM_WRAPPER_URL, 'draco', options),\n await loadLibrary(DRACO_WASM_DECODER_URL, 'draco', options)\n ]);\n }\n // Depends on how import happened...\n // @ts-ignore\n DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;\n return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);\n}\n\nfunction initializeDracoDecoder(DracoDecoderModule, wasmBinary) {\n const options: {wasmBinary?: any} = {};\n if (wasmBinary) {\n options.wasmBinary = wasmBinary;\n }\n\n return new Promise((resolve) => {\n DracoDecoderModule({\n ...options,\n onModuleLoaded: (draco) => resolve({draco}) // Module is Promise-like. Wrap in object to avoid loop.\n });\n });\n}\n\n// ENCODER\n\nasync function loadDracoEncoder(options) {\n let DracoEncoderModule = await loadLibrary(DRACO_ENCODER_URL, 'draco', options);\n // @ts-ignore\n DracoEncoderModule = DracoEncoderModule || globalThis.DracoEncoderModule;\n\n return new Promise((resolve) => {\n DracoEncoderModule({\n onModuleLoaded: (draco) => resolve({draco}) // Module is Promise-like. Wrap in object to avoid loop.\n });\n });\n}\n", "// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n", "import type {Writer, WriterOptions} from '@loaders.gl/loader-utils';\nimport type {DracoMesh} from './lib/draco-types';\nimport type {DracoBuildOptions} from './lib/draco-builder';\nimport DRACOBuilder from './lib/draco-builder';\nimport {loadDracoEncoderModule} from './lib/draco-module-loader';\nimport {VERSION} from './lib/utils/version';\n\n/** Writer Options for draco */\nexport type DracoWriterOptions = WriterOptions & {\n draco?: DracoBuildOptions & {\n method?: 'MESH_EDGEBREAKER_ENCODING' | 'MESH_SEQUENTIAL_ENCODING';\n speed?: [number, number];\n quantization?: Record<string, number>;\n attributeNameEntry?: string;\n };\n};\n\nconst DEFAULT_DRACO_WRITER_OPTIONS = {\n pointcloud: false, // Set to true if pointcloud (mode: 0, no indices)\n attributeNameEntry: 'name'\n // Draco Compression Parameters\n // method: 'MESH_EDGEBREAKER_ENCODING', // Use draco defaults\n // speed: [5, 5], // Use draco defaults\n // quantization: { // Use draco defaults\n // POSITION: 10\n // }\n};\n\n/**\n * Exporter for Draco3D compressed geometries\n */\nexport const DracoWriter: Writer<DracoMesh, unknown, DracoWriterOptions> = {\n name: 'DRACO',\n id: 'draco',\n module: 'draco',\n version: VERSION,\n extensions: ['drc'],\n encode,\n options: {\n draco: DEFAULT_DRACO_WRITER_OPTIONS\n }\n};\n\nasync function encode(data: DracoMesh, options: DracoWriterOptions = {}): Promise<ArrayBuffer> {\n // Dynamically load draco\n const {draco} = await loadDracoEncoderModule(options);\n const dracoBuilder = new DRACOBuilder(draco);\n\n try {\n return dracoBuilder.encodeSync(data, options.draco);\n } finally {\n dracoBuilder.destroy();\n }\n}\n", "import {WorkerBody, WorkerMessagePayload} from '@loaders.gl/worker-utils';\nimport {DracoWriter} from '../draco-writer';\n\n(() => {\n // Check that we are actually in a worker thread\n if (!WorkerBody.inWorkerThread()) {\n return;\n }\n\n WorkerBody.onmessage = async (type, payload: WorkerMessagePayload) => {\n switch (type) {\n case 'process':\n try {\n const {input, options} = payload;\n const result = await DracoWriter.encode!(input, options);\n WorkerBody.postMessage('done', {result});\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n break;\n default:\n }\n };\n})();\n"],
5
- "mappings": "wlBAAA,gBCMO,GAAM,GAA+C,gBCDrD,WAAgB,EAAgB,EAAwB,CAC7D,GAAI,CAAC,EACH,KAAM,IAAI,OAAM,GAAW,gCCH/B,GAAM,GAAU,CACd,KAAM,MAAO,OAAS,aAAe,KACrC,OAAQ,MAAO,SAAW,aAAe,OACzC,OAAQ,MAAO,SAAW,aAAe,OACzC,SAAU,MAAO,WAAa,aAAe,UAGzC,GAA8B,EAAQ,MAAQ,EAAQ,QAAU,EAAQ,QAAU,GAClF,GAAgC,EAAQ,QAAU,EAAQ,MAAQ,EAAQ,QAAU,GACpF,EAAgC,EAAQ,QAAU,EAAQ,MAAQ,EAAQ,QAAU,GACpF,GAAkC,EAAQ,UAAY,GAKrD,GAAM,GAEX,MAAO,UAAY,UAAY,OAAO,WAAa,oBAAsB,QAAQ,QAGtE,EAAoB,MAAO,gBAAkB,WAG7C,GACX,MAAO,SAAW,aAAe,MAAO,QAAO,aAAgB,YAG3D,EACJ,MAAO,UAAY,aAAe,QAAQ,SAAW,YAAY,KAAK,QAAQ,SAGnE,GAAuB,GAAW,WAAW,EAAQ,KAAQ,ECxBnE,WACL,EACA,EA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GAAU,YAAiB,OAAQ,EAAM,QAAU,GACzD,EAAW,YAAY,QAAS,CAAC,MAAO,IAE1C",
4
+ "sourcesContent": ["", "// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n\n/**\n * TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...\n * 'beta' on beta branch, 'latest' on prod branch\n */\nexport const NPM_TAG = 'beta'; // Change to `latest` on production branches\n\ndeclare let __VERSION__: string;\n\nfunction getVersion() {\n if (!globalThis._loadersgl_?.version) {\n globalThis._loadersgl_ = globalThis._loadersgl_ || {};\n // __VERSION__ is injected by babel-plugin-version-inline\n if (typeof __VERSION__ === 'undefined') {\n // eslint-disable-next-line\n console.error(\n 'loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.'\n );\n globalThis._loadersgl_.version = NPM_TAG;\n } else {\n globalThis._loadersgl_.version = __VERSION__;\n }\n }\n\n return globalThis._loadersgl_.version;\n}\n\nexport const VERSION = getVersion();\n", "// Replacement for the external assert method to reduce bundle size\n// Note: We don't use the second \"message\" argument in calling code,\n// so no need to support it here\n\n/** Throws an `Error` with the optional `message` if `condition` is falsy */\nexport function assert(condition: any, message?: string): void {\n if (!condition) {\n throw new Error(message || 'loaders.gl assertion failed.');\n }\n}\n", "// Purpose: include this in your module to avoids adding dependencies on\n// micro modules like 'global' and 'is-browser';\n\n/* eslint-disable no-restricted-globals */\nconst globals = {\n self: typeof self !== 'undefined' && self,\n window: typeof window !== 'undefined' && window,\n global: typeof global !== 'undefined' && global,\n document: typeof document !== 'undefined' && document\n};\n\nconst self_: {[key: string]: any} = globals.self || globals.window || globals.global || {};\nconst window_: {[key: string]: any} = globals.window || globals.self || globals.global || {};\nconst global_: {[key: string]: any} = globals.global || globals.self || globals.window || {};\nconst document_: {[key: string]: any} = globals.document || {};\n\nexport {self_ as self, window_ as window, global_ as global, document_ as document};\n\n/** true if running in the browser, false if running in Node.js */\nexport const isBrowser: boolean =\n // @ts-ignore process.browser\n typeof process !== 'object' || String(process) !== '[object process]' || process.browser;\n\n/** true if running on a worker thread */\nexport const isWorker: boolean = typeof importScripts === 'function';\n\n/** true if running on a mobile device */\nexport const isMobile: boolean =\n typeof window !== 'undefined' && typeof window.orientation !== 'undefined';\n\n// Extract node major version\nconst matches =\n typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version);\n\n/** Version of Node.js if running under Node, otherwise 0 */\nexport const nodeVersion: number = (matches && parseFloat(matches[1])) || 0;\n", "// NOTE - there is a copy of this function is both in core and loader-utils\n// core does not need all the utils in loader-utils, just this one.\n\n/**\n * Returns an array of Transferrable objects that can be used with postMessage\n * https://developer.mozilla.org/en-US/docs/Web/API/Worker/postMessage\n * @param object data to be sent via postMessage\n * @param recursive - not for application use\n * @param transfers - not for application use\n * @returns a transfer list that can be passed to postMessage\n */\nexport function getTransferList(\n object: any,\n recursive: boolean = true,\n transfers?: Set<any>\n): Transferable[] {\n // Make sure that items in the transfer list is unique\n const transfersSet = transfers || new Set();\n\n if (!object) {\n // ignore\n } else if (isTransferable(object)) {\n transfersSet.add(object);\n } else if (isTransferable(object.buffer)) {\n // Typed array\n transfersSet.add(object.buffer);\n } else if (ArrayBuffer.isView(object)) {\n // object is a TypeArray viewing into a SharedArrayBuffer (not transferable)\n // Do not iterate through the content in this case\n } else if (recursive && typeof object === 'object') {\n for (const key in object) {\n // Avoid perf hit - only go one level deep\n getTransferList(object[key], recursive, transfersSet);\n }\n }\n\n // If transfers is defined, is internal recursive call\n // Otherwise it's called by the user\n return transfers === undefined ? Array.from(transfersSet) : [];\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Transferable\nfunction isTransferable(object: unknown) {\n if (!object) {\n return false;\n }\n if (object instanceof ArrayBuffer) {\n return true;\n }\n if (typeof MessagePort !== 'undefined' && object instanceof MessagePort) {\n return true;\n }\n if (typeof ImageBitmap !== 'undefined' && object instanceof ImageBitmap) {\n return true;\n }\n // @ts-ignore\n if (typeof OffscreenCanvas !== 'undefined' && object instanceof OffscreenCanvas) {\n return true;\n }\n return false;\n}\n\n/**\n * Recursively drop non serializable values like functions and regexps.\n * @param object\n */\nexport function getTransferListForWriter(object: object | null): object {\n if (object === null) {\n return {};\n }\n const clone = Object.assign({}, object);\n\n Object.keys(clone).forEach((key) => {\n // Typed Arrays and Arrays are passed with no change\n if (\n typeof object[key] === 'object' &&\n !ArrayBuffer.isView(object[key]) &&\n !(object[key] instanceof Array)\n ) {\n clone[key] = getTransferListForWriter(object[key]);\n } else if (typeof clone[key] === 'function' || clone[key] instanceof RegExp) {\n clone[key] = {};\n } else {\n clone[key] = object[key];\n }\n });\n\n return clone;\n}\n", "import type {WorkerMessageData, WorkerMessageType, WorkerMessagePayload} from '../../types';\nimport {getTransferList} from '../worker-utils/get-transfer-list';\n\n/** Vile hack to defeat over-zealous bundlers from stripping out the require */\nfunction getParentPort() {\n // const isNode = globalThis.process;\n let parentPort;\n try {\n // prettier-ignore\n eval('globalThis.parentPort = require(\\'worker_threads\\').parentPort'); // eslint-disable-line no-eval\n parentPort = globalThis.parentPort;\n // eslint-disable-next-line no-empty\n } catch {}\n return parentPort;\n}\n\nconst onMessageWrapperMap = new Map();\n\n/**\n * Type safe wrapper for worker code\n */\nexport default class WorkerBody {\n /** Check that we are actually in a worker thread */\n static inWorkerThread(): boolean {\n return typeof self !== 'undefined' || Boolean(getParentPort());\n }\n\n /*\n * (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n */\n static set onmessage(onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any) {\n function handleMessage(message) {\n // Confusingly the message itself also has a 'type' field which is always set to 'message'\n const parentPort = getParentPort();\n const {type, payload} = parentPort ? message : message.data;\n // if (!isKnownMessage(message)) {\n // return;\n // }\n onMessage(type, payload);\n }\n\n const parentPort = getParentPort();\n if (parentPort) {\n parentPort.on('message', handleMessage);\n // if (message == 'exit') { parentPort.unref(); }\n // eslint-disable-next-line\n parentPort.on('exit', () => console.debug('Node worker closing'));\n } else {\n // eslint-disable-next-line no-restricted-globals\n globalThis.onmessage = handleMessage;\n }\n }\n\n static addEventListener(\n onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n ) {\n let onMessageWrapper = onMessageWrapperMap.get(onMessage);\n\n if (!onMessageWrapper) {\n onMessageWrapper = (message: MessageEvent<any>) => {\n if (!isKnownMessage(message)) {\n return;\n }\n\n // Confusingly in the browser, the message itself also has a 'type' field which is always set to 'message'\n const parentPort = getParentPort();\n const {type, payload} = parentPort ? message : message.data;\n onMessage(type, payload);\n };\n }\n\n const parentPort = getParentPort();\n if (parentPort) {\n console.error('not implemented'); // eslint-disable-line\n } else {\n globalThis.addEventListener('message', onMessageWrapper);\n }\n }\n\n static removeEventListener(\n onMessage: (type: WorkerMessageType, payload: WorkerMessagePayload) => any\n ) {\n const onMessageWrapper = onMessageWrapperMap.get(onMessage);\n onMessageWrapperMap.delete(onMessage);\n const parentPort = getParentPort();\n if (parentPort) {\n console.error('not implemented'); // eslint-disable-line\n } else {\n globalThis.removeEventListener('message', onMessageWrapper);\n }\n }\n\n /**\n * Send a message from a worker to creating thread (main thread)\n * @param type\n * @param payload\n */\n static postMessage(type: WorkerMessageType, payload: WorkerMessagePayload): void {\n const data: WorkerMessageData = {source: 'loaders.gl', type, payload};\n // console.log('posting message', data);\n const transferList = getTransferList(payload);\n\n const parentPort = getParentPort();\n if (parentPort) {\n parentPort.postMessage(data, transferList);\n // console.log('posted message', data);\n } else {\n // @ts-ignore\n globalThis.postMessage(data, transferList);\n }\n }\n}\n\n// Filter out noise messages sent to workers\nfunction isKnownMessage(message: MessageEvent<any>) {\n const {type, data} = message;\n return (\n type === 'message' &&\n data &&\n typeof data.source === 'string' &&\n data.source.startsWith('loaders.gl')\n );\n}\n", "/* global importScripts */\nimport {global, isBrowser, isWorker} from '../env-utils/globals';\nimport * as node from '../node/require-utils.node';\nimport {assert} from '../env-utils/assert';\nimport {VERSION} from '../env-utils/version';\n\nconst loadLibraryPromises: Record<string, Promise<any>> = {}; // promises\n\n/**\n * Dynamically loads a library (\"module\")\n *\n * - wasm library: Array buffer is returned\n * - js library: Parse JS is returned\n *\n * Method depends on environment\n * - browser - script element is created and installed on document\n * - worker - eval is called on global context\n * - node - file is required\n *\n * @param libraryUrl\n * @param moduleName\n * @param options\n */\nexport async function loadLibrary(\n libraryUrl: string,\n moduleName: string | null = null,\n options: object = {},\n libraryName: string | null = null\n): Promise<any> {\n if (moduleName) {\n libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);\n }\n // Ensure libraries are only loaded once\n\n loadLibraryPromises[libraryUrl] =\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);\n return await loadLibraryPromises[libraryUrl];\n}\n\n// TODO - sort out how to resolve paths for main/worker and dev/prod\nexport function getLibraryUrl(\n library: string,\n moduleName?: string,\n options: any = {},\n libraryName: string | null = null\n): string {\n // Check if already a URL\n if (!options.useLocalLibraries && library.startsWith('http')) {\n return library;\n }\n\n libraryName = libraryName || library;\n\n // Allow application to import and supply libraries through `options.modules`\n const modules = options.modules || {};\n if (modules[libraryName]) {\n return modules[libraryName];\n }\n\n // Load from local files, not from CDN scripts in Node.js\n // TODO - needs to locate the modules directory when installed!\n if (!isBrowser) {\n return `modules/${moduleName}/dist/libs/${libraryName}`;\n }\n\n // In browser, load from external scripts\n if (options.CDN) {\n assert(options.CDN.startsWith('http'));\n return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${libraryName}`;\n }\n\n // TODO - loading inside workers requires paths relative to worker script location...\n if (isWorker) {\n return `../src/libs/${libraryName}`;\n }\n\n return `modules/${moduleName}/src/libs/${libraryName}`;\n}\n\nasync function loadLibraryFromFile(libraryUrl: string): Promise<any> {\n if (libraryUrl.endsWith('wasm')) {\n return await loadAsArrayBuffer(libraryUrl);\n }\n\n if (!isBrowser) {\n try {\n return node && node.requireFromFile && (await node.requireFromFile(libraryUrl));\n } catch {\n return null;\n }\n }\n if (isWorker) {\n return importScripts(libraryUrl);\n }\n // TODO - fix - should be more secure than string parsing since observes CORS\n // if (isBrowser) {\n // return await loadScriptFromFile(libraryUrl);\n // }\n\n const scriptSource = await loadAsText(libraryUrl);\n return loadLibraryFromString(scriptSource, libraryUrl);\n}\n\n/*\nasync function loadScriptFromFile(libraryUrl) {\n const script = document.createElement('script');\n script.src = libraryUrl;\n return await new Promise((resolve, reject) => {\n script.onload = data => {\n resolve(data);\n };\n script.onerror = reject;\n });\n}\n*/\n\n// TODO - Needs security audit...\n// - Raw eval call\n// - Potentially bypasses CORS\n// Upside is that this separates fetching and parsing\n// we could create a`LibraryLoader` or`ModuleLoader`\nfunction loadLibraryFromString(scriptSource: string, id: string): null | any {\n if (!isBrowser) {\n return node.requireFromString && node.requireFromString(scriptSource, id);\n }\n\n if (isWorker) {\n // Use lvalue trick to make eval run in global scope\n eval.call(global, scriptSource); // eslint-disable-line no-eval\n // https://stackoverflow.com/questions/9107240/1-evalthis-vs-evalthis-in-javascript\n // http://perfectionkills.com/global-eval-what-are-the-options/\n return null;\n }\n\n const script = document.createElement('script');\n script.id = id;\n // most browsers like a separate text node but some throw an error. The second method covers those.\n try {\n script.appendChild(document.createTextNode(scriptSource));\n } catch (e) {\n script.text = scriptSource;\n }\n document.body.appendChild(script);\n return null;\n}\n\n// TODO - technique for module injection into worker, from THREE.DracoLoader...\n/*\nfunction combineWorkerWithLibrary(worker, jsContent) {\n var fn = wWorker.toString();\n var body = [\n '// injected',\n jsContent,\n '',\n '// worker',\n fn.substring(fn.indexOf('{') + 1, fn.lastIndexOf('}'))\n ].join('\\n');\n this.workerSourceURL = URL.createObjectURL(new Blob([body]));\n}\n*/\n\nasync function loadAsArrayBuffer(url: string): Promise<ArrayBuffer> {\n if (!node.readFileAsArrayBuffer || url.startsWith('http')) {\n const response = await fetch(url);\n return await response.arrayBuffer();\n }\n return await node.readFileAsArrayBuffer(url);\n}\n\n/**\n * Load a file from local file system\n * @param filename\n * @returns\n */\nasync function loadAsText(url: string): Promise<string> {\n if (!node.readFileAsText || url.startsWith('http')) {\n const response = await fetch(url);\n return await response.text();\n }\n return await node.readFileAsText(url);\n}\n", "/* eslint-disable camelcase */\n// This code is inspired by example code in the DRACO repository\nimport type {\n Draco3D,\n DracoInt8Array,\n Encoder,\n Mesh,\n MeshBuilder,\n PointCloud,\n Metadata,\n MetadataBuilder,\n draco_GeometryAttribute_Type\n} from '../draco3d/draco3d-types';\n\nimport type {TypedArray} from '@loaders.gl/schema';\nimport type {DracoMesh} from './draco-types';\n\nexport type DracoBuildOptions = {\n pointcloud?: boolean;\n metadata?: {[key: string]: string};\n attributesMetadata?: {};\n log?: any;\n\n // draco encoding options\n speed?: [number, number];\n method?: string;\n quantization?: {[attributeName: string]: number};\n};\n\n// Native Draco attribute names to GLTF attribute names.\nconst GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP = {\n POSITION: 'POSITION',\n NORMAL: 'NORMAL',\n COLOR_0: 'COLOR',\n TEXCOORD_0: 'TEX_COORD'\n};\n\nconst noop = () => {};\n\nexport default class DracoBuilder {\n draco: Draco3D;\n dracoEncoder: Encoder;\n dracoMeshBuilder: MeshBuilder;\n dracoMetadataBuilder: MetadataBuilder;\n log: any;\n\n // draco - the draco decoder, either import `draco3d` or load dynamically\n constructor(draco: Draco3D) {\n this.draco = draco;\n this.dracoEncoder = new this.draco.Encoder();\n this.dracoMeshBuilder = new this.draco.MeshBuilder();\n this.dracoMetadataBuilder = new this.draco.MetadataBuilder();\n }\n\n destroy(): void {\n this.destroyEncodedObject(this.dracoMeshBuilder);\n this.destroyEncodedObject(this.dracoEncoder);\n this.destroyEncodedObject(this.dracoMetadataBuilder);\n // @ts-ignore\n this.dracoMeshBuilder = null;\n // @ts-ignore\n this.dracoEncoder = null;\n // @ts-ignore\n this.draco = null;\n }\n\n // TBD - when does this need to be called?\n destroyEncodedObject(object): void {\n if (object) {\n this.draco.destroy(object);\n }\n }\n\n /**\n * Encode mesh or point cloud\n * @param mesh =({})\n * @param options\n */\n encodeSync(mesh: DracoMesh, options: DracoBuildOptions = {}): ArrayBuffer {\n this.log = noop; // TODO\n this._setOptions(options);\n\n return options.pointcloud\n ? this._encodePointCloud(mesh, options)\n : this._encodeMesh(mesh, options);\n }\n\n // PRIVATE\n\n _getAttributesFromMesh(mesh: DracoMesh) {\n // TODO - Change the encodePointCloud interface instead?\n const attributes = {...mesh, ...mesh.attributes};\n // Fold indices into the attributes\n if (mesh.indices) {\n attributes.indices = mesh.indices;\n }\n return attributes;\n }\n\n _encodePointCloud(pointcloud: DracoMesh, options: DracoBuildOptions): ArrayBuffer {\n const dracoPointCloud = new this.draco.PointCloud();\n\n if (options.metadata) {\n this._addGeometryMetadata(dracoPointCloud, options.metadata);\n }\n\n const attributes = this._getAttributesFromMesh(pointcloud);\n\n // Build a `DracoPointCloud` from the input data\n this._createDracoPointCloud(dracoPointCloud, attributes, options);\n\n const dracoData = new this.draco.DracoInt8Array();\n\n try {\n const encodedLen = this.dracoEncoder.EncodePointCloudToDracoBuffer(\n dracoPointCloud,\n false,\n dracoData\n );\n\n if (!(encodedLen > 0)) {\n throw new Error('Draco encoding failed.');\n }\n\n this.log(`DRACO encoded ${dracoPointCloud.num_points()} points\n with ${dracoPointCloud.num_attributes()} attributes into ${encodedLen} bytes`);\n\n return dracoInt8ArrayToArrayBuffer(dracoData);\n } finally {\n this.destroyEncodedObject(dracoData);\n this.destroyEncodedObject(dracoPointCloud);\n }\n }\n\n _encodeMesh(mesh: DracoMesh, options: DracoBuildOptions): ArrayBuffer {\n const dracoMesh = new this.draco.Mesh();\n\n if (options.metadata) {\n this._addGeometryMetadata(dracoMesh, options.metadata);\n }\n\n const attributes = this._getAttributesFromMesh(mesh);\n\n // Build a `DracoMesh` from the input data\n this._createDracoMesh(dracoMesh, attributes, options);\n\n const dracoData = new this.draco.DracoInt8Array();\n\n try {\n const encodedLen = this.dracoEncoder.EncodeMeshToDracoBuffer(dracoMesh, dracoData);\n if (encodedLen <= 0) {\n throw new Error('Draco encoding failed.');\n }\n\n this.log(`DRACO encoded ${dracoMesh.num_points()} points\n with ${dracoMesh.num_attributes()} attributes into ${encodedLen} bytes`);\n\n return dracoInt8ArrayToArrayBuffer(dracoData);\n } finally {\n this.destroyEncodedObject(dracoData);\n this.destroyEncodedObject(dracoMesh);\n }\n }\n\n /**\n * Set encoding options.\n * @param {{speed?: any; method?: any; quantization?: any;}} options\n */\n _setOptions(options: DracoBuildOptions): void {\n if ('speed' in options) {\n // @ts-ignore\n this.dracoEncoder.SetSpeedOptions(...options.speed);\n }\n if ('method' in options) {\n const dracoMethod = this.draco[options.method || 'MESH_SEQUENTIAL_ENCODING'];\n // assert(dracoMethod)\n this.dracoEncoder.SetEncodingMethod(dracoMethod);\n }\n if ('quantization' in options) {\n for (const attribute in options.quantization) {\n const bits = options.quantization[attribute];\n const dracoPosition = this.draco[attribute];\n this.dracoEncoder.SetAttributeQuantization(dracoPosition, bits);\n }\n }\n }\n\n /**\n * @param {Mesh} dracoMesh\n * @param {object} attributes\n * @returns {Mesh}\n */\n _createDracoMesh(dracoMesh: Mesh, attributes, options: DracoBuildOptions): Mesh {\n const optionalMetadata = options.attributesMetadata || {};\n\n try {\n const positions = this._getPositionAttribute(attributes);\n if (!positions) {\n throw new Error('positions');\n }\n const vertexCount = positions.length / 3;\n\n for (let attributeName in attributes) {\n const attribute = attributes[attributeName];\n attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[attributeName] || attributeName;\n const uniqueId = this._addAttributeToMesh(dracoMesh, attributeName, attribute, vertexCount);\n\n if (uniqueId !== -1) {\n this._addAttributeMetadata(dracoMesh, uniqueId, {\n name: attributeName,\n ...(optionalMetadata[attributeName] || {})\n });\n }\n }\n } catch (error) {\n this.destroyEncodedObject(dracoMesh);\n throw error;\n }\n\n return dracoMesh;\n }\n\n /**\n * @param {} dracoPointCloud\n * @param {object} attributes\n */\n _createDracoPointCloud(\n dracoPointCloud: PointCloud,\n attributes: object,\n options: DracoBuildOptions\n ): PointCloud {\n const optionalMetadata = options.attributesMetadata || {};\n\n try {\n const positions = this._getPositionAttribute(attributes);\n if (!positions) {\n throw new Error('positions');\n }\n const vertexCount = positions.length / 3;\n\n for (let attributeName in attributes) {\n const attribute = attributes[attributeName];\n attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[attributeName] || attributeName;\n const uniqueId = this._addAttributeToMesh(\n dracoPointCloud,\n attributeName,\n attribute,\n vertexCount\n );\n if (uniqueId !== -1) {\n this._addAttributeMetadata(dracoPointCloud, uniqueId, {\n name: attributeName,\n ...(optionalMetadata[attributeName] || {})\n });\n }\n }\n } catch (error) {\n this.destroyEncodedObject(dracoPointCloud);\n throw error;\n }\n\n return dracoPointCloud;\n }\n\n /**\n * @param mesh\n * @param attributeName\n * @param attribute\n * @param vertexCount\n */\n _addAttributeToMesh(\n mesh: PointCloud,\n attributeName: string,\n attribute: TypedArray,\n vertexCount: number\n ) {\n if (!ArrayBuffer.isView(attribute)) {\n return -1;\n }\n\n const type = this._getDracoAttributeType(attributeName);\n // @ts-ignore TODO/fix types\n const size = attribute.length / vertexCount;\n\n if (type === 'indices') {\n // @ts-ignore TODO/fix types\n const numFaces = attribute.length / 3;\n this.log(`Adding attribute ${attributeName}, size ${numFaces}`);\n\n // @ts-ignore assumes mesh is a Mesh, not a point cloud\n this.dracoMeshBuilder.AddFacesToMesh(mesh, numFaces, attribute);\n return -1;\n }\n\n this.log(`Adding attribute ${attributeName}, size ${size}`);\n\n const builder = this.dracoMeshBuilder;\n const {buffer} = attribute;\n\n switch (attribute.constructor) {\n case Int8Array:\n return builder.AddInt8Attribute(mesh, type, vertexCount, size, new Int8Array(buffer));\n\n case Int16Array:\n return builder.AddInt16Attribute(mesh, type, vertexCount, size, new Int16Array(buffer));\n\n case Int32Array:\n return builder.AddInt32Attribute(mesh, type, vertexCount, size, new Int32Array(buffer));\n case Uint8Array:\n case Uint8ClampedArray:\n return builder.AddUInt8Attribute(mesh, type, vertexCount, size, new Uint8Array(buffer));\n\n case Uint16Array:\n return builder.AddUInt16Attribute(mesh, type, vertexCount, size, new Uint16Array(buffer));\n\n case Uint32Array:\n return builder.AddUInt32Attribute(mesh, type, vertexCount, size, new Uint32Array(buffer));\n\n case Float32Array:\n default:\n return builder.AddFloatAttribute(mesh, type, vertexCount, size, new Float32Array(buffer));\n }\n }\n\n /**\n * DRACO can compress attributes of know type better\n * TODO - expose an attribute type map?\n * @param attributeName\n */\n _getDracoAttributeType(attributeName: string): draco_GeometryAttribute_Type | 'indices' {\n switch (attributeName.toLowerCase()) {\n case 'indices':\n return 'indices';\n case 'position':\n case 'positions':\n case 'vertices':\n return this.draco.POSITION;\n case 'normal':\n case 'normals':\n return this.draco.NORMAL;\n case 'color':\n case 'colors':\n return this.draco.COLOR;\n case 'texcoord':\n case 'texcoords':\n return this.draco.TEX_COORD;\n default:\n return this.draco.GENERIC;\n }\n }\n\n _getPositionAttribute(attributes) {\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n const dracoType = this._getDracoAttributeType(attributeName);\n if (dracoType === this.draco.POSITION) {\n return attribute;\n }\n }\n return null;\n }\n\n /**\n * Add metadata for the geometry.\n * @param dracoGeometry - WASM Draco Object\n * @param metadata\n */\n _addGeometryMetadata(dracoGeometry: PointCloud, metadata: {[key: string]: string}) {\n const dracoMetadata = new this.draco.Metadata();\n this._populateDracoMetadata(dracoMetadata, metadata);\n this.dracoMeshBuilder.AddMetadata(dracoGeometry, dracoMetadata);\n }\n\n /**\n * Add metadata for an attribute to geometry.\n * @param dracoGeometry - WASM Draco Object\n * @param uniqueAttributeId\n * @param metadata\n */\n _addAttributeMetadata(\n dracoGeometry: PointCloud,\n uniqueAttributeId: number,\n metadata: Map<string, string> | {[key: string]: string}\n ) {\n // Note: Draco JS IDL doesn't seem to expose draco.AttributeMetadata, however it seems to\n // create such objects automatically from draco.Metadata object.\n const dracoAttributeMetadata = new this.draco.Metadata();\n this._populateDracoMetadata(dracoAttributeMetadata, metadata);\n // Draco3d doc note: Directly add attribute metadata to geometry.\n // You can do this without explicitly adding |GeometryMetadata| to mesh.\n this.dracoMeshBuilder.SetMetadataForAttribute(\n dracoGeometry,\n uniqueAttributeId,\n dracoAttributeMetadata\n );\n }\n\n /**\n * Add contents of object or map to a WASM Draco Metadata Object\n * @param dracoMetadata - WASM Draco Object\n * @param metadata\n */\n _populateDracoMetadata(\n dracoMetadata: Metadata,\n metadata: Map<string, string> | {[key: string]: string}\n ) {\n for (const [key, value] of getEntries(metadata)) {\n switch (typeof value) {\n case 'number':\n if (Math.trunc(value) === value) {\n this.dracoMetadataBuilder.AddIntEntry(dracoMetadata, key, value);\n } else {\n this.dracoMetadataBuilder.AddDoubleEntry(dracoMetadata, key, value);\n }\n break;\n case 'object':\n if (value instanceof Int32Array) {\n this.dracoMetadataBuilder.AddIntEntryArray(dracoMetadata, key, value, value.length);\n }\n break;\n case 'string':\n default:\n this.dracoMetadataBuilder.AddStringEntry(dracoMetadata, key, value);\n }\n }\n }\n}\n\n// HELPER FUNCTIONS\n\n/**\n * Copy encoded data to buffer\n * @param dracoData\n */\nfunction dracoInt8ArrayToArrayBuffer(dracoData: DracoInt8Array) {\n const byteLength = dracoData.size();\n const outputBuffer = new ArrayBuffer(byteLength);\n const outputData = new Int8Array(outputBuffer);\n for (let i = 0; i < byteLength; ++i) {\n outputData[i] = dracoData.GetValue(i);\n }\n return outputBuffer;\n}\n\n/** Enable iteration over either an object or a map */\nfunction getEntries(container) {\n const hasEntriesFunc = container.entries && !container.hasOwnProperty('entries');\n return hasEntriesFunc ? container.entries() : Object.entries(container);\n}\n", "// Dynamic DRACO module loading inspired by THREE.DRACOLoader\n// https://github.com/mrdoob/three.js/blob/398c4f39ebdb8b23eefd4a7a5ec49ec0c96c7462/examples/jsm/loaders/DRACOLoader.js\n// by Don McCurdy / https://www.donmccurdy.com / MIT license\n\nimport {loadLibrary} from '@loaders.gl/worker-utils';\n\nconst DRACO_DECODER_VERSION = '1.5.6';\nconst DRACO_ENCODER_VERSION = '1.4.1';\n\nconst STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;\n\nexport const DRACO_EXTERNAL_LIBRARIES = {\n /** The primary Draco3D encoder, javascript wrapper part */\n DECODER: 'draco_wasm_wrapper.js',\n /** The primary draco decoder, compiled web assembly part */\n DECODER_WASM: 'draco_decoder.wasm',\n /** Fallback decoder for non-webassebly environments. Very big bundle, lower performance */\n FALLBACK_DECODER: 'draco_decoder.js',\n /** Draco encoder */\n ENCODER: 'draco_encoder.js'\n};\n\nexport const DRACO_EXTERNAL_LIBRARY_URLS = {\n [DRACO_EXTERNAL_LIBRARIES.DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER}`,\n [DRACO_EXTERNAL_LIBRARIES.DECODER_WASM]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER_WASM}`,\n [DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER}`,\n [DRACO_EXTERNAL_LIBRARIES.ENCODER]: `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/${DRACO_EXTERNAL_LIBRARIES.ENCODER}`\n};\n\nlet loadDecoderPromise;\nlet loadEncoderPromise;\n\nexport async function loadDracoDecoderModule(options) {\n const modules = options.modules || {};\n\n // Check if a bundled draco3d library has been supplied by application\n if (modules.draco3d) {\n loadDecoderPromise =\n loadDecoderPromise ||\n modules.draco3d.createDecoderModule({}).then((draco) => {\n return {draco};\n });\n } else {\n // If not, dynamically load the WASM script from our CDN\n loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);\n }\n return await loadDecoderPromise;\n}\n\nexport async function loadDracoEncoderModule(options) {\n const modules = options.modules || {};\n\n // Check if a bundled draco3d library has been supplied by application\n if (modules.draco3d) {\n loadEncoderPromise =\n loadEncoderPromise ||\n modules.draco3d.createEncoderModule({}).then((draco) => {\n return {draco};\n });\n } else {\n // If not, dynamically load the WASM script from our CDN\n loadEncoderPromise = loadEncoderPromise || loadDracoEncoder(options);\n }\n return await loadEncoderPromise;\n}\n\n// DRACO DECODER LOADING\n\nasync function loadDracoDecoder(options) {\n let DracoDecoderModule;\n let wasmBinary;\n switch (options.draco && options.draco.decoderType) {\n case 'js':\n DracoDecoderModule = await loadLibrary(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER],\n 'draco',\n options,\n DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER\n );\n break;\n\n case 'wasm':\n default:\n [DracoDecoderModule, wasmBinary] = await Promise.all([\n await loadLibrary(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],\n 'draco',\n options,\n DRACO_EXTERNAL_LIBRARIES.DECODER\n ),\n await loadLibrary(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],\n 'draco',\n options,\n DRACO_EXTERNAL_LIBRARIES.DECODER_WASM\n )\n ]);\n }\n // Depends on how import happened...\n // @ts-ignore\n DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;\n return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);\n}\n\nfunction initializeDracoDecoder(DracoDecoderModule, wasmBinary) {\n const options: {wasmBinary?: any} = {};\n if (wasmBinary) {\n options.wasmBinary = wasmBinary;\n }\n\n return new Promise((resolve) => {\n DracoDecoderModule({\n ...options,\n onModuleLoaded: (draco) => resolve({draco}) // Module is Promise-like. Wrap in object to avoid loop.\n });\n });\n}\n\n// ENCODER\n\nasync function loadDracoEncoder(options) {\n let DracoEncoderModule = await loadLibrary(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.ENCODER],\n 'draco',\n options,\n DRACO_EXTERNAL_LIBRARIES.ENCODER\n );\n // @ts-ignore\n DracoEncoderModule = DracoEncoderModule || globalThis.DracoEncoderModule;\n\n return new Promise((resolve) => {\n DracoEncoderModule({\n onModuleLoaded: (draco) => resolve({draco}) // Module is Promise-like. Wrap in object to avoid loop.\n });\n });\n}\n", "// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n", "import type {Writer, WriterOptions} from '@loaders.gl/loader-utils';\nimport type {DracoMesh} from './lib/draco-types';\nimport type {DracoBuildOptions} from './lib/draco-builder';\nimport DRACOBuilder from './lib/draco-builder';\nimport {loadDracoEncoderModule} from './lib/draco-module-loader';\nimport {VERSION} from './lib/utils/version';\n\n/** Writer Options for draco */\nexport type DracoWriterOptions = WriterOptions & {\n draco?: DracoBuildOptions & {\n method?: 'MESH_EDGEBREAKER_ENCODING' | 'MESH_SEQUENTIAL_ENCODING';\n speed?: [number, number];\n quantization?: Record<string, number>;\n attributeNameEntry?: string;\n };\n};\n\nconst DEFAULT_DRACO_WRITER_OPTIONS = {\n pointcloud: false, // Set to true if pointcloud (mode: 0, no indices)\n attributeNameEntry: 'name'\n // Draco Compression Parameters\n // method: 'MESH_EDGEBREAKER_ENCODING', // Use draco defaults\n // speed: [5, 5], // Use draco defaults\n // quantization: { // Use draco defaults\n // POSITION: 10\n // }\n};\n\n/**\n * Exporter for Draco3D compressed geometries\n */\nexport const DracoWriter: Writer<DracoMesh, unknown, DracoWriterOptions> = {\n name: 'DRACO',\n id: 'draco',\n module: 'draco',\n version: VERSION,\n extensions: ['drc'],\n encode,\n options: {\n draco: DEFAULT_DRACO_WRITER_OPTIONS\n }\n};\n\nasync function encode(data: DracoMesh, options: DracoWriterOptions = {}): Promise<ArrayBuffer> {\n // Dynamically load draco\n const {draco} = await loadDracoEncoderModule(options);\n const dracoBuilder = new DRACOBuilder(draco);\n\n try {\n return dracoBuilder.encodeSync(data, options.draco);\n } finally {\n dracoBuilder.destroy();\n }\n}\n", "import {WorkerBody, WorkerMessagePayload} from '@loaders.gl/worker-utils';\nimport {DracoWriter} from '../draco-writer';\n\n(() => {\n // Check that we are actually in a worker thread\n if (!WorkerBody.inWorkerThread()) {\n return;\n }\n\n WorkerBody.onmessage = async (type, payload: WorkerMessagePayload) => {\n switch (type) {\n case 'process':\n try {\n const {input, options} = payload;\n const result = await DracoWriter.encode!(input, options);\n WorkerBody.postMessage('done', {result});\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n break;\n default:\n }\n };\n})();\n"],
5
+ "mappings": "wlBAAA,gBCUA,YAAsB,CACpB,MAAK,YAAW,aAAa,SAC3B,YAAW,YAAc,WAAW,aAAe,GASjD,WAAW,YAAY,QAAU,gBAI9B,WAAW,YAAY,QAGzB,GAAM,GAAU,ICvBhB,WAAgB,EAAgB,EAAwB,CAC7D,GAAI,CAAC,EACH,KAAM,IAAI,OAAM,GAAW,gCCH/B,GAAM,GAAU,CACd,KAAM,MAAO,OAAS,aAAe,KACrC,OAAQ,MAAO,SAAW,aAAe,OACzC,OAAQ,MAAO,SAAW,aAAe,OACzC,SAAU,MAAO,WAAa,aAAe,UAGzC,GAA8B,EAAQ,MAAQ,EAAQ,QAAU,EAAQ,QAAU,GAClF,GAAgC,EAAQ,QAAU,EAAQ,MAAQ,EAAQ,QAAU,GACpF,EAAgC,EAAQ,QAAU,EAAQ,MAAQ,EAAQ,QAAU,GACpF,GAAkC,EAAQ,UAAY,GAKrD,GAAM,GAEX,MAAO,UAAY,UAAY,OAAO,WAAa,oBAAsB,QAAQ,QAGtE,EAAoB,MAAO,gBAAkB,WAG7C,GACX,MAAO,SAAW,aAAe,MAAO,QAAO,aAAgB,YAG3D,EACJ,MAAO,UAAY,aAAe,QAAQ,SAAW,YAAY,KAAK,QAAQ,SAGnE,GAAuB,GAAW,WAAW,EAAQ,KAAQ,ECxBnE,WACL,EACA,EAAqB,GACrB,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,MAAO,KAIX,kBAAsB,EAAiB,EAA8B,GAA0B,CAE7F,GAAM,CAAC,SAAS,KAAM,GAAuB,GACvC,EAAe,GAAI,GAAa,GAEtC,GAAI,CACF,MAAO,GAAa,WAAW,EAAM,EAAQ,cAC7C,CACA,EAAa,WChDjB,AAAC,KAAM,CAEL,AAAI,CAAC,EAAW,kBAIhB,GAAW,UAAY,MAAO,EAAM,IAAkC,CACpE,OAAQ,OACD,UACH,GAAI,CACF,GAAM,CAAC,QAAO,WAAW,EACnB,EAAS,KAAM,GAAY,OAAQ,EAAO,GAChD,EAAW,YAAY,OAAQ,CAAC,iBACzB,EAAP,CACA,GAAM,GAAU,YAAiB,OAAQ,EAAM,QAAU,GACzD,EAAW,YAAY,QAAS,CAAC,MAAO,IAE1C",
6
6
  "names": []
7
7
  }
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports._TypecheckDracoLoader = exports.DracoLoader = void 0;
7
+ exports.DracoLoader = void 0;
8
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _version = require("./lib/utils/version");
10
10
  var DEFAULT_DRACO_OPTIONS = {
@@ -28,6 +28,4 @@ var DracoLoader = {
28
28
  options: DEFAULT_DRACO_OPTIONS
29
29
  };
30
30
  exports.DracoLoader = DracoLoader;
31
- var _TypecheckDracoLoader = DracoLoader;
32
- exports._TypecheckDracoLoader = _TypecheckDracoLoader;
33
31
  //# sourceMappingURL=draco-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"draco-loader.js","names":["_version","require","DEFAULT_DRACO_OPTIONS","draco","decoderType","WebAssembly","_typeof2","default","libraryPath","extraAttributes","attributeNameEntry","undefined","DracoLoader","name","id","module","version","VERSION","worker","extensions","mimeTypes","binary","tests","options","exports","_TypecheckDracoLoader"],"sources":["../../src/draco-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\nimport type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {DracoMesh} from './lib/draco-types';\nimport type {DracoParseOptions} from './lib/draco-parser';\nimport {VERSION} from './lib/utils/version';\n\nexport type DracoLoaderOptions = LoaderOptions & {\n draco?: DracoParseOptions & {\n decoderType?: 'wasm' | 'js';\n libraryPath?: string;\n extraAttributes?;\n attributeNameEntry?: string;\n workerUrl?: string;\n };\n};\n\nconst DEFAULT_DRACO_OPTIONS: DracoLoaderOptions = {\n draco: {\n decoderType: typeof WebAssembly === 'object' ? 'wasm' : 'js', // 'js' for IE11\n libraryPath: 'libs/',\n extraAttributes: {},\n attributeNameEntry: undefined\n }\n};\n\n/**\n * Worker loader for Draco3D compressed geometries\n */\nexport const DracoLoader: Loader<DracoMesh, never, DracoLoaderOptions> = {\n name: 'Draco',\n id: 'draco',\n module: 'draco',\n // shapes: ['mesh'],\n version: VERSION,\n worker: true,\n extensions: ['drc'],\n mimeTypes: ['application/octet-stream'],\n binary: true,\n tests: ['DRACO'],\n options: DEFAULT_DRACO_OPTIONS\n};\n\nexport const _TypecheckDracoLoader: Loader = DracoLoader;\n"],"mappings":";;;;;;;;AAIA,IAAAA,QAAA,GAAAC,OAAA;AAYA,IAAMC,qBAAyC,GAAG;EAChDC,KAAK,EAAE;IACLC,WAAW,EAAE,QAAOC,WAAW,qCAAAC,QAAA,CAAAC,OAAA,EAAXF,WAAW,OAAK,QAAQ,GAAG,MAAM,GAAG,IAAI;IAC5DG,WAAW,EAAE,OAAO;IACpBC,eAAe,EAAE,CAAC,CAAC;IACnBC,kBAAkB,EAAEC;EACtB;AACF,CAAC;AAKM,IAAMC,WAAyD,GAAG;EACvEC,IAAI,EAAE,OAAO;EACbC,EAAE,EAAE,OAAO;EACXC,MAAM,EAAE,OAAO;EAEfC,OAAO,EAAEC,gBAAO;EAChBC,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EACvCC,MAAM,EAAE,IAAI;EACZC,KAAK,EAAE,CAAC,OAAO,CAAC;EAChBC,OAAO,EAAErB;AACX,CAAC;AAACsB,OAAA,CAAAZ,WAAA,GAAAA,WAAA;AAEK,IAAMa,qBAA6B,GAAGb,WAAW;AAACY,OAAA,CAAAC,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"file":"draco-loader.js","names":["_version","require","DEFAULT_DRACO_OPTIONS","draco","decoderType","WebAssembly","_typeof2","default","libraryPath","extraAttributes","attributeNameEntry","undefined","DracoLoader","name","id","module","version","VERSION","worker","extensions","mimeTypes","binary","tests","options","exports"],"sources":["../../src/draco-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\nimport type {Loader, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {DracoMesh} from './lib/draco-types';\nimport type {DracoParseOptions} from './lib/draco-parser';\nimport {VERSION} from './lib/utils/version';\n\nexport type DracoLoaderOptions = LoaderOptions & {\n draco?: DracoParseOptions & {\n decoderType?: 'wasm' | 'js';\n libraryPath?: string;\n extraAttributes?;\n attributeNameEntry?: string;\n workerUrl?: string;\n };\n};\n\nconst DEFAULT_DRACO_OPTIONS: DracoLoaderOptions = {\n draco: {\n decoderType: typeof WebAssembly === 'object' ? 'wasm' : 'js', // 'js' for IE11\n libraryPath: 'libs/',\n extraAttributes: {},\n attributeNameEntry: undefined\n }\n};\n\n/**\n * Worker loader for Draco3D compressed geometries\n */\nexport const DracoLoader: Loader<DracoMesh, never, DracoLoaderOptions> = {\n name: 'Draco',\n id: 'draco',\n module: 'draco',\n // shapes: ['mesh'],\n version: VERSION,\n worker: true,\n extensions: ['drc'],\n mimeTypes: ['application/octet-stream'],\n binary: true,\n tests: ['DRACO'],\n options: DEFAULT_DRACO_OPTIONS\n};\n"],"mappings":";;;;;;;;AAIA,IAAAA,QAAA,GAAAC,OAAA;AAYA,IAAMC,qBAAyC,GAAG;EAChDC,KAAK,EAAE;IACLC,WAAW,EAAE,QAAOC,WAAW,qCAAAC,QAAA,CAAAC,OAAA,EAAXF,WAAW,OAAK,QAAQ,GAAG,MAAM,GAAG,IAAI;IAC5DG,WAAW,EAAE,OAAO;IACpBC,eAAe,EAAE,CAAC,CAAC;IACnBC,kBAAkB,EAAEC;EACtB;AACF,CAAC;AAKM,IAAMC,WAAyD,GAAG;EACvEC,IAAI,EAAE,OAAO;EACbC,EAAE,EAAE,OAAO;EACXC,MAAM,EAAE,OAAO;EAEfC,OAAO,EAAEC,gBAAO;EAChBC,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,CAAC,KAAK,CAAC;EACnBC,SAAS,EAAE,CAAC,0BAA0B,CAAC;EACvCC,MAAM,EAAE,IAAI;EACZC,KAAK,EAAE,CAAC,OAAO,CAAC;EAChBC,OAAO,EAAErB;AACX,CAAC;AAACsB,OAAA,CAAAZ,WAAA,GAAAA,WAAA"}
package/dist/es5/index.js CHANGED
@@ -4,6 +4,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ Object.defineProperty(exports, "DRACO_EXTERNAL_LIBRARIES", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _dracoModuleLoader.DRACO_EXTERNAL_LIBRARIES;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "DRACO_EXTERNAL_LIBRARY_URLS", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _dracoModuleLoader.DRACO_EXTERNAL_LIBRARY_URLS;
17
+ }
18
+ });
7
19
  exports.DracoLoader = void 0;
8
20
  Object.defineProperty(exports, "DracoWorkerLoader", {
9
21
  enumerable: true,
@@ -17,7 +29,7 @@ Object.defineProperty(exports, "DracoWriter", {
17
29
  return _dracoWriter.DracoWriter;
18
30
  }
19
31
  });
20
- exports._TypecheckDracoLoader = exports.DracoWriterWorker = void 0;
32
+ exports.DracoWriterWorker = void 0;
21
33
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
22
34
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
23
35
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
@@ -73,6 +85,4 @@ function _parse() {
73
85
  }));
74
86
  return _parse.apply(this, arguments);
75
87
  }
76
- var _TypecheckDracoLoader = DracoLoader;
77
- exports._TypecheckDracoLoader = _TypecheckDracoLoader;
78
88
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_dracoLoader","require","_dracoParser","_interopRequireDefault","_dracoModuleLoader","_version","_dracoWriter","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","DracoWriterWorker","id","name","module","version","VERSION","worker","options","draco","exports","DracoLoader","DracoWorkerLoader","parse","_x","_x2","_parse","_asyncToGenerator2","_regenerator","mark","_callee","arrayBuffer","_yield$loadDracoDecod","dracoParser","wrap","_callee$","_context","prev","next","loadDracoDecoderModule","sent","DracoParser","abrupt","parseSync","destroy","finish","stop","_TypecheckDracoLoader"],"sources":["../../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {DracoMesh, DracoLoaderData} from './lib/draco-types';\nimport type {DracoLoaderOptions} from './draco-loader';\nimport {DracoLoader as DracoWorkerLoader} from './draco-loader';\nimport DracoParser from './lib/draco-parser';\nimport {loadDracoDecoderModule} from './lib/draco-module-loader';\nimport {VERSION} from './lib/utils/version';\n\n// Draco data types\n\nexport type {DracoMesh, DracoLoaderData};\n\n// Draco Writer\n\nexport type {DracoWriterOptions} from './draco-writer';\nexport {DracoWriter} from './draco-writer';\n\n/**\n * Browser worker doesn't work because of issue during \"draco_encoder.js\" loading.\n * Refused to execute script from 'https://raw.githubusercontent.com/google/draco/1.4.1/javascript/draco_encoder.js' because its MIME type ('') is not executable.\n */\nexport const DracoWriterWorker = {\n id: 'draco-writer',\n name: 'Draco compressed geometry writer',\n module: 'draco',\n version: VERSION,\n worker: true,\n options: {\n draco: {},\n source: null\n }\n};\n\n// Draco Loader\n\nexport type {DracoLoaderOptions};\nexport {DracoWorkerLoader};\n\n/**\n * Loader for Draco3D compressed geometries\n */\nexport const DracoLoader: LoaderWithParser<DracoMesh, never, DracoLoaderOptions> = {\n ...DracoWorkerLoader,\n parse\n};\n\nasync function parse(arrayBuffer: ArrayBuffer, options?: DracoLoaderOptions): Promise<DracoMesh> {\n const {draco} = await loadDracoDecoderModule(options);\n const dracoParser = new DracoParser(draco);\n try {\n return dracoParser.parseSync(arrayBuffer, options?.draco);\n } finally {\n dracoParser.destroy();\n }\n}\n\n// TYPE TESTS - TODO find a better way than exporting junk\nexport const _TypecheckDracoLoader: LoaderWithParser = DracoLoader;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AASA,IAAAK,YAAA,GAAAL,OAAA;AAA2C,SAAAM,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA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,OAA4B;IAAA,IAAAc,qBAAA,EAAAb,KAAA,EAAAc,WAAA;IAAA,OAAAL,YAAA,CAAArB,OAAA,CAAA2B,IAAA,UAAAC,SAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UAAAF,QAAA,CAAAE,IAAA;UAAA,OACnD,IAAAC,yCAAsB,EAACrB,OAAO,CAAC;QAAA;UAAAc,qBAAA,GAAAI,QAAA,CAAAI,IAAA;UAA9CrB,KAAK,GAAAa,qBAAA,CAALb,KAAK;UACNc,WAAW,GAAG,IAAIQ,oBAAW,CAACtB,KAAK,CAAC;UAAAiB,QAAA,CAAAC,IAAA;UAAA,OAAAD,QAAA,CAAAM,MAAA,WAEjCT,WAAW,CAACU,SAAS,CAACZ,WAAW,EAAEb,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,KAAK,CAAC;QAAA;UAAAiB,QAAA,CAAAC,IAAA;UAEzDJ,WAAW,CAACW,OAAO,CAAC,CAAC;UAAC,OAAAR,QAAA,CAAAS,MAAA;QAAA;QAAA;UAAA,OAAAT,QAAA,CAAAU,IAAA;MAAA;IAAA,GAAAhB,OAAA;EAAA,CAEzB;EAAA,OAAAJ,MAAA,CAAA7B,KAAA,OAAAI,SAAA;AAAA;AAGM,IAAM8C,qBAAuC,GAAG1B,WAAW;AAACD,OAAA,CAAA2B,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"file":"index.js","names":["_dracoLoader","require","_dracoParser","_interopRequireDefault","_dracoModuleLoader","_version","_dracoWriter","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","DracoWriterWorker","id","name","module","version","VERSION","worker","options","draco","exports","DracoLoader","DracoWorkerLoader","parse","_x","_x2","_parse","_asyncToGenerator2","_regenerator","mark","_callee","arrayBuffer","_yield$loadDracoDecod","dracoParser","wrap","_callee$","_context","prev","next","loadDracoDecoderModule","sent","DracoParser","abrupt","parseSync","destroy","finish","stop"],"sources":["../../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {DracoMesh, DracoLoaderData} from './lib/draco-types';\nimport type {DracoLoaderOptions} from './draco-loader';\nimport {DracoLoader as DracoWorkerLoader} from './draco-loader';\nimport DracoParser from './lib/draco-parser';\nimport {loadDracoDecoderModule} from './lib/draco-module-loader';\nimport {VERSION} from './lib/utils/version';\n\n// Module constants\nexport {DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS} from './lib/draco-module-loader';\n\n// Draco data types\n\nexport type {DracoMesh, DracoLoaderData};\n\n// Draco Writer\n\nexport type {DracoWriterOptions} from './draco-writer';\nexport {DracoWriter} from './draco-writer';\n\n/**\n * Browser worker doesn't work because of issue during \"draco_encoder.js\" loading.\n * Refused to execute script from 'https://raw.githubusercontent.com/google/draco/1.4.1/javascript/draco_encoder.js' because its MIME type ('') is not executable.\n */\nexport const DracoWriterWorker = {\n id: 'draco-writer',\n name: 'Draco compressed geometry writer',\n module: 'draco',\n version: VERSION,\n worker: true,\n options: {\n draco: {},\n source: null\n }\n};\n\n// Draco Loader\n\nexport type {DracoLoaderOptions};\nexport {DracoWorkerLoader};\n\n/**\n * Loader for Draco3D compressed geometries\n */\nexport const DracoLoader: LoaderWithParser<DracoMesh, never, DracoLoaderOptions> = {\n ...DracoWorkerLoader,\n parse\n};\n\nasync function parse(arrayBuffer: ArrayBuffer, options?: DracoLoaderOptions): Promise<DracoMesh> {\n const {draco} = await loadDracoDecoderModule(options);\n const dracoParser = new DracoParser(draco);\n try {\n return dracoParser.parseSync(arrayBuffer, options?.draco);\n } finally {\n dracoParser.destroy();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAAA,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CAAC,CAAC;UAAC,OAAAR,QAAA,CAAAS,MAAA;QAAA;QAAA;UAAA,OAAAT,QAAA,CAAAU,IAAA;MAAA;IAAA,GAAAhB,OAAA;EAAA,CAEzB;EAAA,OAAAJ,MAAA,CAAA7B,KAAA,OAAAI,SAAA;AAAA"}
@@ -4,22 +4,29 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ exports.DRACO_EXTERNAL_LIBRARY_URLS = exports.DRACO_EXTERNAL_LIBRARIES = void 0;
7
8
  exports.loadDracoDecoderModule = loadDracoDecoderModule;
8
9
  exports.loadDracoEncoderModule = loadDracoEncoderModule;
9
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
14
  var _workerUtils = require("@loaders.gl/worker-utils");
15
+ var _DRACO_EXTERNAL_LIBRA;
14
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
- var DRACO_DECODER_VERSION = '1.5.5';
18
+ var DRACO_DECODER_VERSION = '1.5.6';
17
19
  var DRACO_ENCODER_VERSION = '1.4.1';
18
20
  var STATIC_DECODER_URL = "https://www.gstatic.com/draco/versioned/decoders/".concat(DRACO_DECODER_VERSION);
19
- var DRACO_JS_DECODER_URL = "".concat(STATIC_DECODER_URL, "/draco_decoder.js");
20
- var DRACO_WASM_WRAPPER_URL = "".concat(STATIC_DECODER_URL, "/draco_wasm_wrapper.js");
21
- var DRACO_WASM_DECODER_URL = "".concat(STATIC_DECODER_URL, "/draco_decoder.wasm");
22
- var DRACO_ENCODER_URL = "https://raw.githubusercontent.com/google/draco/".concat(DRACO_ENCODER_VERSION, "/javascript/draco_encoder.js");
21
+ var DRACO_EXTERNAL_LIBRARIES = {
22
+ DECODER: 'draco_wasm_wrapper.js',
23
+ DECODER_WASM: 'draco_decoder.wasm',
24
+ FALLBACK_DECODER: 'draco_decoder.js',
25
+ ENCODER: 'draco_encoder.js'
26
+ };
27
+ exports.DRACO_EXTERNAL_LIBRARIES = DRACO_EXTERNAL_LIBRARIES;
28
+ var DRACO_EXTERNAL_LIBRARY_URLS = (_DRACO_EXTERNAL_LIBRA = {}, (0, _defineProperty2.default)(_DRACO_EXTERNAL_LIBRA, DRACO_EXTERNAL_LIBRARIES.DECODER, "".concat(STATIC_DECODER_URL, "/").concat(DRACO_EXTERNAL_LIBRARIES.DECODER)), (0, _defineProperty2.default)(_DRACO_EXTERNAL_LIBRA, DRACO_EXTERNAL_LIBRARIES.DECODER_WASM, "".concat(STATIC_DECODER_URL, "/").concat(DRACO_EXTERNAL_LIBRARIES.DECODER_WASM)), (0, _defineProperty2.default)(_DRACO_EXTERNAL_LIBRA, DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER, "".concat(STATIC_DECODER_URL, "/").concat(DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER)), (0, _defineProperty2.default)(_DRACO_EXTERNAL_LIBRA, DRACO_EXTERNAL_LIBRARIES.ENCODER, "https://raw.githubusercontent.com/google/draco/".concat(DRACO_ENCODER_VERSION, "/javascript/").concat(DRACO_EXTERNAL_LIBRARIES.ENCODER)), _DRACO_EXTERNAL_LIBRA);
29
+ exports.DRACO_EXTERNAL_LIBRARY_URLS = DRACO_EXTERNAL_LIBRARY_URLS;
23
30
  var loadDecoderPromise;
24
31
  var loadEncoderPromise;
25
32
  function loadDracoDecoderModule(_x) {
@@ -98,18 +105,18 @@ function _loadDracoDecoder() {
98
105
  break;
99
106
  case 3:
100
107
  _context3.next = 5;
101
- return (0, _workerUtils.loadLibrary)(DRACO_JS_DECODER_URL, 'draco', options);
108
+ return (0, _workerUtils.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER], 'draco', options, DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER);
102
109
  case 5:
103
110
  DracoDecoderModule = _context3.sent;
104
111
  return _context3.abrupt("break", 21);
105
112
  case 7:
106
113
  _context3.t1 = Promise;
107
114
  _context3.next = 10;
108
- return (0, _workerUtils.loadLibrary)(DRACO_WASM_WRAPPER_URL, 'draco', options);
115
+ return (0, _workerUtils.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER], 'draco', options, DRACO_EXTERNAL_LIBRARIES.DECODER);
109
116
  case 10:
110
117
  _context3.t2 = _context3.sent;
111
118
  _context3.next = 13;
112
- return (0, _workerUtils.loadLibrary)(DRACO_WASM_DECODER_URL, 'draco', options);
119
+ return (0, _workerUtils.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM], 'draco', options, DRACO_EXTERNAL_LIBRARIES.DECODER_WASM);
113
120
  case 13:
114
121
  _context3.t3 = _context3.sent;
115
122
  _context3.t4 = [_context3.t2, _context3.t3];
@@ -159,7 +166,7 @@ function _loadDracoEncoder() {
159
166
  while (1) switch (_context4.prev = _context4.next) {
160
167
  case 0:
161
168
  _context4.next = 2;
162
- return (0, _workerUtils.loadLibrary)(DRACO_ENCODER_URL, 'draco', options);
169
+ return (0, _workerUtils.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.ENCODER], 'draco', options, DRACO_EXTERNAL_LIBRARIES.ENCODER);
163
170
  case 2:
164
171
  DracoEncoderModule = _context4.sent;
165
172
  DracoEncoderModule = DracoEncoderModule || globalThis.DracoEncoderModule;
@@ -1 +1 @@
1
- {"version":3,"file":"draco-module-loader.js","names":["_workerUtils","require","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","DRACO_DECODER_VERSION","DRACO_ENCODER_VERSION","STATIC_DECODER_URL","concat","DRACO_JS_DECODER_URL","DRACO_WASM_WRAPPER_URL","DRACO_WASM_DECODER_URL","DRACO_ENCODER_URL","loadDecoderPromise","loadEncoderPromise","loadDracoDecoderModule","_x","_loadDracoDecoderModule","_asyncToGenerator2","_regenerator","mark","_callee","options","modules","wrap","_callee$","_context","prev","next","draco3d","createDecoderModule","then","draco","loadDracoDecoder","abrupt","sent","stop","loadDracoEncoderModule","_x2","_loadDracoEncoderModule","_callee2","_callee2$","_context2","createEncoderModule","loadDracoEncoder","_x3","_loadDracoDecoder","_callee3","DracoDecoderModule","wasmBinary","_yield$Promise$all","_yield$Promise$all2","_callee3$","_context3","t0","decoderType","loadLibrary","t1","Promise","t2","t3","t4","all","call","_slicedToArray2","globalThis","initializeDracoDecoder","resolve","onModuleLoaded","_x4","_loadDracoEncoder","_callee4","DracoEncoderModule","_callee4$","_context4"],"sources":["../../../src/lib/draco-module-loader.ts"],"sourcesContent":["// Dynamic DRACO module loading inspired by THREE.DRACOLoader\n// https://github.com/mrdoob/three.js/blob/398c4f39ebdb8b23eefd4a7a5ec49ec0c96c7462/examples/jsm/loaders/DRACOLoader.js\n// by Don McCurdy / https://www.donmccurdy.com / MIT license\n\nimport {loadLibrary} from '@loaders.gl/worker-utils';\n\nconst DRACO_DECODER_VERSION = '1.5.5';\nconst DRACO_ENCODER_VERSION = '1.4.1';\n\nconst STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;\n\nconst DRACO_JS_DECODER_URL = `${STATIC_DECODER_URL}/draco_decoder.js`;\nconst DRACO_WASM_WRAPPER_URL = `${STATIC_DECODER_URL}/draco_wasm_wrapper.js`;\nconst DRACO_WASM_DECODER_URL = `${STATIC_DECODER_URL}/draco_decoder.wasm`;\n\nconst DRACO_ENCODER_URL = `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/draco_encoder.js`;\n\nlet loadDecoderPromise;\nlet loadEncoderPromise;\n\nexport async function loadDracoDecoderModule(options) {\n const modules = options.modules || {};\n\n // Check if a bundled draco3d library has been supplied by application\n if (modules.draco3d) {\n loadDecoderPromise =\n loadDecoderPromise ||\n modules.draco3d.createDecoderModule({}).then((draco) => {\n return {draco};\n });\n } else {\n // If not, dynamically load the WASM script from our CDN\n loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);\n }\n return await loadDecoderPromise;\n}\n\nexport async function loadDracoEncoderModule(options) {\n const modules = options.modules || {};\n\n // Check if a bundled draco3d library has been supplied by application\n if (modules.draco3d) {\n loadEncoderPromise =\n loadEncoderPromise ||\n modules.draco3d.createEncoderModule({}).then((draco) => {\n return {draco};\n });\n } else {\n // If not, dynamically load the WASM script from our CDN\n loadEncoderPromise = loadEncoderPromise || loadDracoEncoder(options);\n }\n return await loadEncoderPromise;\n}\n\n// DRACO DECODER LOADING\n\nasync function loadDracoDecoder(options) {\n let DracoDecoderModule;\n let wasmBinary;\n switch (options.draco && options.draco.decoderType) {\n case 'js':\n DracoDecoderModule = await loadLibrary(DRACO_JS_DECODER_URL, 'draco', options);\n break;\n\n case 'wasm':\n default:\n [DracoDecoderModule, wasmBinary] = await Promise.all([\n await loadLibrary(DRACO_WASM_WRAPPER_URL, 'draco', options),\n await loadLibrary(DRACO_WASM_DECODER_URL, 'draco', options)\n ]);\n }\n // Depends on how import happened...\n // @ts-ignore\n DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;\n return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);\n}\n\nfunction initializeDracoDecoder(DracoDecoderModule, wasmBinary) {\n const options: {wasmBinary?: any} = {};\n if (wasmBinary) {\n options.wasmBinary = wasmBinary;\n }\n\n return new Promise((resolve) => {\n DracoDecoderModule({\n ...options,\n onModuleLoaded: (draco) => resolve({draco}) // Module is Promise-like. Wrap in object to avoid loop.\n });\n });\n}\n\n// ENCODER\n\nasync function loadDracoEncoder(options) {\n let DracoEncoderModule = await loadLibrary(DRACO_ENCODER_URL, 'draco', options);\n // @ts-ignore\n DracoEncoderModule = DracoEncoderModule || globalThis.DracoEncoderModule;\n\n return new Promise((resolve) => {\n DracoEncoderModule({\n onModuleLoaded: (draco) => resolve({draco}) // Module is Promise-like. Wrap in object to avoid loop.\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;AAIA,IAAAA,YAAA,GAAAC,OAAA;AAAqD,SAAAC,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,C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,EAAE,SAAAA,eAACpC,KAAK;gBAAA,OAAKmC,OAAO,CAAC;kBAACnC,KAAK,EAALA;gBAAK,CAAC,CAAC;cAAA;YAC7C,CAAC,CAAC;UACJ,CAAC,CAAC;QAAA;QAAA;UAAA,OAAA0C,SAAA,CAAAtC,IAAA;MAAA;IAAA,GAAAmC,QAAA;EAAA,CACH;EAAA,OAAAD,iBAAA,CAAA/E,KAAA,OAAAI,SAAA;AAAA"}
1
+ {"version":3,"file":"draco-module-loader.js","names":["_workerUtils","require","_DRACO_EXTERNAL_LIBRA","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","DRACO_DECODER_VERSION","DRACO_ENCODER_VERSION","STATIC_DECODER_URL","concat","DRACO_EXTERNAL_LIBRARIES","DECODER","DECODER_WASM","FALLBACK_DECODER","ENCODER","exports","DRACO_EXTERNAL_LIBRARY_URLS","loadDecoderPromise","loadEncoderPromise","loadDracoDecoderModule","_x","_loadDracoDecoderModule","_asyncToGenerator2","_regenerator","mark","_callee","options","modules","wrap","_callee$","_context","prev","next","draco3d","createDecoderModule","then","draco","loadDracoDecoder","abrupt","sent","stop","loadDracoEncoderModule","_x2","_loadDracoEncoderModule","_callee2","_callee2$","_context2","createEncoderModule","loadDracoEncoder","_x3","_loadDracoDecoder","_callee3","DracoDecoderModule","wasmBinary","_yield$Promise$all","_yield$Promise$all2","_callee3$","_context3","t0","decoderType","loadLibrary","t1","Promise","t2","t3","t4","all","call","_slicedToArray2","globalThis","initializeDracoDecoder","resolve","onModuleLoaded","_x4","_loadDracoEncoder","_callee4","DracoEncoderModule","_callee4$","_context4"],"sources":["../../../src/lib/draco-module-loader.ts"],"sourcesContent":["// Dynamic DRACO module loading inspired by THREE.DRACOLoader\n// https://github.com/mrdoob/three.js/blob/398c4f39ebdb8b23eefd4a7a5ec49ec0c96c7462/examples/jsm/loaders/DRACOLoader.js\n// by Don McCurdy / https://www.donmccurdy.com / MIT license\n\nimport {loadLibrary} from '@loaders.gl/worker-utils';\n\nconst DRACO_DECODER_VERSION = '1.5.6';\nconst DRACO_ENCODER_VERSION = '1.4.1';\n\nconst STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;\n\nexport const DRACO_EXTERNAL_LIBRARIES = {\n /** The primary Draco3D encoder, javascript wrapper part */\n DECODER: 'draco_wasm_wrapper.js',\n /** The primary draco decoder, compiled web assembly part */\n DECODER_WASM: 'draco_decoder.wasm',\n /** Fallback decoder for non-webassebly environments. Very big bundle, lower performance */\n FALLBACK_DECODER: 'draco_decoder.js',\n /** Draco encoder */\n ENCODER: 'draco_encoder.js'\n};\n\nexport const DRACO_EXTERNAL_LIBRARY_URLS = {\n [DRACO_EXTERNAL_LIBRARIES.DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER}`,\n [DRACO_EXTERNAL_LIBRARIES.DECODER_WASM]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER_WASM}`,\n [DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER}`,\n [DRACO_EXTERNAL_LIBRARIES.ENCODER]: `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/${DRACO_EXTERNAL_LIBRARIES.ENCODER}`\n};\n\nlet loadDecoderPromise;\nlet loadEncoderPromise;\n\nexport async function loadDracoDecoderModule(options) {\n const modules = options.modules || {};\n\n // Check if a bundled draco3d library has been supplied by application\n if (modules.draco3d) {\n loadDecoderPromise =\n loadDecoderPromise ||\n modules.draco3d.createDecoderModule({}).then((draco) => {\n return {draco};\n });\n } else {\n // If not, dynamically load the WASM script from our CDN\n loadDecoderPromise = loadDecoderPromise || loadDracoDecoder(options);\n }\n return await loadDecoderPromise;\n}\n\nexport async function loadDracoEncoderModule(options) {\n const modules = options.modules || {};\n\n // Check if a bundled draco3d library has been supplied by application\n if (modules.draco3d) {\n loadEncoderPromise =\n loadEncoderPromise ||\n modules.draco3d.createEncoderModule({}).then((draco) => {\n return {draco};\n });\n } else {\n // If not, dynamically load the WASM script from our CDN\n loadEncoderPromise = loadEncoderPromise || loadDracoEncoder(options);\n }\n return await loadEncoderPromise;\n}\n\n// DRACO DECODER LOADING\n\nasync function loadDracoDecoder(options) {\n let DracoDecoderModule;\n let wasmBinary;\n switch (options.draco && options.draco.decoderType) {\n case 'js':\n DracoDecoderModule = await loadLibrary(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER],\n 'draco',\n options,\n DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER\n );\n break;\n\n case 'wasm':\n default:\n [DracoDecoderModule, wasmBinary] = await Promise.all([\n await loadLibrary(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],\n 'draco',\n options,\n DRACO_EXTERNAL_LIBRARIES.DECODER\n ),\n await loadLibrary(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],\n 'draco',\n options,\n DRACO_EXTERNAL_LIBRARIES.DECODER_WASM\n )\n ]);\n }\n // Depends on how import happened...\n // @ts-ignore\n DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;\n return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);\n}\n\nfunction initializeDracoDecoder(DracoDecoderModule, wasmBinary) {\n const options: {wasmBinary?: any} = {};\n if (wasmBinary) {\n options.wasmBinary = wasmBinary;\n }\n\n return new Promise((resolve) => {\n DracoDecoderModule({\n ...options,\n onModuleLoaded: (draco) => resolve({draco}) // Module is Promise-like. Wrap in object to avoid loop.\n });\n });\n}\n\n// ENCODER\n\nasync function loadDracoEncoder(options) {\n let DracoEncoderModule = await loadLibrary(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.ENCODER],\n 'draco',\n options,\n DRACO_EXTERNAL_LIBRARIES.ENCODER\n );\n // @ts-ignore\n DracoEncoderModule = DracoEncoderModule || globalThis.DracoEncoderModule;\n\n return new Promise((resolve) => {\n DracoEncoderModule({\n onModuleLoaded: (draco) => resolve({draco}) // Module is Promise-like. Wrap in object to avoid loop.\n });\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAIA,IAAAA,YAAA,GAAAC,OAAA;AAAqD,IAAAC,qBAAA;AAAA,SAAAC,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,CAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAmB,yBAAA,GAAAnB,MAAA,CAAAoB,gBAAA,CAAAV,MAAA,EAAAV,MAAA,CAAAmB,yBAAA,CAAAL,MAAA,KAAAlB,OAAA,CAAAI,MA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IAAA,GAAA+C,SAAA,CAAA9C,IAAA;QAAA;UAAA8C,SAAA,CAAA9C,IAAA;UAAA,OACN,IAAA4B,wBAAW,EACxC5C,2BAA2B,CAACN,wBAAwB,CAACI,OAAO,CAAC,EAC7D,OAAO,EACPY,OAAO,EACPhB,wBAAwB,CAACI,OAC3B,CAAC;QAAA;UALG8D,kBAAkB,GAAAE,SAAA,CAAAvC,IAAA;UAOtBqC,kBAAkB,GAAGA,kBAAkB,IAAIP,UAAU,CAACO,kBAAkB;UAAC,OAAAE,SAAA,CAAAxC,MAAA,WAElE,IAAIwB,OAAO,CAAC,UAACS,OAAO,EAAK;YAC9BK,kBAAkB,CAAC;cACjBJ,cAAc,EAAE,SAAAA,eAACpC,KAAK;gBAAA,OAAKmC,OAAO,CAAC;kBAACnC,KAAK,EAALA;gBAAK,CAAC,CAAC;cAAA;YAC7C,CAAC,CAAC;UACJ,CAAC,CAAC;QAAA;QAAA;UAAA,OAAA0C,SAAA,CAAAtC,IAAA;MAAA;IAAA,GAAAmC,QAAA;EAAA,CACH;EAAA,OAAAD,iBAAA,CAAAlF,KAAA,OAAAI,SAAA;AAAA"}
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VERSION = void 0;
7
- var VERSION = typeof "4.0.0-alpha.9" !== 'undefined' ? "4.0.0-alpha.9" : 'latest';
7
+ var VERSION = typeof "4.0.0-beta.1" !== 'undefined' ? "4.0.0-beta.1" : 'latest';
8
8
  exports.VERSION = VERSION;
9
9
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":["VERSION","exports"],"sources":["../../../../src/lib/utils/version.ts"],"sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n"],"mappings":";;;;;;AAGO,IAAMA,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAACC,OAAA,CAAAD,OAAA,GAAAA,OAAA"}
1
+ {"version":3,"file":"version.js","names":["VERSION","exports"],"sources":["../../../../src/lib/utils/version.ts"],"sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n"],"mappings":";;;;;;AAGO,IAAMA,OAAO,GAAG,qBAAkB,KAAK,WAAW,oBAAiB,QAAQ;AAACC,OAAA,CAAAD,OAAA,GAAAA,OAAA"}
Binary file