endset_three_editor 0.9.6 → 0.9.7

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.
@@ -135,7 +135,7 @@
135
135
  `,i.setAttribute("data-item-code",n.code||""),i.innerHTML=`
136
136
  <span class="item-label" style="flex-shrink:0;letter-spacing:0.02em;color:#8cc8ff;">${this.escapeHtml(n.label)}</span>
137
137
  <span class="item-value" style="font-weight:700;color:#ffffff;text-shadow:0 0 0.62em rgba(0, 200, 255, 0.40);text-align:right;word-break:break-all;">${this.escapeHtml(n.value)}${n.unit?`<span style="font-size:0.85em;margin-left:0.15em;color:#8cc8ff;">${this.escapeHtml(n.unit)}</span>`:""}</span>
138
- `,e.appendChild(i)})}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}attachTo(e){this.attachedObject&&this.attachedObject!==e&&this.detach();const t=new S.Vector3;e.getWorldPosition(t);const i=new S.Box3().setFromObject(e).max.y-t.y+this.options.offsetY;this.css2dObject||(this.css2dObject=new jn(this.container),this.css2dObject.name=`DataPanel_${e.name||e.uuid}`,this.css2dObject.center.set(.5,1)),this.css2dObject.position.set(this.options.offsetX,i,this.options.offsetZ??0),e.add(this.css2dObject),this.attachedObject=e}detach(){this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.attachedObject=null}show(){this._visible=!0,this.css2dObject&&(this.css2dObject.visible=!0)}hide(){this._visible=!1,this.css2dObject&&(this.css2dObject.visible=!1)}get visible(){return this._visible}set visible(e){e?this.show():this.hide()}setTitle(e){var n;this.options.title=e;const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-title]");e?t?t.textContent=e:this.rebuildPanel():t&&t.remove()}getTitle(){return this.options.title||""}setItems(e){var n;this.options.items=[...e];const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}getItems(){return[...this.options.items||[]]}addItem(e){var n;this.options.items.push(e);const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}removeItem(e){var n;this.options.items=this.options.items.filter(s=>s.label!==e);const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}updateItem(e,t,n){var i;const s=this.options.items.find(o=>o.label===e);if(s){s.value=t,n!==void 0&&(s.unit=n);const o=(i=this.container)==null?void 0:i.querySelector("[data-panel-list]");o&&this.renderItems(o,this.options.items)}}updateItemByCode(e,t){var s;const n=this.options.items.find(i=>i.code===e);if(n){n.value=t;const i=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");i&&this.renderItems(i,this.options.items)}}clearItems(){var t;this.options.items=[];const e=(t=this.container)==null?void 0:t.querySelector("[data-panel-list]");e&&this.renderItems(e,[])}rebuildPanel(){const e=this._visible,t=this.attachedObject;this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.buildPanel(),t&&(this.attachedObject=t,t.add(this.css2dObject),e||this.hide())}updateOptions(e){this.options={...this.options,...e},this.rebuildPanel()}getOffsetY(){return this.options.offsetY??.1}setOffsetY(e){if(this.options.offsetY=e,this.css2dObject&&this.attachedObject){const t=new S.Vector3;this.attachedObject.getWorldPosition(t);const s=new S.Box3().setFromObject(this.attachedObject).max.y-t.y;this.css2dObject.position.set(this.options.offsetX??0,s+e,this.options.offsetZ??0)}}getOffsetX(){return this.options.offsetX??0}setOffsetX(e){this.options.offsetX=e,this.css2dObject&&this.attachedObject&&(this.css2dObject.position.x=e)}getOffsetZ(){return this.options.offsetZ??0}setOffsetZ(e){this.options.offsetZ=e,this.css2dObject&&this.attachedObject&&(this.css2dObject.position.z=e)}getWidth(){return this.options.width||"20em"}getFontSize(){return this.options.fontSize||"0.85em"}setWidth(e){this.options.width=e,this.container&&(this.container.style.width=e)}setFontSize(e){if(this.options.fontSize=e,this.container){this.container.style.fontSize=e;const t=this.container.querySelector("[data-panel-title]");t&&(t.style.fontSize=`calc(${e} + 0.15em)`)}}getElement(){return this.container}dispose(){var e;this.detach(),(e=this.container)!=null&&e.parentNode&&this.container.parentNode.removeChild(this.container),this.css2dObject=null,this.container=null,this.attachedObject=null}};Me(Re,"_breathInjected",!1);let ze=Re;const ot=new WeakMap;function gs(r,e){const t=a.toRaw(r);ot.set(t,e),t.userData._hasDataPanel=!0}function Oe(r){return ot.get(a.toRaw(r))||null}function Et(r){const e=a.toRaw(r),t=ot.get(e);t&&(t.dispose(),ot.delete(e)),e.userData._hasDataPanel=void 0}let _=null;function ys(r){return _?(_.domElement.parentNode!==r&&r.appendChild(_.domElement),_):(_=new Un,_.setSize(r.clientWidth,r.clientHeight),_.domElement.style.position="absolute",_.domElement.style.top="0",_.domElement.style.left="0",_.domElement.style.pointerEvents="none",r.appendChild(_.domElement),_)}function Qn(){return _}function bs(r,e){_&&_.render(r,e)}function xs(r,e){_&&_.setSize(r,e)}function Is(){_&&(_.domElement.parentNode&&_.domElement.parentNode.removeChild(_.domElement),_=null)}function Jn(){const r=new S.Scene;r.position.y=-3.5;const e=new S.BoxGeometry;e.deleteAttribute("uv");const t=new S.MeshStandardMaterial({side:S.BackSide}),n=new S.PointLight(16777215,900,28,2);n.position.set(.418,16.199,.3),r.add(n);const s=new S.Mesh(e,t);s.position.set(-.757,13.219,.717),s.scale.set(31.713,28.305,28.591),r.add(s);const i=new S.MeshStandardMaterial,o=new S.InstancedMesh(e,i,6),l=new S.Object3D;l.position.set(-10.906,2.009,1.846),l.rotation.set(0,-.195,0),l.scale.set(2.328,7.905,4.651),l.updateMatrix(),o.setMatrixAt(0,l.matrix),l.position.set(-5.607,-.754,-.758),l.rotation.set(0,.994,0),l.scale.set(1.97,1.534,3.955),l.updateMatrix(),o.setMatrixAt(1,l.matrix),l.position.set(6.167,.857,7.803),l.rotation.set(0,.561,0),l.scale.set(3.927,6.285,3.687),l.updateMatrix(),o.setMatrixAt(2,l.matrix),l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),l.updateMatrix(),o.setMatrixAt(3,l.matrix),l.position.set(2.291,-.756,-2.621),l.rotation.set(0,-.286,0),l.scale.set(1.546,1.552,1.496),l.updateMatrix(),o.setMatrixAt(4,l.matrix),l.position.set(-2.193,-.369,-5.547),l.rotation.set(0,.516,0),l.scale.set(3.875,3.487,2.986),l.updateMatrix(),o.setMatrixAt(5,l.matrix),o.instanceMatrix.needsUpdate=!0,r.add(o);function u(m){return new S.MeshLambertMaterial({color:0,emissive:16777215,emissiveIntensity:m})}const d=new S.Mesh(e,u(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),r.add(d);const f=new S.Mesh(e,u(50));f.position.set(-16.109,18.021,-8.207),f.scale.set(.1,2.425,2.751),r.add(f);const h=new S.Mesh(e,u(17));h.position.set(14.904,12.198,-1.832),h.scale.set(.15,4.265,6.331),r.add(h);const g=new S.Mesh(e,u(43));g.position.set(-.462,8.89,14.52),g.scale.set(4.38,5.441,.088),r.add(g);const A=new S.Mesh(e,u(20));A.position.set(3.235,11.486,-12.541),A.scale.set(2.5,2,.1),r.add(A);const b=new S.Mesh(e,u(100));return b.position.set(0,20,0),b.scale.set(1,.1,1),r.add(b),r}function xt(r){try{const e=new S.PMREMGenerator(r),t=Jn(),n=e.fromScene(t).texture;return t.traverse(s=>{if(s.isMesh){const i=s,o=Array.isArray(i.material)?i.material:[i.material];for(const l of o)l&&l.dispose()}}),e.dispose(),n}catch(e){return console.error("环境贴图生成失败:",e),null}}const es={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"]};class Fe{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new li(e)}),this.register(function(e){return new ci(e)}),this.register(function(e){return new fi(e)}),this.register(function(e){return new pi(e)}),this.register(function(e){return new mi(e)}),this.register(function(e){return new Ai(e)}),this.register(function(e){return new ui(e)}),this.register(function(e){return new di(e)}),this.register(function(e){return new hi(e)}),this.register(function(e){return new gi(e)}),this.register(function(e){return new yi(e)}),this.register(function(e){return new bi(e)}),this.register(function(e){return new xi(e)}),this.register(function(e){return new Ii(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,t,n,s){const i=new ai,o=[];for(let l=0,u=this.pluginCallbacks.length;l<u;l++)o.push(this.pluginCallbacks[l](i));i.setPlugins(o),i.setTextureUtils(this.textureUtils),i.writeAsync(e,t,s).catch(n)}parseAsync(e,t){const n=this;return new Promise(function(s,i){n.parse(e,s,i,t)})}}const F={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,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},ft="KHR_mesh_quantization",re={};re[c.NearestFilter]=F.NEAREST;re[c.NearestMipmapNearestFilter]=F.NEAREST_MIPMAP_NEAREST;re[c.NearestMipmapLinearFilter]=F.NEAREST_MIPMAP_LINEAR;re[c.LinearFilter]=F.LINEAR;re[c.LinearMipmapNearestFilter]=F.LINEAR_MIPMAP_NEAREST;re[c.LinearMipmapLinearFilter]=F.LINEAR_MIPMAP_LINEAR;re[c.ClampToEdgeWrapping]=F.CLAMP_TO_EDGE;re[c.RepeatWrapping]=F.REPEAT;re[c.MirroredRepeatWrapping]=F.MIRRORED_REPEAT;const ts={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},_n=new c.Color,ss=12,$n=1179937895,ei=2,ns=8,ti=1313821514,si=5130562;function me(r,e){return r.length===e.length&&r.every(function(t,n){return t===e[n]})}function ni(r){return new TextEncoder().encode(r).buffer}function ii(r){return me(r.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function oi(r,e,t){const n={min:new Array(r.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(r.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=e;s<e+t;s++)for(let i=0;i<r.itemSize;i++){let o;r.itemSize>4?o=r.array[s*r.itemSize+i]:(i===0?o=r.getX(s):i===1?o=r.getY(s):i===2?o=r.getZ(s):i===3&&(o=r.getW(s)),r.normalized===!0&&(o=c.MathUtils.normalize(o,r.array))),n.min[i]=Math.min(n.min[i],o),n.max[i]=Math.max(n.max[i],o)}return n}function Cs(r){return Math.ceil(r/4)*4}function pt(r,e=0){const t=Cs(r.byteLength);if(t!==r.byteLength){const n=new Uint8Array(t);if(n.set(new Uint8Array(r)),e!==0)for(let s=r.byteLength;s<t;s++)n[s]=e;return n.buffer}return r}function is(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function ri(r,e){if(typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas){let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),r.convertToBlob({type:e,quality:t})}else return new Promise(t=>r.toBlob(t,e))}class ai{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 r"+c.REVISION}},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,t,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);const s=this,i=s.buffers,o=s.json;n=s.options;const l=s.extensionsUsed,u=s.extensionsRequired,d=new Blob(i,{type:"application/octet-stream"}),f=Object.keys(l),h=Object.keys(u);if(f.length>0&&(o.extensionsUsed=f),h.length>0&&(o.extensionsRequired=h),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=d.size),n.binary===!0){const g=new FileReader;g.readAsArrayBuffer(d),g.onloadend=function(){const A=pt(g.result),b=new DataView(new ArrayBuffer(ns));b.setUint32(0,A.byteLength,!0),b.setUint32(4,si,!0);const m=pt(ni(JSON.stringify(o)),32),p=new DataView(new ArrayBuffer(ns));p.setUint32(0,m.byteLength,!0),p.setUint32(4,ti,!0);const x=new ArrayBuffer(ss),M=new DataView(x);M.setUint32(0,$n,!0),M.setUint32(4,ei,!0);const w=ss+p.byteLength+m.byteLength+b.byteLength+A.byteLength;M.setUint32(8,w,!0);const y=new Blob([x,p,m,b,A],{type:"application/octet-stream"}),E=new FileReader;E.readAsArrayBuffer(y),E.onloadend=function(){t(E.result)}}}else if(o.buffers&&o.buffers.length>0){const g=new FileReader;g.readAsDataURL(d),g.onloadend=function(){const A=g.result;o.buffers[0].uri=A,t(o)}}else t(o)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const n=this.options,s=this.extensionsUsed;try{const i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const o in i.gltfExtensions)t.extensions[o]=i.gltfExtensions[o],s[o]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.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,t=!1){if(this.uids.has(e)===!1){const s=new Map;s.set(!0,this.uid++),s.set(!1,this.uid++),this.uids.set(e,s)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new c.Vector3;for(let s=0,i=e.count;s<i;s++)if(Math.abs(n.fromBufferAttribute(e,s).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const n=e.clone(),s=new c.Vector3;for(let i=0,o=n.count;i<o;i++)s.fromBufferAttribute(n,i),s.x===0&&s.y===0&&s.z===0?s.setX(1):s.normalize(),n.setXYZ(i,s.x,s.y,s.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1;const s={};(t.offset.x!==0||t.offset.y!==0)&&(s.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(s.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(s.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=s,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,t){if(e===t)return e;function n(A){return A.colorSpace===c.SRGBColorSpace?function(m){return m<.04045?m*.0773993808:Math.pow(m*.9478672986+.0521327014,2.4)}:function(m){return m}}e instanceof c.CompressedTexture&&(e=await this.decompressTextureAsync(e)),t instanceof c.CompressedTexture&&(t=await this.decompressTextureAsync(t));const s=e?e.image:null,i=t?t.image:null,o=Math.max(s?s.width:0,i?i.width:0),l=Math.max(s?s.height:0,i?i.height:0),u=is();u.width=o,u.height=l;const d=u.getContext("2d",{willReadFrequently:!0});d.fillStyle="#00ffff",d.fillRect(0,0,o,l);const f=d.getImageData(0,0,o,l);if(s){d.drawImage(s,0,0,o,l);const A=n(e),b=d.getImageData(0,0,o,l).data;for(let m=2;m<b.length;m+=4)f.data[m]=A(b[m]/256)*256}if(i){d.drawImage(i,0,0,o,l);const A=n(t),b=d.getImageData(0,0,o,l).data;for(let m=1;m<b.length;m+=4)f.data[m]=A(b[m]/256)*256}d.putImageData(f,0,0);const g=(e||t).clone();return g.source=new c.Source(u),g.colorSpace=c.NoColorSpace,g.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),g}async decompressTextureAsync(e,t=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,t)}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,s,i){const o=this.json;o.bufferViews||(o.bufferViews=[]);let l;switch(t){case F.BYTE:case F.UNSIGNED_BYTE:l=1;break;case F.SHORT:case F.UNSIGNED_SHORT:l=2;break;default:l=4}let u=e.itemSize*l;i===F.ARRAY_BUFFER&&(u=Math.ceil(u/4)*4);const d=Cs(s*u),f=new DataView(new ArrayBuffer(d));let h=0;for(let b=n;b<n+s;b++){for(let m=0;m<e.itemSize;m++){let p;e.itemSize>4?p=e.array[b*e.itemSize+m]:(m===0?p=e.getX(b):m===1?p=e.getY(b):m===2?p=e.getZ(b):m===3&&(p=e.getW(b)),e.normalized===!0&&(p=c.MathUtils.normalize(p,e.array))),t===F.FLOAT?f.setFloat32(h,p,!0):t===F.INT?f.setInt32(h,p,!0):t===F.UNSIGNED_INT?f.setUint32(h,p,!0):t===F.SHORT?f.setInt16(h,p,!0):t===F.UNSIGNED_SHORT?f.setUint16(h,p,!0):t===F.BYTE?f.setInt8(h,p):t===F.UNSIGNED_BYTE&&f.setUint8(h,p),h+=l}h%u!==0&&(h+=u-h%u)}const g={buffer:this.processBuffer(f.buffer),byteOffset:this.byteOffset,byteLength:d};return i!==void 0&&(g.target=i),i===F.ARRAY_BUFFER&&(g.byteStride=u),this.byteOffset+=d,o.bufferViews.push(g),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(s){const i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){const o=pt(i.result),l={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,s(n.bufferViews.push(l)-1)}})}processAccessor(e,t,n,s){const i=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let l;if(e.array.constructor===Float32Array)l=F.FLOAT;else if(e.array.constructor===Int32Array)l=F.INT;else if(e.array.constructor===Uint32Array)l=F.UNSIGNED_INT;else if(e.array.constructor===Int16Array)l=F.SHORT;else if(e.array.constructor===Uint16Array)l=F.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)l=F.BYTE;else if(e.array.constructor===Uint8Array)l=F.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(s===void 0||s===1/0)&&(s=e.count),s===0)return null;const u=oi(e,n,s);let d;t!==void 0&&(d=e===t.index?F.ELEMENT_ARRAY_BUFFER:F.ARRAY_BUFFER);const f=this.processBufferView(e,l,n,s,d),h={bufferView:f.id,byteOffset:f.byteOffset,componentType:l,count:s,max:u.max,min:u.min,type:o[e.itemSize]};return e.normalized===!0&&(h.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(h)-1}processImage(e,t,n,s="image/png"){if(e!==null){const i=this,o=i.cache,l=i.json,u=i.options,d=i.pending;o.images.has(e)||o.images.set(e,{});const f=o.images.get(e),h=s+":flipY/"+n.toString();if(f[h]!==void 0)return f[h];l.images||(l.images=[]);const g={mimeType:s},A=is();A.width=Math.min(e.width,u.maxTextureSize),A.height=Math.min(e.height,u.maxTextureSize);const b=A.getContext("2d",{willReadFrequently:!0});if(n===!0&&(b.translate(0,A.height),b.scale(1,-1)),e.data!==void 0){t!==c.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>u.maxTextureSize||e.height>u.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const p=new Uint8ClampedArray(e.height*e.width*4);for(let x=0;x<p.length;x+=4)p[x+0]=e.data[x+0],p[x+1]=e.data[x+1],p[x+2]=e.data[x+2],p[x+3]=e.data[x+3];b.putImageData(new ImageData(p,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)b.drawImage(e,0,0,A.width,A.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");u.binary===!0?d.push(ri(A,s).then(p=>i.processBufferViewImage(p)).then(p=>{g.bufferView=p})):g.uri=c.ImageUtils.getDataURL(A,s);const m=l.images.push(g)-1;return f[h]=m,m}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const n={magFilter:re[e.magFilter],minFilter:re[e.minFilter],wrapS:re[e.wrapS],wrapT:re[e.wrapT]};return t.samplers.push(n)-1}async processTextureAsync(e){const n=this.options,s=this.cache,i=this.json;if(s.textures.has(e))return s.textures.get(e);i.textures||(i.textures=[]),e instanceof c.CompressedTexture&&(e=await this.decompressTextureAsync(e,n.maxTextureSize));const o=e.userData.mimeType,l=this.processImage(e.image,e.format,e.flipY,o),u={sampler:this.processSampler(e)};o==="image/webp"?(u.extensions=u.extensions||{},u.extensions.EXT_texture_webp={source:l},this.extensionsUsed.EXT_texture_webp=!0,this.extensionsRequired.EXT_texture_webp=!0):u.source=l,e.name&&(u.name=e.name),await this._invokeAllAsync(async function(f){f.writeTexture&&await f.writeTexture(e,u)});const d=i.textures.push(u)-1;return s.textures.set(e,d),d}async processMaterialAsync(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const s={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const i=e.color.toArray().concat([e.opacity]);if(me(i,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=e.metalness,s.pbrMetallicRoughness.roughnessFactor=e.roughness):(s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){const l=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),u={index:await this.processTextureAsync(l),texCoord:l.channel};this.applyTextureTransform(u,l),s.pbrMetallicRoughness.metallicRoughnessTexture=u}if(e.map){const l={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(l,e.map),s.pbrMetallicRoughness.baseColorTexture=l}if(e.emissive){const l=e.emissive;if(Math.max(l.r,l.g,l.b)>0&&(s.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const d={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(d,e.emissiveMap),s.emissiveTexture=d}}if(e.normalMap){const l={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(l.scale=e.normalScale.x),this.applyTextureTransform(l,e.normalMap),s.normalTexture=l}if(e.aoMap){const l={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(l.strength=e.aoMapIntensity),this.applyTextureTransform(l,e.aoMap),s.occlusionTexture=l}e.transparent?s.alphaMode="BLEND":e.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),e.side===c.DoubleSide&&(s.doubleSided=!0),e.name!==""&&(s.name=e.name),this.serializeUserData(e,s),await this._invokeAllAsync(async function(l){l.writeMaterialAsync&&await l.writeMaterialAsync(e,s)});const o=n.materials.push(s)-1;return t.materials.set(e,o),o}async processMeshAsync(e){const t=this.cache,n=this.json,s=[e.geometry.uuid];if(Array.isArray(e.material))for(let y=0,E=e.material.length;y<E;y++)s.push(e.material[y].uuid);else s.push(e.material.uuid);const i=s.join(":");if(t.meshes.has(i))return t.meshes.get(i);const o=e.geometry;let l;e.isLineSegments?l=F.LINES:e.isLineLoop?l=F.LINE_LOOP:e.isLine?l=F.LINE_STRIP:e.isPoints?l=F.POINTS:l=e.material.wireframe?F.LINES:F.TRIANGLES;const u={},d={},f=[],h=[],g={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},A=o.getAttribute("normal");A!==void 0&&!this.isNormalizedNormalAttribute(A)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(A)));let b=null;for(let y in o.attributes){if(y.slice(0,5)==="morph")continue;const E=o.attributes[y];if(y=g[y]||y.toUpperCase(),!/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(y)&&!y.startsWith("_")&&(y="_"+y),t.attributes.has(this.getUID(E))){d[y]=t.attributes.get(this.getUID(E));continue}b=null;const v=E.array;y==="JOINTS_0"&&!(v instanceof Uint16Array)&&!(v instanceof Uint8Array)?(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),b=Fe.Utils.toTypedBufferAttribute(E,Uint16Array)):(v instanceof Uint32Array||v instanceof Int32Array)&&!y.startsWith("_")&&(console.warn(`GLTFExporter: Attribute "${y}" converted to type FLOAT.`),b=Fe.Utils.toTypedBufferAttribute(E,Float32Array));const O=this.processAccessor(b||E,o);O!==null&&(y.startsWith("_")||this.detectMeshQuantization(y,E),d[y]=O,t.attributes.set(this.getUID(E),O))}if(A!==void 0&&o.setAttribute("normal",A),Object.keys(d).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const y=[],E=[],N={};if(e.morphTargetDictionary!==void 0)for(const v in e.morphTargetDictionary)N[e.morphTargetDictionary[v]]=v;for(let v=0;v<e.morphTargetInfluences.length;++v){const O={};let J=!1;for(const L in o.morphAttributes){if(L!=="position"&&L!=="normal"){J||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),J=!0);continue}const X=o.morphAttributes[L][v],G=L.toUpperCase(),z=o.attributes[L];if(t.attributes.has(this.getUID(X,!0))){O[G]=t.attributes.get(this.getUID(X,!0));continue}const V=X.clone();if(!o.morphTargetsRelative)for(let P=0,W=X.count;P<W;P++)for(let K=0;K<X.itemSize;K++)K===0&&V.setX(P,X.getX(P)-z.getX(P)),K===1&&V.setY(P,X.getY(P)-z.getY(P)),K===2&&V.setZ(P,X.getZ(P)-z.getZ(P)),K===3&&V.setW(P,X.getW(P)-z.getW(P));O[G]=this.processAccessor(V,o),t.attributes.set(this.getUID(z,!0),O[G])}h.push(O),y.push(e.morphTargetInfluences[v]),e.morphTargetDictionary!==void 0&&E.push(N[v])}u.weights=y,E.length>0&&(u.extras={},u.extras.targetNames=E)}const m=Array.isArray(e.material);if(m&&o.groups.length===0)return null;let p=!1;if(m&&o.index===null){const y=[];for(let E=0,N=o.attributes.position.count;E<N;E++)y[E]=E;o.setIndex(y),p=!0}const x=m?e.material:[e.material],M=m?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let y=0,E=M.length;y<E;y++){const N={mode:l,attributes:d};if(this.serializeUserData(o,N),h.length>0&&(N.targets=h),o.index!==null){let O=this.getUID(o.index);(M[y].start!==void 0||M[y].count!==void 0)&&(O+=":"+M[y].start+":"+M[y].count),t.attributes.has(O)?N.indices=t.attributes.get(O):(N.indices=this.processAccessor(o.index,o,M[y].start,M[y].count),t.attributes.set(O,N.indices)),N.indices===null&&delete N.indices}const v=await this.processMaterialAsync(x[M[y].materialIndex]);v!==null&&(N.material=v),f.push(N)}p===!0&&o.setIndex(null),u.primitives=f,n.meshes||(n.meshes=[]),await this._invokeAllAsync(function(y){y.writeMesh&&y.writeMesh(e,u)});const w=n.meshes.push(u)-1;return t.meshes.set(i,w),w}detectMeshQuantization(e,t){if(this.extensionsUsed[ft])return;let n;switch(t.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}t.normalized&&(n+=" normalized");const s=e.split("_",1)[0];es[s]&&es[s].includes(n)&&(this.extensionsUsed[ft]=!0,this.extensionsRequired[ft]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,s={type:n?"orthographic":"perspective"};return n?s.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:s.perspective={aspectRatio:e.aspect,yfov:c.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(s.name=e.type),t.cameras.push(s)-1}processAnimation(e,t){const n=this.json,s=this.nodeMap;n.animations||(n.animations=[]),e=Fe.Utils.mergeMorphTargetTracks(e.clone(),t);const i=e.tracks,o=[],l=[];for(let d=0;d<i.length;++d){const f=i[d],h=c.PropertyBinding.parseTrackName(f.name);let g=c.PropertyBinding.findNode(t,h.nodeName);const A=ts[h.propertyName];if(h.objectName==="bones"&&(g.isSkinnedMesh===!0?g=g.skeleton.getBoneByName(h.objectIndex):g=void 0),!g||!A){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',f.name);continue}const b=1;let m=f.values.length/f.times.length;A===ts.morphTargetInfluences&&(m/=g.morphTargetInfluences.length);let p;f.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(p="CUBICSPLINE",m/=3):f.getInterpolation()===c.InterpolateDiscrete?p="STEP":p="LINEAR",l.push({input:this.processAccessor(new c.BufferAttribute(f.times,b)),output:this.processAccessor(new c.BufferAttribute(f.values,m)),interpolation:p}),o.push({sampler:l.length-1,target:{node:s.get(g),path:A}})}const u={name:e.name||"clip_"+n.animations.length,samplers:l,channels:o};return this.serializeUserData(e,u),n.animations.push(u),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,s=t.nodes[n.get(e)],i=e.skeleton;if(i===void 0)return null;const o=e.skeleton.bones[0];if(o===void 0)return null;const l=[],u=new Float32Array(i.bones.length*16),d=new c.Matrix4;for(let h=0;h<i.bones.length;++h)l.push(n.get(i.bones[h])),d.copy(i.boneInverses[h]),d.multiply(e.bindMatrix).toArray(u,h*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new c.BufferAttribute(u,16)),joints:l,skeleton:n.get(o)}),s.skin=t.skins.length-1}async processNodeAsync(e){const t=this.json,n=this.options,s=this.nodeMap;if(t.nodes||(t.nodes=[]),e.pivot!==null)return await this._processNodeWithPivotAsync(e);const i={};if(n.trs){const l=e.quaternion.toArray(),u=e.position.toArray(),d=e.scale.toArray();me(l,[0,0,0,1])||(i.rotation=l),me(u,[0,0,0])||(i.translation=u),me(d,[1,1,1])||(i.scale=d)}else e.matrixAutoUpdate&&e.updateMatrix(),ii(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){const l=await this.processMeshAsync(e);l!==null&&(i.mesh=l)}else e.isCamera&&(i.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);const o=t.nodes.push(i)-1;if(s.set(e,o),e.children.length>0){const l=[];for(let u=0,d=e.children.length;u<d;u++){const f=e.children[u];if(f.visible||n.onlyVisible===!1){const h=await this.processNodeAsync(f);h!==null&&l.push(h)}}l.length>0&&(i.children=l)}return await this._invokeAllAsync(function(l){l.writeNode&&l.writeNode(e,i)}),o}async _processNodeWithPivotAsync(e){const t=this.json,n=this.options,s=this.nodeMap,i=e.pivot,o={},l=e.quaternion.toArray(),u=[e.position.x+i.x,e.position.y+i.y,e.position.z+i.z],d=e.scale.toArray();me(l,[0,0,0,1])||(o.rotation=l),me(u,[0,0,0])||(o.translation=u),me(d,[1,1,1])||(o.scale=d),o.extras={pivot:i.toArray()},e.name!==""&&(o.name=String(e.name)),this.serializeUserData(e,o);const f=t.nodes.push(o)-1;s.set(e,f);const h={},g=[-i.x,-i.y,-i.z];if(me(g,[0,0,0])||(h.translation=g),e.isMesh||e.isLine||e.isPoints){const m=await this.processMeshAsync(e);m!==null&&(h.mesh=m)}else e.isCamera&&(h.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);const b=[t.nodes.push(h)-1];if(e.children.length>0){const m=[];for(let p=0,x=e.children.length;p<x;p++){const M=e.children[p];if(M.visible||n.onlyVisible===!1){const w=await this.processNodeAsync(M);w!==null&&m.push(w)}}m.length>0&&(h.children=m)}return o.children=b,await this._invokeAllAsync(function(m){m.writeNode&&m.writeNode(e,o)}),f}async processSceneAsync(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const s={};e.name!==""&&(s.name=e.name),t.scenes.push(s);const i=[];for(let o=0,l=e.children.length;o<l;o++){const u=e.children[o];if(u.visible||n.onlyVisible===!1){const d=await this.processNodeAsync(u);d!==null&&i.push(d)}}i.length>0&&(s.nodes=i),this.serializeUserData(e,s)}async processObjectsAsync(e){const t=new c.Scene;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);await this.processSceneAsync(t)}async processInputAsync(e){const t=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync(function(s){s.beforeParse&&s.beforeParse(e)});const n=[];for(let s=0;s<e.length;s++)e[s]instanceof c.Scene?await this.processSceneAsync(e[s]):n.push(e[s]);n.length>0&&await this.processObjectsAsync(n);for(let s=0;s<this.skins.length;++s)this.processSkin(this.skins[s]);for(let s=0;s<t.animations.length;++s)this.processAnimation(t.animations[s],e[0]);await this._invokeAllAsync(function(s){s.afterParse&&s.afterParse(e)})}async _invokeAllAsync(e){for(let t=0,n=this.plugins.length;t<n;t++)await e(this.plugins[t])}}class li{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){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}const n=this.writer,s=n.json,i=n.extensionsUsed,o={};e.name&&(o.name=e.name),o.color=e.color.toArray(),o.intensity=e.intensity,e.isDirectionalLight?o.type="directional":e.isPointLight?(o.type="point",e.distance>0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.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]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},i[this.name]=!0);const l=s.extensions[this.name].lights;l.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:l.length-1}}}let ci=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;const s=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},s[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},ui=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){const o={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(o,e.clearcoatMap),i.clearcoatTexture=o}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const o={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(o,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=o}if(e.clearcoatNormalMap){const o={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(o.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(o,e.clearcoatNormalMap),i.clearcoatNormalTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},di=class{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;const s=this.writer.extensionsUsed,i={};i.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},hi=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){const o={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(o,e.iridescenceMap),i.iridescenceTexture=o}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const o={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(o,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},fi=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){const o={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(o,e.transmissionMap),i.transmissionTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},pi=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){const o={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(o,e.thicknessMap),i.thicknessTexture=o}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},mi=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const s=this.writer.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},Ai=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(_n)&&!e.specularIntensityMap&&!e.specularColorMap)return;const n=this.writer,s=n.extensionsUsed,i={};if(e.specularIntensityMap){const o={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(o,e.specularIntensityMap),i.specularTexture=o}if(e.specularColorMap){const o={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(o,e.specularColorMap),i.specularColorTexture=o}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},gi=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,s=n.extensionsUsed,i={};if(e.sheenRoughnessMap){const o={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(o,e.sheenRoughnessMap),i.sheenRoughnessTexture=o}if(e.sheenColorMap){const o={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(o,e.sheenColorMap),i.sheenColorTexture=o}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},yi=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,s=n.extensionsUsed,i={};if(e.anisotropyMap){const o={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(o,e.anisotropyMap),i.anisotropyTexture=o}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},bi=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const s=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},xi=class{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const n=this.writer,s=n.extensionsUsed,i={};if(e.bumpMap){const o={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(o,e.bumpMap),i.bumpTexture=o}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},Ii=class{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;const n=this.writer,s=e,i=new Float32Array(s.count*3),o=new Float32Array(s.count*4),l=new Float32Array(s.count*3),u=new c.Matrix4,d=new c.Vector3,f=new c.Quaternion,h=new c.Vector3;for(let A=0;A<s.count;A++)s.getMatrixAt(A,u),u.decompose(d,f,h),d.toArray(i,A*3),f.toArray(o,A*4),h.toArray(l,A*3);const g={TRANSLATION:n.processAccessor(new c.BufferAttribute(i,3)),ROTATION:n.processAccessor(new c.BufferAttribute(o,4)),SCALE:n.processAccessor(new c.BufferAttribute(l,3))};s.instanceColor&&(g._COLOR_0=n.processAccessor(s.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:g},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}};Fe.Utils={insertKeyframe:function(r,e){const n=r.getValueSize(),s=new r.TimeBufferType(r.times.length+1),i=new r.ValueBufferType(r.values.length+n),o=r.createInterpolant(new r.ValueBufferType(n));let l;if(r.times.length===0){s[0]=e;for(let u=0;u<n;u++)i[u]=0;l=0}else if(e<r.times[0]){if(Math.abs(r.times[0]-e)<.001)return 0;s[0]=e,s.set(r.times,1),i.set(o.evaluate(e),0),i.set(r.values,n),l=0}else if(e>r.times[r.times.length-1]){if(Math.abs(r.times[r.times.length-1]-e)<.001)return r.times.length-1;s[s.length-1]=e,s.set(r.times,0),i.set(r.values,0),i.set(o.evaluate(e),r.values.length),l=s.length-1}else for(let u=0;u<r.times.length;u++){if(Math.abs(r.times[u]-e)<.001)return u;if(r.times[u]<e&&r.times[u+1]>e){s.set(r.times.slice(0,u+1),0),s[u+1]=e,s.set(r.times.slice(u+1),u+2),i.set(r.values.slice(0,(u+1)*n),0),i.set(o.evaluate(e),(u+1)*n),i.set(r.values.slice((u+1)*n),(u+2)*n),l=u+1;break}}return r.times=s,r.values=i,l},mergeMorphTargetTracks:function(r,e){const t=[],n={},s=r.tracks;for(let i=0;i<s.length;++i){let o=s[i];const l=c.PropertyBinding.parseTrackName(o.name),u=c.PropertyBinding.findNode(e,l.nodeName);if(l.propertyName!=="morphTargetInfluences"||l.propertyIndex===void 0){t.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.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."),o=o.clone(),o.setInterpolation(c.InterpolateLinear)}const d=u.morphTargetInfluences.length,f=u.morphTargetDictionary[l.propertyIndex];if(f===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+l.propertyIndex);let h;if(n[u.uuid]===void 0){h=o.clone();const A=new h.ValueBufferType(d*h.times.length);for(let b=0;b<h.times.length;b++)A[b*d+f]=h.values[b];h.name=(l.nodeName||"")+".morphTargetInfluences",h.values=A,n[u.uuid]=h,t.push(h);continue}const g=o.createInterpolant(new o.ValueBufferType(1));h=n[u.uuid];for(let A=0;A<h.times.length;A++)h.values[A*d+f]=g.evaluate(h.times[A]);for(let A=0;A<o.times.length;A++){const b=this.insertKeyframe(h,o.times[A]);h.values[b*d+f]=o.values[A]}}return r.tracks=t,r},toTypedBufferAttribute:function(r,e){const t=new c.BufferAttribute(new e(r.count*r.itemSize),r.itemSize,!1);if(!r.normalized&&!r.isInterleavedBufferAttribute)return t.array.set(r.array),t;for(let n=0,s=r.count;n<s;n++)for(let i=0;i<r.itemSize;i++)t.setComponent(n,i,r.getComponent(n,i));return t}};function os(r,e){if(e===c.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===c.TriangleFanDrawMode||e===c.TriangleStripDrawMode){let t=r.getIndex();if(t===null){const o=[],l=r.getAttribute("position");if(l!==void 0){for(let u=0;u<l.count;u++)o.push(u);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,s=[];if(e===c.TriangleFanDrawMode)for(let o=1;o<=n;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=r.clone();return i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}function Ci(r){const e=new Map,t=new Map,n=r.clone();return Ms(r,n,function(s,i){e.set(i,s),t.set(s,i)}),n.traverse(function(s){if(!s.isSkinnedMesh)return;const i=s,o=e.get(s),l=o.skeleton.bones;i.skeleton=o.skeleton.clone(),i.bindMatrix.copy(o.bindMatrix),i.skeleton.bones=l.map(function(u){return t.get(u)}),i.bind(i.skeleton,i.bindMatrix)}),n}function Ms(r,e,t){t(r,e);for(let n=0;n<r.children.length;n++)Ms(r.children[n],e.children[n],t)}class ws extends c.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ti(t)}),this.register(function(t){return new Di(t)}),this.register(function(t){return new Hi(t)}),this.register(function(t){return new Bi(t)}),this.register(function(t){return new Fi(t)}),this.register(function(t){return new Si(t)}),this.register(function(t){return new Ri(t)}),this.register(function(t){return new Pi(t)}),this.register(function(t){return new Oi(t)}),this.register(function(t){return new Ei(t)}),this.register(function(t){return new Li(t)}),this.register(function(t){return new Ni(t)}),this.register(function(t){return new Vi(t)}),this.register(function(t){return new ki(t)}),this.register(function(t){return new wi(t)}),this.register(function(t){return new rs(t,B.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new rs(t,B.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new ji(t)})}load(e,t,n,s){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const d=c.LoaderUtils.extractUrlBase(e);o=c.LoaderUtils.resolveURL(d,this.path)}else o=c.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const l=function(d){s?s(d):console.error(d),i.manager.itemError(e),i.manager.itemEnd(e)},u=new c.FileLoader(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(e,function(d){try{i.parse(d,o,function(f){t(f),i.manager.itemEnd(e)},l)}catch(f){l(f)}},n,l)}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,n,s){let i;const o={},l={},u=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(u.decode(new Uint8Array(e,0,4))===vs){try{o[B.KHR_BINARY_GLTF]=new Ui(e)}catch(h){s&&s(h);return}i=JSON.parse(o[B.KHR_BINARY_GLTF].content)}else i=JSON.parse(u.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const d=new eo(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});d.fileLoader.setRequestHeader(this.requestHeader);for(let f=0;f<this.pluginCallbacks.length;f++){const h=this.pluginCallbacks[f](d);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),l[h.name]=h,o[h.name]=!0}if(i.extensionsUsed)for(let f=0;f<i.extensionsUsed.length;++f){const h=i.extensionsUsed[f],g=i.extensionsRequired||[];switch(h){case B.KHR_MATERIALS_UNLIT:o[h]=new vi;break;case B.KHR_DRACO_MESH_COMPRESSION:o[h]=new Gi(i,this.dracoLoader);break;case B.KHR_TEXTURE_TRANSFORM:o[h]=new zi;break;case B.KHR_MESH_QUANTIZATION:o[h]=new Wi;break;default:g.indexOf(h)>=0&&l[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}d.setExtensions(o),d.setPlugins(l),d.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,i){n.parse(e,t,s,i)})}}function Mi(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}function $(r,e,t){const n=r.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}const B={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class wi{constructor(e){this.parser=e,this.name=B.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const i=t.json,u=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let d;const f=new c.Color(16777215);u.color!==void 0&&f.setRGB(u.color[0],u.color[1],u.color[2],c.LinearSRGBColorSpace);const h=u.range!==void 0?u.range:0;switch(u.type){case"directional":d=new c.DirectionalLight(f),d.target.position.set(0,0,-1),d.add(d.target);break;case"point":d=new c.PointLight(f),d.distance=h;break;case"spot":d=new c.SpotLight(f),d.distance=h,u.spot=u.spot||{},u.spot.innerConeAngle=u.spot.innerConeAngle!==void 0?u.spot.innerConeAngle:0,u.spot.outerConeAngle=u.spot.outerConeAngle!==void 0?u.spot.outerConeAngle:Math.PI/4,d.angle=u.spot.outerConeAngle,d.penumbra=1-u.spot.innerConeAngle/u.spot.outerConeAngle,d.target.position.set(0,0,-1),d.add(d.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+u.type)}return d.position.set(0,0,0),pe(d,u),u.intensity!==void 0&&(d.intensity=u.intensity),d.name=t.createUniqueName(u.name||"light_"+e),s=Promise.resolve(d),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],l=(i.extensions&&i.extensions[this.name]||{}).light;return l===void 0?null:this._loadLight(l).then(function(u){return n._getNodeRef(t.cache,l,u)})}}class vi{constructor(){this.name=B.KHR_MATERIALS_UNLIT}getMaterialType(){return c.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new c.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],c.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",i.baseColorTexture,c.SRGBColorSpace))}return Promise.all(s)}}class Ei{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class Ti{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(s.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const i=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new c.Vector2(i,i)}return Promise.all(s)}}class Di{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_DISPERSION}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class Ni{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(s)}}class Si{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_SHEEN}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];if(t.sheenColor=new c.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){const i=n.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],c.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,c.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(s)}}class Ri{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&s.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(s)}}class Pi{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_VOLUME}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const i=n.attenuationColor||[1,1,1];return t.attenuationColor=new c.Color().setRGB(i[0],i[1],i[2],c.LinearSRGBColorSpace),Promise.all(s)}}class Oi{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_IOR}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0&&(t.ior=1e3)),Promise.resolve()}}class Li{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_SPECULAR}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));const i=n.specularColorFactor||[1,1,1];return t.specularColor=new c.Color().setRGB(i[0],i[1],i[2],c.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,c.SRGBColorSpace)),Promise.all(s)}}class ki{constructor(e){this.parser=e,this.name=B.EXT_MATERIALS_BUMP}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&s.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(s)}}class Vi{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&s.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(s)}}class Hi{constructor(e){this.parser=e,this.name=B.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class Bi{constructor(e){this.parser=e,this.name=B.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],l=s.images[o.source];let u=n.textureLoader;if(l.uri){const d=n.options.manager.getHandler(l.uri);d!==null&&(u=d)}return n.loadTextureImage(e,o.source,u)}}class Fi{constructor(e){this.parser=e,this.name=B.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],l=s.images[o.source];let u=n.textureLoader;if(l.uri){const d=n.options.manager.getHandler(l.uri);d!==null&&(u=d)}return n.loadTextureImage(e,o.source,u)}}class rs{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],i=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.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 i.then(function(l){const u=s.byteOffset||0,d=s.byteLength||0,f=s.count,h=s.byteStride,g=new Uint8Array(l,u,d);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(f,h,g,s.mode,s.filter).then(function(A){return A.buffer}):o.ready.then(function(){const A=new ArrayBuffer(f*h);return o.decodeGltfBuffer(new Uint8Array(A),f,h,g,s.mode,s.filter),A})})}else return null}}class ji{constructor(e){this.name=B.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const d of s.primitives)if(d.mode!==le.TRIANGLES&&d.mode!==le.TRIANGLE_STRIP&&d.mode!==le.TRIANGLE_FAN&&d.mode!==void 0)return null;const o=n.extensions[this.name].attributes,l=[],u={};for(const d in o)l.push(this.parser.getDependency("accessor",o[d]).then(f=>(u[d]=f,u[d])));return l.length<1?null:(l.push(this.parser.createNodeMesh(e)),Promise.all(l).then(d=>{const f=d.pop(),h=f.isGroup?f.children:[f],g=d[0].count,A=[];for(const b of h){const m=new c.Matrix4,p=new c.Vector3,x=new c.Quaternion,M=new c.Vector3(1,1,1),w=new c.InstancedMesh(b.geometry,b.material,g);for(let y=0;y<g;y++)u.TRANSLATION&&p.fromBufferAttribute(u.TRANSLATION,y),u.ROTATION&&x.fromBufferAttribute(u.ROTATION,y),u.SCALE&&M.fromBufferAttribute(u.SCALE,y),w.setMatrixAt(y,m.compose(p,x,M));for(const y in u)if(y==="_COLOR_0"){const E=u[y];w.instanceColor=new c.InstancedBufferAttribute(E.array,E.itemSize,E.normalized)}else y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&b.geometry.setAttribute(y,u[y]);c.Object3D.prototype.copy.call(w,b),this.parser.assignFinalMaterial(w),A.push(w)}return f.isGroup?(f.clear(),f.add(...A),f):A[0]}))}}const vs="glTF",Ve=12,as={JSON:1313821514,BIN:5130562};class Ui{constructor(e){this.name=B.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ve),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==vs)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-Ve,i=new DataView(e,Ve);let o=0;for(;o<s;){const l=i.getUint32(o,!0);o+=4;const u=i.getUint32(o,!0);if(o+=4,u===as.JSON){const d=new Uint8Array(e,Ve+o,l);this.content=n.decode(d)}else if(u===as.BIN){const d=Ve+o;this.body=e.slice(d,d+l)}o+=l}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Gi{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=B.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,l={},u={},d={};for(const f in o){const h=It[f]||f.toLowerCase();l[h]=o[f]}for(const f in e.attributes){const h=It[f]||f.toLowerCase();if(o[f]!==void 0){const g=n.accessors[e.attributes[f]],A=Pe[g.componentType];d[h]=A.name,u[h]=g.normalized===!0}}return t.getDependency("bufferView",i).then(function(f){return new Promise(function(h,g){s.decodeDracoFile(f,function(A){for(const b in A.attributes){const m=A.attributes[b],p=u[b];p!==void 0&&(m.normalized=p)}h(A)},l,d,c.LinearSRGBColorSpace,g)})})}}class zi{constructor(){this.name=B.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}}class Wi{constructor(){this.name=B.KHR_MESH_QUANTIZATION}}class Es extends c.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let o=0;o!==s;o++)t[o]=n[i+o];return t}interpolate_(e,t,n,s){const i=this.resultBuffer,o=this.sampleValues,l=this.valueSize,u=l*2,d=l*3,f=s-t,h=(n-t)/f,g=h*h,A=g*h,b=e*d,m=b-d,p=-2*A+3*g,x=A-g,M=1-p,w=x-g+h;for(let y=0;y!==l;y++){const E=o[m+y+l],N=o[m+y+u]*f,v=o[b+y+l],O=o[b+y]*f;i[y]=M*E+w*N+p*v+x*O}return i}}const Xi=new c.Quaternion;class qi extends Es{interpolate_(e,t,n,s){const i=super.interpolate_(e,t,n,s);return Xi.fromArray(i).normalize().toArray(i),i}}const le={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Pe={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ls={9728:c.NearestFilter,9729:c.LinearFilter,9984:c.NearestMipmapNearestFilter,9985:c.LinearMipmapNearestFilter,9986:c.NearestMipmapLinearFilter,9987:c.LinearMipmapLinearFilter},cs={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},mt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},It={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"},ye={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Yi={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete},At={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ki(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new c.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:c.FrontSide})),r.DefaultMaterial}function ve(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function pe(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Zi(r,e,t){let n=!1,s=!1,i=!1;for(let d=0,f=e.length;d<f;d++){const h=e[d];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(s=!0),h.COLOR_0!==void 0&&(i=!0),n&&s&&i)break}if(!n&&!s&&!i)return Promise.resolve(r);const o=[],l=[],u=[];for(let d=0,f=e.length;d<f;d++){const h=e[d];if(n){const g=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):r.attributes.position;o.push(g)}if(s){const g=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):r.attributes.normal;l.push(g)}if(i){const g=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):r.attributes.color;u.push(g)}}return Promise.all([Promise.all(o),Promise.all(l),Promise.all(u)]).then(function(d){const f=d[0],h=d[1],g=d[2];return n&&(r.morphAttributes.position=f),s&&(r.morphAttributes.normal=h),i&&(r.morphAttributes.color=g),r.morphTargetsRelative=!0,r})}function Qi(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)r.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Ji(r){let e;const t=r.extensions&&r.extensions[B.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+gt(t.attributes):e=r.indices+":"+gt(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,s=r.targets.length;n<s;n++)e+=":"+gt(r.targets[n]);return e}function gt(r){let e="";const t=Object.keys(r).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+r[t[n]]+";";return e}function Ct(r){switch(r){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 _i(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const $i=new c.Matrix4;class eo{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Mi,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 n=!1,s=-1,i=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const l=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(l)===!0;const u=l.match(/Version\/(\d+)/);s=n&&u?parseInt(u[1],10):-1,i=l.indexOf("Firefox")>-1,o=i?l.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||i&&o<98?this.textureLoader=new c.TextureLoader(this.options.manager):this.textureLoader=new c.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new c.FileLoader(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){const n=this,s=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const l={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return ve(i,l,s),pe(l,s),Promise.all(n._invokeAll(function(u){return u.afterRoot&&u.afterRoot(l)})).then(function(){for(const u of l.scenes)u.updateMatrixWorld();e(l)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,i=t.length;s<i;s++){const o=t[s].joints;for(let l=0,u=o.length;l<u;l++)e[o[l]].isBone=!0}for(let s=0,i=e.length;s<i;s++){const o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.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,n){if(e.refs[t]<=1)return n;const s=n.clone(),i=(o,l)=>{const u=this.associations.get(o);u!=null&&this.associations.set(l,u);for(const[d,f]of o.children.entries())i(f,l.children[d])};return i(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const i=e(t[s]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":s=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(i,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=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[B.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(i,o){n.load(c.LoaderUtils.resolveURL(t.uri,s.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,i=t.byteOffset||0;return n.slice(i,i+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const o=mt[s.type],l=Pe[s.componentType],u=s.normalized===!0,d=new l(s.count*o);return Promise.resolve(new c.BufferAttribute(d,o,u))}const i=[];return s.bufferView!==void 0?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),s.sparse!==void 0&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then(function(o){const l=o[0],u=mt[s.type],d=Pe[s.componentType],f=d.BYTES_PER_ELEMENT,h=f*u,g=s.byteOffset||0,A=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,b=s.normalized===!0;let m,p;if(A&&A!==h){const x=Math.floor(g/A),M="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+x+":"+s.count;let w=t.cache.get(M);w||(m=new d(l,x*A,s.count*A/f),w=new c.InterleavedBuffer(m,A/f),t.cache.add(M,w)),p=new c.InterleavedBufferAttribute(w,u,g%A/f,b)}else l===null?m=new d(s.count*u):m=new d(l,g,s.count*u),p=new c.BufferAttribute(m,u,b);if(s.sparse!==void 0){const x=mt.SCALAR,M=Pe[s.sparse.indices.componentType],w=s.sparse.indices.byteOffset||0,y=s.sparse.values.byteOffset||0,E=new M(o[1],w,s.sparse.count*x),N=new d(o[2],y,s.sparse.count*u);l!==null&&(p=new c.BufferAttribute(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let v=0,O=E.length;v<O;v++){const J=E[v];if(p.setX(J,N[v*u]),u>=2&&p.setY(J,N[v*u+1]),u>=3&&p.setZ(J,N[v*u+2]),u>=4&&p.setW(J,N[v*u+3]),u>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=b}return p})}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,o=t.images[i];let l=this.textureLoader;if(o.uri){const u=n.manager.getHandler(o.uri);u!==null&&(l=u)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,n){const s=this,i=this.json,o=i.textures[e],l=i.images[t],u=(l.uri||l.bufferView)+":"+o.sampler;if(this.textureCache[u])return this.textureCache[u];const d=this.loadImageSource(t,n).then(function(f){f.flipY=!1,f.name=o.name||l.name||"",f.name===""&&typeof l.uri=="string"&&l.uri.startsWith("data:image/")===!1&&(f.name=l.uri);const g=(i.samplers||{})[o.sampler]||{};return f.magFilter=ls[g.magFilter]||c.LinearFilter,f.minFilter=ls[g.minFilter]||c.LinearMipmapLinearFilter,f.wrapS=cs[g.wrapS]||c.RepeatWrapping,f.wrapT=cs[g.wrapT]||c.RepeatWrapping,f.generateMipmaps=!f.isCompressedTexture&&f.minFilter!==c.NearestFilter&&f.minFilter!==c.LinearFilter,s.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[u]=d,d}loadImageSource(e,t){const n=this,s=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const o=s.images[e],l=self.URL||self.webkitURL;let u=o.uri||"",d=!1;if(o.bufferView!==void 0)u=n.getDependency("bufferView",o.bufferView).then(function(h){d=!0;const g=new Blob([h],{type:o.mimeType});return u=l.createObjectURL(g),u});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(u).then(function(h){return new Promise(function(g,A){let b=g;t.isImageBitmapLoader===!0&&(b=function(m){const p=new c.Texture(m);p.needsUpdate=!0,g(p)}),t.load(c.LoaderUtils.resolveURL(h,i.path),b,void 0,A)})}).then(function(h){return d===!0&&l.revokeObjectURL(u),pe(h,o),h.userData.mimeType=o.mimeType||_i(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",u),h});return this.sourceCache[e]=f,f}assignTexture(e,t,n,s){const i=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),i.extensions[B.KHR_TEXTURE_TRANSFORM]){const l=n.extensions!==void 0?n.extensions[B.KHR_TEXTURE_TRANSFORM]:void 0;if(l){const u=i.associations.get(o);o=i.extensions[B.KHR_TEXTURE_TRANSFORM].extendTexture(o,l),i.associations.set(o,u)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const l="PointsMaterial:"+n.uuid;let u=this.cache.get(l);u||(u=new c.PointsMaterial,c.Material.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,u.sizeAttenuation=!1,this.cache.add(l,u)),n=u}else if(e.isLine){const l="LineBasicMaterial:"+n.uuid;let u=this.cache.get(l);u||(u=new c.LineBasicMaterial,c.Material.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,this.cache.add(l,u)),n=u}if(s||i||o){let l="ClonedMaterial:"+n.uuid+":";s&&(l+="derivative-tangents:"),i&&(l+="vertex-colors:"),o&&(l+="flat-shading:");let u=this.cache.get(l);u||(u=n.clone(),i&&(u.vertexColors=!0),o&&(u.flatShading=!0),s&&(u.normalScale&&(u.normalScale.y*=-1),u.clearcoatNormalScale&&(u.clearcoatNormalScale.y*=-1)),this.cache.add(l,u),this.associations.set(u,this.associations.get(n))),n=u}e.material=n}getMaterialType(){return c.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,i=n.materials[e];let o;const l={},u=i.extensions||{},d=[];if(u[B.KHR_MATERIALS_UNLIT]){const h=s[B.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),d.push(h.extendParams(l,i,t))}else{const h=i.pbrMetallicRoughness||{};if(l.color=new c.Color(1,1,1),l.opacity=1,Array.isArray(h.baseColorFactor)){const g=h.baseColorFactor;l.color.setRGB(g[0],g[1],g[2],c.LinearSRGBColorSpace),l.opacity=g[3]}h.baseColorTexture!==void 0&&d.push(t.assignTexture(l,"map",h.baseColorTexture,c.SRGBColorSpace)),l.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,l.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(d.push(t.assignTexture(l,"metalnessMap",h.metallicRoughnessTexture)),d.push(t.assignTexture(l,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),d.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,l)})))}i.doubleSided===!0&&(l.side=c.DoubleSide);const f=i.alphaMode||At.OPAQUE;if(f===At.BLEND?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,f===At.MASK&&(l.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==c.MeshBasicMaterial&&(d.push(t.assignTexture(l,"normalMap",i.normalTexture)),l.normalScale=new c.Vector2(1,1),i.normalTexture.scale!==void 0)){const h=i.normalTexture.scale;l.normalScale.set(h,h)}if(i.occlusionTexture!==void 0&&o!==c.MeshBasicMaterial&&(d.push(t.assignTexture(l,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(l.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==c.MeshBasicMaterial){const h=i.emissiveFactor;l.emissive=new c.Color().setRGB(h[0],h[1],h[2],c.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==c.MeshBasicMaterial&&d.push(t.assignTexture(l,"emissiveMap",i.emissiveTexture,c.SRGBColorSpace)),Promise.all(d).then(function(){const h=new o(l);return i.name&&(h.name=i.name),pe(h,i),t.associations.set(h,{materials:e}),i.extensions&&ve(s,h,i),h})}createUniqueName(e){const t=c.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function i(l){return n[B.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(l,t).then(function(u){return us(u,l,t)})}const o=[];for(let l=0,u=e.length;l<u;l++){const d=e[l],f=Ji(d),h=s[f];if(h)o.push(h.promise);else{let g;d.extensions&&d.extensions[B.KHR_DRACO_MESH_COMPRESSION]?g=i(d):g=us(new c.BufferGeometry,d,t),s[f]={primitive:d,promise:g},o.push(g)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,s=this.extensions,i=n.meshes[e],o=i.primitives,l=[];for(let u=0,d=o.length;u<d;u++){const f=o[u].material===void 0?Ki(this.cache):this.getDependency("material",o[u].material);l.push(f)}return l.push(t.loadGeometries(o)),Promise.all(l).then(function(u){const d=u.slice(0,u.length-1),f=u[u.length-1],h=[];for(let A=0,b=f.length;A<b;A++){const m=f[A],p=o[A];let x;const M=d[A];if(p.mode===le.TRIANGLES||p.mode===le.TRIANGLE_STRIP||p.mode===le.TRIANGLE_FAN||p.mode===void 0)x=i.isSkinnedMesh===!0?new c.SkinnedMesh(m,M):new c.Mesh(m,M),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),p.mode===le.TRIANGLE_STRIP?x.geometry=os(x.geometry,c.TriangleStripDrawMode):p.mode===le.TRIANGLE_FAN&&(x.geometry=os(x.geometry,c.TriangleFanDrawMode));else if(p.mode===le.LINES)x=new c.LineSegments(m,M);else if(p.mode===le.LINE_STRIP)x=new c.Line(m,M);else if(p.mode===le.LINE_LOOP)x=new c.LineLoop(m,M);else if(p.mode===le.POINTS)x=new c.Points(m,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);Object.keys(x.geometry.morphAttributes).length>0&&Qi(x,i),x.name=t.createUniqueName(i.name||"mesh_"+e),pe(x,i),p.extensions&&ve(s,x,p),t.assignFinalMaterial(x),h.push(x)}for(let A=0,b=h.length;A<b;A++)t.associations.set(h[A],{meshes:e,primitives:A});if(h.length===1)return i.extensions&&ve(s,h[0],i),h[0];const g=new c.Group;i.extensions&&ve(s,g,i),t.associations.set(g,{meshes:e});for(let A=0,b=h.length;A<b;A++)g.add(h[A]);return g})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new c.PerspectiveCamera(c.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new c.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),pe(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,i=t.joints.length;s<i;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const i=s.pop(),o=s,l=[],u=[];for(let d=0,f=o.length;d<f;d++){const h=o[d];if(h){l.push(h);const g=new c.Matrix4;i!==null&&g.fromArray(i.array,d*16),u.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[d])}return new c.Skeleton(l,u)})}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,o=[],l=[],u=[],d=[],f=[];for(let h=0,g=s.channels.length;h<g;h++){const A=s.channels[h],b=s.samplers[A.sampler],m=A.target,p=m.node,x=s.parameters!==void 0?s.parameters[b.input]:b.input,M=s.parameters!==void 0?s.parameters[b.output]:b.output;m.node!==void 0&&(o.push(this.getDependency("node",p)),l.push(this.getDependency("accessor",x)),u.push(this.getDependency("accessor",M)),d.push(b),f.push(m))}return Promise.all([Promise.all(o),Promise.all(l),Promise.all(u),Promise.all(d),Promise.all(f)]).then(function(h){const g=h[0],A=h[1],b=h[2],m=h[3],p=h[4],x=[];for(let w=0,y=g.length;w<y;w++){const E=g[w],N=A[w],v=b[w],O=m[w],J=p[w];if(E===void 0)continue;E.updateMatrix&&E.updateMatrix();const L=n._createAnimationTracks(E,N,v,O,J);if(L)for(let X=0;X<L.length;X++)x.push(L[X])}const M=new c.AnimationClip(i,void 0,x);return pe(M,s),M})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(i){const o=n._getNodeRef(n.meshCache,s.mesh,i);return s.weights!==void 0&&o.traverse(function(l){if(l.isMesh)for(let u=0,d=s.weights.length;u<d;u++)l.morphTargetInfluences[u]=s.weights[u]}),o})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],i=n._loadNodeShallow(e),o=[],l=s.children||[];for(let d=0,f=l.length;d<f;d++)o.push(n.getDependency("node",l[d]));const u=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([i,Promise.all(o),u]).then(function(d){const f=d[0],h=d[1],g=d[2];g!==null&&f.traverse(function(A){A.isSkinnedMesh&&A.bind(g,$i)});for(let A=0,b=h.length;A<b;A++)f.add(h[A]);if(f.userData.pivot!==void 0&&h.length>0){const A=f.userData.pivot,b=h[0];f.pivot=new c.Vector3().fromArray(A),f.position.x-=A[0],f.position.y-=A[1],f.position.z-=A[2],b.position.set(0,0,0),delete f.userData.pivot}return f})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?s.createUniqueName(i.name):"",l=[],u=s._invokeOne(function(d){return d.createNodeMesh&&d.createNodeMesh(e)});return u&&l.push(u),i.camera!==void 0&&l.push(s.getDependency("camera",i.camera).then(function(d){return s._getNodeRef(s.cameraCache,i.camera,d)})),s._invokeAll(function(d){return d.createNodeAttachment&&d.createNodeAttachment(e)}).forEach(function(d){l.push(d)}),this.nodeCache[e]=Promise.all(l).then(function(d){let f;if(i.isBone===!0?f=new c.Bone:d.length>1?f=new c.Group:d.length===1?f=d[0]:f=new c.Object3D,f!==d[0])for(let h=0,g=d.length;h<g;h++)f.add(d[h]);if(i.name&&(f.userData.name=i.name,f.name=o),pe(f,i),i.extensions&&ve(n,f,i),i.matrix!==void 0){const h=new c.Matrix4;h.fromArray(i.matrix),f.applyMatrix4(h)}else i.translation!==void 0&&f.position.fromArray(i.translation),i.rotation!==void 0&&f.quaternion.fromArray(i.rotation),i.scale!==void 0&&f.scale.fromArray(i.scale);if(!s.associations.has(f))s.associations.set(f,{});else if(i.mesh!==void 0&&s.meshCache.refs[i.mesh]>1){const h=s.associations.get(f);s.associations.set(f,{...h})}return s.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,i=new c.Group;n.name&&(i.name=s.createUniqueName(n.name)),pe(i,n),n.extensions&&ve(t,i,n);const o=n.nodes||[],l=[];for(let u=0,d=o.length;u<d;u++)l.push(s.getDependency("node",o[u]));return Promise.all(l).then(function(u){for(let f=0,h=u.length;f<h;f++){const g=u[f];g.parent!==null?i.add(Ci(g)):i.add(g)}const d=f=>{const h=new Map;for(const[g,A]of s.associations)(g instanceof c.Material||g instanceof c.Texture)&&h.set(g,A);return f.traverse(g=>{const A=s.associations.get(g);A!=null&&h.set(g,A)}),h};return s.associations=d(i),i})}_createAnimationTracks(e,t,n,s,i){const o=[],l=e.name?e.name:e.uuid,u=[];function d(A){A.morphTargetInfluences&&u.push(A.name?A.name:A.uuid)}ye[i.path]===ye.weights?(d(e),e.isGroup&&e.children.forEach(d)):u.push(l);let f;switch(ye[i.path]){case ye.weights:f=c.NumberKeyframeTrack;break;case ye.rotation:f=c.QuaternionKeyframeTrack;break;case ye.translation:case ye.scale:f=c.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:f=c.NumberKeyframeTrack;break;case 2:case 3:default:f=c.VectorKeyframeTrack;break}break}const h=s.interpolation!==void 0?Yi[s.interpolation]:c.InterpolateLinear,g=this._getArrayFromAccessor(n);for(let A=0,b=u.length;A<b;A++){const m=new f(u[A]+"."+ye[i.path],t.array,g,h);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Ct(t.constructor),s=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)s[i]=t[i]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const s=this instanceof c.QuaternionKeyframeTrack?qi:Es;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function to(r,e,t){const n=e.attributes,s=new c.Box3;if(n.POSITION!==void 0){const l=t.json.accessors[n.POSITION],u=l.min,d=l.max;if(u!==void 0&&d!==void 0){if(s.set(new c.Vector3(u[0],u[1],u[2]),new c.Vector3(d[0],d[1],d[2])),l.normalized){const f=Ct(Pe[l.componentType]);s.min.multiplyScalar(f),s.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const l=new c.Vector3,u=new c.Vector3;for(let d=0,f=i.length;d<f;d++){const h=i[d];if(h.POSITION!==void 0){const g=t.json.accessors[h.POSITION],A=g.min,b=g.max;if(A!==void 0&&b!==void 0){if(u.setX(Math.max(Math.abs(A[0]),Math.abs(b[0]))),u.setY(Math.max(Math.abs(A[1]),Math.abs(b[1]))),u.setZ(Math.max(Math.abs(A[2]),Math.abs(b[2]))),g.normalized){const m=Ct(Pe[g.componentType]);u.multiplyScalar(m)}l.max(u)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(l)}r.boundingBox=s;const o=new c.Sphere;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,r.boundingSphere=o}function us(r,e,t){const n=e.attributes,s=[];function i(o,l){return t.getDependency("accessor",o).then(function(u){r.setAttribute(l,u)})}for(const o in n){const l=It[o]||o.toLowerCase();l in r.attributes||s.push(i(n[o],l))}if(e.indices!==void 0&&!r.index){const o=t.getDependency("accessor",e.indices).then(function(l){r.setIndex(l)});s.push(o)}return c.ColorManagement.workingColorSpace!==c.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${c.ColorManagement.workingColorSpace}" not supported.`),pe(r,e),to(r,e,t),Promise.all(s).then(function(){return e.targets!==void 0?Zi(r,e.targets,t):r})}const C={mode:"",transformControlsMode:"translate",scene:null,camera:null,defaultMainCamera:null,renderer:null,orbitControls:null,transformControls:null,container:null,gridHelper:null,selectedObject:null};let tt=!1,De=!1,be=null;const so=16755200;let Mt=[],_e=[],We=!0,Te=null,wt=null,st=null,xe=[];const Ne=new Map;let rt,nt=null,je=null,Ue=null;async function Ts(r,e="edit",t){C.container=r,C.mode=e,io(),ro(),lo(),t&&(await Xs(t.scene,e,t.dataPanels,t.waters,t.textures,t.ambientLight),t!=null&&t.camera&&(C.defaultMainCamera=t.camera,Tt(!0))),uo(),co(),rt&&C.orbitControls&&(C.orbitControls.target.fromArray(rt),C.orbitControls.update()),oo(),Hs(),Ns(),je=n=>po(n),Ue=()=>fo(),e==="edit"&&r.addEventListener("click",je),window.addEventListener("resize",Ue),t||ho(),e==="edit"&&ao()}function no(){return window.devicePixelRatio}function io(){const r=no(),e=new S.WebGLRenderer({antialias:!0,alpha:!0});e.setSize(C.container.clientWidth,C.container.clientHeight),e.setPixelRatio(r),e.toneMapping=S.NeutralToneMapping,e.toneMappingExposure=1,console.log(`[Renderer] css=${C.container.clientWidth}×${C.container.clientHeight}, dpr=${window.devicePixelRatio}, targetRatio=${r}, antialias=true`),C.container.appendChild(e.domElement),C.renderer=e}function oo(){if(!C.renderer||!C.scene||!C.camera)return;const r=C.renderer.getPixelRatio(),e=C.container.clientWidth*r,t=C.container.clientHeight*r,n=new S.WebGLRenderTarget(e,t,{type:S.HalfFloatType,samples:4});n.texture.name="EffectComposer.rt1";const s=new Hn(C.renderer,n);s.addPass(new Bn(C.scene,C.camera)),s.addPass(new Fn),be=s}function ro(){if(C.scene=new S.Scene,C.scene.name="sl_scene",C.renderer){const r=xt(C.renderer);r&&(C.scene.environment=r,C.scene.environmentIntensity=1)}}function ao(){const r=new S.GridHelper(30,30,8956671,3364232);r.name="地板",r.userData.type="initFloor",C.scene.add(r),C.gridHelper=r}function lo(){const r=C.container,e=r.clientWidth/r.clientHeight,t=new S.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),C.camera=t}function Tt(r=!1){if(!C.defaultMainCamera)return;const e=C.defaultMainCamera;if(r){C.camera.position.set(e.position[0],e.position[1],e.position[2]),C.camera.rotation.set(e.rotation[0],e.rotation[1],e.rotation[2]),C.camera.updateProjectionMatrix(),rt=e.target;return}else Nt(""),at();if(!C.camera||!C.orbitControls)return;const t=C.camera.position.clone(),n=C.orbitControls.target.clone(),s=new S.Vector3(e.position[0],e.position[1],e.position[2]),i=e.target?new S.Vector3(e.target[0],e.target[1],e.target[2]):new S.Vector3(0,0,0);C.orbitControls.enabled=!1,new Ge.Tween({x:t.x,y:t.y,z:t.z,tx:n.x,ty:n.y,tz:n.z}).to({x:s.x,y:s.y,z:s.z,tx:i.x,ty:i.y,tz:i.z},1e3).easing(Ge.Easing.Quadratic.InOut).onUpdate(o=>{C.camera.position.set(o.x,o.y,o.z),C.orbitControls.target.set(o.tx,o.ty,o.tz),C.orbitControls.update()}).onComplete(()=>{rt=e.target,C.orbitControls.enabled=!0}).start()}function co(){const r=new cn(C.camera,C.renderer.domElement);r.minDistance=0,r.maxDistance=1/0,r.addEventListener("start",()=>{tt=!1}),r.addEventListener("change",()=>{tt=!0}),r.addEventListener("end",()=>{tt&&(De=!0,setTimeout(()=>{De=!1},200))}),C.orbitControls=r}function uo(){const r=new Cn(C.camera,C.renderer.domElement);r.addEventListener("dragging-changed",e=>{C.orbitControls.enabled=!e.value,e.value||(De=!0,setTimeout(()=>{De=!1},200))}),r.addEventListener("objectChange",()=>{const e=C.selectedObject;if(wt&&e&&wt(e),e&&e.type==="DirectionalLight"){const t=e.userData.helper;t&&t.update&&t.update()}}),C.scene.add(r.getHelper()),C.transformControls=r}function Ds(r=C.scene){if(!r||r.children.some(t=>t.type==="AmbientLight"))return null;const e=new S.AmbientLight(wo,vo);return e.name="环境光",r.add(e),e}function ho(){Ds(C.scene)}function Ns(){var e,t;nt=requestAnimationFrame(Ns),Ge.update(),(e=C.orbitControls)==null||e.update(),C.mode==="run"&&be&&C.scene&&C.camera?be.render():(t=C.renderer)==null||t.render(C.scene,C.camera),C.scene&&C.camera&&bs(C.scene,C.camera),We&&C.scene&&(_e=[],C.scene.traverse(n=>{n.userData.isWater&&n.type==="Mesh"&&_e.push(n)}),We=!1);for(let n=0;n<_e.length;n++){const s=_e[n],i=s.material;if(i.uniforms&&i.uniforms.time){const o=s.userData.waterTimeScale??1;i.uniforms.time.value+=1/60*o,C.camera&&i.uniforms.eye&&i.uniforms.eye.value.copy(C.camera.position);continue}if(i.normalMap){const o=s.userData.waterSpeed||{x:.005,y:.003};i.normalMap.offset.x+=o.x,i.normalMap.offset.y+=o.y}}}function fo(){if(!C.container||!C.camera||!C.renderer)return;const r=C.container.clientWidth,e=C.container.clientHeight;r===0||e===0||(C.camera.aspect=r/e,C.camera.updateProjectionMatrix(),C.renderer.setSize(r,e),be&&be.setSize(r,e),xs(r,e))}function lt(r){C.selectedObject!==r&&(C.selectedObject&&C.transformControls.detach(),C.selectedObject=r,C.transformControls.attach(r),C.transformControls.setMode(C.transformControlsMode),C.transformControls.showX=!0,C.transformControls.showY=!0,C.transformControls.showZ=!0,Ps(r),Te==null||Te(r))}let oe=null;function Ss(r){oe=r}function it(r){oe==null||oe(r)}function Rs(r){C.transformControlsMode=r,C.transformControls&&C.transformControls.setMode(C.transformControlsMode)}function Ps(r){if(C.mode!=="edit"){at();return}at(),r.traverse(e=>{if(e.isMesh){const t=e,n=new S.EdgesGeometry(t.geometry),s=new S.LineBasicMaterial({color:so,depthTest:!0}),i=new S.LineSegments(n,s);e.add(i),Mt.push(i)}})}function at(){for(const r of Mt)r.parent&&r.parent.remove(r),r.geometry.dispose(),r.material.dispose();Mt=[]}function Dt(){C.selectedObject&&(at(),C.transformControls.detach(),C.selectedObject=null,Te==null||Te(null))}function Nt(r){let e=null;Ne.forEach(t=>{t.userData.id==r&&(e=t),t.children&&t.children.forEach(n=>{n.name&&n.name.startsWith("DataPanel_")&&(n.visible=!1)})}),e&&(e.children.forEach(t=>{t.name&&t.name.startsWith("DataPanel_")&&(t.visible=!0)}),Ps(e),C.selectedObject=e,setTimeout(()=>{Os(e)},500))}function po(r){if(De){De=!1;return}const e=C.renderer.domElement.getBoundingClientRect(),t=new S.Vector2((r.clientX-e.left)/e.width*2-1,-((r.clientY-e.top)/e.height)*2+1),n=new S.Raycaster;n.setFromCamera(t,C.camera);const s=[];C.scene.traverse(o=>{(o.userData.isMovable||o.userData.type==="lightHelper")&&s.push(o)});const i=n.intersectObjects(s);if(i.length>0){let o=mo(i[0].object);lt(o)}else Dt()}function mo(r){var t,n;let e=r;for(;e;){if(((t=e.userData)==null?void 0:t.type)==="lightHelper"||e.type==="DirectionalLightHelper")return e.light||e;if(((n=e.userData)==null?void 0:n.type)==="AmbientLightHelper")return e.parent&&e.parent.type==="AmbientLight"?e.parent:e;e=e.parent}if(r.type==="Line"||r.type==="LineSegments"){const s=r.parent;if(s)switch(s.type){case"DirectionalLightHelper":return s.light;case"AmbientLight":return s;default:return s.isMesh?s:r}return r}return r}function Os(r,e=500){if(!C.camera||!C.orbitControls){console.warn("[focusOnObject] 编辑器尚未初始化或已销毁,无法执行聚焦操作。请确保已调用 initEditor()");return}if(!r){console.warn("[focusOnObject] 传入的物体为空,无法执行聚焦操作。");return}let t=null;r.userData.closeUpView&&typeof r.userData.closeUpView.x=="number"&&typeof r.userData.closeUpView.y=="number"&&typeof r.userData.closeUpView.z=="number"&&(t=r.userData.closeUpView);const n=new S.Vector3;r.getWorldPosition(n);const i=new S.Box3().setFromObject(r).getSize(new S.Vector3),o=Math.max(i.x,i.y,i.z)*.5,l=Math.max(o*3.5,5),u=new S.Vector3().copy(C.camera.position).sub(n).normalize();u.lengthSq()<.001&&u.set(0,0,1);const d=n.clone().add(u.multiplyScalar(l)),f=C.camera.position.clone(),h=C.orbitControls.target.clone();try{new Ge.Tween({x:f.x,y:f.y,z:f.z,tx:h.x,ty:h.y,tz:h.z}).to({x:t?t.x:d.x,y:t?t.y:d.y,z:t?t.z:d.z,tx:n.x,ty:n.y,tz:n.z},e).easing(Ge.Easing.Quadratic.InOut).onUpdate(g=>{C.camera.position.set(g.x,g.y,g.z),C.orbitControls.target.set(g.tx,g.ty,g.tz),C.orbitControls.update()}).start()}catch(g){console.error("[focusOnObject] TWEEN 动画创建失败,请检查 @tweenjs/tween.js 是否已正确安装且版本兼容(^23.1.3):",g)}}function Ao(r){r.userData.id&&Ne.set(String(r.userData.id),r)}function go(r){r.userData.id&&Ne.delete(String(r.userData.id))}function Ls(r,e){const t=e||r.userData.id;if(t)Ne.set(String(t),r);else{const n=S.MathUtils.generateUUID();r.userData.id=n,Ne.set(n,r)}}function yo(r){r.traverse(e=>{if(e.name&&e.name.startsWith("DataPanel_")){const t=e;t.element&&t.element.parentNode&&t.element.parentNode.removeChild(t.element)}})}function Ie(r,e=!1){C.scene.add(r),We=!0,r.userData.isMovable&&(bo(r),ct()),e&&C.mode==="edit"&&lt(r)}function ks(r){C.selectedObject===r&&Dt(),We=!0,yo(r),go(r),r.userData.helper&&C.scene.remove(r.userData.helper),r.parent?r.parent.remove(r):C.scene.remove(r),xo(r),ct()}function Vs(r){const e=C.scene.getObjectByProperty("uuid",r);e&&ks(e)}function bo(r){r.userData.isMovable&&r.parent===C.scene&&(xe.includes(r)||xe.push(r))}function xo(r){const e=xe.indexOf(r);e!==-1&&xe.splice(e,1)}function Hs(){const r=[];C.scene.children.forEach(e=>{e.userData.isMovable&&r.push(e)}),xe=r,ct()}function ct(){st==null||st([...xe])}function Bs(r){Te=r}function Fs(r){wt=r}function js(r){st=r}function Us(){return xe}function Gs(){return C.selectedObject}function Io(r,e,t){if(!C.scene)return;const n=Ne.get(r);if(n){const s=Oe(n);s&&s.updateItemByCode(e,t)}}function Co(){return C.scene}function zs(){return C.camera}function Mo(){return C.renderer}const wo=16777215,vo=1;async function Ws(){var w,y,E,N;oe==null||oe(!0),await new Promise(v=>setTimeout(v,50)),Dt();const r=C.scene;if(!r)return oe==null||oe(!1),{scene:new ArrayBuffer(0),camera:{position:void 0,rotation:void 0,target:[0,0,0]},dataPanels:{},waters:[],textures:{},ambientLight:null};const e=[],t=new Map,n=new Map,s={},i=[],o=[];let l=null;const u=[];r.traverse(v=>{var O,J;if(v.userData._sourceUuid=v.uuid,v.type==="AmbientLight"){const L=v;l={color:"#"+L.color.getHexString(),intensity:L.intensity,name:L.name||"环境光",visible:L.visible,position:L.position.toArray(),hasHelper:!!L.userData.helper},u.push(L)}if(v.userData.type==="lightHelper"&&e.push(v),v.type==="DirectionalLight"&&v.userData.helper&&(t.set(v,v.userData.helper),v.userData.helper=void 0),v.userData.isWater&&v.type==="Mesh"&&v.parent){const L=v,X=L.material;let G="#4fc3f7";X.uniforms&&X.uniforms.waterColor&&(G="#"+X.uniforms.waterColor.value.getHexString());const z=L.geometry,V={uuid:v.uuid,name:v.name,position:v.position.toArray(),rotation:[v.rotation.x,v.rotation.y,v.rotation.z],scale:v.scale.toArray(),color:G,timeScale:v.userData.waterTimeScale??.05,geometryType:"box",boxWidth:void 0,boxDepth:void 0,cylinderRadiusTop:void 0,cylinderRadiusBottom:void 0,cylinderRadialSegments:void 0};z.parameters&&z.parameters.radiusTop!==void 0?(V.geometryType="cylinder",V.cylinderRadiusTop=z.parameters.radiusTop,V.cylinderRadiusBottom=z.parameters.radiusBottom,V.cylinderRadialSegments=z.parameters.radialSegments):(V.geometryType="box",V.boxWidth=z.parameters.width,V.boxDepth=z.parameters.depth),i.push(V),o.push(v)}if(v.name&&v.name.startsWith("DataPanel_")){const L=v;if(L.element){const X=L.element.querySelector("[data-panel-title]"),G=[];if(L.element.querySelectorAll(".sl-css2d-data-panel-item").forEach(V=>{var K,te,q;const P=V.querySelector(".item-label"),W=V.querySelector(".item-value");if(P&&W){const ue=(P.textContent||"").trim(),de=((te=(K=W.childNodes[0])==null?void 0:K.textContent)==null?void 0:te.trim())||"",ce=W.querySelector("span"),Ae=ce?(ce.textContent||"").trim():void 0,he=((q=V.getAttribute("data-item-code"))==null?void 0:q.trim())||void 0;G.push({label:ue,value:de,unit:Ae,code:he})}}),v.parent){const V=L.element.style.width||"",P=L.element.style.fontSize||"",W=Oe(v.parent),K=W?W.getOffsetY():.1;n.set(v.parent.userData.id?v.parent.userData.id:v.parent.uuid,{title:((O=X==null?void 0:X.textContent)==null?void 0:O.trim())||"",items:G,width:V,fontSize:P,offsetY:K,offsetX:W?W.getOffsetX():0,offsetZ:W?W.getOffsetZ():0})}}}if(v.type==="Mesh"){const L=v,X=Array.isArray(L.material)?L.material:[L.material];for(const G of X)if(G&&G.userData){const z=G.userData;if(z._mapDataUrl||z._normalMapDataUrl||z._aoMapDataUrl){const V=G.uuid,P=s[V]||{};z._mapDataUrl&&(P.mapDataUrl=z._mapDataUrl,P.mapFileName=z._mapFileName),z._normalMapDataUrl&&(P.normalMapDataUrl=z._normalMapDataUrl,P.normalMapFileName=z._normalMapFileName,P.normalScale=((J=G.normalScale)==null?void 0:J.x)??1),z._aoMapDataUrl&&(P.aoMapDataUrl=z._aoMapDataUrl,P.aoMapFileName=z._aoMapFileName,P.aoMapIntensity=G.aoMapIntensity??1),s[V]=P}}}}),e.forEach(v=>r.remove(v));const d=(w=C.transformControls)==null?void 0:w.getHelper(),f=(d==null?void 0:d.parent)??null;d&&d.parent&&d.parent.remove(d);const h=new Map;for(const v of u)h.set(v,v.parent),v.parent&&v.parent.remove(v);const g=new Map;for(const v of o)g.set(v,v.parent),v.parent&&v.parent.remove(v);const A=r.clone();A.children=A.children.filter(v=>v.userData.type!=="initFloor"),A.traverse(v=>{v.name&&v.name.startsWith("DataPanel_")&&v.parent&&v.parent.remove(v)});const m=await new Fe().parseAsync(A,{binary:!0,onlyVisible:!1,embedImages:!0});e.forEach(v=>r.add(v));for(const v of u){const O=h.get(v);O?O.add(v):r.add(v)}for(const v of o){const O=g.get(v);O?O.add(v):r.add(v)}t.forEach((v,O)=>{O.userData.helper=v}),r.traverse(v=>{delete v.userData._sourceUuid}),d&&(f?f.add(d):r.add(d));const p={position:(y=C.camera)==null?void 0:y.position.toArray(),rotation:(E=C.camera)==null?void 0:E.rotation.toArray(),target:((N=C.orbitControls)==null?void 0:N.target.toArray())||[0,0,0]},x={};n.forEach((v,O)=>{x[O]=v});const M={scene:m,camera:p,dataPanels:x,waters:i,textures:s,ambientLight:l};return oe==null||oe(!1),M}function Eo(r){if(r instanceof ArrayBuffer||ArrayBuffer.isView(r)){if(r instanceof ArrayBuffer)return r;const e=r;return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(typeof r=="string"){const e=r.trim();let t=e;if(e.startsWith("data:")){const n=e.indexOf(",");if(n===-1)return null;t=e.slice(n+1)}if(/^Z2xURg/.test(t)){const n=atob(t),s=new Uint8Array(n.length);for(let i=0;i<n.length;i++)s[i]=n.charCodeAt(i);return s.buffer}return null}return r&&typeof r=="object"&&r.type==="Buffer"&&Array.isArray(r.data)?new Uint8Array(r.data).buffer:null}function To(r,e=.5){const t=new S.EdgesGeometry(new S.SphereGeometry(e,12,8)),n=new S.LineBasicMaterial({color:r.color,transparent:!0,opacity:.6}),s=new S.LineSegments(t,n);return s.userData.type="AmbientLightHelper",s}async function Xs(r,e="edit",t,n,s,i){var l,u,d,f,h,g,A;const o=Eo(r);if(o){const b=await new ws().parseAsync(o,""),m=b.scene||((l=b.scenes)==null?void 0:l[0]),p=(u=C.scene)==null?void 0:u.environment;if(C.scene=m,!m.children.some(x=>x.type==="AmbientLight"))if(i){const x=new S.AmbientLight(i.color,i.intensity);if(x.name=i.name||"环境光",x.visible=i.visible??!0,x.userData.isMovable=!0,i.position&&x.position.fromArray(i.position),e==="edit"&&i.hasHelper){const M=To(x,.5);x.userData.helper=M,x.add(M)}m.add(x)}else Ds(m);if(p)C.scene.environment=p;else if(C.renderer){const x=xt(C.renderer);x&&(C.scene.environment=x,C.scene.environmentIntensity=1)}}else{const b=typeof r=="string"?JSON.parse(r):r,p=new S.ObjectLoader().parse(b);if(p.type==="Scene"){const x=(d=C.scene)==null?void 0:d.environment;if(C.scene=p,x)C.scene.environment=x;else if(C.renderer){const M=xt(C.renderer);M&&(C.scene.environment=M,C.scene.environmentIntensity=1)}}else(f=C.scene)==null||f.add(p)}if(t&&((h=C.scene)==null||h.traverse(b=>{const m=b.userData.id||b.userData._sourceUuid||b.uuid,p=t[m];if(p&&b.userData.isMovable){Ao(b);const x=new ze({title:p.title,items:p.items});x.attachTo(b),x.visible=!1,p.width&&x.setWidth(p.width),p.fontSize&&x.setFontSize(p.fontSize),p.offsetY!==void 0&&x.setOffsetY(p.offsetY),p.offsetX!==void 0&&x.setOffsetX(p.offsetX),p.offsetZ!==void 0&&x.setOffsetZ(p.offsetZ),gs(b,x)}})),n&&n.length>0&&Promise.resolve().then(()=>Ho).then(({addWater:b,addWaterCylinder:m})=>{for(const p of n){const x=p.geometryType||"box";let M;x==="cylinder"?M=m({radiusTop:p.cylinderRadiusTop??5,radiusBottom:p.cylinderRadiusBottom??5,radialSegments:p.cylinderRadialSegments??32,height:.8,color:p.color,scale:4}):M=b({width:p.boxWidth??10,height:p.boxDepth??10,color:p.color,scale:4}),M.position.fromArray(p.position),M.rotation.set(p.rotation[0],p.rotation[1],p.rotation[2]),M.scale.fromArray(p.scale),M.name=p.name,M.userData.waterTimeScale=p.timeScale??.05,M.userData.isWater=!0,M.userData.isMovable=!0,We=!0}Hs()}),s){const b=new S.TextureLoader;(g=C.scene)==null||g.traverse(m=>{if(m.type==="Mesh"){const p=m,x=Array.isArray(p.material)?p.material:[p.material];for(const M of x)if(M&&M.uuid&&s[M.uuid]){const w=s[M.uuid];if(w.mapDataUrl){const y=b.load(w.mapDataUrl);y.wrapS=y.wrapT=S.RepeatWrapping,y.repeat.set(1,1),M.map=y,M.userData=M.userData||{},M.userData._mapDataUrl=w.mapDataUrl,M.userData._mapFileName=w.mapFileName}if(w.normalMapDataUrl){const y=b.load(w.normalMapDataUrl);y.wrapS=y.wrapT=S.RepeatWrapping,y.repeat.set(1,1),M.normalMap=y,M.normalScale=new S.Vector2(w.normalScale??1,w.normalScale??1),M.userData=M.userData||{},M.userData._normalMapDataUrl=w.normalMapDataUrl,M.userData._normalMapFileName=w.normalMapFileName}if(w.aoMapDataUrl){const y=b.load(w.aoMapDataUrl);y.wrapS=y.wrapT=S.RepeatWrapping,y.repeat.set(1,1),M.aoMap=y,M.aoMapIntensity=w.aoMapIntensity??1,M.userData=M.userData||{},M.userData._aoMapDataUrl=w.aoMapDataUrl,M.userData._aoMapFileName=w.aoMapFileName}M.needsUpdate=!0}}})}e==="edit"&&((A=C.scene)==null||A.traverse(b=>{var m;if(b.type==="DirectionalLight"){const p=b;if(!p.userData.helper){const x=new S.DirectionalLightHelper(p,1);x.userData.type="lightHelper",p.userData.helper=x,x.update(),(m=C.scene)==null||m.add(x)}}}))}function qs(r){if(!r)return;if(r.type==="Mesh"){const t=r;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(s=>{s.map&&(s.map=null),s.lightMap&&(s.lightMap=null),s.aoMap&&(s.aoMap=null),s.emissiveMap&&(s.emissiveMap=null),s.bumpMap&&(s.bumpMap=null),s.normalMap&&(s.normalMap=null),s.displacementMap&&(s.displacementMap=null),s.roughnessMap&&(s.roughnessMap=null),s.metalnessMap&&(s.metalnessMap=null),s.alphaMap&&(s.alphaMap=null),s.envMap&&(s.envMap=null),s.dispose()})}const e=r.children.slice();for(const t of e)qs(t)}function Ys(){nt!==null&&(cancelAnimationFrame(nt),nt=null),je&&C.container&&(C.container.removeEventListener("click",je),je=null),Ue&&(window.removeEventListener("resize",Ue),Ue=null),C.orbitControls&&(C.orbitControls.dispose(),C.orbitControls=null),C.transformControls&&(C.transformControls.dispose(),C.transformControls=null),be&&(be.dispose(),be=null),C.scene&&(qs(C.scene),C.scene=null),C.renderer&&(C.renderer.dispose(),C.renderer.domElement&&C.container&&C.container.removeChild(C.renderer.domElement),C.renderer=null),Is(),C.camera=null,C.gridHelper=null,C.selectedObject=null,C.container=null,C.mode="",xe=[],Ne.clear(),ct(),tt=!1,De=!1}const Do=/^[og]\s*(.+)?/,No=/^mtllib /,So=/^usemtl /,Ro=/^usemap /,ds=/\s+/,hs=new c.Vector3,yt=new c.Vector3,fs=new c.Vector3,ps=new c.Vector3,ae=new c.Vector3,$e=new c.Color;function Po(){const r={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}const n=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(s,i){const o=this._finalize(!1);o&&(o.inherited||o.groupCount<=0)&&this.materials.splice(o.index,1);const l={index:this.materials.length,name:s||"",mtllib:Array.isArray(i)&&i.length>0?i[i.length-1]:"",smooth:o!==void 0?o.smooth:this.smooth,groupStart:o!==void 0?o.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(u){const d={index:typeof u=="number"?u:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return d.clone=this.clone.bind(d),d}};return this.materials.push(l),l},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(s){const i=this.currentMaterial();if(i&&i.groupEnd===-1&&(i.groupEnd=this.geometry.vertices.length/3,i.groupCount=i.groupEnd-i.groupStart,i.inherited=!1),s&&this.materials.length>1)for(let o=this.materials.length-1;o>=0;o--)this.materials[o].groupCount<=0&&this.materials.splice(o,1);return s&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),i}},n&&n.name&&typeof n.clone=="function"){const s=n.clone(0);s.inherited=!0,this.object.materials.push(s)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const s=this.vertices,i=this.object.geometry.vertices;i.push(s[e+0],s[e+1],s[e+2]),i.push(s[t+0],s[t+1],s[t+2]),i.push(s[n+0],s[n+1],s[n+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){const s=this.normals,i=this.object.geometry.normals;i.push(s[e+0],s[e+1],s[e+2]),i.push(s[t+0],s[t+1],s[t+2]),i.push(s[n+0],s[n+1],s[n+2])},addFaceNormal:function(e,t,n){const s=this.vertices,i=this.object.geometry.normals;hs.fromArray(s,e),yt.fromArray(s,t),fs.fromArray(s,n),ae.subVectors(fs,yt),ps.subVectors(hs,yt),ae.cross(ps),ae.normalize(),i.push(ae.x,ae.y,ae.z),i.push(ae.x,ae.y,ae.z),i.push(ae.x,ae.y,ae.z)},addColor:function(e,t,n){const s=this.colors,i=this.object.geometry.colors;s[e]!==void 0&&i.push(s[e+0],s[e+1],s[e+2]),s[t]!==void 0&&i.push(s[t+0],s[t+1],s[t+2]),s[n]!==void 0&&i.push(s[n+0],s[n+1],s[n+2])},addUV:function(e,t,n){const s=this.uvs,i=this.object.geometry.uvs;i.push(s[e+0],s[e+1]),i.push(s[t+0],s[t+1]),i.push(s[n+0],s[n+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,s,i,o,l,u,d){const f=this.vertices.length;let h=this.parseVertexIndex(e,f),g=this.parseVertexIndex(t,f),A=this.parseVertexIndex(n,f);if(this.addVertex(h,g,A),this.addColor(h,g,A),l!==void 0&&l!==""){const b=this.normals.length;h=this.parseNormalIndex(l,b),g=this.parseNormalIndex(u,b),A=this.parseNormalIndex(d,b),this.addNormal(h,g,A)}else this.addFaceNormal(h,g,A);if(s!==void 0&&s!==""){const b=this.uvs.length;h=this.parseUVIndex(s,b),g=this.parseUVIndex(i,b),A=this.parseUVIndex(o,b),this.addUV(h,g,A),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let n=0,s=e.length;n<s;n++){const i=this.parseVertexIndex(e[n],t);this.addVertexPoint(i),this.addColor(i)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const n=this.vertices.length,s=this.uvs.length;for(let i=0,o=e.length;i<o;i++)this.addVertexLine(this.parseVertexIndex(e[i],n));for(let i=0,o=t.length;i<o;i++)this.addUVLine(this.parseUVIndex(t[i],s))}};return r.startObject("",!1),r}class Oo extends c.Loader{constructor(e){super(e),this.materials=null}load(e,t,n,s){const i=this,o=new c.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{t(i.parse(l))}catch(u){s?s(u):console.error(u),i.manager.itemError(e)}},n,s)}setMaterials(e){return this.materials=e,this}parse(e){const t=new Po;e.indexOf(`\r
138
+ `,e.appendChild(i)})}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}attachTo(e){this.attachedObject&&this.attachedObject!==e&&this.detach();const t=new S.Vector3;e.getWorldPosition(t);const i=new S.Box3().setFromObject(e).max.y-t.y+this.options.offsetY;this.css2dObject||(this.css2dObject=new jn(this.container),this.css2dObject.name=`DataPanel_${e.name||e.uuid}`,this.css2dObject.center.set(.5,1)),this.css2dObject.position.set(this.options.offsetX,i,this.options.offsetZ??0),e.add(this.css2dObject),this.attachedObject=e}detach(){this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.attachedObject=null}show(){this._visible=!0,this.css2dObject&&(this.css2dObject.visible=!0)}hide(){this._visible=!1,this.css2dObject&&(this.css2dObject.visible=!1)}get visible(){return this._visible}set visible(e){e?this.show():this.hide()}setTitle(e){var n;this.options.title=e;const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-title]");e?t?t.textContent=e:this.rebuildPanel():t&&t.remove()}getTitle(){return this.options.title||""}setItems(e){var n;this.options.items=[...e];const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}getItems(){return[...this.options.items||[]]}addItem(e){var n;this.options.items.push(e);const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}removeItem(e){var n;this.options.items=this.options.items.filter(s=>s.label!==e);const t=(n=this.container)==null?void 0:n.querySelector("[data-panel-list]");t&&this.renderItems(t,this.options.items)}updateItem(e,t,n){var i;const s=this.options.items.find(o=>o.label===e);if(s){s.value=t,n!==void 0&&(s.unit=n);const o=(i=this.container)==null?void 0:i.querySelector("[data-panel-list]");o&&this.renderItems(o,this.options.items)}}updateItemByCode(e,t){var s;const n=this.options.items.find(i=>i.code===e);if(n){n.value=t;const i=(s=this.container)==null?void 0:s.querySelector("[data-panel-list]");i&&this.renderItems(i,this.options.items)}}clearItems(){var t;this.options.items=[];const e=(t=this.container)==null?void 0:t.querySelector("[data-panel-list]");e&&this.renderItems(e,[])}rebuildPanel(){const e=this._visible,t=this.attachedObject;this.css2dObject&&this.attachedObject&&this.attachedObject.remove(this.css2dObject),this.buildPanel(),t&&(this.attachedObject=t,t.add(this.css2dObject),e||this.hide())}updateOptions(e){this.options={...this.options,...e},this.rebuildPanel()}getOffsetY(){return this.options.offsetY??.1}setOffsetY(e){if(this.options.offsetY=e,this.css2dObject&&this.attachedObject){const t=new S.Vector3;this.attachedObject.getWorldPosition(t);const s=new S.Box3().setFromObject(this.attachedObject).max.y-t.y;this.css2dObject.position.set(this.options.offsetX??0,s+e,this.options.offsetZ??0)}}getOffsetX(){return this.options.offsetX??0}setOffsetX(e){this.options.offsetX=e,this.css2dObject&&this.attachedObject&&(this.css2dObject.position.x=e)}getOffsetZ(){return this.options.offsetZ??0}setOffsetZ(e){this.options.offsetZ=e,this.css2dObject&&this.attachedObject&&(this.css2dObject.position.z=e)}getWidth(){return this.options.width||"20em"}getFontSize(){return this.options.fontSize||"0.85em"}setWidth(e){this.options.width=e,this.container&&(this.container.style.width=e)}setFontSize(e){if(this.options.fontSize=e,this.container){this.container.style.fontSize=e;const t=this.container.querySelector("[data-panel-title]");t&&(t.style.fontSize=`calc(${e} + 0.15em)`)}}getElement(){return this.container}dispose(){var e;this.detach(),(e=this.container)!=null&&e.parentNode&&this.container.parentNode.removeChild(this.container),this.css2dObject=null,this.container=null,this.attachedObject=null}};Me(Re,"_breathInjected",!1);let ze=Re;const ot=new WeakMap;function gs(r,e){const t=a.toRaw(r);ot.set(t,e),t.userData._hasDataPanel=!0}function Oe(r){return ot.get(a.toRaw(r))||null}function Et(r){const e=a.toRaw(r),t=ot.get(e);t&&(t.dispose(),ot.delete(e)),e.userData._hasDataPanel=void 0}let _=null;function ys(r){return _?(_.domElement.parentNode!==r&&r.appendChild(_.domElement),_):(_=new Un,_.setSize(r.clientWidth,r.clientHeight),_.domElement.style.position="absolute",_.domElement.style.top="0",_.domElement.style.left="0",_.domElement.style.pointerEvents="none",r.appendChild(_.domElement),_)}function Qn(){return _}function bs(r,e){_&&_.render(r,e)}function xs(r,e){_&&_.setSize(r,e)}function Is(){_&&(_.domElement.parentNode&&_.domElement.parentNode.removeChild(_.domElement),_=null)}function Jn(){const r=new S.Scene;r.position.y=-3.5;const e=new S.BoxGeometry;e.deleteAttribute("uv");const t=new S.MeshStandardMaterial({side:S.BackSide}),n=new S.PointLight(16777215,900,28,2);n.position.set(.418,16.199,.3),r.add(n);const s=new S.Mesh(e,t);s.position.set(-.757,13.219,.717),s.scale.set(31.713,28.305,28.591),r.add(s);const i=new S.MeshStandardMaterial,o=new S.InstancedMesh(e,i,6),l=new S.Object3D;l.position.set(-10.906,2.009,1.846),l.rotation.set(0,-.195,0),l.scale.set(2.328,7.905,4.651),l.updateMatrix(),o.setMatrixAt(0,l.matrix),l.position.set(-5.607,-.754,-.758),l.rotation.set(0,.994,0),l.scale.set(1.97,1.534,3.955),l.updateMatrix(),o.setMatrixAt(1,l.matrix),l.position.set(6.167,.857,7.803),l.rotation.set(0,.561,0),l.scale.set(3.927,6.285,3.687),l.updateMatrix(),o.setMatrixAt(2,l.matrix),l.position.set(-2.017,.018,6.124),l.rotation.set(0,.333,0),l.scale.set(2.002,4.566,2.064),l.updateMatrix(),o.setMatrixAt(3,l.matrix),l.position.set(2.291,-.756,-2.621),l.rotation.set(0,-.286,0),l.scale.set(1.546,1.552,1.496),l.updateMatrix(),o.setMatrixAt(4,l.matrix),l.position.set(-2.193,-.369,-5.547),l.rotation.set(0,.516,0),l.scale.set(3.875,3.487,2.986),l.updateMatrix(),o.setMatrixAt(5,l.matrix),o.instanceMatrix.needsUpdate=!0,r.add(o);function u(m){return new S.MeshLambertMaterial({color:0,emissive:16777215,emissiveIntensity:m})}const d=new S.Mesh(e,u(50));d.position.set(-16.116,14.37,8.208),d.scale.set(.1,2.428,2.739),r.add(d);const f=new S.Mesh(e,u(50));f.position.set(-16.109,18.021,-8.207),f.scale.set(.1,2.425,2.751),r.add(f);const h=new S.Mesh(e,u(17));h.position.set(14.904,12.198,-1.832),h.scale.set(.15,4.265,6.331),r.add(h);const g=new S.Mesh(e,u(43));g.position.set(-.462,8.89,14.52),g.scale.set(4.38,5.441,.088),r.add(g);const A=new S.Mesh(e,u(20));A.position.set(3.235,11.486,-12.541),A.scale.set(2.5,2,.1),r.add(A);const b=new S.Mesh(e,u(100));return b.position.set(0,20,0),b.scale.set(1,.1,1),r.add(b),r}function xt(r){try{const e=new S.PMREMGenerator(r),t=Jn(),n=e.fromScene(t).texture;return t.traverse(s=>{if(s.isMesh){const i=s,o=Array.isArray(i.material)?i.material:[i.material];for(const l of o)l&&l.dispose()}}),e.dispose(),n}catch(e){return console.error("环境贴图生成失败:",e),null}}const es={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"]};class Fe{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new li(e)}),this.register(function(e){return new ci(e)}),this.register(function(e){return new fi(e)}),this.register(function(e){return new pi(e)}),this.register(function(e){return new mi(e)}),this.register(function(e){return new Ai(e)}),this.register(function(e){return new ui(e)}),this.register(function(e){return new di(e)}),this.register(function(e){return new hi(e)}),this.register(function(e){return new gi(e)}),this.register(function(e){return new yi(e)}),this.register(function(e){return new bi(e)}),this.register(function(e){return new xi(e)}),this.register(function(e){return new Ii(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,t,n,s){const i=new ai,o=[];for(let l=0,u=this.pluginCallbacks.length;l<u;l++)o.push(this.pluginCallbacks[l](i));i.setPlugins(o),i.setTextureUtils(this.textureUtils),i.writeAsync(e,t,s).catch(n)}parseAsync(e,t){const n=this;return new Promise(function(s,i){n.parse(e,s,i,t)})}}const F={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,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},ft="KHR_mesh_quantization",re={};re[c.NearestFilter]=F.NEAREST;re[c.NearestMipmapNearestFilter]=F.NEAREST_MIPMAP_NEAREST;re[c.NearestMipmapLinearFilter]=F.NEAREST_MIPMAP_LINEAR;re[c.LinearFilter]=F.LINEAR;re[c.LinearMipmapNearestFilter]=F.LINEAR_MIPMAP_NEAREST;re[c.LinearMipmapLinearFilter]=F.LINEAR_MIPMAP_LINEAR;re[c.ClampToEdgeWrapping]=F.CLAMP_TO_EDGE;re[c.RepeatWrapping]=F.REPEAT;re[c.MirroredRepeatWrapping]=F.MIRRORED_REPEAT;const ts={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},_n=new c.Color,ss=12,$n=1179937895,ei=2,ns=8,ti=1313821514,si=5130562;function me(r,e){return r.length===e.length&&r.every(function(t,n){return t===e[n]})}function ni(r){return new TextEncoder().encode(r).buffer}function ii(r){return me(r.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function oi(r,e,t){const n={min:new Array(r.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(r.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=e;s<e+t;s++)for(let i=0;i<r.itemSize;i++){let o;r.itemSize>4?o=r.array[s*r.itemSize+i]:(i===0?o=r.getX(s):i===1?o=r.getY(s):i===2?o=r.getZ(s):i===3&&(o=r.getW(s)),r.normalized===!0&&(o=c.MathUtils.normalize(o,r.array))),n.min[i]=Math.min(n.min[i],o),n.max[i]=Math.max(n.max[i],o)}return n}function Cs(r){return Math.ceil(r/4)*4}function pt(r,e=0){const t=Cs(r.byteLength);if(t!==r.byteLength){const n=new Uint8Array(t);if(n.set(new Uint8Array(r)),e!==0)for(let s=r.byteLength;s<t;s++)n[s]=e;return n.buffer}return r}function is(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function ri(r,e){if(typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas){let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),r.convertToBlob({type:e,quality:t})}else return new Promise(t=>r.toBlob(t,e))}class ai{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 r"+c.REVISION}},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,t,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);const s=this,i=s.buffers,o=s.json;n=s.options;const l=s.extensionsUsed,u=s.extensionsRequired,d=new Blob(i,{type:"application/octet-stream"}),f=Object.keys(l),h=Object.keys(u);if(f.length>0&&(o.extensionsUsed=f),h.length>0&&(o.extensionsRequired=h),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=d.size),n.binary===!0){const g=new FileReader;g.readAsArrayBuffer(d),g.onloadend=function(){const A=pt(g.result),b=new DataView(new ArrayBuffer(ns));b.setUint32(0,A.byteLength,!0),b.setUint32(4,si,!0);const m=pt(ni(JSON.stringify(o)),32),p=new DataView(new ArrayBuffer(ns));p.setUint32(0,m.byteLength,!0),p.setUint32(4,ti,!0);const x=new ArrayBuffer(ss),M=new DataView(x);M.setUint32(0,$n,!0),M.setUint32(4,ei,!0);const w=ss+p.byteLength+m.byteLength+b.byteLength+A.byteLength;M.setUint32(8,w,!0);const y=new Blob([x,p,m,b,A],{type:"application/octet-stream"}),E=new FileReader;E.readAsArrayBuffer(y),E.onloadend=function(){t(E.result)}}}else if(o.buffers&&o.buffers.length>0){const g=new FileReader;g.readAsDataURL(d),g.onloadend=function(){const A=g.result;o.buffers[0].uri=A,t(o)}}else t(o)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const n=this.options,s=this.extensionsUsed;try{const i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const o in i.gltfExtensions)t.extensions[o]=i.gltfExtensions[o],s[o]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.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,t=!1){if(this.uids.has(e)===!1){const s=new Map;s.set(!0,this.uid++),s.set(!1,this.uid++),this.uids.set(e,s)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new c.Vector3;for(let s=0,i=e.count;s<i;s++)if(Math.abs(n.fromBufferAttribute(e,s).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const n=e.clone(),s=new c.Vector3;for(let i=0,o=n.count;i<o;i++)s.fromBufferAttribute(n,i),s.x===0&&s.y===0&&s.z===0?s.setX(1):s.normalize(),n.setXYZ(i,s.x,s.y,s.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1;const s={};(t.offset.x!==0||t.offset.y!==0)&&(s.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(s.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(s.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=s,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,t){if(e===t)return e;function n(A){return A.colorSpace===c.SRGBColorSpace?function(m){return m<.04045?m*.0773993808:Math.pow(m*.9478672986+.0521327014,2.4)}:function(m){return m}}e instanceof c.CompressedTexture&&(e=await this.decompressTextureAsync(e)),t instanceof c.CompressedTexture&&(t=await this.decompressTextureAsync(t));const s=e?e.image:null,i=t?t.image:null,o=Math.max(s?s.width:0,i?i.width:0),l=Math.max(s?s.height:0,i?i.height:0),u=is();u.width=o,u.height=l;const d=u.getContext("2d",{willReadFrequently:!0});d.fillStyle="#00ffff",d.fillRect(0,0,o,l);const f=d.getImageData(0,0,o,l);if(s){d.drawImage(s,0,0,o,l);const A=n(e),b=d.getImageData(0,0,o,l).data;for(let m=2;m<b.length;m+=4)f.data[m]=A(b[m]/256)*256}if(i){d.drawImage(i,0,0,o,l);const A=n(t),b=d.getImageData(0,0,o,l).data;for(let m=1;m<b.length;m+=4)f.data[m]=A(b[m]/256)*256}d.putImageData(f,0,0);const g=(e||t).clone();return g.source=new c.Source(u),g.colorSpace=c.NoColorSpace,g.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),g}async decompressTextureAsync(e,t=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,t)}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,s,i){const o=this.json;o.bufferViews||(o.bufferViews=[]);let l;switch(t){case F.BYTE:case F.UNSIGNED_BYTE:l=1;break;case F.SHORT:case F.UNSIGNED_SHORT:l=2;break;default:l=4}let u=e.itemSize*l;i===F.ARRAY_BUFFER&&(u=Math.ceil(u/4)*4);const d=Cs(s*u),f=new DataView(new ArrayBuffer(d));let h=0;for(let b=n;b<n+s;b++){for(let m=0;m<e.itemSize;m++){let p;e.itemSize>4?p=e.array[b*e.itemSize+m]:(m===0?p=e.getX(b):m===1?p=e.getY(b):m===2?p=e.getZ(b):m===3&&(p=e.getW(b)),e.normalized===!0&&(p=c.MathUtils.normalize(p,e.array))),t===F.FLOAT?f.setFloat32(h,p,!0):t===F.INT?f.setInt32(h,p,!0):t===F.UNSIGNED_INT?f.setUint32(h,p,!0):t===F.SHORT?f.setInt16(h,p,!0):t===F.UNSIGNED_SHORT?f.setUint16(h,p,!0):t===F.BYTE?f.setInt8(h,p):t===F.UNSIGNED_BYTE&&f.setUint8(h,p),h+=l}h%u!==0&&(h+=u-h%u)}const g={buffer:this.processBuffer(f.buffer),byteOffset:this.byteOffset,byteLength:d};return i!==void 0&&(g.target=i),i===F.ARRAY_BUFFER&&(g.byteStride=u),this.byteOffset+=d,o.bufferViews.push(g),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise(function(s){const i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){const o=pt(i.result),l={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,s(n.bufferViews.push(l)-1)}})}processAccessor(e,t,n,s){const i=this.json,o={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let l;if(e.array.constructor===Float32Array)l=F.FLOAT;else if(e.array.constructor===Int32Array)l=F.INT;else if(e.array.constructor===Uint32Array)l=F.UNSIGNED_INT;else if(e.array.constructor===Int16Array)l=F.SHORT;else if(e.array.constructor===Uint16Array)l=F.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)l=F.BYTE;else if(e.array.constructor===Uint8Array)l=F.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),(s===void 0||s===1/0)&&(s=e.count),s===0)return null;const u=oi(e,n,s);let d;t!==void 0&&(d=e===t.index?F.ELEMENT_ARRAY_BUFFER:F.ARRAY_BUFFER);const f=this.processBufferView(e,l,n,s,d),h={bufferView:f.id,byteOffset:f.byteOffset,componentType:l,count:s,max:u.max,min:u.min,type:o[e.itemSize]};return e.normalized===!0&&(h.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(h)-1}processImage(e,t,n,s="image/png"){if(e!==null){const i=this,o=i.cache,l=i.json,u=i.options,d=i.pending;o.images.has(e)||o.images.set(e,{});const f=o.images.get(e),h=s+":flipY/"+n.toString();if(f[h]!==void 0)return f[h];l.images||(l.images=[]);const g={mimeType:s},A=is();A.width=Math.min(e.width,u.maxTextureSize),A.height=Math.min(e.height,u.maxTextureSize);const b=A.getContext("2d",{willReadFrequently:!0});if(n===!0&&(b.translate(0,A.height),b.scale(1,-1)),e.data!==void 0){t!==c.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>u.maxTextureSize||e.height>u.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const p=new Uint8ClampedArray(e.height*e.width*4);for(let x=0;x<p.length;x+=4)p[x+0]=e.data[x+0],p[x+1]=e.data[x+1],p[x+2]=e.data[x+2],p[x+3]=e.data[x+3];b.putImageData(new ImageData(p,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)b.drawImage(e,0,0,A.width,A.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");u.binary===!0?d.push(ri(A,s).then(p=>i.processBufferViewImage(p)).then(p=>{g.bufferView=p})):g.uri=c.ImageUtils.getDataURL(A,s);const m=l.images.push(g)-1;return f[h]=m,m}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const n={magFilter:re[e.magFilter],minFilter:re[e.minFilter],wrapS:re[e.wrapS],wrapT:re[e.wrapT]};return t.samplers.push(n)-1}async processTextureAsync(e){const n=this.options,s=this.cache,i=this.json;if(s.textures.has(e))return s.textures.get(e);i.textures||(i.textures=[]),e instanceof c.CompressedTexture&&(e=await this.decompressTextureAsync(e,n.maxTextureSize));const o=e.userData.mimeType,l=this.processImage(e.image,e.format,e.flipY,o),u={sampler:this.processSampler(e)};o==="image/webp"?(u.extensions=u.extensions||{},u.extensions.EXT_texture_webp={source:l},this.extensionsUsed.EXT_texture_webp=!0,this.extensionsRequired.EXT_texture_webp=!0):u.source=l,e.name&&(u.name=e.name),await this._invokeAllAsync(async function(f){f.writeTexture&&await f.writeTexture(e,u)});const d=i.textures.push(u)-1;return s.textures.set(e,d),d}async processMaterialAsync(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const s={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const i=e.color.toArray().concat([e.opacity]);if(me(i,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=e.metalness,s.pbrMetallicRoughness.roughnessFactor=e.roughness):(s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){const l=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),u={index:await this.processTextureAsync(l),texCoord:l.channel};this.applyTextureTransform(u,l),s.pbrMetallicRoughness.metallicRoughnessTexture=u}if(e.map){const l={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(l,e.map),s.pbrMetallicRoughness.baseColorTexture=l}if(e.emissive){const l=e.emissive;if(Math.max(l.r,l.g,l.b)>0&&(s.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const d={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(d,e.emissiveMap),s.emissiveTexture=d}}if(e.normalMap){const l={index:await this.processTextureAsync(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(l.scale=e.normalScale.x),this.applyTextureTransform(l,e.normalMap),s.normalTexture=l}if(e.aoMap){const l={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(l.strength=e.aoMapIntensity),this.applyTextureTransform(l,e.aoMap),s.occlusionTexture=l}e.transparent?s.alphaMode="BLEND":e.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),e.side===c.DoubleSide&&(s.doubleSided=!0),e.name!==""&&(s.name=e.name),this.serializeUserData(e,s),await this._invokeAllAsync(async function(l){l.writeMaterialAsync&&await l.writeMaterialAsync(e,s)});const o=n.materials.push(s)-1;return t.materials.set(e,o),o}async processMeshAsync(e){const t=this.cache,n=this.json,s=[e.geometry.uuid];if(Array.isArray(e.material))for(let y=0,E=e.material.length;y<E;y++)s.push(e.material[y].uuid);else s.push(e.material.uuid);const i=s.join(":");if(t.meshes.has(i))return t.meshes.get(i);const o=e.geometry;let l;e.isLineSegments?l=F.LINES:e.isLineLoop?l=F.LINE_LOOP:e.isLine?l=F.LINE_STRIP:e.isPoints?l=F.POINTS:l=e.material.wireframe?F.LINES:F.TRIANGLES;const u={},d={},f=[],h=[],g={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},A=o.getAttribute("normal");A!==void 0&&!this.isNormalizedNormalAttribute(A)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(A)));let b=null;for(let y in o.attributes){if(y.slice(0,5)==="morph")continue;const E=o.attributes[y];if(y=g[y]||y.toUpperCase(),!/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(y)&&!y.startsWith("_")&&(y="_"+y),t.attributes.has(this.getUID(E))){d[y]=t.attributes.get(this.getUID(E));continue}b=null;const v=E.array;y==="JOINTS_0"&&!(v instanceof Uint16Array)&&!(v instanceof Uint8Array)?(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),b=Fe.Utils.toTypedBufferAttribute(E,Uint16Array)):(v instanceof Uint32Array||v instanceof Int32Array)&&!y.startsWith("_")&&(console.warn(`GLTFExporter: Attribute "${y}" converted to type FLOAT.`),b=Fe.Utils.toTypedBufferAttribute(E,Float32Array));const O=this.processAccessor(b||E,o);O!==null&&(y.startsWith("_")||this.detectMeshQuantization(y,E),d[y]=O,t.attributes.set(this.getUID(E),O))}if(A!==void 0&&o.setAttribute("normal",A),Object.keys(d).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const y=[],E=[],N={};if(e.morphTargetDictionary!==void 0)for(const v in e.morphTargetDictionary)N[e.morphTargetDictionary[v]]=v;for(let v=0;v<e.morphTargetInfluences.length;++v){const O={};let J=!1;for(const L in o.morphAttributes){if(L!=="position"&&L!=="normal"){J||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),J=!0);continue}const X=o.morphAttributes[L][v],G=L.toUpperCase(),z=o.attributes[L];if(t.attributes.has(this.getUID(X,!0))){O[G]=t.attributes.get(this.getUID(X,!0));continue}const V=X.clone();if(!o.morphTargetsRelative)for(let P=0,W=X.count;P<W;P++)for(let K=0;K<X.itemSize;K++)K===0&&V.setX(P,X.getX(P)-z.getX(P)),K===1&&V.setY(P,X.getY(P)-z.getY(P)),K===2&&V.setZ(P,X.getZ(P)-z.getZ(P)),K===3&&V.setW(P,X.getW(P)-z.getW(P));O[G]=this.processAccessor(V,o),t.attributes.set(this.getUID(z,!0),O[G])}h.push(O),y.push(e.morphTargetInfluences[v]),e.morphTargetDictionary!==void 0&&E.push(N[v])}u.weights=y,E.length>0&&(u.extras={},u.extras.targetNames=E)}const m=Array.isArray(e.material);if(m&&o.groups.length===0)return null;let p=!1;if(m&&o.index===null){const y=[];for(let E=0,N=o.attributes.position.count;E<N;E++)y[E]=E;o.setIndex(y),p=!0}const x=m?e.material:[e.material],M=m?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let y=0,E=M.length;y<E;y++){const N={mode:l,attributes:d};if(this.serializeUserData(o,N),h.length>0&&(N.targets=h),o.index!==null){let O=this.getUID(o.index);(M[y].start!==void 0||M[y].count!==void 0)&&(O+=":"+M[y].start+":"+M[y].count),t.attributes.has(O)?N.indices=t.attributes.get(O):(N.indices=this.processAccessor(o.index,o,M[y].start,M[y].count),t.attributes.set(O,N.indices)),N.indices===null&&delete N.indices}const v=await this.processMaterialAsync(x[M[y].materialIndex]);v!==null&&(N.material=v),f.push(N)}p===!0&&o.setIndex(null),u.primitives=f,n.meshes||(n.meshes=[]),await this._invokeAllAsync(function(y){y.writeMesh&&y.writeMesh(e,u)});const w=n.meshes.push(u)-1;return t.meshes.set(i,w),w}detectMeshQuantization(e,t){if(this.extensionsUsed[ft])return;let n;switch(t.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}t.normalized&&(n+=" normalized");const s=e.split("_",1)[0];es[s]&&es[s].includes(n)&&(this.extensionsUsed[ft]=!0,this.extensionsRequired[ft]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,s={type:n?"orthographic":"perspective"};return n?s.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:s.perspective={aspectRatio:e.aspect,yfov:c.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(s.name=e.type),t.cameras.push(s)-1}processAnimation(e,t){const n=this.json,s=this.nodeMap;n.animations||(n.animations=[]),e=Fe.Utils.mergeMorphTargetTracks(e.clone(),t);const i=e.tracks,o=[],l=[];for(let d=0;d<i.length;++d){const f=i[d],h=c.PropertyBinding.parseTrackName(f.name);let g=c.PropertyBinding.findNode(t,h.nodeName);const A=ts[h.propertyName];if(h.objectName==="bones"&&(g.isSkinnedMesh===!0?g=g.skeleton.getBoneByName(h.objectIndex):g=void 0),!g||!A){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',f.name);continue}const b=1;let m=f.values.length/f.times.length;A===ts.morphTargetInfluences&&(m/=g.morphTargetInfluences.length);let p;f.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(p="CUBICSPLINE",m/=3):f.getInterpolation()===c.InterpolateDiscrete?p="STEP":p="LINEAR",l.push({input:this.processAccessor(new c.BufferAttribute(f.times,b)),output:this.processAccessor(new c.BufferAttribute(f.values,m)),interpolation:p}),o.push({sampler:l.length-1,target:{node:s.get(g),path:A}})}const u={name:e.name||"clip_"+n.animations.length,samplers:l,channels:o};return this.serializeUserData(e,u),n.animations.push(u),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,s=t.nodes[n.get(e)],i=e.skeleton;if(i===void 0)return null;const o=e.skeleton.bones[0];if(o===void 0)return null;const l=[],u=new Float32Array(i.bones.length*16),d=new c.Matrix4;for(let h=0;h<i.bones.length;++h)l.push(n.get(i.bones[h])),d.copy(i.boneInverses[h]),d.multiply(e.bindMatrix).toArray(u,h*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new c.BufferAttribute(u,16)),joints:l,skeleton:n.get(o)}),s.skin=t.skins.length-1}async processNodeAsync(e){const t=this.json,n=this.options,s=this.nodeMap;if(t.nodes||(t.nodes=[]),e.pivot!==null)return await this._processNodeWithPivotAsync(e);const i={};if(n.trs){const l=e.quaternion.toArray(),u=e.position.toArray(),d=e.scale.toArray();me(l,[0,0,0,1])||(i.rotation=l),me(u,[0,0,0])||(i.translation=u),me(d,[1,1,1])||(i.scale=d)}else e.matrixAutoUpdate&&e.updateMatrix(),ii(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){const l=await this.processMeshAsync(e);l!==null&&(i.mesh=l)}else e.isCamera&&(i.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);const o=t.nodes.push(i)-1;if(s.set(e,o),e.children.length>0){const l=[];for(let u=0,d=e.children.length;u<d;u++){const f=e.children[u];if(f.visible||n.onlyVisible===!1){const h=await this.processNodeAsync(f);h!==null&&l.push(h)}}l.length>0&&(i.children=l)}return await this._invokeAllAsync(function(l){l.writeNode&&l.writeNode(e,i)}),o}async _processNodeWithPivotAsync(e){const t=this.json,n=this.options,s=this.nodeMap,i=e.pivot,o={},l=e.quaternion.toArray(),u=[e.position.x+i.x,e.position.y+i.y,e.position.z+i.z],d=e.scale.toArray();me(l,[0,0,0,1])||(o.rotation=l),me(u,[0,0,0])||(o.translation=u),me(d,[1,1,1])||(o.scale=d),o.extras={pivot:i.toArray()},e.name!==""&&(o.name=String(e.name)),this.serializeUserData(e,o);const f=t.nodes.push(o)-1;s.set(e,f);const h={},g=[-i.x,-i.y,-i.z];if(me(g,[0,0,0])||(h.translation=g),e.isMesh||e.isLine||e.isPoints){const m=await this.processMeshAsync(e);m!==null&&(h.mesh=m)}else e.isCamera&&(h.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);const b=[t.nodes.push(h)-1];if(e.children.length>0){const m=[];for(let p=0,x=e.children.length;p<x;p++){const M=e.children[p];if(M.visible||n.onlyVisible===!1){const w=await this.processNodeAsync(M);w!==null&&m.push(w)}}m.length>0&&(h.children=m)}return o.children=b,await this._invokeAllAsync(function(m){m.writeNode&&m.writeNode(e,o)}),f}async processSceneAsync(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const s={};e.name!==""&&(s.name=e.name),t.scenes.push(s);const i=[];for(let o=0,l=e.children.length;o<l;o++){const u=e.children[o];if(u.visible||n.onlyVisible===!1){const d=await this.processNodeAsync(u);d!==null&&i.push(d)}}i.length>0&&(s.nodes=i),this.serializeUserData(e,s)}async processObjectsAsync(e){const t=new c.Scene;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);await this.processSceneAsync(t)}async processInputAsync(e){const t=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync(function(s){s.beforeParse&&s.beforeParse(e)});const n=[];for(let s=0;s<e.length;s++)e[s]instanceof c.Scene?await this.processSceneAsync(e[s]):n.push(e[s]);n.length>0&&await this.processObjectsAsync(n);for(let s=0;s<this.skins.length;++s)this.processSkin(this.skins[s]);for(let s=0;s<t.animations.length;++s)this.processAnimation(t.animations[s],e[0]);await this._invokeAllAsync(function(s){s.afterParse&&s.afterParse(e)})}async _invokeAllAsync(e){for(let t=0,n=this.plugins.length;t<n;t++)await e(this.plugins[t])}}class li{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){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}const n=this.writer,s=n.json,i=n.extensionsUsed,o={};e.name&&(o.name=e.name),o.color=e.color.toArray(),o.intensity=e.intensity,e.isDirectionalLight?o.type="directional":e.isPointLight?(o.type="point",e.distance>0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(1-e.penumbra)*e.angle,o.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]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},i[this.name]=!0);const l=s.extensions[this.name].lights;l.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:l.length-1}}}let ci=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,t){if(!e.isMeshBasicMaterial)return;const s=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},s[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},ui=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){const o={index:await n.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(o,e.clearcoatMap),i.clearcoatTexture=o}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const o={index:await n.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(o,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=o}if(e.clearcoatNormalMap){const o={index:await n.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(o.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(o,e.clearcoatNormalMap),i.clearcoatNormalTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},di=class{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;const s=this.writer.extensionsUsed,i={};i.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},hi=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){const o={index:await n.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(o,e.iridescenceMap),i.iridescenceTexture=o}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const o={index:await n.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(o,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},fi=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){const o={index:await n.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(o,e.transmissionMap),i.transmissionTexture=o}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},pi=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,s=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){const o={index:await n.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(o,e.thicknessMap),i.thicknessTexture=o}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},mi=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const s=this.writer.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},Ai=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(_n)&&!e.specularIntensityMap&&!e.specularColorMap)return;const n=this.writer,s=n.extensionsUsed,i={};if(e.specularIntensityMap){const o={index:await n.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(o,e.specularIntensityMap),i.specularTexture=o}if(e.specularColorMap){const o={index:await n.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(o,e.specularColorMap),i.specularColorTexture=o}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},gi=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,s=n.extensionsUsed,i={};if(e.sheenRoughnessMap){const o={index:await n.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(o,e.sheenRoughnessMap),i.sheenRoughnessTexture=o}if(e.sheenColorMap){const o={index:await n.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(o,e.sheenColorMap),i.sheenColorTexture=o}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},yi=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,s=n.extensionsUsed,i={};if(e.anisotropyMap){const o={index:await n.processTextureAsync(e.anisotropyMap)};n.applyTextureTransform(o,e.anisotropyMap),i.anisotropyTexture=o}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},bi=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const s=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},xi=class{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const n=this.writer,s=n.extensionsUsed,i={};if(e.bumpMap){const o={index:await n.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(o,e.bumpMap),i.bumpTexture=o}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}},Ii=class{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;const n=this.writer,s=e,i=new Float32Array(s.count*3),o=new Float32Array(s.count*4),l=new Float32Array(s.count*3),u=new c.Matrix4,d=new c.Vector3,f=new c.Quaternion,h=new c.Vector3;for(let A=0;A<s.count;A++)s.getMatrixAt(A,u),u.decompose(d,f,h),d.toArray(i,A*3),f.toArray(o,A*4),h.toArray(l,A*3);const g={TRANSLATION:n.processAccessor(new c.BufferAttribute(i,3)),ROTATION:n.processAccessor(new c.BufferAttribute(o,4)),SCALE:n.processAccessor(new c.BufferAttribute(l,3))};s.instanceColor&&(g._COLOR_0=n.processAccessor(s.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:g},n.extensionsUsed[this.name]=!0,n.extensionsRequired[this.name]=!0}};Fe.Utils={insertKeyframe:function(r,e){const n=r.getValueSize(),s=new r.TimeBufferType(r.times.length+1),i=new r.ValueBufferType(r.values.length+n),o=r.createInterpolant(new r.ValueBufferType(n));let l;if(r.times.length===0){s[0]=e;for(let u=0;u<n;u++)i[u]=0;l=0}else if(e<r.times[0]){if(Math.abs(r.times[0]-e)<.001)return 0;s[0]=e,s.set(r.times,1),i.set(o.evaluate(e),0),i.set(r.values,n),l=0}else if(e>r.times[r.times.length-1]){if(Math.abs(r.times[r.times.length-1]-e)<.001)return r.times.length-1;s[s.length-1]=e,s.set(r.times,0),i.set(r.values,0),i.set(o.evaluate(e),r.values.length),l=s.length-1}else for(let u=0;u<r.times.length;u++){if(Math.abs(r.times[u]-e)<.001)return u;if(r.times[u]<e&&r.times[u+1]>e){s.set(r.times.slice(0,u+1),0),s[u+1]=e,s.set(r.times.slice(u+1),u+2),i.set(r.values.slice(0,(u+1)*n),0),i.set(o.evaluate(e),(u+1)*n),i.set(r.values.slice((u+1)*n),(u+2)*n),l=u+1;break}}return r.times=s,r.values=i,l},mergeMorphTargetTracks:function(r,e){const t=[],n={},s=r.tracks;for(let i=0;i<s.length;++i){let o=s[i];const l=c.PropertyBinding.parseTrackName(o.name),u=c.PropertyBinding.findNode(e,l.nodeName);if(l.propertyName!=="morphTargetInfluences"||l.propertyIndex===void 0){t.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.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."),o=o.clone(),o.setInterpolation(c.InterpolateLinear)}const d=u.morphTargetInfluences.length,f=u.morphTargetDictionary[l.propertyIndex];if(f===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+l.propertyIndex);let h;if(n[u.uuid]===void 0){h=o.clone();const A=new h.ValueBufferType(d*h.times.length);for(let b=0;b<h.times.length;b++)A[b*d+f]=h.values[b];h.name=(l.nodeName||"")+".morphTargetInfluences",h.values=A,n[u.uuid]=h,t.push(h);continue}const g=o.createInterpolant(new o.ValueBufferType(1));h=n[u.uuid];for(let A=0;A<h.times.length;A++)h.values[A*d+f]=g.evaluate(h.times[A]);for(let A=0;A<o.times.length;A++){const b=this.insertKeyframe(h,o.times[A]);h.values[b*d+f]=o.values[A]}}return r.tracks=t,r},toTypedBufferAttribute:function(r,e){const t=new c.BufferAttribute(new e(r.count*r.itemSize),r.itemSize,!1);if(!r.normalized&&!r.isInterleavedBufferAttribute)return t.array.set(r.array),t;for(let n=0,s=r.count;n<s;n++)for(let i=0;i<r.itemSize;i++)t.setComponent(n,i,r.getComponent(n,i));return t}};function os(r,e){if(e===c.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===c.TriangleFanDrawMode||e===c.TriangleStripDrawMode){let t=r.getIndex();if(t===null){const o=[],l=r.getAttribute("position");if(l!==void 0){for(let u=0;u<l.count;u++)o.push(u);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,s=[];if(e===c.TriangleFanDrawMode)for(let o=1;o<=n;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=r.clone();return i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}function Ci(r){const e=new Map,t=new Map,n=r.clone();return Ms(r,n,function(s,i){e.set(i,s),t.set(s,i)}),n.traverse(function(s){if(!s.isSkinnedMesh)return;const i=s,o=e.get(s),l=o.skeleton.bones;i.skeleton=o.skeleton.clone(),i.bindMatrix.copy(o.bindMatrix),i.skeleton.bones=l.map(function(u){return t.get(u)}),i.bind(i.skeleton,i.bindMatrix)}),n}function Ms(r,e,t){t(r,e);for(let n=0;n<r.children.length;n++)Ms(r.children[n],e.children[n],t)}class ws extends c.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ti(t)}),this.register(function(t){return new Di(t)}),this.register(function(t){return new Hi(t)}),this.register(function(t){return new Bi(t)}),this.register(function(t){return new Fi(t)}),this.register(function(t){return new Si(t)}),this.register(function(t){return new Ri(t)}),this.register(function(t){return new Pi(t)}),this.register(function(t){return new Oi(t)}),this.register(function(t){return new Ei(t)}),this.register(function(t){return new Li(t)}),this.register(function(t){return new Ni(t)}),this.register(function(t){return new Vi(t)}),this.register(function(t){return new ki(t)}),this.register(function(t){return new wi(t)}),this.register(function(t){return new rs(t,B.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new rs(t,B.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new ji(t)})}load(e,t,n,s){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const d=c.LoaderUtils.extractUrlBase(e);o=c.LoaderUtils.resolveURL(d,this.path)}else o=c.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const l=function(d){s?s(d):console.error(d),i.manager.itemError(e),i.manager.itemEnd(e)},u=new c.FileLoader(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(e,function(d){try{i.parse(d,o,function(f){t(f),i.manager.itemEnd(e)},l)}catch(f){l(f)}},n,l)}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,n,s){let i;const o={},l={},u=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(u.decode(new Uint8Array(e,0,4))===vs){try{o[B.KHR_BINARY_GLTF]=new Ui(e)}catch(h){s&&s(h);return}i=JSON.parse(o[B.KHR_BINARY_GLTF].content)}else i=JSON.parse(u.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const d=new eo(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});d.fileLoader.setRequestHeader(this.requestHeader);for(let f=0;f<this.pluginCallbacks.length;f++){const h=this.pluginCallbacks[f](d);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),l[h.name]=h,o[h.name]=!0}if(i.extensionsUsed)for(let f=0;f<i.extensionsUsed.length;++f){const h=i.extensionsUsed[f],g=i.extensionsRequired||[];switch(h){case B.KHR_MATERIALS_UNLIT:o[h]=new vi;break;case B.KHR_DRACO_MESH_COMPRESSION:o[h]=new Gi(i,this.dracoLoader);break;case B.KHR_TEXTURE_TRANSFORM:o[h]=new zi;break;case B.KHR_MESH_QUANTIZATION:o[h]=new Wi;break;default:g.indexOf(h)>=0&&l[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}d.setExtensions(o),d.setPlugins(l),d.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,i){n.parse(e,t,s,i)})}}function Mi(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}function $(r,e,t){const n=r.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}const B={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class wi{constructor(e){this.parser=e,this.name=B.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const i=t.json,u=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let d;const f=new c.Color(16777215);u.color!==void 0&&f.setRGB(u.color[0],u.color[1],u.color[2],c.LinearSRGBColorSpace);const h=u.range!==void 0?u.range:0;switch(u.type){case"directional":d=new c.DirectionalLight(f),d.target.position.set(0,0,-1),d.add(d.target);break;case"point":d=new c.PointLight(f),d.distance=h;break;case"spot":d=new c.SpotLight(f),d.distance=h,u.spot=u.spot||{},u.spot.innerConeAngle=u.spot.innerConeAngle!==void 0?u.spot.innerConeAngle:0,u.spot.outerConeAngle=u.spot.outerConeAngle!==void 0?u.spot.outerConeAngle:Math.PI/4,d.angle=u.spot.outerConeAngle,d.penumbra=1-u.spot.innerConeAngle/u.spot.outerConeAngle,d.target.position.set(0,0,-1),d.add(d.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+u.type)}return d.position.set(0,0,0),pe(d,u),u.intensity!==void 0&&(d.intensity=u.intensity),d.name=t.createUniqueName(u.name||"light_"+e),s=Promise.resolve(d),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],l=(i.extensions&&i.extensions[this.name]||{}).light;return l===void 0?null:this._loadLight(l).then(function(u){return n._getNodeRef(t.cache,l,u)})}}class vi{constructor(){this.name=B.KHR_MATERIALS_UNLIT}getMaterialType(){return c.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new c.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],c.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",i.baseColorTexture,c.SRGBColorSpace))}return Promise.all(s)}}class Ei{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class Ti{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(s.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const i=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new c.Vector2(i,i)}return Promise.all(s)}}class Di{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_DISPERSION}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class Ni{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(s)}}class Si{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_SHEEN}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];if(t.sheenColor=new c.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){const i=n.sheenColorFactor;t.sheenColor.setRGB(i[0],i[1],i[2],c.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,c.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(s)}}class Ri{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&s.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(s)}}class Pi{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_VOLUME}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&s.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const i=n.attenuationColor||[1,1,1];return t.attenuationColor=new c.Color().setRGB(i[0],i[1],i[2],c.LinearSRGBColorSpace),Promise.all(s)}}class Oi{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_IOR}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5,t.ior===0&&(t.ior=1e3)),Promise.resolve()}}class Li{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_SPECULAR}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));const i=n.specularColorFactor||[1,1,1];return t.specularColor=new c.Color().setRGB(i[0],i[1],i[2],c.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&s.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,c.SRGBColorSpace)),Promise.all(s)}}class ki{constructor(e){this.parser=e,this.name=B.EXT_MATERIALS_BUMP}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&s.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(s)}}class Vi{constructor(e){this.parser=e,this.name=B.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return $(this.parser,e,this.name)!==null?c.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=$(this.parser,e,this.name);if(n===null)return Promise.resolve();const s=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&s.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(s)}}class Hi{constructor(e){this.parser=e,this.name=B.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class Bi{constructor(e){this.parser=e,this.name=B.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],l=s.images[o.source];let u=n.textureLoader;if(l.uri){const d=n.options.manager.getHandler(l.uri);d!==null&&(u=d)}return n.loadTextureImage(e,o.source,u)}}class Fi{constructor(e){this.parser=e,this.name=B.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],l=s.images[o.source];let u=n.textureLoader;if(l.uri){const d=n.options.manager.getHandler(l.uri);d!==null&&(u=d)}return n.loadTextureImage(e,o.source,u)}}class rs{constructor(e,t){this.name=t,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],i=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.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 i.then(function(l){const u=s.byteOffset||0,d=s.byteLength||0,f=s.count,h=s.byteStride,g=new Uint8Array(l,u,d);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(f,h,g,s.mode,s.filter).then(function(A){return A.buffer}):o.ready.then(function(){const A=new ArrayBuffer(f*h);return o.decodeGltfBuffer(new Uint8Array(A),f,h,g,s.mode,s.filter),A})})}else return null}}class ji{constructor(e){this.name=B.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const d of s.primitives)if(d.mode!==le.TRIANGLES&&d.mode!==le.TRIANGLE_STRIP&&d.mode!==le.TRIANGLE_FAN&&d.mode!==void 0)return null;const o=n.extensions[this.name].attributes,l=[],u={};for(const d in o)l.push(this.parser.getDependency("accessor",o[d]).then(f=>(u[d]=f,u[d])));return l.length<1?null:(l.push(this.parser.createNodeMesh(e)),Promise.all(l).then(d=>{const f=d.pop(),h=f.isGroup?f.children:[f],g=d[0].count,A=[];for(const b of h){const m=new c.Matrix4,p=new c.Vector3,x=new c.Quaternion,M=new c.Vector3(1,1,1),w=new c.InstancedMesh(b.geometry,b.material,g);for(let y=0;y<g;y++)u.TRANSLATION&&p.fromBufferAttribute(u.TRANSLATION,y),u.ROTATION&&x.fromBufferAttribute(u.ROTATION,y),u.SCALE&&M.fromBufferAttribute(u.SCALE,y),w.setMatrixAt(y,m.compose(p,x,M));for(const y in u)if(y==="_COLOR_0"){const E=u[y];w.instanceColor=new c.InstancedBufferAttribute(E.array,E.itemSize,E.normalized)}else y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&b.geometry.setAttribute(y,u[y]);c.Object3D.prototype.copy.call(w,b),this.parser.assignFinalMaterial(w),A.push(w)}return f.isGroup?(f.clear(),f.add(...A),f):A[0]}))}}const vs="glTF",Ve=12,as={JSON:1313821514,BIN:5130562};class Ui{constructor(e){this.name=B.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ve),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==vs)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-Ve,i=new DataView(e,Ve);let o=0;for(;o<s;){const l=i.getUint32(o,!0);o+=4;const u=i.getUint32(o,!0);if(o+=4,u===as.JSON){const d=new Uint8Array(e,Ve+o,l);this.content=n.decode(d)}else if(u===as.BIN){const d=Ve+o;this.body=e.slice(d,d+l)}o+=l}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Gi{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=B.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,l={},u={},d={};for(const f in o){const h=It[f]||f.toLowerCase();l[h]=o[f]}for(const f in e.attributes){const h=It[f]||f.toLowerCase();if(o[f]!==void 0){const g=n.accessors[e.attributes[f]],A=Pe[g.componentType];d[h]=A.name,u[h]=g.normalized===!0}}return t.getDependency("bufferView",i).then(function(f){return new Promise(function(h,g){s.decodeDracoFile(f,function(A){for(const b in A.attributes){const m=A.attributes[b],p=u[b];p!==void 0&&(m.normalized=p)}h(A)},l,d,c.LinearSRGBColorSpace,g)})})}}class zi{constructor(){this.name=B.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}}class Wi{constructor(){this.name=B.KHR_MESH_QUANTIZATION}}class Es extends c.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let o=0;o!==s;o++)t[o]=n[i+o];return t}interpolate_(e,t,n,s){const i=this.resultBuffer,o=this.sampleValues,l=this.valueSize,u=l*2,d=l*3,f=s-t,h=(n-t)/f,g=h*h,A=g*h,b=e*d,m=b-d,p=-2*A+3*g,x=A-g,M=1-p,w=x-g+h;for(let y=0;y!==l;y++){const E=o[m+y+l],N=o[m+y+u]*f,v=o[b+y+l],O=o[b+y]*f;i[y]=M*E+w*N+p*v+x*O}return i}}const Xi=new c.Quaternion;class qi extends Es{interpolate_(e,t,n,s){const i=super.interpolate_(e,t,n,s);return Xi.fromArray(i).normalize().toArray(i),i}}const le={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Pe={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ls={9728:c.NearestFilter,9729:c.LinearFilter,9984:c.NearestMipmapNearestFilter,9985:c.LinearMipmapNearestFilter,9986:c.NearestMipmapLinearFilter,9987:c.LinearMipmapLinearFilter},cs={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},mt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},It={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"},ye={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Yi={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete},At={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ki(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new c.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:c.FrontSide})),r.DefaultMaterial}function ve(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function pe(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Zi(r,e,t){let n=!1,s=!1,i=!1;for(let d=0,f=e.length;d<f;d++){const h=e[d];if(h.POSITION!==void 0&&(n=!0),h.NORMAL!==void 0&&(s=!0),h.COLOR_0!==void 0&&(i=!0),n&&s&&i)break}if(!n&&!s&&!i)return Promise.resolve(r);const o=[],l=[],u=[];for(let d=0,f=e.length;d<f;d++){const h=e[d];if(n){const g=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):r.attributes.position;o.push(g)}if(s){const g=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):r.attributes.normal;l.push(g)}if(i){const g=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):r.attributes.color;u.push(g)}}return Promise.all([Promise.all(o),Promise.all(l),Promise.all(u)]).then(function(d){const f=d[0],h=d[1],g=d[2];return n&&(r.morphAttributes.position=f),s&&(r.morphAttributes.normal=h),i&&(r.morphAttributes.color=g),r.morphTargetsRelative=!0,r})}function Qi(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)r.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Ji(r){let e;const t=r.extensions&&r.extensions[B.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+gt(t.attributes):e=r.indices+":"+gt(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,s=r.targets.length;n<s;n++)e+=":"+gt(r.targets[n]);return e}function gt(r){let e="";const t=Object.keys(r).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+r[t[n]]+";";return e}function Ct(r){switch(r){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 _i(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const $i=new c.Matrix4;class eo{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Mi,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 n=!1,s=-1,i=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const l=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(l)===!0;const u=l.match(/Version\/(\d+)/);s=n&&u?parseInt(u[1],10):-1,i=l.indexOf("Firefox")>-1,o=i?l.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||i&&o<98?this.textureLoader=new c.TextureLoader(this.options.manager):this.textureLoader=new c.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new c.FileLoader(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){const n=this,s=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const l={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return ve(i,l,s),pe(l,s),Promise.all(n._invokeAll(function(u){return u.afterRoot&&u.afterRoot(l)})).then(function(){for(const u of l.scenes)u.updateMatrixWorld();e(l)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,i=t.length;s<i;s++){const o=t[s].joints;for(let l=0,u=o.length;l<u;l++)e[o[l]].isBone=!0}for(let s=0,i=e.length;s<i;s++){const o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.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,n){if(e.refs[t]<=1)return n;const s=n.clone(),i=(o,l)=>{const u=this.associations.get(o);u!=null&&this.associations.set(l,u);for(const[d,f]of o.children.entries())i(f,l.children[d])};return i(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const i=e(t[s]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":s=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(i,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=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[B.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(i,o){n.load(c.LoaderUtils.resolveURL(t.uri,s.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,i=t.byteOffset||0;return n.slice(i,i+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const o=mt[s.type],l=Pe[s.componentType],u=s.normalized===!0,d=new l(s.count*o);return Promise.resolve(new c.BufferAttribute(d,o,u))}const i=[];return s.bufferView!==void 0?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),s.sparse!==void 0&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then(function(o){const l=o[0],u=mt[s.type],d=Pe[s.componentType],f=d.BYTES_PER_ELEMENT,h=f*u,g=s.byteOffset||0,A=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,b=s.normalized===!0;let m,p;if(A&&A!==h){const x=Math.floor(g/A),M="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+x+":"+s.count;let w=t.cache.get(M);w||(m=new d(l,x*A,s.count*A/f),w=new c.InterleavedBuffer(m,A/f),t.cache.add(M,w)),p=new c.InterleavedBufferAttribute(w,u,g%A/f,b)}else l===null?m=new d(s.count*u):m=new d(l,g,s.count*u),p=new c.BufferAttribute(m,u,b);if(s.sparse!==void 0){const x=mt.SCALAR,M=Pe[s.sparse.indices.componentType],w=s.sparse.indices.byteOffset||0,y=s.sparse.values.byteOffset||0,E=new M(o[1],w,s.sparse.count*x),N=new d(o[2],y,s.sparse.count*u);l!==null&&(p=new c.BufferAttribute(p.array.slice(),p.itemSize,p.normalized)),p.normalized=!1;for(let v=0,O=E.length;v<O;v++){const J=E[v];if(p.setX(J,N[v*u]),u>=2&&p.setY(J,N[v*u+1]),u>=3&&p.setZ(J,N[v*u+2]),u>=4&&p.setW(J,N[v*u+3]),u>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}p.normalized=b}return p})}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,o=t.images[i];let l=this.textureLoader;if(o.uri){const u=n.manager.getHandler(o.uri);u!==null&&(l=u)}return this.loadTextureImage(e,i,l)}loadTextureImage(e,t,n){const s=this,i=this.json,o=i.textures[e],l=i.images[t],u=(l.uri||l.bufferView)+":"+o.sampler;if(this.textureCache[u])return this.textureCache[u];const d=this.loadImageSource(t,n).then(function(f){f.flipY=!1,f.name=o.name||l.name||"",f.name===""&&typeof l.uri=="string"&&l.uri.startsWith("data:image/")===!1&&(f.name=l.uri);const g=(i.samplers||{})[o.sampler]||{};return f.magFilter=ls[g.magFilter]||c.LinearFilter,f.minFilter=ls[g.minFilter]||c.LinearMipmapLinearFilter,f.wrapS=cs[g.wrapS]||c.RepeatWrapping,f.wrapT=cs[g.wrapT]||c.RepeatWrapping,f.generateMipmaps=!f.isCompressedTexture&&f.minFilter!==c.NearestFilter&&f.minFilter!==c.LinearFilter,s.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[u]=d,d}loadImageSource(e,t){const n=this,s=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const o=s.images[e],l=self.URL||self.webkitURL;let u=o.uri||"",d=!1;if(o.bufferView!==void 0)u=n.getDependency("bufferView",o.bufferView).then(function(h){d=!0;const g=new Blob([h],{type:o.mimeType});return u=l.createObjectURL(g),u});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(u).then(function(h){return new Promise(function(g,A){let b=g;t.isImageBitmapLoader===!0&&(b=function(m){const p=new c.Texture(m);p.needsUpdate=!0,g(p)}),t.load(c.LoaderUtils.resolveURL(h,i.path),b,void 0,A)})}).then(function(h){return d===!0&&l.revokeObjectURL(u),pe(h,o),h.userData.mimeType=o.mimeType||_i(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",u),h});return this.sourceCache[e]=f,f}assignTexture(e,t,n,s){const i=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),i.extensions[B.KHR_TEXTURE_TRANSFORM]){const l=n.extensions!==void 0?n.extensions[B.KHR_TEXTURE_TRANSFORM]:void 0;if(l){const u=i.associations.get(o);o=i.extensions[B.KHR_TEXTURE_TRANSFORM].extendTexture(o,l),i.associations.set(o,u)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const l="PointsMaterial:"+n.uuid;let u=this.cache.get(l);u||(u=new c.PointsMaterial,c.Material.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,u.sizeAttenuation=!1,this.cache.add(l,u)),n=u}else if(e.isLine){const l="LineBasicMaterial:"+n.uuid;let u=this.cache.get(l);u||(u=new c.LineBasicMaterial,c.Material.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,this.cache.add(l,u)),n=u}if(s||i||o){let l="ClonedMaterial:"+n.uuid+":";s&&(l+="derivative-tangents:"),i&&(l+="vertex-colors:"),o&&(l+="flat-shading:");let u=this.cache.get(l);u||(u=n.clone(),i&&(u.vertexColors=!0),o&&(u.flatShading=!0),s&&(u.normalScale&&(u.normalScale.y*=-1),u.clearcoatNormalScale&&(u.clearcoatNormalScale.y*=-1)),this.cache.add(l,u),this.associations.set(u,this.associations.get(n))),n=u}e.material=n}getMaterialType(){return c.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,i=n.materials[e];let o;const l={},u=i.extensions||{},d=[];if(u[B.KHR_MATERIALS_UNLIT]){const h=s[B.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),d.push(h.extendParams(l,i,t))}else{const h=i.pbrMetallicRoughness||{};if(l.color=new c.Color(1,1,1),l.opacity=1,Array.isArray(h.baseColorFactor)){const g=h.baseColorFactor;l.color.setRGB(g[0],g[1],g[2],c.LinearSRGBColorSpace),l.opacity=g[3]}h.baseColorTexture!==void 0&&d.push(t.assignTexture(l,"map",h.baseColorTexture,c.SRGBColorSpace)),l.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,l.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(d.push(t.assignTexture(l,"metalnessMap",h.metallicRoughnessTexture)),d.push(t.assignTexture(l,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),d.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,l)})))}i.doubleSided===!0&&(l.side=c.DoubleSide);const f=i.alphaMode||At.OPAQUE;if(f===At.BLEND?(l.transparent=!0,l.depthWrite=!1):(l.transparent=!1,f===At.MASK&&(l.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==c.MeshBasicMaterial&&(d.push(t.assignTexture(l,"normalMap",i.normalTexture)),l.normalScale=new c.Vector2(1,1),i.normalTexture.scale!==void 0)){const h=i.normalTexture.scale;l.normalScale.set(h,h)}if(i.occlusionTexture!==void 0&&o!==c.MeshBasicMaterial&&(d.push(t.assignTexture(l,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(l.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==c.MeshBasicMaterial){const h=i.emissiveFactor;l.emissive=new c.Color().setRGB(h[0],h[1],h[2],c.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==c.MeshBasicMaterial&&d.push(t.assignTexture(l,"emissiveMap",i.emissiveTexture,c.SRGBColorSpace)),Promise.all(d).then(function(){const h=new o(l);return i.name&&(h.name=i.name),pe(h,i),t.associations.set(h,{materials:e}),i.extensions&&ve(s,h,i),h})}createUniqueName(e){const t=c.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function i(l){return n[B.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(l,t).then(function(u){return us(u,l,t)})}const o=[];for(let l=0,u=e.length;l<u;l++){const d=e[l],f=Ji(d),h=s[f];if(h)o.push(h.promise);else{let g;d.extensions&&d.extensions[B.KHR_DRACO_MESH_COMPRESSION]?g=i(d):g=us(new c.BufferGeometry,d,t),s[f]={primitive:d,promise:g},o.push(g)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,s=this.extensions,i=n.meshes[e],o=i.primitives,l=[];for(let u=0,d=o.length;u<d;u++){const f=o[u].material===void 0?Ki(this.cache):this.getDependency("material",o[u].material);l.push(f)}return l.push(t.loadGeometries(o)),Promise.all(l).then(function(u){const d=u.slice(0,u.length-1),f=u[u.length-1],h=[];for(let A=0,b=f.length;A<b;A++){const m=f[A],p=o[A];let x;const M=d[A];if(p.mode===le.TRIANGLES||p.mode===le.TRIANGLE_STRIP||p.mode===le.TRIANGLE_FAN||p.mode===void 0)x=i.isSkinnedMesh===!0?new c.SkinnedMesh(m,M):new c.Mesh(m,M),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),p.mode===le.TRIANGLE_STRIP?x.geometry=os(x.geometry,c.TriangleStripDrawMode):p.mode===le.TRIANGLE_FAN&&(x.geometry=os(x.geometry,c.TriangleFanDrawMode));else if(p.mode===le.LINES)x=new c.LineSegments(m,M);else if(p.mode===le.LINE_STRIP)x=new c.Line(m,M);else if(p.mode===le.LINE_LOOP)x=new c.LineLoop(m,M);else if(p.mode===le.POINTS)x=new c.Points(m,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+p.mode);Object.keys(x.geometry.morphAttributes).length>0&&Qi(x,i),x.name=t.createUniqueName(i.name||"mesh_"+e),pe(x,i),p.extensions&&ve(s,x,p),t.assignFinalMaterial(x),h.push(x)}for(let A=0,b=h.length;A<b;A++)t.associations.set(h[A],{meshes:e,primitives:A});if(h.length===1)return i.extensions&&ve(s,h[0],i),h[0];const g=new c.Group;i.extensions&&ve(s,g,i),t.associations.set(g,{meshes:e});for(let A=0,b=h.length;A<b;A++)g.add(h[A]);return g})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new c.PerspectiveCamera(c.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new c.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),pe(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,i=t.joints.length;s<i;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const i=s.pop(),o=s,l=[],u=[];for(let d=0,f=o.length;d<f;d++){const h=o[d];if(h){l.push(h);const g=new c.Matrix4;i!==null&&g.fromArray(i.array,d*16),u.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[d])}return new c.Skeleton(l,u)})}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,o=[],l=[],u=[],d=[],f=[];for(let h=0,g=s.channels.length;h<g;h++){const A=s.channels[h],b=s.samplers[A.sampler],m=A.target,p=m.node,x=s.parameters!==void 0?s.parameters[b.input]:b.input,M=s.parameters!==void 0?s.parameters[b.output]:b.output;m.node!==void 0&&(o.push(this.getDependency("node",p)),l.push(this.getDependency("accessor",x)),u.push(this.getDependency("accessor",M)),d.push(b),f.push(m))}return Promise.all([Promise.all(o),Promise.all(l),Promise.all(u),Promise.all(d),Promise.all(f)]).then(function(h){const g=h[0],A=h[1],b=h[2],m=h[3],p=h[4],x=[];for(let w=0,y=g.length;w<y;w++){const E=g[w],N=A[w],v=b[w],O=m[w],J=p[w];if(E===void 0)continue;E.updateMatrix&&E.updateMatrix();const L=n._createAnimationTracks(E,N,v,O,J);if(L)for(let X=0;X<L.length;X++)x.push(L[X])}const M=new c.AnimationClip(i,void 0,x);return pe(M,s),M})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(i){const o=n._getNodeRef(n.meshCache,s.mesh,i);return s.weights!==void 0&&o.traverse(function(l){if(l.isMesh)for(let u=0,d=s.weights.length;u<d;u++)l.morphTargetInfluences[u]=s.weights[u]}),o})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],i=n._loadNodeShallow(e),o=[],l=s.children||[];for(let d=0,f=l.length;d<f;d++)o.push(n.getDependency("node",l[d]));const u=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([i,Promise.all(o),u]).then(function(d){const f=d[0],h=d[1],g=d[2];g!==null&&f.traverse(function(A){A.isSkinnedMesh&&A.bind(g,$i)});for(let A=0,b=h.length;A<b;A++)f.add(h[A]);if(f.userData.pivot!==void 0&&h.length>0){const A=f.userData.pivot,b=h[0];f.pivot=new c.Vector3().fromArray(A),f.position.x-=A[0],f.position.y-=A[1],f.position.z-=A[2],b.position.set(0,0,0),delete f.userData.pivot}return f})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?s.createUniqueName(i.name):"",l=[],u=s._invokeOne(function(d){return d.createNodeMesh&&d.createNodeMesh(e)});return u&&l.push(u),i.camera!==void 0&&l.push(s.getDependency("camera",i.camera).then(function(d){return s._getNodeRef(s.cameraCache,i.camera,d)})),s._invokeAll(function(d){return d.createNodeAttachment&&d.createNodeAttachment(e)}).forEach(function(d){l.push(d)}),this.nodeCache[e]=Promise.all(l).then(function(d){let f;if(i.isBone===!0?f=new c.Bone:d.length>1?f=new c.Group:d.length===1?f=d[0]:f=new c.Object3D,f!==d[0])for(let h=0,g=d.length;h<g;h++)f.add(d[h]);if(i.name&&(f.userData.name=i.name,f.name=o),pe(f,i),i.extensions&&ve(n,f,i),i.matrix!==void 0){const h=new c.Matrix4;h.fromArray(i.matrix),f.applyMatrix4(h)}else i.translation!==void 0&&f.position.fromArray(i.translation),i.rotation!==void 0&&f.quaternion.fromArray(i.rotation),i.scale!==void 0&&f.scale.fromArray(i.scale);if(!s.associations.has(f))s.associations.set(f,{});else if(i.mesh!==void 0&&s.meshCache.refs[i.mesh]>1){const h=s.associations.get(f);s.associations.set(f,{...h})}return s.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,i=new c.Group;n.name&&(i.name=s.createUniqueName(n.name)),pe(i,n),n.extensions&&ve(t,i,n);const o=n.nodes||[],l=[];for(let u=0,d=o.length;u<d;u++)l.push(s.getDependency("node",o[u]));return Promise.all(l).then(function(u){for(let f=0,h=u.length;f<h;f++){const g=u[f];g.parent!==null?i.add(Ci(g)):i.add(g)}const d=f=>{const h=new Map;for(const[g,A]of s.associations)(g instanceof c.Material||g instanceof c.Texture)&&h.set(g,A);return f.traverse(g=>{const A=s.associations.get(g);A!=null&&h.set(g,A)}),h};return s.associations=d(i),i})}_createAnimationTracks(e,t,n,s,i){const o=[],l=e.name?e.name:e.uuid,u=[];function d(A){A.morphTargetInfluences&&u.push(A.name?A.name:A.uuid)}ye[i.path]===ye.weights?(d(e),e.isGroup&&e.children.forEach(d)):u.push(l);let f;switch(ye[i.path]){case ye.weights:f=c.NumberKeyframeTrack;break;case ye.rotation:f=c.QuaternionKeyframeTrack;break;case ye.translation:case ye.scale:f=c.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:f=c.NumberKeyframeTrack;break;case 2:case 3:default:f=c.VectorKeyframeTrack;break}break}const h=s.interpolation!==void 0?Yi[s.interpolation]:c.InterpolateLinear,g=this._getArrayFromAccessor(n);for(let A=0,b=u.length;A<b;A++){const m=new f(u[A]+"."+ye[i.path],t.array,g,h);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Ct(t.constructor),s=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)s[i]=t[i]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const s=this instanceof c.QuaternionKeyframeTrack?qi:Es;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function to(r,e,t){const n=e.attributes,s=new c.Box3;if(n.POSITION!==void 0){const l=t.json.accessors[n.POSITION],u=l.min,d=l.max;if(u!==void 0&&d!==void 0){if(s.set(new c.Vector3(u[0],u[1],u[2]),new c.Vector3(d[0],d[1],d[2])),l.normalized){const f=Ct(Pe[l.componentType]);s.min.multiplyScalar(f),s.max.multiplyScalar(f)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const l=new c.Vector3,u=new c.Vector3;for(let d=0,f=i.length;d<f;d++){const h=i[d];if(h.POSITION!==void 0){const g=t.json.accessors[h.POSITION],A=g.min,b=g.max;if(A!==void 0&&b!==void 0){if(u.setX(Math.max(Math.abs(A[0]),Math.abs(b[0]))),u.setY(Math.max(Math.abs(A[1]),Math.abs(b[1]))),u.setZ(Math.max(Math.abs(A[2]),Math.abs(b[2]))),g.normalized){const m=Ct(Pe[g.componentType]);u.multiplyScalar(m)}l.max(u)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(l)}r.boundingBox=s;const o=new c.Sphere;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,r.boundingSphere=o}function us(r,e,t){const n=e.attributes,s=[];function i(o,l){return t.getDependency("accessor",o).then(function(u){r.setAttribute(l,u)})}for(const o in n){const l=It[o]||o.toLowerCase();l in r.attributes||s.push(i(n[o],l))}if(e.indices!==void 0&&!r.index){const o=t.getDependency("accessor",e.indices).then(function(l){r.setIndex(l)});s.push(o)}return c.ColorManagement.workingColorSpace!==c.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${c.ColorManagement.workingColorSpace}" not supported.`),pe(r,e),to(r,e,t),Promise.all(s).then(function(){return e.targets!==void 0?Zi(r,e.targets,t):r})}const C={mode:"",transformControlsMode:"translate",scene:null,camera:null,defaultMainCamera:null,renderer:null,orbitControls:null,transformControls:null,container:null,gridHelper:null,selectedObject:null};let tt=!1,De=!1,be=null;const so=16755200;let Mt=[],_e=[],We=!0,Te=null,wt=null,st=null,xe=[];const Ne=new Map;let rt,nt=null,je=null,Ue=null;async function Ts(r,e="edit",t){C.container=r,C.mode=e,io(),ro(),lo(),t&&(await Xs(t.scene,e,t.dataPanels,t.waters,t.textures,t.ambientLight),t!=null&&t.camera&&(C.defaultMainCamera=t.camera,Tt(!0))),uo(),co(),rt&&C.orbitControls&&(C.orbitControls.target.fromArray(rt),C.orbitControls.update()),oo(),Hs(),Ns(),je=n=>po(n),Ue=()=>fo(),e==="edit"&&r.addEventListener("click",je),window.addEventListener("resize",Ue),t||ho(),e==="edit"&&ao()}function no(){return window.devicePixelRatio}function io(){const r=no(),e=new S.WebGLRenderer({antialias:!0,alpha:!0});e.setSize(C.container.clientWidth,C.container.clientHeight),e.setPixelRatio(r),e.toneMapping=S.NeutralToneMapping,e.toneMappingExposure=1,console.log(`[Renderer] css=${C.container.clientWidth}×${C.container.clientHeight}, dpr=${window.devicePixelRatio}, targetRatio=${r}, antialias=true`),C.container.appendChild(e.domElement),C.renderer=e}function oo(){if(!C.renderer||!C.scene||!C.camera)return;const r=C.renderer.getPixelRatio(),e=C.container.clientWidth*r,t=C.container.clientHeight*r,n=new S.WebGLRenderTarget(e,t,{type:S.HalfFloatType,samples:4});n.texture.name="EffectComposer.rt1";const s=new Hn(C.renderer,n);s.addPass(new Bn(C.scene,C.camera)),s.addPass(new Fn),be=s}function ro(){if(C.scene=new S.Scene,C.scene.name="sl_scene",C.renderer){const r=xt(C.renderer);r&&(C.scene.environment=r,C.scene.environmentIntensity=1)}}function ao(){const r=new S.GridHelper(30,30,8956671,3364232);r.name="地板",r.userData.type="initFloor",C.scene.add(r),C.gridHelper=r}function lo(){const r=C.container,e=r.clientWidth/r.clientHeight,t=new S.PerspectiveCamera(45,e,.1,1e3);t.position.set(0,6,15),t.lookAt(0,0,0),C.camera=t}function Tt(r=!1){if(!C.defaultMainCamera)return;const e=C.defaultMainCamera;if(r){C.camera.position.set(e.position[0],e.position[1],e.position[2]),C.camera.rotation.set(e.rotation[0],e.rotation[1],e.rotation[2]),C.camera.updateProjectionMatrix(),rt=e.target;return}else Nt(""),at();if(!C.camera||!C.orbitControls)return;const t=C.camera.position.clone(),n=C.orbitControls.target.clone(),s=new S.Vector3(e.position[0],e.position[1],e.position[2]),i=e.target?new S.Vector3(e.target[0],e.target[1],e.target[2]):new S.Vector3(0,0,0);C.orbitControls.enabled=!1,new Ge.Tween({x:t.x,y:t.y,z:t.z,tx:n.x,ty:n.y,tz:n.z}).to({x:s.x,y:s.y,z:s.z,tx:i.x,ty:i.y,tz:i.z},1e3).easing(Ge.Easing.Quadratic.InOut).onUpdate(o=>{C.camera.position.set(o.x,o.y,o.z),C.orbitControls.target.set(o.tx,o.ty,o.tz),C.orbitControls.update()}).onComplete(()=>{rt=e.target,C.orbitControls.enabled=!0}).start()}function co(){const r=new cn(C.camera,C.renderer.domElement);r.minDistance=0,r.maxDistance=1/0,r.addEventListener("start",()=>{tt=!1}),r.addEventListener("change",()=>{tt=!0}),r.addEventListener("end",()=>{tt&&(De=!0,setTimeout(()=>{De=!1},200))}),C.orbitControls=r}function uo(){const r=new Cn(C.camera,C.renderer.domElement);r.addEventListener("dragging-changed",e=>{C.orbitControls.enabled=!e.value,e.value||(De=!0,setTimeout(()=>{De=!1},200))}),r.addEventListener("objectChange",()=>{const e=C.selectedObject;if(wt&&e&&wt(e),e&&e.type==="DirectionalLight"){const t=e.userData.helper;t&&t.update&&t.update()}}),C.scene.add(r.getHelper()),C.transformControls=r}function Ds(r=C.scene){if(!r||r.children.some(t=>t.type==="AmbientLight"))return null;const e=new S.AmbientLight(wo,vo);return e.name="环境光",r.add(e),e}function ho(){Ds(C.scene)}function Ns(){var e,t;nt=requestAnimationFrame(Ns),Ge.update(),(e=C.orbitControls)==null||e.update(),C.mode==="run"&&be&&C.scene&&C.camera?be.render():(t=C.renderer)==null||t.render(C.scene,C.camera),C.scene&&C.camera&&bs(C.scene,C.camera),We&&C.scene&&(_e=[],C.scene.traverse(n=>{n.userData.isWater&&n.type==="Mesh"&&_e.push(n)}),We=!1);for(let n=0;n<_e.length;n++){const s=_e[n],i=s.material;if(i.uniforms&&i.uniforms.time){const o=s.userData.waterTimeScale??1;i.uniforms.time.value+=1/60*o,C.camera&&i.uniforms.eye&&i.uniforms.eye.value.copy(C.camera.position);continue}if(i.normalMap){const o=s.userData.waterSpeed||{x:.005,y:.003};i.normalMap.offset.x+=o.x,i.normalMap.offset.y+=o.y}}}function fo(){if(!C.container||!C.camera||!C.renderer)return;const r=C.container.clientWidth,e=C.container.clientHeight;r===0||e===0||(C.camera.aspect=r/e,C.camera.updateProjectionMatrix(),C.renderer.setSize(r,e),be&&be.setSize(r,e),xs(r,e))}function lt(r){C.selectedObject!==r&&(C.selectedObject&&C.transformControls.detach(),C.selectedObject=r,C.transformControls.attach(r),C.transformControls.setMode(C.transformControlsMode),C.transformControls.showX=!0,C.transformControls.showY=!0,C.transformControls.showZ=!0,Ps(r),Te==null||Te(r))}let oe=null;function Ss(r){oe=r}function it(r){oe==null||oe(r)}function Rs(r){C.transformControlsMode=r,C.transformControls&&C.transformControls.setMode(C.transformControlsMode)}function Ps(r){if(C.mode!=="edit"){at();return}at(),r.traverse(e=>{if(e.isMesh){const t=e,n=new S.EdgesGeometry(t.geometry),s=new S.LineBasicMaterial({color:so,depthTest:!0}),i=new S.LineSegments(n,s);e.add(i),Mt.push(i)}})}function at(){for(const r of Mt)r.parent&&r.parent.remove(r),r.geometry.dispose(),r.material.dispose();Mt=[]}function Dt(){C.selectedObject&&(at(),C.transformControls.detach(),C.selectedObject=null,Te==null||Te(null))}function Nt(r){let e=null;Ne.forEach(t=>{t.userData.id==r&&(e=t),t.children&&t.children.forEach(n=>{n.name&&n.name.startsWith("DataPanel_")&&(n.visible=!1)})}),e&&(e.children.forEach(t=>{t.name&&t.name.startsWith("DataPanel_")&&(t.visible=!0)}),Ps(e),C.selectedObject=e,setTimeout(()=>{Os(e)},500))}function po(r){if(De){De=!1;return}const e=C.renderer.domElement.getBoundingClientRect(),t=new S.Vector2((r.clientX-e.left)/e.width*2-1,-((r.clientY-e.top)/e.height)*2+1),n=new S.Raycaster;n.setFromCamera(t,C.camera);const s=[];C.scene.traverse(o=>{(o.userData.isMovable||o.userData.type==="lightHelper")&&s.push(o)});const i=n.intersectObjects(s);if(i.length>0){let o=mo(i[0].object);lt(o)}else Dt()}function mo(r){var t,n;let e=r;for(;e;){if(((t=e.userData)==null?void 0:t.type)==="lightHelper"||e.type==="DirectionalLightHelper")return e.light||e;if(((n=e.userData)==null?void 0:n.type)==="AmbientLightHelper")return e.parent&&e.parent.type==="AmbientLight"?e.parent:e;e=e.parent}if(r.type==="Line"||r.type==="LineSegments"){const s=r.parent;if(s)switch(s.type){case"DirectionalLightHelper":return s.light;case"AmbientLight":return s;default:return s.isMesh?s:r}return r}return r}function Os(r,e=500){if(!C.camera||!C.orbitControls){console.warn("[focusOnObject] 编辑器尚未初始化或已销毁,无法执行聚焦操作。请确保已调用 initEditor()");return}if(!r){console.warn("[focusOnObject] 传入的物体为空,无法执行聚焦操作。");return}let t=null;r.userData.closeUpView&&typeof r.userData.closeUpView.x=="number"&&typeof r.userData.closeUpView.y=="number"&&typeof r.userData.closeUpView.z=="number"&&(t=r.userData.closeUpView);const n=new S.Vector3;r.getWorldPosition(n);const i=new S.Box3().setFromObject(r).getSize(new S.Vector3),o=Math.max(i.x,i.y,i.z)*.5,l=Math.max(o*3.5,5),u=new S.Vector3().copy(C.camera.position).sub(n).normalize();u.lengthSq()<.001&&u.set(0,0,1);const d=n.clone().add(u.multiplyScalar(l)),f=C.camera.position.clone(),h=C.orbitControls.target.clone();try{new Ge.Tween({x:f.x,y:f.y,z:f.z,tx:h.x,ty:h.y,tz:h.z}).to({x:t?t.x:d.x,y:t?t.y:d.y,z:t?t.z:d.z,tx:n.x,ty:n.y,tz:n.z},e).easing(Ge.Easing.Quadratic.InOut).onUpdate(g=>{C.camera.position.set(g.x,g.y,g.z),C.orbitControls.target.set(g.tx,g.ty,g.tz),C.orbitControls.update()}).start()}catch(g){console.error("[focusOnObject] TWEEN 动画创建失败,请检查 @tweenjs/tween.js 是否已正确安装且版本兼容(^23.1.3):",g)}}function Ao(r){r.userData.id&&Ne.set(String(r.userData.id),r)}function go(r){r.userData.id&&Ne.delete(String(r.userData.id))}function Ls(r,e){const t=e||r.userData.id;if(t)Ne.set(String(t),r);else{const n=S.MathUtils.generateUUID();r.userData.id=n,Ne.set(n,r)}}function yo(r){r.traverse(e=>{if(e.name&&e.name.startsWith("DataPanel_")){const t=e;t.element&&t.element.parentNode&&t.element.parentNode.removeChild(t.element)}})}function Ie(r,e=!1){C.scene.add(r),We=!0,r.userData.isMovable&&(bo(r),ct()),e&&C.mode==="edit"&&lt(r)}function ks(r){C.selectedObject===r&&Dt(),We=!0,yo(r),go(r),r.userData.helper&&C.scene.remove(r.userData.helper),r.parent?r.parent.remove(r):C.scene.remove(r),xo(r),ct()}function Vs(r){const e=C.scene.getObjectByProperty("uuid",r);e&&ks(e)}function bo(r){r.userData.isMovable&&r.parent===C.scene&&(xe.includes(r)||xe.push(r))}function xo(r){const e=xe.indexOf(r);e!==-1&&xe.splice(e,1)}function Hs(){const r=[];C.scene.children.forEach(e=>{e.userData.isMovable&&r.push(e)}),xe=r,ct()}function ct(){st==null||st([...xe])}function Bs(r){Te=r}function Fs(r){wt=r}function js(r){st=r}function Us(){return xe}function Gs(){return C.selectedObject}function Io(r,e,t){if(!C.scene)return;const n=Ne.get(r);if(n){const s=Oe(n);s&&s.updateItemByCode(e,t)}}function Co(){return C.scene}function zs(){return C.camera}function Mo(){return C.renderer}const wo=16777215,vo=1;async function Ws(){var w,y,E,N;oe==null||oe(!0),await new Promise(v=>setTimeout(v,50)),Dt();const r=C.scene;if(!r)return oe==null||oe(!1),{scene:new ArrayBuffer(0),camera:{position:void 0,rotation:void 0,target:[0,0,0]},dataPanels:{},waters:[],textures:{},ambientLight:null};const e=[],t=new Map,n=new Map,s={},i=[],o=[];let l=null;const u=[];r.traverse(v=>{var O,J;if(v.userData._sourceUuid=v.uuid,v.type==="AmbientLight"){const L=v;l={color:"#"+L.color.getHexString(),intensity:L.intensity,name:L.name||"环境光",visible:L.visible,position:L.position.toArray(),hasHelper:!!L.userData.helper},u.push(L)}if(v.userData.type==="lightHelper"&&e.push(v),v.type==="DirectionalLight"&&v.userData.helper&&(t.set(v,v.userData.helper),v.userData.helper=void 0),v.userData.isWater&&v.type==="Mesh"&&v.parent){const L=v,X=L.material;let G="#4fc3f7";X.uniforms&&X.uniforms.waterColor&&(G="#"+X.uniforms.waterColor.value.getHexString());const z=L.geometry,V={uuid:v.uuid,name:v.name,position:v.position.toArray(),rotation:[v.rotation.x,v.rotation.y,v.rotation.z],scale:v.scale.toArray(),color:G,timeScale:v.userData.waterTimeScale??.05,geometryType:"box",boxWidth:void 0,boxDepth:void 0,cylinderRadiusTop:void 0,cylinderRadiusBottom:void 0,cylinderRadialSegments:void 0};z.parameters&&z.parameters.radiusTop!==void 0?(V.geometryType="cylinder",V.cylinderRadiusTop=z.parameters.radiusTop,V.cylinderRadiusBottom=z.parameters.radiusBottom,V.cylinderRadialSegments=z.parameters.radialSegments):(V.geometryType="box",V.boxWidth=z.parameters.width,V.boxDepth=z.parameters.depth),i.push(V),o.push(v)}if(v.name&&v.name.startsWith("DataPanel_")){const L=v;if(L.element){const X=L.element.querySelector("[data-panel-title]"),G=[];if(L.element.querySelectorAll(".sl-css2d-data-panel-item").forEach(V=>{var K,te,q;const P=V.querySelector(".item-label"),W=V.querySelector(".item-value");if(P&&W){const ue=(P.textContent||"").trim(),de=((te=(K=W.childNodes[0])==null?void 0:K.textContent)==null?void 0:te.trim())||"",ce=W.querySelector("span"),Ae=ce?(ce.textContent||"").trim():void 0,he=((q=V.getAttribute("data-item-code"))==null?void 0:q.trim())||void 0;G.push({label:ue,value:de,unit:Ae,code:he})}}),v.parent){const V=L.element.style.width||"",P=L.element.style.fontSize||"",W=Oe(v.parent),K=W?W.getOffsetY():.1;n.set(v.parent.userData.id?v.parent.userData.id:v.parent.uuid,{title:((O=X==null?void 0:X.textContent)==null?void 0:O.trim())||"",items:G,width:V,fontSize:P,offsetY:K,offsetX:W?W.getOffsetX():0,offsetZ:W?W.getOffsetZ():0})}}}if(v.type==="Mesh"){const L=v,X=Array.isArray(L.material)?L.material:[L.material];for(const G of X)if(G&&G.userData){const z=G.userData;if(z._mapDataUrl||z._normalMapDataUrl||z._aoMapDataUrl){const V=G.uuid,P=s[V]||{};z._mapDataUrl&&(P.mapDataUrl=z._mapDataUrl,P.mapFileName=z._mapFileName),z._normalMapDataUrl&&(P.normalMapDataUrl=z._normalMapDataUrl,P.normalMapFileName=z._normalMapFileName,P.normalScale=((J=G.normalScale)==null?void 0:J.x)??1),z._aoMapDataUrl&&(P.aoMapDataUrl=z._aoMapDataUrl,P.aoMapFileName=z._aoMapFileName,P.aoMapIntensity=G.aoMapIntensity??1),s[V]=P}}}}),e.forEach(v=>r.remove(v));const d=(w=C.transformControls)==null?void 0:w.getHelper(),f=(d==null?void 0:d.parent)??null;d&&d.parent&&d.parent.remove(d);const h=new Map;for(const v of u)h.set(v,v.parent),v.parent&&v.parent.remove(v);const g=new Map;for(const v of o)g.set(v,v.parent),v.parent&&v.parent.remove(v);const A=r.clone();A.children=A.children.filter(v=>v.userData.type!=="initFloor"),A.traverse(v=>{v.name&&v.name.startsWith("DataPanel_")&&v.parent&&v.parent.remove(v)});const m=await new Fe().parseAsync(A,{binary:!0,onlyVisible:!1,embedImages:!0});e.forEach(v=>r.add(v));for(const v of u){const O=h.get(v);O?O.add(v):r.add(v)}for(const v of o){const O=g.get(v);O?O.add(v):r.add(v)}t.forEach((v,O)=>{O.userData.helper=v}),r.traverse(v=>{delete v.userData._sourceUuid}),d&&(f?f.add(d):r.add(d));const p={position:(y=C.camera)==null?void 0:y.position.toArray(),rotation:(E=C.camera)==null?void 0:E.rotation.toArray(),target:((N=C.orbitControls)==null?void 0:N.target.toArray())||[0,0,0]},x={};n.forEach((v,O)=>{x[O]=v});const M={scene:m,camera:p,dataPanels:x,waters:i,textures:s,ambientLight:l};return oe==null||oe(!1),M}function Eo(r){if(r instanceof ArrayBuffer||ArrayBuffer.isView(r)){if(r instanceof ArrayBuffer)return r;const e=r;return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(typeof r=="string"){const e=r.trim();let t=e;if(e.startsWith("data:")){const n=e.indexOf(",");if(n===-1)return null;t=e.slice(n+1)}if(/^Z2xURg/.test(t)){const n=atob(t),s=new Uint8Array(n.length);for(let i=0;i<n.length;i++)s[i]=n.charCodeAt(i);return s.buffer}return null}return r&&typeof r=="object"&&r.type==="Buffer"&&Array.isArray(r.data)?new Uint8Array(r.data).buffer:null}function To(r,e=.5){const t=new S.EdgesGeometry(new S.SphereGeometry(e,12,8)),n=new S.LineBasicMaterial({color:r.color,transparent:!0,opacity:.6}),s=new S.LineSegments(t,n);return s.userData.type="AmbientLightHelper",s}async function Xs(r,e="edit",t,n,s,i){var l,u,d,f,h,g,A;const o=Eo(r);if(o){const b=await new ws().parseAsync(o,""),m=b.scene||((l=b.scenes)==null?void 0:l[0]),p=(u=C.scene)==null?void 0:u.environment;if(C.scene=m,!m.children.some(x=>x.type==="AmbientLight"))if(i){const x=new S.AmbientLight(i.color,i.intensity);if(x.name=i.name||"环境光",x.visible=i.visible??!0,x.userData.isMovable=!0,i.position&&x.position.fromArray(i.position),e==="edit"&&i.hasHelper){const M=To(x,.5);x.userData.helper=M,x.add(M)}m.add(x)}else Ds(m);if(p)C.scene.environment=p,C.scene.environmentIntensity=1;else if(C.renderer){const x=xt(C.renderer);x&&(C.scene.environment=x,C.scene.environmentIntensity=1)}}else{const b=typeof r=="string"?JSON.parse(r):r,p=new S.ObjectLoader().parse(b);if(p.type==="Scene"){const x=(d=C.scene)==null?void 0:d.environment;if(C.scene=p,x)C.scene.environment=x,C.scene.environmentIntensity=1;else if(C.renderer){const M=xt(C.renderer);M&&(C.scene.environment=M,C.scene.environmentIntensity=1)}}else(f=C.scene)==null||f.add(p)}if(t&&((h=C.scene)==null||h.traverse(b=>{const m=b.userData.id||b.userData._sourceUuid||b.uuid,p=t[m];if(p&&b.userData.isMovable){Ao(b);const x=new ze({title:p.title,items:p.items});x.attachTo(b),x.visible=!1,p.width&&x.setWidth(p.width),p.fontSize&&x.setFontSize(p.fontSize),p.offsetY!==void 0&&x.setOffsetY(p.offsetY),p.offsetX!==void 0&&x.setOffsetX(p.offsetX),p.offsetZ!==void 0&&x.setOffsetZ(p.offsetZ),gs(b,x)}})),n&&n.length>0&&Promise.resolve().then(()=>Ho).then(({addWater:b,addWaterCylinder:m})=>{for(const p of n){const x=p.geometryType||"box";let M;x==="cylinder"?M=m({radiusTop:p.cylinderRadiusTop??5,radiusBottom:p.cylinderRadiusBottom??5,radialSegments:p.cylinderRadialSegments??32,height:.8,color:p.color,scale:4}):M=b({width:p.boxWidth??10,height:p.boxDepth??10,color:p.color,scale:4}),M.position.fromArray(p.position),M.rotation.set(p.rotation[0],p.rotation[1],p.rotation[2]),M.scale.fromArray(p.scale),M.name=p.name,M.userData.waterTimeScale=p.timeScale??.05,M.userData.isWater=!0,M.userData.isMovable=!0,We=!0}Hs()}),s){const b=new S.TextureLoader;(g=C.scene)==null||g.traverse(m=>{if(m.type==="Mesh"){const p=m,x=Array.isArray(p.material)?p.material:[p.material];for(const M of x)if(M&&M.uuid&&s[M.uuid]){const w=s[M.uuid];if(w.mapDataUrl){const y=b.load(w.mapDataUrl);y.wrapS=y.wrapT=S.RepeatWrapping,y.repeat.set(1,1),M.map=y,M.userData=M.userData||{},M.userData._mapDataUrl=w.mapDataUrl,M.userData._mapFileName=w.mapFileName}if(w.normalMapDataUrl){const y=b.load(w.normalMapDataUrl);y.wrapS=y.wrapT=S.RepeatWrapping,y.repeat.set(1,1),M.normalMap=y,M.normalScale=new S.Vector2(w.normalScale??1,w.normalScale??1),M.userData=M.userData||{},M.userData._normalMapDataUrl=w.normalMapDataUrl,M.userData._normalMapFileName=w.normalMapFileName}if(w.aoMapDataUrl){const y=b.load(w.aoMapDataUrl);y.wrapS=y.wrapT=S.RepeatWrapping,y.repeat.set(1,1),M.aoMap=y,M.aoMapIntensity=w.aoMapIntensity??1,M.userData=M.userData||{},M.userData._aoMapDataUrl=w.aoMapDataUrl,M.userData._aoMapFileName=w.aoMapFileName}M.needsUpdate=!0}}})}e==="edit"&&((A=C.scene)==null||A.traverse(b=>{var m;if(b.type==="DirectionalLight"){const p=b;if(!p.userData.helper){const x=new S.DirectionalLightHelper(p,1);x.userData.type="lightHelper",p.userData.helper=x,x.update(),(m=C.scene)==null||m.add(x)}}}))}function qs(r){if(!r)return;if(r.type==="Mesh"){const t=r;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(s=>{s.map&&(s.map=null),s.lightMap&&(s.lightMap=null),s.aoMap&&(s.aoMap=null),s.emissiveMap&&(s.emissiveMap=null),s.bumpMap&&(s.bumpMap=null),s.normalMap&&(s.normalMap=null),s.displacementMap&&(s.displacementMap=null),s.roughnessMap&&(s.roughnessMap=null),s.metalnessMap&&(s.metalnessMap=null),s.alphaMap&&(s.alphaMap=null),s.envMap&&(s.envMap=null),s.dispose()})}const e=r.children.slice();for(const t of e)qs(t)}function Ys(){nt!==null&&(cancelAnimationFrame(nt),nt=null),je&&C.container&&(C.container.removeEventListener("click",je),je=null),Ue&&(window.removeEventListener("resize",Ue),Ue=null),C.orbitControls&&(C.orbitControls.dispose(),C.orbitControls=null),C.transformControls&&(C.transformControls.dispose(),C.transformControls=null),be&&(be.dispose(),be=null),C.scene&&(qs(C.scene),C.scene=null),C.renderer&&(C.renderer.dispose(),C.renderer.domElement&&C.container&&C.container.removeChild(C.renderer.domElement),C.renderer=null),Is(),C.camera=null,C.gridHelper=null,C.selectedObject=null,C.container=null,C.mode="",xe=[],Ne.clear(),ct(),tt=!1,De=!1}const Do=/^[og]\s*(.+)?/,No=/^mtllib /,So=/^usemtl /,Ro=/^usemap /,ds=/\s+/,hs=new c.Vector3,yt=new c.Vector3,fs=new c.Vector3,ps=new c.Vector3,ae=new c.Vector3,$e=new c.Color;function Po(){const r={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}const n=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(s,i){const o=this._finalize(!1);o&&(o.inherited||o.groupCount<=0)&&this.materials.splice(o.index,1);const l={index:this.materials.length,name:s||"",mtllib:Array.isArray(i)&&i.length>0?i[i.length-1]:"",smooth:o!==void 0?o.smooth:this.smooth,groupStart:o!==void 0?o.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(u){const d={index:typeof u=="number"?u:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return d.clone=this.clone.bind(d),d}};return this.materials.push(l),l},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(s){const i=this.currentMaterial();if(i&&i.groupEnd===-1&&(i.groupEnd=this.geometry.vertices.length/3,i.groupCount=i.groupEnd-i.groupStart,i.inherited=!1),s&&this.materials.length>1)for(let o=this.materials.length-1;o>=0;o--)this.materials[o].groupCount<=0&&this.materials.splice(o,1);return s&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),i}},n&&n.name&&typeof n.clone=="function"){const s=n.clone(0);s.inherited=!0,this.object.materials.push(s)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){const n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){const s=this.vertices,i=this.object.geometry.vertices;i.push(s[e+0],s[e+1],s[e+2]),i.push(s[t+0],s[t+1],s[t+2]),i.push(s[n+0],s[n+1],s[n+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){const s=this.normals,i=this.object.geometry.normals;i.push(s[e+0],s[e+1],s[e+2]),i.push(s[t+0],s[t+1],s[t+2]),i.push(s[n+0],s[n+1],s[n+2])},addFaceNormal:function(e,t,n){const s=this.vertices,i=this.object.geometry.normals;hs.fromArray(s,e),yt.fromArray(s,t),fs.fromArray(s,n),ae.subVectors(fs,yt),ps.subVectors(hs,yt),ae.cross(ps),ae.normalize(),i.push(ae.x,ae.y,ae.z),i.push(ae.x,ae.y,ae.z),i.push(ae.x,ae.y,ae.z)},addColor:function(e,t,n){const s=this.colors,i=this.object.geometry.colors;s[e]!==void 0&&i.push(s[e+0],s[e+1],s[e+2]),s[t]!==void 0&&i.push(s[t+0],s[t+1],s[t+2]),s[n]!==void 0&&i.push(s[n+0],s[n+1],s[n+2])},addUV:function(e,t,n){const s=this.uvs,i=this.object.geometry.uvs;i.push(s[e+0],s[e+1]),i.push(s[t+0],s[t+1]),i.push(s[n+0],s[n+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,s,i,o,l,u,d){const f=this.vertices.length;let h=this.parseVertexIndex(e,f),g=this.parseVertexIndex(t,f),A=this.parseVertexIndex(n,f);if(this.addVertex(h,g,A),this.addColor(h,g,A),l!==void 0&&l!==""){const b=this.normals.length;h=this.parseNormalIndex(l,b),g=this.parseNormalIndex(u,b),A=this.parseNormalIndex(d,b),this.addNormal(h,g,A)}else this.addFaceNormal(h,g,A);if(s!==void 0&&s!==""){const b=this.uvs.length;h=this.parseUVIndex(s,b),g=this.parseUVIndex(i,b),A=this.parseUVIndex(o,b),this.addUV(h,g,A),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let n=0,s=e.length;n<s;n++){const i=this.parseVertexIndex(e[n],t);this.addVertexPoint(i),this.addColor(i)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const n=this.vertices.length,s=this.uvs.length;for(let i=0,o=e.length;i<o;i++)this.addVertexLine(this.parseVertexIndex(e[i],n));for(let i=0,o=t.length;i<o;i++)this.addUVLine(this.parseUVIndex(t[i],s))}};return r.startObject("",!1),r}class Oo extends c.Loader{constructor(e){super(e),this.materials=null}load(e,t,n,s){const i=this,o=new c.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{t(i.parse(l))}catch(u){s?s(u):console.error(u),i.manager.itemError(e)}},n,s)}setMaterials(e){return this.materials=e,this}parse(e){const t=new Po;e.indexOf(`\r
139
139
  `)!==-1&&(e=e.replace(/\r\n/g,`
140
140
  `)),e.indexOf(`\\
141
141
  `)!==-1&&(e=e.replace(/\\\n/g,""));const n=e.split(`