(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if (typeof define === 'function' && define.amd) define([], factory); else if (typeof exports === 'object') exports['loaders'] = factory(); else root['loaders'] = factory();})(globalThis, function () { "use strict";var __exports__=(()=>{var H=Object.create;var E=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var et=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports),rt=(o,t)=>{for(var e in t)E(o,e,{get:t[e],enumerable:!0})},D=(o,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Z(t))!tt.call(o,n)&&n!==e&&E(o,n,{get:()=>t[n],enumerable:!(r=K(t,n))||r.enumerable});return o},w=(o,t,e)=>(D(o,t,"default"),e&&D(e,t,"default")),ot=(o,t,e)=>(e=o!=null?H(J(o)):{},D(t||!o||!o.__esModule?E(e,"default",{value:o,enumerable:!0}):e,o)),nt=o=>D(E({},"__esModule",{value:!0}),o);var F=et((xt,N)=>{N.exports=globalThis.loaders});var g={};rt(g,{DRACO_EXTERNAL_LIBRARIES:()=>u,DRACO_EXTERNAL_LIBRARY_URLS:()=>_,DracoLoader:()=>It,DracoWorkerLoader:()=>I,DracoWriter:()=>Y,DracoWriterWorker:()=>Ot});w(g,ot(F(),1));var y="4.3.1";var I={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:y,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function B(o){switch(o.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 M(o){let t=1/0,e=1/0,r=1/0,n=-1/0,a=-1/0,i=-1/0,s=o.POSITION?o.POSITION.value:[],c=s&&s.length;for(let d=0;dn?l:n,a=h>a?h:a,i=m>i?m:i}return[[t,e,r],[n,a,i]]}function R(o,t,e){let r=B(t.value),n=e||P(t);return{name:o,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:r}]},nullable:!1,metadata:n}}function P(o){let t={};return"byteOffset"in o&&(t.byteOffset=o.byteOffset.toString(10)),"byteStride"in o&&(t.byteStride=o.byteStride.toString(10)),"normalized"in o&&(t.normalized=o.normalized.toString()),t}function U(o,t,e){let r=z(t.metadata),n=[],a=at(t.attributes);for(let i in o){let s=o[i],c=k(i,s,a[i]);n.push(c)}if(e){let i=k("indices",e);n.push(i)}return{fields:n,metadata:r}}function at(o){let t={};for(let e in o){let r=o[e];t[r.name||"undefined"]=r}return t}function k(o,t,e){let r=e?z(e.metadata):void 0;return R(o,t,r)}function z(o){Object.entries(o);let t={};for(let e in o)t[`${e}.string`]=JSON.stringify(o[e]);return t}var W={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},it={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},st=4,b=class{draco;decoder;metadataQuerier;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 r=new this.draco.DecoderBuffer;r.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(e);let n=this.decoder.GetEncodedGeometryType(r),a=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let i;switch(n){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(r,a);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(r,a);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!a.ptr){let m=`DRACO decompression failed: ${i.error_msg()}`;throw new Error(m)}let s=this._getDracoLoaderData(a,n,e),c=this._getMeshData(a,s,e),d=M(c.attributes),l=U(c.attributes,s,c.indices);return{loader:"draco",loaderData:s,header:{vertexCount:a.num_points(),boundingBox:d},...c,schema:l}}finally{this.draco.destroy(r),a&&this.draco.destroy(a)}}_getDracoLoaderData(t,e,r){let n=this._getTopLevelMetadata(t),a=this._getDracoAttributes(t,r);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:n,attributes:a}}_getDracoAttributes(t,e){let r={};for(let n=0;nthis.decoder[i]).includes(n)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(t))return{quantization_bits:i.quantization_bits(),range:i.range(),min_values:new Float32Array([1,2,3]).map(s=>i.min_value(s))}}finally{this.draco.destroy(i)}}return null}_getOctahedronTransform(t,e){let{octahedronAttributes:r=[]}=e,n=t.attribute_type();if(r.map(i=>this.decoder[i]).includes(n)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(t))return{quantization_bits:i.quantization_bits()}}finally{this.draco.destroy(i)}}return null}};function ct(o,t){switch(t){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32;default:return o.DT_INVALID}}function dt(o){let t=o.size(),e=new Int32Array(t);for(let r=0;r({draco:e})):C||=_t(o),await C}async function G(o){let t=o.modules||{};return t.draco3d?S||=t.draco3d.createEncoderModule({}).then(e=>({draco:e})):S||=Tt(o),await S}async function _t(o){let t,e;switch(o.draco&&o.draco.decoderType){case"js":t=await p(_[u.FALLBACK_DECODER],"draco",o,u.FALLBACK_DECODER);break;case"wasm":default:[t,e]=await Promise.all([await p(_[u.DECODER],"draco",o,u.DECODER),await p(_[u.DECODER_WASM],"draco",o,u.DECODER_WASM)])}return t=t||globalThis.DracoDecoderModule,await bt(t,e)}function bt(o,t){let e={};return t&&(e.wasmBinary=t),new Promise(r=>{o({...e,onModuleLoaded:n=>r({draco:n})})})}async function Tt(o){let t=await p(_[u.ENCODER],"draco",o,u.ENCODER);return t=t||globalThis.DracoEncoderModule,new Promise(e=>{t({onModuleLoaded:r=>e({draco:r})})})}var Q={POSITION:"POSITION",NORMAL:"NORMAL",COLOR_0:"COLOR",TEXCOORD_0:"TEX_COORD"},gt=()=>{},T=class{draco;dracoEncoder;dracoMeshBuilder;dracoMetadataBuilder;log;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=gt,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 r=new this.draco.PointCloud;e.metadata&&this._addGeometryMetadata(r,e.metadata);let n=this._getAttributesFromMesh(t);this._createDracoPointCloud(r,n,e);let a=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodePointCloudToDracoBuffer(r,!1,a);if(!(i>0))throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${r.num_points()} points with ${r.num_attributes()} attributes into ${i} bytes`),X(a)}finally{this.destroyEncodedObject(a),this.destroyEncodedObject(r)}}_encodeMesh(t,e){let r=new this.draco.Mesh;e.metadata&&this._addGeometryMetadata(r,e.metadata);let n=this._getAttributesFromMesh(t);this._createDracoMesh(r,n,e);let a=new this.draco.DracoInt8Array;try{let i=this.dracoEncoder.EncodeMeshToDracoBuffer(r,a);if(i<=0)throw new Error("Draco encoding failed.");return this.log(`DRACO encoded ${r.num_points()} points with ${r.num_attributes()} attributes into ${i} bytes`),X(a)}finally{this.destroyEncodedObject(a),this.destroyEncodedObject(r)}}_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 r=t.quantization[e],n=this.draco[e];this.dracoEncoder.SetAttributeQuantization(n,r)}}_createDracoMesh(t,e,r){let n=r.attributesMetadata||{};try{let a=this._getPositionAttribute(e);if(!a)throw new Error("positions");let i=a.length/3;for(let s in e){let c=e[s];s=Q[s]||s;let d=this._addAttributeToMesh(t,s,c,i);d!==-1&&this._addAttributeMetadata(t,d,{name:s,...n[s]||{}})}}catch(a){throw this.destroyEncodedObject(t),a}return t}_createDracoPointCloud(t,e,r){let n=r.attributesMetadata||{};try{let a=this._getPositionAttribute(e);if(!a)throw new Error("positions");let i=a.length/3;for(let s in e){let c=e[s];s=Q[s]||s;let d=this._addAttributeToMesh(t,s,c,i);d!==-1&&this._addAttributeMetadata(t,d,{name:s,...n[s]||{}})}}catch(a){throw this.destroyEncodedObject(t),a}return t}_addAttributeToMesh(t,e,r,n){if(!ArrayBuffer.isView(r))return-1;let a=this._getDracoAttributeType(e),i=r.length/n;if(a==="indices"){let d=r.length/3;return this.log(`Adding attribute ${e}, size ${d}`),this.dracoMeshBuilder.AddFacesToMesh(t,d,r),-1}this.log(`Adding attribute ${e}, size ${i}`);let s=this.dracoMeshBuilder,{buffer:c}=r;switch(r.constructor){case Int8Array:return s.AddInt8Attribute(t,a,n,i,new Int8Array(c));case Int16Array:return s.AddInt16Attribute(t,a,n,i,new Int16Array(c));case Int32Array:return s.AddInt32Attribute(t,a,n,i,new Int32Array(c));case Uint8Array:case Uint8ClampedArray:return s.AddUInt8Attribute(t,a,n,i,new Uint8Array(c));case Uint16Array:return s.AddUInt16Attribute(t,a,n,i,new Uint16Array(c));case Uint32Array:return s.AddUInt32Attribute(t,a,n,i,new Uint32Array(c));case Float32Array:return s.AddFloatAttribute(t,a,n,i,new Float32Array(c));default:return console.warn("Unsupported attribute type",r),-1}}_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 r=t[e];if(this._getDracoAttributeType(e)===this.draco.POSITION)return r}return null}_addGeometryMetadata(t,e){let r=new this.draco.Metadata;this._populateDracoMetadata(r,e),this.dracoMeshBuilder.AddMetadata(t,r)}_addAttributeMetadata(t,e,r){let n=new this.draco.Metadata;this._populateDracoMetadata(n,r),this.dracoMeshBuilder.SetMetadataForAttribute(t,e,n)}_populateDracoMetadata(t,e){for(let[r,n]of Dt(e))switch(typeof n){case"number":Math.trunc(n)===n?this.dracoMetadataBuilder.AddIntEntry(t,r,n):this.dracoMetadataBuilder.AddDoubleEntry(t,r,n);break;case"object":n instanceof Int32Array&&this.dracoMetadataBuilder.AddIntEntryArray(t,r,n,n.length);break;case"string":default:this.dracoMetadataBuilder.AddStringEntry(t,r,n)}}};function X(o){let t=o.size(),e=new ArrayBuffer(t),r=new Int8Array(e);for(let n=0;n