@mappedin/mappedin-js 6.25.0 → 6.26.0

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.
@@ -12755,6 +12755,36 @@ SOFTWARE.
12755
12755
 
12756
12756
  -----------
12757
12757
 
12758
+ The following npm package may be included in this product:
12759
+
12760
+ - preact@10.28.2
12761
+
12762
+ This package contains the following license:
12763
+
12764
+ The MIT License (MIT)
12765
+
12766
+ Copyright (c) 2015-present Jason Miller
12767
+
12768
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12769
+ of this software and associated documentation files (the "Software"), to deal
12770
+ in the Software without restriction, including without limitation the rights
12771
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12772
+ copies of the Software, and to permit persons to whom the Software is
12773
+ furnished to do so, subject to the following conditions:
12774
+
12775
+ The above copyright notice and this permission notice shall be included in all
12776
+ copies or substantial portions of the Software.
12777
+
12778
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12779
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12780
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
12781
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
12782
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
12783
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
12784
+ SOFTWARE.
12785
+
12786
+ -----------
12787
+
12758
12788
  The following npm packages may be included in this product:
12759
12789
 
12760
12790
  - global-prefix@4.0.0
@@ -13384,6 +13414,36 @@ THE SOFTWARE.
13384
13414
 
13385
13415
  -----------
13386
13416
 
13417
+ The following npm package may be included in this product:
13418
+
13419
+ - ktx-parse@1.1.0
13420
+
13421
+ This package contains the following license:
13422
+
13423
+ The MIT License (MIT)
13424
+
13425
+ Copyright (c) 2020 Don McCurdy
13426
+
13427
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13428
+ of this software and associated documentation files (the "Software"), to deal
13429
+ in the Software without restriction, including without limitation the rights
13430
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13431
+ copies of the Software, and to permit persons to whom the Software is
13432
+ furnished to do so, subject to the following conditions:
13433
+
13434
+ The above copyright notice and this permission notice shall be included in all
13435
+ copies or substantial portions of the Software.
13436
+
13437
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13438
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13439
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13440
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13441
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
13442
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
13443
+ SOFTWARE.
13444
+
13445
+ -----------
13446
+
13387
13447
  The following npm package may be included in this product:
13388
13448
 
13389
13449
  - ms@2.1.3
@@ -13474,6 +13534,36 @@ SOFTWARE.
13474
13534
 
13475
13535
  -----------
13476
13536
 
13537
+ The following npm package may be included in this product:
13538
+
13539
+ - property-graph@4.1.0
13540
+
13541
+ This package contains the following license:
13542
+
13543
+ The MIT License (MIT)
13544
+
13545
+ Copyright (c) 2021 Don McCurdy
13546
+
13547
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13548
+ of this software and associated documentation files (the "Software"), to deal
13549
+ in the Software without restriction, including without limitation the rights
13550
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13551
+ copies of the Software, and to permit persons to whom the Software is
13552
+ furnished to do so, subject to the following conditions:
13553
+
13554
+ The above copyright notice and this permission notice shall be included in all
13555
+ copies or substantial portions of the Software.
13556
+
13557
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13558
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13559
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13560
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13561
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
13562
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
13563
+ SOFTWARE.
13564
+
13565
+ -----------
13566
+
13477
13567
  The following npm package may be included in this product:
13478
13568
 
13479
13569
  - react-freeze@1.0.4
@@ -13626,6 +13716,37 @@ SOFTWARE.
13626
13716
 
13627
13717
  -----------
13628
13718
 
13719
+ The following npm packages may be included in this product:
13720
+
13721
+ - @gltf-transform/core@4.4.2
13722
+ - @gltf-transform/extensions@4.4.2
13723
+
13724
+ These packages each contain the following license:
13725
+
13726
+ The MIT License (MIT)
13727
+
13728
+ Copyright (c) 2024 Don McCurdy
13729
+
13730
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13731
+ of this software and associated documentation files (the "Software"), to deal
13732
+ in the Software without restriction, including without limitation the rights
13733
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13734
+ copies of the Software, and to permit persons to whom the Software is
13735
+ furnished to do so, subject to the following conditions:
13736
+
13737
+ The above copyright notice and this permission notice shall be included in all
13738
+ copies or substantial portions of the Software.
13739
+
13740
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13741
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13742
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13743
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
13744
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
13745
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
13746
+ SOFTWARE.
13747
+
13748
+ -----------
13749
+
13629
13750
  The following npm package may be included in this product:
13630
13751
 
13631
13752
  - i18next@25.8.0
