import{$d as bJ,$f as XX,Aa as FJ,Ad as v,Fd as fJ,Gf as HJ,Hd as l,If as QJ,Kf as WJ,Lb as yJ,Lf as rJ,Mb as GJ,Pf as tJ,Qf as _J,Rd as gJ,Sd as i,Td as r,Ub as PJ,Ud as t,Vb as c,Vd as m,Wb as b,Wf as eJ,_d as h,_f as JX,ae as lJ,ag as YX,be as uJ,bg as ZX,cc as f,cg as $X,dc as k,de as dJ,ed as xJ,ee as e,fd as KJ,fe as cJ,gd as CJ,hd as M,ig as y,jd as $J,ke as pJ,le as mJ,m as MJ,md as qJ,me as nJ,mg as qX,ne as sJ,nf as zJ,o as IJ,oe as aJ,of as N,pa as n,pe as oJ,qa as jJ,ra as vJ,sa as OJ,ta as AJ,ud as d,va as DJ,xa as s,xd as RJ,ya as hJ,yd as p,yf as iJ,yg as HX}from"./chunk-nw9je8wy.js";function JJ(J,X){if(X===PJ)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),J;if(X===b||X===c){let Z=J.getIndex();if(Z===null){let Q=[],q=J.getAttribute("position");if(q!==void 0){for(let W=0;W=2.0 are supported."));return}let W=new jX($,{path:X||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});W.fileLoader.setRequestHeader(this.requestHeader);for(let E=0;E=0&&Q[U]===void 0)console.warn('THREE.GLTFLoader: Unknown extension "'+U+'".')}}W.setExtensions(H),W.setPlugins(Q),W.parse(Z,Y)}parseAsync(J,X){let Z=this;return new Promise(function(Y,$){Z.parse(J,X,Y,$)})}}function AX(){let J={};return{get:function(X){return J[X]},add:function(X,Z){J[X]=Z},remove:function(X){delete J[X]},removeAll:function(){J={}}}}function P(J,X,Z){let Y=J.json.materials[X];if(Y.extensions&&Y.extensions[Z])return Y.extensions[Z];return null}var K={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class QX{constructor(J){this.parser=J,this.name=K.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let J=this.parser,X=this.parser.json.nodes||[];for(let Z=0,Y=X.length;Z=0)throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");else return null;return X.loadTextureImage(J,$.source,H)}}class PX{constructor(J){this.parser=J,this.name=K.EXT_TEXTURE_WEBP}loadTexture(J){let X=this.name,Z=this.parser,Y=Z.json,$=Y.textures[J];if(!$.extensions||!$.extensions[X])return null;let H=$.extensions[X],Q=Y.images[H.source],q=Z.textureLoader;if(Q.uri){let W=Z.options.manager.getHandler(Q.uri);if(W!==null)q=W}return Z.loadTextureImage(J,H.source,q)}}class VX{constructor(J){this.parser=J,this.name=K.EXT_TEXTURE_AVIF}loadTexture(J){let X=this.name,Z=this.parser,Y=Z.json,$=Y.textures[J];if(!$.extensions||!$.extensions[X])return null;let H=$.extensions[X],Q=Y.images[H.source],q=Z.textureLoader;if(Q.uri){let W=Z.options.manager.getHandler(Q.uri);if(W!==null)q=W}return Z.loadTextureImage(J,H.source,q)}}class EJ{constructor(J,X){this.name=X,this.parser=J}loadBufferView(J){let X=this.parser.json,Z=X.bufferViews[J];if(Z.extensions&&Z.extensions[this.name]){let Y=Z.extensions[this.name],$=this.parser.getDependency("buffer",Y.buffer),H=this.parser.options.meshoptDecoder;if(!H||!H.supported)if(X.extensionsRequired&&X.extensionsRequired.indexOf(this.name)>=0)throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");else return null;return $.then(function(Q){let q=Y.byteOffset||0,W=Y.byteLength||0,E=Y.count,U=Y.byteStride,L=new Uint8Array(Q,q,W);if(H.decodeGltfBufferAsync)return H.decodeGltfBufferAsync(E,U,L,Y.mode,Y.filter).then(function(O){return O.buffer});else return H.ready.then(function(){let O=new ArrayBuffer(E*U);return H.decodeGltfBuffer(new Uint8Array(O),E,U,L,Y.mode,Y.filter),O})})}else return null}}class SX{constructor(J){this.name=K.EXT_MESH_GPU_INSTANCING,this.parser=J}createNodeMesh(J){let X=this.parser.json,Z=X.nodes[J];if(!Z.extensions||!Z.extensions[this.name]||Z.mesh===void 0)return null;let Y=X.meshes[Z.mesh];for(let W of Y.primitives)if(W.mode!==S.TRIANGLES&&W.mode!==S.TRIANGLE_STRIP&&W.mode!==S.TRIANGLE_FAN&&W.mode!==void 0)return null;let H=Z.extensions[this.name].attributes,Q=[],q={};for(let W in H)Q.push(this.parser.getDependency("accessor",H[W]).then((E)=>{return q[W]=E,q[W]}));if(Q.length<1)return null;return Q.push(this.parser.createNodeMesh(J)),Promise.all(Q).then((W)=>{let E=W.pop(),U=E.isGroup?E.children:[E],L=W[0].count,O=[];for(let G of U){let R=new d,F=new M,C=new CJ,B=new M(1,1,1),_=new cJ(G.geometry,G.material,L);for(let z=0;z0||J.search(/^data\:image\/jpeg/)===0)return"image/jpeg";if(J.search(/\.webp($|\?)/i)>0||J.search(/^data\:image\/webp/)===0)return"image/webp";if(J.search(/\.ktx2($|\?)/i)>0||J.search(/^data\:image\/ktx2/)===0)return"image/ktx2";return"image/png"}var lX=new d;class jX{constructor(J={},X={}){this.json=J,this.extensions={},this.plugins={},this.options=X,this.cache=new AX,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let Z=!1,Y=-1,$=!1,H=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){let Q=navigator.userAgent;Z=/^((?!chrome|android).)*safari/i.test(Q)===!0;let q=Q.match(/Version\/(\d+)/);Y=Z&&q?parseInt(q[1],10):-1,$=Q.indexOf("Firefox")>-1,H=$?Q.match(/Firefox\/([0-9]+)\./)[1]:-1}if(typeof createImageBitmap>"u"||Z&&Y<17||$&&H<98)this.textureLoader=new eJ(this.options.manager);else this.textureLoader=new qX(this.options.manager);if(this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new _J(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials")this.fileLoader.setWithCredentials(!0)}setExtensions(J){this.extensions=J}setPlugins(J){this.plugins=J}parse(J,X){let Z=this,Y=this.json,$=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(H){return H._markDefs&&H._markDefs()}),Promise.all(this._invokeAll(function(H){return H.beforeRoot&&H.beforeRoot()})).then(function(){return Promise.all([Z.getDependencies("scene"),Z.getDependencies("animation"),Z.getDependencies("camera")])}).then(function(H){let Q={scene:H[0][Y.scene||0],scenes:H[0],animations:H[1],cameras:H[2],asset:Y.asset,parser:Z,userData:{}};return A($,Q,Y),T(Q,Y),Promise.all(Z._invokeAll(function(q){return q.afterRoot&&q.afterRoot(Q)})).then(function(){for(let q of Q.scenes)q.updateMatrixWorld();J(Q)})}).catch(X)}_markDefs(){let J=this.json.nodes||[],X=this.json.skins||[],Z=this.json.meshes||[];for(let Y=0,$=X.length;Y<$;Y++){let H=X[Y].joints;for(let Q=0,q=H.length;Q{let q=this.associations.get(H);if(q!=null)this.associations.set(Q,q);for(let[W,E]of H.children.entries())$(E,Q.children[W])};return $(Z,Y),Y.name+="_instance_"+J.uses[X]++,Y}_invokeOne(J){let X=Object.values(this.plugins);X.push(this);for(let Z=0;Z=2)F.setY(D,I[w*q+1]);if(q>=3)F.setZ(D,I[w*q+2]);if(q>=4)F.setW(D,I[w*q+3]);if(q>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}F.normalized=G}return F})}loadTexture(J){let X=this.json,Z=this.options,$=X.textures[J].source,H=X.images[$],Q=this.textureLoader;if(H.uri){let q=Z.manager.getHandler(H.uri);if(q!==null)Q=q}return this.loadTextureImage(J,$,Q)}loadTextureImage(J,X,Z){let Y=this,$=this.json,H=$.textures[J],Q=$.images[X],q=(Q.uri||Q.bufferView)+":"+H.sampler;if(this.textureCache[q])return this.textureCache[q];let W=this.loadImageSource(X,Z).then(function(E){if(E.flipY=!1,E.name=H.name||Q.name||"",E.name===""&&typeof Q.uri==="string"&&Q.uri.startsWith("data:image/")===!1)E.name=Q.uri;let L=($.samplers||{})[H.sampler]||{};return E.magFilter=NJ[L.magFilter]||s,E.minFilter=NJ[L.minFilter]||FJ,E.wrapS=TJ[L.wrapS]||n,E.wrapT=TJ[L.wrapT]||n,E.generateMipmaps=!E.isCompressedTexture&&E.minFilter!==OJ&&E.minFilter!==s,Y.associations.set(E,{textures:J}),E}).catch(function(){return null});return this.textureCache[q]=W,W}loadImageSource(J,X){let Z=this,Y=this.json,$=this.options;if(this.sourceCache[J]!==void 0)return this.sourceCache[J].then((U)=>U.clone());let H=Y.images[J],Q=self.URL||self.webkitURL,q=H.uri||"",W=!1;if(H.bufferView!==void 0)q=Z.getDependency("bufferView",H.bufferView).then(function(U){W=!0;let L=new Blob([U],{type:H.mimeType});return q=Q.createObjectURL(L),q});else if(H.uri===void 0)throw Error("THREE.GLTFLoader: Image "+J+" is missing URI and bufferView");let E=Promise.resolve(q).then(function(U){return new Promise(function(L,O){let G=L;if(X.isImageBitmapLoader===!0)G=function(R){let F=new qJ(R);F.needsUpdate=!0,L(F)};X.load(y.resolveURL(U,$.path),G,void 0,O)})}).then(function(U){if(W===!0)Q.revokeObjectURL(q);return T(U,H),U.userData.mimeType=H.mimeType||bX(H.uri),U}).catch(function(U){throw console.error("THREE.GLTFLoader: Couldn't load texture",q),U});return this.sourceCache[J]=E,E}assignTexture(J,X,Z,Y){let $=this;return this.getDependency("texture",Z.index).then(function(H){if(!H)return null;if(Z.texCoord!==void 0&&Z.texCoord>0)H=H.clone(),H.channel=Z.texCoord;if($.extensions[K.KHR_TEXTURE_TRANSFORM]){let Q=Z.extensions!==void 0?Z.extensions[K.KHR_TEXTURE_TRANSFORM]:void 0;if(Q){let q=$.associations.get(H);H=$.extensions[K.KHR_TEXTURE_TRANSFORM].extendTexture(H,Q),$.associations.set(H,q)}}if(Y!==void 0)H.colorSpace=Y;return J[X]=H,H})}assignFinalMaterial(J){let{geometry:X,material:Z}=J,Y=X.attributes.tangent===void 0,$=X.attributes.color!==void 0,H=X.attributes.normal===void 0;if(J.isPoints){let Q="PointsMaterial:"+Z.uuid,q=this.cache.get(Q);if(!q)q=new aJ,m.prototype.copy.call(q,Z),q.color.copy(Z.color),q.map=Z.map,q.sizeAttenuation=!1,this.cache.add(Q,q);Z=q}else if(J.isLine){let Q="LineBasicMaterial:"+Z.uuid,q=this.cache.get(Q);if(!q)q=new pJ,m.prototype.copy.call(q,Z),q.color.copy(Z.color),q.map=Z.map,this.cache.add(Q,q);Z=q}if(Y||$||H){let Q="ClonedMaterial:"+Z.uuid+":";if(Y)Q+="derivative-tangents:";if($)Q+="vertex-colors:";if(H)Q+="flat-shading:";let q=this.cache.get(Q);if(!q){if(q=Z.clone(),$)q.vertexColors=!0;if(H)q.flatShading=!0;if(Y){if(q.normalScale)q.normalScale.y*=-1;if(q.clearcoatNormalScale)q.clearcoatNormalScale.y*=-1}this.cache.add(Q,q),this.associations.set(q,this.associations.get(Z))}Z=q}J.material=Z}getMaterialType(){return zJ}loadMaterial(J){let X=this,Z=this.json,Y=this.extensions,$=Z.materials[J],H,Q={},q=$.extensions||{},W=[];if(q[K.KHR_MATERIALS_UNLIT]){let U=Y[K.KHR_MATERIALS_UNLIT];H=U.getMaterialType(),W.push(U.extendParams(Q,$,X))}else{let U=$.pbrMetallicRoughness||{};if(Q.color=new v(1,1,1),Q.opacity=1,Array.isArray(U.baseColorFactor)){let L=U.baseColorFactor;Q.color.setRGB(L[0],L[1],L[2],k),Q.opacity=L[3]}if(U.baseColorTexture!==void 0)W.push(X.assignTexture(Q,"map",U.baseColorTexture,f));if(Q.metalness=U.metallicFactor!==void 0?U.metallicFactor:1,Q.roughness=U.roughnessFactor!==void 0?U.roughnessFactor:1,U.metallicRoughnessTexture!==void 0)W.push(X.assignTexture(Q,"metalnessMap",U.metallicRoughnessTexture)),W.push(X.assignTexture(Q,"roughnessMap",U.metallicRoughnessTexture));H=this._invokeOne(function(L){return L.getMaterialType&&L.getMaterialType(J)}),W.push(Promise.all(this._invokeAll(function(L){return L.extendMaterialParams&&L.extendMaterialParams(J,Q)})))}if($.doubleSided===!0)Q.side=IJ;let E=$.alphaMode||YJ.OPAQUE;if(E===YJ.BLEND)Q.transparent=!0,Q.depthWrite=!1;else if(Q.transparent=!1,E===YJ.MASK)Q.alphaTest=$.alphaCutoff!==void 0?$.alphaCutoff:0.5;if($.normalTexture!==void 0&&H!==h){if(W.push(X.assignTexture(Q,"normalMap",$.normalTexture)),Q.normalScale=new KJ(1,1),$.normalTexture.scale!==void 0){let U=$.normalTexture.scale;Q.normalScale.set(U,U)}}if($.occlusionTexture!==void 0&&H!==h){if(W.push(X.assignTexture(Q,"aoMap",$.occlusionTexture)),$.occlusionTexture.strength!==void 0)Q.aoMapIntensity=$.occlusionTexture.strength}if($.emissiveFactor!==void 0&&H!==h){let U=$.emissiveFactor;Q.emissive=new v().setRGB(U[0],U[1],U[2],k)}if($.emissiveTexture!==void 0&&H!==h)W.push(X.assignTexture(Q,"emissiveMap",$.emissiveTexture,f));return Promise.all(W).then(function(){let U=new H(Q);if($.name)U.name=$.name;if(T(U,$),X.associations.set(U,{materials:J}),$.extensions)A(Y,U,$);return U})}createUniqueName(J){let X=HX.sanitizeNodeName(J||"");if(X in this.nodeNamesUsed)return X+"_"+ ++this.nodeNamesUsed[X];else return this.nodeNamesUsed[X]=0,X}loadGeometries(J){let X=this,Z=this.extensions,Y=this.primitiveCache;function $(Q){return Z[K.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(Q,X).then(function(q){return kJ(q,Q,X)})}let H=[];for(let Q=0,q=J.length;Q0)fX(C,$);if(C.name=X.createUniqueName($.name||"mesh_"+J),T(C,$),F.extensions)A(Y,C,F);X.assignFinalMaterial(C),U.push(C)}for(let O=0,G=U.length;O0){let O=E.userData.pivot,G=U[0];E.pivot=new M().fromArray(O),E.position.x-=O[0],E.position.y-=O[1],E.position.z-=O[2],G.position.set(0,0,0),delete E.userData.pivot}return E})}_loadNodeShallow(J){let X=this.json,Z=this.extensions,Y=this;if(this.nodeCache[J]!==void 0)return this.nodeCache[J];let $=X.nodes[J],H=$.name?Y.createUniqueName($.name):"",Q=[],q=Y._invokeOne(function(W){return W.createNodeMesh&&W.createNodeMesh(J)});if(q)Q.push(q);if($.camera!==void 0)Q.push(Y.getDependency("camera",$.camera).then(function(W){return Y._getNodeRef(Y.cameraCache,$.camera,W)}));return Y._invokeAll(function(W){return W.createNodeAttachment&&W.createNodeAttachment(J)}).forEach(function(W){Q.push(W)}),this.nodeCache[J]=Promise.all(Q).then(function(W){let E;if($.isBone===!0)E=new uJ;else if(W.length>1)E=new p;else if(W.length===1)E=W[0];else E=new RJ;if(E!==W[0])for(let U=0,L=W.length;U1){let U=Y.associations.get(E);Y.associations.set(E,{...U})}return Y.associations.get(E).nodes=J,E}),this.nodeCache[J]}loadScene(J){let X=this.extensions,Z=this.json.scenes[J],Y=this,$=new p;if(Z.name)$.name=Y.createUniqueName(Z.name);if(T($,Z),Z.extensions)A(X,$,Z);let H=Z.nodes||[],Q=[];for(let q=0,W=H.length;q{let U=new Map;for(let[L,O]of Y.associations)if(L instanceof m||L instanceof qJ)U.set(L,O);return E.traverse((L)=>{let O=Y.associations.get(L);if(O!=null)U.set(L,O)}),U};return Y.associations=W($),$})}_createAnimationTracks(J,X,Z,Y,$){let H=[],Q=J.name?J.name:J.uuid,q=[];if(j[$.path]===j.weights)J.traverse(function(L){if(L.morphTargetInfluences)q.push(L.name?L.name:L.uuid)});else q.push(Q);let W;switch(j[$.path]){case j.weights:W=HJ;break;case j.rotation:W=QJ;break;case j.translation:case j.scale:W=WJ;break;default:switch(Z.itemSize){case 1:W=HJ;break;case 2:case 3:default:W=WJ;break}break}let E=Y.interpolation!==void 0?hX[Y.interpolation]:GJ,U=this._getArrayFromAccessor(Z);for(let L=0,O=q.length;L