import{TrianglesDrawMode as Re,TriangleFanDrawMode as W,TriangleStripDrawMode as ce,Loader as xe,LoaderUtils as H,FileLoader as le,MeshPhysicalMaterial as M,Vector2 as ue,Color as O,LinearSRGBColorSpace as y,SRGBColorSpace as G,SpotLight as Ee,PointLight as _e,DirectionalLight as Le,Matrix4 as B,Vector3 as C,InstancedMesh as Se,Quaternion as he,InstancedBufferAttribute as ye,Object3D as fe,TextureLoader as Me,ImageBitmapLoader as we,BufferAttribute as j,InterleavedBuffer as ve,LinearMipmapLinearFilter as de,NearestMipmapLinearFilter as be,LinearMipmapNearestFilter as Ne,NearestMipmapNearestFilter as Ie,LinearFilter as pe,NearestFilter as Oe,RepeatWrapping as Y,MirroredRepeatWrapping as Ce,ClampToEdgeWrapping as De,PointsMaterial as Fe,Material as K,LineBasicMaterial as Pe,MeshStandardMaterial as me,DoubleSide as ke,MeshBasicMaterial as k,PropertyBinding as He,BufferGeometry as Ge,SkinnedMesh as Be,Mesh as Ue,LineSegments as je,Line as Ke,LineLoop as Ve,Points as Xe,Group as V,PerspectiveCamera as ze,MathUtils as qe,OrthographicCamera as We,Skeleton as Ye,AnimationClip as Qe,Bone as Ze,InterpolateDiscrete as Je,InterpolateLinear as ge,InterleavedBufferAttribute as $e,Texture as J,VectorKeyframeTrack as $,NumberKeyframeTrack as ee,QuaternionKeyframeTrack as te,ColorManagement as se,FrontSide as et,Interpolant as tt,Box3 as st,Sphere as nt}from"./three.module-DJHaYUcg.js";function ne(f,t){if(t===Re)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(t===W||t===ce){let e=f.getIndex();if(e===null){const n=[],a=f.getAttribute("position");if(a!==void 0){for(let i=0;i=2.0 are supported."));return}const c=new Ft(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u=0&&a[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(n),c.setPlugins(a),c.parse(o,s)}parseAsync(t,e){const o=this;return new Promise(function(s,r){o.parse(t,e,s,r)})}}function rt(){let f={};return{get:function(t){return f[t]},add:function(t,e){f[t]=e},remove:function(t){delete f[t]},removeAll:function(){f={}}}}const g={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_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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ot{constructor(t){this.parser=t,this.name=g.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let o=0,s=e.length;o=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,n)}}class Tt{constructor(t){this.parser=t,this.name=g.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,o=this.parser,s=o.json,r=s.textures[t];if(!r.extensions||!r.extensions[e])return null;const n=r.extensions[e],a=s.images[n.source];let i=o.textureLoader;if(a.uri){const c=o.options.manager.getHandler(a.uri);c!==null&&(i=c)}return this.detectSupport().then(function(c){if(c)return o.loadTextureImage(t,n.source,i);if(s.extensionsRequired&&s.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return o.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Rt{constructor(t){this.parser=t,this.name=g.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,o=this.parser,s=o.json,r=s.textures[t];if(!r.extensions||!r.extensions[e])return null;const n=r.extensions[e],a=s.images[n.source];let i=o.textureLoader;if(a.uri){const c=o.options.manager.getHandler(a.uri);c!==null&&(i=c)}return this.detectSupport().then(function(c){if(c)return o.loadTextureImage(t,n.source,i);if(s.extensionsRequired&&s.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return o.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class xt{constructor(t){this.name=g.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,o=e.bufferViews[t];if(o.extensions&&o.extensions[this.name]){const s=o.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const i=s.byteOffset||0,c=s.byteLength||0,u=s.count,l=s.byteStride,h=new Uint8Array(a,i,c);return n.decodeGltfBufferAsync?n.decodeGltfBufferAsync(u,l,h,s.mode,s.filter).then(function(d){return d.buffer}):n.ready.then(function(){const d=new ArrayBuffer(u*l);return n.decodeGltfBuffer(new Uint8Array(d),u,l,h,s.mode,s.filter),d})})}else return null}}class Et{constructor(t){this.name=g.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,o=e.nodes[t];if(!o.extensions||!o.extensions[this.name]||o.mesh===void 0)return null;const s=e.meshes[o.mesh];for(const c of s.primitives)if(c.mode!==_.TRIANGLES&&c.mode!==_.TRIANGLE_STRIP&&c.mode!==_.TRIANGLE_FAN&&c.mode!==void 0)return null;const n=o.extensions[this.name].attributes,a=[],i={};for(const c in n)a.push(this.parser.getDependency("accessor",n[c]).then(u=>(i[c]=u,i[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const u=c.pop(),l=u.isGroup?u.children:[u],h=c[0].count,d=[];for(const p of l){const T=new B,m=new C,A=new he,x=new C(1,1,1),E=new Se(p.geometry,p.material,h);for(let R=0;R0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Dt=new B;class Ft{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new rt,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 o=!1,s=!1,r=-1;typeof navigator<"u"&&(o=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,r=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||o||s&&r<98?this.textureLoader=new Me(this.options.manager):this.textureLoader=new we(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new le(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const o=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(n){return n._markDefs&&n._markDefs()}),Promise.all(this._invokeAll(function(n){return n.beforeRoot&&n.beforeRoot()})).then(function(){return Promise.all([o.getDependencies("scene"),o.getDependencies("animation"),o.getDependencies("camera")])}).then(function(n){const a={scene:n[0][s.scene||0],scenes:n[0],animations:n[1],cameras:n[2],asset:s.asset,parser:o,userData:{}};return I(r,a,s),N(a,s),Promise.all(o._invokeAll(function(i){return i.afterRoot&&i.afterRoot(a)})).then(function(){t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],o=this.json.meshes||[];for(let s=0,r=e.length;s{const i=this.associations.get(n);i!=null&&this.associations.set(a,i);for(const[c,u]of n.children.entries())r(u,a.children[c])};return r(o,s),s.name+="_instance_"+t.uses[e]++,s}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let o=0;o=2&&m.setY(v,w[L*i+1]),i>=3&&m.setZ(v,w[L*i+2]),i>=4&&m.setW(v,w[L*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m})}loadTexture(t){const e=this.json,o=this.options,r=e.textures[t].source,n=e.images[r];let a=this.textureLoader;if(n.uri){const i=o.manager.getHandler(n.uri);i!==null&&(a=i)}return this.loadTextureImage(t,r,a)}loadTextureImage(t,e,o){const s=this,r=this.json,n=r.textures[t],a=r.images[e],i=(a.uri||a.bufferView)+":"+n.sampler;if(this.textureCache[i])return this.textureCache[i];const c=this.loadImageSource(e,o).then(function(u){u.flipY=!1,u.name=n.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const h=(r.samplers||{})[n.sampler]||{};return u.magFilter=oe[h.magFilter]||pe,u.minFilter=oe[h.minFilter]||de,u.wrapS=ie[h.wrapS]||Y,u.wrapT=ie[h.wrapT]||Y,s.associations.set(u,{textures:t}),u}).catch(function(){return null});return this.textureCache[i]=c,c}loadImageSource(t,e){const o=this,s=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(l=>l.clone());const n=s.images[t],a=self.URL||self.webkitURL;let i=n.uri||"",c=!1;if(n.bufferView!==void 0)i=o.getDependency("bufferView",n.bufferView).then(function(l){c=!0;const h=new Blob([l],{type:n.mimeType});return i=a.createObjectURL(h),i});else if(n.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const u=Promise.resolve(i).then(function(l){return new Promise(function(h,d){let p=h;e.isImageBitmapLoader===!0&&(p=function(T){const m=new J(T);m.needsUpdate=!0,h(m)}),e.load(H.resolveURL(l,r.path),p,void 0,d)})}).then(function(l){return c===!0&&a.revokeObjectURL(i),l.userData.mimeType=n.mimeType||Ct(n.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",i),l});return this.sourceCache[t]=u,u}assignTexture(t,e,o,s){const r=this;return this.getDependency("texture",o.index).then(function(n){if(!n)return null;if(o.texCoord!==void 0&&o.texCoord>0&&(n=n.clone(),n.channel=o.texCoord),r.extensions[g.KHR_TEXTURE_TRANSFORM]){const a=o.extensions!==void 0?o.extensions[g.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const i=r.associations.get(n);n=r.extensions[g.KHR_TEXTURE_TRANSFORM].extendTexture(n,a),r.associations.set(n,i)}}return s!==void 0&&(n.colorSpace=s),t[e]=n,n})}assignFinalMaterial(t){const e=t.geometry;let o=t.material;const s=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,n=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+o.uuid;let i=this.cache.get(a);i||(i=new Fe,K.prototype.copy.call(i,o),i.color.copy(o.color),i.map=o.map,i.sizeAttenuation=!1,this.cache.add(a,i)),o=i}else if(t.isLine){const a="LineBasicMaterial:"+o.uuid;let i=this.cache.get(a);i||(i=new Pe,K.prototype.copy.call(i,o),i.color.copy(o.color),i.map=o.map,this.cache.add(a,i)),o=i}if(s||r||n){let a="ClonedMaterial:"+o.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),n&&(a+="flat-shading:");let i=this.cache.get(a);i||(i=o.clone(),r&&(i.vertexColors=!0),n&&(i.flatShading=!0),s&&(i.normalScale&&(i.normalScale.y*=-1),i.clearcoatNormalScale&&(i.clearcoatNormalScale.y*=-1)),this.cache.add(a,i),this.associations.set(i,this.associations.get(o))),o=i}t.material=o}getMaterialType(){return me}loadMaterial(t){const e=this,o=this.json,s=this.extensions,r=o.materials[t];let n;const a={},i=r.extensions||{},c=[];if(i[g.KHR_MATERIALS_UNLIT]){const l=s[g.KHR_MATERIALS_UNLIT];n=l.getMaterialType(),c.push(l.extendParams(a,r,e))}else{const l=r.pbrMetallicRoughness||{};if(a.color=new O(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){const h=l.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],y),a.opacity=h[3]}l.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",l.baseColorTexture,G)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",l.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",l.metallicRoughnessTexture))),n=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(t,a)})))}r.doubleSided===!0&&(a.side=ke);const u=r.alphaMode||z.OPAQUE;if(u===z.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===z.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&n!==k&&(c.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new ue(1,1),r.normalTexture.scale!==void 0)){const l=r.normalTexture.scale;a.normalScale.set(l,l)}if(r.occlusionTexture!==void 0&&n!==k&&(c.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&n!==k){const l=r.emissiveFactor;a.emissive=new O().setRGB(l[0],l[1],l[2],y)}return r.emissiveTexture!==void 0&&n!==k&&c.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,G)),Promise.all(c).then(function(){const l=new n(a);return r.name&&(l.name=r.name),N(l,r),e.associations.set(l,{materials:t}),r.extensions&&I(s,l,r),l})}createUniqueName(t){const e=He.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,o=this.extensions,s=this.primitiveCache;function r(a){return o[g.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(i){return ae(i,a,e)})}const n=[];for(let a=0,i=t.length;a0&&It(A,r),A.name=e.createUniqueName(r.name||"mesh_"+t),N(A,r),m.extensions&&I(s,A,m),e.assignFinalMaterial(A),l.push(A)}for(let d=0,p=l.length;d1?u=new V:c.length===1?u=c[0]:u=new fe,u!==c[0])for(let l=0,h=c.length;l{const l=new Map;for(const[h,d]of s.associations)(h instanceof K||h instanceof J)&&l.set(h,d);return u.traverse(h=>{const d=s.associations.get(h);d!=null&&l.set(h,d)}),l};return s.associations=c(r),r})}_createAnimationTracks(t,e,o,s,r){const n=[],a=t.name?t.name:t.uuid,i=[];b[r.path]===b.weights?t.traverse(function(h){h.morphTargetInfluences&&i.push(h.name?h.name:h.uuid)}):i.push(a);let c;switch(b[r.path]){case b.weights:c=ee;break;case b.rotation:c=te;break;case b.position:case b.scale:c=$;break;default:o.itemSize===1?c=ee:c=$;break}const u=s.interpolation!==void 0?vt[s.interpolation]:ge,l=this._getArrayFromAccessor(o);for(let h=0,d=i.length;h