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

@loaders.gl/draco

Package Overview
Dependencies
Maintainers
9
Versions
339
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/draco - npm Package Compare versions

Comparing version 4.0.0-beta.2 to 4.0.0-beta.3

dist/dist.dev.js

2

dist/draco-worker.js

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

(()=>{var X=Object.create;var x=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var ee=t=>x(t,"__esModule",{value:!0});var te=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var re=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of H(e))!Z.call(t,o)&&o!=="default"&&x(t,o,{get:()=>e[o],enumerable:!(r=J(e,o))||r.enumerable});return t},oe=t=>re(ee(x(t!=null?X(K(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var N=te(()=>{});function ae(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.0.0-beta.2"),globalThis._loadersgl_.version}var k=ae();function S(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var f={self:typeof self!="undefined"&&self,window:typeof window!="undefined"&&window,global:typeof global!="undefined"&&global,document:typeof document!="undefined"&&document},Le=f.self||f.window||f.global||{},Ie=f.window||f.self||f.global||{},F=f.global||f.self||f.window||{},Pe=f.document||{};var T=typeof process!="object"||String(process)!=="[object process]"||process.browser,D=typeof importScripts=="function",Re=typeof window!="undefined"&&typeof window.orientation!="undefined",C=typeof process!="undefined"&&process.version&&/v([0-9]*)/.exec(process.version),ke=C&&parseFloat(C[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 b(){let parentPort;try{eval("globalThis.parentPort = require('worker_threads').parentPort"),parentPort=globalThis.parentPort}catch{}return parentPort}var M=new Map,p=class{static inWorkerThread(){return typeof self!="undefined"||Boolean(b())}static set onmessage(e){function r(a){let s=b(),{type:i,payload:n}=s?a:a.data;e(i,n)}let o=b();o?(o.on("message",r),o.on("exit",()=>console.debug("Node worker closing"))):globalThis.onmessage=r}static addEventListener(e){let r=M.get(e);r||(r=a=>{if(!se(a))return;let s=b(),{type:i,payload:n}=s?a:a.data;e(i,n)}),b()?console.error("not implemented"):globalThis.addEventListener("message",r)}static removeEventListener(e){let r=M.get(e);M.delete(e),b()?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=b();s?s.postMessage(o,a):globalThis.postMessage(o,a)}};function se(t){let{type:e,data:r}=t;return e==="message"&&r&&typeof r.source=="string"&&r.source.startsWith("loaders.gl")}var y=oe(N());var O={};async function h(t,e=null,r={},o=null){return e&&(t=v(t,e,r,o)),O[t]=O[t]||ie(t),await O[t]}function v(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]:T?r.CDN?(S(r.CDN.startsWith("http")),`${r.CDN}/${e}@${k}/dist/libs/${o}`):D?`../src/libs/${o}`:`modules/${e}/src/libs/${o}`:`modules/${e}/dist/libs/${o}`}async function ie(t){if(t.endsWith("wasm"))return await le(t);if(!T)try{return y&&y.requireFromFile&&await y.requireFromFile(t)}catch{return null}if(D)return importScripts(t);let e=await ce(t);return ne(e,t)}function ne(t,e){if(!T)return y.requireFromString&&y.requireFromString(t,e);if(D)return eval.call(F,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 le(t){return!y.readFileAsArrayBuffer||t.startsWith("http")?await(await fetch(t)).arrayBuffer():await y.readFileAsArrayBuffer(t)}async function ce(t){return!y.readFileAsText||t.startsWith("http")?await(await fetch(t)).text():await y.readFileAsText(t)}var de=0;function E(t){!p.inWorkerThread()||(p.onmessage=async(e,r)=>{switch(e){case"process":try{let{input:o,options:a={},context:s={}}=r,i=await pe({loader:t,arrayBuffer:o,options:a,context:{...s,_parse:ue}});p.postMessage("done",{result:i})}catch(o){let a=o instanceof Error?o.message:"";p.postMessage("error",{error:a})}break;default:}})}function ue(t,e,r,o){return new Promise((a,s)=>{let i=de++,n=(u,c)=>{if(c.id===i)switch(u){case"done":p.removeEventListener(n),a(c.result);break;case"error":p.removeEventListener(n),s(c.error);break;default:}};p.addEventListener(n);let l={id:i,input:t,options:r};p.postMessage("process",l)})}async function pe({loader:t,arrayBuffer:e,options:r,context:o}){let a,s;if(t.parseSync||t.parse)a=e,s=t.parseSync||t.parse;else if(t.parseTextSync)a=new TextDecoder().decode(e),s=t.parseTextSync;else throw new Error(`Could not load data with ${t.name} loader`);return r={...r,modules:t&&t.options&&t.options.modules||{},worker:!1},await s(a,{...r},o,t)}var W="4.0.0-beta.2";var fe={draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}},z={name:"Draco",id:"draco",module:"draco",version:W,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:fe};function V(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function L(t){let e=1/0,r=1/0,o=1/0,a=-1/0,s=-1/0,i=-1/0,n=t.POSITION?t.POSITION.value:[],l=n&&n.length;for(let u=0;u<l;u+=3){let c=n[u],m=n[u+1],g=n[u+2];e=c<e?c:e,r=m<r?m:r,o=g<o?g:o,a=c>a?c:a,s=m>s?m:s,i=g>i?g:i}return[[e,r,o],[a,s,i]]}function I(t,e,r){let o=V(e.value),a=r||G(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:o}]},nullable:!1,metadata:a}}function G(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}function q(t,e,r){let o=$(e.metadata),a=[],s=ye(e.attributes);for(let i in t){let n=t[i],l=U(i,n,s[i]);a.push(l)}if(r){let i=U("indices",r);a.push(i)}return{fields:a,metadata:o}}function ye(t){let e={};for(let r in t){let o=t[r];e[o.name||"undefined"]=o}return e}function U(t,e,r){let o=r?$(r.metadata):void 0;return I(t,e,o)}function $(t){Object.entries(t);let e={};for(let r in t)e[`${r}.string`]=JSON.stringify(t[r]);return e}var Q={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},me={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},be=4,_=class{constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,r={}){let o=new this.draco.DecoderBuffer;o.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(r);let a=this.decoder.GetEncodedGeometryType(o),s=a===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let i;switch(a){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(o,s);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(o,s);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!s.ptr){let g=`DRACO decompression failed: ${i.error_msg()}`;throw new Error(g)}let n=this._getDracoLoaderData(s,a,r),l=this._getMeshData(s,n,r),u=L(l.attributes),c=q(l.attributes,n,l.indices);return{loader:"draco",loaderData:n,header:{vertexCount:s.num_points(),boundingBox:u},...l,schema:c}}finally{this.draco.destroy(o),s&&this.draco.destroy(s)}}_getDracoLoaderData(e,r,o){let a=this._getTopLevelMetadata(e),s=this._getDracoAttributes(e,o);return{geometry_type:r,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:a,attributes:s}}_getDracoAttributes(e,r){let o={};for(let a=0;a<e.num_attributes();a++){let s=this.decoder.GetAttribute(e,a),i=this._getAttributeMetadata(e,a);o[s.unique_id()]={unique_id:s.unique_id(),attribute_type:s.attribute_type(),data_type:s.data_type(),num_components:s.num_components(),byte_offset:s.byte_offset(),byte_stride:s.byte_stride(),normalized:s.normalized(),attribute_index:a,metadata:i};let n=this._getQuantizationTransform(s,r);n&&(o[s.unique_id()].quantization_transform=n);let l=this._getOctahedronTransform(s,r);l&&(o[s.unique_id()].octahedron_transform=l)}return o}_getMeshData(e,r,o){let a=this._getMeshAttributes(r,e,o);if(!a.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(o.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:a,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:a,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:a}}_getMeshAttributes(e,r,o){let a={};for(let s of Object.values(e.attributes)){let i=this._deduceAttributeName(s,o);s.name=i;let{value:n,size:l}=this._getAttributeValues(r,s);a[i]={value:n,size:l,byteOffset:s.byte_offset,byteStride:s.byte_stride,normalized:s.normalized}}return a}_getTriangleListIndices(e){let o=e.num_faces()*3,a=o*be,s=this.draco._malloc(a);try{return this.decoder.GetTrianglesUInt32Array(e,a,s),new Uint32Array(this.draco.HEAPF32.buffer,s,o).slice()}finally{this.draco._free(s)}}_getTriangleStripIndices(e){let r=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,r),Ae(r)}finally{this.draco.destroy(r)}}_getAttributeValues(e,r){let o=me[r.data_type],a=r.num_components,i=e.num_points()*a,n=i*o.BYTES_PER_ELEMENT,l=ge(this.draco,o),u,c=this.draco._malloc(n);try{let m=this.decoder.GetAttribute(e,r.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,m,l,n,c),u=new o(this.draco.HEAPF32.buffer,c,i).slice()}finally{this.draco._free(c)}return{value:u,size:a}}_deduceAttributeName(e,r){let o=e.unique_id;for(let[i,n]of Object.entries(r.extraAttributes||{}))if(n===o)return i;let a=e.attribute_type;for(let i in Q)if(this.draco[i]===a)return Q[i];let s=r.attributeNameEntry||"name";return e.metadata[s]?e.metadata[s].string:`CUSTOM_ATTRIBUTE_${o}`}_getTopLevelMetadata(e){let r=this.decoder.GetMetadata(e);return this._getDracoMetadata(r)}_getAttributeMetadata(e,r){let o=this.decoder.GetAttributeMetadata(e,r);return this._getDracoMetadata(o)}_getDracoMetadata(e){if(!e||!e.ptr)return{};let r={},o=this.metadataQuerier.NumEntries(e);for(let a=0;a<o;a++){let s=this.metadataQuerier.GetEntryName(e,a);r[s]=this._getDracoMetadataField(e,s)}return r}_getDracoMetadataField(e,r){let o=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,r,o);let a=he(o);return{int:this.metadataQuerier.GetIntEntry(e,r),string:this.metadataQuerier.GetStringEntry(e,r),double:this.metadataQuerier.GetDoubleEntry(e,r),intArray:a}}finally{this.draco.destroy(o)}}_disableAttributeTransforms(e){let{quantizedAttributes:r=[],octahedronAttributes:o=[]}=e,a=[...r,...o];for(let s of a)this.decoder.SkipAttributeTransform(this.draco[s])}_getQuantizationTransform(e,r){let{quantizedAttributes:o=[]}=r,a=e.attribute_type();if(o.map(i=>this.decoder[i]).includes(a)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits(),range:i.range(),min_values:new Float32Array([1,2,3]).map(n=>i.min_value(n))}}finally{this.draco.destroy(i)}}return null}_getOctahedronTransform(e,r){let{octahedronAttributes:o=[]}=r,a=e.attribute_type();if(o.map(i=>this.decoder[i]).includes(a)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(e))return{quantization_bits:i.quantization_bits()}}finally{this.draco.destroy(i)}}return null}};function ge(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function he(t){let e=t.size(),r=new Int32Array(e);for(let o=0;o<e;o++)r[o]=t.GetValue(o);return r}function Ae(t){let e=t.size(),r=new Int32Array(e);for(let o=0;o<e;o++)r[o]=t.GetValue(o);return r}var Te="1.5.6",De="1.4.1",P=`https://www.gstatic.com/draco/versioned/decoders/${Te}`,d={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},R={[d.DECODER]:`${P}/${d.DECODER}`,[d.DECODER_WASM]:`${P}/${d.DECODER_WASM}`,[d.FALLBACK_DECODER]:`${P}/${d.FALLBACK_DECODER}`,[d.ENCODER]:`https://raw.githubusercontent.com/google/draco/${De}/javascript/${d.ENCODER}`},A;async function j(t){let e=t.modules||{};return e.draco3d?A=A||e.draco3d.createDecoderModule({}).then(r=>({draco:r})):A=A||_e(t),await A}async function _e(t){let e,r;switch(t.draco&&t.draco.decoderType){case"js":e=await h(R[d.FALLBACK_DECODER],"draco",t,d.FALLBACK_DECODER);break;case"wasm":default:[e,r]=await Promise.all([await h(R[d.DECODER],"draco",t,d.DECODER),await h(R[d.DECODER_WASM],"draco",t,d.DECODER_WASM)])}return e=e||globalThis.DracoDecoderModule,await xe(e,r)}function xe(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(o=>{t({...r,onModuleLoaded:a=>o({draco:a})})})}var Y={...z,parse:we};async function we(t,e){let{draco:r}=await j(e),o=new _(r);try{return o.parseSync(t,e?.draco)}finally{o.destroy()}}E(Y);})();
"use strict";(()=>{var X=Object.create;var R=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var ee=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var te=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of H(e))!Z.call(t,a)&&a!==r&&R(t,a,{get:()=>e[a],enumerable:!(o=J(e,a))||o.enumerable});return t};var re=(t,e,r)=>(r=t!=null?X(K(t)):{},te(e||!t||!t.__esModule?R(r,"default",{value:t,enumerable:!0}):r,t));var k=ee(()=>{"use strict"});function oe(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.0.0-beta.3"),globalThis._loadersgl_.version}var S=oe();function F(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var y={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},we=y.self||y.window||y.global||{},Le=y.window||y.self||y.global||{},B=y.global||y.self||y.window||{},Ie=y.document||{};var D=typeof process!="object"||String(process)!=="[object process]"||process.browser,_=typeof importScripts=="function",Pe=typeof window<"u"&&typeof window.orientation<"u",C=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Re=C&&parseFloat(C[1])||0;function x(t,e=!0,r){let o=r||new Set;if(t){if(N(t))o.add(t);else if(N(t.buffer))o.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let a in t)x(t[a],e,o)}}return r===void 0?Array.from(o):[]}function N(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}function g(){let parentPort;try{eval("globalThis.parentPort = require('worker_threads').parentPort"),parentPort=globalThis.parentPort}catch{}return parentPort}var M=new Map,l=class{static inWorkerThread(){return typeof self<"u"||Boolean(g())}static set onmessage(e){function r(a){let n=g(),{type:s,payload:i}=n?a:a.data;e(s,i)}let o=g();o?(o.on("message",r),o.on("exit",()=>console.debug("Node worker closing"))):globalThis.onmessage=r}static addEventListener(e){let r=M.get(e);r||(r=a=>{if(!ae(a))return;let n=g(),{type:s,payload:i}=n?a:a.data;e(s,i)}),g()?console.error("not implemented"):globalThis.addEventListener("message",r)}static removeEventListener(e){let r=M.get(e);M.delete(e),g()?console.error("not implemented"):globalThis.removeEventListener("message",r)}static postMessage(e,r){let o={source:"loaders.gl",type:e,payload:r},a=x(r),n=g();n?n.postMessage(o,a):globalThis.postMessage(o,a)}};function ae(t){let{type:e,data:r}=t;return e==="message"&&r&&typeof r.source=="string"&&r.source.startsWith("loaders.gl")}var p=re(k(),1);var O={};async function h(t,e=null,r={},o=null){return e&&(t=W(t,e,r,o)),O[t]=O[t]||ne(t),await O[t]}function W(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]:D?r.CDN?(F(r.CDN.startsWith("http")),`${r.CDN}/${e}@${S}/dist/libs/${o}`):_?`../src/libs/${o}`:`modules/${e}/src/libs/${o}`:`modules/${e}/dist/libs/${o}`}async function ne(t){if(t.endsWith("wasm"))return await ie(t);if(!D)try{return p&&void 0&&await(void 0)(t)}catch(r){return console.error(r),null}if(_)return importScripts(t);let e=await ce(t);return se(e,t)}function se(t,e){if(!D)return void 0&&(void 0)(t,e);if(_)return eval.call(B,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 ie(t){return!void 0||t.startsWith("http")?await(await fetch(t)).arrayBuffer():await(void 0)(t)}async function ce(t){return!void 0||t.startsWith("http")?await(await fetch(t)).text():await(void 0)(t)}var de=0;function E(t){l.inWorkerThread()&&(l.onmessage=async(e,r)=>{switch(e){case"process":try{let{input:o,options:a={},context:n={}}=r,s=await le({loader:t,arrayBuffer:o,options:a,context:{...n,_parse:ue}});l.postMessage("done",{result:s})}catch(o){let a=o instanceof Error?o.message:"";l.postMessage("error",{error:a})}break;default:}})}function ue(t,e,r,o){return new Promise((a,n)=>{let s=de++,i=(f,d)=>{if(d.id===s)switch(f){case"done":l.removeEventListener(i),a(d.result);break;case"error":l.removeEventListener(i),n(d.error);break;default:}};l.addEventListener(i);let c={id:s,input:t,options:r};l.postMessage("process",c)})}async function le({loader:t,arrayBuffer:e,options:r,context:o}){let a,n;if(t.parseSync||t.parse)a=e,n=t.parseSync||t.parse;else if(t.parseTextSync)a=new TextDecoder().decode(e),n=t.parseTextSync;else throw new Error(`Could not load data with ${t.name} loader`);return r={...r,modules:t&&t.options&&t.options.modules||{},worker:!1},await n(a,{...r},o,t)}var v="4.0.0-beta.3";var pe={draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}},z={name:"Draco",id:"draco",module:"draco",version:v,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:pe};function V(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function w(t){let e=1/0,r=1/0,o=1/0,a=-1/0,n=-1/0,s=-1/0,i=t.POSITION?t.POSITION.value:[],c=i&&i.length;for(let f=0;f<c;f+=3){let d=i[f],m=i[f+1],A=i[f+2];e=d<e?d:e,r=m<r?m:r,o=A<o?A:o,a=d>a?d:a,n=m>n?m:n,s=A>s?A:s}return[[e,r,o],[a,n,s]]}function L(t,e,r){let o=V(e.value),a=r||G(e);return{name:t,type:{type:"fixed-size-list",listSize:e.size,children:[{name:"value",type:o}]},nullable:!1,metadata:a}}function G(t){let e={};return"byteOffset"in t&&(e.byteOffset=t.byteOffset.toString(10)),"byteStride"in t&&(e.byteStride=t.byteStride.toString(10)),"normalized"in t&&(e.normalized=t.normalized.toString()),e}function q(t,e,r){let o=$(e.metadata),a=[],n=fe(e.attributes);for(let s in t){let i=t[s],c=U(s,i,n[s]);a.push(c)}if(r){let s=U("indices",r);a.push(s)}return{fields:a,metadata:o}}function fe(t){let e={};for(let r in t){let o=t[r];e[o.name||"undefined"]=o}return e}function U(t,e,r){let o=r?$(r.metadata):void 0;return L(t,e,o)}function $(t){Object.entries(t);let e={};for(let r in t)e[`${r}.string`]=JSON.stringify(t[r]);return e}var Q={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},ye={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},me=4,b=class{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,r={}){let o=new this.draco.DecoderBuffer;o.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(r);let a=this.decoder.GetEncodedGeometryType(o),n=a===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let s;switch(a){case this.draco.TRIANGULAR_MESH:s=this.decoder.DecodeBufferToMesh(o,n);break;case this.draco.POINT_CLOUD:s=this.decoder.DecodeBufferToPointCloud(o,n);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!s.ok()||!n.ptr){let A=`DRACO decompression failed: ${s.error_msg()}`;throw new Error(A)}let i=this._getDracoLoaderData(n,a,r),c=this._getMeshData(n,i,r),f=w(c.attributes),d=q(c.attributes,i,c.indices);return{loader:"draco",loaderData:i,header:{vertexCount:n.num_points(),boundingBox:f},...c,schema:d}}finally{this.draco.destroy(o),n&&this.draco.destroy(n)}}_getDracoLoaderData(e,r,o){let a=this._getTopLevelMetadata(e),n=this._getDracoAttributes(e,o);return{geometry_type:r,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:a,attributes:n}}_getDracoAttributes(e,r){let o={};for(let a=0;a<e.num_attributes();a++){let n=this.decoder.GetAttribute(e,a),s=this._getAttributeMetadata(e,a);o[n.unique_id()]={unique_id:n.unique_id(),attribute_type:n.attribute_type(),data_type:n.data_type(),num_components:n.num_components(),byte_offset:n.byte_offset(),byte_stride:n.byte_stride(),normalized:n.normalized(),attribute_index:a,metadata:s};let i=this._getQuantizationTransform(n,r);i&&(o[n.unique_id()].quantization_transform=i);let c=this._getOctahedronTransform(n,r);c&&(o[n.unique_id()].octahedron_transform=c)}return o}_getMeshData(e,r,o){let a=this._getMeshAttributes(r,e,o);if(!a.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(o.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:a,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:a,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:a}}_getMeshAttributes(e,r,o){let a={};for(let n of Object.values(e.attributes)){let s=this._deduceAttributeName(n,o);n.name=s;let{value:i,size:c}=this._getAttributeValues(r,n);a[s]={value:i,size:c,byteOffset:n.byte_offset,byteStride:n.byte_stride,normalized:n.normalized}}return a}_getTriangleListIndices(e){let o=e.num_faces()*3,a=o*me,n=this.draco._malloc(a);try{return this.decoder.GetTrianglesUInt32Array(e,a,n),new Uint32Array(this.draco.HEAPF32.buffer,n,o).slice()}finally{this.draco._free(n)}}_getTriangleStripIndices(e){let r=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,r),he(r)}finally{this.draco.destroy(r)}}_getAttributeValues(e,r){let o=ye[r.data_type],a=r.num_components,s=e.num_points()*a,i=s*o.BYTES_PER_ELEMENT,c=ge(this.draco,o),f,d=this.draco._malloc(i);try{let m=this.decoder.GetAttribute(e,r.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,m,c,i,d),f=new o(this.draco.HEAPF32.buffer,d,s).slice()}finally{this.draco._free(d)}return{value:f,size:a}}_deduceAttributeName(e,r){let o=e.unique_id;for(let[s,i]of Object.entries(r.extraAttributes||{}))if(i===o)return s;let a=e.attribute_type;for(let s in Q)if(this.draco[s]===a)return Q[s];let n=r.attributeNameEntry||"name";return e.metadata[n]?e.metadata[n].string:`CUSTOM_ATTRIBUTE_${o}`}_getTopLevelMetadata(e){let r=this.decoder.GetMetadata(e);return this._getDracoMetadata(r)}_getAttributeMetadata(e,r){let o=this.decoder.GetAttributeMetadata(e,r);return this._getDracoMetadata(o)}_getDracoMetadata(e){if(!e||!e.ptr)return{};let r={},o=this.metadataQuerier.NumEntries(e);for(let a=0;a<o;a++){let n=this.metadataQuerier.GetEntryName(e,a);r[n]=this._getDracoMetadataField(e,n)}return r}_getDracoMetadataField(e,r){let o=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,r,o);let a=Ae(o);return{int:this.metadataQuerier.GetIntEntry(e,r),string:this.metadataQuerier.GetStringEntry(e,r),double:this.metadataQuerier.GetDoubleEntry(e,r),intArray:a}}finally{this.draco.destroy(o)}}_disableAttributeTransforms(e){let{quantizedAttributes:r=[],octahedronAttributes:o=[]}=e,a=[...r,...o];for(let n of a)this.decoder.SkipAttributeTransform(this.draco[n])}_getQuantizationTransform(e,r){let{quantizedAttributes:o=[]}=r,a=e.attribute_type();if(o.map(s=>this.decoder[s]).includes(a)){let s=new this.draco.AttributeQuantizationTransform;try{if(s.InitFromAttribute(e))return{quantization_bits:s.quantization_bits(),range:s.range(),min_values:new Float32Array([1,2,3]).map(i=>s.min_value(i))}}finally{this.draco.destroy(s)}}return null}_getOctahedronTransform(e,r){let{octahedronAttributes:o=[]}=r,a=e.attribute_type();if(o.map(s=>this.decoder[s]).includes(a)){let s=new this.draco.AttributeQuantizationTransform;try{if(s.InitFromAttribute(e))return{quantization_bits:s.quantization_bits()}}finally{this.draco.destroy(s)}}return null}};function ge(t,e){switch(e){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32;default:return t.DT_INVALID}}function Ae(t){let e=t.size(),r=new Int32Array(e);for(let o=0;o<e;o++)r[o]=t.GetValue(o);return r}function he(t){let e=t.size(),r=new Int32Array(e);for(let o=0;o<e;o++)r[o]=t.GetValue(o);return r}var be="1.5.6",Te="1.4.1",I=`https://www.gstatic.com/draco/versioned/decoders/${be}`,u={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},P={[u.DECODER]:`${I}/${u.DECODER}`,[u.DECODER_WASM]:`${I}/${u.DECODER_WASM}`,[u.FALLBACK_DECODER]:`${I}/${u.FALLBACK_DECODER}`,[u.ENCODER]:`https://raw.githubusercontent.com/google/draco/${Te}/javascript/${u.ENCODER}`},T;async function j(t){let e=t.modules||{};return e.draco3d?T=T||e.draco3d.createDecoderModule({}).then(r=>({draco:r})):T=T||De(t),await T}async function De(t){let e,r;switch(t.draco&&t.draco.decoderType){case"js":e=await h(P[u.FALLBACK_DECODER],"draco",t,u.FALLBACK_DECODER);break;case"wasm":default:[e,r]=await Promise.all([await h(P[u.DECODER],"draco",t,u.DECODER),await h(P[u.DECODER_WASM],"draco",t,u.DECODER_WASM)])}return e=e||globalThis.DracoDecoderModule,await _e(e,r)}function _e(t,e){let r={};return e&&(r.wasmBinary=e),new Promise(o=>{t({...r,onModuleLoaded:a=>o({draco:a})})})}var Y={...z,parse:xe};async function xe(t,e){let{draco:r}=await j(e),o=new b(r);try{return o.parseSync(t,e?.draco)}finally{o.destroy()}}E(Y);})();
//# sourceMappingURL=draco-worker.js.map

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

(()=>{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.2"),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
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
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.2";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:}})})();})();
"use strict";(()=>{var N=Object.create;var w=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var G=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var j=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of $(e))!V.call(r,a)&&a!==t&&w(r,a,{get:()=>e[a],enumerable:!(o=F(e,a))||o.enumerable});return r};var q=(r,e,t)=>(t=r!=null?N(v(r)):{},j(e||!r||!r.__esModule?w(t,"default",{value:r,enumerable:!0}):t,r));var P=G(()=>{"use strict"});function z(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.0.0-beta.3"),globalThis._loadersgl_.version}var b=z();function T(r,e){if(!r)throw new Error(e||"loaders.gl assertion failed.")}var u={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},de=u.self||u.window||u.global||{},ce=u.window||u.self||u.global||{},B=u.global||u.self||u.window||{},ue=u.document||{};var m=typeof process!="object"||String(process)!=="[object process]"||process.browser,E=typeof importScripts=="function",le=typeof window<"u"&&typeof window.orientation<"u",R=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),fe=R&&parseFloat(R[1])||0;function A(r,e=!0,t){let o=t||new Set;if(r){if(C(r))o.add(r);else if(C(r.buffer))o.add(r.buffer);else if(!ArrayBuffer.isView(r)){if(e&&typeof r=="object")for(let a in r)A(r[a],e,o)}}return t===void 0?Array.from(o):[]}function C(r){return r?r instanceof ArrayBuffer||typeof MessagePort<"u"&&r instanceof MessagePort||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas:!1}function y(){let parentPort;try{eval("globalThis.parentPort = require('worker_threads').parentPort"),parentPort=globalThis.parentPort}catch{}return parentPort}var D=new Map,f=class{static inWorkerThread(){return typeof self<"u"||Boolean(y())}static set onmessage(e){function t(a){let n=y(),{type:i,payload:s}=n?a:a.data;e(i,s)}let o=y();o?(o.on("message",t),o.on("exit",()=>console.debug("Node worker closing"))):globalThis.onmessage=t}static addEventListener(e){let t=D.get(e);t||(t=a=>{if(!U(a))return;let n=y(),{type:i,payload:s}=n?a:a.data;e(i,s)}),y()?console.error("not implemented"):globalThis.addEventListener("message",t)}static removeEventListener(e){let t=D.get(e);D.delete(e),y()?console.error("not implemented"):globalThis.removeEventListener("message",t)}static postMessage(e,t){let o={source:"loaders.gl",type:e,payload:t},a=A(t),n=y();n?n.postMessage(o,a):globalThis.postMessage(o,a)}};function U(r){let{type:e,data:t}=r;return e==="message"&&t&&typeof t.source=="string"&&t.source.startsWith("loaders.gl")}var d=q(P(),1);var M={};async function _(r,e=null,t={},o=null){return e&&(r=W(r,e,t,o)),M[r]=M[r]||K(r),await M[r]}function W(r,e,t={},o=null){if(!t.useLocalLibraries&&r.startsWith("http"))return r;o=o||r;let a=t.modules||{};return a[o]?a[o]:m?t.CDN?(T(t.CDN.startsWith("http")),`${t.CDN}/${e}@${b}/dist/libs/${o}`):E?`../src/libs/${o}`:`modules/${e}/src/libs/${o}`:`modules/${e}/dist/libs/${o}`}async function K(r){if(r.endsWith("wasm"))return await Q(r);if(!m)try{return d&&void 0&&await(void 0)(r)}catch(t){return console.error(t),null}if(E)return importScripts(r);let e=await H(r);return X(e,r)}function X(r,e){if(!m)return void 0&&(void 0)(r,e);if(E)return eval.call(B,r),null;let t=document.createElement("script");t.id=e;try{t.appendChild(document.createTextNode(r))}catch{t.text=r}return document.body.appendChild(t),null}async function Q(r){return!void 0||r.startsWith("http")?await(await fetch(r)).arrayBuffer():await(void 0)(r)}async function H(r){return!void 0||r.startsWith("http")?await(await fetch(r)).text():await(void 0)(r)}var I={POSITION:"POSITION",NORMAL:"NORMAL",COLOR_0:"COLOR",TEXCOORD_0:"TEX_COORD"},J=()=>{},h=class{draco;dracoEncoder;dracoMeshBuilder;dracoMetadataBuilder;log;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,t={}){return this.log=J,this._setOptions(t),t.pointcloud?this._encodePointCloud(e,t):this._encodeMesh(e,t)}_getAttributesFromMesh(e){let t={...e,...e.attributes};return e.indices&&(t.indices=e.indices),t}_encodePointCloud(e,t){let o=new this.draco.PointCloud;t.metadata&&this._addGeometryMetadata(o,t.metadata);let a=this._getAttributesFromMesh(e);this._createDracoPointCloud(o,a,t);let n=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodePointCloudToDracoBuffer(o,!1,n);if(!(i>0))throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${o.num_points()} points
with ${o.num_attributes()} attributes into ${i} bytes`),L(n)}finally{this.destroyEncodedObject(n),this.destroyEncodedObject(o)}}_encodeMesh(e,t){let o=new this.draco.Mesh;t.metadata&&this._addGeometryMetadata(o,t.metadata);let a=this._getAttributesFromMesh(e);this._createDracoMesh(o,a,t);let n=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodeMeshToDracoBuffer(o,n);if(i<=0)throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${o.num_points()} points
with ${o.num_attributes()} attributes into ${i} bytes`),L(n)}finally{this.destroyEncodedObject(n),this.destroyEncodedObject(o)}}_setOptions(e){if("speed"in e&&this.dracoEncoder.SetSpeedOptions(...e.speed),"method"in e){let t=this.draco[e.method||"MESH_SEQUENTIAL_ENCODING"];this.dracoEncoder.SetEncodingMethod(t)}if("quantization"in e)for(let t in e.quantization){let o=e.quantization[t],a=this.draco[t];this.dracoEncoder.SetAttributeQuantization(a,o)}}_createDracoMesh(e,t,o){let a=o.attributesMetadata||{};try{let n=this._getPositionAttribute(t);if(!n)throw new Error("positions");let i=n.length/3;for(let s in t){let c=t[s];s=I[s]||s;let p=this._addAttributeToMesh(e,s,c,i);p!==-1&&this._addAttributeMetadata(e,p,{name:s,...a[s]||{}})}}catch(n){throw this.destroyEncodedObject(e),n}return e}_createDracoPointCloud(e,t,o){let a=o.attributesMetadata||{};try{let n=this._getPositionAttribute(t);if(!n)throw new Error("positions");let i=n.length/3;for(let s in t){let c=t[s];s=I[s]||s;let p=this._addAttributeToMesh(e,s,c,i);p!==-1&&this._addAttributeMetadata(e,p,{name:s,...a[s]||{}})}}catch(n){throw this.destroyEncodedObject(e),n}return e}_addAttributeToMesh(e,t,o,a){if(!ArrayBuffer.isView(o))return-1;let n=this._getDracoAttributeType(t),i=o.length/a;if(n==="indices"){let p=o.length/3;return this.log(`Adding attribute ${t}, size ${p}`),this.dracoMeshBuilder.AddFacesToMesh(e,p,o),-1}this.log(`Adding attribute ${t}, size ${i}`);let s=this.dracoMeshBuilder,{buffer:c}=o;switch(o.constructor){case Int8Array:return s.AddInt8Attribute(e,n,a,i,new Int8Array(c));case Int16Array:return s.AddInt16Attribute(e,n,a,i,new Int16Array(c));case Int32Array:return s.AddInt32Attribute(e,n,a,i,new Int32Array(c));case Uint8Array:case Uint8ClampedArray:return s.AddUInt8Attribute(e,n,a,i,new Uint8Array(c));case Uint16Array:return s.AddUInt16Attribute(e,n,a,i,new Uint16Array(c));case Uint32Array:return s.AddUInt32Attribute(e,n,a,i,new Uint32Array(c));case Float32Array:default:return s.AddFloatAttribute(e,n,a,i,new Float32Array(c))}}_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 t in e){let o=e[t];if(this._getDracoAttributeType(t)===this.draco.POSITION)return o}return null}_addGeometryMetadata(e,t){let o=new this.draco.Metadata;this._populateDracoMetadata(o,t),this.dracoMeshBuilder.AddMetadata(e,o)}_addAttributeMetadata(e,t,o){let a=new this.draco.Metadata;this._populateDracoMetadata(a,o),this.dracoMeshBuilder.SetMetadataForAttribute(e,t,a)}_populateDracoMetadata(e,t){for(let[o,a]of Y(t))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 L(r){let e=r.size(),t=new ArrayBuffer(e),o=new Int8Array(t);for(let a=0;a<e;++a)o[a]=r.GetValue(a);return t}function Y(r){return r.entries&&!r.hasOwnProperty("entries")?r.entries():Object.entries(r)}var Z="1.5.6",ee="1.4.1",O=`https://www.gstatic.com/draco/versioned/decoders/${Z}`,l={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},te={[l.DECODER]:`${O}/${l.DECODER}`,[l.DECODER_WASM]:`${O}/${l.DECODER_WASM}`,[l.FALLBACK_DECODER]:`${O}/${l.FALLBACK_DECODER}`,[l.ENCODER]:`https://raw.githubusercontent.com/google/draco/${ee}/javascript/${l.ENCODER}`};var g;async function k(r){let e=r.modules||{};return e.draco3d?g=g||e.draco3d.createEncoderModule({}).then(t=>({draco:t})):g=g||re(r),await g}async function re(r){let e=await _(te[l.ENCODER],"draco",r,l.ENCODER);return e=e||globalThis.DracoEncoderModule,new Promise(t=>{e({onModuleLoaded:o=>t({draco:o})})})}var x="4.0.0-beta.3";var oe={pointcloud:!1,attributeNameEntry:"name"},S={name:"DRACO",id:"draco",module:"draco",version:x,extensions:["drc"],encode:ae,options:{draco:oe}};async function ae(r,e={}){let{draco:t}=await k(e),o=new h(t);try{return o.encodeSync(r,e.draco)}finally{o.destroy()}}f.inWorkerThread()&&(f.onmessage=async(r,e)=>{switch(r){case"process":try{let{input:t,options:o}=e,a=await S.encode(t,o);f.postMessage("done",{result:a})}catch(t){let o=t instanceof Error?t.message:"";f.postMessage("error",{error:o})}break;default:}});})();
//# sourceMappingURL=draco-writer-worker.js.map
{
"name": "@loaders.gl/draco",
"version": "4.0.0-beta.2",
"version": "4.0.0-beta.3",
"description": "Framework-independent loader and writer for Draco compressed meshes and point clouds",
"license": "MIT",
"type": "module",
"publishConfig": {

@@ -23,4 +24,11 @@ "access": "public"

"types": "dist/index.d.ts",
"main": "dist/es5/index.js",
"module": "dist/esm/index.js",
"main": "dist/index.cjs",
"module": "dist/index.js",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
}
},
"sideEffects": false,

@@ -36,5 +44,5 @@ "browser": {

"scripts": {
"pre-build": "npm run copy-libs && npm run build-bundle && npm run build-workers",
"pre-build": "npm run copy-libs && npm run build-bundle && npm run build-bundle -- --env=dev && npm run build-workers",
"copy-libs": "cp -rf ./src/libs ./dist/libs",
"build-bundle": "esbuild src/bundle.ts --outfile=dist/dist.min.js --bundle --minify --sourcemap",
"build-bundle": "ocular-bundle ./src/index.ts",
"build-workers": "yarn build-loader-worker && yarn build-loader-worker-node && yarn build-writer-worker && yarn build-writer-worker-node",

@@ -48,11 +56,11 @@ "build-loader-worker": "esbuild src/workers/draco-worker.ts --outfile=dist/draco-worker.js --target=esnext --bundle --minify --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\"",

"@babel/runtime": "^7.3.1",
"@loaders.gl/loader-utils": "4.0.0-beta.2",
"@loaders.gl/schema": "4.0.0-beta.2",
"@loaders.gl/worker-utils": "4.0.0-beta.2",
"@loaders.gl/loader-utils": "4.0.0-beta.3",
"@loaders.gl/schema": "4.0.0-beta.3",
"@loaders.gl/worker-utils": "4.0.0-beta.3",
"draco3d": "1.5.5"
},
"devDependencies": {
"@loaders.gl/polyfills": "4.0.0-beta.2"
"@loaders.gl/polyfills": "4.0.0-beta.3"
},
"gitHead": "79c2033f755e88e11bc30a04428e3666b177b8fc"
"gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
}

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc