@loaders.gl/draco 3.2.7 → 3.3.0-alpha.3
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/dist.min.js +2 -2
- package/dist/dist.min.js.map +3 -3
- package/dist/draco-loader.d.ts.map +1 -1
- package/dist/draco-loader.js +2 -1
- package/dist/draco-nodejs-worker.js +190 -0
- package/dist/draco-nodejs-worker.js.map +7 -0
- package/dist/draco-worker.js +1 -1
- package/dist/draco-worker.js.map +2 -2
- package/dist/draco-writer-nodejs-worker.js +26 -26
- package/dist/draco-writer-nodejs-worker.js.map +2 -2
- package/dist/draco-writer-worker.js +2 -2
- package/dist/draco-writer-worker.js.map +2 -2
- package/dist/es5/draco-loader.js +3 -1
- package/dist/es5/draco-loader.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/lib/utils/version.js.map +1 -1
- package/dist/es5/workers/draco-nodejs-worker.js +10 -0
- package/dist/es5/workers/draco-nodejs-worker.js.map +1 -0
- package/dist/esm/draco-loader.js +2 -1
- package/dist/esm/draco-loader.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/lib/utils/version.js.map +1 -1
- package/dist/esm/workers/draco-nodejs-worker.js +5 -0
- package/dist/esm/workers/draco-nodejs-worker.js.map +1 -0
- 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/package.json +8 -7
- package/src/draco-loader.ts +2 -1
- package/src/workers/draco-nodejs-worker.ts +5 -0
package/dist/dist.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{var Xt=Object.create;var U=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames;var Kt=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var ct=r=>U(r,"__esModule",{value:!0});var l=(r,t)=>()=>(r&&(t=r(r=0)),t);var dt=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ee=(r,t)=>{ct(r);for(var e in t)U(r,e,{get:t[e],enumerable:!0})},re=(r,t,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Zt(t))!te.call(r,o)&&o!=="default"&&U(r,o,{get:()=>t[o],enumerable:!(e=Jt(t,o))||e.enumerable});return r},oe=r=>re(ct(U(r!=null?Xt(Kt(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var _,v=l(()=>{_=typeof __VERSION__!="undefined"?__VERSION__:"latest"});var ae,q,ut=l(()=>{v();ae={draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}},q={name:"Draco",id:"draco",module:"draco",shapes:["mesh"],version:_,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:ae}});function V(r){let t=1/0,e=1/0,o=1/0,a=-1/0,i=-1/0,s=-1/0,c=r.POSITION?r.POSITION.value:[],u=c&&c.length;for(let m=0;m<u;m+=3){let h=c[m],A=c[m+1],M=c[m+2];t=h<t?h:t,e=A<e?A:e,o=M<o?M:o,a=h>a?h:a,i=A>i?A:i,s=M>s?M:s}return[[t,e,o],[a,i,s]]}var lt=l(()=>{});function mt(r,t){if(!r)throw new Error(t||"loader assertion failed.")}var pt=l(()=>{});function ne(r){let t={};for(let e of r)t[e.name]&&console.warn("Schema: duplicated field name",e.name,e),t[e.name]=!0}function yt(r,t){return new Map([...r||new Map,...t||new Map])}var y,ht=l(()=>{pt();y=class{constructor(t,e){mt(Array.isArray(t)),ne(t),this.fields=t,this.metadata=e||new Map}compareTo(t){if(this.metadata!==t.metadata||this.fields.length!==t.fields.length)return!1;for(let e=0;e<this.fields.length;++e)if(!this.fields[e].compareTo(t.fields[e]))return!1;return!0}select(...t){let e=Object.create(null);for(let a of t)e[a]=!0;let o=this.fields.filter(a=>e[a.name]);return new y(o,this.metadata)}selectAt(...t){let e=t.map(o=>this.fields[o]).filter(Boolean);return new y(e,this.metadata)}assign(t){let e,o=this.metadata;if(t instanceof y){let s=t;e=s.fields,o=yt(yt(new Map,this.metadata),s.metadata)}else e=t;let a=Object.create(null);for(let s of this.fields)a[s.name]=s;for(let s of e)a[s.name]=s;let i=Object.values(a);return new y(i,o)}}});var b,ft=l(()=>{b=class{constructor(t,e,o=!1,a=new Map){this.name=t,this.type=e,this.nullable=o,this.metadata=a}get typeId(){return this.type&&this.type.typeId}clone(){return new b(this.name,this.type,this.nullable,this.metadata)}compareTo(t){return this.name===t.name&&this.type===t.type&&this.nullable===t.nullable&&this.metadata===t.metadata}toString(){return`${this.type}${this.nullable?", nullable":""}${this.metadata?`, metadata: ${this.metadata}`:""}`}}});var d,bt=l(()=>{(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth"})(d||(d={}))});var p,Q,Y,g,w,O,T,x,S,E,gt,F,N,L,H,X,ie,J,At,Z,K,se,tt,B,et,Dt=l(()=>{bt();p=class{static isNull(t){return t&&t.typeId===d.Null}static isInt(t){return t&&t.typeId===d.Int}static isFloat(t){return t&&t.typeId===d.Float}static isBinary(t){return t&&t.typeId===d.Binary}static isUtf8(t){return t&&t.typeId===d.Utf8}static isBool(t){return t&&t.typeId===d.Bool}static isDecimal(t){return t&&t.typeId===d.Decimal}static isDate(t){return t&&t.typeId===d.Date}static isTime(t){return t&&t.typeId===d.Time}static isTimestamp(t){return t&&t.typeId===d.Timestamp}static isInterval(t){return t&&t.typeId===d.Interval}static isList(t){return t&&t.typeId===d.List}static isStruct(t){return t&&t.typeId===d.Struct}static isUnion(t){return t&&t.typeId===d.Union}static isFixedSizeBinary(t){return t&&t.typeId===d.FixedSizeBinary}static isFixedSizeList(t){return t&&t.typeId===d.FixedSizeList}static isMap(t){return t&&t.typeId===d.Map}static isDictionary(t){return t&&t.typeId===d.Dictionary}get typeId(){return d.NONE}compareTo(t){return this===t}},Q=class extends p{get typeId(){return d.Null}get[Symbol.toStringTag](){return"Null"}toString(){return"Null"}},Y=class extends p{get typeId(){return d.Bool}get[Symbol.toStringTag](){return"Bool"}toString(){return"Bool"}},g=class extends p{constructor(t,e){super();this.isSigned=t,this.bitWidth=e}get typeId(){return d.Int}get[Symbol.toStringTag](){return"Int"}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}},w=class extends g{constructor(){super(!0,8)}},O=class extends g{constructor(){super(!0,16)}},T=class extends g{constructor(){super(!0,32)}},x=class extends g{constructor(){super(!1,8)}},S=class extends g{constructor(){super(!1,16)}},E=class extends g{constructor(){super(!1,32)}},gt={HALF:16,SINGLE:32,DOUBLE:64},F=class extends p{constructor(t){super();this.precision=t}get typeId(){return d.Float}get[Symbol.toStringTag](){return"Float"}toString(){return`Float${this.precision}`}},N=class extends F{constructor(){super(gt.SINGLE)}},L=class extends F{constructor(){super(gt.DOUBLE)}},H=class extends p{constructor(){super()}get typeId(){return d.Binary}toString(){return"Binary"}get[Symbol.toStringTag](){return"Binary"}},X=class extends p{get typeId(){return d.Utf8}get[Symbol.toStringTag](){return"Utf8"}toString(){return"Utf8"}},ie={DAY:0,MILLISECOND:1},J=class extends p{constructor(t){super();this.unit=t}get typeId(){return d.Date}get[Symbol.toStringTag](){return"Date"}toString(){return`Date${(this.unit+1)*32}<${ie[this.unit]}>`}},At={SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},Z=class extends p{constructor(t,e){super();this.unit=t,this.bitWidth=e}get typeId(){return d.Time}toString(){return`Time${this.bitWidth}<${At[this.unit]}>`}get[Symbol.toStringTag](){return"Time"}},K=class extends p{constructor(t,e=null){super();this.unit=t,this.timezone=e}get typeId(){return d.Timestamp}get[Symbol.toStringTag](){return"Timestamp"}toString(){return`Timestamp<${At[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}},se={DAY_TIME:0,YEAR_MONTH:1},tt=class extends p{constructor(t){super();this.unit=t}get typeId(){return d.Interval}get[Symbol.toStringTag](){return"Interval"}toString(){return`Interval<${se[this.unit]}>`}},B=class extends p{constructor(t,e){super();this.listSize=t,this.children=[e]}get typeId(){return d.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[Symbol.toStringTag](){return"FixedSizeList"}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}},et=class extends p{constructor(t){super();this.children=t}get typeId(){return d.Struct}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}get[Symbol.toStringTag](){return"Struct"}}});var z=l(()=>{ht();ft();Dt()});function Mt(r){switch(r.constructor){case Int8Array:return new w;case Uint8Array:return new x;case Int16Array:return new O;case Uint16Array:return new S;case Int32Array:return new T;case Uint32Array:return new E;case Float32Array:return new N;case Float64Array:return new L;default:throw new Error("array type not supported")}}var _t=l(()=>{z()});function rt(r,t,e){let o=Mt(t.value),a=e||It(t);return new b(r,new B(t.size,new b("value",o)),!1,a)}function It(r){let t=new Map;return"byteOffset"in r&&t.set("byteOffset",r.byteOffset.toString(10)),"byteStride"in r&&t.set("byteStride",r.byteStride.toString(10)),"normalized"in r&&t.set("normalized",r.normalized.toString()),t}var wt=l(()=>{z();_t()});var W=l(()=>{lt();wt();z()});function Ot(r,t,e){let o=xt(t.metadata),a=[],i=Me(t.attributes);for(let s in r){let c=r[s],u=Tt(s,c,i[s]);a.push(u)}if(e){let s=Tt("indices",e);a.push(s)}return new y(a,o)}function Me(r){let t={};for(let e in r){let o=r[e];t[o.name||"undefined"]=o}return t}function Tt(r,t,e){let o=e?xt(e.metadata):void 0;return rt(r,t,o)}function xt(r){let t=new Map;for(let e in r)t.set(`${e}.string`,JSON.stringify(r[e]));return t}var St=l(()=>{W();W()});function we(r,t){switch(t){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32;default:return r.DT_INVALID}}function Oe(r){let t=r.size(),e=new Int32Array(t);for(let o=0;o<t;o++)e[o]=r.GetValue(o);return e}function Te(r){let t=r.size(),e=new Int32Array(t);for(let o=0;o<t;o++)e[o]=r.GetValue(o);return e}var Et,_e,Ie,$,Ft=l(()=>{W();St();Et={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},_e={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},Ie=4,$=class{constructor(t){this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(t,e={}){let o=new this.draco.DecoderBuffer;o.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(e);let a=this.decoder.GetEncodedGeometryType(o),i=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,i);break;case this.draco.POINT_CLOUD:s=this.decoder.DecodeBufferToPointCloud(o,i);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!s.ok()||!i.ptr){let M=`DRACO decompression failed: ${s.error_msg()}`;throw new Error(M)}let c=this._getDracoLoaderData(i,a,e),u=this._getMeshData(i,c,e),m=V(u.attributes),h=Ot(u.attributes,c,u.indices);return{loader:"draco",loaderData:c,header:{vertexCount:i.num_points(),boundingBox:m},...u,schema:h}}finally{this.draco.destroy(o),i&&this.draco.destroy(i)}}_getDracoLoaderData(t,e,o){let a=this._getTopLevelMetadata(t),i=this._getDracoAttributes(t,o);return{geometry_type:e,num_attributes:t.num_attributes(),num_points:t.num_points(),num_faces:t instanceof this.draco.Mesh?t.num_faces():0,metadata:a,attributes:i}}_getDracoAttributes(t,e){let o={};for(let a=0;a<t.num_attributes();a++){let i=this.decoder.GetAttribute(t,a),s=this._getAttributeMetadata(t,a);o[i.unique_id()]={unique_id:i.unique_id(),attribute_type:i.attribute_type(),data_type:i.data_type(),num_components:i.num_components(),byte_offset:i.byte_offset(),byte_stride:i.byte_stride(),normalized:i.normalized(),attribute_index:a,metadata:s};let c=this._getQuantizationTransform(i,e);c&&(o[i.unique_id()].quantization_transform=c);let u=this._getOctahedronTransform(i,e);u&&(o[i.unique_id()].octahedron_transform=u)}return o}_getMeshData(t,e,o){let a=this._getMeshAttributes(e,t,o);if(!a.POSITION)throw new Error("DRACO: No position attribute found.");if(t instanceof this.draco.Mesh)switch(o.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:a,indices:{value:this._getTriangleStripIndices(t),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:a,indices:{value:this._getTriangleListIndices(t),size:1}}}return{topology:"point-list",mode:0,attributes:a}}_getMeshAttributes(t,e,o){let a={};for(let i of Object.values(t.attributes)){let s=this._deduceAttributeName(i,o);i.name=s;let{value:c,size:u}=this._getAttributeValues(e,i);a[s]={value:c,size:u,byteOffset:i.byte_offset,byteStride:i.byte_stride,normalized:i.normalized}}return a}_getTriangleListIndices(t){let o=t.num_faces()*3,a=o*Ie,i=this.draco._malloc(a);try{return this.decoder.GetTrianglesUInt32Array(t,a,i),new Uint32Array(this.draco.HEAPF32.buffer,i,o).slice()}finally{this.draco._free(i)}}_getTriangleStripIndices(t){let e=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(t,e),Te(e)}finally{this.draco.destroy(e)}}_getAttributeValues(t,e){let o=_e[e.data_type],a=e.num_components,s=t.num_points()*a,c=s*o.BYTES_PER_ELEMENT,u=we(this.draco,o),m,h=this.draco._malloc(c);try{let A=this.decoder.GetAttribute(t,e.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(t,A,u,c,h),m=new o(this.draco.HEAPF32.buffer,h,s).slice()}finally{this.draco._free(h)}return{value:m,size:a}}_deduceAttributeName(t,e){let o=t.unique_id;for(let[s,c]of Object.entries(e.extraAttributes||{}))if(c===o)return s;let a=t.attribute_type;for(let s in Et)if(this.draco[s]===a)return Et[s];let i=e.attributeNameEntry||"name";return t.metadata[i]?t.metadata[i].string:`CUSTOM_ATTRIBUTE_${o}`}_getTopLevelMetadata(t){let e=this.decoder.GetMetadata(t);return this._getDracoMetadata(e)}_getAttributeMetadata(t,e){let o=this.decoder.GetAttributeMetadata(t,e);return this._getDracoMetadata(o)}_getDracoMetadata(t){if(!t||!t.ptr)return{};let e={},o=this.metadataQuerier.NumEntries(t);for(let a=0;a<o;a++){let i=this.metadataQuerier.GetEntryName(t,a);e[i]=this._getDracoMetadataField(t,i)}return e}_getDracoMetadataField(t,e){let o=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(t,e,o);let a=Oe(o);return{int:this.metadataQuerier.GetIntEntry(t,e),string:this.metadataQuerier.GetStringEntry(t,e),double:this.metadataQuerier.GetDoubleEntry(t,e),intArray:a}}finally{this.draco.destroy(o)}}_disableAttributeTransforms(t){let{quantizedAttributes:e=[],octahedronAttributes:o=[]}=t,a=[...e,...o];for(let i of a)this.decoder.SkipAttributeTransform(this.draco[i])}_getQuantizationTransform(t,e){let{quantizedAttributes:o=[]}=e,a=t.attribute_type();if(o.map(s=>this.decoder[s]).includes(a)){let s=new this.draco.AttributeQuantizationTransform;try{if(s.InitFromAttribute(t))return{quantization_bits:s.quantization_bits(),range:s.range(),min_values:new Float32Array([1,2,3]).map(c=>s.min_value(c))}}finally{this.draco.destroy(s)}}return null}_getOctahedronTransform(t,e){let{octahedronAttributes:o=[]}=e,a=t.attribute_type();if(o.map(s=>this.decoder[s]).includes(a)){let s=new this.draco.AttributeQuantizationTransform;try{if(s.InitFromAttribute(t))return{quantization_bits:s.quantization_bits()}}finally{this.draco.destroy(s)}}return null}}});var xe,ot,Nt=l(()=>{xe="latest",ot=typeof __VERSION__!="undefined"?__VERSION__:xe;typeof __VERSION__=="undefined"&&console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.")});function Lt(r,t){if(!r)throw new Error(t||"loaders.gl assertion failed.")}var Bt=l(()=>{});var f,Lr,Br,Pt,Pr,D,P,Rr,Rt,Cr,at=l(()=>{f={self:typeof self!="undefined"&&self,window:typeof window!="undefined"&&window,global:typeof global!="undefined"&&global,document:typeof document!="undefined"&&document},Lr=f.self||f.window||f.global||{},Br=f.window||f.self||f.global||{},Pt=f.global||f.self||f.window||{},Pr=f.document||{},D=typeof process!="object"||String(process)!=="[object process]"||process.browser,P=typeof importScripts=="function",Rr=typeof window!="undefined"&&typeof window.orientation!="undefined",Rt=typeof process!="undefined"&&process.version&&/v([0-9]*)/.exec(process.version),Cr=Rt&&parseFloat(Rt[1])||0});var Ct=dt(()=>{});async function I(r,t=null,e={}){return t&&(r=kt(r,t,e)),nt[r]=nt[r]||Fe(r),await nt[r]}function kt(r,t,e){if(r.startsWith("http"))return r;let o=e.modules||{};return o[r]?o[r]:D?e.CDN?(Lt(e.CDN.startsWith("http")),`${e.CDN}/${t}@${Ee}/dist/libs/${r}`):P?`../src/libs/${r}`:`modules/${t}/src/libs/${r}`:`modules/${t}/dist/libs/${r}`}async function Fe(r){if(r.endsWith("wasm"))return await(await fetch(r)).arrayBuffer();if(!D)try{return R&&R.requireFromFile&&await R.requireFromFile(r)}catch{return null}if(P)return importScripts(r);let e=await(await fetch(r)).text();return Ne(e,r)}function Ne(r,t){if(!D)return R.requireFromString&&R.requireFromString(r,t);if(P)return eval.call(Pt,r),null;let e=document.createElement("script");e.id=t;try{e.appendChild(document.createTextNode(r))}catch{e.text=r}return document.body.appendChild(e),null}var R,Se,Ee,nt,Ut=l(()=>{at();R=oe(Ct());Bt();Nt();Se="latest",Ee=typeof ot!="undefined"?ot:Se,nt={}});var it=l(()=>{at();Ut()});async function vt(r){let t=r.modules||{};return t.draco3d?C=C||t.draco3d.createDecoderModule({}).then(e=>({draco:e})):C=C||Ce(r),await C}async function zt(r){let t=r.modules||{};return t.draco3d?k=k||t.draco3d.createEncoderModule({}).then(e=>({draco:e})):k=k||Ue(r),await k}async function Ce(r){let t,e;switch(r.draco&&r.draco.decoderType){case"js":t=await I(Le,"draco",r);break;case"wasm":default:[t,e]=await Promise.all([await I(Be,"draco",r),await I(Pe,"draco",r)])}return t=t||globalThis.DracoDecoderModule,await ke(t,e)}function ke(r,t){let e={};return t&&(e.wasmBinary=t),new Promise(o=>{r({...e,onModuleLoaded:a=>o({draco:a})})})}async function Ue(r){let t=await I(Re,"draco",r);return t=t||globalThis.DracoEncoderModule,new Promise(e=>{t({onModuleLoaded:o=>e({draco:o})})})}var G,Le,Be,Pe,Re,C,k,st=l(()=>{it();G="1.4.1",Le=`https://www.gstatic.com/draco/versioned/decoders/${G}/draco_decoder.js`,Be=`https://www.gstatic.com/draco/versioned/decoders/${G}/draco_wasm_wrapper.js`,Pe=`https://www.gstatic.com/draco/versioned/decoders/${G}/draco_decoder.wasm`,Re=`https://raw.githubusercontent.com/google/draco/${G}/javascript/draco_encoder.js`});function $t(r){let t=r.size(),e=new ArrayBuffer(t),o=new Int8Array(e);for(let a=0;a<t;++a)o[a]=r.GetValue(a);return e}function ze(r){return r.entries&&!r.hasOwnProperty("entries")?r.entries():Object.entries(r)}var Wt,ve,j,Gt=l(()=>{Wt={POSITION:"POSITION",NORMAL:"NORMAL",COLOR_0:"COLOR",TEXCOORD_0:"TEX_COORD"},ve=()=>{},j=class{constructor(t){this.draco=t,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(t){t&&this.draco.destroy(t)}encodeSync(t,e={}){return this.log=ve,this._setOptions(e),e.pointcloud?this._encodePointCloud(t,e):this._encodeMesh(t,e)}_getAttributesFromMesh(t){let e={...t,...t.attributes};return t.indices&&(e.indices=t.indices),e}_encodePointCloud(t,e){let o=new this.draco.PointCloud;e.metadata&&this._addGeometryMetadata(o,e.metadata);let a=this._getAttributesFromMesh(t);this._createDracoPointCloud(o,a,e);let i=new this.draco.DracoInt8Array;try{let s=this.dracoEncoder.EncodePointCloudToDracoBuffer(o,!1,i);if(!(s>0))throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${o.num_points()} points
|
|
1
|
+
(()=>{var Xt=Object.create;var U=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames;var Kt=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var ct=r=>U(r,"__esModule",{value:!0});var l=(r,t)=>()=>(r&&(t=r(r=0)),t);var dt=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ee=(r,t)=>{ct(r);for(var e in t)U(r,e,{get:t[e],enumerable:!0})},re=(r,t,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Zt(t))!te.call(r,o)&&o!=="default"&&U(r,o,{get:()=>t[o],enumerable:!(e=Jt(t,o))||e.enumerable});return r},oe=r=>re(ct(U(r!=null?Xt(Kt(r)):{},"default",r&&r.__esModule&&"default"in r?{get:()=>r.default,enumerable:!0}:{value:r,enumerable:!0})),r);var ae,V,ut=l(()=>{ae="beta",V=typeof __VERSION__!="undefined"?__VERSION__:ae;typeof __VERSION__=="undefined"&&console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.")});function lt(r,t){if(!r)throw new Error(t||"loaders.gl assertion failed.")}var mt=l(()=>{});var f,Je,Ze,pt,Ke,b,w,tr,yt,er,Q=l(()=>{f={self:typeof self!="undefined"&&self,window:typeof window!="undefined"&&window,global:typeof global!="undefined"&&global,document:typeof document!="undefined"&&document},Je=f.self||f.window||f.global||{},Ze=f.window||f.self||f.global||{},pt=f.global||f.self||f.window||{},Ke=f.document||{},b=typeof process!="object"||String(process)!=="[object process]"||process.browser,w=typeof importScripts=="function",tr=typeof window!="undefined"&&typeof window.orientation!="undefined",yt=typeof process!="undefined"&&process.version&&/v([0-9]*)/.exec(process.version),er=yt&&parseFloat(yt[1])||0});var ht=dt(()=>{});async function _(r,t=null,e={}){return t&&(r=ft(r,t,e)),Y[r]=Y[r]||se(r),await Y[r]}function ft(r,t,e){if(r.startsWith("http"))return r;let o=e.modules||{};return o[r]?o[r]:b?e.CDN?(lt(e.CDN.startsWith("http")),`${e.CDN}/${t}@${ie}/dist/libs/${r}`):w?`../src/libs/${r}`:`modules/${t}/src/libs/${r}`:`modules/${t}/dist/libs/${r}`}async function se(r){if(r.endsWith("wasm"))return await(await fetch(r)).arrayBuffer();if(!b)try{return O&&O.requireFromFile&&await O.requireFromFile(r)}catch{return null}if(w)return importScripts(r);let e=await(await fetch(r)).text();return ce(e,r)}function ce(r,t){if(!b)return O.requireFromString&&O.requireFromString(r,t);if(w)return eval.call(pt,r),null;let e=document.createElement("script");e.id=t;try{e.appendChild(document.createTextNode(r))}catch{e.text=r}return document.body.appendChild(e),null}var O,ne,ie,Y,bt=l(()=>{Q();O=oe(ht());mt();ut();ne="beta",ie=typeof V!="undefined"?V:ne,Y={}});var v=l(()=>{Q();bt()});var I,z=l(()=>{I=typeof __VERSION__!="undefined"?__VERSION__:"latest"});var de,H,gt=l(()=>{v();z();de={draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}},H={name:"Draco",id:b?"draco":"draco-nodejs",module:"draco",shapes:["mesh"],version:I,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:de}});function X(r){let t=1/0,e=1/0,o=1/0,a=-1/0,i=-1/0,s=-1/0,c=r.POSITION?r.POSITION.value:[],u=c&&c.length;for(let m=0;m<u;m+=3){let h=c[m],D=c[m+1],M=c[m+2];t=h<t?h:t,e=D<e?D:e,o=M<o?M:o,a=h>a?h:a,i=D>i?D:i,s=M>s?M:s}return[[t,e,o],[a,i,s]]}var At=l(()=>{});function Dt(r,t){if(!r)throw new Error(t||"loader assertion failed.")}var Mt=l(()=>{});function ue(r){let t={};for(let e of r)t[e.name]&&console.warn("Schema: duplicated field name",e.name,e),t[e.name]=!0}function _t(r,t){return new Map([...r||new Map,...t||new Map])}var y,It=l(()=>{Mt();y=class{constructor(t,e){Dt(Array.isArray(t)),ue(t),this.fields=t,this.metadata=e||new Map}compareTo(t){if(this.metadata!==t.metadata||this.fields.length!==t.fields.length)return!1;for(let e=0;e<this.fields.length;++e)if(!this.fields[e].compareTo(t.fields[e]))return!1;return!0}select(...t){let e=Object.create(null);for(let a of t)e[a]=!0;let o=this.fields.filter(a=>e[a.name]);return new y(o,this.metadata)}selectAt(...t){let e=t.map(o=>this.fields[o]).filter(Boolean);return new y(e,this.metadata)}assign(t){let e,o=this.metadata;if(t instanceof y){let s=t;e=s.fields,o=_t(_t(new Map,this.metadata),s.metadata)}else e=t;let a=Object.create(null);for(let s of this.fields)a[s.name]=s;for(let s of e)a[s.name]=s;let i=Object.values(a);return new y(i,o)}}});var g,wt=l(()=>{g=class{constructor(t,e,o=!1,a=new Map){this.name=t,this.type=e,this.nullable=o,this.metadata=a}get typeId(){return this.type&&this.type.typeId}clone(){return new g(this.name,this.type,this.nullable,this.metadata)}compareTo(t){return this.name===t.name&&this.type===t.type&&this.nullable===t.nullable&&this.metadata===t.metadata}toString(){return`${this.type}${this.nullable?", nullable":""}${this.metadata?`, metadata: ${this.metadata}`:""}`}}});var d,Ot=l(()=>{(function(n){n[n.NONE=0]="NONE",n[n.Null=1]="Null",n[n.Int=2]="Int",n[n.Float=3]="Float",n[n.Binary=4]="Binary",n[n.Utf8=5]="Utf8",n[n.Bool=6]="Bool",n[n.Decimal=7]="Decimal",n[n.Date=8]="Date",n[n.Time=9]="Time",n[n.Timestamp=10]="Timestamp",n[n.Interval=11]="Interval",n[n.List=12]="List",n[n.Struct=13]="Struct",n[n.Union=14]="Union",n[n.FixedSizeBinary=15]="FixedSizeBinary",n[n.FixedSizeList=16]="FixedSizeList",n[n.Map=17]="Map",n[n.Dictionary=-1]="Dictionary",n[n.Int8=-2]="Int8",n[n.Int16=-3]="Int16",n[n.Int32=-4]="Int32",n[n.Int64=-5]="Int64",n[n.Uint8=-6]="Uint8",n[n.Uint16=-7]="Uint16",n[n.Uint32=-8]="Uint32",n[n.Uint64=-9]="Uint64",n[n.Float16=-10]="Float16",n[n.Float32=-11]="Float32",n[n.Float64=-12]="Float64",n[n.DateDay=-13]="DateDay",n[n.DateMillisecond=-14]="DateMillisecond",n[n.TimestampSecond=-15]="TimestampSecond",n[n.TimestampMillisecond=-16]="TimestampMillisecond",n[n.TimestampMicrosecond=-17]="TimestampMicrosecond",n[n.TimestampNanosecond=-18]="TimestampNanosecond",n[n.TimeSecond=-19]="TimeSecond",n[n.TimeMillisecond=-20]="TimeMillisecond",n[n.TimeMicrosecond=-21]="TimeMicrosecond",n[n.TimeNanosecond=-22]="TimeNanosecond",n[n.DenseUnion=-23]="DenseUnion",n[n.SparseUnion=-24]="SparseUnion",n[n.IntervalDayTime=-25]="IntervalDayTime",n[n.IntervalYearMonth=-26]="IntervalYearMonth"})(d||(d={}))});var p,J,Z,A,T,x,S,E,F,N,Tt,L,B,P,K,tt,le,et,xt,rt,ot,me,at,R,nt,St=l(()=>{Ot();p=class{static isNull(t){return t&&t.typeId===d.Null}static isInt(t){return t&&t.typeId===d.Int}static isFloat(t){return t&&t.typeId===d.Float}static isBinary(t){return t&&t.typeId===d.Binary}static isUtf8(t){return t&&t.typeId===d.Utf8}static isBool(t){return t&&t.typeId===d.Bool}static isDecimal(t){return t&&t.typeId===d.Decimal}static isDate(t){return t&&t.typeId===d.Date}static isTime(t){return t&&t.typeId===d.Time}static isTimestamp(t){return t&&t.typeId===d.Timestamp}static isInterval(t){return t&&t.typeId===d.Interval}static isList(t){return t&&t.typeId===d.List}static isStruct(t){return t&&t.typeId===d.Struct}static isUnion(t){return t&&t.typeId===d.Union}static isFixedSizeBinary(t){return t&&t.typeId===d.FixedSizeBinary}static isFixedSizeList(t){return t&&t.typeId===d.FixedSizeList}static isMap(t){return t&&t.typeId===d.Map}static isDictionary(t){return t&&t.typeId===d.Dictionary}get typeId(){return d.NONE}compareTo(t){return this===t}},J=class extends p{get typeId(){return d.Null}get[Symbol.toStringTag](){return"Null"}toString(){return"Null"}},Z=class extends p{get typeId(){return d.Bool}get[Symbol.toStringTag](){return"Bool"}toString(){return"Bool"}},A=class extends p{constructor(t,e){super();this.isSigned=t,this.bitWidth=e}get typeId(){return d.Int}get[Symbol.toStringTag](){return"Int"}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}},T=class extends A{constructor(){super(!0,8)}},x=class extends A{constructor(){super(!0,16)}},S=class extends A{constructor(){super(!0,32)}},E=class extends A{constructor(){super(!1,8)}},F=class extends A{constructor(){super(!1,16)}},N=class extends A{constructor(){super(!1,32)}},Tt={HALF:16,SINGLE:32,DOUBLE:64},L=class extends p{constructor(t){super();this.precision=t}get typeId(){return d.Float}get[Symbol.toStringTag](){return"Float"}toString(){return`Float${this.precision}`}},B=class extends L{constructor(){super(Tt.SINGLE)}},P=class extends L{constructor(){super(Tt.DOUBLE)}},K=class extends p{constructor(){super()}get typeId(){return d.Binary}toString(){return"Binary"}get[Symbol.toStringTag](){return"Binary"}},tt=class extends p{get typeId(){return d.Utf8}get[Symbol.toStringTag](){return"Utf8"}toString(){return"Utf8"}},le={DAY:0,MILLISECOND:1},et=class extends p{constructor(t){super();this.unit=t}get typeId(){return d.Date}get[Symbol.toStringTag](){return"Date"}toString(){return`Date${(this.unit+1)*32}<${le[this.unit]}>`}},xt={SECOND:1,MILLISECOND:1e3,MICROSECOND:1e6,NANOSECOND:1e9},rt=class extends p{constructor(t,e){super();this.unit=t,this.bitWidth=e}get typeId(){return d.Time}toString(){return`Time${this.bitWidth}<${xt[this.unit]}>`}get[Symbol.toStringTag](){return"Time"}},ot=class extends p{constructor(t,e=null){super();this.unit=t,this.timezone=e}get typeId(){return d.Timestamp}get[Symbol.toStringTag](){return"Timestamp"}toString(){return`Timestamp<${xt[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}},me={DAY_TIME:0,YEAR_MONTH:1},at=class extends p{constructor(t){super();this.unit=t}get typeId(){return d.Interval}get[Symbol.toStringTag](){return"Interval"}toString(){return`Interval<${me[this.unit]}>`}},R=class extends p{constructor(t,e){super();this.listSize=t,this.children=[e]}get typeId(){return d.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[Symbol.toStringTag](){return"FixedSizeList"}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}},nt=class extends p{constructor(t){super();this.children=t}get typeId(){return d.Struct}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}get[Symbol.toStringTag](){return"Struct"}}});var W=l(()=>{It();wt();St()});function Et(r){switch(r.constructor){case Int8Array:return new T;case Uint8Array:return new E;case Int16Array:return new x;case Uint16Array:return new F;case Int32Array:return new S;case Uint32Array:return new N;case Float32Array:return new B;case Float64Array:return new P;default:throw new Error("array type not supported")}}var Ft=l(()=>{W()});function it(r,t,e){let o=Et(t.value),a=e||Nt(t);return new g(r,new R(t.size,new g("value",o)),!1,a)}function Nt(r){let t=new Map;return"byteOffset"in r&&t.set("byteOffset",r.byteOffset.toString(10)),"byteStride"in r&&t.set("byteStride",r.byteStride.toString(10)),"normalized"in r&&t.set("normalized",r.normalized.toString()),t}var Lt=l(()=>{W();Ft()});var $=l(()=>{At();Lt();W()});function Bt(r,t,e){let o=Rt(t.metadata),a=[],i=Te(t.attributes);for(let s in r){let c=r[s],u=Pt(s,c,i[s]);a.push(u)}if(e){let s=Pt("indices",e);a.push(s)}return new y(a,o)}function Te(r){let t={};for(let e in r){let o=r[e];t[o.name||"undefined"]=o}return t}function Pt(r,t,e){let o=e?Rt(e.metadata):void 0;return it(r,t,o)}function Rt(r){let t=new Map;for(let e in r)t.set(`${e}.string`,JSON.stringify(r[e]));return t}var Ct=l(()=>{$();$()});function Ee(r,t){switch(t){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32;default:return r.DT_INVALID}}function Fe(r){let t=r.size(),e=new Int32Array(t);for(let o=0;o<t;o++)e[o]=r.GetValue(o);return e}function Ne(r){let t=r.size(),e=new Int32Array(t);for(let o=0;o<t;o++)e[o]=r.GetValue(o);return e}var kt,xe,Se,G,Ut=l(()=>{$();Ct();kt={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},xe={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},Se=4,G=class{constructor(t){this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(t,e={}){let o=new this.draco.DecoderBuffer;o.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(e);let a=this.decoder.GetEncodedGeometryType(o),i=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,i);break;case this.draco.POINT_CLOUD:s=this.decoder.DecodeBufferToPointCloud(o,i);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!s.ok()||!i.ptr){let M=`DRACO decompression failed: ${s.error_msg()}`;throw new Error(M)}let c=this._getDracoLoaderData(i,a,e),u=this._getMeshData(i,c,e),m=X(u.attributes),h=Bt(u.attributes,c,u.indices);return{loader:"draco",loaderData:c,header:{vertexCount:i.num_points(),boundingBox:m},...u,schema:h}}finally{this.draco.destroy(o),i&&this.draco.destroy(i)}}_getDracoLoaderData(t,e,o){let a=this._getTopLevelMetadata(t),i=this._getDracoAttributes(t,o);return{geometry_type:e,num_attributes:t.num_attributes(),num_points:t.num_points(),num_faces:t instanceof this.draco.Mesh?t.num_faces():0,metadata:a,attributes:i}}_getDracoAttributes(t,e){let o={};for(let a=0;a<t.num_attributes();a++){let i=this.decoder.GetAttribute(t,a),s=this._getAttributeMetadata(t,a);o[i.unique_id()]={unique_id:i.unique_id(),attribute_type:i.attribute_type(),data_type:i.data_type(),num_components:i.num_components(),byte_offset:i.byte_offset(),byte_stride:i.byte_stride(),normalized:i.normalized(),attribute_index:a,metadata:s};let c=this._getQuantizationTransform(i,e);c&&(o[i.unique_id()].quantization_transform=c);let u=this._getOctahedronTransform(i,e);u&&(o[i.unique_id()].octahedron_transform=u)}return o}_getMeshData(t,e,o){let a=this._getMeshAttributes(e,t,o);if(!a.POSITION)throw new Error("DRACO: No position attribute found.");if(t instanceof this.draco.Mesh)switch(o.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:a,indices:{value:this._getTriangleStripIndices(t),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:a,indices:{value:this._getTriangleListIndices(t),size:1}}}return{topology:"point-list",mode:0,attributes:a}}_getMeshAttributes(t,e,o){let a={};for(let i of Object.values(t.attributes)){let s=this._deduceAttributeName(i,o);i.name=s;let{value:c,size:u}=this._getAttributeValues(e,i);a[s]={value:c,size:u,byteOffset:i.byte_offset,byteStride:i.byte_stride,normalized:i.normalized}}return a}_getTriangleListIndices(t){let o=t.num_faces()*3,a=o*Se,i=this.draco._malloc(a);try{return this.decoder.GetTrianglesUInt32Array(t,a,i),new Uint32Array(this.draco.HEAPF32.buffer,i,o).slice()}finally{this.draco._free(i)}}_getTriangleStripIndices(t){let e=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(t,e),Ne(e)}finally{this.draco.destroy(e)}}_getAttributeValues(t,e){let o=xe[e.data_type],a=e.num_components,s=t.num_points()*a,c=s*o.BYTES_PER_ELEMENT,u=Ee(this.draco,o),m,h=this.draco._malloc(c);try{let D=this.decoder.GetAttribute(t,e.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(t,D,u,c,h),m=new o(this.draco.HEAPF32.buffer,h,s).slice()}finally{this.draco._free(h)}return{value:m,size:a}}_deduceAttributeName(t,e){let o=t.unique_id;for(let[s,c]of Object.entries(e.extraAttributes||{}))if(c===o)return s;let a=t.attribute_type;for(let s in kt)if(this.draco[s]===a)return kt[s];let i=e.attributeNameEntry||"name";return t.metadata[i]?t.metadata[i].string:`CUSTOM_ATTRIBUTE_${o}`}_getTopLevelMetadata(t){let e=this.decoder.GetMetadata(t);return this._getDracoMetadata(e)}_getAttributeMetadata(t,e){let o=this.decoder.GetAttributeMetadata(t,e);return this._getDracoMetadata(o)}_getDracoMetadata(t){if(!t||!t.ptr)return{};let e={},o=this.metadataQuerier.NumEntries(t);for(let a=0;a<o;a++){let i=this.metadataQuerier.GetEntryName(t,a);e[i]=this._getDracoMetadataField(t,i)}return e}_getDracoMetadataField(t,e){let o=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(t,e,o);let a=Fe(o);return{int:this.metadataQuerier.GetIntEntry(t,e),string:this.metadataQuerier.GetStringEntry(t,e),double:this.metadataQuerier.GetDoubleEntry(t,e),intArray:a}}finally{this.draco.destroy(o)}}_disableAttributeTransforms(t){let{quantizedAttributes:e=[],octahedronAttributes:o=[]}=t,a=[...e,...o];for(let i of a)this.decoder.SkipAttributeTransform(this.draco[i])}_getQuantizationTransform(t,e){let{quantizedAttributes:o=[]}=e,a=t.attribute_type();if(o.map(s=>this.decoder[s]).includes(a)){let s=new this.draco.AttributeQuantizationTransform;try{if(s.InitFromAttribute(t))return{quantization_bits:s.quantization_bits(),range:s.range(),min_values:new Float32Array([1,2,3]).map(c=>s.min_value(c))}}finally{this.draco.destroy(s)}}return null}_getOctahedronTransform(t,e){let{octahedronAttributes:o=[]}=e,a=t.attribute_type();if(o.map(s=>this.decoder[s]).includes(a)){let s=new this.draco.AttributeQuantizationTransform;try{if(s.InitFromAttribute(t))return{quantization_bits:s.quantization_bits()}}finally{this.draco.destroy(s)}}return null}}});async function vt(r){let t=r.modules||{};return t.draco3d?C=C||t.draco3d.createDecoderModule({}).then(e=>({draco:e})):C=C||Ce(r),await C}async function zt(r){let t=r.modules||{};return t.draco3d?k=k||t.draco3d.createEncoderModule({}).then(e=>({draco:e})):k=k||Ue(r),await k}async function Ce(r){let t,e;switch(r.draco&&r.draco.decoderType){case"js":t=await _(Le,"draco",r);break;case"wasm":default:[t,e]=await Promise.all([await _(Be,"draco",r),await _(Pe,"draco",r)])}return t=t||globalThis.DracoDecoderModule,await ke(t,e)}function ke(r,t){let e={};return t&&(e.wasmBinary=t),new Promise(o=>{r({...e,onModuleLoaded:a=>o({draco:a})})})}async function Ue(r){let t=await _(Re,"draco",r);return t=t||globalThis.DracoEncoderModule,new Promise(e=>{t({onModuleLoaded:o=>e({draco:o})})})}var j,Le,Be,Pe,Re,C,k,st=l(()=>{v();j="1.4.1",Le=`https://www.gstatic.com/draco/versioned/decoders/${j}/draco_decoder.js`,Be=`https://www.gstatic.com/draco/versioned/decoders/${j}/draco_wasm_wrapper.js`,Pe=`https://www.gstatic.com/draco/versioned/decoders/${j}/draco_decoder.wasm`,Re=`https://raw.githubusercontent.com/google/draco/${j}/javascript/draco_encoder.js`});function $t(r){let t=r.size(),e=new ArrayBuffer(t),o=new Int8Array(e);for(let a=0;a<t;++a)o[a]=r.GetValue(a);return e}function ze(r){return r.entries&&!r.hasOwnProperty("entries")?r.entries():Object.entries(r)}var Wt,ve,q,Gt=l(()=>{Wt={POSITION:"POSITION",NORMAL:"NORMAL",COLOR_0:"COLOR",TEXCOORD_0:"TEX_COORD"},ve=()=>{},q=class{constructor(t){this.draco=t,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(t){t&&this.draco.destroy(t)}encodeSync(t,e={}){return this.log=ve,this._setOptions(e),e.pointcloud?this._encodePointCloud(t,e):this._encodeMesh(t,e)}_getAttributesFromMesh(t){let e={...t,...t.attributes};return t.indices&&(e.indices=t.indices),e}_encodePointCloud(t,e){let o=new this.draco.PointCloud;e.metadata&&this._addGeometryMetadata(o,e.metadata);let a=this._getAttributesFromMesh(t);this._createDracoPointCloud(o,a,e);let i=new this.draco.DracoInt8Array;try{let s=this.dracoEncoder.EncodePointCloudToDracoBuffer(o,!1,i);if(!(s>0))throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${o.num_points()} points
|
|
2
2
|
with ${o.num_attributes()} attributes into ${s} bytes`),$t(i)}finally{this.destroyEncodedObject(i),this.destroyEncodedObject(o)}}_encodeMesh(t,e){let o=new this.draco.Mesh;e.metadata&&this._addGeometryMetadata(o,e.metadata);let a=this._getAttributesFromMesh(t);this._createDracoMesh(o,a,e);let i=new this.draco.DracoInt8Array;try{let s=this.dracoEncoder.EncodeMeshToDracoBuffer(o,i);if(s<=0)throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${o.num_points()} points
|
|
3
|
-
with ${o.num_attributes()} attributes into ${s} bytes`),$t(i)}finally{this.destroyEncodedObject(i),this.destroyEncodedObject(o)}}_setOptions(t){if("speed"in t&&this.dracoEncoder.SetSpeedOptions(...t.speed),"method"in t){let e=this.draco[t.method||"MESH_SEQUENTIAL_ENCODING"];this.dracoEncoder.SetEncodingMethod(e)}if("quantization"in t)for(let e in t.quantization){let o=t.quantization[e],a=this.draco[e];this.dracoEncoder.SetAttributeQuantization(a,o)}}_createDracoMesh(t,e,o){let a=o.attributesMetadata||{};try{let i=this._getPositionAttribute(e);if(!i)throw new Error("positions");let s=i.length/3;for(let c in e){let u=e[c];c=Wt[c]||c;let m=this._addAttributeToMesh(t,c,u,s);m!==-1&&this._addAttributeMetadata(t,m,{name:c,...a[c]||{}})}}catch(i){throw this.destroyEncodedObject(t),i}return t}_createDracoPointCloud(t,e,o){let a=o.attributesMetadata||{};try{let i=this._getPositionAttribute(e);if(!i)throw new Error("positions");let s=i.length/3;for(let c in e){let u=e[c];c=Wt[c]||c;let m=this._addAttributeToMesh(t,c,u,s);m!==-1&&this._addAttributeMetadata(t,m,{name:c,...a[c]||{}})}}catch(i){throw this.destroyEncodedObject(t),i}return t}_addAttributeToMesh(t,e,o,a){if(!ArrayBuffer.isView(o))return-1;let i=this._getDracoAttributeType(e),s=o.length/a;if(i==="indices"){let m=o.length/3;return this.log(`Adding attribute ${e}, size ${m}`),this.dracoMeshBuilder.AddFacesToMesh(t,m,o),-1}this.log(`Adding attribute ${e}, size ${s}`);let c=this.dracoMeshBuilder,{buffer:u}=o;switch(o.constructor){case Int8Array:return c.AddInt8Attribute(t,i,a,s,new Int8Array(u));case Int16Array:return c.AddInt16Attribute(t,i,a,s,new Int16Array(u));case Int32Array:return c.AddInt32Attribute(t,i,a,s,new Int32Array(u));case Uint8Array:case Uint8ClampedArray:return c.AddUInt8Attribute(t,i,a,s,new Uint8Array(u));case Uint16Array:return c.AddUInt16Attribute(t,i,a,s,new Uint16Array(u));case Uint32Array:return c.AddUInt32Attribute(t,i,a,s,new Uint32Array(u));case Float32Array:default:return c.AddFloatAttribute(t,i,a,s,new Float32Array(u))}}_getDracoAttributeType(t){switch(t.toLowerCase()){case"indices":return"indices";case"position":case"positions":case"vertices":return this.draco.POSITION;case"normal":case"normals":return this.draco.NORMAL;case"color":case"colors":return this.draco.COLOR;case"texcoord":case"texcoords":return this.draco.TEX_COORD;default:return this.draco.GENERIC}}_getPositionAttribute(t){for(let e in t){let o=t[e];if(this._getDracoAttributeType(e)===this.draco.POSITION)return o}return null}_addGeometryMetadata(t,e){let o=new this.draco.Metadata;this._populateDracoMetadata(o,e),this.dracoMeshBuilder.AddMetadata(t,o)}_addAttributeMetadata(t,e,o){let a=new this.draco.Metadata;this._populateDracoMetadata(a,o),this.dracoMeshBuilder.SetMetadataForAttribute(t,e,a)}_populateDracoMetadata(t,e){for(let[o,a]of ze(e))switch(typeof a){case"number":Math.trunc(a)===a?this.dracoMetadataBuilder.AddIntEntry(t,o,a):this.dracoMetadataBuilder.AddDoubleEntry(t,o,a);break;case"object":a instanceof Int32Array&&this.dracoMetadataBuilder.AddIntEntryArray(t,o,a,a.length);break;case"string":default:this.dracoMetadataBuilder.AddStringEntry(t,o,a)}}}});async function $e(r,t={}){let{draco:e}=await zt(t),o=new
|
|
3
|
+
with ${o.num_attributes()} attributes into ${s} bytes`),$t(i)}finally{this.destroyEncodedObject(i),this.destroyEncodedObject(o)}}_setOptions(t){if("speed"in t&&this.dracoEncoder.SetSpeedOptions(...t.speed),"method"in t){let e=this.draco[t.method||"MESH_SEQUENTIAL_ENCODING"];this.dracoEncoder.SetEncodingMethod(e)}if("quantization"in t)for(let e in t.quantization){let o=t.quantization[e],a=this.draco[e];this.dracoEncoder.SetAttributeQuantization(a,o)}}_createDracoMesh(t,e,o){let a=o.attributesMetadata||{};try{let i=this._getPositionAttribute(e);if(!i)throw new Error("positions");let s=i.length/3;for(let c in e){let u=e[c];c=Wt[c]||c;let m=this._addAttributeToMesh(t,c,u,s);m!==-1&&this._addAttributeMetadata(t,m,{name:c,...a[c]||{}})}}catch(i){throw this.destroyEncodedObject(t),i}return t}_createDracoPointCloud(t,e,o){let a=o.attributesMetadata||{};try{let i=this._getPositionAttribute(e);if(!i)throw new Error("positions");let s=i.length/3;for(let c in e){let u=e[c];c=Wt[c]||c;let m=this._addAttributeToMesh(t,c,u,s);m!==-1&&this._addAttributeMetadata(t,m,{name:c,...a[c]||{}})}}catch(i){throw this.destroyEncodedObject(t),i}return t}_addAttributeToMesh(t,e,o,a){if(!ArrayBuffer.isView(o))return-1;let i=this._getDracoAttributeType(e),s=o.length/a;if(i==="indices"){let m=o.length/3;return this.log(`Adding attribute ${e}, size ${m}`),this.dracoMeshBuilder.AddFacesToMesh(t,m,o),-1}this.log(`Adding attribute ${e}, size ${s}`);let c=this.dracoMeshBuilder,{buffer:u}=o;switch(o.constructor){case Int8Array:return c.AddInt8Attribute(t,i,a,s,new Int8Array(u));case Int16Array:return c.AddInt16Attribute(t,i,a,s,new Int16Array(u));case Int32Array:return c.AddInt32Attribute(t,i,a,s,new Int32Array(u));case Uint8Array:case Uint8ClampedArray:return c.AddUInt8Attribute(t,i,a,s,new Uint8Array(u));case Uint16Array:return c.AddUInt16Attribute(t,i,a,s,new Uint16Array(u));case Uint32Array:return c.AddUInt32Attribute(t,i,a,s,new Uint32Array(u));case Float32Array:default:return c.AddFloatAttribute(t,i,a,s,new Float32Array(u))}}_getDracoAttributeType(t){switch(t.toLowerCase()){case"indices":return"indices";case"position":case"positions":case"vertices":return this.draco.POSITION;case"normal":case"normals":return this.draco.NORMAL;case"color":case"colors":return this.draco.COLOR;case"texcoord":case"texcoords":return this.draco.TEX_COORD;default:return this.draco.GENERIC}}_getPositionAttribute(t){for(let e in t){let o=t[e];if(this._getDracoAttributeType(e)===this.draco.POSITION)return o}return null}_addGeometryMetadata(t,e){let o=new this.draco.Metadata;this._populateDracoMetadata(o,e),this.dracoMeshBuilder.AddMetadata(t,o)}_addAttributeMetadata(t,e,o){let a=new this.draco.Metadata;this._populateDracoMetadata(a,o),this.dracoMeshBuilder.SetMetadataForAttribute(t,e,a)}_populateDracoMetadata(t,e){for(let[o,a]of ze(e))switch(typeof a){case"number":Math.trunc(a)===a?this.dracoMetadataBuilder.AddIntEntry(t,o,a):this.dracoMetadataBuilder.AddDoubleEntry(t,o,a);break;case"object":a instanceof Int32Array&&this.dracoMetadataBuilder.AddIntEntryArray(t,o,a,a.length);break;case"string":default:this.dracoMetadataBuilder.AddStringEntry(t,o,a)}}}});async function $e(r,t={}){let{draco:e}=await zt(t),o=new q(e);try{return o.encodeSync(r,t.draco)}finally{o.destroy()}}var We,jt,qt=l(()=>{Gt();st();z();We={pointcloud:!1,attributeNameEntry:"name"},jt={name:"DRACO",id:"draco",module:"draco",version:I,extensions:["drc"],encode:$e,options:{draco:We}}});var Qt={};ee(Qt,{DracoLoader:()=>Vt,DracoWorkerLoader:()=>H,DracoWriter:()=>jt,DracoWriterWorker:()=>Ge,_TypecheckDracoLoader:()=>qe});async function je(r,t){let{draco:e}=await vt(t),o=new G(e);try{return o.parseSync(r,t?.draco)}finally{o.destroy()}}var Ge,Vt,qe,Yt=l(()=>{gt();Ut();st();z();v();qt();Ge={id:b?"draco-writer":"draco-writer-nodejs",name:"Draco compressed geometry writer",module:"draco",version:I,worker:!0,options:{draco:{},source:null}},Vt={...H,parse:je};qe=Vt});var Qe=dt((so,Ht)=>{var Ve=(Yt(),Qt);globalThis.loaders=globalThis.loaders||{};Ht.exports=Object.assign(globalThis.loaders,Ve)});Qe();})();
|
|
4
4
|
//# sourceMappingURL=dist.min.js.map
|