@@ -1 +1 @@
1
- import{$ as H,B as Ae,C as Me,Ha as D,N as P,P as Ee,Q as O,T as Ie,U as Re,a as ae,ca as Ne,f as ce,fa as S,i as ue,j as le,k as fe,l as he,m as pe,n as de,nb as v,o as xe,p as ye,pa as G,q as ge,u as Te,v as we,w as me}from"./chunk-CO4ZOCZ7.js";import"./chunk-PWEV3AFA.js";ae();var be={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]},z=class{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new j(e)}),this.register(function(e){return new q(e)}),this.register(function(e){return new Z(e)}),this.register(function(e){return new Q(e)}),this.register(function(e){return new $(e)}),this.register(function(e){return new ee(e)}),this.register(function(e){return new X(e)}),this.register(function(e){return new W(e)}),this.register(function(e){return new J(e)}),this.register(function(e){return new se(e)}),this.register(function(e){return new te(e)}),this.register(function(e){return new ne(e)}),this.register(function(e){return new ie(e)}),this.register(function(e){return new re(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setTextureUtils(e){return this.textureUtils=e,this}parse(e,s,n,t){let i=new K,r=[];for(let o=0,c=this.pluginCallbacks.length;o<c;o++)r.push(this.pluginCallbacks[o](i));i.setPlugins(r),i.setTextureUtils(this.textureUtils),i.writeAsync(e,s,t).catch(n)}parseAsync(e,s){let n=this;return new Promise(function(t,i){n.parse(e,t,i,s)})}},y={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},V="KHR_mesh_quantization",R={};R[he]=y.NEAREST;R[pe]=y.NEAREST_MIPMAP_NEAREST;R[de]=y.NEAREST_MIPMAP_LINEAR;R[xe]=y.LINEAR;R[ye]=y.LINEAR_MIPMAP_NEAREST;R[ge]=y.LINEAR_MIPMAP_LINEAR;R[le]=y.CLAMP_TO_EDGE;R[ue]=y.REPEAT;R[fe]=y.MIRRORED_REPEAT;var Se={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Fe=new Ne,_e=12,ze=1179937895,Be=2,Ue=8,Pe=1313821514,De=5130562;function F(a,e){return a.length===e.length&&a.every(function(s,n){return s===e[n]})}function ke(a){return new TextEncoder().encode(a).buffer}function He(a){return F(a.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Ge(a,e,s){let n={min:new Array(a.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(a.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let t=e;t<e+s;t++)for(let i=0;i<a.itemSize;i++){let r;a.itemSize>4?r=a.array[t*a.itemSize+i]:(i===0?r=a.getX(t):i===1?r=a.getY(t):i===2?r=a.getZ(t):i===3&&(r=a.getW(t)),a.normalized===!0&&(r=P.normalize(r,a.array))),n.min[i]=Math.min(n.min[i],r),n.max[i]=Math.max(n.max[i],r)}return n}function Le(a){return Math.ceil(a/4)*4}function Y(a,e=0){let s=Le(a.byteLength);if(s!==a.byteLength){let n=new Uint8Array(s);if(n.set(new Uint8Array(a)),e!==0)for(let t=a.byteLength;t<s;t++)n[t]=e;return n.buffer}return a}function Ce(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function Ve(a,e){if(a.toBlob!==void 0)return new Promise(n=>a.toBlob(n,e));let s;return e==="image/jpeg"?s=.92:e==="image/webp"&&(s=.8),a.convertToBlob({type:e,quality:s})}var K=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r178"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,s,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);let t=this,i=t.buffers,r=t.json;n=t.options;let o=t.extensionsUsed,c=t.extensionsRequired,l=new Blob(i,{type:"application/octet-stream"}),h=Object.keys(o),u=Object.keys(c);if(h.length>0&&(r.extensionsUsed=h),u.length>0&&(r.extensionsRequired=u),r.buffers&&r.buffers.length>0&&(r.buffers[0].byteLength=l.size),n.binary===!0){let T=new FileReader;T.readAsArrayBuffer(l),T.onloadend=function(){let f=Y(T.result),p=new DataView(new ArrayBuffer(Ue));p.setUint32(0,f.byteLength,!0),p.setUint32(4,De,!0);let d=Y(ke(JSON.stringify(r)),32),g=new DataView(new ArrayBuffer(Ue));g.setUint32(0,d.byteLength,!0),g.setUint32(4,Pe,!0);let A=new ArrayBuffer(_e),N=new DataView(A);N.setUint32(0,ze,!0),N.setUint32(4,Be,!0);let B=_e+g.byteLength+d.byteLength+p.byteLength+f.byteLength;N.setUint32(8,B,!0);let x=new Blob([A,g,d,p,f],{type:"application/octet-stream"}),w=new FileReader;w.readAsArrayBuffer(x),w.onloadend=function(){s(w.result)}}}else if(r.buffers&&r.buffers.length>0){let T=new FileReader;T.readAsDataURL(l),T.onloadend=function(){let f=T.result;r.buffers[0].uri=f,s(r)}}else s(r)}serializeUserData(e,s){if(Object.keys(e.userData).length===0)return;let n=this.options,t=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){s.extensions===void 0&&(s.extensions={});for(let r in i.gltfExtensions)s.extensions[r]=i.gltfExtensions[r],t[r]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(s.extras=i)}catch(i){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+i.message)}}getUID(e,s=!1){if(this.uids.has(e)===!1){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(s)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let n=new O;for(let t=0,i=e.count;t<i;t++)if(Math.abs(n.fromBufferAttribute(e,t).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let s=this.cache;if(s.attributesNormalized.has(e))return s.attributesNormalized.get(e);let n=e.clone(),t=new O;for(let i=0,r=n.count;i<r;i++)t.fromBufferAttribute(n,i),t.x===0&&t.y===0&&t.z===0?t.setX(1):t.normalize(),n.setXYZ(i,t.x,t.y,t.z);return s.attributesNormalized.set(e,n),n}applyTextureTransform(e,s){let n=!1,t={};(s.offset.x!==0||s.offset.y!==0)&&(t.offset=s.offset.toArray(),n=!0),s.rotation!==0&&(t.rotation=s.rotation,n=!0),(s.repeat.x!==1||s.repeat.y!==1)&&(t.scale=s.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=t,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,s){if(e===s)return e;function n(f){return f.colorSpace===Me?function(d){return d<.04045?d*.0773993808:Math.pow(d*.9478672986+.0521327014,2.4)}:function(d){return d}}e instanceof D&&(e=await this.decompressTextureAsync(e)),s instanceof D&&(s=await this.decompressTextureAsync(s));let t=e?e.image:null,i=s?s.image:null,r=Math.max(t?t.width:0,i?i.width:0),o=Math.max(t?t.height:0,i?i.height:0),c=Ce();c.width=r,c.height=o;let l=c.getContext("2d",{willReadFrequently:!0});l.fillStyle="#00ffff",l.fillRect(0,0,r,o);let h=l.getImageData(0,0,r,o);if(t){l.drawImage(t,0,0,r,o);let f=n(e),p=l.getImageData(0,0,r,o).data;for(let d=2;d<p.length;d+=4)h.data[d]=f(p[d]/256)*256}if(i){l.drawImage(i,0,0,r,o);let f=n(s),p=l.getImageData(0,0,r,o).data;for(let d=1;d<p.length;d+=4)h.data[d]=f(p[d]/256)*256}l.putImageData(h,0,0);let T=(e||s).clone();return T.source=new Re(c),T.colorSpace=Ae,T.channel=(e||s).channel,e&&s&&e.channel!==s.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),T}async decompressTextureAsync(e,s=1/0){if(this.textureUtils===null)throw new Error("THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.");return await this.textureUtils.decompress(e,s)}processBuffer(e){let s=this.json,n=this.buffers;return s.buffers||(s.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,s,n,t,i){let r=this.json;r.bufferViews||(r.bufferViews=[]);let o;switch(s){case y.BYTE:case y.UNSIGNED_BYTE:o=1;break;case y.SHORT:case y.UNSIGNED_SHORT:o=2;break;default:o=4}let c=e.itemSize*o;i===y.ARRAY_BUFFER&&(c=Math.ceil(c/4)*4);let l=Le(t*c),h=new DataView(new ArrayBuffer(l)),u=0;for(let p=n;p<n+t;p++){for(let d=0;d<e.itemSize;d++){let g;e.itemSize>4?g=e.array[p*e.itemSize+d]:(d===0?g=e.getX(p):d===1?g=e.getY(p):d===2?g=e.getZ(p):d===3&&(g=e.getW(p)),e.normalized===!0&&(g=P.normalize(g,e.array))),s===y.FLOAT?h.setFloat32(u,g,!0):s===y.INT?h.setInt32(u,g,!0):s===y.UNSIGNED_INT?h.setUint32(u,g,!0):s===y.SHORT?h.setInt16(u,g,!0):s===y.UNSIGNED_SHORT?h.setUint16(u,g,!0):s===y.BYTE?h.setInt8(u,g):s===y.UNSIGNED_BYTE&&h.setUint8(u,g),u+=o}u%c!==0&&(u+=c-u%c)}let T={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:l};return i!==void 0&&(T.target=i),i===y.ARRAY_BUFFER&&(T.byteStride=c),this.byteOffset+=l,r.bufferViews.push(T),{id:r.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let s=this,n=s.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(t){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let r=Y(i.result),o={buffer:s.processBuffer(r),byteOffset:s.byteOffset,byteLength:r.byteLength};s.byteOffset+=r.byteLength,t(n.bufferViews.push(o)-1)}})}processAccessor(e,s,n,t){let i=this.json,r={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"},o;if(e.array.constructor===Float32Array)o=y.FLOAT;else if(e.array.constructor===Int32Array)o=y.INT;else if(e.array.constructor===Uint32Array)o=y.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=y.SHORT;else if(e.array.constructor===Uint16Array)o=y.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=y.BYTE;else if(e.array.constructor===Uint8Array)o=y.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(t===void 0||t===1/0)&&(t=e.count),t===0)return null;let c=Ge(e,n,t),l;s!==void 0&&(l=e===s.index?y.ELEMENT_ARRAY_BUFFER:y.ARRAY_BUFFER);let h=this.processBufferView(e,o,n,t,l),u={bufferView:h.id,byteOffset:h.byteOffset,componentType:o,count:t,max:c.max,min:c.min,type:r[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(u)-1}processImage(e,s,n,t="image/png"){if(e!==null){let i=this,r=i.cache,o=i.json,c=i.options,l=i.pending;r.images.has(e)||r.images.set(e,{});let h=r.images.get(e),u=t+":flipY/"+n.toString();if(h[u]!==void 0)return h[u];o.images||(o.images=[]);let T={mimeType:t},f=Ce();f.width=Math.min(e.width,c.maxTextureSize),f.height=Math.min(e.height,c.maxTextureSize);let p=f.getContext("2d",{willReadFrequently:!0});if(n===!0&&(p.translate(0,f.height),p.scale(1,-1)),e.data!==void 0){s!==Te&&console.error("GLTFExporter: Only RGBAFormat is supported.",s),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let g=new Uint8ClampedArray(e.height*e.width*4);for(let A=0;A<g.length;A+=4)g[A+0]=e.data[A+0],g[A+1]=e.data[A+1],g[A+2]=e.data[A+2],g[A+3]=e.data[A+3];p.putImageData(new ImageData(g,e.width,e.height),0,0)}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)p.drawImage(e,0,0,f.width,f.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");c.binary===!0?l.push(Ve(f,t).then(g=>i.processBufferViewImage(g)).then(g=>{T.bufferView=g})):T.uri=Ie.getDataURL(f,t);let d=o.images.push(T)-1;return h[u]=d,d}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let s=this.json;s.samplers||(s.samplers=[]);let n={magFilter:R[e.magFilter],minFilter:R[e.minFilter],wrapS:R[e.wrapS],wrapT:R[e.wrapT]};return s.samplers.push(n)-1}async processTextureAsync(e){let n=this.options,t=this.cache,i=this.json;if(t.textures.has(e))return t.textures.get(e);i.textures||(i.textures=[]),e instanceof D&&(e=await this.decompressTextureAsync(e,n.maxTextureSize));let r=e.userData.mimeType;r==="image/webp"&&(r="image/png");let o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(o.name=e.name),await this._invokeAllAsync(async function(l){l.writeTexture&&await l.writeTexture(e,o)});let c=i.textures.push(o)-1;return t.textures.set(e,c),c}async processMaterialAsync(e){let s=this.cache,n=this.json;if(s.materials.has(e))return s.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let t={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let i=e.color.toArray().concat([e.opacity]);if(F(i,[1,1,1,1])||(t.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(t.pbrMetallicRoughness.metallicFactor=e.metalness,t.pbrMetallicRoughness.roughnessFactor=e.roughness):(t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let o=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),c={index:await this.processTextureAsync(o),texCoord:o.channel};this.applyTextureTransform(c,o),t.pbrMetallicRoughness.metallicRoughnessTexture=c}if(e.map){let o={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(o,e.map),t.pbrMetallicRoughness.baseColorTexture=o}if(e.emissive){let o=e.emissive;if(Math.max(o.r,o.g,o.b)>0&&(t.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let l={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(l,e.emissiveMap),t.emissiveTexture=l}}if(e.normalMap){let o={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(o.scale=e.normalScale.x),this.applyTextureTransform(o,e.normalMap),t.normalTexture=o}if(e.aoMap){let o={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(o.strength=e.aoMapIntensity),this.applyTextureTransform(o,e.aoMap),t.occlusionTexture=o}e.transparent?t.alphaMode="BLEND":e.alphaTest>0&&(t.alphaMode="MASK",t.alphaCutoff=e.alphaTest),e.side===ce&&(t.doubleSided=!0),e.name!==""&&(t.name=e.name),this.serializeUserData(e,t),await this._invokeAllAsync(async function(o){o.writeMaterialAsync&&await o.writeMaterialAsync(e,t)});let r=n.materials.push(t)-1;return s.materials.set(e,r),r}async processMeshAsync(e){let s=this.cache,n=this.json,t=[e.geometry.uuid];if(Array.isArray(e.material))for(let x=0,w=e.material.length;x<w;x++)t.push(e.material[x].uuid);else t.push(e.material.uuid);let i=t.join(":");if(s.meshes.has(i))return s.meshes.get(i);let r=e.geometry,o;e.isLineSegments?o=y.LINES:e.isLineLoop?o=y.LINE_LOOP:e.isLine?o=y.LINE_STRIP:e.isPoints?o=y.POINTS:o=e.material.wireframe?y.LINES:y.TRIANGLES;let c={},l={},h=[],u=[],T={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},f=r.getAttribute("normal");f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),r.setAttribute("normal",this.createNormalizedNormalAttribute(f)));let p=null;for(let x in r.attributes){if(x.slice(0,5)==="morph")continue;let w=r.attributes[x];if(x=T[x]||x.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(x)||(x="_"+x),s.attributes.has(this.getUID(w))){l[x]=s.attributes.get(this.getUID(w));continue}p=null;let m=w.array;x==="JOINTS_0"&&!(m instanceof Uint16Array)&&!(m instanceof Uint8Array)?(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),p=new S(new Uint16Array(m),w.itemSize,w.normalized)):(m instanceof Uint32Array||m instanceof Int32Array)&&!x.startsWith("_")&&(console.warn(`GLTFExporter: Attribute "${x}" converted to type FLOAT.`),p=z.Utils.toFloat32BufferAttribute(w));let I=this.processAccessor(p||w,r);I!==null&&(x.startsWith("_")||this.detectMeshQuantization(x,w),l[x]=I,s.attributes.set(this.getUID(w),I))}if(f!==void 0&&r.setAttribute("normal",f),Object.keys(l).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let x=[],w=[],M={};if(e.morphTargetDictionary!==void 0)for(let m in e.morphTargetDictionary)M[e.morphTargetDictionary[m]]=m;for(let m=0;m<e.morphTargetInfluences.length;++m){let I={},oe=!1;for(let U in r.morphAttributes){if(U!=="position"&&U!=="normal"){oe||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),oe=!0);continue}let b=r.morphAttributes[U][m],k=U.toUpperCase(),C=r.attributes[U];if(s.attributes.has(this.getUID(b,!0))){I[k]=s.attributes.get(this.getUID(b,!0));continue}let L=b.clone();if(!r.morphTargetsRelative)for(let E=0,Oe=b.count;E<Oe;E++)for(let _=0;_<b.itemSize;_++)_===0&&L.setX(E,b.getX(E)-C.getX(E)),_===1&&L.setY(E,b.getY(E)-C.getY(E)),_===2&&L.setZ(E,b.getZ(E)-C.getZ(E)),_===3&&L.setW(E,b.getW(E)-C.getW(E));I[k]=this.processAccessor(L,r),s.attributes.set(this.getUID(C,!0),I[k])}u.push(I),x.push(e.morphTargetInfluences[m]),e.morphTargetDictionary!==void 0&&w.push(M[m])}c.weights=x,w.length>0&&(c.extras={},c.extras.targetNames=w)}let d=Array.isArray(e.material);if(d&&r.groups.length===0)return null;let g=!1;if(d&&r.index===null){let x=[];for(let w=0,M=r.attributes.position.count;w<M;w++)x[w]=w;r.setIndex(x),g=!0}let A=d?e.material:[e.material],N=d?r.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let x=0,w=N.length;x<w;x++){let M={mode:o,attributes:l};if(this.serializeUserData(r,M),u.length>0&&(M.targets=u),r.index!==null){let I=this.getUID(r.index);(N[x].start!==void 0||N[x].count!==void 0)&&(I+=":"+N[x].start+":"+N[x].count),s.attributes.has(I)?M.indices=s.attributes.get(I):(M.indices=this.processAccessor(r.index,r,N[x].start,N[x].count),s.attributes.set(I,M.indices)),M.indices===null&&delete M.indices}let m=await this.processMaterialAsync(A[N[x].materialIndex]);m!==null&&(M.material=m),h.push(M)}g===!0&&r.setIndex(null),c.primitives=h,n.meshes||(n.meshes=[]),await this._invokeAllAsync(function(x){x.writeMesh&&x.writeMesh(e,c)});let B=n.meshes.push(c)-1;return s.meshes.set(i,B),B}detectMeshQuantization(e,s){if(this.extensionsUsed[V])return;let n;switch(s.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}s.normalized&&(n+=" normalized");let t=e.split("_",1)[0];be[t]&&be[t].includes(n)&&(this.extensionsUsed[V]=!0,this.extensionsRequired[V]=!0)}processCamera(e){let s=this.json;s.cameras||(s.cameras=[]);let n=e.isOrthographicCamera,t={type:n?"orthographic":"perspective"};return n?t.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:t.perspective={aspectRatio:e.aspect,yfov:P.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(t.name=e.type),s.cameras.push(t)-1}processAnimation(e,s){let n=this.json,t=this.nodeMap;n.animations||(n.animations=[]),e=z.Utils.mergeMorphTargetTracks(e.clone(),s);let i=e.tracks,r=[],o=[];for(let c=0;c<i.length;++c){let l=i[c],h=v.parseTrackName(l.name),u=v.findNode(s,h.nodeName),T=Se[h.propertyName];if(h.objectName==="bones"&&(u.isSkinnedMesh===!0?u=u.skeleton.getBoneByName(h.objectIndex):u=void 0),!u||!T){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',l.name);continue}let f=1,p=l.values.length/l.times.length;T===Se.morphTargetInfluences&&(p/=u.morphTargetInfluences.length);let d;l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(d="CUBICSPLINE",p/=3):l.getInterpolation()===we?d="STEP":d="LINEAR",o.push({input:this.processAccessor(new S(l.times,f)),output:this.processAccessor(new S(l.values,p)),interpolation:d}),r.push({sampler:o.length-1,target:{node:t.get(u),path:T}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:o,channels:r}),n.animations.length-1}processSkin(e){let s=this.json,n=this.nodeMap,t=s.nodes[n.get(e)],i=e.skeleton;if(i===void 0)return null;let r=e.skeleton.bones[0];if(r===void 0)return null;let o=[],c=new Float32Array(i.bones.length*16),l=new H;for(let u=0;u<i.bones.length;++u)o.push(n.get(i.bones[u])),l.copy(i.boneInverses[u]),l.multiply(e.bindMatrix).toArray(c,u*16);return s.skins===void 0&&(s.skins=[]),s.skins.push({inverseBindMatrices:this.processAccessor(new S(c,16)),joints:o,skeleton:n.get(r)}),t.skin=s.skins.length-1}async processNodeAsync(e){let s=this.json,n=this.options,t=this.nodeMap;s.nodes||(s.nodes=[]);let i={};if(n.trs){let o=e.quaternion.toArray(),c=e.position.toArray(),l=e.scale.toArray();F(o,[0,0,0,1])||(i.rotation=o),F(c,[0,0,0])||(i.translation=c),F(l,[1,1,1])||(i.scale=l)}else e.matrixAutoUpdate&&e.updateMatrix(),He(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==""&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){let o=await this.processMeshAsync(e);o!==null&&(i.mesh=o)}else e.isCamera&&(i.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let r=s.nodes.push(i)-1;if(t.set(e,r),e.children.length>0){let o=[];for(let c=0,l=e.children.length;c<l;c++){let h=e.children[c];if(h.visible||n.onlyVisible===!1){let u=await this.processNodeAsync(h);u!==null&&o.push(u)}}o.length>0&&(i.children=o)}return await this._invokeAllAsync(function(o){o.writeNode&&o.writeNode(e,i)}),r}async processSceneAsync(e){let s=this.json,n=this.options;s.scenes||(s.scenes=[],s.scene=0);let t={};e.name!==""&&(t.name=e.name),s.scenes.push(t);let i=[];for(let r=0,o=e.children.length;r<o;r++){let c=e.children[r];if(c.visible||n.onlyVisible===!1){let l=await this.processNodeAsync(c);l!==null&&i.push(l)}}i.length>0&&(t.nodes=i),this.serializeUserData(e,t)}async processObjectsAsync(e){let s=new G;s.name="AuxScene";for(let n=0;n<e.length;n++)s.children.push(e[n]);await this.processSceneAsync(s)}async processInputAsync(e){let s=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync(function(t){t.beforeParse&&t.beforeParse(e)});let n=[];for(let t=0;t<e.length;t++)e[t]instanceof G?await this.processSceneAsync(e[t]):n.push(e[t]);n.length>0&&await this.processObjectsAsync(n);for(let t=0;t<this.skins.length;++t)this.processSkin(this.skins[t]);for(let t=0;t<s.animations.length;++t)this.processAnimation(s.animations[t],e[0]);await this._invokeAllAsync(function(t){t.afterParse&&t.afterParse(e)})}async _invokeAllAsync(e){for(let s=0,n=this.plugins.length;s<n;s++)await e(this.plugins[s])}},j=class{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,s){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}let n=this.writer,t=n.json,i=n.extensionsUsed,r={};e.name&&(r.name=e.name),r.color=e.color.toArray(),r.intensity=e.intensity,e.isDirectionalLight?r.type="directional":e.isPointLight?(r.type="point",e.distance>0&&(r.range=e.distance)):e.isSpotLight&&(r.type="spot",e.distance>0&&(r.range=e.distance),r.spot={},r.spot.innerConeAngle=(1-e.penumbra)*e.angle,r.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(t.extensions=t.extensions||{},t.extensions[this.name]={lights:[]},i[this.name]=!0);let o=t.extensions[this.name].lights;o.push(r),s.extensions=s.extensions||{},s.extensions[this.name]={light:o.length-1}}},q=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,s){if(!e.isMeshBasicMaterial)return;let t=this.writer.extensionsUsed;s.extensions=s.extensions||{},s.extensions[this.name]={},t[this.name]=!0,s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=.9}},X=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let n=this.writer,t=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let r={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(r,e.clearcoatMap),i.clearcoatTexture=r}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let r={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(r,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=r}if(e.clearcoatNormalMap){let r={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(r.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(r,e.clearcoatNormalMap),i.clearcoatNormalTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},W=class{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;let t=this.writer.extensionsUsed,i={};i.dispersion=e.dispersion,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},J=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let n=this.writer,t=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let r={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(r,e.iridescenceMap),i.iridescenceTexture=r}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let r={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(r,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},Z=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,t=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let r={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(r,e.transmissionMap),i.transmissionTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},Q=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,t=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let r={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(r,e.thicknessMap),i.thicknessTexture=r}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},$=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let t=this.writer.extensionsUsed,i={};i.ior=e.ior,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},ee=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(Fe)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,t=n.extensionsUsed,i={};if(e.specularIntensityMap){let r={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(r,e.specularIntensityMap),i.specularTexture=r}if(e.specularColorMap){let r={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(r,e.specularColorMap),i.specularColorTexture=r}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},se=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let n=this.writer,t=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let r={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(r,e.sheenRoughnessMap),i.sheenRoughnessTexture=r}if(e.sheenColorMap){let r={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(r,e.sheenColorMap),i.sheenColorTexture=r}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},te=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let n=this.writer,t=n.extensionsUsed,i={};if(e.anisotropyMap){let r={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(r,e.anisotropyMap),i.anisotropyTexture=r}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},ne=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let t=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},ie=class{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;let n=this.writer,t=n.extensionsUsed,i={};if(e.bumpMap){let r={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(r,e.bumpMap),i.bumpTexture=r}i.bumpFactor=e.bumpScale,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},re=class{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,s){if(!e.isInstancedMesh)return;let n=this.writer,t=e,i=new Float32Array(t.count*3),r=new Float32Array(t.count*4),o=new Float32Array(t.count*3),c=new H,l=new O,h=new Ee,u=new O;for(let f=0;f<t.count;f++)t.getMatrixAt(f,c),c.decompose(l,h,u),l.toArray(i,f*3),h.toArray(r,f*4),u.toArray(o,f*3);let T={TRANSLATION:n.processAccessor(new S(i,3)),ROTATION:n.processAccessor(new S(r,4)),SCALE:n.processAccessor(new S(o,3))};t.instanceColor&&(T._COLOR_0=n.processAccessor(t.instanceColor)),s.extensions=s.extensions||{},s.extensions[this.name]={attributes:T},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}};z.Utils={insertKeyframe:function(a,e){let n=a.getValueSize(),t=new a.TimeBufferType(a.times.length+1),i=new a.ValueBufferType(a.values.length+n),r=a.createInterpolant(new a.ValueBufferType(n)),o;if(a.times.length===0){t[0]=e;for(let c=0;c<n;c++)i[c]=0;o=0}else if(e<a.times[0]){if(Math.abs(a.times[0]-e)<.001)return 0;t[0]=e,t.set(a.times,1),i.set(r.evaluate(e),0),i.set(a.values,n),o=0}else if(e>a.times[a.times.length-1]){if(Math.abs(a.times[a.times.length-1]-e)<.001)return a.times.length-1;t[t.length-1]=e,t.set(a.times,0),i.set(a.values,0),i.set(r.evaluate(e),a.values.length),o=t.length-1}else for(let c=0;c<a.times.length;c++){if(Math.abs(a.times[c]-e)<.001)return c;if(a.times[c]<e&&a.times[c+1]>e){t.set(a.times.slice(0,c+1),0),t[c+1]=e,t.set(a.times.slice(c+1),c+2),i.set(a.values.slice(0,(c+1)*n),0),i.set(r.evaluate(e),(c+1)*n),i.set(a.values.slice((c+1)*n),(c+2)*n),o=c+1;break}}return a.times=t,a.values=i,o},mergeMorphTargetTracks:function(a,e){let s=[],n={},t=a.tracks;for(let i=0;i<t.length;++i){let r=t[i],o=v.parseTrackName(r.name),c=v.findNode(e,o.nodeName);if(o.propertyName!=="morphTargetInfluences"||o.propertyIndex===void 0){s.push(r);continue}if(r.createInterpolant!==r.InterpolantFactoryMethodDiscrete&&r.createInterpolant!==r.InterpolantFactoryMethodLinear){if(r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),r=r.clone(),r.setInterpolation(me)}let l=c.morphTargetInfluences.length,h=c.morphTargetDictionary[o.propertyIndex];if(h===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let u;if(n[c.uuid]===void 0){u=r.clone();let f=new u.ValueBufferType(l*u.times.length);for(let p=0;p<u.times.length;p++)f[p*l+h]=u.values[p];u.name=(o.nodeName||"")+".morphTargetInfluences",u.values=f,n[c.uuid]=u,s.push(u);continue}let T=r.createInterpolant(new r.ValueBufferType(1));u=n[c.uuid];for(let f=0;f<u.times.length;f++)u.values[f*l+h]=T.evaluate(u.times[f]);for(let f=0;f<r.times.length;f++){let p=this.insertKeyframe(u,r.times[f]);u.values[p*l+h]=r.values[f]}}return a.tracks=s,a},toFloat32BufferAttribute:function(a){let e=new S(new Float32Array(a.count*a.itemSize),a.itemSize,!1);if(!a.normalized&&!a.isInterleavedBufferAttribute)return e.array.set(a.array),e;for(let s=0,n=a.count;s<n;s++)for(let t=0;t<a.itemSize;t++)e.setComponent(s,t,a.getComponent(s,t));return e}};export{z as GLTFExporter};
1
+ import{$ as H,B as Ae,C as Me,Ha as D,N as P,P as Ee,Q as O,T as Ie,U as Re,a as ae,ca as Ne,f as ce,fa as S,i as ue,j as le,k as fe,l as he,m as pe,n as de,nb as v,o as xe,p as ye,pa as G,q as ge,u as Te,v as we,w as me}from"./chunk-3P7B76SS.js";import"./chunk-PWEV3AFA.js";ae();var be={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]},z=class{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new j(e)}),this.register(function(e){return new q(e)}),this.register(function(e){return new Z(e)}),this.register(function(e){return new Q(e)}),this.register(function(e){return new $(e)}),this.register(function(e){return new ee(e)}),this.register(function(e){return new X(e)}),this.register(function(e){return new W(e)}),this.register(function(e){return new J(e)}),this.register(function(e){return new se(e)}),this.register(function(e){return new te(e)}),this.register(function(e){return new ne(e)}),this.register(function(e){return new ie(e)}),this.register(function(e){return new re(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setTextureUtils(e){return this.textureUtils=e,this}parse(e,s,n,t){let i=new K,r=[];for(let o=0,c=this.pluginCallbacks.length;o<c;o++)r.push(this.pluginCallbacks[o](i));i.setPlugins(r),i.setTextureUtils(this.textureUtils),i.writeAsync(e,s,t).catch(n)}parseAsync(e,s){let n=this;return new Promise(function(t,i){n.parse(e,t,i,s)})}},y={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},V="KHR_mesh_quantization",R={};R[he]=y.NEAREST;R[pe]=y.NEAREST_MIPMAP_NEAREST;R[de]=y.NEAREST_MIPMAP_LINEAR;R[xe]=y.LINEAR;R[ye]=y.LINEAR_MIPMAP_NEAREST;R[ge]=y.LINEAR_MIPMAP_LINEAR;R[le]=y.CLAMP_TO_EDGE;R[ue]=y.REPEAT;R[fe]=y.MIRRORED_REPEAT;var Se={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Fe=new Ne,_e=12,ze=1179937895,Be=2,Ue=8,Pe=1313821514,De=5130562;function F(a,e){return a.length===e.length&&a.every(function(s,n){return s===e[n]})}function ke(a){return new TextEncoder().encode(a).buffer}function He(a){return F(a.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Ge(a,e,s){let n={min:new Array(a.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(a.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let t=e;t<e+s;t++)for(let i=0;i<a.itemSize;i++){let r;a.itemSize>4?r=a.array[t*a.itemSize+i]:(i===0?r=a.getX(t):i===1?r=a.getY(t):i===2?r=a.getZ(t):i===3&&(r=a.getW(t)),a.normalized===!0&&(r=P.normalize(r,a.array))),n.min[i]=Math.min(n.min[i],r),n.max[i]=Math.max(n.max[i],r)}return n}function Le(a){return Math.ceil(a/4)*4}function Y(a,e=0){let s=Le(a.byteLength);if(s!==a.byteLength){let n=new Uint8Array(s);if(n.set(new Uint8Array(a)),e!==0)for(let t=a.byteLength;t<s;t++)n[t]=e;return n.buffer}return a}function Ce(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function Ve(a,e){if(a.toBlob!==void 0)return new Promise(n=>a.toBlob(n,e));let s;return e==="image/jpeg"?s=.92:e==="image/webp"&&(s=.8),a.convertToBlob({type:e,quality:s})}var K=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter r178"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,s,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),await this.processInputAsync(e),await Promise.all(this.pending);let t=this,i=t.buffers,r=t.json;n=t.options;let o=t.extensionsUsed,c=t.extensionsRequired,l=new Blob(i,{type:"application/octet-stream"}),h=Object.keys(o),u=Object.keys(c);if(h.length>0&&(r.extensionsUsed=h),u.length>0&&(r.extensionsRequired=u),r.buffers&&r.buffers.length>0&&(r.buffers[0].byteLength=l.size),n.binary===!0){let T=new FileReader;T.readAsArrayBuffer(l),T.onloadend=function(){let f=Y(T.result),p=new DataView(new ArrayBuffer(Ue));p.setUint32(0,f.byteLength,!0),p.setUint32(4,De,!0);let d=Y(ke(JSON.stringify(r)),32),g=new DataView(new ArrayBuffer(Ue));g.setUint32(0,d.byteLength,!0),g.setUint32(4,Pe,!0);let A=new ArrayBuffer(_e),N=new DataView(A);N.setUint32(0,ze,!0),N.setUint32(4,Be,!0);let B=_e+g.byteLength+d.byteLength+p.byteLength+f.byteLength;N.setUint32(8,B,!0);let x=new Blob([A,g,d,p,f],{type:"application/octet-stream"}),w=new FileReader;w.readAsArrayBuffer(x),w.onloadend=function(){s(w.result)}}}else if(r.buffers&&r.buffers.length>0){let T=new FileReader;T.readAsDataURL(l),T.onloadend=function(){let f=T.result;r.buffers[0].uri=f,s(r)}}else s(r)}serializeUserData(e,s){if(Object.keys(e.userData).length===0)return;let n=this.options,t=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){s.extensions===void 0&&(s.extensions={});for(let r in i.gltfExtensions)s.extensions[r]=i.gltfExtensions[r],t[r]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(s.extras=i)}catch(i){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+i.message)}}getUID(e,s=!1){if(this.uids.has(e)===!1){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(s)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let n=new O;for(let t=0,i=e.count;t<i;t++)if(Math.abs(n.fromBufferAttribute(e,t).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let s=this.cache;if(s.attributesNormalized.has(e))return s.attributesNormalized.get(e);let n=e.clone(),t=new O;for(let i=0,r=n.count;i<r;i++)t.fromBufferAttribute(n,i),t.x===0&&t.y===0&&t.z===0?t.setX(1):t.normalize(),n.setXYZ(i,t.x,t.y,t.z);return s.attributesNormalized.set(e,n),n}applyTextureTransform(e,s){let n=!1,t={};(s.offset.x!==0||s.offset.y!==0)&&(t.offset=s.offset.toArray(),n=!0),s.rotation!==0&&(t.rotation=s.rotation,n=!0),(s.repeat.x!==1||s.repeat.y!==1)&&(t.scale=s.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=t,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,s){if(e===s)return e;function n(f){return f.colorSpace===Me?function(d){return d<.04045?d*.0773993808:Math.pow(d*.9478672986+.0521327014,2.4)}:function(d){return d}}e instanceof D&&(e=await this.decompressTextureAsync(e)),s instanceof D&&(s=await this.decompressTextureAsync(s));let t=e?e.image:null,i=s?s.image:null,r=Math.max(t?t.width:0,i?i.width:0),o=Math.max(t?t.height:0,i?i.height:0),c=Ce();c.width=r,c.height=o;let l=c.getContext("2d",{willReadFrequently:!0});l.fillStyle="#00ffff",l.fillRect(0,0,r,o);let h=l.getImageData(0,0,r,o);if(t){l.drawImage(t,0,0,r,o);let f=n(e),p=l.getImageData(0,0,r,o).data;for(let d=2;d<p.length;d+=4)h.data[d]=f(p[d]/256)*256}if(i){l.drawImage(i,0,0,r,o);let f=n(s),p=l.getImageData(0,0,r,o).data;for(let d=1;d<p.length;d+=4)h.data[d]=f(p[d]/256)*256}l.putImageData(h,0,0);let T=(e||s).clone();return T.source=new Re(c),T.colorSpace=Ae,T.channel=(e||s).channel,e&&s&&e.channel!==s.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),T}async decompressTextureAsync(e,s=1/0){if(this.textureUtils===null)throw new Error("THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.");return await this.textureUtils.decompress(e,s)}processBuffer(e){let s=this.json,n=this.buffers;return s.buffers||(s.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,s,n,t,i){let r=this.json;r.bufferViews||(r.bufferViews=[]);let o;switch(s){case y.BYTE:case y.UNSIGNED_BYTE:o=1;break;case y.SHORT:case y.UNSIGNED_SHORT:o=2;break;default:o=4}let c=e.itemSize*o;i===y.ARRAY_BUFFER&&(c=Math.ceil(c/4)*4);let l=Le(t*c),h=new DataView(new ArrayBuffer(l)),u=0;for(let p=n;p<n+t;p++){for(let d=0;d<e.itemSize;d++){let g;e.itemSize>4?g=e.array[p*e.itemSize+d]:(d===0?g=e.getX(p):d===1?g=e.getY(p):d===2?g=e.getZ(p):d===3&&(g=e.getW(p)),e.normalized===!0&&(g=P.normalize(g,e.array))),s===y.FLOAT?h.setFloat32(u,g,!0):s===y.INT?h.setInt32(u,g,!0):s===y.UNSIGNED_INT?h.setUint32(u,g,!0):s===y.SHORT?h.setInt16(u,g,!0):s===y.UNSIGNED_SHORT?h.setUint16(u,g,!0):s===y.BYTE?h.setInt8(u,g):s===y.UNSIGNED_BYTE&&h.setUint8(u,g),u+=o}u%c!==0&&(u+=c-u%c)}let T={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:l};return i!==void 0&&(T.target=i),i===y.ARRAY_BUFFER&&(T.byteStride=c),this.byteOffset+=l,r.bufferViews.push(T),{id:r.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let s=this,n=s.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(t){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let r=Y(i.result),o={buffer:s.processBuffer(r),byteOffset:s.byteOffset,byteLength:r.byteLength};s.byteOffset+=r.byteLength,t(n.bufferViews.push(o)-1)}})}processAccessor(e,s,n,t){let i=this.json,r={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"},o;if(e.array.constructor===Float32Array)o=y.FLOAT;else if(e.array.constructor===Int32Array)o=y.INT;else if(e.array.constructor===Uint32Array)o=y.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=y.SHORT;else if(e.array.constructor===Uint16Array)o=y.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=y.BYTE;else if(e.array.constructor===Uint8Array)o=y.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(t===void 0||t===1/0)&&(t=e.count),t===0)return null;let c=Ge(e,n,t),l;s!==void 0&&(l=e===s.index?y.ELEMENT_ARRAY_BUFFER:y.ARRAY_BUFFER);let h=this.processBufferView(e,o,n,t,l),u={bufferView:h.id,byteOffset:h.byteOffset,componentType:o,count:t,max:c.max,min:c.min,type:r[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(u)-1}processImage(e,s,n,t="image/png"){if(e!==null){let i=this,r=i.cache,o=i.json,c=i.options,l=i.pending;r.images.has(e)||r.images.set(e,{});let h=r.images.get(e),u=t+":flipY/"+n.toString();if(h[u]!==void 0)return h[u];o.images||(o.images=[]);let T={mimeType:t},f=Ce();f.width=Math.min(e.width,c.maxTextureSize),f.height=Math.min(e.height,c.maxTextureSize);let p=f.getContext("2d",{willReadFrequently:!0});if(n===!0&&(p.translate(0,f.height),p.scale(1,-1)),e.data!==void 0){s!==Te&&console.error("GLTFExporter: Only RGBAFormat is supported.",s),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let g=new Uint8ClampedArray(e.height*e.width*4);for(let A=0;A<g.length;A+=4)g[A+0]=e.data[A+0],g[A+1]=e.data[A+1],g[A+2]=e.data[A+2],g[A+3]=e.data[A+3];p.putImageData(new ImageData(g,e.width,e.height),0,0)}else if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas)p.drawImage(e,0,0,f.width,f.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");c.binary===!0?l.push(Ve(f,t).then(g=>i.processBufferViewImage(g)).then(g=>{T.bufferView=g})):T.uri=Ie.getDataURL(f,t);let d=o.images.push(T)-1;return h[u]=d,d}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let s=this.json;s.samplers||(s.samplers=[]);let n={magFilter:R[e.magFilter],minFilter:R[e.minFilter],wrapS:R[e.wrapS],wrapT:R[e.wrapT]};return s.samplers.push(n)-1}async processTextureAsync(e){let n=this.options,t=this.cache,i=this.json;if(t.textures.has(e))return t.textures.get(e);i.textures||(i.textures=[]),e instanceof D&&(e=await this.decompressTextureAsync(e,n.maxTextureSize));let r=e.userData.mimeType;r==="image/webp"&&(r="image/png");let o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,r)};e.name&&(o.name=e.name),await this._invokeAllAsync(async function(l){l.writeTexture&&await l.writeTexture(e,o)});let c=i.textures.push(o)-1;return t.textures.set(e,c),c}async processMaterialAsync(e){let s=this.cache,n=this.json;if(s.materials.has(e))return s.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);let t={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let i=e.color.toArray().concat([e.opacity]);if(F(i,[1,1,1,1])||(t.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(t.pbrMetallicRoughness.metallicFactor=e.metalness,t.pbrMetallicRoughness.roughnessFactor=e.roughness):(t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let o=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),c={index:await this.processTextureAsync(o),texCoord:o.channel};this.applyTextureTransform(c,o),t.pbrMetallicRoughness.metallicRoughnessTexture=c}if(e.map){let o={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(o,e.map),t.pbrMetallicRoughness.baseColorTexture=o}if(e.emissive){let o=e.emissive;if(Math.max(o.r,o.g,o.b)>0&&(t.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let l={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(l,e.emissiveMap),t.emissiveTexture=l}}if(e.normalMap){let o={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(o.scale=e.normalScale.x),this.applyTextureTransform(o,e.normalMap),t.normalTexture=o}if(e.aoMap){let o={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(o.strength=e.aoMapIntensity),this.applyTextureTransform(o,e.aoMap),t.occlusionTexture=o}e.transparent?t.alphaMode="BLEND":e.alphaTest>0&&(t.alphaMode="MASK",t.alphaCutoff=e.alphaTest),e.side===ce&&(t.doubleSided=!0),e.name!==""&&(t.name=e.name),this.serializeUserData(e,t),await this._invokeAllAsync(async function(o){o.writeMaterialAsync&&await o.writeMaterialAsync(e,t)});let r=n.materials.push(t)-1;return s.materials.set(e,r),r}async processMeshAsync(e){let s=this.cache,n=this.json,t=[e.geometry.uuid];if(Array.isArray(e.material))for(let x=0,w=e.material.length;x<w;x++)t.push(e.material[x].uuid);else t.push(e.material.uuid);let i=t.join(":");if(s.meshes.has(i))return s.meshes.get(i);let r=e.geometry,o;e.isLineSegments?o=y.LINES:e.isLineLoop?o=y.LINE_LOOP:e.isLine?o=y.LINE_STRIP:e.isPoints?o=y.POINTS:o=e.material.wireframe?y.LINES:y.TRIANGLES;let c={},l={},h=[],u=[],T={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},f=r.getAttribute("normal");f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),r.setAttribute("normal",this.createNormalizedNormalAttribute(f)));let p=null;for(let x in r.attributes){if(x.slice(0,5)==="morph")continue;let w=r.attributes[x];if(x=T[x]||x.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(x)||(x="_"+x),s.attributes.has(this.getUID(w))){l[x]=s.attributes.get(this.getUID(w));continue}p=null;let m=w.array;x==="JOINTS_0"&&!(m instanceof Uint16Array)&&!(m instanceof Uint8Array)?(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),p=new S(new Uint16Array(m),w.itemSize,w.normalized)):(m instanceof Uint32Array||m instanceof Int32Array)&&!x.startsWith("_")&&(console.warn(`GLTFExporter: Attribute "${x}" converted to type FLOAT.`),p=z.Utils.toFloat32BufferAttribute(w));let I=this.processAccessor(p||w,r);I!==null&&(x.startsWith("_")||this.detectMeshQuantization(x,w),l[x]=I,s.attributes.set(this.getUID(w),I))}if(f!==void 0&&r.setAttribute("normal",f),Object.keys(l).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let x=[],w=[],M={};if(e.morphTargetDictionary!==void 0)for(let m in e.morphTargetDictionary)M[e.morphTargetDictionary[m]]=m;for(let m=0;m<e.morphTargetInfluences.length;++m){let I={},oe=!1;for(let U in r.morphAttributes){if(U!=="position"&&U!=="normal"){oe||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),oe=!0);continue}let b=r.morphAttributes[U][m],k=U.toUpperCase(),C=r.attributes[U];if(s.attributes.has(this.getUID(b,!0))){I[k]=s.attributes.get(this.getUID(b,!0));continue}let L=b.clone();if(!r.morphTargetsRelative)for(let E=0,Oe=b.count;E<Oe;E++)for(let _=0;_<b.itemSize;_++)_===0&&L.setX(E,b.getX(E)-C.getX(E)),_===1&&L.setY(E,b.getY(E)-C.getY(E)),_===2&&L.setZ(E,b.getZ(E)-C.getZ(E)),_===3&&L.setW(E,b.getW(E)-C.getW(E));I[k]=this.processAccessor(L,r),s.attributes.set(this.getUID(C,!0),I[k])}u.push(I),x.push(e.morphTargetInfluences[m]),e.morphTargetDictionary!==void 0&&w.push(M[m])}c.weights=x,w.length>0&&(c.extras={},c.extras.targetNames=w)}let d=Array.isArray(e.material);if(d&&r.groups.length===0)return null;let g=!1;if(d&&r.index===null){let x=[];for(let w=0,M=r.attributes.position.count;w<M;w++)x[w]=w;r.setIndex(x),g=!0}let A=d?e.material:[e.material],N=d?r.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let x=0,w=N.length;x<w;x++){let M={mode:o,attributes:l};if(this.serializeUserData(r,M),u.length>0&&(M.targets=u),r.index!==null){let I=this.getUID(r.index);(N[x].start!==void 0||N[x].count!==void 0)&&(I+=":"+N[x].start+":"+N[x].count),s.attributes.has(I)?M.indices=s.attributes.get(I):(M.indices=this.processAccessor(r.index,r,N[x].start,N[x].count),s.attributes.set(I,M.indices)),M.indices===null&&delete M.indices}let m=await this.processMaterialAsync(A[N[x].materialIndex]);m!==null&&(M.material=m),h.push(M)}g===!0&&r.setIndex(null),c.primitives=h,n.meshes||(n.meshes=[]),await this._invokeAllAsync(function(x){x.writeMesh&&x.writeMesh(e,c)});let B=n.meshes.push(c)-1;return s.meshes.set(i,B),B}detectMeshQuantization(e,s){if(this.extensionsUsed[V])return;let n;switch(s.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}s.normalized&&(n+=" normalized");let t=e.split("_",1)[0];be[t]&&be[t].includes(n)&&(this.extensionsUsed[V]=!0,this.extensionsRequired[V]=!0)}processCamera(e){let s=this.json;s.cameras||(s.cameras=[]);let n=e.isOrthographicCamera,t={type:n?"orthographic":"perspective"};return n?t.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:t.perspective={aspectRatio:e.aspect,yfov:P.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(t.name=e.type),s.cameras.push(t)-1}processAnimation(e,s){let n=this.json,t=this.nodeMap;n.animations||(n.animations=[]),e=z.Utils.mergeMorphTargetTracks(e.clone(),s);let i=e.tracks,r=[],o=[];for(let c=0;c<i.length;++c){let l=i[c],h=v.parseTrackName(l.name),u=v.findNode(s,h.nodeName),T=Se[h.propertyName];if(h.objectName==="bones"&&(u.isSkinnedMesh===!0?u=u.skeleton.getBoneByName(h.objectIndex):u=void 0),!u||!T){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',l.name);continue}let f=1,p=l.values.length/l.times.length;T===Se.morphTargetInfluences&&(p/=u.morphTargetInfluences.length);let d;l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(d="CUBICSPLINE",p/=3):l.getInterpolation()===we?d="STEP":d="LINEAR",o.push({input:this.processAccessor(new S(l.times,f)),output:this.processAccessor(new S(l.values,p)),interpolation:d}),r.push({sampler:o.length-1,target:{node:t.get(u),path:T}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:o,channels:r}),n.animations.length-1}processSkin(e){let s=this.json,n=this.nodeMap,t=s.nodes[n.get(e)],i=e.skeleton;if(i===void 0)return null;let r=e.skeleton.bones[0];if(r===void 0)return null;let o=[],c=new Float32Array(i.bones.length*16),l=new H;for(let u=0;u<i.bones.length;++u)o.push(n.get(i.bones[u])),l.copy(i.boneInverses[u]),l.multiply(e.bindMatrix).toArray(c,u*16);return s.skins===void 0&&(s.skins=[]),s.skins.push({inverseBindMatrices:this.processAccessor(new S(c,16)),joints:o,skeleton:n.get(r)}),t.skin=s.skins.length-1}async processNodeAsync(e){let s=this.json,n=this.options,t=this.nodeMap;s.nodes||(s.nodes=[]);let i={};if(n.trs){let o=e.quaternion.toArray(),c=e.position.toArray(),l=e.scale.toArray();F(o,[0,0,0,1])||(i.rotation=o),F(c,[0,0,0])||(i.translation=c),F(l,[1,1,1])||(i.scale=l)}else e.matrixAutoUpdate&&e.updateMatrix(),He(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==""&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){let o=await this.processMeshAsync(e);o!==null&&(i.mesh=o)}else e.isCamera&&(i.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let r=s.nodes.push(i)-1;if(t.set(e,r),e.children.length>0){let o=[];for(let c=0,l=e.children.length;c<l;c++){let h=e.children[c];if(h.visible||n.onlyVisible===!1){let u=await this.processNodeAsync(h);u!==null&&o.push(u)}}o.length>0&&(i.children=o)}return await this._invokeAllAsync(function(o){o.writeNode&&o.writeNode(e,i)}),r}async processSceneAsync(e){let s=this.json,n=this.options;s.scenes||(s.scenes=[],s.scene=0);let t={};e.name!==""&&(t.name=e.name),s.scenes.push(t);let i=[];for(let r=0,o=e.children.length;r<o;r++){let c=e.children[r];if(c.visible||n.onlyVisible===!1){let l=await this.processNodeAsync(c);l!==null&&i.push(l)}}i.length>0&&(t.nodes=i),this.serializeUserData(e,t)}async processObjectsAsync(e){let s=new G;s.name="AuxScene";for(let n=0;n<e.length;n++)s.children.push(e[n]);await this.processSceneAsync(s)}async processInputAsync(e){let s=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync(function(t){t.beforeParse&&t.beforeParse(e)});let n=[];for(let t=0;t<e.length;t++)e[t]instanceof G?await this.processSceneAsync(e[t]):n.push(e[t]);n.length>0&&await this.processObjectsAsync(n);for(let t=0;t<this.skins.length;++t)this.processSkin(this.skins[t]);for(let t=0;t<s.animations.length;++t)this.processAnimation(s.animations[t],e[0]);await this._invokeAllAsync(function(t){t.afterParse&&t.afterParse(e)})}async _invokeAllAsync(e){for(let s=0,n=this.plugins.length;s<n;s++)await e(this.plugins[s])}},j=class{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,s){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}let n=this.writer,t=n.json,i=n.extensionsUsed,r={};e.name&&(r.name=e.name),r.color=e.color.toArray(),r.intensity=e.intensity,e.isDirectionalLight?r.type="directional":e.isPointLight?(r.type="point",e.distance>0&&(r.range=e.distance)):e.isSpotLight&&(r.type="spot",e.distance>0&&(r.range=e.distance),r.spot={},r.spot.innerConeAngle=(1-e.penumbra)*e.angle,r.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),i[this.name]||(t.extensions=t.extensions||{},t.extensions[this.name]={lights:[]},i[this.name]=!0);let o=t.extensions[this.name].lights;o.push(r),s.extensions=s.extensions||{},s.extensions[this.name]={light:o.length-1}}},q=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,s){if(!e.isMeshBasicMaterial)return;let t=this.writer.extensionsUsed;s.extensions=s.extensions||{},s.extensions[this.name]={},t[this.name]=!0,s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=.9}},X=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let n=this.writer,t=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let r={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(r,e.clearcoatMap),i.clearcoatTexture=r}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let r={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(r,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=r}if(e.clearcoatNormalMap){let r={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(r.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(r,e.clearcoatNormalMap),i.clearcoatNormalTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},W=class{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;let t=this.writer.extensionsUsed,i={};i.dispersion=e.dispersion,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},J=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let n=this.writer,t=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let r={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(r,e.iridescenceMap),i.iridescenceTexture=r}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let r={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(r,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},Z=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,t=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let r={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(r,e.transmissionMap),i.transmissionTexture=r}s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},Q=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,t=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let r={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(r,e.thicknessMap),i.thicknessTexture=r}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},$=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let t=this.writer.extensionsUsed,i={};i.ior=e.ior,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},ee=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(Fe)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,t=n.extensionsUsed,i={};if(e.specularIntensityMap){let r={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(r,e.specularIntensityMap),i.specularTexture=r}if(e.specularColorMap){let r={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(r,e.specularColorMap),i.specularColorTexture=r}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},se=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let n=this.writer,t=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let r={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(r,e.sheenRoughnessMap),i.sheenRoughnessTexture=r}if(e.sheenColorMap){let r={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(r,e.sheenColorMap),i.sheenColorTexture=r}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},te=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let n=this.writer,t=n.extensionsUsed,i={};if(e.anisotropyMap){let r={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(r,e.anisotropyMap),i.anisotropyTexture=r}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},ne=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let t=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},ie=class{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;let n=this.writer,t=n.extensionsUsed,i={};if(e.bumpMap){let r={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(r,e.bumpMap),i.bumpTexture=r}i.bumpFactor=e.bumpScale,s.extensions=s.extensions||{},s.extensions[this.name]=i,t[this.name]=!0}},re=class{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,s){if(!e.isInstancedMesh)return;let n=this.writer,t=e,i=new Float32Array(t.count*3),r=new Float32Array(t.count*4),o=new Float32Array(t.count*3),c=new H,l=new O,h=new Ee,u=new O;for(let f=0;f<t.count;f++)t.getMatrixAt(f,c),c.decompose(l,h,u),l.toArray(i,f*3),h.toArray(r,f*4),u.toArray(o,f*3);let T={TRANSLATION:n.processAccessor(new S(i,3)),ROTATION:n.processAccessor(new S(r,4)),SCALE:n.processAccessor(new S(o,3))};t.instanceColor&&(T._COLOR_0=n.processAccessor(t.instanceColor)),s.extensions=s.extensions||{},s.extensions[this.name]={attributes:T},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}};z.Utils={insertKeyframe:function(a,e){let n=a.getValueSize(),t=new a.TimeBufferType(a.times.length+1),i=new a.ValueBufferType(a.values.length+n),r=a.createInterpolant(new a.ValueBufferType(n)),o;if(a.times.length===0){t[0]=e;for(let c=0;c<n;c++)i[c]=0;o=0}else if(e<a.times[0]){if(Math.abs(a.times[0]-e)<.001)return 0;t[0]=e,t.set(a.times,1),i.set(r.evaluate(e),0),i.set(a.values,n),o=0}else if(e>a.times[a.times.length-1]){if(Math.abs(a.times[a.times.length-1]-e)<.001)return a.times.length-1;t[t.length-1]=e,t.set(a.times,0),i.set(a.values,0),i.set(r.evaluate(e),a.values.length),o=t.length-1}else for(let c=0;c<a.times.length;c++){if(Math.abs(a.times[c]-e)<.001)return c;if(a.times[c]<e&&a.times[c+1]>e){t.set(a.times.slice(0,c+1),0),t[c+1]=e,t.set(a.times.slice(c+1),c+2),i.set(a.values.slice(0,(c+1)*n),0),i.set(r.evaluate(e),(c+1)*n),i.set(a.values.slice((c+1)*n),(c+2)*n),o=c+1;break}}return a.times=t,a.values=i,o},mergeMorphTargetTracks:function(a,e){let s=[],n={},t=a.tracks;for(let i=0;i<t.length;++i){let r=t[i],o=v.parseTrackName(r.name),c=v.findNode(e,o.nodeName);if(o.propertyName!=="morphTargetInfluences"||o.propertyIndex===void 0){s.push(r);continue}if(r.createInterpolant!==r.InterpolantFactoryMethodDiscrete&&r.createInterpolant!==r.InterpolantFactoryMethodLinear){if(r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),r=r.clone(),r.setInterpolation(me)}let l=c.morphTargetInfluences.length,h=c.morphTargetDictionary[o.propertyIndex];if(h===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let u;if(n[c.uuid]===void 0){u=r.clone();let f=new u.ValueBufferType(l*u.times.length);for(let p=0;p<u.times.length;p++)f[p*l+h]=u.values[p];u.name=(o.nodeName||"")+".morphTargetInfluences",u.values=f,n[c.uuid]=u,s.push(u);continue}let T=r.createInterpolant(new r.ValueBufferType(1));u=n[c.uuid];for(let f=0;f<u.times.length;f++)u.values[f*l+h]=T.evaluate(u.times[f]);for(let f=0;f<r.times.length;f++){let p=this.insertKeyframe(u,r.times[f]);u.values[p*l+h]=r.values[f]}}return a.tracks=s,a},toFloat32BufferAttribute:function(a){let e=new S(new Float32Array(a.count*a.itemSize),a.itemSize,!1);if(!a.normalized&&!a.isInterleavedBufferAttribute)return e.array.set(a.array),e;for(let s=0,n=a.count;s<n;s++)for(let t=0;t<a.itemSize;t++)e.setComponent(s,t,a.getComponent(s,t));return e}};export{z as GLTFExporter};
@@ -1 +1 @@
1
- import{b as ae}from"./chunk-R4YYWOA4.js";import{$ as F,$a as ie,Ba as at,C as P,Ca as ct,D as N,Da as ut,Ea as lt,Fa as ft,Ga as ht,N as We,O as Q,P as Z,Q as C,S as $,Ta as ne,Ua as S,V as ee,Y as Ye,Ya as dt,Z as Je,Za as se,_a as re,a as ve,ab as pt,ba as te,bb as mt,ca as I,cb as oe,d as Ue,da as V,db as gt,ea as k,eb as Tt,f as Fe,fa as G,fb as Rt,gb as At,ha as Qe,hb as _t,i as K,ia as Ze,j as je,jb as H,k as Ke,l as W,lb as xt,m as Be,n as Ve,na as $e,nb as Et,o as B,oa as X,p as Ge,q as Y,qa as et,ra as tt,sa as nt,ta as st,v as Xe,va as rt,w as J,wa as it,xa as ot,y as ze,z as qe}from"./chunk-CO4ZOCZ7.js";import"./chunk-PWEV3AFA.js";ve();var yt=class extends mt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new pe(t)}),this.register(function(t){return new me(t)}),this.register(function(t){return new Se(t)}),this.register(function(t){return new we(t)}),this.register(function(t){return new Ne(t)}),this.register(function(t){return new Te(t)}),this.register(function(t){return new Re(t)}),this.register(function(t){return new Ae(t)}),this.register(function(t){return new _e(t)}),this.register(function(t){return new de(t)}),this.register(function(t){return new xe(t)}),this.register(function(t){return new ge(t)}),this.register(function(t){return new ye(t)}),this.register(function(t){return new Ee(t)}),this.register(function(t){return new fe(t)}),this.register(function(t){return new Me(t)}),this.register(function(t){return new Le(t)})}load(e,t,r,n){let s=this,i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){let c=H.extractUrlBase(e);i=H.resolveURL(c,this.path)}else i=H.extractUrlBase(e);this.manager.itemStart(e);let a=function(c){n?n(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},o=new oe(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{s.parse(c,i,function(l){t(l),s.manager.itemEnd(e)},a)}catch(l){a(l)}},r,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,n){let s,i={},a={},o=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===Lt){try{i[g.KHR_BINARY_GLTF]=new be(e)}catch(u){n&&n(u);return}s=JSON.parse(i[g.KHR_BINARY_GLTF].content)}else s=JSON.parse(o.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new He(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,i[u.name]=!0}if(s.extensionsUsed)for(let l=0;l<s.extensionsUsed.length;++l){let u=s.extensionsUsed[l],f=s.extensionsRequired||[];switch(u){case g.KHR_MATERIALS_UNLIT:i[u]=new he;break;case g.KHR_DRACO_MESH_COMPRESSION:i[u]=new Ie(s,this.dracoLoader);break;case g.KHR_TEXTURE_TRANSFORM:i[u]=new Oe;break;case g.KHR_MESH_QUANTIZATION:i[u]=new Ce;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(i),c.setPlugins(a),c.parse(r,n)}parseAsync(e,t){let r=this;return new Promise(function(n,s){r.parse(e,t,n,s)})}};function bt(){let h={};return{get:function(e){return h[e]},add:function(e,t){h[e]=t},remove:function(e){delete h[e]},removeAll:function(){h={}}}}var 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_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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},fe=class{constructor(e){this.parser=e,this.name=g.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let r=0,n=t.length;r<n;r++){let s=t[r];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){let t=this.parser,r="light:"+e,n=t.cache.get(r);if(n)return n;let s=t.json,o=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e],c,l=new I(16777215);o.color!==void 0&&l.setRGB(o.color[0],o.color[1],o.color[2],N);let u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new _t(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Rt(l),c.distance=u;break;case"spot":c=new Tt(l),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),M(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=t.createUniqueName(o.name||"light_"+e),n=Promise.resolve(c),t.cache.add(r,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,r=this.parser,s=r.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return r._getNodeRef(t.cache,a,o)})}},he=class{constructor(){this.name=g.KHR_MATERIALS_UNLIT}getMaterialType(){return k}extendParams(e,t,r){let n=[];e.color=new I(1,1,1),e.opacity=1;let s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){let i=s.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],N),e.opacity=i[3]}s.baseColorTexture!==void 0&&n.push(r.assignTexture(e,"map",s.baseColorTexture,P))}return Promise.all(n)}},de=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=n.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}},pe=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(s.push(r.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){let a=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Q(a,a)}return Promise.all(s)}},me=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_DISPERSION}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=n.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}},ge=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(s)}},Te=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_SHEEN}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[];t.sheenColor=new I(0,0,0),t.sheenRoughness=0,t.sheen=1;let i=n.extensions[this.name];if(i.sheenColorFactor!==void 0){let a=i.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],N)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&s.push(r.assignTexture(t,"sheenColorMap",i.sheenColorTexture,P)),i.sheenRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}},Re=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&s.push(r.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(s)}},Ae=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_VOLUME}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&s.push(r.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;let a=i.attenuationColor||[1,1,1];return t.attenuationColor=new I().setRGB(a[0],a[1],a[2],N),Promise.all(s)}},_e=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_IOR}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=n.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},xe=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_SPECULAR}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&s.push(r.assignTexture(t,"specularIntensityMap",i.specularTexture));let a=i.specularColorFactor||[1,1,1];return t.specularColor=new I().setRGB(a[0],a[1],a[2],N),i.specularColorTexture!==void 0&&s.push(r.assignTexture(t,"specularColorMap",i.specularColorTexture,P)),Promise.all(s)}},Ee=class{constructor(e){this.parser=e,this.name=g.EXT_MATERIALS_BUMP}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&s.push(r.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(s)}},ye=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&s.push(r.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(s)}},Se=class{constructor(e){this.parser=e,this.name=g.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,r=t.json,n=r.textures[e];if(!n.extensions||!n.extensions[this.name])return null;let s=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,i)}},we=class{constructor(e){this.parser=e,this.name=g.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,r=this.parser,n=r.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;let i=s.extensions[t],a=n.images[i.source],o=r.textureLoader;if(a.uri){let c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return r.loadTextureImage(e,i.source,o)}},Ne=class{constructor(e){this.parser=e,this.name=g.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,r=this.parser,n=r.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;let i=s.extensions[t],a=n.images[i.source],o=r.textureLoader;if(a.uri){let c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return r.loadTextureImage(e,i.source,o)}},Me=class{constructor(e){this.name=g.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){let n=r.extensions[this.name],s=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){let o=n.byteOffset||0,c=n.byteLength||0,l=n.count,u=n.byteStride,f=new Uint8Array(a,o,c);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(l,u,f,n.mode,n.filter).then(function(d){return d.buffer}):i.ready.then(function(){let d=new ArrayBuffer(l*u);return i.decodeGltfBuffer(new Uint8Array(d),l,u,f,n.mode,n.filter),d})})}else return null}},Le=class{constructor(e){this.name=g.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;let n=t.meshes[r.mesh];for(let c of n.primitives)if(c.mode!==E.TRIANGLES&&c.mode!==E.TRIANGLE_STRIP&&c.mode!==E.TRIANGLE_FAN&&c.mode!==void 0)return null;let i=r.extensions[this.name].attributes,a=[],o={};for(let c in i)a.push(this.parser.getDependency("accessor",i[c]).then(l=>(o[c]=l,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{let l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,d=[];for(let m of u){let R=new F,p=new C,T=new Z,_=new C(1,1,1),x=new ot(m.geometry,m.material,f);for(let A=0;A<f;A++)o.TRANSLATION&&p.fromBufferAttribute(o.TRANSLATION,A),o.ROTATION&&T.fromBufferAttribute(o.ROTATION,A),o.SCALE&&_.fromBufferAttribute(o.SCALE,A),x.setMatrixAt(A,R.compose(p,T,_));for(let A in o)if(A==="_COLOR_0"){let w=o[A];x.instanceColor=new it(w.array,w.itemSize,w.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&m.geometry.setAttribute(A,o[A]);te.prototype.copy.call(x,m),this.parser.assignFinalMaterial(x),d.push(x)}return l.isGroup?(l.clear(),l.add(...d),l):d[0]}))}},Lt="glTF",j=12,St={JSON:1313821514,BIN:5130562},be=class{constructor(e){this.name=g.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,j),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Lt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let n=this.header.length-j,s=new DataView(e,j),i=0;for(;i<n;){let a=s.getUint32(i,!0);i+=4;let o=s.getUint32(i,!0);if(i+=4,o===St.JSON){let c=new Uint8Array(e,j+i,a);this.content=r.decode(c)}else if(o===St.BIN){let c=j+i;this.body=e.slice(c,c+a)}i+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},Ie=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=g.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let r=this.json,n=this.dracoLoader,s=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},o={},c={};for(let l in i){let u=Pe[l]||l.toLowerCase();a[u]=i[l]}for(let l in e.attributes){let u=Pe[l]||l.toLowerCase();if(i[l]!==void 0){let f=r.accessors[e.attributes[l]],d=v[f.componentType];c[u]=d.name,o[u]=f.normalized===!0}}return t.getDependency("bufferView",s).then(function(l){return new Promise(function(u,f){n.decodeDracoFile(l,function(d){for(let m in d.attributes){let R=d.attributes[m],p=o[m];p!==void 0&&(R.normalized=p)}u(d)},a,c,N,f)})})}},Oe=class{constructor(){this.name=g.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},Ce=class{constructor(){this.name=g.KHR_MESH_QUANTIZATION}},z=class extends dt{constructor(e,t,r,n){super(e,t,r,n)}copySampleValue_(e){let t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,s=e*n*3+n;for(let i=0;i!==n;i++)t[i]=r[s+i];return t}interpolate_(e,t,r,n){let s=this.resultBuffer,i=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,l=n-t,u=(r-t)/l,f=u*u,d=f*u,m=e*c,R=m-c,p=-2*d+3*f,T=d-f,_=1-p,x=T-f+u;for(let A=0;A!==a;A++){let w=i[R+A+a],L=i[R+A+o]*l,y=i[m+A+a],U=i[m+A]*l;s[A]=_*w+x*L+p*y+T*U}return s}},It=new Z,De=class extends z{interpolate_(e,t,r,n){let s=super.interpolate_(e,t,r,n);return It.fromArray(s).normalize().toArray(s),s}},E={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},v={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},wt={9728:W,9729:B,9984:Be,9985:Ge,9986:Ve,9987:Y},Nt={33071:je,33648:Ke,10497:K},ce={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Pe={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},O={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ot={CUBICSPLINE:void 0,LINEAR:J,STEP:Xe},ue={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ct(h){return h.DefaultMaterial===void 0&&(h.DefaultMaterial=new ne({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Ue})),h.DefaultMaterial}function D(h,e,t){for(let r in t.extensions)h[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=t.extensions[r])}function M(h,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(h.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Dt(h,e,t){let r=!1,n=!1,s=!1;for(let c=0,l=e.length;c<l;c++){let u=e[c];if(u.POSITION!==void 0&&(r=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(s=!0),r&&n&&s)break}if(!r&&!n&&!s)return Promise.resolve(h);let i=[],a=[],o=[];for(let c=0,l=e.length;c<l;c++){let u=e[c];if(r){let f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):h.attributes.position;i.push(f)}if(n){let f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):h.attributes.normal;a.push(f)}if(s){let f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):h.attributes.color;o.push(f)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o)]).then(function(c){let l=c[0],u=c[1],f=c[2];return r&&(h.morphAttributes.position=l),n&&(h.morphAttributes.normal=u),s&&(h.morphAttributes.color=f),h.morphTargetsRelative=!0,h})}function Pt(h,e){if(h.updateMorphTargets(),e.weights!==void 0)for(let t=0,r=e.weights.length;t<r;t++)h.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(h.morphTargetInfluences.length===t.length){h.morphTargetDictionary={};for(let r=0,n=t.length;r<n;r++)h.morphTargetDictionary[t[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function kt(h){let e,t=h.extensions&&h.extensions[g.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+le(t.attributes):e=h.indices+":"+le(h.attributes)+":"+h.mode,h.targets!==void 0)for(let r=0,n=h.targets.length;r<n;r++)e+=":"+le(h.targets[r]);return e}function le(h){let e="",t=Object.keys(h).sort();for(let r=0,n=t.length;r<n;r++)e+=t[r]+":"+h[t[r]]+";";return e}function ke(h){switch(h){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Ht(h){return h.search(/\.jpe?g($|\?)/i)>0||h.search(/^data\:image\/jpeg/)===0?"image/jpeg":h.search(/\.webp($|\?)/i)>0||h.search(/^data\:image\/webp/)===0?"image/webp":h.search(/\.ktx2($|\?)/i)>0||h.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var vt=new F,He=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new bt,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 r=!1,n=-1,s=!1,i=-1;if(typeof navigator<"u"){let a=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(a)===!0;let o=a.match(/Version\/(\d+)/);n=r&&o?parseInt(o[1],10):-1,s=a.indexOf("Firefox")>-1,i=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&n<17||s&&i<98?this.textureLoader=new gt(this.options.manager):this.textureLoader=new xt(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new oe(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let r=this,n=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(i){let a={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:r,userData:{}};return D(s,a,n),M(a,n),Promise.all(r._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(let o of a.scenes)o.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let n=0,s=t.length;n<s;n++){let i=t[n].joints;for(let a=0,o=i.length;a<o;a++)e[i[a]].isBone=!0}for(let n=0,s=e.length;n<s;n++){let i=e[n];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(r[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;let n=r.clone(),s=(i,a)=>{let o=this.associations.get(i);o!=null&&this.associations.set(a,o);for(let[c,l]of i.children.entries())s(l,a.children[c])};return s(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){let n=e(t[r]);if(n)return n}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let r=[];for(let n=0;n<t.length;n++){let s=e(t[n]);s&&r.push(s)}return r}getDependency(e,t){let r=e+":"+t,n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":n=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(r,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){let r=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(s,i){return r.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],r=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[g.KHR_BINARY_GLTF].body);let n=this.options;return new Promise(function(s,i){r.load(H.resolveURL(t.uri,n.path),s,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(r){let n=t.byteLength||0,s=t.byteOffset||0;return r.slice(s,s+n)})}loadAccessor(e){let t=this,r=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){let i=ce[n.type],a=v[n.componentType],o=n.normalized===!0,c=new a(n.count*i);return Promise.resolve(new G(c,i,o))}let s=[];return n.bufferView!==void 0?s.push(this.getDependency("bufferView",n.bufferView)):s.push(null),n.sparse!==void 0&&(s.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(s).then(function(i){let a=i[0],o=ce[n.type],c=v[n.componentType],l=c.BYTES_PER_ELEMENT,u=l*o,f=n.byteOffset||0,d=n.bufferView!==void 0?r.bufferViews[n.bufferView].byteStride:void 0,m=n.normalized===!0,R,p;if(d&&d!==u){let T=Math.floor(f/d),_="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+T+":"+n.count,x=t.cache.get(_);x||(R=new c(a,T*d,n.count*d/l),x=new et(R,d/l),t.cache.add(_,x)),p=new tt(x,o,f%d/l,m)}else a===null?R=new c(n.count*o):R=new c(a,f,n.count*o),p=new G(R,o,m);if(n.sparse!==void 0){let T=ce.SCALAR,_=v[n.sparse.indices.componentType],x=n.sparse.indices.byteOffset||0,A=n.sparse.values.byteOffset||0,w=new _(i[1],x,n.sparse.count*T),L=new c(i[2],A,n.sparse.count*o);a!==null&&(p=new G(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let y=0,U=w.length;y<U;y++){let b=w[y];if(p.setX(b,L[y*o]),o>=2&&p.setY(b,L[y*o+1]),o>=3&&p.setZ(b,L[y*o+2]),o>=4&&p.setW(b,L[y*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=m}return p})}loadTexture(e){let t=this.json,r=this.options,s=t.textures[e].source,i=t.images[s],a=this.textureLoader;if(i.uri){let o=r.manager.getHandler(i.uri);o!==null&&(a=o)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,r){let n=this,s=this.json,i=s.textures[e],a=s.images[t],o=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[o])return this.textureCache[o];let c=this.loadImageSource(t,r).then(function(l){l.flipY=!1,l.name=i.name||a.name||"",l.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(l.name=a.uri);let f=(s.samplers||{})[i.sampler]||{};return l.magFilter=wt[f.magFilter]||B,l.minFilter=wt[f.minFilter]||Y,l.wrapS=Nt[f.wrapS]||K,l.wrapT=Nt[f.wrapT]||K,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==W&&l.minFilter!==B,n.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(e,t){let r=this,n=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());let i=n.images[e],a=self.URL||self.webkitURL,o=i.uri||"",c=!1;if(i.bufferView!==void 0)o=r.getDependency("bufferView",i.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:i.mimeType});return o=a.createObjectURL(f),o});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(o).then(function(u){return new Promise(function(f,d){let m=f;t.isImageBitmapLoader===!0&&(m=function(R){let p=new ee(R);p.needsUpdate=!0,f(p)}),t.load(H.resolveURL(u,s.path),m,void 0,d)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),M(u,i),u.userData.mimeType=i.mimeType||Ht(i.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[e]=l,l}assignTexture(e,t,r,n){let s=this;return this.getDependency("texture",r.index).then(function(i){if(!i)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(i=i.clone(),i.channel=r.texCoord),s.extensions[g.KHR_TEXTURE_TRANSFORM]){let a=r.extensions!==void 0?r.extensions[g.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let o=s.associations.get(i);i=s.extensions[g.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),s.associations.set(i,o)}}return n!==void 0&&(i.colorSpace=n),e[t]=i,i})}assignFinalMaterial(e){let t=e.geometry,r=e.material,n=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+r.uuid,o=this.cache.get(a);o||(o=new ft,V.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,o.sizeAttenuation=!1,this.cache.add(a,o)),r=o}else if(e.isLine){let a="LineBasicMaterial:"+r.uuid,o=this.cache.get(a);o||(o=new at,V.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,this.cache.add(a,o)),r=o}if(n||s||i){let a="ClonedMaterial:"+r.uuid+":";n&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=r.clone(),s&&(o.vertexColors=!0),i&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(r))),r=o}e.material=r}getMaterialType(){return ne}loadMaterial(e){let t=this,r=this.json,n=this.extensions,s=r.materials[e],i,a={},o=s.extensions||{},c=[];if(o[g.KHR_MATERIALS_UNLIT]){let u=n[g.KHR_MATERIALS_UNLIT];i=u.getMaterialType(),c.push(u.extendParams(a,s,t))}else{let u=s.pbrMetallicRoughness||{};if(a.color=new I(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],N),a.opacity=f[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,P)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),i=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Fe);let l=s.alphaMode||ue.OPAQUE;if(l===ue.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===ue.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&i!==k&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Q(1,1),s.normalTexture.scale!==void 0)){let u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&i!==k&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&i!==k){let u=s.emissiveFactor;a.emissive=new I().setRGB(u[0],u[1],u[2],N)}return s.emissiveTexture!==void 0&&i!==k&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,P)),Promise.all(c).then(function(){let u=new i(a);return s.name&&(u.name=s.name),M(u,s),t.associations.set(u,{materials:e}),s.extensions&&D(n,u,s),u})}createUniqueName(e){let t=Et.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,r=this.extensions,n=this.primitiveCache;function s(a){return r[g.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(o){return Mt(o,a,t)})}let i=[];for(let a=0,o=e.length;a<o;a++){let c=e[a],l=kt(c),u=n[l];if(u)i.push(u.promise);else{let f;c.extensions&&c.extensions[g.KHR_DRACO_MESH_COMPRESSION]?f=s(c):f=Mt(new Qe,c,t),n[l]={primitive:c,promise:f},i.push(f)}}return Promise.all(i)}loadMesh(e){let t=this,r=this.json,n=this.extensions,s=r.meshes[e],i=s.primitives,a=[];for(let o=0,c=i.length;o<c;o++){let l=i[o].material===void 0?Ct(this.cache):this.getDependency("material",i[o].material);a.push(l)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(o){let c=o.slice(0,o.length-1),l=o[o.length-1],u=[];for(let d=0,m=l.length;d<m;d++){let R=l[d],p=i[d],T,_=c[d];if(p.mode===E.TRIANGLES||p.mode===E.TRIANGLE_STRIP||p.mode===E.TRIANGLE_FAN||p.mode===void 0)T=s.isSkinnedMesh===!0?new nt(R,_):new Ze(R,_),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),p.mode===E.TRIANGLE_STRIP?T.geometry=ae(T.geometry,ze):p.mode===E.TRIANGLE_FAN&&(T.geometry=ae(T.geometry,qe));else if(p.mode===E.LINES)T=new ut(R,_);else if(p.mode===E.LINE_STRIP)T=new ct(R,_);else if(p.mode===E.LINE_LOOP)T=new lt(R,_);else if(p.mode===E.POINTS)T=new ht(R,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);Object.keys(T.geometry.morphAttributes).length>0&&Pt(T,s),T.name=t.createUniqueName(s.name||"mesh_"+e),M(T,s),p.extensions&&D(n,T,p),t.assignFinalMaterial(T),u.push(T)}for(let d=0,m=u.length;d<m;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return s.extensions&&D(n,u[0],s),u[0];let f=new X;s.extensions&&D(n,f,s),t.associations.set(f,{meshes:e});for(let d=0,m=u.length;d<m;d++)f.add(u[d]);return f})}loadCamera(e){let t,r=this.json.cameras[e],n=r[r.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?t=new $e(We.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):r.type==="orthographic"&&(t=new At(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),M(t,r),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],r=[];for(let n=0,s=t.joints.length;n<s;n++)r.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(n){let s=n.pop(),i=n,a=[],o=[];for(let c=0,l=i.length;c<l;c++){let u=i[c];if(u){a.push(u);let f=new F;s!==null&&f.fromArray(s.array,c*16),o.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new rt(a,o)})}loadAnimation(e){let t=this.json,r=this,n=t.animations[e],s=n.name?n.name:"animation_"+e,i=[],a=[],o=[],c=[],l=[];for(let u=0,f=n.channels.length;u<f;u++){let d=n.channels[u],m=n.samplers[d.sampler],R=d.target,p=R.node,T=n.parameters!==void 0?n.parameters[m.input]:m.input,_=n.parameters!==void 0?n.parameters[m.output]:m.output;R.node!==void 0&&(i.push(this.getDependency("node",p)),a.push(this.getDependency("accessor",T)),o.push(this.getDependency("accessor",_)),c.push(m),l.push(R))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],d=u[1],m=u[2],R=u[3],p=u[4],T=[];for(let _=0,x=f.length;_<x;_++){let A=f[_],w=d[_],L=m[_],y=R[_],U=p[_];if(A===void 0)continue;A.updateMatrix&&A.updateMatrix();let b=r._createAnimationTracks(A,w,L,y,U);if(b)for(let q=0;q<b.length;q++)T.push(b[q])}return new pt(s,void 0,T)})}createNodeMesh(e){let t=this.json,r=this,n=t.nodes[e];return n.mesh===void 0?null:r.getDependency("mesh",n.mesh).then(function(s){let i=r._getNodeRef(r.meshCache,n.mesh,s);return n.weights!==void 0&&i.traverse(function(a){if(a.isMesh)for(let o=0,c=n.weights.length;o<c;o++)a.morphTargetInfluences[o]=n.weights[o]}),i})}loadNode(e){let t=this.json,r=this,n=t.nodes[e],s=r._loadNodeShallow(e),i=[],a=n.children||[];for(let c=0,l=a.length;c<l;c++)i.push(r.getDependency("node",a[c]));let o=n.skin===void 0?Promise.resolve(null):r.getDependency("skin",n.skin);return Promise.all([s,Promise.all(i),o]).then(function(c){let l=c[0],u=c[1],f=c[2];f!==null&&l.traverse(function(d){d.isSkinnedMesh&&d.bind(f,vt)});for(let d=0,m=u.length;d<m;d++)l.add(u[d]);return l})}_loadNodeShallow(e){let t=this.json,r=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let s=t.nodes[e],i=s.name?n.createUniqueName(s.name):"",a=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return o&&a.push(o),s.camera!==void 0&&a.push(n.getDependency("camera",s.camera).then(function(c){return n._getNodeRef(n.cameraCache,s.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let l;if(s.isBone===!0?l=new st:c.length>1?l=new X:c.length===1?l=c[0]:l=new te,l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(s.name&&(l.userData.name=s.name,l.name=i),M(l,s),s.extensions&&D(r,l,s),s.matrix!==void 0){let u=new F;u.fromArray(s.matrix),l.applyMatrix4(u)}else s.translation!==void 0&&l.position.fromArray(s.translation),s.rotation!==void 0&&l.quaternion.fromArray(s.rotation),s.scale!==void 0&&l.scale.fromArray(s.scale);if(!n.associations.has(l))n.associations.set(l,{});else if(s.mesh!==void 0&&n.meshCache.refs[s.mesh]>1){let u=n.associations.get(l);n.associations.set(l,{...u})}return n.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,r=this.json.scenes[e],n=this,s=new X;r.name&&(s.name=n.createUniqueName(r.name)),M(s,r),r.extensions&&D(t,s,r);let i=r.nodes||[],a=[];for(let o=0,c=i.length;o<c;o++)a.push(n.getDependency("node",i[o]));return Promise.all(a).then(function(o){for(let l=0,u=o.length;l<u;l++)s.add(o[l]);let c=l=>{let u=new Map;for(let[f,d]of n.associations)(f instanceof V||f instanceof ee)&&u.set(f,d);return l.traverse(f=>{let d=n.associations.get(f);d!=null&&u.set(f,d)}),u};return n.associations=c(s),s})}_createAnimationTracks(e,t,r,n,s){let i=[],a=e.name?e.name:e.uuid,o=[];O[s.path]===O.weights?e.traverse(function(f){f.morphTargetInfluences&&o.push(f.name?f.name:f.uuid)}):o.push(a);let c;switch(O[s.path]){case O.weights:c=se;break;case O.rotation:c=re;break;case O.translation:case O.scale:c=ie;break;default:switch(r.itemSize){case 1:c=se;break;case 2:case 3:default:c=ie;break}break}let l=n.interpolation!==void 0?Ot[n.interpolation]:J,u=this._getArrayFromAccessor(r);for(let f=0,d=o.length;f<d;f++){let m=new c(o[f]+"."+O[s.path],t.array,u,l);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),i.push(m)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let r=ke(t.constructor),n=new Float32Array(t.length);for(let s=0,i=t.length;s<i;s++)n[s]=t[s]*r;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(r){let n=this instanceof re?De:z;return new n(this.times,this.values,this.getValueSize()/3,r)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function Ut(h,e,t){let r=e.attributes,n=new Ye;if(r.POSITION!==void 0){let a=t.json.accessors[r.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(n.set(new C(o[0],o[1],o[2]),new C(c[0],c[1],c[2])),a.normalized){let l=ke(v[a.componentType]);n.min.multiplyScalar(l),n.max.multiplyScalar(l)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=e.targets;if(s!==void 0){let a=new C,o=new C;for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u.POSITION!==void 0){let f=t.json.accessors[u.POSITION],d=f.min,m=f.max;if(d!==void 0&&m!==void 0){if(o.setX(Math.max(Math.abs(d[0]),Math.abs(m[0]))),o.setY(Math.max(Math.abs(d[1]),Math.abs(m[1]))),o.setZ(Math.max(Math.abs(d[2]),Math.abs(m[2]))),f.normalized){let R=ke(v[f.componentType]);o.multiplyScalar(R)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}h.boundingBox=n;let i=new Je;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,h.boundingSphere=i}function Mt(h,e,t){let r=e.attributes,n=[];function s(i,a){return t.getDependency("accessor",i).then(function(o){h.setAttribute(a,o)})}for(let i in r){let a=Pe[i]||i.toLowerCase();a in h.attributes||n.push(s(r[i],a))}if(e.indices!==void 0&&!h.index){let i=t.getDependency("accessor",e.indices).then(function(a){h.setIndex(a)});n.push(i)}return $.workingColorSpace!==N&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${$.workingColorSpace}" not supported.`),M(h,e),Ut(h,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Dt(h,e.targets,t):h})}export{yt as GLTFLoader};
1
+ import{b as ae}from"./chunk-GP5WKEWH.js";import{$ as F,$a as ie,Ba as at,C as P,Ca as ct,D as N,Da as ut,Ea as lt,Fa as ft,Ga as ht,N as We,O as Q,P as Z,Q as C,S as $,Ta as ne,Ua as S,V as ee,Y as Ye,Ya as dt,Z as Je,Za as se,_a as re,a as ve,ab as pt,ba as te,bb as mt,ca as I,cb as oe,d as Ue,da as V,db as gt,ea as k,eb as Tt,f as Fe,fa as G,fb as Rt,gb as At,ha as Qe,hb as _t,i as K,ia as Ze,j as je,jb as H,k as Ke,l as W,lb as xt,m as Be,n as Ve,na as $e,nb as Et,o as B,oa as X,p as Ge,q as Y,qa as et,ra as tt,sa as nt,ta as st,v as Xe,va as rt,w as J,wa as it,xa as ot,y as ze,z as qe}from"./chunk-3P7B76SS.js";import"./chunk-PWEV3AFA.js";ve();var yt=class extends mt{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new pe(t)}),this.register(function(t){return new me(t)}),this.register(function(t){return new Se(t)}),this.register(function(t){return new we(t)}),this.register(function(t){return new Ne(t)}),this.register(function(t){return new Te(t)}),this.register(function(t){return new Re(t)}),this.register(function(t){return new Ae(t)}),this.register(function(t){return new _e(t)}),this.register(function(t){return new de(t)}),this.register(function(t){return new xe(t)}),this.register(function(t){return new ge(t)}),this.register(function(t){return new ye(t)}),this.register(function(t){return new Ee(t)}),this.register(function(t){return new fe(t)}),this.register(function(t){return new Me(t)}),this.register(function(t){return new Le(t)})}load(e,t,r,n){let s=this,i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){let c=H.extractUrlBase(e);i=H.resolveURL(c,this.path)}else i=H.extractUrlBase(e);this.manager.itemStart(e);let a=function(c){n?n(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},o=new oe(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(c){try{s.parse(c,i,function(l){t(l),s.manager.itemEnd(e)},a)}catch(l){a(l)}},r,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,n){let s,i={},a={},o=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o.decode(new Uint8Array(e,0,4))===Lt){try{i[g.KHR_BINARY_GLTF]=new be(e)}catch(u){n&&n(u);return}s=JSON.parse(i[g.KHR_BINARY_GLTF].content)}else s=JSON.parse(o.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let c=new He(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){let u=this.pluginCallbacks[l](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,i[u.name]=!0}if(s.extensionsUsed)for(let l=0;l<s.extensionsUsed.length;++l){let u=s.extensionsUsed[l],f=s.extensionsRequired||[];switch(u){case g.KHR_MATERIALS_UNLIT:i[u]=new he;break;case g.KHR_DRACO_MESH_COMPRESSION:i[u]=new Ie(s,this.dracoLoader);break;case g.KHR_TEXTURE_TRANSFORM:i[u]=new Oe;break;case g.KHR_MESH_QUANTIZATION:i[u]=new Ce;break;default:f.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(i),c.setPlugins(a),c.parse(r,n)}parseAsync(e,t){let r=this;return new Promise(function(n,s){r.parse(e,t,n,s)})}};function bt(){let h={};return{get:function(e){return h[e]},add:function(e,t){h[e]=t},remove:function(e){delete h[e]},removeAll:function(){h={}}}}var 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_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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"},fe=class{constructor(e){this.parser=e,this.name=g.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let r=0,n=t.length;r<n;r++){let s=t[r];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){let t=this.parser,r="light:"+e,n=t.cache.get(r);if(n)return n;let s=t.json,o=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e],c,l=new I(16777215);o.color!==void 0&&l.setRGB(o.color[0],o.color[1],o.color[2],N);let u=o.range!==void 0?o.range:0;switch(o.type){case"directional":c=new _t(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new Rt(l),c.distance=u;break;case"spot":c=new Tt(l),c.distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=o.spot.innerConeAngle!==void 0?o.spot.innerConeAngle:0,o.spot.outerConeAngle=o.spot.outerConeAngle!==void 0?o.spot.outerConeAngle:Math.PI/4,c.angle=o.spot.outerConeAngle,c.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return c.position.set(0,0,0),M(c,o),o.intensity!==void 0&&(c.intensity=o.intensity),c.name=t.createUniqueName(o.name||"light_"+e),n=Promise.resolve(c),t.cache.add(r,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){let t=this,r=this.parser,s=r.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(o){return r._getNodeRef(t.cache,a,o)})}},he=class{constructor(){this.name=g.KHR_MATERIALS_UNLIT}getMaterialType(){return k}extendParams(e,t,r){let n=[];e.color=new I(1,1,1),e.opacity=1;let s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){let i=s.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],N),e.opacity=i[3]}s.baseColorTexture!==void 0&&n.push(r.assignTexture(e,"map",s.baseColorTexture,P))}return Promise.all(n)}},de=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=n.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}},pe=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(s.push(r.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){let a=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Q(a,a)}return Promise.all(s)}},me=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_DISPERSION}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=n.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}},ge=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&s.push(r.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(s)}},Te=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_SHEEN}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[];t.sheenColor=new I(0,0,0),t.sheenRoughness=0,t.sheen=1;let i=n.extensions[this.name];if(i.sheenColorFactor!==void 0){let a=i.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],N)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&s.push(r.assignTexture(t,"sheenColorMap",i.sheenColorTexture,P)),i.sheenRoughnessTexture!==void 0&&s.push(r.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}},Re=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&s.push(r.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(s)}},Ae=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_VOLUME}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&s.push(r.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;let a=i.attenuationColor||[1,1,1];return t.attenuationColor=new I().setRGB(a[0],a[1],a[2],N),Promise.all(s)}},_e=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_IOR}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=n.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}},xe=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_SPECULAR}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&s.push(r.assignTexture(t,"specularIntensityMap",i.specularTexture));let a=i.specularColorFactor||[1,1,1];return t.specularColor=new I().setRGB(a[0],a[1],a[2],N),i.specularColorTexture!==void 0&&s.push(r.assignTexture(t,"specularColorMap",i.specularColorTexture,P)),Promise.all(s)}},Ee=class{constructor(e){this.parser=e,this.name=g.EXT_MATERIALS_BUMP}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&s.push(r.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(s)}},ye=class{constructor(e){this.parser=e,this.name=g.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let r=this.parser.json.materials[e];return!r.extensions||!r.extensions[this.name]?null:S}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let s=[],i=n.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&s.push(r.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(s)}},Se=class{constructor(e){this.parser=e,this.name=g.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,r=t.json,n=r.textures[e];if(!n.extensions||!n.extensions[this.name])return null;let s=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,i)}},we=class{constructor(e){this.parser=e,this.name=g.EXT_TEXTURE_WEBP}loadTexture(e){let t=this.name,r=this.parser,n=r.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;let i=s.extensions[t],a=n.images[i.source],o=r.textureLoader;if(a.uri){let c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return r.loadTextureImage(e,i.source,o)}},Ne=class{constructor(e){this.parser=e,this.name=g.EXT_TEXTURE_AVIF}loadTexture(e){let t=this.name,r=this.parser,n=r.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;let i=s.extensions[t],a=n.images[i.source],o=r.textureLoader;if(a.uri){let c=r.options.manager.getHandler(a.uri);c!==null&&(o=c)}return r.loadTextureImage(e,i.source,o)}},Me=class{constructor(e){this.name=g.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){let n=r.extensions[this.name],s=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){let o=n.byteOffset||0,c=n.byteLength||0,l=n.count,u=n.byteStride,f=new Uint8Array(a,o,c);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(l,u,f,n.mode,n.filter).then(function(d){return d.buffer}):i.ready.then(function(){let d=new ArrayBuffer(l*u);return i.decodeGltfBuffer(new Uint8Array(d),l,u,f,n.mode,n.filter),d})})}else return null}},Le=class{constructor(e){this.name=g.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||r.mesh===void 0)return null;let n=t.meshes[r.mesh];for(let c of n.primitives)if(c.mode!==E.TRIANGLES&&c.mode!==E.TRIANGLE_STRIP&&c.mode!==E.TRIANGLE_FAN&&c.mode!==void 0)return null;let i=r.extensions[this.name].attributes,a=[],o={};for(let c in i)a.push(this.parser.getDependency("accessor",i[c]).then(l=>(o[c]=l,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{let l=c.pop(),u=l.isGroup?l.children:[l],f=c[0].count,d=[];for(let m of u){let R=new F,p=new C,T=new Z,_=new C(1,1,1),x=new ot(m.geometry,m.material,f);for(let A=0;A<f;A++)o.TRANSLATION&&p.fromBufferAttribute(o.TRANSLATION,A),o.ROTATION&&T.fromBufferAttribute(o.ROTATION,A),o.SCALE&&_.fromBufferAttribute(o.SCALE,A),x.setMatrixAt(A,R.compose(p,T,_));for(let A in o)if(A==="_COLOR_0"){let w=o[A];x.instanceColor=new it(w.array,w.itemSize,w.normalized)}else A!=="TRANSLATION"&&A!=="ROTATION"&&A!=="SCALE"&&m.geometry.setAttribute(A,o[A]);te.prototype.copy.call(x,m),this.parser.assignFinalMaterial(x),d.push(x)}return l.isGroup?(l.clear(),l.add(...d),l):d[0]}))}},Lt="glTF",j=12,St={JSON:1313821514,BIN:5130562},be=class{constructor(e){this.name=g.KHR_BINARY_GLTF,this.content=null,this.body=null;let t=new DataView(e,0,j),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Lt)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");let n=this.header.length-j,s=new DataView(e,j),i=0;for(;i<n;){let a=s.getUint32(i,!0);i+=4;let o=s.getUint32(i,!0);if(i+=4,o===St.JSON){let c=new Uint8Array(e,j+i,a);this.content=r.decode(c)}else if(o===St.BIN){let c=j+i;this.body=e.slice(c,c+a)}i+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}},Ie=class{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=g.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let r=this.json,n=this.dracoLoader,s=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},o={},c={};for(let l in i){let u=Pe[l]||l.toLowerCase();a[u]=i[l]}for(let l in e.attributes){let u=Pe[l]||l.toLowerCase();if(i[l]!==void 0){let f=r.accessors[e.attributes[l]],d=v[f.componentType];c[u]=d.name,o[u]=f.normalized===!0}}return t.getDependency("bufferView",s).then(function(l){return new Promise(function(u,f){n.decodeDracoFile(l,function(d){for(let m in d.attributes){let R=d.attributes[m],p=o[m];p!==void 0&&(R.normalized=p)}u(d)},a,c,N,f)})})}},Oe=class{constructor(){this.name=g.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}},Ce=class{constructor(){this.name=g.KHR_MESH_QUANTIZATION}},z=class extends dt{constructor(e,t,r,n){super(e,t,r,n)}copySampleValue_(e){let t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,s=e*n*3+n;for(let i=0;i!==n;i++)t[i]=r[s+i];return t}interpolate_(e,t,r,n){let s=this.resultBuffer,i=this.sampleValues,a=this.valueSize,o=a*2,c=a*3,l=n-t,u=(r-t)/l,f=u*u,d=f*u,m=e*c,R=m-c,p=-2*d+3*f,T=d-f,_=1-p,x=T-f+u;for(let A=0;A!==a;A++){let w=i[R+A+a],L=i[R+A+o]*l,y=i[m+A+a],U=i[m+A]*l;s[A]=_*w+x*L+p*y+T*U}return s}},It=new Z,De=class extends z{interpolate_(e,t,r,n){let s=super.interpolate_(e,t,r,n);return It.fromArray(s).normalize().toArray(s),s}},E={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},v={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},wt={9728:W,9729:B,9984:Be,9985:Ge,9986:Ve,9987:Y},Nt={33071:je,33648:Ke,10497:K},ce={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Pe={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},O={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ot={CUBICSPLINE:void 0,LINEAR:J,STEP:Xe},ue={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ct(h){return h.DefaultMaterial===void 0&&(h.DefaultMaterial=new ne({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Ue})),h.DefaultMaterial}function D(h,e,t){for(let r in t.extensions)h[r]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[r]=t.extensions[r])}function M(h,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(h.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Dt(h,e,t){let r=!1,n=!1,s=!1;for(let c=0,l=e.length;c<l;c++){let u=e[c];if(u.POSITION!==void 0&&(r=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(s=!0),r&&n&&s)break}if(!r&&!n&&!s)return Promise.resolve(h);let i=[],a=[],o=[];for(let c=0,l=e.length;c<l;c++){let u=e[c];if(r){let f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):h.attributes.position;i.push(f)}if(n){let f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):h.attributes.normal;a.push(f)}if(s){let f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):h.attributes.color;o.push(f)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o)]).then(function(c){let l=c[0],u=c[1],f=c[2];return r&&(h.morphAttributes.position=l),n&&(h.morphAttributes.normal=u),s&&(h.morphAttributes.color=f),h.morphTargetsRelative=!0,h})}function Pt(h,e){if(h.updateMorphTargets(),e.weights!==void 0)for(let t=0,r=e.weights.length;t<r;t++)h.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){let t=e.extras.targetNames;if(h.morphTargetInfluences.length===t.length){h.morphTargetDictionary={};for(let r=0,n=t.length;r<n;r++)h.morphTargetDictionary[t[r]]=r}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function kt(h){let e,t=h.extensions&&h.extensions[g.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+le(t.attributes):e=h.indices+":"+le(h.attributes)+":"+h.mode,h.targets!==void 0)for(let r=0,n=h.targets.length;r<n;r++)e+=":"+le(h.targets[r]);return e}function le(h){let e="",t=Object.keys(h).sort();for(let r=0,n=t.length;r<n;r++)e+=t[r]+":"+h[t[r]]+";";return e}function ke(h){switch(h){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Ht(h){return h.search(/\.jpe?g($|\?)/i)>0||h.search(/^data\:image\/jpeg/)===0?"image/jpeg":h.search(/\.webp($|\?)/i)>0||h.search(/^data\:image\/webp/)===0?"image/webp":h.search(/\.ktx2($|\?)/i)>0||h.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}var vt=new F,He=class{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new bt,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 r=!1,n=-1,s=!1,i=-1;if(typeof navigator<"u"){let a=navigator.userAgent;r=/^((?!chrome|android).)*safari/i.test(a)===!0;let o=a.match(/Version\/(\d+)/);n=r&&o?parseInt(o[1],10):-1,s=a.indexOf("Firefox")>-1,i=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||r&&n<17||s&&i<98?this.textureLoader=new gt(this.options.manager):this.textureLoader=new xt(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new oe(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){let r=this,n=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(i){let a={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:r,userData:{}};return D(s,a,n),M(a,n),Promise.all(r._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(let o of a.scenes)o.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let n=0,s=t.length;n<s;n++){let i=t[n].joints;for(let a=0,o=i.length;a<o;a++)e[i[a]].isBone=!0}for(let n=0,s=e.length;n<s;n++){let i=e[n];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(r[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;let n=r.clone(),s=(i,a)=>{let o=this.associations.get(i);o!=null&&this.associations.set(a,o);for(let[c,l]of i.children.entries())s(l,a.children[c])};return s(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){let n=e(t[r]);if(n)return n}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let r=[];for(let n=0;n<t.length;n++){let s=e(t[n]);s&&r.push(s)}return r}getDependency(e,t){let r=e+":"+t,n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":n=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(r,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){let r=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(s,i){return r.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],r=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[g.KHR_BINARY_GLTF].body);let n=this.options;return new Promise(function(s,i){r.load(H.resolveURL(t.uri,n.path),s,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(r){let n=t.byteLength||0,s=t.byteOffset||0;return r.slice(s,s+n)})}loadAccessor(e){let t=this,r=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){let i=ce[n.type],a=v[n.componentType],o=n.normalized===!0,c=new a(n.count*i);return Promise.resolve(new G(c,i,o))}let s=[];return n.bufferView!==void 0?s.push(this.getDependency("bufferView",n.bufferView)):s.push(null),n.sparse!==void 0&&(s.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(s).then(function(i){let a=i[0],o=ce[n.type],c=v[n.componentType],l=c.BYTES_PER_ELEMENT,u=l*o,f=n.byteOffset||0,d=n.bufferView!==void 0?r.bufferViews[n.bufferView].byteStride:void 0,m=n.normalized===!0,R,p;if(d&&d!==u){let T=Math.floor(f/d),_="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+T+":"+n.count,x=t.cache.get(_);x||(R=new c(a,T*d,n.count*d/l),x=new et(R,d/l),t.cache.add(_,x)),p=new tt(x,o,f%d/l,m)}else a===null?R=new c(n.count*o):R=new c(a,f,n.count*o),p=new G(R,o,m);if(n.sparse!==void 0){let T=ce.SCALAR,_=v[n.sparse.indices.componentType],x=n.sparse.indices.byteOffset||0,A=n.sparse.values.byteOffset||0,w=new _(i[1],x,n.sparse.count*T),L=new c(i[2],A,n.sparse.count*o);a!==null&&(p=new G(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let y=0,U=w.length;y<U;y++){let b=w[y];if(p.setX(b,L[y*o]),o>=2&&p.setY(b,L[y*o+1]),o>=3&&p.setZ(b,L[y*o+2]),o>=4&&p.setW(b,L[y*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=m}return p})}loadTexture(e){let t=this.json,r=this.options,s=t.textures[e].source,i=t.images[s],a=this.textureLoader;if(i.uri){let o=r.manager.getHandler(i.uri);o!==null&&(a=o)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,r){let n=this,s=this.json,i=s.textures[e],a=s.images[t],o=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[o])return this.textureCache[o];let c=this.loadImageSource(t,r).then(function(l){l.flipY=!1,l.name=i.name||a.name||"",l.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(l.name=a.uri);let f=(s.samplers||{})[i.sampler]||{};return l.magFilter=wt[f.magFilter]||B,l.minFilter=wt[f.minFilter]||Y,l.wrapS=Nt[f.wrapS]||K,l.wrapT=Nt[f.wrapT]||K,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==W&&l.minFilter!==B,n.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(e,t){let r=this,n=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());let i=n.images[e],a=self.URL||self.webkitURL,o=i.uri||"",c=!1;if(i.bufferView!==void 0)o=r.getDependency("bufferView",i.bufferView).then(function(u){c=!0;let f=new Blob([u],{type:i.mimeType});return o=a.createObjectURL(f),o});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(o).then(function(u){return new Promise(function(f,d){let m=f;t.isImageBitmapLoader===!0&&(m=function(R){let p=new ee(R);p.needsUpdate=!0,f(p)}),t.load(H.resolveURL(u,s.path),m,void 0,d)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),M(u,i),u.userData.mimeType=i.mimeType||Ht(i.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[e]=l,l}assignTexture(e,t,r,n){let s=this;return this.getDependency("texture",r.index).then(function(i){if(!i)return null;if(r.texCoord!==void 0&&r.texCoord>0&&(i=i.clone(),i.channel=r.texCoord),s.extensions[g.KHR_TEXTURE_TRANSFORM]){let a=r.extensions!==void 0?r.extensions[g.KHR_TEXTURE_TRANSFORM]:void 0;if(a){let o=s.associations.get(i);i=s.extensions[g.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),s.associations.set(i,o)}}return n!==void 0&&(i.colorSpace=n),e[t]=i,i})}assignFinalMaterial(e){let t=e.geometry,r=e.material,n=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){let a="PointsMaterial:"+r.uuid,o=this.cache.get(a);o||(o=new ft,V.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,o.sizeAttenuation=!1,this.cache.add(a,o)),r=o}else if(e.isLine){let a="LineBasicMaterial:"+r.uuid,o=this.cache.get(a);o||(o=new at,V.prototype.copy.call(o,r),o.color.copy(r.color),o.map=r.map,this.cache.add(a,o)),r=o}if(n||s||i){let a="ClonedMaterial:"+r.uuid+":";n&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=r.clone(),s&&(o.vertexColors=!0),i&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(r))),r=o}e.material=r}getMaterialType(){return ne}loadMaterial(e){let t=this,r=this.json,n=this.extensions,s=r.materials[e],i,a={},o=s.extensions||{},c=[];if(o[g.KHR_MATERIALS_UNLIT]){let u=n[g.KHR_MATERIALS_UNLIT];i=u.getMaterialType(),c.push(u.extendParams(a,s,t))}else{let u=s.pbrMetallicRoughness||{};if(a.color=new I(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){let f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],N),a.opacity=f[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,P)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),i=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Fe);let l=s.alphaMode||ue.OPAQUE;if(l===ue.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===ue.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&i!==k&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new Q(1,1),s.normalTexture.scale!==void 0)){let u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&i!==k&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&i!==k){let u=s.emissiveFactor;a.emissive=new I().setRGB(u[0],u[1],u[2],N)}return s.emissiveTexture!==void 0&&i!==k&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,P)),Promise.all(c).then(function(){let u=new i(a);return s.name&&(u.name=s.name),M(u,s),t.associations.set(u,{materials:e}),s.extensions&&D(n,u,s),u})}createUniqueName(e){let t=Et.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,r=this.extensions,n=this.primitiveCache;function s(a){return r[g.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(o){return Mt(o,a,t)})}let i=[];for(let a=0,o=e.length;a<o;a++){let c=e[a],l=kt(c),u=n[l];if(u)i.push(u.promise);else{let f;c.extensions&&c.extensions[g.KHR_DRACO_MESH_COMPRESSION]?f=s(c):f=Mt(new Qe,c,t),n[l]={primitive:c,promise:f},i.push(f)}}return Promise.all(i)}loadMesh(e){let t=this,r=this.json,n=this.extensions,s=r.meshes[e],i=s.primitives,a=[];for(let o=0,c=i.length;o<c;o++){let l=i[o].material===void 0?Ct(this.cache):this.getDependency("material",i[o].material);a.push(l)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(o){let c=o.slice(0,o.length-1),l=o[o.length-1],u=[];for(let d=0,m=l.length;d<m;d++){let R=l[d],p=i[d],T,_=c[d];if(p.mode===E.TRIANGLES||p.mode===E.TRIANGLE_STRIP||p.mode===E.TRIANGLE_FAN||p.mode===void 0)T=s.isSkinnedMesh===!0?new nt(R,_):new Ze(R,_),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),p.mode===E.TRIANGLE_STRIP?T.geometry=ae(T.geometry,ze):p.mode===E.TRIANGLE_FAN&&(T.geometry=ae(T.geometry,qe));else if(p.mode===E.LINES)T=new ut(R,_);else if(p.mode===E.LINE_STRIP)T=new ct(R,_);else if(p.mode===E.LINE_LOOP)T=new lt(R,_);else if(p.mode===E.POINTS)T=new ht(R,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);Object.keys(T.geometry.morphAttributes).length>0&&Pt(T,s),T.name=t.createUniqueName(s.name||"mesh_"+e),M(T,s),p.extensions&&D(n,T,p),t.assignFinalMaterial(T),u.push(T)}for(let d=0,m=u.length;d<m;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return s.extensions&&D(n,u[0],s),u[0];let f=new X;s.extensions&&D(n,f,s),t.associations.set(f,{meshes:e});for(let d=0,m=u.length;d<m;d++)f.add(u[d]);return f})}loadCamera(e){let t,r=this.json.cameras[e],n=r[r.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return r.type==="perspective"?t=new $e(We.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):r.type==="orthographic"&&(t=new At(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),M(t,r),Promise.resolve(t)}loadSkin(e){let t=this.json.skins[e],r=[];for(let n=0,s=t.joints.length;n<s;n++)r.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(n){let s=n.pop(),i=n,a=[],o=[];for(let c=0,l=i.length;c<l;c++){let u=i[c];if(u){a.push(u);let f=new F;s!==null&&f.fromArray(s.array,c*16),o.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new rt(a,o)})}loadAnimation(e){let t=this.json,r=this,n=t.animations[e],s=n.name?n.name:"animation_"+e,i=[],a=[],o=[],c=[],l=[];for(let u=0,f=n.channels.length;u<f;u++){let d=n.channels[u],m=n.samplers[d.sampler],R=d.target,p=R.node,T=n.parameters!==void 0?n.parameters[m.input]:m.input,_=n.parameters!==void 0?n.parameters[m.output]:m.output;R.node!==void 0&&(i.push(this.getDependency("node",p)),a.push(this.getDependency("accessor",T)),o.push(this.getDependency("accessor",_)),c.push(m),l.push(R))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(o),Promise.all(c),Promise.all(l)]).then(function(u){let f=u[0],d=u[1],m=u[2],R=u[3],p=u[4],T=[];for(let _=0,x=f.length;_<x;_++){let A=f[_],w=d[_],L=m[_],y=R[_],U=p[_];if(A===void 0)continue;A.updateMatrix&&A.updateMatrix();let b=r._createAnimationTracks(A,w,L,y,U);if(b)for(let q=0;q<b.length;q++)T.push(b[q])}return new pt(s,void 0,T)})}createNodeMesh(e){let t=this.json,r=this,n=t.nodes[e];return n.mesh===void 0?null:r.getDependency("mesh",n.mesh).then(function(s){let i=r._getNodeRef(r.meshCache,n.mesh,s);return n.weights!==void 0&&i.traverse(function(a){if(a.isMesh)for(let o=0,c=n.weights.length;o<c;o++)a.morphTargetInfluences[o]=n.weights[o]}),i})}loadNode(e){let t=this.json,r=this,n=t.nodes[e],s=r._loadNodeShallow(e),i=[],a=n.children||[];for(let c=0,l=a.length;c<l;c++)i.push(r.getDependency("node",a[c]));let o=n.skin===void 0?Promise.resolve(null):r.getDependency("skin",n.skin);return Promise.all([s,Promise.all(i),o]).then(function(c){let l=c[0],u=c[1],f=c[2];f!==null&&l.traverse(function(d){d.isSkinnedMesh&&d.bind(f,vt)});for(let d=0,m=u.length;d<m;d++)l.add(u[d]);return l})}_loadNodeShallow(e){let t=this.json,r=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];let s=t.nodes[e],i=s.name?n.createUniqueName(s.name):"",a=[],o=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return o&&a.push(o),s.camera!==void 0&&a.push(n.getDependency("camera",s.camera).then(function(c){return n._getNodeRef(n.cameraCache,s.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let l;if(s.isBone===!0?l=new st:c.length>1?l=new X:c.length===1?l=c[0]:l=new te,l!==c[0])for(let u=0,f=c.length;u<f;u++)l.add(c[u]);if(s.name&&(l.userData.name=s.name,l.name=i),M(l,s),s.extensions&&D(r,l,s),s.matrix!==void 0){let u=new F;u.fromArray(s.matrix),l.applyMatrix4(u)}else s.translation!==void 0&&l.position.fromArray(s.translation),s.rotation!==void 0&&l.quaternion.fromArray(s.rotation),s.scale!==void 0&&l.scale.fromArray(s.scale);if(!n.associations.has(l))n.associations.set(l,{});else if(s.mesh!==void 0&&n.meshCache.refs[s.mesh]>1){let u=n.associations.get(l);n.associations.set(l,{...u})}return n.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){let t=this.extensions,r=this.json.scenes[e],n=this,s=new X;r.name&&(s.name=n.createUniqueName(r.name)),M(s,r),r.extensions&&D(t,s,r);let i=r.nodes||[],a=[];for(let o=0,c=i.length;o<c;o++)a.push(n.getDependency("node",i[o]));return Promise.all(a).then(function(o){for(let l=0,u=o.length;l<u;l++)s.add(o[l]);let c=l=>{let u=new Map;for(let[f,d]of n.associations)(f instanceof V||f instanceof ee)&&u.set(f,d);return l.traverse(f=>{let d=n.associations.get(f);d!=null&&u.set(f,d)}),u};return n.associations=c(s),s})}_createAnimationTracks(e,t,r,n,s){let i=[],a=e.name?e.name:e.uuid,o=[];O[s.path]===O.weights?e.traverse(function(f){f.morphTargetInfluences&&o.push(f.name?f.name:f.uuid)}):o.push(a);let c;switch(O[s.path]){case O.weights:c=se;break;case O.rotation:c=re;break;case O.translation:case O.scale:c=ie;break;default:switch(r.itemSize){case 1:c=se;break;case 2:case 3:default:c=ie;break}break}let l=n.interpolation!==void 0?Ot[n.interpolation]:J,u=this._getArrayFromAccessor(r);for(let f=0,d=o.length;f<d;f++){let m=new c(o[f]+"."+O[s.path],t.array,u,l);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),i.push(m)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let r=ke(t.constructor),n=new Float32Array(t.length);for(let s=0,i=t.length;s<i;s++)n[s]=t[s]*r;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(r){let n=this instanceof re?De:z;return new n(this.times,this.values,this.getValueSize()/3,r)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}};function Ut(h,e,t){let r=e.attributes,n=new Ye;if(r.POSITION!==void 0){let a=t.json.accessors[r.POSITION],o=a.min,c=a.max;if(o!==void 0&&c!==void 0){if(n.set(new C(o[0],o[1],o[2]),new C(c[0],c[1],c[2])),a.normalized){let l=ke(v[a.componentType]);n.min.multiplyScalar(l),n.max.multiplyScalar(l)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;let s=e.targets;if(s!==void 0){let a=new C,o=new C;for(let c=0,l=s.length;c<l;c++){let u=s[c];if(u.POSITION!==void 0){let f=t.json.accessors[u.POSITION],d=f.min,m=f.max;if(d!==void 0&&m!==void 0){if(o.setX(Math.max(Math.abs(d[0]),Math.abs(m[0]))),o.setY(Math.max(Math.abs(d[1]),Math.abs(m[1]))),o.setZ(Math.max(Math.abs(d[2]),Math.abs(m[2]))),f.normalized){let R=ke(v[f.componentType]);o.multiplyScalar(R)}a.max(o)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}h.boundingBox=n;let i=new Je;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,h.boundingSphere=i}function Mt(h,e,t){let r=e.attributes,n=[];function s(i,a){return t.getDependency("accessor",i).then(function(o){h.setAttribute(a,o)})}for(let i in r){let a=Pe[i]||i.toLowerCase();a in h.attributes||n.push(s(r[i],a))}if(e.indices!==void 0&&!h.index){let i=t.getDependency("accessor",e.indices).then(function(a){h.setIndex(a)});n.push(i)}return $.workingColorSpace!==N&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${$.workingColorSpace}" not supported.`),M(h,e),Ut(h,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Dt(h,e.targets,t):h})}export{yt as GLTFLoader};