1import{f as fs,r as R,j as m,em as tn,en as ie,eo as oe,B as q,cM as sn,ep as ae,eq as nn,O as yt,T as rn,a as ds,C as vt,x as ms,z as on,L as an,d8 as cn,s as ln,y as z,a6 as ee,dn as un,E as hn,G as pn,H as fn,J as dn,N as He,ed as mn,aa as gn,ab as xn}from"./index-CgMUx9S8.js";import{b as gs,T as yn,c as Tt,d as xs,P as re,I as _t,e as k,V as _,f as tt,g as be,M as G,h as vn,D as ys,B as de,i as vs,j as F,S as ke,k as Pt,l as Ts,U as Tn,m as pe,n as Ft,W as wn,N as ws,o as As,p as Es,L as Be,q as Rs,r as Nt,s as We,R as Se,t as Ms,v as Ot,w as Ae,F as $e,x as bs,y as wt,z as Ss,A as _e,E as te,G as Is,H as An,J as En,K as Ee,Q as Ls,X as Rn,Y as Mn,Z as Pe,_ as Oe,$ as De,a0 as Dt,a1 as me,a2 as Cs,a3 as At,a4 as _s,a5 as bn,a6 as Ye,a7 as Re,a8 as Ps,a9 as Fs,aa as Ns,ab as Et,ac as ue,ad as Sn,ae as In,af as Rt,ag as Mt,ah as bt,ai as Ln,aj as Cn,ak as _n,al as Je,am as Pn,an as qe,ao as Fn,ap as Nn,aq as On,ar as W,as as Dn,at as jn,au as Fe,av as kn,aw as J,ax as Bn,ay as Gn,az as Un,aA as zn,u as Ge,aB as Hn,a as Vn,aC as Xn,aD as Kn,aE as Yn,C as qn,O as Wn,aF as Os,aG as Ds,aH as $n}from"./OrbitControls-B4FhfE04.js";import{_ as Q}from"./extends-CF3RwP-h.js";import{G as Jn}from"./grid-3x3-CH2hYleZ.js";import{R as Zn}from"./rotate-cw-BhxtVD2O.js";import{S as Qn}from"./scale-CIY189v4.js";import{F as er}from"./folder-open-gXIYGExP.js";import{I as tr}from"./info-Cgi8Zijo.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const sr=fs("Cylinder",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const nr=fs("Move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]),jt=parseInt(gs.replace(/\D+/g,"")),rr=jt>=125?"uv1":"uv2";function Ht(l,e){if(e===yn)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===Tt||e===xs){let t=l.getIndex();if(t===null){const i=[],o=l.getAttribute("position");if(o!==void 0){for(let a=0;a<o.count;a++)i.push(a);l.setIndex(i),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const n=t.count-2,s=[];if(t)if(e===Tt)for(let i=1;i<=n;i++)s.push(t.getX(0)),s.push(t.getX(i)),s.push(t.getX(i+1));else for(let i=0;i<n;i++)i%2===0?(s.push(t.getX(i)),s.push(t.getX(i+1)),s.push(t.getX(i+2))):(s.push(t.getX(i+2)),s.push(t.getX(i+1)),s.push(t.getX(i)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=l.clone();return r.setIndex(s),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}var ir=Object.defineProperty,or=(l,e,t)=>e in l?ir(l,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[e]=t,ar=(l,e,t)=>(or(l,e+"",t),t);async function Vt(l){const e=await l.arrayBuffer(),t=btoa(String.fromCharCode(...new Uint8Array(e)));return`data:${l.type||""};base64,${t}`}let Ve,st,ye,Xe;function nt(l,e=1/0,t=null){st||(st=new Pt(2,2,1,1)),ye||(ye=new Ts({uniforms:{blitTexture:new Tn(l)},vertexShader:` 12 varying vec2 vUv; 13 void main(){ 14 vUv = uv; 15 gl_Position = vec4(position.xy * 1.0,0.,.999999); 16 } 17 `,fragmentShader:` 18 uniform sampler2D blitTexture; 19 varying vec2 vUv; 20 21 void main(){ 22 gl_FragColor = vec4(vUv.xy, 0, 1); 23 24 #ifdef IS_SRGB 25 gl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) ); 26 #else 27 gl_FragColor = texture2D( blitTexture, vUv); 28 #endif 29 } 30 `})),ye.uniforms.blitTexture.value=l,ye.defines.IS_SRGB="colorSpace"in l?l.colorSpace
vendor: 51,448 bytes, line 30
30==="srgb":l.encoding===3001,ye.needsUpdate=!0,Xe||(Xe=new pe(st,ye),Xe.frustrumCulled=!1);const n=new Ft,s=new ke;s.add(Xe),t||(t=Ve=new wn({antialias:!1})),t.setSize(Math.min(l.image.width,e),Math.min(l.image.height,e)),t.clear(),t.render(s,n);const r=new be(t.domElement);return r.minFilter=l.minFilter,r.magFilter=l.magFilter,r.wrapS=l.wrapS,r.wrapT=l.wrapT,r.name=l.name,Ve&&(Ve.dispose(),Ve=null),r}const Xt={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"]},js=(()=>{class l{constructor(){this.pluginCallbacks=[],this.register(function(t){return new xr(t)}),this.register(function(t){return new yr(t)}),this.register(function(t){return new wr(t)}),this.register(function(t){return new Ar(t)}),this.register(function(t){return new Er(t)}),this.register(function(t){return new Rr(t)}),this.register(function(t){return new vr(t)}),this.register(function(t){return new Tr(t)}),this.register(function(t){return new Mr(t)}),this.register(function(t){return new br(t)}),this.register(function(t){return new Sr(t)})}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,n,s,r){const i=new gr,o=[];for(let a=0,c=this.pluginCallbacks.length;a<c;a++)o.push(this.pluginCallbacks[a](i));i.setPlugins(o),i.write(t,n,r).catch(s)}parseAsync(t,n){const s=this;return new Promise(function(r,i){s.parse(t,r,i,n)})}}return ar(l,"Utils",{insertKeyframe:function(e,t){const s=e.getValueSize(),r=new e.TimeBufferType(e.times.length+1),i=new e.ValueBufferType(e.values.length+s),o=e.createInterpolant(new e.ValueBufferType(s));let a;if(e.times.length===0){r[0]=t;for(let c=0;c<s;c++)i[c]=0;a=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<.001)return 0;r[0]=t,r.set(e.times,1),i.set(o.evaluate(t),0),i.set(e.values,s),a=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<.001)return e.times.length-1;r[r.length-1]=t,r.set(e.times,0),i.set(e.values,0),i.set(o.evaluate(t),e.values.length),a=r.length-1}else for(let c=0;c<e.times.length;c++){if(Math.abs(e.times[c]-t)<.001)return c;if(e.times[c]<t&&e.times[c+1]>t){r.set(e.times.slice(0,c+1),0),r[c+1]=t,r.set(e.times.slice(c+1),c+2),i.set(e.values.slice(0,(c+1)*s),0),i.set(o.evaluate(t),(c+1)*s),i.set(e.values.slice((c+1)*s),(c+2)*s),a=c+1;break}}return e.times=r,e.values=i,a},mergeMorphTargetTracks:function(e,t){const n=[],s={},r=e.tracks;for(let i=0;i<r.length;++i){let o=r[i];const a=re.parseTrackName(o.name),c=re.findNode(t,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){n.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(_t)}const h=c.morphTargetInfluences.length,u=c.morphTargetDictionary[a.propertyIndex];if(u===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let p;if(s[c.uuid]===void 0){p=o.clone();const d=new p.ValueBufferType(h*p.times.length);for(let g=0;g<p.times.length;g++)d[g*h+u]=p.values[g];p.name=(a.nodeName||"")+".morphTargetInfluences",p.values=d,s[c.uuid]=p,n.push(p);continue}const f=o.createInterpolant(new o.ValueBufferType(1));p=s[c.uuid];for(let d=0;d<p.times.length;d++)p.values[d*h+u]=f.evaluate(p.times[d]);for(let d=0;d<o.times.length;d++){const g=this.insertKeyframe(p,o.times[d]);p.values[g*h+u]=o.values[d]}}return e.tracks=n,e}}),l})(),I={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},rt="KHR_mesh_quantization",H={};H[ws]=I.NEAREST;H[As]=I.NEAREST_MIPMAP_NEAREST;H[Es]=I.NEAREST_MIPMAP_LINEAR;H[Be]=I.LINEAR;H[Rs]=I.LINEAR_MIPMAP_NEAREST;H[Nt]=I.LINEAR_MIPMAP_LINEAR;H[We]=I.CLAMP_TO_EDGE;H[Se]=I.REPEAT;H[Ms]=I.MIRRORED_REPEAT;const Kt={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},cr=new k,Yt=12,lr=1179937895,ur=2,qt=8,hr=1313821514,pr=5130562;function Ne(l,e){return l.length===e.length&&l.every(function(t,n){return t===e[n]})}function fr(l){return new TextEncoder().encode(l).buffer}function dr(l){return Ne(l.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function mr(l,e,t){const n={min:new Array(l.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(l.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=e;s<e+t;s++)for(let r=0;r<l.itemSize;r++){let i;l.itemSize>4?i=l.array[s*l.itemSize+r]:(r===0?i=l.getX(s):r===1?i=l.getY(s):r===2?i=l.getZ(s):r===3&&(i=l.getW(s)),l.normalized===!0&&(i=G.normalize(i,l.array))),n.min[r]=Math.min(n.min[r],i),n.max[r]=Math.max(n.max[r],i)}return n}function ks(l){return Math.ceil(l/4)*4}function it(l,e=0){const t=ks(l.byteLength);if(t!==l.byteLength){const n=new Uint8Array(t);if(n.set(new Uint8Array(l)),e!==0)for(let s=l.byteLength;s<t;s++)n[s]=e;return n.buffer}return l}function Wt(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function $t(l,e){if(l.toBlob!==void 0)return new Promise(n=>l.toBlob(n,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),l.convertToBlob({type:e,quality:t})}class gr{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"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(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),this.processInput(e),await Promise.all(this.pending);const s=this,r=s.buffers,i=s.json;n=s.options;const o=s.extensionsUsed,a=s.extensionsRequired,c=new Blob(r,{type:"application/octet-stream"}),h=Object.keys(o),u=Object.keys(a);h.length>0&&(i.extensionsUsed=h),u.length>0&&(i.extensionsRequired=u),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=c.size),n.binary===!0?c.arrayBuffer().then(p=>{const f=it(p),d=new DataView(new ArrayBuffer(qt));d.setUint32(0,f.byteLength,!0),d.setUint32(4,pr,!0);const g=it(fr(JSON.stringify(i)),32),x=new DataView(new ArrayBuffer(qt));x.setUint32(0,g.byteLength,!0),x.setUint32(4,hr,!0);const T=new ArrayBuffer(Yt),A=new DataView(T);A.setUint32(0,lr,!0),A.setUint32(4,ur,!0);const y=Yt+x.byteLength+g.byteLength+d.byteLength+f.byteLength;A.setUint32(8,y,!0),new Blob([T,x,g,d,f],{type:"application/octet-stream"}).arrayBuffer().then(t)}):i.buffers&&i.buffers.length>0?Vt(c).then(p=>{i.buffers[0].uri=p,t(i)}):t(i)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const n=this.options,s=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const i in r.gltfExtensions)t.extensions[i]=r.gltfExtensions[i],s[i]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(r){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+r.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 _;for(let s=0,r=e.count;s<r;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 _;for(let r=0,i=n.count;r<i;r++)s.fromBufferAttribute(n,r),s.x===0&&s.y===0&&s.z===0?s.setX(1):s.normalize(),n.setXYZ(r,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)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(f){return("colorSpace"in f?f.colorSpace==="srgb":f.encoding===3001)?function(g){return g<.04045?g*.0773993808:Math.pow(g*.9478672986+.0521327014,2.4)}:function(g){return g}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof tt&&(e=nt(e)),t instanceof tt&&(t=nt(t));const s=e?e.image:null,r=t?t.image:null,i=Math.max(s?s.width:0,r?r.width:0),o=Math.max(s?s.height:0,r?r.height:0),a=Wt();a.width=i,a.height=o;const c=a.getContext("2d");c.fillStyle="#00ffff",c.fillRect(0,0,i,o);const h=c.getImageData(0,0,i,o);if(s){c.drawImage(s,0,0,i,o);const f=n(e),d=c.getImageData(0,0,i,o).data;for(let g=2;g<d.length;g+=4)h.data[g]=f(d[g]/256)*256}if(r){c.drawImage(r,0,0,i,o);const f=n(t),d=c.getImageData(0,0,i,o).data;for(let g=1;g<d.length;g+=4)h.data[g]=f(d[g]/256)*256}c.putImageData(h,0,0);const p=(e||t).clone();return p.source=new be(a).source,"colorSpace"in p?p.colorSpace="":p.encoding=3e3,p.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),p}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,r){const i=this.json;i.bufferViews||(i.bufferViews=[]);let o;switch(t){case I.BYTE:case I.UNSIGNED_BYTE:o=1;break;case I.SHORT:case I.UNSIGNED_SHORT:o=2;break;default:o=4}let a=e.itemSize*o;r===I.ARRAY_BUFFER&&(a=Math.ceil(a/4)*4);const c=ks(s*a),h=new DataView(new ArrayBuffer(c));let u=0;for(let d=n;d<n+s;d++){for(let g=0;g<e.itemSize;g++){let x;e.itemSize>4?x=e.array[d*e.itemSize+g]:(g===0?x=e.getX(d):g===1?x=e.getY(d):g===2?x=e.getZ(d):g===3&&(x=e.getW(d)),e.normalized===!0&&(x=G.normalize(x,e.array))),t===I.FLOAT?h.setFloat32(u,x,!0):t===I.INT?h.setInt32(u,x,!0):t===I.UNSIGNED_INT?h.setUint32(u,x,!0):t===I.SHORT?h.setInt16(u,x,!0):t===I.UNSIGNED_SHORT?h.setUint16(u,x,!0):t===I.BYTE?h.setInt8(u,x):t===I.UNSIGNED_BYTE&&h.setUint8(u,x),u+=o}u%a!==0&&(u+=a-u%a)}const p={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:c};return r!==void 0&&(p.target=r),r===I.ARRAY_BUFFER&&(p.byteStride=a),this.byteOffset+=c,i.bufferViews.push(p),{id:i.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),e.arrayBuffer().then(s=>{const r=it(s),i={buffer:t.processBuffer(r),byteOffset:t.byteOffset,byteLength:r.byteLength};return t.byteOffset+=r.byteLength,n.bufferViews.push(i)-1})}processAccessor(e,t,n,s){const r=this.json,i={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let o;if(e.array.constructor===Float32Array)o=I.FLOAT;else if(e.array.constructor===Int32Array)o=I.INT;else if(e.array.constructor===Uint32Array)o=I.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=I.SHORT;else if(e.array.constructor===Uint16Array)o=I.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=I.BYTE;else if(e.array.constructor===Uint8Array)o=I.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=e.count),s===0)return null;const a=mr(e,n,s);let c;t!==void 0&&(c=e===t.index?I.ELEMENT_ARRAY_BUFFER:I.ARRAY_BUFFER);const h=this.processBufferView(e,o,n,s,c),u={bufferView:h.id,byteOffset:h.byteOffset,componentType:o,count:s,max:a.max,min:a.min,type:i[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(u)-1}processImage(e,t,n,s="image/png"){if(e!==null){const r=this,i=r.cache,o=r.json,a=r.options,c=r.pending;i.images.has(e)||i.images.set(e,{});const h=i.images.get(e),u=s+":flipY/"+n.toString();if(h[u]!==void 0)return h[u];o.images||(o.images=[]);const p={mimeType:s},f=Wt();f.width=Math.min(e.width,a.maxTextureSize),f.height=Math.min(e.height,a.maxTextureSize);const d=f.getContext("2d");if(n===!0&&(d.translate(0,f.height),d.scale(1,-1)),e.data!==void 0){t!==vn&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const x=new Uint8ClampedArray(e.height*e.width*4);for(let T=0;T<x.length;T+=4)x[T+0]=e.data[T+0],x[T+1]=e.data[T+1],x[T+2]=e.data[T+2],x[T+3]=e.data[T+3];d.putImageData(new ImageData(x,e.width,e.height),0,0)}else d.drawImage(e,0,0,f.width,f.height);a.binary===!0?c.push($t(f,s).then(x=>r.processBufferViewImage(x)).then(x=>{p.bufferView=x})):f.toDataURL!==void 0?p.uri=f.toDataURL(s):c.push($t(f,s).then(Vt).then(x=>{p.uri=x}));const g=o.images.push(p)-1;return h[u]=g,g}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:H[e.magFilter],minFilter:H[e.minFilter],wrapS:H[e.wrapS],wrapT:H[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const n=this.options,s=this.cache,r=this.json;if(s.textures.has(e))return s.textures.get(e);r.textures||(r.textures=[]),e instanceof tt&&(e=nt(e,n.maxTextureSize));let i=e.userData.mimeType;i==="image/webp"&&(i="image/png");const o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(o.name=e.name),this._invokeAll(function(c){c.writeTexture&&c.writeTexture(e,o)});const a=r.textures.push(o)-1;return s.textures.set(e,a),a}processMaterial(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 r=e.color.toArray().concat([e.opacity]);if(Ne(r,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=r),e.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=e.metalness,s.pbrMetallicRoughness.roughnessFactor=e.roughness):(s.pbrMetallicRoughness.metallicFactor=.5,s.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const o=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),a={index:this.processTexture(o),channel:o.channel};this.applyTextureTransform(a,o),s.pbrMetallicRoughness.metallicRoughnessTexture=a}if(e.map){const o={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(o,e.map),s.pbrMetallicRoughness.baseColorTexture=o}if(e.emissive){const o=e.emissive;if(Math.max(o.r,o.g,o.b)>0&&(s.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const c={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(c,e.emissiveMap),s.emissiveTexture=c}}if(e.normalMap){const o={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(o.scale=e.normalScale.x),this.applyTextureTransform(o,e.normalMap),s.normalTexture=o}if(e.aoMap){const o={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(o.strength=e.aoMapIntensity),this.applyTextureTransform(o,e.aoMap),s.occlusionTexture=o}e.transparent?s.alphaMode="BLEND":e.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),e.side===ys&&(s.doubleSided=!0),e.name!==""&&(s.name=e.name),this.serializeUserData(e,s),this._invokeAll(function(o){o.writeMaterial&&o.writeMaterial(e,s)});const i=n.materials.push(s)-1;return t.materials.set(e,i),i}processMesh(e){const t=this.cache,n=this.json,s=[e.geometry.uuid];if(Array.isArray(e.material))for(let y=0,v=e.material.length;y<v;y++)s.push(e.material[y].uuid);else s.push(e.material.uuid);const r=s.join(":");if(t.meshes.has(r))return t.meshes.get(r);const i=e.geometry;let o;e.isLineSegments?o=I.LINES:e.isLineLoop?o=I.LINE_LOOP:e.isLine?o=I.LINE_STRIP:e.isPoints?o=I.POINTS:o=e.material.wireframe?I.LINES:I.TRIANGLES;const a={},c={},h=[],u=[],p={...jt>=152?{uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3"}:{uv:"TEXCOORD_0",uv2:"TEXCOORD_1"},color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},f=i.getAttribute("normal");f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),i.setAttribute("normal",this.createNormalizedNormalAttribute(f)));let d=null;for(let y in i.attributes){if(y.slice(0,5)==="morph")continue;const v=i.attributes[y];if(y=p[y]||y.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(y)||(y="_"+y),t.attributes.has(this.getUID(v))){c[y]=t.attributes.get(this.getUID(v));continue}d=null;const w=v.array;y==="JOINTS_0"&&!(w instanceof Uint16Array)&&!(w instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),d=new de(new Uint16Array(w),v.itemSize,v.normalized));const b=this.processAccessor(d||v,i);b!==null&&(y.startsWith("_")||this.detectMeshQuantization(y,v),c[y]=b,t.attributes.set(this.getUID(v),b))}if(f!==void 0&&i.setAttribute("normal",f),Object.keys(c).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const y=[],v=[],E={};if(e.morphTargetDictionary!==void 0)for(const w in e.morphTargetDictionary)E[e.morphTargetDictionary[w]]=w;for(let w=0;w<e.morphTargetInfluences.length;++w){const b={};let S=!1;for(const P in i.morphAttributes){if(P!=="position"&&P!=="normal"){S||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),S=!0);continue}const M=i.morphAttributes[P][w],j=P.toUpperCase(),V=i.attributes[P];if(t.attributes.has(this.getUID(M,!0))){b[j]=t.attributes.get(this.getUID(M,!0));continue}const X=M.clone();if(!i.morphTargetsRelative)for(let D=0,ze=M.count;D<ze;D++)for(let B=0;B<M.itemSize;B++)B===0&&X.setX(D,M.getX(D)-V.getX(D)),B===1&&X.setY(D,M.getY(D)-V.getY(D)),B===2&&X.setZ(D,M.getZ(D)-V.getZ(D)),B===3&&X.setW(D,M.getW(D)-V.getW(D));b[j]=this.processAccessor(X,i),t.attributes.set(this.getUID(V,!0),b[j])}u.push(b),y.push(e.morphTargetInfluences[w]),e.morphTargetDictionary!==void 0&&v.push(E[w])}a.weights=y,v.length>0&&(a.extras={},a.extras.targetNames=v)}const g=Array.isArray(e.material);if(g&&i.groups.length===0)return null;const x=g?e.material:[e.material],T=g?i.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let y=0,v=T.length;y<v;y++){const E={mode:o,attributes:c};if(this.serializeUserData(i,E),u.length>0&&(E.targets=u),i.index!==null){let b=this.getUID(i.index);(T[y].start!==void 0||T[y].count!==void 0)&&(b+=":"+T[y].start+":"+T[y].count),t.attributes.has(b)?E.indices=t.attributes.get(b):(E.indices=this.processAccessor(i.index,i,T[y].start,T[y].count),t.attributes.set(b,E.indices)),E.indices===null&&delete E.indices}const w=this.processMaterial(x[T[y].materialIndex]);w!==null&&(E.material=w),h.push(E)}a.primitives=h,n.meshes||(n.meshes=[]),this._invokeAll(function(y){y.writeMesh&&y.writeMesh(e,a)});const A=n.meshes.push(a)-1;return t.meshes.set(r,A),A}detectMeshQuantization(e,t){if(this.extensionsUsed[rt])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];Xt[s]&&Xt[s].includes(n)&&(this.extensionsUsed[rt]=!0,this.extensionsRequired[rt]=!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:G.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=js.Utils.mergeMorphTargetTracks(e.clone(),t);const r=e.tracks,i=[],o=[];for(let a=0;a<r.length;++a){const c=r[a],h=re.parseTrackName(c.name);let u=re.findNode(t,h.nodeName);const p=Kt[h.propertyName];if(h.objectName==="bones"&&(u.isSkinnedMesh===!0?u=u.skeleton.getBoneByName(h.objectIndex):u=void 0),!u||!p)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',c.name),null;const f=1;let d=c.values.length/c.times.length;p===Kt.morphTargetInfluences&&(d/=u.morphTargetInfluences.length);let g;c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(g="CUBICSPLINE",d/=3):c.getInterpolation()===vs?g="STEP":g="LINEAR",o.push({input:this.processAccessor(new de(c.times,f)),output:this.processAccessor(new de(c.values,d)),interpolation:g}),i.push({sampler:o.length-1,target:{node:s.get(u),path:p}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:o,channels:i}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,s=t.nodes[n.get(e)],r=e.skeleton;if(r===void 0)return null;const i=e.skeleton.bones[0];if(i===void 0)return null;const o=[],a=new Float32Array(r.bones.length*16),c=new F;for(let u=0;u<r.bones.length;++u)o.push(n.get(r.bones[u])),c.copy(r.boneInverses[u]),c.multiply(e.bindMatrix).toArray(a,u*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new de(a,16)),joints:o,skeleton:n.get(i)}),s.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,s=this.nodeMap;t.nodes||(t.nodes=[]);const r={};if(n.trs){const o=e.quaternion.toArray(),a=e.position.toArray(),c=e.scale.toArray();Ne(o,[0,0,0,1])||(r.rotation=o),Ne(a,[0,0,0])||(r.translation=a),Ne(c,[1,1,1])||(r.scale=c)}else e.matrixAutoUpdate&&e.updateMatrix(),dr(e.matrix)===!1&&(r.matrix=e.matrix.elements);if(e.name!==""&&(r.name=String(e.name)),this.serializeUserData(e,r),e.isMesh||e.isLine||e.isPoints){const o=this.processMesh(e);o!==null&&(r.mesh=o)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const o=[];for(let a=0,c=e.children.length;a<c;a++){const h=e.children[a];if(h.visible||n.onlyVisible===!1){const u=this.processNode(h);u!==null&&o.push(u)}}o.length>0&&(r.children=o)}this._invokeAll(function(o){o.writeNode&&o.writeNode(e,r)});const i=t.nodes.push(r)-1;return s.set(e,i),i}processScene(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 r=[];for(let i=0,o=e.children.length;i<o;i++){const a=e.children[i];if(a.visible||n.onlyVisible===!1){const c=this.processNode(a);c!==null&&r.push(c)}}r.length>0&&(s.nodes=r),this.serializeUserData(e,s)}processObjects(e){const t=new ke;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(s){s.beforeParse&&s.beforeParse(e)});const n=[];for(let s=0;s<e.length;s++)e[s]instanceof ke?this.processScene(e[s]):n.push(e[s]);n.length>0&&this.processObjects(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]);this._invokeAll(function(s){s.afterParse&&s.afterParse(e)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class xr{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,r=n.extensionsUsed,i={};e.name&&(i.name=e.name),i.color=e.color.toArray(),i.intensity=e.intensity,e.isDirectionalLight?i.type="directional":e.isPointLight?(i.type="point",e.distance>0&&(i.range=e.distance)):e.isSpotLight&&(i.type="spot",e.distance>0&&(i.range=e.distance),i.spot={},i.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,i.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."),r[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},r[this.name]=!0);const o=s.extensions[this.name].lights;o.push(i),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}let yr=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(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}},vr=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,s=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){const i={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(i,e.clearcoatMap),r.clearcoatTexture=i}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const i={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(i,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=i}if(e.clearcoatNormalMap){const i={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(i,e.clearcoatNormalMap),r.clearcoatNormalTexture=i}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Tr=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,s=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){const i={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(i,e.iridescenceMap),r.iridescenceTexture=i}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const i={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(i,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=i}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},wr=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,s=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){const i={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(i,e.transmissionMap),r.transmissionTexture=i}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Ar=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,s=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){const i={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(i,e.thicknessMap),r.thicknessTexture=i}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Er=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const s=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Rr=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(cr)&&!e.specularIntensityMap&&!e.specularColorTexture)return;const n=this.writer,s=n.extensionsUsed,r={};if(e.specularIntensityMap){const i={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(i,e.specularIntensityMap),r.specularTexture=i}if(e.specularColorMap){const i={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(i,e.specularColorMap),r.specularColorTexture=i}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Mr=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,s=n.extensionsUsed,r={};if(e.sheenRoughnessMap){const i={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(i,e.sheenRoughnessMap),r.sheenRoughnessTexture=i}if(e.sheenColorMap){const i={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(i,e.sheenColorMap),r.sheenColorTexture=i}r.sheenRoughnessFactor=e.sheenRoughness,r.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},br=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,s=n.extensionsUsed,r={};if(e.anisotropyMap){const i={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(i,e.anisotropyMap),r.anisotropyTexture=i}r.anisotropyStrength=e.anisotropy,r.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},Sr=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const s=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}};var $=Uint8Array,he=Uint16Array,St=Uint32Array,Bs=new $([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Gs=new $([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ir=new $([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Us=function(l,e){for(var t=new he(31),n=0;n<31;++n)t[n]=e+=1<<l[n-1];for(var s=new St(t[30]),n=1;n<30;++n)for(var r=t[n];r<t[n+1];++r)s[r]=r-t[n]<<5|n;return[t,s]},zs=Us(Bs,2),Hs=zs[0],Lr=zs[1];Hs[28]=258,Lr[258]=28;var Cr=Us(Gs,0),_r=Cr[0],It=new he(32768);for(var N=0;N<32768;++N){var ce=(N&43690)>>>1|(N&21845)<<1;ce=(ce&52428)>>>2|(ce&13107)<<2,ce=(ce&61680)>>>4|(ce&3855)<<4,It[N]=((ce&65280)>>>8|(ce&255)<<8)>>>1}var je=function(l,e,t){for(var n=l.length,s=0,r=new he(e);s<n;++s)++r[l[s]-1];var i=new he(e);for(s=0;s<e;++s)i[s]=i[s-1]+r[s-1]<<1;var o;if(t){o=new he(1<<e);var a=15-e;for(s=0;s<n;++s)if(l[s])for(var c=s<<4|l[s],h=e-l[s],u=i[l[s]-1]++<<h,p=u|(1<<h)-1;u<=p;++u)o[It[u]>>>a]=c}else for(o=new he(n),s=0;s<n;++s)l[s]&&(o[s]=It[i[l[s]-1]++]>>>15-l[s]);return o},Ue=new $(288);for(var N=0;N<144;++N)Ue[N]=8;for(var N=144;N<256;++N)Ue[N]=9;for(var N=256;N<280;++N)Ue[N]=7;for(var N=280;N<288;++N)Ue[N]=8;var Vs=new $(32);for(var N=0;N<32;++N)Vs[N]=5;var Pr=je(Ue,9,1),Fr=je(Vs,5,1),ot=function(l){for(var e=l[0],t=1;t<l.length;++t)l[t]>e&&(e=l[t]);return e},Z=function(l,e,t){var n=e/8|0;return(l[n]|l[n+1]<<8)>>(e&7)&t},at=function(l,e){var t=e/8|0;return(l[t]|l[t+1]<<8|l[t+2]<<16)>>(e&7)},Nr=function(l){return(l/8|0)+(l&7&&1)},Or=function(l,e,t){(t==null||t>l.length)&&(t=l.length);var n=new(l instanceof he?he:l instanceof St?St:$)(t-e);return n.set(l.subarray(e,t)),n},Dr=function(l,e,t){var n=l.length;if(!n||t&&!t.l&&n<5)return e||new $(0);var s=!e||t,r=!t||t.i;t||(t={}),e||(e=new $(n*3));var i=function(Gt){var Ut=e.length;if(Gt>Ut){var zt=new $(Math.max(Ut*2,Gt));zt.set(e),e=zt}},o=t.f||0,a=t.p||0,c=t.b||0,h=t.l,u=t.d,p=t.m,f=t.n,d=n*8;do{if(!h){t.f=o=Z(l,a,1);var g=Z(l,a+1,3);if(a+=3,g)if(g==1)h=Pr,u=Fr,p=9,f=5;else if(g==2){var y=Z(l,a,31)+257,v=Z(l,a+10,15)+4,E=y+Z(l,a+5,31)+1;a+=14;for(var w=new $(E),b=new $(19),S=0;S<v;++S)b[Ir[S]]=Z(l,a+S*3,7);a+=v*3;for(var P=ot(b),M=(1<<P)-1,j=je(b,P,1),S=0;S<E;){var V=j[Z(l,a,M)];a+=V&15;var x=V>>>4;if(x<16)w[S++]=x;else{var X=0,D=0;for(x==16?(D=3+Z(l,a,3),a+=2,X=w[S-1]):x==17?(D=3+Z(l,a,7),a+=3):x==18&&(D=11+Z(l,a,127),a+=7);D--;)w[S++]=X}}var ze=w.subarray(0,y),B=w.subarray(y);p=ot(ze),f=ot(B),h=je(ze,p,1),u=je(B,f,1)}else throw"invalid block type";else{var x=Nr(a)+4,T=l[x-4]|l[x-3]<<8,A=x+T;if(A>n){if(r)throw"unexpected EOF";break}s&&i(c+T),e.set(l.subarray(x,A),c),t.b=c+=T,t.p=a=A*8;continue}if(a>d){if(r)throw"unexpected EOF";break}}s&&i(c+131072);for(var Qs=(1<<p)-1,en=(1<<f)-1,Ze=a;;Ze=a){var X=h[at(l,a)&Qs],xe=X>>>4;if(a+=X&15,a>d){if(r)throw"unexpected EOF";break}if(!X)throw"invalid length/literal";if(xe<256)e[c++]=xe;else if(xe==256){Ze=a,h=null;break}else{var kt=xe-254;if(xe>264){var S=xe-257,Le=Bs[S];kt=Z(l,a,(1<<Le)-1)+Hs[S],a+=Le}var Qe=u[at(l,a)&en],et=Qe>>>4;if(!Qe)throw"invalid distance";a+=Qe&15;var B=_r[et];if(et>3){var Le=Gs[et];B+=at(l,a)&(1<<Le)-1,a+=Le}if(a>d){if(r)throw"unexpected EOF";break}s&&i(c+131072);for(var Bt=c+kt;c<Bt;c+=4)e[c]=e[c-B],e[c+1]=e[c+1-B],e[c+2]=e[c+2-B],e[c+3]=e[c+3-B];c=Bt}}t.l=h,t.p=Ze,t.b=c,h&&(o=1,t.m=p,t.d=u,t.n=f)}while(!o);return c==e.length?e:Or(e,0,c)},jr=new $(0),kr=function(l){if((l[0]&15)!=8||l[0]>>>4>7||(l[0]<<8|l[1])%31)throw"invalid zlib data";if(l[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Br(l,e){return Dr((kr(l),l.subarray(2,-4)),e)}var Gr=typeof TextDecoder<"u"&&new TextDecoder,Ur=0;try{Gr.decode(jr,{stream:!0}),Ur=1}catch{}function Ie(l){if(typeof TextDecoder<"u")return new TextDecoder().decode(l);let e="";for(let t=0,n=l.length;t<n;t++)e+=String.fromCharCode(l[t]);try{return decodeURIComponent(escape(e))}catch{return e}}const ge="srgb",ne="srgb-linear",Jt=3001,zr=3e3;class Hr extends Ot{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new qr(t)}),this.register(function(t){return new Wr(t)}),this.register(function(t){return new ri(t)}),this.register(function(t){return new ii(t)}),this.register(function(t){return new oi(t)}),this.register(function(t){return new Jr(t)}),this.register(function(t){return new Zr(t)}),this.register(function(t){return new Qr(t)}),this.register(function(t){return new ei(t)}),this.register(function(t){return new Yr(t)}),this.register(function(t){return new ti(t)}),this.register(function(t){return new $r(t)}),this.register(function(t){return new ni(t)}),this.register(function(t){return new si(t)}),this.register(function(t){return new Xr(t)}),this.register(function(t){return new ai(t)}),this.register(function(t){return new ci(t)})}load(e,t,n,s){const r=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const c=Ae.extractUrlBase(e);i=Ae.resolveURL(c,this.path)}else i=Ae.extractUrlBase(e);this.manager.itemStart(e);const o=function(c){s?s(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},a=new $e(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{r.parse(c,i,function(h){t(h),r.manager.itemEnd(e)},o)}catch(h){o(h)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}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 r;const i={},o={};if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(Ie(new Uint8Array(e.slice(0,4)))===Xs){try{i[C.KHR_BINARY_GLTF]=new li(e)}catch(h){s&&s(h);return}r=JSON.parse(i[C.KHR_BINARY_GLTF].content)}else r=JSON.parse(Ie(new Uint8Array(e)));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const a=new Ai(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});a.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c<this.pluginCallbacks.length;c++){const h=this.pluginCallbacks[c](a);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),o[h.name]=h,i[h.name]=!0}if(r.extensionsUsed)for(let c=0;c<r.extensionsUsed.length;++c){const h=r.extensionsUsed[c],u=r.extensionsRequired||[];switch(h){case C.KHR_MATERIALS_UNLIT:i[h]=new Kr;break;case C.KHR_DRACO_MESH_COMPRESSION:i[h]=new ui(r,this.dracoLoader);break;case C.KHR_TEXTURE_TRANSFORM:i[h]=new hi;break;case C.KHR_MESH_QUANTIZATION:i[h]=new pi;break;default:u.indexOf(h)>=0&&o[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}a.setExtensions(i),a.setPlugins(o),a.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,r){n.parse(e,t,s,r)})}}function Vr(){let l={};return{get:function(e){return l[e]},add:function(e,t){l[e]=t},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Xr{constructor(e){this.parser=e,this.name=C.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 r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const r=t.json,a=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const h=new k(16777215);a.color!==void 0&&h.setRGB(a.color[0],a.color[1],a.color[2],ne);const u=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new Ss(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new wt(h),c.distance=u;break;case"spot":c=new bs(h),c.distance=u,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return c.position.set(0,0,0),c.decay=2,se(c,a),a.intensity!==void 0&&(c.intensity=a.intensity),c.name=t.createUniqueName(a.name||"light_"+e),s=Promise.resolve(c),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],o=(r.extensions&&r.extensions[this.name]||{}).light;return o===void 0?null:this._loadLight(o).then(function(a){return n._getNodeRef(t.cache,o,a)})}}class Kr{constructor(){this.name=C.KHR_MATERIALS_UNLIT}getMaterialType(){return _e}extendParams(e,t,n){const s=[];e.color=new k(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const i=r.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],ne),e.opacity=i[3]}r.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",r.baseColorTexture,ge))}return Promise.all(s)}}class Yr{constructor(e){this.parser=e,this.name=C.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class qr{constructor(e){this.parser=e,this.name=C.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:te}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const o=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Is(o,o)}return Promise.all(r)}}class Wr{constructor(e){this.parser=e,this.name=C.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:te}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class $r{constructor(e){this.parser=e,this.name=C.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:te}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(r)}}class Jr{constructor(e){this.parser=e,this.name=C.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:te}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new k(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=s.extensions[this.name];if(i.sheenColorFactor!==void 0){const o=i.sheenColorFactor;t.sheenColor.setRGB(o[0],o[1],o[2],ne)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,ge)),i.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(r)}}class Zr{constructor(e){this.parser=e,this.name=C.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:te}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(r)}}class Qr{constructor(e){this.parser=e,this.name=C.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:te}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const o=i.attenuationColor||[1,1,1];return t.attenuationColor=new k().setRGB(o[0],o[1],o[2],ne),Promise.all(r)}}class ei{constructor(e){this.parser=e,this.name=C.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:te}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class ti{constructor(e){this.parser=e,this.name=C.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:te}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));const o=i.specularColorFactor||[1,1,1];return t.specularColor=new k().setRGB(o[0],o[1],o[2],ne),i.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,ge)),Promise.all(r)}}class si{constructor(e){this.parser=e,this.name=C.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:te}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];return t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&r.push(n.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(r)}}class ni{constructor(e){this.parser=e,this.name=C.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:te}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(r)}}class ri{constructor(e){this.parser=e,this.name=C.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 r=s.extensions[this.name],i=t.options.ktx2Loader;if(!i){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,r.source,i)}}class ii{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],o=s.images[i.source];let a=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(a=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,i.source,a);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class oi{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],o=s.images[i.source];let a=n.textureLoader;if(o.uri){const c=n.options.manager.getHandler(o.uri);c!==null&&(a=c)}return this.detectSupport().then(function(c){if(c)return n.loadTextureImage(e,i.source,a);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdj
30FDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ai{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,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],r=this.parser.getDependency("buffer",s.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(o){const a=s.byteOffset||0,c=s.byteLength||0,h=s.count,u=s.byteStride,p=new Uint8Array(o,a,c);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(h,u,p,s.mode,s.filter).then(function(f){return f.buffer}):i.ready.then(function(){const f=new ArrayBuffer(h*u);return i.decodeGltfBuffer(new Uint8Array(f),h,u,p,s.mode,s.filter),f})})}else return null}}class ci{constructor(e){this.name=C.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 c of s.primitives)if(c.mode!==Y.TRIANGLES&&c.mode!==Y.TRIANGLE_STRIP&&c.mode!==Y.TRIANGLE_FAN&&c.mode!==void 0)return null;const i=n.extensions[this.name].attributes,o=[],a={};for(const c in i)o.push(this.parser.getDependency("accessor",i[c]).then(h=>(a[c]=h,a[c])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(c=>{const h=c.pop(),u=h.isGroup?h.children:[h],p=c[0].count,f=[];for(const d of u){const g=new F,x=new _,T=new ue,A=new _(1,1,1),y=new An(d.geometry,d.material,p);for(let v=0;v<p;v++)a.TRANSLATION&&x.fromBufferAttribute(a.TRANSLATION,v),a.ROTATION&&T.fromBufferAttribute(a.ROTATION,v),a.SCALE&&A.fromBufferAttribute(a.SCALE,v),y.setMatrixAt(v,g.compose(x,T,A));for(const v in a)if(v==="_COLOR_0"){const E=a[v];y.instanceColor=new En(E.array,E.itemSize,E.normalized)}else v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"&&d.geometry.setAttribute(v,a[v]);Ee.prototype.copy.call(y,d),this.parser.assignFinalMaterial(y),f.push(y)}return h.isGroup?(h.clear(),h.add(...f),h):f[0]}))}}const Xs="glTF",Ce=12,Zt={JSON:1313821514,BIN:5130562};class li{constructor(e){this.name=C.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ce);if(this.header={magic:Ie(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Xs)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Ce,s=new DataView(e,Ce);let r=0;for(;r<n;){const i=s.getUint32(r,!0);r+=4;const o=s.getUint32(r,!0);if(r+=4,o===Zt.JSON){const a=new Uint8Array(e,Ce+r,i);this.content=Ie(a)}else if(o===Zt.BIN){const a=Ce+r;this.body=e.slice(a,a+i)}r+=i}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class ui{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=C.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,o={},a={},c={};for(const h in i){const u=Lt[h]||h.toLowerCase();o[u]=i[h]}for(const h in e.attributes){const u=Lt[h]||h.toLowerCase();if(i[h]!==void 0){const p=n.accessors[e.attributes[h]],f=Me[p.componentType];c[u]=f.name,a[u]=p.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,p){s.decodeDracoFile(h,function(f){for(const d in f.attributes){const g=f.attributes[d],x=a[d];x!==void 0&&(g.normalized=x)}u(f)},o,c,ne,p)})})}}class hi{constructor(){this.name=C.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}}
vendor: 22,287 bytes, line 30
30class pi{constructor(){this.name=C.KHR_MESH_QUANTIZATION}}class Ks extends _n{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let i=0;i!==s;i++)t[i]=n[r+i];return t}interpolate_(e,t,n,s){const r=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=o*2,c=o*3,h=s-t,u=(n-t)/h,p=u*u,f=p*u,d=e*c,g=d-c,x=-2*f+3*p,T=f-p,A=1-x,y=T-p+u;for(let v=0;v!==o;v++){const E=i[g+v+o],w=i[g+v+a]*h,b=i[d+v+o],S=i[d+v]*h;r[v]=A*E+y*w+x*b+T*S}return r}}const fi=new ue;class di extends Ks{interpolate_(e,t,n,s){const r=super.interpolate_(e,t,n,s);return fi.fromArray(r).normalize().toArray(r),r}}const Y={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Me={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Qt={9728:ws,9729:Be,9984:As,9985:Rs,9986:Es,9987:Nt},es={33071:We,33648:Ms,10497:Se},ct={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Lt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...jt>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},le={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},mi={CUBICSPLINE:void 0,LINEAR:_t,STEP:vs},lt={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function gi(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new Dt({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:Sn})),l.DefaultMaterial}function fe(l,e,t){for(const n in t.extensions)l[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function se(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function xi(l,e,t){let n=!1,s=!1,r=!1;for(let c=0,h=e.length;c<h;c++){const u=e[c];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(s=!0),u.COLOR_0!==void 0&&(r=!0),n&&s&&r)break}if(!n&&!s&&!r)return Promise.resolve(l);const i=[],o=[],a=[];for(let c=0,h=e.length;c<h;c++){const u=e[c];if(n){const p=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):l.attributes.position;i.push(p)}if(s){const p=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):l.attributes.normal;o.push(p)}if(r){const p=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):l.attributes.color;a.push(p)}}return Promise.all([Promise.all(i),Promise.all(o),Promise.all(a)]).then(function(c){const h=c[0],u=c[1],p=c[2];return n&&(l.morphAttributes.position=h),s&&(l.morphAttributes.normal=u),r&&(l.morphAttributes.color=p),l.morphTargetsRelative=!0,l})}function yi(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)l.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(l.morphTargetInfluences.length===t.length){l.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)l.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function vi(l){let e;const t=l.extensions&&l.extensions[C.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+ut(t.attributes):e=l.indices+":"+ut(l.attributes)+":"+l.mode,l.targets!==void 0)for(let n=0,s=l.targets.length;n<s;n++)e+=":"+ut(l.targets[n]);return e}function ut(l){let e="";const t=Object.keys(l).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+l[t[n]]+";";return e}function Ct(l){switch(l){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 Ti(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const wi=new F;class Ai{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Vr,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,r=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,r=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||s&&r<98?this.textureLoader=new Ls(this.options.manager):this.textureLoader=new Rn(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new $e(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,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(i){const o={scene:i[0][s.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:s.asset,parser:n,userData:{}};return fe(r,o,s),se(o,s),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(o)})).then(function(){for(const a of o.scenes)a.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){const i=t[s].joints;for(let o=0,a=i.length;o<a;o++)e[i[o]].isBone=!0}for(let s=0,r=e.length;s<r;s++){const i=e[s];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(n[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),r=(i,o)=>{const a=this.associations.get(i);a!=null&&this.associations.set(o,a);for(const[c,h]of i.children.entries())r(h,o.children[c])};return r(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 r=e(t[s]);r&&n.push(r)}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(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.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(r,i){return n.getDependency(e,i)})),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[C.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,i){n.load(Ae.resolveURL(t.uri,s.path),r,void 0,function(){i(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,r=t.byteOffset||0;return n.slice(r,r+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const i=ct[s.type],o=Me[s.componentType],a=s.normalized===!0,c=new o(s.count*i);return Promise.resolve(new de(c,i,a))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(i){const o=i[0],a=ct[s.type],c=Me[s.componentType],h=c.BYTES_PER_ELEMENT,u=h*a,p=s.byteOffset||0,f=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,d=s.normalized===!0;let g,x;if(f&&f!==u){const T=Math.floor(p/f),A="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+T+":"+s.count;let y=t.cache.get(A);y||(g=new c(o,T*f,s.count*f/h),y=new Mn(g,f/h),t.cache.add(A,y)),x=new In(y,a,p%f/h,d)}else o===null?g=new c(s.count*a):g=new c(o,p,s.count*a),x=new de(g,a,d);if(s.sparse!==void 0){const T=ct.SCALAR,A=Me[s.sparse.indices.componentType],y=s.sparse.indices.byteOffset||0,v=s.sparse.values.byteOffset||0,E=new A(i[1],y,s.sparse.count*T),w=new c(i[2],v,s.sparse.count*a);o!==null&&(x=new de(x.array.slice(),x.itemSize,x.normalized));for(let b=0,S=E.length;b<S;b++){const P=E[b];if(x.setX(P,w[b*a]),a>=2&&x.setY(P,w[b*a+1]),a>=3&&x.setZ(P,w[b*a+2]),a>=4&&x.setW(P,w[b*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return x})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r];let o=this.textureLoader;if(i.uri){const a=n.manager.getHandler(i.uri);a!==null&&(o=a)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,n){const s=this,r=this.json,i=r.textures[e],o=r.images[t],a=(o.uri||o.bufferView)+":"+i.sampler;if(this.textureCache[a])return this.textureCache[a];const c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=i.name||o.name||"",h.name===""&&typeof o.uri=="string"&&o.uri.startsWith("data:image/")===!1&&(h.name=o.uri);const p=(r.samplers||{})[i.sampler]||{};return h.magFilter=Qt[p.magFilter]||Be,h.minFilter=Qt[p.minFilter]||Nt,h.wrapS=es[p.wrapS]||Se,h.wrapT=es[p.wrapT]||Se,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){const n=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const i=s.images[e],o=self.URL||self.webkitURL;let a=i.uri||"",c=!1;if(i.bufferView!==void 0)a=n.getDependency("bufferView",i.bufferView).then(function(u){c=!0;const p=new Blob([u],{type:i.mimeType});return a=o.createObjectURL(p),a});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(a).then(function(u){return new Promise(function(p,f){let d=p;t.isImageBitmapLoader===!0&&(d=function(g){const x=new be(g);x.needsUpdate=!0,p(x)}),t.load(Ae.resolveURL(u,r.path),d,void 0,f)})}).then(function(u){return c===!0&&o.revokeObjectURL(a),se(u,i),u.userData.mimeType=i.mimeType||Ti(i.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,s){const r=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(i=i.clone(),i.channel=n.texCoord),r.extensions[C.KHR_TEXTURE_TRANSFORM]){const o=n.extensions!==void 0?n.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(o){const a=r.associations.get(i);i=r.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(i,o),r.associations.set(i,a)}}return s!==void 0&&(typeof s=="number"&&(s=s===Jt?ge:ne),"colorSpace"in i?i.colorSpace=s:i.encoding=s===ge?Jt:zr),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const o="PointsMaterial:"+n.uuid;let a=this.cache.get(o);a||(a=new Pe,Oe.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(o,a)),n=a}else if(e.isLine){const o="LineBasicMaterial:"+n.uuid;let a=this.cache.get(o);a||(a=new De,Oe.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(o,a)),n=a}if(s||r||i){let o="ClonedMaterial:"+n.uuid+":";s&&(o+="derivative-tangents:"),r&&(o+="vertex-colors:"),i&&(o+="flat-shading:");let a=this.cache.get(o);a||(a=n.clone(),r&&(a.vertexColors=!0),i&&(a.flatShading=!0),s&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(o,a),this.associations.set(a,this.associations.get(n))),n=a}e.material=n}getMaterialType(){return Dt}loadMaterial(e){const t=this,n=this.json,s=this.extensions,r=n.materials[e];let i;const o={},a=r.extensions||{},c=[];if(a[C.KHR_MATERIALS_UNLIT]){const u=s[C.KHR_MATERIALS_UNLIT];i=u.getMaterialType(),c.push(u.extendParams(o,r,t))}else{const u=r.pbrMetallicRoughness||{};if(o.color=new k(1,1,1),o.opacity=1,Array.isArray(u.baseColorFactor)){const p=u.baseColorFactor;o.color.setRGB(p[0],p[1],p[2],ne),o.opacity=p[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(o,"map",u.baseColorTexture,ge)),o.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,o.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(o,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(o,"roughnessMap",u.metallicRoughnessTexture))),i=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,o)})))}r.doubleSided===!0&&(o.side=ys);const h=r.alphaMode||lt.OPAQUE;if(h===lt.BLEND?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,h===lt.MASK&&(o.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&i!==_e&&(c.push(t.assignTexture(o,"normalMap",r.normalTexture)),o.normalScale=new Is(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;o.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&i!==_e&&(c.push(t.assignTexture(o,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(o.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&i!==_e){const u=r.emissiveFactor;o.emissive=new k().setRGB(u[0],u[1],u[2],ne)}return r.emissiveTexture!==void 0&&i!==_e&&c.push(t.assignTexture(o,"emissiveMap",r.emissiveTexture,ge)),Promise.all(c).then(function(){const u=new i(o);return r.name&&(u.name=r.name),se(u,r),t.associations.set(u,{materials:e}),r.extensions&&fe(s,u,r),u})}createUniqueName(e){const t=re.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 r(o){return n[C.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(o,t).then(function(a){return ts(a,o,t)})}const i=[];for(let o=0,a=e.length;o<a;o++){const c=e[o],h=vi(c),u=s[h];if(u)i.push(u.promise);else{let p;c.extensions&&c.extensions[C.KHR_DRACO_MESH_COMPRESSION]?p=r(c):p=ts(new me,c,t),s[h]={primitive:c,promise:p},i.push(p)}}return Promise.all(i)}loadMesh(e){const t=this,n=this.json,s=this.extensions,r=n.meshes[e],i=r.primitives,o=[];for(let a=0,c=i.length;a<c;a++){const h=i[a].material===void 0?gi(this.cache):this.getDependency("material",i[a].material);o.push(h)}return o.push(t.loadGeometries(i)),Promise.all(o).then(function(a){const c=a.slice(0,a.length-1),h=a[a.length-1],u=[];for(let f=0,d=h.length;f<d;f++){const g=h[f],x=i[f];let T;const A=c[f];if(x.mode===Y.TRIANGLES||x.mode===Y.TRIANGLE_STRIP||x.mode===Y.TRIANGLE_FAN||x.mode===void 0)T=r.isSkinnedMesh===!0?new Cs(g,A):new pe(g,A),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),x.mode===Y.TRIANGLE_STRIP?T.geometry=Ht(T.geometry,xs):x.mode===Y.TRIANGLE_FAN&&(T.geometry=Ht(T.geometry,Tt));else if(x.mode===Y.LINES)T=new At(g,A);else if(x.mode===Y.LINE_STRIP)T=new _s(g,A);else if(x.mode===Y.LINE_LOOP)T=new bn(g,A);else if(x.mode===Y.POINTS)T=new Ye(g,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);Object.keys(T.geometry.morphAttributes).length>0&&yi(T,r),T.name=t.createUniqueName(r.name||"mesh_"+e),se(T,r),x.extensions&&fe(s,T,x),t.assignFinalMaterial(T),u.push(T)}for(let f=0,d=u.length;f<d;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return r.extensions&&fe(s,u[0],r),u[0];const p=new Re;r.extensions&&fe(s,p,r),t.associations.set(p,{meshes:e});for(let f=0,d=u.length;f<d;f++)p.add(u[f]);return p})}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 Ft(G.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new Ps(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),se(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,r=t.joints.length;s<r;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 r=s.pop(),i=s,o=[],a=[];for(let c=0,h=i.length;c<h;c++){const u=i[c];if(u){o.push(u);const p=new F;r!==null&&p.fromArray(r.array,c*16),a.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new Fs(o,a)})}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],r=s.name?s.name:"animation_"+e,i=[],o=[],a=[],c=[],h=[];for(let u=0,p=s.channels.length;u<p;u++){const f=s.channels[u],d=s.samplers[f.sampler],g=f.target,x=g.node,T=s.parameters!==void 0?s.parameters[d.input]:d.input,A=s.parameters!==void 0?s.parameters[d.output]:d.output;g.node!==void 0&&(i.push(this.getDependency("node",x)),o.push(this.getDependency("accessor",T)),a.push(this.getDependency("accessor",A)),c.push(d),h.push(g))}return Promise.all([Promise.all(i),Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(h)]).then(function(u){const p=u[0],f=u[1],d=u[2],g=u[3],x=u[4],T=[];for(let A=0,y=p.length;A<y;A++){const v=p[A],E=f[A],w=d[A],b=g[A],S=x[A];if(v===void 0)continue;v.updateMatrix&&v.updateMatrix();const P=n._createAnimationTracks(v,E,w,b,S);if(P)for(let M=0;M<P.length;M++)T.push(P[M])}return new Ns(r,void 0,T)})}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(r){const i=n._getNodeRef(n.meshCache,s.mesh,r);return s.weights!==void 0&&i.traverse(function(o){if(o.isMesh)for(let a=0,c=s.weights.length;a<c;a++)o.morphTargetInfluences[a]=s.weights[a]}),i})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],r=n._loadNodeShallow(e),i=[],o=s.children||[];for(let c=0,h=o.length;c<h;c++)i.push(n.getDependency("node",o[c]));const a=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([r,Promise.all(i),a]).then(function(c){const h=c[0],u=c[1],p=c[2];p!==null&&h.traverse(function(f){f.isSkinnedMesh&&f.bind(p,wi)});for(let f=0,d=u.length;f<d;f++)h.add(u[f]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],i=r.name?s.createUniqueName(r.name):"",o=[],a=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return a&&o.push(a),r.camera!==void 0&&o.push(s.getDependency("camera",r.camera).then(function(c){return s._getNodeRef(s.cameraCache,r.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){o.push(c)}),this.nodeCache[e]=Promise.all(o).then(function(c){let h;if(r.isBone===!0?h=new Et:c.length>1?h=new Re:c.length===1?h=c[0]:h=new Ee,h!==c[0])for(let u=0,p=c.length;u<p;u++)h.add(c[u]);if(r.name&&(h.userData.name=r.name,h.name=i),se(h,r),r.extensions&&fe(n,h,r),r.matrix!==void 0){const u=new F;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return s.associations.has(h)||s.associations.set(h,{}),s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,r=new Re;n.name&&(r.name=s.createUniqueName(n.name)),se(r,n),n.extensions&&fe(t,r,n);const i=n.nodes||[],o=[];for(let a=0,c=i.length;a<c;a++)o.push(s.getDependency("node",i[a]));return Promise.all(o).then(function(a){for(let h=0,u=a.length;h<u;h++)r.add(a[h]);const c=h=>{const u=new Map;for(const[p,f]of s.associations)(p instanceof Oe||p instanceof be)&&u.set(p,f);return h.traverse(p=>{const f=s.associations.get(p);f!=null&&u.set(p,f)}),u};return s.associations=c(r),r})}_createAnimationTracks(e,t,n,s,r){const i=[],o=e.name?e.name:e.uuid,a=[];le[r.path]===le.weights?e.traverse(function(p){p.morphTargetInfluences&&a.push(p.name?p.name:p.uuid)}):a.push(o);let c;switch(le[r.path]){case le.weights:c=Mt;break;case le.rotation:c=bt;break;case le.position:case le.scale:c=Rt;break;default:switch(n.itemSize){case 1:c=Mt;break;case 2:case 3:default:c=Rt;break}break}const h=s.interpolation!==void 0?mi[s.interpolation]:_t,u=this._getArrayFromAccessor(n);for(let p=0,f=a.length;p<f;p++){const d=new c(a[p]+"."+le[r.path],t.array,u,h);
30s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(d),i.push(d)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Ct(t.constructor),s=new Float32Array(t.length);for(let r=0,i=t.length;r<i;r++)s[r]=t[r]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const s=this instanceof bt?di:Ks;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ei(l,e,t){const n=e.attributes,s=new Ln;if(n.POSITION!==void 0){const o=t.json.accessors[n.POSITION],a=o.min,c=o.max;if(a!==void 0&&c!==void 0){if(s.set(new _(a[0],a[1],a[2]),new _(c[0],c[1],c[2])),o.normalized){const h=Ct(Me[o.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const o=new _,a=new _;for(let c=0,h=r.length;c<h;c++){const u=r[c];if(u.POSITION!==void 0){const p=t.json.accessors[u.POSITION],f=p.min,d=p.max;if(f!==void 0&&d!==void 0){if(a.setX(Math.max(Math.abs(f[0]),Math.abs(d[0]))),a.setY(Math.max(Math.abs(f[1]),Math.abs(d[1]))),a.setZ(Math.max(Math.abs(f[2]),Math.abs(d[2]))),p.normalized){const g=Ct(Me[p.componentType]);a.multiplyScalar(g)}o.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(o)}l.boundingBox=s;const i=new Cn;s.getCenter(i.center),i.radius=s.min.distanceTo(s.max)/2,l.boundingSphere=i}function ts(l,e,t){const n=e.attributes,s=[];function r(i,o){return t.getDependency("accessor",i).then(function(a){l.setAttribute(o,a)})}for(const i in n){const o=Lt[i]||i.toLowerCase();o in l.attributes||s.push(r(n[i],o))}if(e.indices!==void 0&&!l.index){const i=t.getDependency("accessor",e.indices).then(function(o){l.setIndex(o)});s.push(i)}return se(l,e),Ei(l,e,t),Promise.all(s).then(function(){return e.targets!==void 0?xi(l,e.targets,t):l})}function Ys(l,e,t){const n=t.length-l-1;if(e>=t[n])return n-1;if(e<=t[l])return l;let s=l,r=n,i=Math.floor((s+r)/2);for(;e<t[i]||e>=t[i+1];)e<t[i]?r=i:s=i,i=Math.floor((s+r)/2);return i}function Ri(l,e,t,n){const s=[],r=[],i=[];s[0]=1;for(let o=1;o<=t;++o){r[o]=e-n[l+1-o],i[o]=n[l+o]-e;let a=0;for(let c=0;c<o;++c){const h=i[c+1],u=r[o-c],p=s[c]/(h+u);s[c]=a+h*p,a=u*p}s[o]=a}return s}function Mi(l,e,t,n){const s=Ys(l,n,e),r=Ri(s,n,l,e),i=new Je(0,0,0,0);for(let o=0;o<=l;++o){const a=t[s-l+o],c=r[o],h=a.w*c;i.x+=a.x*h,i.y+=a.y*h,i.z+=a.z*h,i.w+=a.w*c}return i}function bi(l,e,t,n,s){const r=[];for(let u=0;u<=t;++u)r[u]=0;const i=[];for(let u=0;u<=n;++u)i[u]=r.slice(0);const o=[];for(let u=0;u<=t;++u)o[u]=r.slice(0);o[0][0]=1;const a=r.slice(0),c=r.slice(0);for(let u=1;u<=t;++u){a[u]=e-s[l+1-u],c[u]=s[l+u]-e;let p=0;for(let f=0;f<u;++f){const d=c[f+1],g=a[u-f];o[u][f]=d+g;const x=o[f][u-1]/o[u][f];o[f][u]=p+d*x,p=g*x}o[u][u]=p}for(let u=0;u<=t;++u)i[0][u]=o[u][t];for(let u=0;u<=t;++u){let p=0,f=1;const d=[];for(let g=0;g<=t;++g)d[g]=r.slice(0);d[0][0]=1;for(let g=1;g<=n;++g){let x=0;const T=u-g,A=t-g;u>=g&&(d[f][0]=d[p][0]/o[A+1][T],x=d[f][0]*o[T][A]);const y=T>=-1?1:-T,v=u-1<=A?g-1:t-u;for(let w=y;w<=v;++w)d[f][w]=(d[p][w]-d[p][w-1])/o[A+1][T+w],x+=d[f][w]*o[T+w][A];u<=A&&(d[f][g]=-d[p][g-1]/o[A+1][u],x+=d[f][g]*o[u][A]),i[g][u]=x;const E=p;p=f,f=E}}let h=t;for(let u=1;u<=n;++u){for(let p=0;p<=t;++p)i[u][p]*=h;h*=t-u}return i}function Si(l,e,t,n,s){const r=s<l?s:l,i=[],o=Ys(l,n,e),a=bi(o,n,l,r,e),c=[];for(let h=0;h<t.length;++h){const u=t[h].clone(),p=u.w;u.x*=p,u.y*=p,u.z*=p,c[h]=u}for(let h=0;h<=r;++h){const u=c[o-l].clone().multiplyScalar(a[h][0]);for(let p=1;p<=l;++p)u.add(c[o-l+p].clone().multiplyScalar(a[h][p]));i[h]=u}for(let h=r+1;h<=s+1;++h)i[h]=new Je(0,0,0);return i}function Ii(l,e){let t=1;for(let s=2;s<=l;++s)t*=s;let n=1;for(let s=2;s<=e;++s)n*=s;for(let s=2;s<=l-e;++s)n*=s;return t/n}function Li(l){const e=l.length,t=[],n=[];for(let r=0;r<e;++r){const i=l[r];t[r]=new _(i.x,i.y,i.z),n[r]=i.w}const s=[];for(let r=0;r<e;++r){const i=t[r].clone();for(let o=1;o<=r;++o)i.sub(s[r-o].clone().multiplyScalar(Ii(r,o)*n[o]));s[r]=i.divideScalar(n[0])}return s}function Ci(l,e,t,n,s){const r=Si(l,e,t,n,s);return Li(r)}
30class ss extends Pn{constructor(e,t,n,s,r){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=s||0,this.endKnot=r||this.knots.length-1;for(let i=0;i<n.length;++i){const o=n[i];this.controlPoints[i]=new Je(o.x,o.y,o.z,o.w)}}getPoint(e,t){const n=t||new _,s=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=Mi(this.degree,this.knots,this.controlPoints,s);return r.w!=1&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e,t){const n=t||new _,s=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=Ci(this.degree,this.knots,this.controlPoints,s,1);return n.copy(r[1]).normalize(),n}}let L,O,U;class _i extends Ot{constructor(e){super(e)}load(e,t,n,s){const r=this,i=r.path===""?Ae.extractUrlBase(e):r.path,o=new $e(this.manager);o.setPath(r.path),o.setResponseType("arraybuffer"),o.setRequestHeader(r.requestHeader),o.setWithCredentials(r.withCredentials),o.load(e,function(a){try{t(r.parse(a,i))}catch(c){s?s(c):console.error(c),r.manager.itemError(e)}},n,s)}parse(e,t){if(ji(e))L=new Di().parse(e);else{const s=Js(e);if(!ki(s))throw new Error("THREE.FBXLoader: Unknown format.");if(rs(s)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+rs(s));L=new Oi().parse(s)}const n=new Ls(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Pi(n,this.manager).parse(L)}}class Pi{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){O=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),s=this.parseDeformers(),r=new Fi().parse(s);return this.parseScene(s,r,n),U}parseConnections(){const e=new Map;return"Connections"in L&&L.Connections.connections.forEach(function(n){const s=n[0],r=n[1],i=n[2];e.has(s)||e.set(s,{parents:[],children:[]});const o={ID:r,relationship:i};e.get(s).parents.push(o),e.has(r)||e.set(r,{parents:[],children:[]});const a={ID:s,relationship:i};e.get(r).children.push(a)}),e}parseImages(){const e={},t={};if("Video"in L.Objects){const n=L.Objects.Video;for(const s in n){const r=n[s],i=parseInt(s);if(e[i]=r.RelativeFilename||r.Filename,"Content"in r){const o=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,a=typeof r.Content=="string"&&r.Content!=="";if(o||a){const c=this.parseImage(n[s]);t[r.RelativeFilename||r.Filename]=c}}}}for(const n in e){const s=e[n];t[s]!==void 0?e[n]=t[s]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,s=n.slice(n.lastIndexOf(".")+1).toLowerCase();let r;switch(s){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),r="image/tga";break;default:console.warn('FBXLoader: Image type "'+s+'" is not supported.');return}if(typeof t=="string")return"data:"+r+";base64,"+t;{const i=new Uint8Array(t);return window.URL.createObjectURL(new Blob([i],{type:r}))}}parseTextures(e){const t=new Map;if("Texture"in L.Objects){const n=L.Objects.Texture;for(const s in n){const r=this.parseTexture(n[s],e);t.set(parseInt(s),r)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const s=e.WrapModeU,r=e.WrapModeV,i=s!==void 0?s.value:0,o=r!==void 0?r.value:0;if(n.wrapS=i===0?Se:We,n.wrapT=o===0?Se:We,"Scaling"in e){const a=e.Scaling.value;n.repeat.x=a[0],n.repeat.y=a[1]}return n}loadTexture(e,t){let n;const s=this.textureLoader.path,r=O.get(e.id).children;r!==void 0&&r.length>0&&t[r[0].ID]!==void 0&&(n=t[r[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let i;const o=e.FileName.slice(-3).toLowerCase();if(o==="tga"){const a=this.manager.getHandler(".tga");a===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),i=new be):(a.setPath(this.textureLoader.path),i=a.load(n))}else o==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),i=new be):i=this.textureLoader.load(n);return this.textureLoader.setPath(s),i}parseMaterials(e){const t=new Map;if("Material"in L.Objects){const n=L.Objects.Material;for(const s in n){const r=this.parseMaterial(n[s],e);r!==null&&t.set(parseInt(s),r)}}return t}parseMaterial(e,t){const n=e.id,s=e.attrName;let r=e.ShadingModel;if(typeof r=="object"&&(r=r.value),!O.has(n))return null;const i=this.parseParameters(e,t,n);let o;switch(r.toLowerCase()){case"phong":o=new qe;break;case"lambert":o=new Fn;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),o=new qe;break}return o.setValues(i),o.name=s,o}parseParameters(e,t,n){const s={};e.BumpFactor&&(s.bumpScale=e.BumpFactor.value),e.Diffuse?s.color=new k().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(s.color=new k().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(s.displacementScale=e.DisplacementFactor.value),e.Emissive?s.emissive=new k().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(s.emissive=new k().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(s.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(s.op
30acity=parseFloat(e.Opacity.value)),s.opacity<1&&(s.transparent=!0),e.ReflectionFactor&&(s.reflectivity=e.ReflectionFactor.value),e.Shininess&&(s.shininess=e.Shininess.value),e.Specular?s.specular=new k().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(s.specular=new k().fromArray(e.SpecularColor.value));const r=this;return O.get(n).children.forEach(function(i){const o=i.relationship;switch(o){case"Bump":s.bumpMap=r.getTexture(t,i.ID);break;case"Maya|TEX_ao_map":s.aoMap=r.getTexture(t,i.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":s.map=r.getTexture(t,i.ID),s.map!==void 0&&("colorSpace"in s.map?s.map.colorSpace="srgb":s.map.encoding=3001);break;case"DisplacementColor":s.displacementMap=r.getTexture(t,i.ID);break;case"EmissiveColor":s.emissiveMap=r.getTexture(t,i.ID),s.emissiveMap!==void 0&&("colorSpace"in s.emissiveMap?s.emissiveMap.colorSpace="srgb":s.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":s.normalMap=r.getTexture(t,i.ID);break;case"ReflectionColor":s.envMap=r.getTexture(t,i.ID),s.envMap!==void 0&&(s.envMap.mapping=Nn,"colorSpace"in s.envMap?s.envMap.colorSpace
30="srgb":s.envMap.encoding=3001);break;case"SpecularColor":s.specularMap=r.getTexture(t,i.ID),s.specularMap!==void 0&&("colorSpace"in s.specularMap?s.specularMap.colorSpace="srgb":s.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":s.alphaMap=r.getTexture(t,i.ID),s.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",o);break}}),s}getTexture(e,t){return"LayeredTexture"in L.Objects&&t in L.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=O.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in L.Objects){const n=L.Objects.Deformer;for(const s in n){const r=n[s],i=O.get(parseInt(s));if(r.attrType==="Skin"){const o=this.parseSkeleton(i,n);o.ID=s,i.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),o.geometryID=i.parents[0].ID,e[s]=o}else if(r.attrType==="BlendShape"){const o={id:s};o.rawTargets=this.parseMorphTargets(i,n),o.id=s,i.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[s]=o}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(s){const r=t[s.ID];if(r.attrType!=="Cluster")return;const i={ID:s.ID,indices:[],weights:[],transformLink:new F().fromArray(r.TransformLink.a)};"Indexes"in r&&(i.indices=r.Indexes.a,i.weights=r.Weights.a),n.push(i)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let s=0;s<e.children.length;s++){const r=e.children[s],i=t[r.ID],o={name:i.attrName,initialWeight:i.DeformPercent,id:i.id,fullWeights:i.FullWeights.a};if(i.attrType!=="BlendShapeChannel")return;o.geoID=O.get(parseInt(r.ID)).children.filter(function(a){return a.relationship===void 0})[0].ID,n.push(o)}return n}parseScene(e,t,n){U=new Re;const s=this.parseModels(e.skeletons,t,n),r=L.Objects.Model,i=this;s.forEach(function(a){const c=r[a.ID];i.setLookAtProperties(a,c),O.get(a.ID).parents.forEach(function(u){const p=s.get(u.ID);p!==void 0&&p.add(a)}),a.parent===null&&U.add(a)}),this.bindSkeleton(e.skeletons,t,s),this.createAmbientLight(),U.traverse(function(a){if(a.userData.transformData){a.parent&&(a.userData.transformData.parentMatrix=a.parent.matrix,a.userData.transformData.parentMatrixWorld=a.parent.matrixWorld);const c=Ws(a.userData.transformData);a.applyMatrix4(c),a.updateWorldMatrix()}});const o=new Ni().parse();U.children.length===1&&U.children[0].isGroup&&(U.children[0].animations=o,U=U.children[0]),U.animations=o}parseModels(e,t,n){const s=new Map,r=L.Objects.Model;for(const i in r){const o=parseInt(i),a=r[i],c=O.get(o);let h=this.buildSkeleton(c,e,o,a.attrName);if(!h){switch(a.attrType){case"Camera":h=this.createCamera(c);break;case"Light":h=this.createLight(c);break;case"Mesh":h=this.createMesh(c,t,n);break;case"NurbsCurve":h=this.createCurve(c,t);break;case"LimbNode":case"Root":h=new Et;break;case"Null":default:h=new Re;break}h.name=a.attrName?re.sanitizeNodeName(a.attrName):"",h.ID=o}this.getTransformData(h,a),s.set(o,h)}return s}buildSkeleton(e,t,n,s){let r=null;return e.parents.forEach(function(i){for(const o in t){const a=t[o];a.rawBones.forEach(function(c,h){if(c.ID===i.ID){const u=r;r=new Et,r.matrixWorld.copy(c.transformLink),r.name=s?re.sanitizeNodeName(s):"",r.ID=n,a.bones[h]=r,u!==null&&r.add(u)}})}}),r}createCamera(e){let t,n;if(e.children.forEach(function(s){const r=L.Objects.NodeAttribute[s.ID];r!==void 0&&(n=r)}),n===void 0)t=new Ee;else{let s=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(s=1);let r=1;n.NearPlane!==void 0&&(r=n.NearPlane.value/1e3);let i=1e3;n.FarPlane!==void 0&&(i=n.FarPlane.value/1e3);let o=window.innerWidth,a=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(o=n.AspectWidth.value,a=n.AspectHeight.value);const c=o/a;let h=45;n.FieldOfView!==void 0&&(h=n.FieldOfView.value);const u=n.FocalLength?n.FocalLength.value:null;switch(s){case 0:t=new Ft(h,c,r,i),u!==null&&t.setFocalLength(u);break;case 1:t=new Ps(-o/2,o/2,a/2,-a/2,r,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+s+"."),t=new Ee;break}}return t}createLight(e){let t,n;
30if(e.children.forEach(function(s){const r=L.Objects.NodeAttribute[s.ID];r!==void 0&&(n=r)}),n===void 0)t=new Ee;else{let s;n.LightType===void 0?s=0:s=n.LightType.value;let r=16777215;n.Color!==void 0&&(r=new k().fromArray(n.Color.value));let i=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(i=0);let o=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?o=0:o=n.FarAttenuationEnd.value);const a=1;switch(s){case 0:t=new wt(r,i,o,a);break;case 1:t=new Ss(r,i);break;case 2:let c=Math.PI/3;n.InnerAngle!==void 0&&(c=G.degToRad(n.InnerAngle.value));let h=0;n.OuterAngle!==void 0&&(h=G.degToRad(n.OuterAngle.value),h=Math.max(h,1)),t=new bs(r,i,o,c,h,a);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new wt(r,i);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let s,r=null,i=null;const o=[];return e.children.forEach(function(a){t.has(a.ID)&&(r=t.get(a.ID)),n.has(a.ID)&&o.push(n.get(a.ID))}),o.length>1?i=o:o.length>0?i=o[0]:(i=new qe({color:13421772}),o.push(i)),"color"in r.attributes&&o.forEach(function(a){a.vertexColors=!0}),r.FBX_Deformer?(s=new Cs(r,i),s.normalizeSkinWeights()):s=new pe(r,i),s}createCurve(e,t){const n=e.children.reduce(function(r,i){return t.has(i.ID)&&(r=t.get(i.ID)),r},null),s=new De({color:3342591,linewidth:1});return new _s(n,s)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=$s(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&O.get(e.ID).children.forEach(function(s){if(s.relationship==="LookAtProperty"){const r=L.Objects.Model[s.ID];if("Lcl_Translation"in r){const i=r.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(i),U.add(e.target)):e.lookAt(new _().fromArray(i))}}})}bindSkeleton(e,t,n){const s=this.parsePoseNodes();for(const r in e){const i=e[r];O.get(parseInt(i.ID)).parents.forEach(function(a){if(t.has(a.ID)){const c=a.ID;O.get(c).parents.forEach(function(u){n.has(u.ID)&&n.get(u.ID).bind(new Fs(i.bones),s[u.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in L.Objects){const t=L.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const s=t[n].PoseNode;Array.isArray(s)?s.forEach(function(r){e[r.Node]=new F().fromArray(r.Matrix.a)}):e[s.Node]=new F().fromArray(s.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in L&&"AmbientColor"in L.GlobalSettings){const e=L.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],s=e[2];if(t!==0||n!==0||s!==0){const r=new k(t,n,s);U.add(new On(r,1))}}}}class Fi{parse(e){const t=new Map;if("Geometry"in L.Objects){const n=L.Objects.Geometry;for(const s in n){const r=O.get(parseInt(s)),i=this.parseGeometry(r,n[s],e);t.set(parseInt(s),i)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const s=n.skeletons,r=[],i=e.parents.map(function(u){return L.Objects.Model[u.ID]});if(i.length===0)return;const o=e.children.reduce(function(u,p){return s[p.ID]!==void 0&&(u=s[p.ID]),u},null);e.children.forEach(function(u){n.morphTargets[u.ID]!==void 0&&r.push(n.morphTargets[u.ID])});const a=i[0],c={};"RotationOrder"in a&&(c.eulerOrder=$s(a.RotationOrder.value)),"InheritType"in a&&(c.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(c.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(c.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(c.scale=a.GeometricScaling.value);const h=Ws(c);return this.genGeometry(t,o,r,h)}genGeometry(e,t,n,s){const r=new me;e.attrName&&(r.name=e.attrName);const i=this.parseGeoNode(e,t),o=this.genBuffers(i),a=new W(o.vertex,3);if(a.applyMatrix4(s),r.setAttribute("position",a),o.colors.length>0&&r.setAttribute("color",new W(o.colors,3)),t&&(r.setAttribute("skinIndex",new Dn(o.weightsIndices,4)),r.setAttribute("skinWeight",new W(o.vertexWeights,4)),r.FBX_Deformer=t),o.normal.length>0){const c=new jn().getNormalMatrix(s),h=new W(o.normal,3);h.applyNormalMatrix(c),r.setAttribute("normal",h)}
30if(o.uvs.forEach(function(c,h){rr==="uv2"&&h++;const u=h===0?"uv":`uv${h}`;r.setAttribute(u,new W(o.uvs[h],2))}),i.material&&i.material.mappingType!=="AllSame"){let c=o.materialIndex[0],h=0;if(o.materialIndex.forEach(function(u,p){u!==c&&(r.addGroup(h,p-h,c),c=u,h=p)}),r.groups.length>0){const u=r.groups[r.groups.length-1],p=u.start+u.count;p!==o.materialIndex.length&&r.addGroup(p,o.materialIndex.length-p,c)}r.groups.length===0&&r.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(r,e,n,s),r}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let s=0;for(;e.LayerElementUV[s];)e.LayerElementUV[s].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[s])),s++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(s,r){s.indices.forEach(function(i,o){n.weightTable[i]===void 0&&(n.weightTable[i]=[]),n.weightTable[i].push({id:r,weight:s.weights[o]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,s=0,r=!1,i=[],o=[],a=[],c=[],h=[],u=[];const p=this;return e.vertexIndices.forEach(function(f,d){let g,x=!1;f<0&&(f=f^-1,x=!0);let T=[],A=[];if(i.push(f*3,f*3+1,f*3+2),e.color){const y=Ke(d,n,f,e.color);a.push(y[0],y[1],y[2])}if(e.skeleton){if(e.weightTable[f]!==void 0&&e.weightTable[f].forEach(function(y){A.push(y.weight),T.push(y.id)}),A.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const y=[0,0,0,0],v=[0,0,0,0];A.forEach(function(E,w){let b=E,S=T[w];v.forEach(function(P,M,j){if(b>P){j[M]=b,b=P;const V=y[M];y[M]=S,S=V}})}),T=y,A=v}for(;A.length<4;)A.push(0),T.push(0);for(let y=0;y<4;++y)h.push(A[y]),u.push(T[y])}if(e.normal){const y=Ke(d,n,f,e.normal);o.push(y[0],y[1],y[2])}e.material&&e.material.mappingType!=="AllSame"&&(g=Ke(d,n,f,e.material)[0]),e.uv&&e.uv.forEach(function(y,v){const E=Ke(d,n,f,y);c[v]===void 0&&(c[v]=[]),c[v].push(E[0]),c[v].push(E[1])}),s++,x&&(p.genFace(t,e,i,g,o,a,c,h,u,s),n++,s=0,i=[],o=[],a=[],c=[],h=[],u=[])}),t}genFace(e,t,n,s,r,i,o,a,c,h){for(let u=2;u<h;u++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[(u-1)*3]]),e.vertex.push(t.vertexPositions[n[(u-1)*3+1]]),e.vertex.push(t.vertexPositions[n[(u-1)*3+2]]),e.vertex.push(t.vertexPositions[n[u*3]]),e.vertex.push(t.vertexPositions[n[u*3+1]]),e.vertex.push(t.vertexPositions[n[u*3+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[(u-1)*4]),e.vertexWeights.push(a[(u-1)*4+1]),e.vertexWeights.push(a[(u-1)*4+2]),e.vertexWeights.push(a[(u-1)*4+3]),e.vertexWeights.push(a[u*4]),e.vertexWeights.push(a[u*4+1]),e.vertexWeights.push(a[u*4+2]),e.vertexWeights.push(a[u*4+3]),e.weightsIndices.push(c[0]),e.weightsIndices.push(c[1]),e.weightsIndices.push(c[2]),e.weightsIndices.push(c[3]),e.weightsIndices.push(c[(u-1)*4]),e.weightsIndices.push(c[(u-1)*4+1]),e.weightsIndices.push(c[(u-1)*4+2]),e.weightsIndices.push(c[(u-1)*4+3]),e.weightsIndices.push(c[u*4]),e.weightsIndices.push(c[u*4+1]),e.weightsIndices.push(c[u*4+2]),e.weightsIndices.push(c[u*4+3])),t.color&&(e.colors.push(i[0]),e.colors.push(i[1]),e.colors.push(i[2]),e.colors.push(i[(u-1)*3]),e.colors.push(i[(u-1)*3+1]),e.colors.push(i[(u-1)*3+2]),e.colors.push(i[u*3]),e.colors.push(i[u*3+1]),e.colors.push(i[u*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(s),e.materialIndex.push(s),e.materialIndex.push(s)),t.normal&&(e.normal.push(r[0]),e.normal.push(r[1]),e.normal.push(r[2]),e.normal.push(r[(u-1)*3]),e.normal.push(r[(u
30-1)*3+1]),e.normal.push(r[(u-1)*3+2]),e.normal.push(r[u*3]),e.normal.push(r[u*3+1]),e.normal.push(r[u*3+2])),t.uv&&t.uv.forEach(function(p,f){e.uvs[f]===void 0&&(e.uvs[f]=[]),e.uvs[f].push(o[f][0]),e.uvs[f].push(o[f][1]),e.uvs[f].push(o[f][(u-1)*2]),e.uvs[f].push(o[f][(u-1)*2+1]),e.uvs[f].push(o[f][u*2]),e.uvs[f].push(o[f][u*2+1])})}addMorphTargets(e,t,n,s){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const r=this;n.forEach(function(i){i.rawTargets.forEach(function(o){const a=L.Objects.Geometry[o.geoID];a!==void 0&&r.genMorphGeometry(e,t,a,s,o.name)})})}genMorphGeometry(e,t,n,s,r){const i=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],o=n.Vertices!==void 0?n.Vertices.a:[],a=n.Indexes!==void 0?n.Indexes.a:[],c=e.attributes.position.count*3,h=new Float32Array(c);for(let d=0;d<a.length;d++){const g=a[d]*3;h[g]=o[d*3],h[g+1]=o[d*3+1],h[g+2]=o[d*3+2]}const u={vertexIndices:i,vertexPositions:h},p=this.genBuffers(u),f=new W(p.vertex,3);f.name=r||n.attrName,f.applyMatrix4(s),e.morphAttributes.position.push(f)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Normals.a;let r=[];return n==="IndexToDirect"&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:s,indices:r,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.UV.a;let r=[];return n==="IndexToDirect"&&(r=e.UVIndex.a),{dataSize:2,buffer:s,indices:r,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Colors.a;let r=[];return n==="IndexToDirect"&&(r=e.ColorIndex.a),{dataSize:4,buffer:s,indices:r,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const s=e.Materials.a,r=[];for(let i=0;i<s.length;++i)r.push(i);return{dataSize:1,buffer:s,indices:r,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(ss===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new me;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new me;const n=t-1,s=e.KnotVector.a,r=[],i=e.Points.a;for(let u=0,p=i.length;u<p;u+=4)r.push(new Je().fromArray(i,u));let o,a;if(e.Form==="Closed")r.push(r[0]);else if(e.Form==="Periodic"){o=n,a=s.length-1-o;for(let u=0;u<n;++u)r.push(r[u])}const h=new ss(n,s,r,o,a).getPoints(r.length*12);return new me().setFromPoints(h)}}class Ni{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const s=t[n],r=this.addClip(s);e.push(r)}return e}parseClips(){if(L.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=L.Objects.AnimationCurveNode,t=new Map;for(const n in e){const s=e[n];if(s.attrName.match(/S|R|T|DeformPercent/)!==null){const r={id:s.id,attr:s.attrName,curves:{}};t.set(r.id,r)}}return t}parseAnimationCurves(e){const t=L.Objects.AnimationCurve;for(const n in t){const s={id:t[n].id,times:t[n].KeyTime.a.map(Bi),values:t[n].KeyValueFloat.a},r=O.get(s.id);if(r!==void 0){const i=r.parents[0].ID,o=r.parents[0].relationship;o.match(/X/)?e.get(i).curves.x=s:o.match(/Y/)?e.get(i).curves.y=s:o.match(/Z/)?e.get(i).curves.z=s:o.match(/d|DeformPercent/)&&e.has(i)&&(e.get(i).curves.morph=s)}}}parseAnimationLayers(e){const t=L.Objects.AnimationLayer,n=new Map;for(const s in t){const r=[],i=O.get(parseInt(s));i!==void 0&&(i.children.forEach(function(a,c){if(e.has(a.ID)){const h=e.get(a.ID);if(h.curves.x!==void 0||h.curves.y!==void 0||h.curves.z!==void 0){if(r[c]===void 0){const u=O.get(a.ID).parents.filter(function(p){return p.relationship!==void 0})[0].ID;if(u!==void 0){const p=L.Objects.Model[u.toString()];if(p===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",a);return}const f={modelName:p.attrName?re.sanitizeNodeName(p.attrName):"",ID:p.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};U.traverse(function(d){d.ID===p.id&&(f.transform=d.matrix,d.userData.transformData&&(f.eulerOrder=d.userData.transformData.eulerOrder))}),f.transform||(f.transform=new F),"PreRotation"in p&&(f.preRotation=p.PreRotation.value),"PostRotation"in p&&(f.postRotation=p.PostRotation.value),r[c]=f}}r[c]&&(r[c][h.attr]=h)}else if(h.curves.morph!==void 0){if(r[c]===void 0){const u=O.get(a.ID).parents.filter(function(T){return T.relationship!==void 0})[0].ID,p=O.get(u).parents[0].ID,f=O.get(p).parents[0].ID,d=O.get(f).parents[0].ID,g=L.Objects.Model[d],x={modelName:g.attrName?re.sanitizeNodeName(g.attrName):"",morphName:L.Objects.Deformer[u].attrName};r[c]=x}r[c][h.attr]=h}}}),n.set(parseInt(s),r))}return n}parseAnimStacks(e){const t=L.Objects.AnimationStack,n={};for(const s in t){const r=O.get(parseInt(s)).children;r.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const i=e.get(r[0].ID);n[s]={name:t[s].attrName,layer:i}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(s){t=t.concat(n.generateTracks(s))}),new Ns(e.name,-1,t)}generateTracks(e){const t=[];let n=new _,s=new ue,r=new _;if(e.transform&&e.transform.decompose(n,s,r),n=n.toArray(),s=new Fe().setFromQuaternion(s,e.eulerOrder).toArray(),r=r.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");i!==void 0&&t.push(i)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const i=this.generateRotationTrack(e.modelName,e.R.curves,s,e.preRotation,e.postRotation,e.eulerOrder);i!==void 0&&t.push(i)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");i!==void 0&&t.push(i)}if(e.DeformPercent!==void 0){const i=this.generateMorphTrack(e);i!==void 0&&t.push(i)}return t}generateVectorTrack(e,t,n,s){const r=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(r,t,n);return new Rt(e+"."+s,r,i)}generateRotationTrack(e,t,n,s,r,i){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(G.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(G.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(G.degToRad));const o=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(o,t,n);s!==void 0&&(s=s.map(G.degToRad),s.push(i),s=new Fe().fromArray(s),s=new ue().setFromEuler(s)),r!==void 0&&(r=r.map(G.degToRad),r.push(i),r=new Fe().fromArray(r),r=new ue().setFromEuler(r).invert());const c=new ue,h=new Fe,u=[];for(let p=0;p<a.length;p+=3)h.set(a[p],a[p+1],a[p+2],i),c.setFromEuler(h),s!==void 0&&c.premultiply(s),r!==void 0&&c.multiply(r),c.toArray(u,p/3*4);return new bt(e+".quaternion",o,u)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(r){return r/100}),s=U.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new Mt(e.modelName+".morphTargetInfluences["+s+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,s){return n-s}),t.length>1){let n=1,s=t[0];for(let r=1;r<t.length;r++){const i=t[r];
30i!==s&&(t[n]=i,s=i,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const s=n,r=[];let i=-1,o=-1,a=-1;return e.forEach(function(c){if(t.x&&(i=t.x.times.indexOf(c)),t.y&&(o=t.y.times.indexOf(c)),t.z&&(a=t.z.times.indexOf(c)),i!==-1){const h=t.x.values[i];r.push(h),s[0]=h}else r.push(s[0]);if(o!==-1){const h=t.y.values[o];r.push(h),s[1]=h}else r.push(s[1]);if(a!==-1){const h=t.z.values[a];r.push(h),s[2]=h}else r.push(s[2])}),r}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],s=e.values[t]-n,r=Math.abs(s);if(r>=180){const i=r/180,o=s/i;let a=n+o;const c=e.times[t-1],u=(e.times[t]-c)/i;let p=c+u;const f=[],d=[];for(;p<e.times[t];)f.push(p),p+=u,d.push(a),a+=o;e.times=is(e.times,t,f),e.values=is(e.values,t,d)}}}}class Oi{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new qs,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(s,r){const i=s.match(/^[\s\t]*;/),o=s.match(/^[\s\t]*$/);if(i||o)return;const a=s.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),c=s.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),h=s.match("^\\t{"+(t.currentIndent-1)+"}}");a?t.parseNodeBegin(s,a):c?t.parseNodeProperty(s,c,n[++r]):h?t.popStack():s.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(s)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),s=t[2].split(",").map(function(a){return a.trim().replace(/^"/,"").replace(/"$/,"")}),r={name:n},i=this.parseNodeAttr(s),o=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,r):n in o?(n==="PoseNode"?o.PoseNode.push(r):o[n].id!==void 0&&(o[n]={},o[n][o[n].id]=o[n]),i.id!==""&&(o[n][i.id]=r)):typeof i.id=="number"?(o[n]={},o[n][i.id]=r):n!=="Properties70"&&(n==="PoseNode"?o[n]=[r]:o[n]=r),typeof i.id=="number"&&(r.id=i.id),i.name!==""&&(r.attrName=i.name),i.type!==""&&(r.attrType=i.type),this.pushStack(r)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",s="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),s=e[2]),{id:t,name:n,type:s}}parseNodeProperty(e,t,n){let s=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();s==="Content"&&r===","&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if(i.name==="Properties70"){this.parseNodeSpecialProperty(e,s,r);return}if(s==="C"){const a=r.split(",").slice(1),c=parseInt(a[0]),h=parseInt(a[1]);let u=r.split(",").slice(3);u=u.map(function(p){return p.trim().replace(/^"/,"")}),s="connections",r=[c,h],Ui(r,u),i[s]===void 0&&(i[s]=[])}s==="Node"&&(i.id=r),s in i&&Array.isArray(i[s])?i[s].push(r):s!=="a"?i[s]=r:i.a=r,this.setCurrentProp(i,s),s==="a"&&r.slice(-1)!==","&&(i.a=pt(r))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=pt(t.a))}parseNodeSpecialProperty(e,t,n){const s=n.split('",').map(function(h){return h.trim().replace(/^\"/,"").replace(/\s/,"_")}),r=s[0],i=s[1],o=s[2],a=s[3];let c=s[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":c=parseFloat(c);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":c=pt(c);break}this.getPrevNode()[r]={type:i,type2:o,flag:a,value:c},this.setCurrentProp(this.getPrevNode(),r)}}class Di{parse(e){const t=new ns(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const s=new qs;for(;!this.endOfContent(t);){const r=this.parseNode(t,n);r!==null&&s.add(r.name,r)}return s}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},s=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const i=e.getUint8(),o=e.getString(i);if(s===0)return null;const a=[];for(let p=0;p<r;p++)a.push(this.parseProperty(e));const c=a.length>0?a[0]:"",h=a.length>1?a[1]:"",u=a.length>2?a[2]:"";for(n.singleProperty=r===1&&e.getOffset()===s;s>e.getOffset();){const p=this.parseNode(e,t);p!==null&&this.parseSubNode(o,n,p)}return n.propertyList=a,typeof c=="number"&&(n.id=c),h!==""&&(n.attrName=h),u!==""&&(n.attrType=u),o!==""&&(n.name=o),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const s=n.propertyList[0];Array.isArray(s)?(t[n.name]=n,n.a=s):t[n.name]=s}else if(e==="Connections"&&n.name==="C"){const s=[];n.propertyList.forEach(function(r,i){i!==0&&s.push(r)}),t.connections===void 0&&(t.connections=[]),t.connections.push(s)}
30else if(n.name==="Properties70")Object.keys(n).forEach(function(r){t[r]=n[r]});else if(e==="Properties70"&&n.name==="P"){let s=n.propertyList[0],r=n.propertyList[1];const i=n.propertyList[2],o=n.propertyList[3];let a;s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),r.indexOf("Lcl ")===0&&(r=r.replace("Lcl ","Lcl_")),r==="Color"||r==="ColorRGB"||r==="Vector"||r==="Vector3D"||r.indexOf("Lcl_")===0?a=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:a=n.propertyList[4],t[s]={type:r,type2:i,flag:o,value:a}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const s=e.getUint32(),r=e.getUint32(),i=e.getUint32();if(r===0)switch(t){case"b":case"c":return e.getBooleanArray(s);case"d":return e.getFloat64Array(s);case"f":return e.getFloat32Array(s);case"i":return e.getInt32Array(s);case"l":return e.getInt64Array(s)}const o=Br(new Uint8Array(e.getArrayBuffer(i))),a=new ns(o.buffer);switch(t){case"b":case"c":return a.getBooleanArray(s);case"d":return a.getFloat64Array(s);case"f":return a.getFloat32Array(s);case"i":return a.getInt32Array(s);case"l":return a.getInt64Array(s)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class ns{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let s=0;s<e;s++)t[s]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),Ie(new Uint8Array(t))}}class qs{add(e,t){this[e]=t}}function ji(l){const e="Kaydara FBX Binary \0";return l.byteLength>=e.length&&e===Js(l,0,e.length)}function ki(l){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(s){const r=l[s-1];return l=l.slice(t+s),t++,r}for(let s=0;s<e.length;++s)if(n(1)===e[s])return!1;return!0}function rs(l){const e=/FBXVersion: (\d+)/,t=l.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Bi(l){return l/46186158e3}const Gi=[];function Ke(l,e,t,n){let s;switch(n.mappingType){case"ByPolygonVertex":s=l;break;case"ByPolygon":s=e;break;
30case"ByVertice":s=t;break;case"AllSame":s=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(s=n.indices[s]);const r=s*n.dataSize,i=r+n.dataSize;return zi(Gi,n.buffer,r,i)}const ht=new Fe,ve=new _;function Ws(l){const e=new F,t=new F,n=new F,s=new F,r=new F,i=new F,o=new F,a=new F,c=new F,h=new F,u=new F,p=new F,f=l.inheritType?l.inheritType:0;if(l.translation&&e.setPosition(ve.fromArray(l.translation)),l.preRotation){const M=l.preRotation.map(G.degToRad);M.push(l.eulerOrder),t.makeRotationFromEuler(ht.fromArray(M))}if(l.rotation){const M=l.rotation.map(G.degToRad);M.push(l.eulerOrder),n.makeRotationFromEuler(ht.fromArray(M))}if(l.postRotation){const M=l.postRotation.map(G.degToRad);M.push(l.eulerOrder),s.makeRotationFromEuler(ht.fromArray(M)),s.invert()}l.scale&&r.scale(ve.fromArray(l.scale)),l.scalingOffset&&o.setPosition(ve.fromArray(l.scalingOffset)),l.scalingPivot&&i.setPosition(ve.fromArray(l.scalingPivot)),l.rotationOffset&&a.setPosition(ve.fromArray(l.rotationOffset)),l.rotationPivot&&c.setPosition(ve.fromArray(l.rotationPivot)),l.parentMatrixWorld&&(u.copy(l.parentMatrix),h.copy(l.parentMatrixWorld));const d=t.clone().multiply(n).multiply(s),g=new F;g.extractRotation(h);const x=new F;x.copyPosition(h);const T=x.clone().invert().multiply(h),A=g.clone().invert().multiply(T),y=r,v=new F;if(f===0)v.copy(g).multiply(d).multiply(A).multiply(y);else if(f===1)v.copy(g).multiply(A).multiply(d).multiply(y);else{const j=new F().scale(new _().setFromMatrixScale(u)).clone().invert(),V=A.clone().multiply(j);v.copy(g).multiply(d).multiply(V).multiply(y)}const E=c.clone().invert(),w=i.clone().invert();let b=e.clone().multiply(a).multiply(c).multiply(t).multiply(n).multiply(s).multiply(E).multiply(o).multiply(i).multiply(r).multiply(w);const S=new F().copyPosition(b),P=h.clone().multiply(S);return p.copyPosition(P),b=p.clone().multiply(v),b.premultiply(h.invert()),b}function $s(l){l=l||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return l===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[l]}function pt(l){return l.split(",").map(function(t){return parseFloat(t)})}function Js(l,e,t){return e===void 0&&(e=0),t===void 0&&(t=l.byteLength),Ie(new Uint8Array(l,e,t))}function Ui(l,e){for(let t=0,n=l.length,s=e.length;t<s;t++,n++)l[n]=e[t]}function zi(l,e,t,n){for(let s=t,r=0;s<n;s++,r++)l[r]=e[s];return l}function is(l,e,t){return l.slice(0,e).concat(t).concat(l.slice(e))}const Hi=/^[og]\s*(.+)?/,Vi=/^mtllib /,Xi=/^usemtl /,Ki=/^usemap /,os=new _,ft=new _,as=new _,cs=new _,K=new _;function Yi(){const l={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,r){const i=this._finalize(!1);i&&(i.inherited||i.groupCount<=0)&&this.materials.splice(i.index,1);const o={index:this.materials.length,name:s||"",mtllib:Array.isArray(r)&&r.length>0?r[r.length-1]:"",smooth:i!==void 0?i.smooth:this.smooth,groupStart:i!==void 0?i.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(a){const c={index:typeof a=="number"?a:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return c.clone=this.clone.bind(c),c}};return this.materials.push(o),o},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(s){const r=this.currentMaterial();if(r&&r.groupEnd===-1&&(r.groupEnd=this.geometry.vertices.length/3,r.groupCount=r.groupEnd-r.groupStart,r.inherited=!1),s&&this.materials.length>1)for(let i=this.materials.length-1;i>=0;i--)this.materials[i].groupCount<=0&&this.materials.splice(i,1);return s&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),r}},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,r=this.object.geometry.vertices;r.push(s[e+0],s[e+1],s[e+2]),r.push(s[t+0],s[t+1],s[t+2]),r.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,r=this.object.geometry.normals;r.push(s[e+0],s[e+1],s[e+2]),r.push(s[t+0],s[t+1],s[t+2]),r.push(s[n+0],s[n+1],s[n+2])},addFaceNormal:function(e,t,n){const s=this.vertices,r=this.object.geometry.normals;os.fromArray(s,e),ft.fromArray(s,t),as.fromArray(s,n),K.subVectors(as,ft),cs.subVectors(os,ft),K.cross(cs),K.normalize(),r.push(K.x,K.y,K.z),r.push(K.x,K.y,K.z),r.push(K.x,K.y,K.z)},addColor:function(e,t,n){const s=this.colors,r=this.object.geometry.colors;s[e]!==void 0&&r.push(s[e+0],s[e+1],s[e+2]),s[t]!==void 0&&r.push(s[t+0],s[t+1],s[t+2]),s[n]!==void 0&&r.push(s[n+0],s[n+1],s[n+2])},addUV:function(e,t,n){const s=this.uvs,r=this.object.geometry.uvs;r.push(s[e+0],s[e+1]),r.push(s[t+0],s[t+1]),r.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,r,i,o,a,c){const h=this.vertices.length;let u=this.parseVertexIndex(e,h),p=this.parseVertexIndex(t,h),f=this.parseVertexIndex(n,h);
30if(this.addVertex(u,p,f),this.addColor(u,p,f),o!==void 0&&o!==""){const d=this.normals.length;u=this.parseNormalIndex(o,d),p=this.parseNormalIndex(a,d),f=this.parseNormalIndex(c,d),this.addNormal(u,p,f)}else this.addFaceNormal(u,p,f);if(s!==void 0&&s!==""){const d=this.uvs.length;u=this.parseUVIndex(s,d),p=this.parseUVIndex(r,d),f=this.parseUVIndex(i,d),this.addUV(u,p,f),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 r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const n=this.vertices.length,s=this.uvs.length;for(let r=0,i=e.length;r<i;r++)this.addVertexLine(this.parseVertexIndex(e[r],n));for(let r=0,i=t.length;r<i;r++)this.addUVLine(this.parseUVIndex(t[r],s))}};return l.startObject("",!1),l}class qi extends Ot{constructor(e){super(e),this.materials=null}load(e,t,n,s){const r=this,i=new $e(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(o){try{t(r.parse(o))}catch(a){s?s(a):console.error(a),r.manager.itemError(e)}},n,s)}setMaterials(e){return this.materials=e,this}parse(e){const t=new Yi;e.indexOf(`\r 31`)!==-1&&(e=e.replace(/\r\n/g,` 32`)),e.indexOf(`\\ 33`)!==-1&&(e=e.replace(/\\\n/g,""));const n=e.split(` 34`);let s="",r="",i=0,o=[];const a=typeof"".trimLeft=="function";for(let u=0,p=n.length;u<p;u++)if(s=n[u],s=a?s.trimLeft():s.trim(),i=s.length,i!==0&&(r=s.charAt(0),r!=="#"))if(r==="v"){const f=s.split(/\s+/);switch(f[0]){case"v":t.vertices.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),f.length>=7?t.colors.push(parseFloat(f[4]),parseFloat(f[5]),parseFloat(f[6])):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3]));break;case"vt":t.uvs.push(parseFloat(f[1]),parseFloat(f[2]));break}}else if(r==="f"){const d=s.substr(1).trim().split(/\s+/),g=[];for(let T=0,A=d.length;T<A;T++){const y=d[T];if(y.length>0){const v=y.split("/");g.push(v)}}const x=g[0];for(let T=1,A=g.length-1;T<A;T++){const y=g[T],v=g[T+1];t.addFace(x[0],y[0],v[0],x[1],y[1],v[1],x[2],y[2],v[2])}}else if(r==="l"){const f=s.substring(1).trim().split(" ");let d=[];const g=[];if(s.indexOf("/")===-1)d=f;else for(let x=0,T=f.length;x<T;x++){const A=f[x].split("/");A[0]!==""&&d.push(A[0]),A[1]!==""&&g.push(A[1])}t.addLineGeometry(d,g)}else if(r==="p"){const d=s.substr(1).trim().split(" ");t.addPointGeometry(d)}else if((o=Hi.exec(s))!==null){const f=(" "+o[0].substr(1).trim()).substr(1);t.startObject(f)}else if(Xi.test(s))t.object.startMaterial(s.substring(7).trim(),t.materialLibraries);else if(Vi.test(s))t.materialLibraries.push(s.substring(7).trim());else if(Ki.test(s))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(r==="s"){if(o=s.split(" "),o.length>1){const d=o[1].trim().toLowerCase();t.object.smooth=d!=="0"&&d!=="off"}else t.object.smooth=!0;const f=t.object.currentMaterial();f&&(f.smooth=t.object.smooth)}else{if(s==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+s+'"')}t.finalize();const c=new Re;if(c.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let u=0,p=t.objects.length;u<p;u++){const f=t.objects[u],d=f.geometry,g=f.materials,x=d.type==="Line",T=d.type==="Points";let A=!1;if(d.vertices.length===0)continue;const y=new me;y.setAttribute("position",new W(d.vertices,3)),d.normals.length>0&&y.setAttribute("normal",new W(d.normals,3)),d.colors.length>0&&(A=!0,y.setAttribute("color",new W(d.colors,3))),d.hasUVIndices===!0&&y.setAttribute("uv",new W(d.uvs,2));const v=[];for(let w=0,b=g.length;w<b;w++){const S=g[w],P=S.name+"_"+S.smooth+"_"+A;let M=t.materials[P];if(this.materials!==null){if(M=this.materials.create(S.name),x&&M&&!(M instanceof De)){const j=new De;Oe.prototype.copy.call(j,M),j.color.copy(M.color),M=j}else if(T&&M&&!(M instanceof Pe)){const j=new Pe({size:10,sizeAttenuation:!1});Oe.prototype.copy.call(j,M),j.color.copy(M.color),j.map=M.map,M=j}}
34M===void 0&&(x?M=new De:T?M=new Pe({size:1,sizeAttenuation:!1}):M=new qe,M.name=S.name,M.flatShading=!S.smooth,M.vertexColors=A,t.materials[P]=M),v.push(M)}let E;if(v.length>1){for(let w=0,b=g.length;w<b;w++){const S=g[w];y.addGroup(S.groupStart,S.groupCount,w)}x?E=new At(y,v):T?E=new Ye(y,v):E=new pe(y,v)}else x?E=new At(y,v[0]):T?E=new Ye(y,v[0]):E=new pe(y,v[0]);E.name=f.name,c.add(E)}else if(t.vertices.length>0){const u=new Pe({size:1,sizeAttenuation:!1}),p=new me;p.setAttribute("position",new W(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(p.setAttribute("color",new W(t.colors,3)),u.vertexColors=!0);const f=new Ye(p,u);c.add(f)}return c}}function Wi(l,e,t,n){const s=class extends Ts{constructor(i={}){const o=Object.entries(l);super({uniforms:o.reduce((a,[c,h])=>{const u=kn.clone({[c]:{value:h}});return{...a,...u}},{}),vertexShader:e,fragmentShader:t}),this.key="",o.forEach(([a])=>Object.defineProperty(this,a,{get:()=>this.uniforms[a].value,set:c=>this.uniforms[a].value=c})),Object.assign(this,i)}};return s.key=G.generateUUID(),s}const $i=()=>parseInt(gs.replace(/\D+/g,"")),Ji=$i();function Zi(l,e,t){const n=J(p=>p.size),s=J(p=>p.viewport),r=typeof l=="number"?l:n.width*s.dpr,i=n.height*s.dpr,o=(typeof l=="number"?t:l)||{},{samples:a=0,depth:c,...h}=o,u=R.useMemo(()=>{const p=new Bn(r,i,{minFilter:Be,magFilter:Be,type:Gn,...h});return c&&(p.depthTexture=new Un(r,i,zn)),p.samples=a,p},[]);return R.useLayoutEffect(()=>{u.setSize(r,i),a&&(u.samples=a)},[a,u,r,i]),R.useEffect(()=>()=>u.dispose(),[]),u}const Qi=l=>typeof l=="function",eo=R.forwardRef(({envMap:l,resolution:e=256,frames:t=1/0,children:n,makeDefault:s,...r},i)=>{const o=J(({set:x})=>x),a=J(({camera:x})=>x),c=J(({size:x})=>x),h=R.useRef(null);R.useImperativeHandle(i,()=>h.current,[]);const u=R.useRef(null),p=Zi(e);R.useLayoutEffect(()=>{r.manual||h.current.updateProjectionMatrix()},[c,r]),R.useLayoutEffect(()=>{h.current.updateProjectionMatrix()}),R.useLayoutEffect(()=>{if(s){const x=a;return o(()=>({camera:h.current})),()=>o(()=>({camera:x}))}},[h,s,o]);let f=0,d=null;const g=Qi(n);return Ge(x=>{g&&(t===1/0||f<t)&&(u.current.visible=!1,x.gl.setRenderTarget(p),d=x.scene.background,l&&(x.scene.background=l),x.gl.render(x.scene,h.current),x.scene.background=d,x.gl.setRenderTarget(null),u.current.visible=!0,f++)}),R.createElement(R.Fragment,null,R.createElement("orthographicCamera",Q({left:c.width/-2,right:c.width/2,top:c.height/2,bottom:c.height/-2,ref:h},r),!g&&n),R.createElement("group",{ref:u},g&&n(p.texture)))});function to({defaultScene:l,defaultCamera:e,renderPriority:t=1}){const{gl:n,scene:s,camera:r}=J();let i;return Ge(()=>{i=n.autoClear,t===1&&(n.autoClear=!0,n.render(l,e)),n.autoClear=!1,n.clearDepth(),n.render(s,r),n.autoClear=i},t),R.createElement("group",{onPointerOver:()=>null})}function so({children:l,renderPriority:e=1}){const{scene:t,camera:n}=J(),[s]=R.useState(()=>new ke);return R.createElement(R.Fragment,null,Hn(R.createElement(R.Fragment,null,l,R.createElement(to,{defaultScene:t,defaultCamera:n,renderPriority:e})),s,{events:{priority:e+1}}))}const Zs=R.createContext({}),no=()=>R.useContext(Zs),ro=2*Math.PI,dt=new Ee,ls=new F,[Te,mt]=[new ue,new ue],us=new _,hs=new _,io=l=>"minPolarAngle"in l,ps=l=>"getTarget"in l,oo=({alignment:l="bottom-right",margin:e=[80,80],renderPri
34ority:t=1,onUpdate:n,onTarget:s,children:r})=>{const i=J(w=>w.size),o=J(w=>w.camera),a=J(w=>w.controls),c=J(w=>w.invalidate),h=R.useRef(null),u=R.useRef(null),p=R.useRef(!1),f=R.useRef(0),d=R.useRef(new _(0,0,0)),g=R.useRef(new _(0,0,0));R.useEffect(()=>{g.current.copy(o.up),dt.up.copy(o.up)},[o]);const x=R.useCallback(w=>{p.current=!0,(a||s)&&(d.current=(s==null?void 0:s())||(ps(a)?a.getTarget(d.current):a==null?void 0:a.target)),f.current=o.position.distanceTo(us),Te.copy(o.quaternion),hs.copy(w).multiplyScalar(f.current).add(us),dt.lookAt(hs),mt.copy(dt.quaternion),c()},[a,o,s,c]);Ge((w,b)=>{if(u.current&&h.current){var S;if(p.current)if(Te.angleTo(mt)<.01)p.current=!1,io(a)&&o.up.copy(g.current);else{const P=b*ro;Te.rotateTowards(mt,P),o.position.set(0,0,1).applyQuaternion(Te).multiplyScalar(f.current).add(d.current),o.up.set(0,1,0).applyQuaternion(Te).normalize(),o.quaternion.copy(Te),ps(a)&&a.setPosition(o.position.x,o.position.y,o.position.z),n?n():a&&a.update(b),c()}ls.copy(o.matrix).invert(),(S=h.current)==null||S.quaternion.setFromRotationMatrix(ls)}});const T=R.useMemo(()=>({tweenCamera:x}),[x]),[A,y]=e,v=l.endsWith("-center")?0:l.endsWith("-left")?-i.width/2+A:i.width/2-A,E=l.startsWith("center-")?0:l.startsWith("top-")?i.height/2-y:-i.height/2+y;return R.createElement(so,{renderPriority:t},R.createElement(Zs.Provider,{value:T},R.createElement(eo,{makeDefault:!0,ref:u,position:[0,0,200]}),R.createElement("group",{ref:h,position:[v,E,0]},r)))};function gt({scale:l=[.8,.05,.05],color:e,rotation:t}){return R.createElement("group",{rotation:t},R.createElement("mesh",{position:[.4,0,0]},R.createElement("boxGeometry",{args:l}),R.createElement("meshBasicMaterial",{color:e,toneMapped:!1})))}function we({onClick:l,font:e,disabled:t,arcStyle:n,label:s,labelColor:r,axisHeadScale:i=1,...o}){const a=J(g=>g.gl),c=R.useMemo(()=>{const g=document.createElement("canvas");g.width=64,g.height=64;const x=g.getContext("2d");return x.beginPath(),x.arc(32,32,16,0,2*Math.PI),x.closePath(),x.fillStyle=n,x.fill(),s&&(x.font=e,x.textAlign="center",x.fillStyle=r,x.fillText(s,32,41)),new Vn(g)},[n,s,r,e]),[h,u]=R.useState(!1),p=(s?1:.75)*(h?1.2:1)*i,f=g=>{g.stopPropagation(),u(!0)},d=g=>{g.stopPropagation(),u(!1)};return R.createElement("sprite",Q({scale:p,onPointerOver:t?void 0:f,onPointerOut:t?void 0:l||d},o),R.createElement("spriteMaterial",{map:c,"map-anisotropy":a.capabilities.getMaxAnisotropy()||1,alphaTest:.3,opacity:s?1:.75,toneMapped:!1}))}const ao=({hideNegativeAxes:l,hideAxisHeads:e,disabled:t,font:n="18px Inter var, Arial, sans-serif",axisColors:s=["#ff2060","#20df80","#2080ff"],axisHeadScale:r=1,axisScale:i,labels:o=["X","Y","Z"],labelColor:a="#000",onClick:c,...h})=>{const[u,p,f]=s,{tweenCamera:d}=no(),g={font:n,disabled:t,labelColor:a,onClick:c,axisHeadScale:r,onPointerDown:t?void 0:x=>{d(x.object.position),x.stopPropagation()}};return R.createElement("group",Q({scale:40},h),R.createElement(gt,{color:u,rotation:[0,0,0],scale:i}),R.createElement(gt,{color:p,rotation:[0,0,Math.PI/2],scale:i}),R.createElement(gt,{color:f,rotation:[0,-Math.PI/2,0],scale:i}),!e&&R.createElement(R.Fragment,null,R.createElement(we,Q({arcStyle:u,position:[1,0,0],label:o[0]},g)),R.createElement(we,Q({arcStyle:p,position:[0,1,0],label:o[1]},g)),R.createElement(we,Q({arcStyle:f,position:[0,0,1],label:o[2]},g)),!l&&R.createElement(R.Fragment,null,R.createElement(we,Q({arcStyle:u,position:[-1,0,0]},g)),R.createElement(we,Q({arcStyle:p,position:[0,-1,0]},g)),R.createElement(we,Q({arcStyle:f,position:[0,0,-1]},g)))))},co=Wi({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,fadeFrom:1,cellThickness:.5,sectionThickness:1,cellColor:new k,sectionColor:new k,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new _,worldPlanePosition:new _},` 35 varying vec3 localPosition; 36 varying vec4 worldPosition; 37 38 uniform vec3 worldCamProjPosition; 39 uniform vec3 worldPlanePosition; 40 uniform float fadeDistance; 41 uniform bool infiniteGrid; 42 uniform bool followCamera; 43 44 void main() { 45 localPosition = position.xzy; 46 if (infiniteGrid) localPosition *= 1.0 + fadeDistance; 47
48 worldPosition = modelMatrix * vec4(localPosition, 1.0); 49 if (followCamera) { 50 worldPosition.xyz += (worldCamProjPosition - worldPlanePosition); 51 localPosition = (inverse(modelMatrix) * worldPosition).xyz; 52 } 53 54 gl_Position = projectionMatrix * viewMatrix * worldPosition; 55 } 56 `,` 57 varying vec3 localPosition; 58 varying vec4 worldPosition; 59 60 uniform vec3 worldCamProjPosition; 61 uniform float cellSize; 62 uniform float sectionSize; 63 uniform vec3 cellColor; 64 uniform vec3 sectionColor; 65 uniform float fadeDistance; 66 uniform float fadeStrength; 67 uniform float fadeFrom; 68 uniform float cellThickness; 69 uniform float sectionThickness; 70 71 float getGrid(float size, float thickness) { 72 vec2 r = localPosition.xz / size; 73 vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r); 74 float line = min(grid.x, grid.y) + 1.0 - thickness; 75 return 1.0 - min(line, 1.0); 76 } 77 78 void main() { 79 float g1 = getGrid(cellSize, cellThickness); 80 float g2 = getGrid(sectionSize, sectionThickness); 81 82 vec3 from = worldCamProjPosition*vec3(fadeFrom); 83 float dist = distance(from, worldPosition.xyz); 84 float d = 1.0 - min(dist / fadeDistance, 1.0); 85 vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2)); 86 87 gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength)); 88 gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2); 89 if (gl_FragColor.a <= 0.0) discard; 90 91 #include <tonemapping_fragment> 92 #include <${Ji>=154?"colorspace_fragment":"encodings_fragment"}> 93 } 94 `),lo=R.forwardRef(({args:l,cellColor:e="#000000",sectionColor:t="#2080ff",cellSize:n=.5,sectionSize:s=1,followCamera:r=!1,infiniteGrid:i=!1,fadeDistance:o=100,fadeStrength:a=1,fadeFrom:c=1,cellThickness:h=.5,sectionThickness:u=1,side:p=Yn,...f},d)=>{Xn({GridMaterial:co});const g=R.useRef(null);R.useImperativeHandle(d,()=>g.current,[]);const x=new Kn,T=new _(0,1,0),A=new _(0,0,0);Ge(E=>{x.setFromNormalAndCoplanarPoint(T,A).applyMatrix4(g.current.matrixWorld);const w=g.current.material,b=w.uniforms.worldCamProjPosition,S=w.uniforms.worldPlanePosition;x.projectPoint(E.camera.position,b.value),S.value.set(0,0,0).applyMatrix4(g.current.matrixWorld)});const y={cellSize:n,sectionSize:s,cellColor:e,sectionColor:t,cellThickness:h,sectionThickness:u},v={fadeDistance:o,fadeStrength:a,fadeFrom:c,infiniteGrid:i,followCamera:r};return R.createElement("mesh",Q({ref:g,frustumCulled:!1},f),R.createElement("gridMaterial",Q({transparent:!0,"extensions-derivatives":!0,side:p},y,v)),R.createElement("planeGeometry",{args:l}))});function uo({object:l,isSelected:e,onSelect:t,onTransform:n}){const s=R.useRef(null);Ge(()=>{s.current&&l.rotation&&(s.current.rotation.x=l.rotation.x||0,s.current.rotation.y=l.rotation.y||0,s.current.rotation.z=l.rotation.z||0)});const r=o=>{o.stopPropagation(),t(l.id)},i=()=>{switch(l.type){case"box":return m.jsx("boxGeometry",{args:[1,1,1]});case"sphere":return m.jsx("sphereGeometry",{args:[.5,32,32]});case"cylinder":return m.jsx("cylinderGeometry",{args:[.5,.5,1,32]});case"plane":return m.jsx("planeGeometry",{args:[2,2]});default:return m.jsx("boxGeometry",{args:[1,1,1]})}};return m.jsxs("mesh",{ref:s,position:[l.position.x,l.position.y,l.position.z],scale:[l.scale.x,l.scale.y,l.scale.z],onClick:r,children:[i(),m.jsx("meshStandardMaterial",{color:e?"#4f46e5":l.color||"#888888",wireframe:l.wireframe||!1})]})}function ho({objects:l,selectedObjectId:e,onObjectSelect:t,onObjectTransform:n}){return m.jsx("div",{className:"w-full h-full bg-zinc-900",children:m.jsxs(qn,{camera:{position:[5,5,5],fov:50},shadows:!0,gl:{preserveDrawingBuffer:!0},style:{background:"#1a1a1a"},children:[m.jsx("ambientLight",{intensity:.4}),m.jsx("directionalLight",{position:[10,10,5],intensity:1,castShadow:!0}),m.jsx("pointLight",{position:[-10,-10,-5],intensity:.5}),m.jsx(lo,{cellSize:1,cellThickness:.5,cellColor:"#444444",sectionSize:5,sectionThickness:1,sectionColor:"#666666",fadeDistance:50,fadeStrength:1,infiniteGrid:!0}),l.map(s=>m.jsx(uo,{object:s,isSelected:s.id===e,onSelect:t,onTransform:n},s.id)),m.jsx(Wn,{makeDefault:!0}),m.jsx(oo,{alignment:"bottom-right",margin:[80,80],children:m.jsx(ao,{axisColors:["#ff0000","#00ff00","#0000ff"],labelColor:"white"})})]})})}function po({onAddObject:l,onDeleteSelected:e,transformMode:t,onTransformModeChange:n,hasSelection:s}){return m.jsx("div",{className:"flex items-center gap-2 p-2 bg-card border-b",children:m.jsxs(tn,{children:[m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsxs(ie,{children:[m.jsx(oe,{asChild:!0,children:m.jsx(q,{variant:"ghost",size:"icon",onClick:()=>l("box"),children:m.jsx(sn,{className:"h-4 w-4"})})}),m.jsx(ae,{children:"Add Cube"})]}),m.jsxs(ie,{children:[m.jsx(oe,{asChild:!0,children:m.jsx(q,{variant:"ghost",size:"icon",onClick:()=>l("sphere"),children:m.jsx(nn,{className:"h-4 w-4"})})}),m.jsx(ae,{children:"Add Sphere"})]}),m.jsxs(ie,{children:[m.jsx(oe,{asChild:!0,children:m.jsx(q,{variant:"ghost",size:"icon",onClick:()=>l("cylinder"),children:m.jsx(sr,{className:"h-4 w-4"})})}),m.jsx(ae,{children:"Add Cylinder"})]}),m.jsxs(ie,{children:[m.jsx(oe,{asChild:!0,children:m.jsx(q,{variant:"ghost",size:"icon",onClick:()=>l("plane"),children:m.jsx(Jn,{className:"h-4 w-4"})})}),m.jsx(ae,{children:"Add Plane"})]})]}),m.jsx(yt,{orientation:"vertical",className:"h-8"}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsxs(ie,{children:[m.jsx(oe,{asChild:!0,children:m.jsx(q,{variant:t==="translate"?"secondary":"ghost",size:"icon",onClick:()=>n("translate"),disabled:!s,children:m.jsx(nr,{className:"h-4 w-4"})})}),m.jsx(ae,{children:"Move (G)"})]}),m.jsxs(ie,{children:[m.jsx(oe,{asChild:!0,children:m.jsx(q,{variant:t==="rotate"?"secondary":"ghost",size:"icon",onClick:()=>n("rotate"),disabled:!s,children:m.jsx(Zn,{className:"h-4 w-4"})})}),m.jsx(ae,{children:"Rotate (R)"})]}),m.jsxs(ie,{children:[m.jsx(oe,{asChild:!0,children:m.jsx(q,{variant:t==="scale"?"secondary":"ghost",size:"icon",onClick:()=>n("scale"),disabled:!s,children:m.jsx(Qn,{className:"h-4 w-4"})})}),m.jsx(ae,{children:"Scale (S)"})]})]}),m.jsx(yt,{orientation:"vertical",className:"h-8"}),m.jsxs(ie,{children:[m.jsx(oe,{asChild:!0,children:m.jsx(q,{variant:"ghost",size:"icon",onClick:e,disabled:!s,children:m.jsx(rn,{className:"h-4 w-4"})})}),m.jsx(ae,{children:"Delete (X)"})]})]})})}function fo({onObjectGenerated:l}
94){const[e,t]=R.useState(""),[n,s]=R.useState(!1),{toast:r}=ds(),i=async()=>{if(e.trim()){s(!0);try{const{data:a,error:c}=await ln.functions.invoke("chat-with-ai",{body:{message:`You are a 3D modeling assistant. Based on this user request, generate a JSON object describing a 3D model configuration. Return ONLY valid JSON with this structure: {"type": "box|sphere|cylinder|plane", "position": {"x": 0, "y": 0, "z": 0}, "scale": {"x": 1, "y": 1, "z": 1}, "rotation": {"x": 0, "y": 0, "z": 0}, "color": "#hexcolor", "name": "descriptive name"}. User request: ${e}`,model:"google/gemini-2.5-flash"}});if(c)throw c;const u=a.response.match(/\{[\s\S]*\}/);if(u){const p=JSON.parse(u[0]);l({id:`ai-${Date.now()}`,...p,aiGenerated:!0}),r({title:"Object Generated",description:`Created ${p.name||p.type} from AI prompt`}),t("")}else throw new Error("Could not parse AI response")}catch(a){console.error("AI generation error:",a),r({title:"Generation Failed",description:a instanceof Error?a.message:"Failed to generate object",variant:"destructive"})}finally{s(!1)}}},o=a=>{a.key==="Enter"&&a.ctrlKey&&i()};return m.jsxs(vt,{className:"p-4 space-y-4",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(ms,{className:"h-5 w-5 text-primary"}),m.jsx("h3",{className:"font-semibold",children:"AI Assistant"})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(on,{placeholder:"Describe what you want to create... (e.g., 'Create a red cube', 'Add a large sphere', 'Make a cylinder for a wheel')",value:e,onChange:a=>t(a.target.value),onKeyDown:o,className:"min-h-[100px] resize-none",disabled:n}),m.jsx(q,{onClick:i,disabled:n||!e.trim(),className:"w-full",children:n?m.jsxs(m.Fragment,{children:[m.jsx(an,{className:"mr-2 h-4 w-4 animate-spin"}),"Generating..."]}):m.jsxs(m.Fragment,{children:[m.jsx(cn,{className:"mr-2 h-4 w-4"}),"Generate (Ctrl+Enter)"]})})]}),m.jsxs("div",{className:"text-xs text-muted-foreground",children:[m.jsx("p",{children:"Example prompts:"}),m.jsxs("ul",{className:"list-disc list-inside space-y-1 mt-1",children:[m.jsx("li",{children:'"Create a red cube at the origin"'}),m.jsx("li",{children:'"Add a blue sphere scaled to 2x"'}),m.jsx("li",{children:'"Make a green cylinder for a tree trunk"'})]})]})]})}function mo({selectedObject:l,onPropertyChange:e}){if(!l)return m.jsx(vt,{className:"p-4",children:m.jsx("p",{className:"text-sm text-muted-foreground",children:"No object selected"})});const t=(n,s,r)=>{const i=parseFloat(r)||0;e(n,{...l[n],[s]:i})};return m.jsxs(vt,{className:"p-4 space-y-4 max-h-[calc(100vh-300px)] overflow-y-auto",children:[m.jsxs("div",{children:[m.jsx("h3",{className:"font-semibold mb-2",children:"Properties"}),m.jsx("p",{className:"text-sm text-muted-foreground",children:l.name||l.type})]}),m.jsx(yt,{}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(z,{className:"text-sm font-semibold",children:"Position"}),m.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[m.jsxs("div",{children:[m.jsx(z,{className:"text-xs text-muted-foreground",children:"X"}),m.jsx(ee,{type:"number",step:"0.1",value:l.position.x,onChange:n=>t("position","x",n.target.value),className:"h-8"})]}),m.jsxs("div",{children:[m.jsx(z,{className:"text-xs text-muted-foreground",children:"Y"}),m.jsx(ee,{type:"number",step:"0.1",value:l.position.y,onChange:n=>t("position","y",n.target.value),className:"h-8"})]}),m.jsxs("div",{children:[m.jsx(z,{className:"text-xs text-muted-foreground",children:"Z"}),m.jsx(ee,{type:"number",step:"0.1",value:l.position.z,onChange:n=>t("position","z",n.target.value),className:"h-8"})]})]})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(z,{className:"text-sm font-semibold",children:"Rotation"}),m.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[m.jsxs("div",{children:[m.jsx(z,{className:"text-xs text-muted-foreground",children:"X"}),m.jsx(ee,{type:"number",step:"0.1",value:l.rotation.x,onChange:n=>t("rotation","x",n.target.value),className:"h-8"})]}),m.jsxs("div",{children:[m.jsx(z,{className:"text-xs text-muted-foreground",children:"Y"}),m.jsx(ee,{type:"number",step:"0.1",value:l.rotation.y,onChange:n=>t("rotation","y",n.target.value),className:"h-8"})]}),m.jsxs("div",{children:[m.jsx(z,{className:"text-xs text-muted-foreground",children:"Z"}),m.jsx(ee,{type:"number",step:"0.1",value:l.rotation.z,onChange:n=>t("rotation","z",n.target.value),className:"h-8"})]})]})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(z,{className:"text-sm font-semibold",children:"Scale"}),m.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[m.jsxs("div",{children:[m.jsx(z,{className:"text-xs text-muted-foreground",children:"X"}),m.jsx(ee,{type:"number",step:"0.1",value:l.scale.x,onChange:n=>t("scale","x",n.target.value),className:"h-8"})]}),m.jsxs("div",{children:[m.jsx(z,{className:"text-xs text-muted-foreground",children:"Y"}),m.jsx(ee,{type:"number",step:"0.1",value:l.scale.y,onChange:n=>t("scale","y",n.target.value),className:"h-8"})]}),m.jsxs("div",{children:[m.jsx(z,{className:"text-xs text-muted-foreground",children:"Z"}),m.jsx(ee,{type:"number",step:"0.1",value:l.scale.z,onChange:n=>t("scale","z",n.target.value),className:"h-8"})]})]})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(z,{className:"text-sm font-semibold",children:"Color"}
94),m.jsx(ee,{type:"color",value:l.color||"#888888",onChange:n=>e("color",n.target.value),className:"h-10"})]})]})}class xt{static openFile(e){const t=document.createElement("input");t.type="file",t.accept=".fbx,.obj,.glb,.gltf,.json,.crider.json",t.onchange=async n=>{var o,a;const r=(o=n.target.files)==null?void 0:o[0];if(!r)return;console.log(`ð Opening file: ${r.name}`);const i=(a=r.name.split(".").pop())==null?void 0:a.toLowerCase();try{let c=[];switch(i){case"fbx":c=await this.loadFBX(r);break;case"obj":c=await this.loadOBJ(r);break;case"glb":case"gltf":c=await this.loadGLTF(r);break;case"json":c=await this.loadJSON(r);break;default:alert(`â Unsupported file format: .${i}`);return}console.log(`â Loaded model: ${r.name} (${c.length} objects)`),e(c,r.name)}catch(c){console.error(`â Error loading file: ${r.name}`,c),alert(`Failed to load ${r.name}: ${c}`)}},t.click()}static loadFBX(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=r=>{var i;try{const o=new _i,a=(i=r.target)==null?void 0:i.result,c=o.parse(a,""),h=this.extractObjectsFromGroup(c);t(h)}catch(o){n(o)}},s.onerror=()=>n(new Error("Failed to read FBX file")),s.readAsArrayBuffer(e)})}static loadOBJ(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=r=>{var i;try{const o=new qi,a=(i=r.target)==null?void 0:i.result,c=o.parse(a),h=this.extractObjectsFromGroup(c);t(h)}catch(o){n(o)}},s.onerror=()=>n(new Error("Failed to read OBJ file")),s.readAsText(e)})}static loadGLTF(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=r=>{var i;try{const o=new Hr,a=(i=r.target)==null?void 0:i.result;o.parse(a,"",c=>{const h=this.extractObjectsFromGroup(c.scene);t(h)},n)}catch(o){n(o)}},s.onerror=()=>n(new Error("Failed to read GLTF file")),s.readAsArrayBuffer(e)})}static loadJSON(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=r=>{var i;try{const o=(i=r.target)==null?void 0:i.result,a=JSON.parse(o);a.objects&&Array.isArray(a.objects)?t(a.objects):n(new Error("Invalid CriderGPT JSON format"))}catch(o){n(o)}},s.onerror=()=>n(new Error("Failed to read JSON file")),s.readAsText(e)})}static extractObjectsFromGroup(e){const t=[];return e.traverse(n=>{if(n instanceof pe){const s=n.geometry;let r="box";s instanceof Os?r="sphere":s instanceof Ds?r="cylinder":s instanceof Pt&&(r="plane");const i=n.material,o=i.color?`#${i.color.getHexString()}`:"#888888";t.push({id:n.uuid,type:r,name:n.name||`imported_${r}`,position:{x:n.position.x,y:n.position.y,z:n.position.z},rotation:{x:n.rotation.x,y:n.rotation.y,z:n.rotation.z},scale:{x:n.scale.x,y:n.scale.y,z:n.scale.z},color:o,wireframe:!1})}}),t}static saveJSON(e){console.log("ð¾ Saving project as CriderGPT JSON...");const t={version:"1.0.0",application:"CriderGPT Studio",timestamp:new Date().toISOString(),objects:e},n=JSON.stringify(t,null,2),s=new Blob([n],{type:"application/json"}),r=URL.createObjectURL(s),i=document.createElement("a");i.href=r,i.download=`crider_project_${Date.now()}.crider.json`,i.click(),URL.revokeObjectURL(r),console.log(`â Saved: ${i.download}`)}static exportFBX(e){console.log("ð¤ Exporting as FBX...");try{alert("â¹ï¸ FBX export requires a backend converter. Use GLB export instead for full compatibility."),console.log("â ï¸ FBX export not available in browser. Use exportGLTF() instead.")}catch(t){console.error("â FBX export failed:",t),alert("FBX export failed. Try GLB format instead.")}}static exportGLTF(e,t=!0){console.log(`ð¤ Exporting as ${t?"GLB":"GLTF"}...`),new js().parse(e,s=>{if(t){const r=new Blob([s],{type:"application/octet-stream"}),i=URL.createObjectURL(r),o=document.createElement("a");o.href=i,o.download=`crider_export_${Date.now()}.glb`,o.click(),URL.revokeObjectURL(i),console.log(`â Exported: ${o.download}`)}else{const r=JSON.stringify(s,null,2),i=new Blob([r],{type:"application/json"}),o=URL.createObjectURL(i),a=document.createElement("a");a.href=o,a.download=`crider_export_${Date.now()}.gltf`,a.click(),URL.revokeObjectURL(o),console.log(`â Exported: ${a.download}`)}},s=>{console.error("â GLTF export failed:",s),alert("GLTF export failed: "+s)},{binary:t})}static exportOBJ(e){console.log("ð¤ Exporting as OBJ...");try{let t=`# CriderGPT Studio Export 95`;t+=`# Exported: ${new Date().toISOString()} 96 97`;let n=0;e.traverse(o=>{if(o instanceof pe){const a=o.geometry,c=a.attributes.position;if(c){t+=`o ${o.name||"mesh"} 98`;for(let u=0;u<c.count;u++){const p=c.getX(u),f=c.getY(u),d=c.getZ(u);t+=`v ${p} ${f} ${d} 99`}const h=a.index;if(h)for(let u=0;u<h.count;u+=3){const p=h.getX(u)+n+1,f=h.getX(u+1)+n+1,d=h.getX(u+2)+n+1;t+=`f ${p} ${f} ${d} 100`}else for(let u=0;u<c.count;u+=3){const p=u+n+1,f=u+1+n+1,d=u+2+n+1;t+=`f ${p} ${f} ${d} 101`}n+=c.count,t+=` 102`}}});const s=new Blob([t],{type:"text/plain"}),r=URL.createObjectURL(s),i=document.createElement("a");i.href=r,i.download=`crider_export_${Date.now()}.obj`,i.click(),URL.revokeObjectURL(r),console.log(`â Exported: ${i.download}`)}catch(t){console.error("â OBJ export failed:",t),alert("OBJ export failed: "+t)}}static autoExport(e,t="glb"){switch(t){case"fbx":this.exportFBX(e);break;case"glb":this.exportGLTF(e,!0);break;case"gltf":this.exportGLTF(e,!1);break;case"obj":this.exportOBJ(e);break;default:this.exportGLTF(e,!0)}}}
102function Oo(){const[l,e]=R.useState([]),[t,n]=R.useState(null),[s,r]=R.useState("translate"),[i,o]=R.useState("glb"),a=R.useRef(null),{toast:c}=ds(),h=v=>{const E={id:`${v}-${Date.now()}`,type:v,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0},scale:{x:1,y:1,z:1},color:"#888888",name:v.charAt(0).toUpperCase()+v.slice(1)};e([...l,E]),n(E.id)},u=()=>{t&&(e(l.filter(v=>v.id!==t)),n(null))},p=v=>{n(v)},f=(v,E)=>{e(l.map(w=>w.id===v?{...w,...E}:w))},d=(v,E)=>{t&&e(l.map(w=>w.id===t?{...w,[v]:E}:w))},g=v=>{e([...l,v]),n(v.id)},x=()=>{xt.openFile((v,E)=>{e(v),c({title:"File Loaded",description:`Successfully loaded ${E} with ${v.length} objects`})})},T=()=>{xt.saveJSON(l),c({title:"Project Saved",description:"Saved as CriderGPT JSON format"})},A=()=>{if(!a.current){const v=new ke;l.forEach(E=>{let w;switch(E.type){case"sphere":w=new Os(.5,32,32);break;case"cylinder":w=new Ds(.5,.5,1,32);break;case"plane":w=new Pt(2,2);break;default:w=new $n(1,1,1)}const b=new Dt({color:E.color||"#888888",wireframe:E.wireframe||!1}),S=new pe(w,b);S.position.set(E.position.x,E.position.y,E.position.z),S.rotation.set(E.rotation.x,E.rotation.y,E.rotation.z),S.scale.set(E.scale.x,E.scale.y,E.scale.z),S.name=E.name||E.type,v.add(S)}),a.current=v}xt.autoExport(a.current,i),c({title:"Exporting Scene",description:`Exporting as ${i.toUpperCase()} format...`})},y=l.find(v=>v.id===t)||null;return m.jsxs("div",{className:"flex flex-col h-[calc(100vh-4rem)]",children:[m.jsxs("div",{className:"flex items-center justify-between p-4 border-b bg-card",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(ms,{className:"h-5 w-5 text-primary"}),m.jsx("h2",{className:"text-lg font-semibold",children:"CriderGPT Studio"})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs(q,{variant:"outline",size:"sm",onClick:x,children:[m.jsx(er,{className:"w-4 h-4 mr-2"}),"Open"]}),m.jsxs(q,{variant:"outline",size:"sm",onClick:T,children:[m.jsx(un,{className:"w-4 h-4 mr-2"}),"Save"]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs(hn,{value:i,onValueChange:v=>o(v),children:[m.jsx(pn,{className:"w-[100px] h-9",children:m.jsx(fn,{})}),m.jsxs(dn,{children:[m.jsx(He,{value:"glb",children:"GLB"}),m.jsx(He,{value:"gltf",children:"GLTF"}),m.jsx(He,{value:"obj",children:"OBJ"}),m.jsx(He,{value:"fbx",children:"FBX"})]})]}),m.jsxs(q,{variant:"outline",size:"sm",onClick:A,children:[m.jsx(mn,{className:"w-4 h-4 mr-2"}),"Export"]})]})]})]}),m.jsxs(gn,{className:"m-4 mb-0",children:[m.jsx(tr,{className:"h-4 w-4"}),m.jsxs(xn,{children:["CriderGPT Studio - Browser-based 3D modeling with Blender-style import/export.",m.jsx("br",{}),m.jsx("strong",{children:"Supported formats:"})," .fbx, .obj, .glb, .gltf, .crider.json",m.jsx("br",{}),"Use ",m.jsx("strong",{children:"Open"})," to import models, ",m.jsx("strong",{children:"Save"})," for project files, and ",m.jsx("strong",{children:"Export"})," for production formats."]})]}),m.jsx(po,{onAddObject:h,onDeleteSelected:u,transformMode:s,onTransformModeChange:r,hasSelection:!!t}),m.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[m.jsx("div",{className:"w-80 border-r overflow-y-auto p-4 space-y-4",children:m.jsx(fo,{onObjectGenerated:g})}),m.jsx("div",{className:"flex-1",children:m.jsx(ho,{objects:l,selectedObjectId:t,onObjectSelect:p,onObjectTransform:f})}),m.jsx("div",{className:"w-80 border-l overflow-y-auto p-4",children:m.jsx(mo,{selectedObject:y,onPropertyChange:d})})]})]})}export{Oo as StudioPanel};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.