@loaders.gl/draco 4.0.0-alpha.5 → 4.0.0-alpha.6
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.
- package/dist/bundle.js +2 -2
- package/dist/dist.min.js +3 -3
- package/dist/dist.min.js.map +3 -3
- package/dist/draco-loader.d.ts +4 -14
- package/dist/draco-loader.d.ts.map +1 -1
- package/dist/draco-loader.js +28 -21
- package/dist/draco-nodejs-worker.js +191 -0
- package/dist/draco-nodejs-worker.js.map +7 -0
- package/dist/draco-worker.js +1 -1
- package/dist/draco-worker.js.map +3 -3
- package/dist/draco-writer-nodejs-worker.js +193 -0
- package/dist/draco-writer-nodejs-worker.js.map +7 -0
- package/dist/draco-writer-nodejs.d.ts +3 -0
- package/dist/draco-writer-nodejs.d.ts.map +1 -0
- package/dist/draco-writer-nodejs.js +7 -0
- package/dist/draco-writer-worker.js +4 -0
- package/dist/draco-writer-worker.js.map +7 -0
- package/dist/draco-writer.d.ts +12 -3
- package/dist/draco-writer.d.ts.map +1 -1
- package/dist/draco-writer.js +40 -28
- package/dist/draco3d/draco3d-types.d.ts +1 -1
- package/dist/draco3d/draco3d-types.d.ts.map +1 -1
- package/dist/draco3d/draco3d-types.js +47 -44
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/draco-loader.js +34 -0
- package/dist/es5/draco-loader.js.map +1 -0
- package/dist/es5/draco-writer-nodejs.js +14 -0
- package/dist/es5/draco-writer-nodejs.js.map +1 -0
- package/dist/es5/draco-writer.js +63 -0
- package/dist/es5/draco-writer.js.map +1 -0
- package/dist/es5/draco3d/draco3d-types.js +51 -0
- package/dist/es5/draco3d/draco3d-types.js.map +1 -0
- package/dist/es5/index.js +79 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/draco-builder.js +324 -0
- package/dist/es5/lib/draco-builder.js.map +1 -0
- package/dist/es5/lib/draco-module-loader.js +183 -0
- package/dist/es5/lib/draco-module-loader.js.map +1 -0
- package/dist/es5/lib/draco-parser.js +435 -0
- package/dist/es5/lib/draco-parser.js.map +1 -0
- package/dist/es5/lib/draco-types.js +2 -0
- package/dist/es5/lib/draco-types.js.map +1 -0
- package/dist/es5/lib/utils/get-draco-schema.js +47 -0
- package/dist/es5/lib/utils/get-draco-schema.js.map +1 -0
- package/dist/es5/lib/utils/version.js +9 -0
- package/dist/es5/lib/utils/version.js.map +1 -0
- package/dist/es5/workers/draco-nodejs-worker.js +7 -0
- package/dist/es5/workers/draco-nodejs-worker.js.map +1 -0
- package/dist/es5/workers/draco-worker.js +6 -0
- package/dist/es5/workers/draco-worker.js.map +1 -0
- package/dist/es5/workers/draco-writer-nodejs-worker.js +53 -0
- package/dist/es5/workers/draco-writer-nodejs-worker.js.map +1 -0
- package/dist/es5/workers/draco-writer-worker.js +53 -0
- package/dist/es5/workers/draco-writer-worker.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/draco-loader.js +24 -0
- package/dist/esm/draco-loader.js.map +1 -0
- package/dist/esm/draco-writer-nodejs.js +3 -0
- package/dist/esm/draco-writer-nodejs.js.map +1 -0
- package/dist/esm/draco-writer.js +31 -0
- package/dist/esm/draco-writer.js.map +1 -0
- package/dist/esm/draco3d/draco3d-types.js +41 -0
- package/dist/esm/draco3d/draco3d-types.js.map +1 -0
- package/dist/esm/index.js +35 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/draco-builder.js +268 -0
- package/dist/esm/lib/draco-builder.js.map +1 -0
- package/dist/esm/lib/draco-module-loader.js +76 -0
- package/dist/esm/lib/draco-module-loader.js.map +1 -0
- package/dist/esm/lib/draco-parser.js +363 -0
- package/dist/esm/lib/draco-parser.js.map +1 -0
- package/dist/esm/lib/draco-types.js +2 -0
- package/dist/esm/lib/draco-types.js.map +1 -0
- package/dist/esm/lib/utils/get-draco-schema.js +41 -0
- package/dist/esm/lib/utils/get-draco-schema.js.map +1 -0
- package/dist/esm/lib/utils/version.js +2 -0
- package/dist/esm/lib/utils/version.js.map +1 -0
- package/dist/esm/workers/draco-nodejs-worker.js +5 -0
- package/dist/esm/workers/draco-nodejs-worker.js.map +1 -0
- package/dist/esm/workers/draco-worker.js +4 -0
- package/dist/esm/workers/draco-worker.js.map +1 -0
- package/dist/esm/workers/draco-writer-nodejs-worker.js +30 -0
- package/dist/esm/workers/draco-writer-nodejs-worker.js.map +1 -0
- package/dist/esm/workers/draco-writer-worker.js +30 -0
- package/dist/esm/workers/draco-writer-worker.js.map +1 -0
- package/dist/index.d.ts +14 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -21
- package/dist/lib/draco-builder.d.ts +1 -1
- package/dist/lib/draco-builder.d.ts.map +1 -1
- package/dist/lib/draco-builder.js +313 -329
- package/dist/lib/draco-module-loader.d.ts.map +1 -1
- package/dist/lib/draco-module-loader.js +81 -73
- package/dist/lib/draco-parser.d.ts +1 -1
- package/dist/lib/draco-parser.d.ts.map +1 -1
- package/dist/lib/draco-parser.js +440 -416
- package/dist/lib/draco-types.d.ts +6 -6
- package/dist/lib/draco-types.d.ts.map +1 -1
- package/dist/lib/draco-types.js +3 -2
- package/dist/lib/utils/get-draco-schema.js +35 -41
- package/dist/lib/utils/version.js +7 -2
- package/dist/workers/draco-nodejs-worker.d.ts +2 -0
- package/dist/workers/draco-nodejs-worker.d.ts.map +1 -0
- package/dist/workers/draco-nodejs-worker.js +6 -0
- package/dist/workers/draco-worker.js +5 -4
- package/dist/workers/draco-writer-nodejs-worker.d.ts +2 -0
- package/dist/workers/draco-writer-nodejs-worker.d.ts.map +1 -0
- package/dist/workers/draco-writer-nodejs-worker.js +26 -0
- package/dist/workers/draco-writer-worker.d.ts +2 -0
- package/dist/workers/draco-writer-worker.d.ts.map +1 -0
- package/dist/workers/draco-writer-worker.js +26 -0
- package/package.json +16 -9
- package/src/draco-loader.ts +8 -4
- package/src/draco-writer-nodejs.ts +4 -0
- package/src/draco-writer.ts +17 -12
- package/src/index.ts +21 -1
- package/src/lib/draco-module-loader.ts +9 -5
- package/src/lib/utils/get-draco-schema.ts +7 -6
- package/src/workers/draco-nodejs-worker.ts +5 -0
- package/src/workers/draco-writer-nodejs-worker.ts +25 -0
- package/src/workers/draco-writer-worker.ts +25 -0
- package/dist/bundle.js.map +0 -1
- package/dist/draco-loader.js.map +0 -1
- package/dist/draco-writer.js.map +0 -1
- package/dist/draco3d/draco3d-types.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/draco-builder.js.map +0 -1
- package/dist/lib/draco-module-loader.js.map +0 -1
- package/dist/lib/draco-parser.js.map +0 -1
- package/dist/lib/draco-types.js.map +0 -1
- package/dist/lib/utils/get-draco-schema.js.map +0 -1
- package/dist/lib/utils/version.js.map +0 -1
- package/dist/workers/draco-worker.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draco-writer-nodejs.d.ts","sourceRoot":"","sources":["../src/draco-writer-nodejs.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAC,WAAW,IAAI,iBAAiB,EAAC,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DracoWriterNodeJS = void 0;
|
|
4
|
+
// Polyfills increases the bundle size significantly. Use it for NodeJS worker only
|
|
5
|
+
require("@loaders.gl/polyfills");
|
|
6
|
+
var draco_writer_1 = require("./draco-writer");
|
|
7
|
+
Object.defineProperty(exports, "DracoWriterNodeJS", { enumerable: true, get: function () { return draco_writer_1.DracoWriter; } });
|
|
@@ -0,0 +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.6";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.6";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:}})})();})();
|
|
4
|
+
//# sourceMappingURL=draco-writer-worker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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,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zB,EAAP,CACA,GAAM,GAAU,YAAiB,OAAQ,EAAM,QAAU,GACzD,EAAW,YAAY,QAAS,CAAC,MAAO,IAE1C",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/draco-writer.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import type { Writer } from '@loaders.gl/loader-utils';
|
|
1
|
+
import type { Writer, WriterOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
import type { DracoMesh } from './lib/draco-types';
|
|
2
3
|
import type { DracoBuildOptions } from './lib/draco-builder';
|
|
3
|
-
|
|
4
|
+
/** Writer Options for draco */
|
|
5
|
+
export type DracoWriterOptions = WriterOptions & {
|
|
6
|
+
draco?: DracoBuildOptions & {
|
|
7
|
+
method?: 'MESH_EDGEBREAKER_ENCODING' | 'MESH_SEQUENTIAL_ENCODING';
|
|
8
|
+
speed?: [number, number];
|
|
9
|
+
quantization?: Record<string, number>;
|
|
10
|
+
attributeNameEntry?: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
4
13
|
/**
|
|
5
14
|
* Exporter for Draco3D compressed geometries
|
|
6
15
|
*/
|
|
7
|
-
export declare const DracoWriter: Writer
|
|
16
|
+
export declare const DracoWriter: Writer<DracoMesh, unknown, DracoWriterOptions>;
|
|
8
17
|
//# sourceMappingURL=draco-writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draco-writer.d.ts","sourceRoot":"","sources":["../src/draco-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"draco-writer.d.ts","sourceRoot":"","sources":["../src/draco-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAK3D,+BAA+B;AAC/B,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,KAAK,CAAC,EAAE,iBAAiB,GAAG;QAC1B,MAAM,CAAC,EAAE,2BAA2B,GAAG,0BAA0B,CAAC;QAClE,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH,CAAC;AAaF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,kBAAkB,CAUtE,CAAC"}
|
package/dist/draco-writer.js
CHANGED
|
@@ -1,32 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const DEFAULT_DRACO_OPTIONS = {
|
|
5
|
-
pointcloud: false,
|
|
6
|
-
attributeNameEntry: 'name'
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
4
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DracoWriter = void 0;
|
|
7
|
+
const draco_builder_1 = __importDefault(require("./lib/draco-builder"));
|
|
8
|
+
const draco_module_loader_1 = require("./lib/draco-module-loader");
|
|
9
|
+
const version_1 = require("./lib/utils/version");
|
|
10
|
+
const DEFAULT_DRACO_WRITER_OPTIONS = {
|
|
11
|
+
pointcloud: false,
|
|
12
|
+
attributeNameEntry: 'name'
|
|
13
|
+
// Draco Compression Parameters
|
|
14
|
+
// method: 'MESH_EDGEBREAKER_ENCODING', // Use draco defaults
|
|
15
|
+
// speed: [5, 5], // Use draco defaults
|
|
16
|
+
// quantization: { // Use draco defaults
|
|
17
|
+
// POSITION: 10
|
|
18
|
+
// }
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Exporter for Draco3D compressed geometries
|
|
22
|
+
*/
|
|
23
|
+
exports.DracoWriter = {
|
|
24
|
+
name: 'DRACO',
|
|
25
|
+
id: 'draco',
|
|
26
|
+
module: 'draco',
|
|
27
|
+
version: version_1.VERSION,
|
|
28
|
+
extensions: ['drc'],
|
|
29
|
+
encode,
|
|
30
|
+
options: {
|
|
31
|
+
draco: DEFAULT_DRACO_WRITER_OPTIONS
|
|
32
|
+
}
|
|
18
33
|
};
|
|
19
|
-
|
|
20
34
|
async function encode(data, options = {}) {
|
|
21
|
-
|
|
22
|
-
draco
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
35
|
+
// Dynamically load draco
|
|
36
|
+
const { draco } = await (0, draco_module_loader_1.loadDracoEncoderModule)(options);
|
|
37
|
+
const dracoBuilder = new draco_builder_1.default(draco);
|
|
38
|
+
try {
|
|
39
|
+
return dracoBuilder.encodeSync(data, options.draco);
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
dracoBuilder.destroy();
|
|
43
|
+
}
|
|
31
44
|
}
|
|
32
|
-
//# sourceMappingURL=draco-writer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draco3d-types.d.ts","sourceRoot":"","sources":["../../src/draco3d/draco3d-types.ts"],"names":[],"mappings":"AAWA,qCAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"draco3d-types.d.ts","sourceRoot":"","sources":["../../src/draco3d/draco3d-types.ts"],"names":[],"mappings":"AAWA,qCAAqC;AACrC,KAAK,OAAO,GAAG,GAAG,CAAC;AAInB,sCAAsC;AACtC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,48 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// A set of typescript types manually adapted from the Draco web IDL
|
|
3
|
+
// Draco JS is a bit tricky to work with due to the C++ emscripten code base
|
|
4
|
+
// sparse documentation, so these types provide an extra safety net.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.draco_StatusCode = exports.draco_DataType = exports.draco_EncodedGeometryType = exports.draco_GeometryAttribute_Type = void 0;
|
|
7
|
+
// DRACO WEB DECODER IDL
|
|
8
|
+
/** Draco3D geometry attribute type */
|
|
9
|
+
var draco_GeometryAttribute_Type;
|
|
3
10
|
(function (draco_GeometryAttribute_Type) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
})(draco_GeometryAttribute_Type || (draco_GeometryAttribute_Type = {}));
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::INVALID"] = 0] = "draco_GeometryAttribute::INVALID";
|
|
12
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::POSITION"] = 1] = "draco_GeometryAttribute::POSITION";
|
|
13
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::NORMAL"] = 2] = "draco_GeometryAttribute::NORMAL";
|
|
14
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::COLOR"] = 3] = "draco_GeometryAttribute::COLOR";
|
|
15
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::TEX_COORD"] = 4] = "draco_GeometryAttribute::TEX_COORD";
|
|
16
|
+
draco_GeometryAttribute_Type[draco_GeometryAttribute_Type["draco_GeometryAttribute::GENERIC"] = 5] = "draco_GeometryAttribute::GENERIC";
|
|
17
|
+
})(draco_GeometryAttribute_Type = exports.draco_GeometryAttribute_Type || (exports.draco_GeometryAttribute_Type = {}));
|
|
18
|
+
/** Draco3D encoded geometry type */
|
|
19
|
+
var draco_EncodedGeometryType;
|
|
14
20
|
(function (draco_EncodedGeometryType) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})(draco_EncodedGeometryType || (draco_EncodedGeometryType = {}));
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
draco_EncodedGeometryType[draco_EncodedGeometryType["draco::INVALID_GEOMETRY_TYPE"] = 0] = "draco::INVALID_GEOMETRY_TYPE";
|
|
22
|
+
draco_EncodedGeometryType[draco_EncodedGeometryType["draco::POINT_CLOUD"] = 1] = "draco::POINT_CLOUD";
|
|
23
|
+
draco_EncodedGeometryType[draco_EncodedGeometryType["draco::TRIANGULAR_MESH"] = 2] = "draco::TRIANGULAR_MESH";
|
|
24
|
+
})(draco_EncodedGeometryType = exports.draco_EncodedGeometryType || (exports.draco_EncodedGeometryType = {}));
|
|
25
|
+
/** Draco3D data type */
|
|
26
|
+
var draco_DataType;
|
|
22
27
|
(function (draco_DataType) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})(draco_DataType || (draco_DataType = {}));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
draco_DataType[draco_DataType["draco::DT_INVALID"] = 0] = "draco::DT_INVALID";
|
|
29
|
+
draco_DataType[draco_DataType["draco::DT_INT8"] = 1] = "draco::DT_INT8";
|
|
30
|
+
draco_DataType[draco_DataType["draco::DT_UINT8"] = 2] = "draco::DT_UINT8";
|
|
31
|
+
draco_DataType[draco_DataType["draco::DT_INT16"] = 3] = "draco::DT_INT16";
|
|
32
|
+
draco_DataType[draco_DataType["draco::DT_UINT16"] = 4] = "draco::DT_UINT16";
|
|
33
|
+
draco_DataType[draco_DataType["draco::DT_INT32"] = 5] = "draco::DT_INT32";
|
|
34
|
+
draco_DataType[draco_DataType["draco::DT_UINT32"] = 6] = "draco::DT_UINT32";
|
|
35
|
+
draco_DataType[draco_DataType["draco::DT_INT64"] = 7] = "draco::DT_INT64";
|
|
36
|
+
draco_DataType[draco_DataType["draco::DT_UINT64"] = 8] = "draco::DT_UINT64";
|
|
37
|
+
draco_DataType[draco_DataType["draco::DT_FLOAT32"] = 9] = "draco::DT_FLOAT32";
|
|
38
|
+
draco_DataType[draco_DataType["draco::DT_FLOAT64"] = 10] = "draco::DT_FLOAT64";
|
|
39
|
+
draco_DataType[draco_DataType["draco::DT_BOOL"] = 11] = "draco::DT_BOOL";
|
|
40
|
+
draco_DataType[draco_DataType["draco::DT_TYPES_COUNT"] = 12] = "draco::DT_TYPES_COUNT";
|
|
41
|
+
})(draco_DataType = exports.draco_DataType || (exports.draco_DataType = {}));
|
|
42
|
+
/** Draco3D status code */
|
|
43
|
+
var draco_StatusCode;
|
|
40
44
|
(function (draco_StatusCode) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
})(draco_StatusCode || (draco_StatusCode = {}));
|
|
48
|
-
//# sourceMappingURL=draco3d-types.js.map
|
|
45
|
+
draco_StatusCode[draco_StatusCode["draco_Status::OK"] = 0] = "draco_Status::OK";
|
|
46
|
+
draco_StatusCode[draco_StatusCode["draco_Status::DRACO_ERROR"] = 1] = "draco_Status::DRACO_ERROR";
|
|
47
|
+
draco_StatusCode[draco_StatusCode["draco_Status::IO_ERROR"] = 2] = "draco_Status::IO_ERROR";
|
|
48
|
+
draco_StatusCode[draco_StatusCode["draco_Status::INVALID_PARAMETER"] = 3] = "draco_Status::INVALID_PARAMETER";
|
|
49
|
+
draco_StatusCode[draco_StatusCode["draco_Status::UNSUPPORTED_VERSION"] = 4] = "draco_Status::UNSUPPORTED_VERSION";
|
|
50
|
+
draco_StatusCode[draco_StatusCode["draco_Status::UNKNOWN_VERSION"] = 5] = "draco_Status::UNKNOWN_VERSION";
|
|
51
|
+
})(draco_StatusCode = exports.draco_StatusCode || (exports.draco_StatusCode = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"sources":["../../src/bundle.ts"],"sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAS,CAAC;AACxCC,UAAU,CAACC,OAAO,GAAGD,UAAU,CAACC,OAAO,IAAI,CAAC,CAAC;AAC7CC,MAAM,CAACC,OAAO,GAAGC,MAAM,CAACC,MAAM,CAACL,UAAU,CAACC,OAAO,EAAEH,aAAa,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports._TypecheckDracoLoader = exports.DracoLoader = void 0;
|
|
8
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
+
var _workerUtils = require("@loaders.gl/worker-utils");
|
|
10
|
+
var _version = require("./lib/utils/version");
|
|
11
|
+
var DEFAULT_DRACO_OPTIONS = {
|
|
12
|
+
draco: {
|
|
13
|
+
decoderType: (typeof WebAssembly === "undefined" ? "undefined" : (0, _typeof2.default)(WebAssembly)) === 'object' ? 'wasm' : 'js',
|
|
14
|
+
libraryPath: 'libs/',
|
|
15
|
+
extraAttributes: {},
|
|
16
|
+
attributeNameEntry: undefined
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var DracoLoader = {
|
|
20
|
+
name: 'Draco',
|
|
21
|
+
id: _workerUtils.isBrowser ? 'draco' : 'draco-nodejs',
|
|
22
|
+
module: 'draco',
|
|
23
|
+
version: _version.VERSION,
|
|
24
|
+
worker: true,
|
|
25
|
+
extensions: ['drc'],
|
|
26
|
+
mimeTypes: ['application/octet-stream'],
|
|
27
|
+
binary: true,
|
|
28
|
+
tests: ['DRACO'],
|
|
29
|
+
options: DEFAULT_DRACO_OPTIONS
|
|
30
|
+
};
|
|
31
|
+
exports.DracoLoader = DracoLoader;
|
|
32
|
+
var _TypecheckDracoLoader = DracoLoader;
|
|
33
|
+
exports._TypecheckDracoLoader = _TypecheckDracoLoader;
|
|
34
|
+
//# sourceMappingURL=draco-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draco-loader.js","names":["_workerUtils","require","_version","DEFAULT_DRACO_OPTIONS","draco","decoderType","WebAssembly","_typeof2","default","libraryPath","extraAttributes","attributeNameEntry","undefined","DracoLoader","name","id","isBrowser","module","version","VERSION","worker","extensions","mimeTypes","binary","tests","options","exports","_TypecheckDracoLoader"],"sources":["../../src/draco-loader.ts"],"sourcesContent":["//\n\nimport {isBrowser} from '@loaders.gl/worker-utils';\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: isBrowser ? 'draco' : 'draco-nodejs',\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":";;;;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AAYA,IAAME,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,EAAEC,sBAAS,GAAG,OAAO,GAAG,cAAc;EACxCC,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,EAAEtB;AACX,CAAC;AAACuB,OAAA,CAAAb,WAAA,GAAAA,WAAA;AAEK,IAAMc,qBAA6B,GAAGd,WAAW;AAACa,OAAA,CAAAC,qBAAA,GAAAA,qBAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "DracoWriterNodeJS", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _dracoWriter.DracoWriter;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
require("@loaders.gl/polyfills");
|
|
13
|
+
var _dracoWriter = require("./draco-writer");
|
|
14
|
+
//# sourceMappingURL=draco-writer-nodejs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draco-writer-nodejs.js","names":["require","_dracoWriter"],"sources":["../../src/draco-writer-nodejs.ts"],"sourcesContent":["// Polyfills increases the bundle size significantly. Use it for NodeJS worker only\nimport '@loaders.gl/polyfills';\n\nexport {DracoWriter as DracoWriterNodeJS} from './draco-writer';\n"],"mappings":";;;;;;;;;;;AACAA,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.DracoWriter = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
|
+
var _dracoBuilder = _interopRequireDefault(require("./lib/draco-builder"));
|
|
11
|
+
var _dracoModuleLoader = require("./lib/draco-module-loader");
|
|
12
|
+
var _version = require("./lib/utils/version");
|
|
13
|
+
var DEFAULT_DRACO_WRITER_OPTIONS = {
|
|
14
|
+
pointcloud: false,
|
|
15
|
+
attributeNameEntry: 'name'
|
|
16
|
+
};
|
|
17
|
+
var DracoWriter = {
|
|
18
|
+
name: 'DRACO',
|
|
19
|
+
id: 'draco',
|
|
20
|
+
module: 'draco',
|
|
21
|
+
version: _version.VERSION,
|
|
22
|
+
extensions: ['drc'],
|
|
23
|
+
encode: encode,
|
|
24
|
+
options: {
|
|
25
|
+
draco: DEFAULT_DRACO_WRITER_OPTIONS
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.DracoWriter = DracoWriter;
|
|
29
|
+
function encode(_x) {
|
|
30
|
+
return _encode.apply(this, arguments);
|
|
31
|
+
}
|
|
32
|
+
function _encode() {
|
|
33
|
+
_encode = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data) {
|
|
34
|
+
var options,
|
|
35
|
+
_yield$loadDracoEncod,
|
|
36
|
+
draco,
|
|
37
|
+
dracoBuilder,
|
|
38
|
+
_args = arguments;
|
|
39
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
40
|
+
while (1) switch (_context.prev = _context.next) {
|
|
41
|
+
case 0:
|
|
42
|
+
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
43
|
+
_context.next = 3;
|
|
44
|
+
return (0, _dracoModuleLoader.loadDracoEncoderModule)(options);
|
|
45
|
+
case 3:
|
|
46
|
+
_yield$loadDracoEncod = _context.sent;
|
|
47
|
+
draco = _yield$loadDracoEncod.draco;
|
|
48
|
+
dracoBuilder = new _dracoBuilder.default(draco);
|
|
49
|
+
_context.prev = 6;
|
|
50
|
+
return _context.abrupt("return", dracoBuilder.encodeSync(data, options.draco));
|
|
51
|
+
case 8:
|
|
52
|
+
_context.prev = 8;
|
|
53
|
+
dracoBuilder.destroy();
|
|
54
|
+
return _context.finish(8);
|
|
55
|
+
case 11:
|
|
56
|
+
case "end":
|
|
57
|
+
return _context.stop();
|
|
58
|
+
}
|
|
59
|
+
}, _callee, null, [[6,, 8, 11]]);
|
|
60
|
+
}));
|
|
61
|
+
return _encode.apply(this, arguments);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=draco-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draco-writer.js","names":["_dracoBuilder","_interopRequireDefault","require","_dracoModuleLoader","_version","DEFAULT_DRACO_WRITER_OPTIONS","pointcloud","attributeNameEntry","DracoWriter","name","id","module","version","VERSION","extensions","encode","options","draco","exports","_x","_encode","apply","arguments","_asyncToGenerator2","default","_regenerator","mark","_callee","data","_yield$loadDracoEncod","dracoBuilder","_args","wrap","_callee$","_context","prev","next","length","undefined","loadDracoEncoderModule","sent","DRACOBuilder","abrupt","encodeSync","destroy","finish","stop"],"sources":["../../src/draco-writer.ts"],"sourcesContent":["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 d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