diff --git a/web/dist/assets/index-2875d455.js b/web/dist/assets/index-b2f552bf.js similarity index 99% rename from web/dist/assets/index-2875d455.js rename to web/dist/assets/index-b2f552bf.js index 97fc54f3..f6915022 100644 --- a/web/dist/assets/index-2875d455.js +++ b/web/dist/assets/index-b2f552bf.js @@ -3833,4 +3833,4 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function Ayt(n,e,t){let i=new zE;const r=new vt,s=new vt,o=new kt,a=new Tyt({depthPacking:lmt}),l=new xyt,c={},d=t.maxTextureSize,u={[dr]:Ln,[Ln]:dr,[Ti]:Ti},_=new Us({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new vt},radius:{value:4}},vertexShader:Cyt,fragmentShader:Ryt}),f=_.clone();f.defines.HORIZONTAL_PASS=1;const E=new Fi;E.setAttribute("position",new wn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new An(E,_),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Gw;let h=this.type;this.render=function(T,C,N){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||T.length===0)return;const x=n.getRenderTarget(),y=n.getActiveCubeFace(),R=n.getActiveMipmapLevel(),P=n.state;P.setBlending(Vr),P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const k=h!==Zi&&this.type===Zi,W=h===Zi&&this.type!==Zi;for(let M=0,H=T.length;Md||r.y>d)&&(r.x>d&&(s.x=Math.floor(d/Y.x),r.x=s.x*Y.x,I.mapSize.x=s.x),r.y>d&&(s.y=Math.floor(d/Y.y),r.y=s.y*Y.y,I.mapSize.y=s.y)),I.map===null||k===!0||W===!0){const q=this.type!==Zi?{minFilter:ln,magFilter:ln}:{};I.map!==null&&I.map.dispose(),I.map=new Ps(r.x,r.y,q),I.map.texture.name=z.name+".shadowMap",I.camera.updateProjectionMatrix()}n.setRenderTarget(I.map),n.clear();const K=I.getViewportCount();for(let q=0;q0||C.map&&C.alphaTest>0){const P=y.uuid,k=C.uuid;let W=c[P];W===void 0&&(W={},c[P]=W);let M=W[k];M===void 0&&(M=y.clone(),W[k]=M),y=M}if(y.visible=C.visible,y.wireframe=C.wireframe,x===Zi?y.side=C.shadowSide!==null?C.shadowSide:C.side:y.side=C.shadowSide!==null?C.shadowSide:u[C.side],y.alphaMap=C.alphaMap,y.alphaTest=C.alphaTest,y.map=C.map,y.clipShadows=C.clipShadows,y.clippingPlanes=C.clippingPlanes,y.clipIntersection=C.clipIntersection,y.displacementMap=C.displacementMap,y.displacementScale=C.displacementScale,y.displacementBias=C.displacementBias,y.wireframeLinewidth=C.wireframeLinewidth,y.linewidth=C.linewidth,N.isPointLight===!0&&y.isMeshDistanceMaterial===!0){const P=n.properties.get(y);P.light=N}return y}function v(T,C,N,x,y){if(T.visible===!1)return;if(T.layers.test(C.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&y===Zi)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,T.matrixWorld);const k=e.update(T),W=T.material;if(Array.isArray(W)){const M=k.groups;for(let H=0,z=M.length;H=1):q.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),Y=K>=2);let le=null,X={};const Z=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),fe=new kt().fromArray(Z),ye=new kt().fromArray(_e);function j(oe,He,Le,Ce){const ke=new Uint8Array(4),it=n.createTexture();n.bindTexture(oe,it),n.texParameteri(oe,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(oe,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let _t=0;_t"u"?!1:/OculusBrowser/g.test(navigator.userAgent),E=new WeakMap;let b;const g=new WeakMap;let h=!1;try{h=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(w,A){return h?new OffscreenCanvas(w,A):Cl("canvas")}function S(w,A,G,ce){let $=1;if((w.width>ce||w.height>ce)&&($=ce/Math.max(w.width,w.height)),$<1||A===!0)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap){const J=A?Cd:Math.floor,ve=J($*w.width),Ee=J($*w.height);b===void 0&&(b=m(ve,Ee));const Me=G?m(ve,Ee):b;return Me.width=ve,Me.height=Ee,Me.getContext("2d").drawImage(w,0,0,ve,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+w.width+"x"+w.height+") to ("+ve+"x"+Ee+")."),Me}else return"data"in w&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+w.width+"x"+w.height+")."),w;return w}function v(w){return rg(w.width)&&rg(w.height)}function T(w){return a?!1:w.wrapS!==Wn||w.wrapT!==Wn||w.minFilter!==ln&&w.minFilter!==Mn}function C(w,A){return w.generateMipmaps&&A&&w.minFilter!==ln&&w.minFilter!==Mn}function N(w){n.generateMipmap(w)}function x(w,A,G,ce,$=!1){if(a===!1)return A;if(w!==null){if(n[w]!==void 0)return n[w];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let J=A;if(A===n.RED&&(G===n.FLOAT&&(J=n.R32F),G===n.HALF_FLOAT&&(J=n.R16F),G===n.UNSIGNED_BYTE&&(J=n.R8)),A===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(J=n.R8UI),G===n.UNSIGNED_SHORT&&(J=n.R16UI),G===n.UNSIGNED_INT&&(J=n.R32UI),G===n.BYTE&&(J=n.R8I),G===n.SHORT&&(J=n.R16I),G===n.INT&&(J=n.R32I)),A===n.RG&&(G===n.FLOAT&&(J=n.RG32F),G===n.HALF_FLOAT&&(J=n.RG16F),G===n.UNSIGNED_BYTE&&(J=n.RG8)),A===n.RGBA){const ve=$?yd:Nt.getTransfer(ce);G===n.FLOAT&&(J=n.RGBA32F),G===n.HALF_FLOAT&&(J=n.RGBA16F),G===n.UNSIGNED_BYTE&&(J=ve===Gt?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT_4_4_4_4&&(J=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(J=n.RGB5_A1)}return(J===n.R16F||J===n.R32F||J===n.RG16F||J===n.RG32F||J===n.RGBA16F||J===n.RGBA32F)&&e.get("EXT_color_buffer_float"),J}function y(w,A,G){return C(w,G)===!0||w.isFramebufferTexture&&w.minFilter!==ln&&w.minFilter!==Mn?Math.log2(Math.max(A.width,A.height))+1:w.mipmaps!==void 0&&w.mipmaps.length>0?w.mipmaps.length:w.isCompressedTexture&&Array.isArray(w.image)?A.mipmaps.length:1}function R(w){return w===ln||w===eg||w===Kc?n.NEAREST:n.LINEAR}function P(w){const A=w.target;A.removeEventListener("dispose",P),W(A),A.isVideoTexture&&E.delete(A)}function k(w){const A=w.target;A.removeEventListener("dispose",k),H(A)}function W(w){const A=i.get(w);if(A.__webglInit===void 0)return;const G=w.source,ce=g.get(G);if(ce){const $=ce[A.__cacheKey];$.usedTimes--,$.usedTimes===0&&M(w),Object.keys(ce).length===0&&g.delete(G)}i.remove(w)}function M(w){const A=i.get(w);n.deleteTexture(A.__webglTexture);const G=w.source,ce=g.get(G);delete ce[A.__cacheKey],o.memory.textures--}function H(w){const A=w.texture,G=i.get(w),ce=i.get(A);if(ce.__webglTexture!==void 0&&(n.deleteTexture(ce.__webglTexture),o.memory.textures--),w.depthTexture&&w.depthTexture.dispose(),w.isWebGLCubeRenderTarget)for(let $=0;$<6;$++){if(Array.isArray(G.__webglFramebuffer[$]))for(let J=0;J=l&&console.warn("THREE.WebGLTextures: Trying to use "+w+" texture units while this GPU supports only "+l),z+=1,w}function K(w){const A=[];return A.push(w.wrapS),A.push(w.wrapT),A.push(w.wrapR||0),A.push(w.magFilter),A.push(w.minFilter),A.push(w.anisotropy),A.push(w.internalFormat),A.push(w.format),A.push(w.type),A.push(w.generateMipmaps),A.push(w.premultiplyAlpha),A.push(w.flipY),A.push(w.unpackAlignment),A.push(w.colorSpace),A.join()}function q(w,A){const G=i.get(w);if(w.isVideoTexture&&te(w),w.isRenderTargetTexture===!1&&w.version>0&&G.__version!==w.version){const ce=w.image;if(ce===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ce.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q(G,w,A);return}}t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+A)}function le(w,A){const G=i.get(w);if(w.version>0&&G.__version!==w.version){Q(G,w,A);return}t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+A)}function X(w,A){const G=i.get(w);if(w.version>0&&G.__version!==w.version){Q(G,w,A);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+A)}function Z(w,A){const G=i.get(w);if(w.version>0&&G.__version!==w.version){he(G,w,A);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+A)}const _e={[Xo]:n.REPEAT,[Wn]:n.CLAMP_TO_EDGE,[Sd]:n.MIRRORED_REPEAT},fe={[ln]:n.NEAREST,[eg]:n.NEAREST_MIPMAP_NEAREST,[Kc]:n.NEAREST_MIPMAP_LINEAR,[Mn]:n.LINEAR,[Hw]:n.LINEAR_MIPMAP_NEAREST,[ks]:n.LINEAR_MIPMAP_LINEAR},ye={[dmt]:n.NEVER,[mmt]:n.ALWAYS,[umt]:n.LESS,[Zw]:n.LEQUAL,[_mt]:n.EQUAL,[hmt]:n.GEQUAL,[pmt]:n.GREATER,[fmt]:n.NOTEQUAL};function j(w,A,G){if(G?(n.texParameteri(w,n.TEXTURE_WRAP_S,_e[A.wrapS]),n.texParameteri(w,n.TEXTURE_WRAP_T,_e[A.wrapT]),(w===n.TEXTURE_3D||w===n.TEXTURE_2D_ARRAY)&&n.texParameteri(w,n.TEXTURE_WRAP_R,_e[A.wrapR]),n.texParameteri(w,n.TEXTURE_MAG_FILTER,fe[A.magFilter]),n.texParameteri(w,n.TEXTURE_MIN_FILTER,fe[A.minFilter])):(n.texParameteri(w,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(w,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),(w===n.TEXTURE_3D||w===n.TEXTURE_2D_ARRAY)&&n.texParameteri(w,n.TEXTURE_WRAP_R,n.CLAMP_TO_EDGE),(A.wrapS!==Wn||A.wrapT!==Wn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(w,n.TEXTURE_MAG_FILTER,R(A.magFilter)),n.texParameteri(w,n.TEXTURE_MIN_FILTER,R(A.minFilter)),A.minFilter!==ln&&A.minFilter!==Mn&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),A.compareFunction&&(n.texParameteri(w,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(w,n.TEXTURE_COMPARE_FUNC,ye[A.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ce=e.get("EXT_texture_filter_anisotropic");if(A.magFilter===ln||A.minFilter!==Kc&&A.minFilter!==ks||A.type===nr&&e.has("OES_texture_float_linear")===!1||a===!1&&A.type===Tl&&e.has("OES_texture_half_float_linear")===!1)return;(A.anisotropy>1||i.get(A).__currentAnisotropy)&&(n.texParameterf(w,ce.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(A.anisotropy,r.getMaxAnisotropy())),i.get(A).__currentAnisotropy=A.anisotropy)}}function de(w,A){let G=!1;w.__webglInit===void 0&&(w.__webglInit=!0,A.addEventListener("dispose",P));const ce=A.source;let $=g.get(ce);$===void 0&&($={},g.set(ce,$));const J=K(A);if(J!==w.__cacheKey){$[J]===void 0&&($[J]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,G=!0),$[J].usedTimes++;const ve=$[w.__cacheKey];ve!==void 0&&($[w.__cacheKey].usedTimes--,ve.usedTimes===0&&M(A)),w.__cacheKey=J,w.__webglTexture=$[J].texture}return G}function Q(w,A,G){let ce=n.TEXTURE_2D;(A.isDataArrayTexture||A.isCompressedArrayTexture)&&(ce=n.TEXTURE_2D_ARRAY),A.isData3DTexture&&(ce=n.TEXTURE_3D);const $=de(w,A),J=A.source;t.bindTexture(ce,w.__webglTexture,n.TEXTURE0+G);const ve=i.get(J);if(J.version!==ve.__version||$===!0){t.activeTexture(n.TEXTURE0+G);const Ee=Nt.getPrimaries(Nt.workingColorSpace),Me=A.colorSpace===jn?null:Nt.getPrimaries(A.colorSpace),Ue=A.colorSpace===jn||Ee===Me?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,A.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,A.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,A.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ue);const Je=T(A)&&v(A.image)===!1;let Ne=S(A.image,Je,!1,d);Ne=ie(A,Ne);const tt=v(Ne)||a,$e=s.convert(A.format,A.colorSpace);let Pe=s.convert(A.type),je=x(A.internalFormat,$e,Pe,A.colorSpace,A.isVideoTexture);j(ce,A,tt);let Ve;const ct=A.mipmaps,oe=a&&A.isVideoTexture!==!0&&je!==jw,He=ve.__version===void 0||$===!0,Le=y(A,Ne,tt);if(A.isDepthTexture)je=n.DEPTH_COMPONENT,a?A.type===nr?je=n.DEPTH_COMPONENT32F:A.type===Fr?je=n.DEPTH_COMPONENT24:A.type===ws?je=n.DEPTH24_STENCIL8:je=n.DEPTH_COMPONENT16:A.type===nr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),A.format===Os&&je===n.DEPTH_COMPONENT&&A.type!==UE&&A.type!==Fr&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),A.type=Fr,Pe=s.convert(A.type)),A.format===Zo&&je===n.DEPTH_COMPONENT&&(je=n.DEPTH_STENCIL,A.type!==ws&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),A.type=ws,Pe=s.convert(A.type))),He&&(oe?t.texStorage2D(n.TEXTURE_2D,1,je,Ne.width,Ne.height):t.texImage2D(n.TEXTURE_2D,0,je,Ne.width,Ne.height,0,$e,Pe,null));else if(A.isDataTexture)if(ct.length>0&&tt){oe&&He&&t.texStorage2D(n.TEXTURE_2D,Le,je,ct[0].width,ct[0].height);for(let Ce=0,ke=ct.length;Ce>=1,ke>>=1}}else if(ct.length>0&&tt){oe&&He&&t.texStorage2D(n.TEXTURE_2D,Le,je,ct[0].width,ct[0].height);for(let Ce=0,ke=ct.length;Ce0&&He++,t.texStorage2D(n.TEXTURE_CUBE_MAP,He,Ve,Ne[0].width,Ne[0].height));for(let Ce=0;Ce<6;Ce++)if(Je){ct?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,Ne[Ce].width,Ne[Ce].height,Pe,je,Ne[Ce].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,Ve,Ne[Ce].width,Ne[Ce].height,0,Pe,je,Ne[Ce].data);for(let ke=0;ke>J),Ne=Math.max(1,A.height>>J);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,J,Me,Je,Ne,A.depth,0,ve,Ee,null):t.texImage2D($,J,Me,Je,Ne,0,ve,Ee,null)}t.bindFramebuffer(n.FRAMEBUFFER,w),ae(A)?_.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ce,$,i.get(G).__webglTexture,0,B(A)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ce,$,i.get(G).__webglTexture,J),t.bindFramebuffer(n.FRAMEBUFFER,null)}function O(w,A,G){if(n.bindRenderbuffer(n.RENDERBUFFER,w),A.depthBuffer&&!A.stencilBuffer){let ce=a===!0?n.DEPTH_COMPONENT24:n.DEPTH_COMPONENT16;if(G||ae(A)){const $=A.depthTexture;$&&$.isDepthTexture&&($.type===nr?ce=n.DEPTH_COMPONENT32F:$.type===Fr&&(ce=n.DEPTH_COMPONENT24));const J=B(A);ae(A)?_.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,J,ce,A.width,A.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,J,ce,A.width,A.height)}else n.renderbufferStorage(n.RENDERBUFFER,ce,A.width,A.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,w)}else if(A.depthBuffer&&A.stencilBuffer){const ce=B(A);G&&ae(A)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,ce,n.DEPTH24_STENCIL8,A.width,A.height):ae(A)?_.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ce,n.DEPTH24_STENCIL8,A.width,A.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,A.width,A.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,w)}else{const ce=A.isWebGLMultipleRenderTargets===!0?A.texture:[A.texture];for(let $=0;$0){G.__webglFramebuffer[Ee]=[];for(let Me=0;Me0){G.__webglFramebuffer=[];for(let Ee=0;Ee0&&ae(w)===!1){const Ee=J?A:[A];G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let Me=0;Me0)for(let Me=0;Me0)for(let Me=0;Me0&&ae(w)===!1){const A=w.isWebGLMultipleRenderTargets?w.texture:[w.texture],G=w.width,ce=w.height;let $=n.COLOR_BUFFER_BIT;const J=[],ve=w.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ee=i.get(w),Me=w.isWebGLMultipleRenderTargets===!0;if(Me)for(let Ue=0;Ue0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&A.__useRenderToTexture!==!1}function te(w){const A=o.render.frame;E.get(w)!==A&&(E.set(w,A),w.update())}function ie(w,A){const G=w.colorSpace,ce=w.format,$=w.type;return w.isCompressedTexture===!0||w.isVideoTexture===!0||w.format===ig||G!==fn&&G!==jn&&(Nt.getTransfer(G)===Gt?a===!1?e.has("EXT_sRGB")===!0&&ce===Kn?(w.format=ig,w.minFilter=Mn,w.generateMipmaps=!1):A=eO.sRGBToLinear(A):(ce!==Kn||$!==Yr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",G)),A}this.allocateTextureUnit=Y,this.resetTextureUnits=I,this.setTexture2D=q,this.setTexture2DArray=le,this.setTexture3D=X,this.setTextureCube=Z,this.rebindTextures=re,this.setupRenderTarget=ee,this.updateRenderTargetMipmap=be,this.updateMultisampleRenderTarget=xe,this.setupDepthRenderbuffer=V,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=ae}function Nyt(n,e,t){const i=t.isWebGL2;function r(s,o=jn){let a;const l=Nt.getTransfer(o);if(s===Yr)return n.UNSIGNED_BYTE;if(s===qw)return n.UNSIGNED_SHORT_4_4_4_4;if(s===Yw)return n.UNSIGNED_SHORT_5_5_5_1;if(s===Xht)return n.BYTE;if(s===Zht)return n.SHORT;if(s===UE)return n.UNSIGNED_SHORT;if(s===Vw)return n.INT;if(s===Fr)return n.UNSIGNED_INT;if(s===nr)return n.FLOAT;if(s===Tl)return i?n.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===Jht)return n.ALPHA;if(s===Kn)return n.RGBA;if(s===emt)return n.LUMINANCE;if(s===tmt)return n.LUMINANCE_ALPHA;if(s===Os)return n.DEPTH_COMPONENT;if(s===Zo)return n.DEPTH_STENCIL;if(s===ig)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===nmt)return n.RED;if(s===$w)return n.RED_INTEGER;if(s===imt)return n.RG;if(s===Ww)return n.RG_INTEGER;if(s===Kw)return n.RGBA_INTEGER;if(s===Ah||s===wh||s===Oh||s===Nh)if(l===Gt)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Ah)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===wh)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Oh)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Nh)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Ah)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===wh)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Oh)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Nh)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Ax||s===wx||s===Ox||s===Nx)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Ax)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===wx)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Ox)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Nx)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===jw)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Mx||s===Ix)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Mx)return l===Gt?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Ix)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Dx||s===Lx||s===kx||s===Px||s===Ux||s===Fx||s===Bx||s===Gx||s===zx||s===Hx||s===Vx||s===qx||s===Yx||s===$x)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Dx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Lx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===kx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Px)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Ux)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Fx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Bx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Gx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===zx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Hx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Vx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===qx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Yx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===$x)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Mh||s===Wx||s===Kx)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===Mh)return l===Gt?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===Wx)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===Kx)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===rmt||s===jx||s===Qx||s===Xx)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===Mh)return a.COMPRESSED_RED_RGTC1_EXT;if(s===jx)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Qx)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Xx)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===ws?i?n.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:r}}class Myt extends Cn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Ts extends Yt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Iyt={type:"move"};class tm{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ts,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ts,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ue,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ue),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ts,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ue,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ue),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const b of e.hand.values()){const g=t.getJointPose(b,i),h=this._getHandJoint(c,b);g!==null&&(h.matrix.fromArray(g.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,h.jointRadius=g.radius),h.visible=g!==null}const d=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],_=d.position.distanceTo(u.position),f=.02,E=.005;c.inputState.pinching&&_>f+E?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&_<=f-E&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Iyt)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Ts;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class Dyt extends ma{constructor(e,t){super();const i=this;let r=null,s=1,o=null,a="local-floor",l=1,c=null,d=null,u=null,_=null,f=null,E=null;const b=t.getContextAttributes();let g=null,h=null;const m=[],S=[],v=new vt;let T=null;const C=new Cn;C.layers.enable(1),C.viewport=new kt;const N=new Cn;N.layers.enable(2),N.viewport=new kt;const x=[C,N],y=new Myt;y.layers.enable(1),y.layers.enable(2);let R=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let _e=m[Z];return _e===void 0&&(_e=new tm,m[Z]=_e),_e.getTargetRaySpace()},this.getControllerGrip=function(Z){let _e=m[Z];return _e===void 0&&(_e=new tm,m[Z]=_e),_e.getGripSpace()},this.getHand=function(Z){let _e=m[Z];return _e===void 0&&(_e=new tm,m[Z]=_e),_e.getHandSpace()};function k(Z){const _e=S.indexOf(Z.inputSource);if(_e===-1)return;const fe=m[_e];fe!==void 0&&(fe.update(Z.inputSource,Z.frame,c||o),fe.dispatchEvent({type:Z.type,data:Z.inputSource}))}function W(){r.removeEventListener("select",k),r.removeEventListener("selectstart",k),r.removeEventListener("selectend",k),r.removeEventListener("squeeze",k),r.removeEventListener("squeezestart",k),r.removeEventListener("squeezeend",k),r.removeEventListener("end",W),r.removeEventListener("inputsourceschange",M);for(let Z=0;Z=0&&(S[ye]=null,m[ye].disconnect(fe))}for(let _e=0;_e=S.length){S.push(fe),ye=de;break}else if(S[de]===null){S[de]=fe,ye=de;break}if(ye===-1)break}const j=m[ye];j&&j.connect(fe)}}const H=new ue,z=new ue;function I(Z,_e,fe){H.setFromMatrixPosition(_e.matrixWorld),z.setFromMatrixPosition(fe.matrixWorld);const ye=H.distanceTo(z),j=_e.projectionMatrix.elements,de=fe.projectionMatrix.elements,Q=j[14]/(j[10]-1),he=j[14]/(j[10]+1),Ae=(j[9]+1)/j[5],O=(j[9]-1)/j[5],F=(j[8]-1)/j[0],V=(de[8]+1)/de[0],re=Q*F,ee=Q*V,be=ye/(-F+V),xe=be*-F;_e.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(xe),Z.translateZ(be),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert();const B=Q+be,ae=he+be,te=re-xe,ie=ee+(ye-xe),w=Ae*he/ae*B,A=O*he/ae*B;Z.projectionMatrix.makePerspective(te,ie,w,A,B,ae),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}function Y(Z,_e){_e===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(_e.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(r===null)return;y.near=N.near=C.near=Z.near,y.far=N.far=C.far=Z.far,(R!==y.near||P!==y.far)&&(r.updateRenderState({depthNear:y.near,depthFar:y.far}),R=y.near,P=y.far);const _e=Z.parent,fe=y.cameras;Y(y,_e);for(let ye=0;ye0&&(g.alphaTest.value=h.alphaTest);const m=e.get(h).envMap;if(m&&(g.envMap.value=m,g.flipEnvMap.value=m.isCubeTexture&&m.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=h.reflectivity,g.ior.value=h.ior,g.refractionRatio.value=h.refractionRatio),h.lightMap){g.lightMap.value=h.lightMap;const S=n._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=h.lightMapIntensity*S,t(h.lightMap,g.lightMapTransform)}h.aoMap&&(g.aoMap.value=h.aoMap,g.aoMapIntensity.value=h.aoMapIntensity,t(h.aoMap,g.aoMapTransform))}function o(g,h){g.diffuse.value.copy(h.color),g.opacity.value=h.opacity,h.map&&(g.map.value=h.map,t(h.map,g.mapTransform))}function a(g,h){g.dashSize.value=h.dashSize,g.totalSize.value=h.dashSize+h.gapSize,g.scale.value=h.scale}function l(g,h,m,S){g.diffuse.value.copy(h.color),g.opacity.value=h.opacity,g.size.value=h.size*m,g.scale.value=S*.5,h.map&&(g.map.value=h.map,t(h.map,g.uvTransform)),h.alphaMap&&(g.alphaMap.value=h.alphaMap,t(h.alphaMap,g.alphaMapTransform)),h.alphaTest>0&&(g.alphaTest.value=h.alphaTest)}function c(g,h){g.diffuse.value.copy(h.color),g.opacity.value=h.opacity,g.rotation.value=h.rotation,h.map&&(g.map.value=h.map,t(h.map,g.mapTransform)),h.alphaMap&&(g.alphaMap.value=h.alphaMap,t(h.alphaMap,g.alphaMapTransform)),h.alphaTest>0&&(g.alphaTest.value=h.alphaTest)}function d(g,h){g.specular.value.copy(h.specular),g.shininess.value=Math.max(h.shininess,1e-4)}function u(g,h){h.gradientMap&&(g.gradientMap.value=h.gradientMap)}function _(g,h){g.metalness.value=h.metalness,h.metalnessMap&&(g.metalnessMap.value=h.metalnessMap,t(h.metalnessMap,g.metalnessMapTransform)),g.roughness.value=h.roughness,h.roughnessMap&&(g.roughnessMap.value=h.roughnessMap,t(h.roughnessMap,g.roughnessMapTransform)),e.get(h).envMap&&(g.envMapIntensity.value=h.envMapIntensity)}function f(g,h,m){g.ior.value=h.ior,h.sheen>0&&(g.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),g.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(g.sheenColorMap.value=h.sheenColorMap,t(h.sheenColorMap,g.sheenColorMapTransform)),h.sheenRoughnessMap&&(g.sheenRoughnessMap.value=h.sheenRoughnessMap,t(h.sheenRoughnessMap,g.sheenRoughnessMapTransform))),h.clearcoat>0&&(g.clearcoat.value=h.clearcoat,g.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(g.clearcoatMap.value=h.clearcoatMap,t(h.clearcoatMap,g.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,t(h.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(g.clearcoatNormalMap.value=h.clearcoatNormalMap,t(h.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===Ln&&g.clearcoatNormalScale.value.negate())),h.iridescence>0&&(g.iridescence.value=h.iridescence,g.iridescenceIOR.value=h.iridescenceIOR,g.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(g.iridescenceMap.value=h.iridescenceMap,t(h.iridescenceMap,g.iridescenceMapTransform)),h.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=h.iridescenceThicknessMap,t(h.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),h.transmission>0&&(g.transmission.value=h.transmission,g.transmissionSamplerMap.value=m.texture,g.transmissionSamplerSize.value.set(m.width,m.height),h.transmissionMap&&(g.transmissionMap.value=h.transmissionMap,t(h.transmissionMap,g.transmissionMapTransform)),g.thickness.value=h.thickness,h.thicknessMap&&(g.thicknessMap.value=h.thicknessMap,t(h.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=h.attenuationDistance,g.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(g.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(g.anisotropyMap.value=h.anisotropyMap,t(h.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=h.specularIntensity,g.specularColor.value.copy(h.specularColor),h.specularColorMap&&(g.specularColorMap.value=h.specularColorMap,t(h.specularColorMap,g.specularColorMapTransform)),h.specularIntensityMap&&(g.specularIntensityMap.value=h.specularIntensityMap,t(h.specularIntensityMap,g.specularIntensityMapTransform))}function E(g,h){h.matcap&&(g.matcap.value=h.matcap)}function b(g,h){const m=e.get(h).light;g.referencePosition.value.setFromMatrixPosition(m.matrixWorld),g.nearDistance.value=m.shadow.camera.near,g.farDistance.value=m.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function kyt(n,e,t,i){let r={},s={},o=[];const a=t.isWebGL2?n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(m,S){const v=S.program;i.uniformBlockBinding(m,v)}function c(m,S){let v=r[m.id];v===void 0&&(E(m),v=d(m),r[m.id]=v,m.addEventListener("dispose",g));const T=S.program;i.updateUBOMapping(m,T);const C=e.render.frame;s[m.id]!==C&&(_(m),s[m.id]=C)}function d(m){const S=u();m.__bindingPointIndex=S;const v=n.createBuffer(),T=m.__size,C=m.usage;return n.bindBuffer(n.UNIFORM_BUFFER,v),n.bufferData(n.UNIFORM_BUFFER,T,C),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,S,v),v}function u(){for(let m=0;m0){C=v%T;const k=T-C;C!==0&&k-R.boundary<0&&(v+=T-C,y.__offset=v)}v+=R.storage}return C=v%T,C>0&&(v+=T-C),m.__size=v,m.__cache={},this}function b(m){const S={boundary:0,storage:0};return typeof m=="number"?(S.boundary=4,S.storage=4):m.isVector2?(S.boundary=8,S.storage=8):m.isVector3||m.isColor?(S.boundary=16,S.storage=12):m.isVector4?(S.boundary=16,S.storage=16):m.isMatrix3?(S.boundary=48,S.storage=48):m.isMatrix4?(S.boundary=64,S.storage=64):m.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",m),S}function g(m){const S=m.target;S.removeEventListener("dispose",g);const v=o.indexOf(S.__bindingPointIndex);o.splice(v,1),n.deleteBuffer(r[S.id]),delete r[S.id],delete s[S.id]}function h(){for(const m in r)n.deleteBuffer(r[m]);o=[],r={},s={}}return{bind:l,update:c,dispose:h}}class gO{constructor(e={}){const{canvas:t=Imt(),context:i=null,depth:r=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let _;i!==null?_=i.getContextAttributes().alpha:_=o;const f=new Uint32Array(4),E=new Int32Array(4);let b=null,g=null;const h=[],m=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Wt,this._useLegacyLights=!1,this.toneMapping=qr,this.toneMappingExposure=1;const S=this;let v=!1,T=0,C=0,N=null,x=-1,y=null;const R=new kt,P=new kt;let k=null;const W=new at(0);let M=0,H=t.width,z=t.height,I=1,Y=null,K=null;const q=new kt(0,0,H,z),le=new kt(0,0,H,z);let X=!1;const Z=new zE;let _e=!1,fe=!1,ye=null;const j=new gt,de=new vt,Q=new ue,he={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ae(){return N===null?I:1}let O=i;function F(U,pe){for(let Se=0;Se{function qe(){if(Te.forEach(function(Qe){xe.get(Qe).currentProgram.isReady()&&Te.delete(Qe)}),Te.size===0){me(U);return}setTimeout(qe,10)}V.get("KHR_parallel_shader_compile")!==null?qe():setTimeout(qe,10)})};let _t=null;function $t(U){_t&&_t(U)}function tn(){Vt.stop()}function wt(){Vt.start()}const Vt=new dO;Vt.setAnimationLoop($t),typeof self<"u"&&Vt.setContext(self),this.setAnimationLoop=function(U){_t=U,Ve.setAnimationLoop(U),U===null?Vt.stop():Vt.start()},Ve.addEventListener("sessionstart",tn),Ve.addEventListener("sessionend",wt),this.render=function(U,pe){if(pe!==void 0&&pe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),pe.parent===null&&pe.matrixWorldAutoUpdate===!0&&pe.updateMatrixWorld(),Ve.enabled===!0&&Ve.isPresenting===!0&&(Ve.cameraAutoUpdate===!0&&Ve.updateCamera(pe),pe=Ve.getCamera()),U.isScene===!0&&U.onBeforeRender(S,U,pe,N),g=J.get(U,m.length),g.init(),m.push(g),j.multiplyMatrices(pe.projectionMatrix,pe.matrixWorldInverse),Z.setFromProjectionMatrix(j),fe=this.localClippingEnabled,_e=ve.init(this.clippingPlanes,fe),b=$.get(U,h.length),b.init(),h.push(b),On(U,pe,0,S.sortObjects),b.finish(),S.sortObjects===!0&&b.sort(Y,K),this.info.render.frame++,_e===!0&&ve.beginShadows();const Se=g.state.shadowsArray;if(Ee.render(Se,U,pe),_e===!0&&ve.endShadows(),this.info.autoReset===!0&&this.info.reset(),Me.render(b,U),g.setupLights(S._useLegacyLights),pe.isArrayCamera){const Te=pe.cameras;for(let me=0,qe=Te.length;me0?g=m[m.length-1]:g=null,h.pop(),h.length>0?b=h[h.length-1]:b=null};function On(U,pe,Se,Te){if(U.visible===!1)return;if(U.layers.test(pe.layers)){if(U.isGroup)Se=U.renderOrder;else if(U.isLOD)U.autoUpdate===!0&&U.update(pe);else if(U.isLight)g.pushLight(U),U.castShadow&&g.pushShadow(U);else if(U.isSprite){if(!U.frustumCulled||Z.intersectsSprite(U)){Te&&Q.setFromMatrixPosition(U.matrixWorld).applyMatrix4(j);const Qe=A.update(U),nt=U.material;nt.visible&&b.push(U,Qe,nt,Se,Q.z,null)}}else if((U.isMesh||U.isLine||U.isPoints)&&(!U.frustumCulled||Z.intersectsObject(U))){const Qe=A.update(U),nt=U.material;if(Te&&(U.boundingSphere!==void 0?(U.boundingSphere===null&&U.computeBoundingSphere(),Q.copy(U.boundingSphere.center)):(Qe.boundingSphere===null&&Qe.computeBoundingSphere(),Q.copy(Qe.boundingSphere.center)),Q.applyMatrix4(U.matrixWorld).applyMatrix4(j)),Array.isArray(nt)){const rt=Qe.groups;for(let dt=0,st=rt.length;dt0&&ya(me,qe,pe,Se),Te&&ee.viewport(R.copy(Te)),me.length>0&&Gi(me,pe,Se),qe.length>0&&Gi(qe,pe,Se),Qe.length>0&&Gi(Qe,pe,Se),ee.buffers.depth.setTest(!0),ee.buffers.depth.setMask(!0),ee.buffers.color.setMask(!0),ee.setPolygonOffset(!1)}function ya(U,pe,Se,Te){if((Se.isScene===!0?Se.overrideMaterial:null)!==null)return;const qe=re.isWebGL2;ye===null&&(ye=new Ps(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")?Tl:Yr,minFilter:ks,samples:qe?4:0})),S.getDrawingBufferSize(de),qe?ye.setSize(de.x,de.y):ye.setSize(Cd(de.x),Cd(de.y));const Qe=S.getRenderTarget();S.setRenderTarget(ye),S.getClearColor(W),M=S.getClearAlpha(),M<1&&S.setClearColor(16777215,.5),S.clear();const nt=S.toneMapping;S.toneMapping=qr,Gi(U,Se,Te),B.updateMultisampleRenderTarget(ye),B.updateRenderTargetMipmap(ye);let rt=!1;for(let dt=0,st=pe.length;dt0),lt=!!Se.morphAttributes.position,Ut=!!Se.morphAttributes.normal,dn=!!Se.morphAttributes.color;let qt=qr;Te.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(qt=S.toneMapping);const hn=Se.morphAttributes.position||Se.morphAttributes.normal||Se.morphAttributes.color,Bt=hn!==void 0?hn.length:0,pt=xe.get(Te),Ta=g.state.lights;if(_e===!0&&(fe===!0||U!==y)){const Nn=U===y&&Te.id===x;ve.setState(Te,U,Nn)}let Ht=!1;Te.version===pt.__version?(pt.needsLights&&pt.lightsStateVersion!==Ta.state.version||pt.outputColorSpace!==nt||me.isBatchedMesh&&pt.batching===!1||!me.isBatchedMesh&&pt.batching===!0||me.isInstancedMesh&&pt.instancing===!1||!me.isInstancedMesh&&pt.instancing===!0||me.isSkinnedMesh&&pt.skinning===!1||!me.isSkinnedMesh&&pt.skinning===!0||me.isInstancedMesh&&pt.instancingColor===!0&&me.instanceColor===null||me.isInstancedMesh&&pt.instancingColor===!1&&me.instanceColor!==null||pt.envMap!==rt||Te.fog===!0&&pt.fog!==qe||pt.numClippingPlanes!==void 0&&(pt.numClippingPlanes!==ve.numPlanes||pt.numIntersection!==ve.numIntersection)||pt.vertexAlphas!==dt||pt.vertexTangents!==st||pt.morphTargets!==lt||pt.morphNormals!==Ut||pt.morphColors!==dn||pt.toneMapping!==qt||re.isWebGL2===!0&&pt.morphTargetsCount!==Bt)&&(Ht=!0):(Ht=!0,pt.__version=Te.version);let Hi=pt.currentProgram;Ht===!0&&(Hi=zi(Te,pe,me));let Fl=!1,ns=!1,xa=!1;const on=Hi.getUniforms(),Vi=pt.uniforms;if(ee.useProgram(Hi.program)&&(Fl=!0,ns=!0,xa=!0),Te.id!==x&&(x=Te.id,ns=!0),Fl||y!==U){on.setValue(O,"projectionMatrix",U.projectionMatrix),on.setValue(O,"viewMatrix",U.matrixWorldInverse);const Nn=on.map.cameraPosition;Nn!==void 0&&Nn.setValue(O,Q.setFromMatrixPosition(U.matrixWorld)),re.logarithmicDepthBuffer&&on.setValue(O,"logDepthBufFC",2/(Math.log(U.far+1)/Math.LN2)),(Te.isMeshPhongMaterial||Te.isMeshToonMaterial||Te.isMeshLambertMaterial||Te.isMeshBasicMaterial||Te.isMeshStandardMaterial||Te.isShaderMaterial)&&on.setValue(O,"isOrthographic",U.isOrthographicCamera===!0),y!==U&&(y=U,ns=!0,xa=!0)}if(me.isSkinnedMesh){on.setOptional(O,me,"bindMatrix"),on.setOptional(O,me,"bindMatrixInverse");const Nn=me.skeleton;Nn&&(re.floatVertexTextures?(Nn.boneTexture===null&&Nn.computeBoneTexture(),on.setValue(O,"boneTexture",Nn.boneTexture,B)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}me.isBatchedMesh&&(on.setOptional(O,me,"batchingTexture"),on.setValue(O,"batchingTexture",me._matricesTexture,B));const Ca=Se.morphAttributes;if((Ca.position!==void 0||Ca.normal!==void 0||Ca.color!==void 0&&re.isWebGL2===!0)&&Ue.update(me,Se,Hi),(ns||pt.receiveShadow!==me.receiveShadow)&&(pt.receiveShadow=me.receiveShadow,on.setValue(O,"receiveShadow",me.receiveShadow)),Te.isMeshGouraudMaterial&&Te.envMap!==null&&(Vi.envMap.value=rt,Vi.flipEnvMap.value=rt.isCubeTexture&&rt.isRenderTargetTexture===!1?-1:1),ns&&(on.setValue(O,"toneMappingExposure",S.toneMappingExposure),pt.needsLights&&ts(Vi,xa),qe&&Te.fog===!0&&ce.refreshFogUniforms(Vi,qe),ce.refreshMaterialUniforms(Vi,Te,I,z,ye),jc.upload(O,es(pt),Vi,B)),Te.isShaderMaterial&&Te.uniformsNeedUpdate===!0&&(jc.upload(O,es(pt),Vi,B),Te.uniformsNeedUpdate=!1),Te.isSpriteMaterial&&on.setValue(O,"center",me.center),on.setValue(O,"modelViewMatrix",me.modelViewMatrix),on.setValue(O,"normalMatrix",me.normalMatrix),on.setValue(O,"modelMatrix",me.matrixWorld),Te.isShaderMaterial||Te.isRawShaderMaterial){const Nn=Te.uniformsGroups;for(let Ra=0,_u=Nn.length;Ra<_u;Ra++)if(re.isWebGL2){const Bl=Nn[Ra];Pe.update(Bl,Hi),Pe.bind(Bl,Hi)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Hi}function ts(U,pe){U.ambientLightColor.needsUpdate=pe,U.lightProbe.needsUpdate=pe,U.directionalLights.needsUpdate=pe,U.directionalLightShadows.needsUpdate=pe,U.pointLights.needsUpdate=pe,U.pointLightShadows.needsUpdate=pe,U.spotLights.needsUpdate=pe,U.spotLightShadows.needsUpdate=pe,U.rectAreaLights.needsUpdate=pe,U.hemisphereLights.needsUpdate=pe}function va(U){return U.isMeshLambertMaterial||U.isMeshToonMaterial||U.isMeshPhongMaterial||U.isMeshStandardMaterial||U.isShadowMaterial||U.isShaderMaterial&&U.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(U,pe,Se){xe.get(U.texture).__webglTexture=pe,xe.get(U.depthTexture).__webglTexture=Se;const Te=xe.get(U);Te.__hasExternalTextures=!0,Te.__hasExternalTextures&&(Te.__autoAllocateDepthBuffer=Se===void 0,Te.__autoAllocateDepthBuffer||V.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Te.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(U,pe){const Se=xe.get(U);Se.__webglFramebuffer=pe,Se.__useDefaultFramebuffer=pe===void 0},this.setRenderTarget=function(U,pe=0,Se=0){N=U,T=pe,C=Se;let Te=!0,me=null,qe=!1,Qe=!1;if(U){const rt=xe.get(U);rt.__useDefaultFramebuffer!==void 0?(ee.bindFramebuffer(O.FRAMEBUFFER,null),Te=!1):rt.__webglFramebuffer===void 0?B.setupRenderTarget(U):rt.__hasExternalTextures&&B.rebindTextures(U,xe.get(U.texture).__webglTexture,xe.get(U.depthTexture).__webglTexture);const dt=U.texture;(dt.isData3DTexture||dt.isDataArrayTexture||dt.isCompressedArrayTexture)&&(Qe=!0);const st=xe.get(U).__webglFramebuffer;U.isWebGLCubeRenderTarget?(Array.isArray(st[pe])?me=st[pe][Se]:me=st[pe],qe=!0):re.isWebGL2&&U.samples>0&&B.useMultisampledRTT(U)===!1?me=xe.get(U).__webglMultisampledFramebuffer:Array.isArray(st)?me=st[Se]:me=st,R.copy(U.viewport),P.copy(U.scissor),k=U.scissorTest}else R.copy(q).multiplyScalar(I).floor(),P.copy(le).multiplyScalar(I).floor(),k=X;if(ee.bindFramebuffer(O.FRAMEBUFFER,me)&&re.drawBuffers&&Te&&ee.drawBuffers(U,me),ee.viewport(R),ee.scissor(P),ee.setScissorTest(k),qe){const rt=xe.get(U.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+pe,rt.__webglTexture,Se)}else if(Qe){const rt=xe.get(U.texture),dt=pe||0;O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,rt.__webglTexture,Se||0,dt)}x=-1},this.readRenderTargetPixels=function(U,pe,Se,Te,me,qe,Qe){if(!(U&&U.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let nt=xe.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&Qe!==void 0&&(nt=nt[Qe]),nt){ee.bindFramebuffer(O.FRAMEBUFFER,nt);try{const rt=U.texture,dt=rt.format,st=rt.type;if(dt!==Kn&&tt.convert(dt)!==O.getParameter(O.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const lt=st===Tl&&(V.has("EXT_color_buffer_half_float")||re.isWebGL2&&V.has("EXT_color_buffer_float"));if(st!==Yr&&tt.convert(st)!==O.getParameter(O.IMPLEMENTATION_COLOR_READ_TYPE)&&!(st===nr&&(re.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float")))&&!lt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}pe>=0&&pe<=U.width-Te&&Se>=0&&Se<=U.height-me&&O.readPixels(pe,Se,Te,me,tt.convert(dt),tt.convert(st),qe)}finally{const rt=N!==null?xe.get(N).__webglFramebuffer:null;ee.bindFramebuffer(O.FRAMEBUFFER,rt)}}},this.copyFramebufferToTexture=function(U,pe,Se=0){const Te=Math.pow(2,-Se),me=Math.floor(pe.image.width*Te),qe=Math.floor(pe.image.height*Te);B.setTexture2D(pe,0),O.copyTexSubImage2D(O.TEXTURE_2D,Se,0,0,U.x,U.y,me,qe),ee.unbindTexture()},this.copyTextureToTexture=function(U,pe,Se,Te=0){const me=pe.image.width,qe=pe.image.height,Qe=tt.convert(Se.format),nt=tt.convert(Se.type);B.setTexture2D(Se,0),O.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,Se.flipY),O.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Se.premultiplyAlpha),O.pixelStorei(O.UNPACK_ALIGNMENT,Se.unpackAlignment),pe.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,Te,U.x,U.y,me,qe,Qe,nt,pe.image.data):pe.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,Te,U.x,U.y,pe.mipmaps[0].width,pe.mipmaps[0].height,Qe,pe.mipmaps[0].data):O.texSubImage2D(O.TEXTURE_2D,Te,U.x,U.y,Qe,nt,pe.image),Te===0&&Se.generateMipmaps&&O.generateMipmap(O.TEXTURE_2D),ee.unbindTexture()},this.copyTextureToTexture3D=function(U,pe,Se,Te,me=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const qe=U.max.x-U.min.x+1,Qe=U.max.y-U.min.y+1,nt=U.max.z-U.min.z+1,rt=tt.convert(Te.format),dt=tt.convert(Te.type);let st;if(Te.isData3DTexture)B.setTexture3D(Te,0),st=O.TEXTURE_3D;else if(Te.isDataArrayTexture)B.setTexture2DArray(Te,0),st=O.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}O.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,Te.flipY),O.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Te.premultiplyAlpha),O.pixelStorei(O.UNPACK_ALIGNMENT,Te.unpackAlignment);const lt=O.getParameter(O.UNPACK_ROW_LENGTH),Ut=O.getParameter(O.UNPACK_IMAGE_HEIGHT),dn=O.getParameter(O.UNPACK_SKIP_PIXELS),qt=O.getParameter(O.UNPACK_SKIP_ROWS),hn=O.getParameter(O.UNPACK_SKIP_IMAGES),Bt=Se.isCompressedTexture?Se.mipmaps[0]:Se.image;O.pixelStorei(O.UNPACK_ROW_LENGTH,Bt.width),O.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Bt.height),O.pixelStorei(O.UNPACK_SKIP_PIXELS,U.min.x),O.pixelStorei(O.UNPACK_SKIP_ROWS,U.min.y),O.pixelStorei(O.UNPACK_SKIP_IMAGES,U.min.z),Se.isDataTexture||Se.isData3DTexture?O.texSubImage3D(st,me,pe.x,pe.y,pe.z,qe,Qe,nt,rt,dt,Bt.data):Se.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),O.compressedTexSubImage3D(st,me,pe.x,pe.y,pe.z,qe,Qe,nt,rt,Bt.data)):O.texSubImage3D(st,me,pe.x,pe.y,pe.z,qe,Qe,nt,rt,dt,Bt),O.pixelStorei(O.UNPACK_ROW_LENGTH,lt),O.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Ut),O.pixelStorei(O.UNPACK_SKIP_PIXELS,dn),O.pixelStorei(O.UNPACK_SKIP_ROWS,qt),O.pixelStorei(O.UNPACK_SKIP_IMAGES,hn),me===0&&Te.generateMipmaps&&O.generateMipmap(st),ee.unbindTexture()},this.initTexture=function(U){U.isCubeTexture?B.setTextureCube(U,0):U.isData3DTexture?B.setTexture3D(U,0):U.isDataArrayTexture||U.isCompressedArrayTexture?B.setTexture2DArray(U,0):B.setTexture2D(U,0),ee.unbindTexture()},this.resetState=function(){T=0,C=0,N=null,ee.reset(),$e.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ir}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===BE?"display-p3":"srgb",t.unpackColorSpace=Nt.workingColorSpace===ou?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Wt?Ns:Xw}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ns?Wt:fn}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class Pyt extends gO{}Pyt.prototype.isWebGL1Renderer=!0;class Uyt extends Yt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class Fyt{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ng,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=pi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;rl)continue;_.applyMatrix4(this.matrixWorld);const x=e.ray.origin.distanceTo(_);xe.far||t.push({distance:x,point:u.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}else{const h=Math.max(0,o.start),m=Math.min(g.count,o.start+o.count);for(let S=h,v=m-1;Sl)continue;_.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(_);Ce.far||t.push({distance:C,point:u.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sr.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class KE extends fi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new at(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new at(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=FE,this.normalScale=new vt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class mr extends KE{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new vt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return En(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new at(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new at(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new at(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class iR extends fi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new at(16777215),this.specular=new at(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new at(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=FE,this.normalScale=new vt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=PE,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}function Lc(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Kyt(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function jyt(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function rR(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){const a=t[s]*e;for(let l=0;l!==e;++l)r[o++]=n[a+l]}return r}function yO(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}class Ul{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e=s)){const a=t[1];e=s)break t}o=i,i=0;break n}break e}for(;i>>1;et;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(r!==void 0&&Kyt(r))for(let a=0,l=r.length;a!==l;++a){const c=r[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Ih,s=e.length-1;let o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Bi.prototype.TimeBufferType=Float32Array;Bi.prototype.ValueBufferType=Float32Array;Bi.prototype.DefaultInterpolation=Jo;class Ea extends Bi{}Ea.prototype.ValueTypeName="bool";Ea.prototype.ValueBufferType=Array;Ea.prototype.DefaultInterpolation=xl;Ea.prototype.InterpolantFactoryMethodLinear=void 0;Ea.prototype.InterpolantFactoryMethodSmooth=void 0;class vO extends Bi{}vO.prototype.ValueTypeName="color";class na extends Bi{}na.prototype.ValueTypeName="number";class Jyt extends Ul{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(r-t);let c=e*a;for(let d=c+a;c!==d;c+=4)Zr.slerpFlat(s,0,o,c-a,o,c,l);return s}}class Fs extends Bi{InterpolantFactoryMethodLinear(e){return new Jyt(this.times,this.values,this.getValueSize(),e)}}Fs.prototype.ValueTypeName="quaternion";Fs.prototype.DefaultInterpolation=Jo;Fs.prototype.InterpolantFactoryMethodSmooth=void 0;class ba extends Bi{}ba.prototype.ValueTypeName="string";ba.prototype.ValueBufferType=Array;ba.prototype.DefaultInterpolation=xl;ba.prototype.InterpolantFactoryMethodLinear=void 0;ba.prototype.InterpolantFactoryMethodSmooth=void 0;class ia extends Bi{}ia.prototype.ValueTypeName="vector";class evt{constructor(e,t=-1,i,r=smt){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=pi(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(nvt(i[o]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(Bi.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,o=[];for(let a=0;a1){const u=d[1];let _=r[u];_||(r[u]=_=[]),_.push(c)}}const o=[];for(const a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,_,f,E,b){if(f.length!==0){const g=[],h=[];yO(f,g,h,E),g.length!==0&&b.push(new u(_,g,h))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u{t&&t(s),this.manager.itemEnd(e)},0),s;if(Qi[e]!==void 0){Qi[e].push({onLoad:t,onProgress:i,onError:r});return}Qi[e]=[],Qi[e].push({onLoad:t,onProgress:i,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const d=Qi[e],u=c.body.getReader(),_=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=_?parseInt(_):0,E=f!==0;let b=0;const g=new ReadableStream({start(h){m();function m(){u.read().then(({done:S,value:v})=>{if(S)h.close();else{b+=v.byteLength;const T=new ProgressEvent("progress",{lengthComputable:E,loaded:b,total:f});for(let C=0,N=d.length;C{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(d=>new DOMParser().parseFromString(d,a));case"json":return c.json();default:if(a===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),_=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(_);return c.arrayBuffer().then(E=>f.decode(E))}}}).then(c=>{ra.add(e,c);const d=Qi[e];delete Qi[e];for(let u=0,_=d.length;u<_;u++){const f=d[u];f.onLoad&&f.onLoad(c)}}).catch(c=>{const d=Qi[e];if(d===void 0)throw this.manager.itemError(e),c;delete Qi[e];for(let u=0,_=d.length;u<_;u++){const f=d[u];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class ovt extends Sa{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ra.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=Cl("img");function l(){d(),ra.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(u){d(),r&&r(u),s.manager.itemError(e),s.manager.itemEnd(e)}function d(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class xO extends Sa{constructor(e){super(e)}load(e,t,i,r){const s=new pn,o=new ovt(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class du extends Yt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new at(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}const sm=new gt,sR=new ue,oR=new ue;class jE{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new vt(512,512),this.map=null,this.mapPass=null,this.matrix=new gt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new zE,this._frameExtents=new vt(1,1),this._viewportCount=1,this._viewports=[new kt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;sR.setFromMatrixPosition(e.matrixWorld),t.position.copy(sR),oR.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(oR),t.updateMatrixWorld(),sm.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sm),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(sm)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class avt extends jE{constructor(){super(new Cn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=ea*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class lvt extends du{constructor(e,t,i=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Yt.DEFAULT_UP),this.updateMatrix(),this.target=new Yt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new avt}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const aR=new gt,za=new ue,om=new ue;class cvt extends jE{constructor(){super(new Cn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new vt(4,2),this._viewportCount=6,this._viewports=[new kt(2,1,1,1),new kt(0,1,1,1),new kt(3,1,1,1),new kt(1,1,1,1),new kt(3,0,1,1),new kt(1,0,1,1)],this._cubeDirections=[new ue(1,0,0),new ue(-1,0,0),new ue(0,0,1),new ue(0,0,-1),new ue(0,1,0),new ue(0,-1,0)],this._cubeUps=[new ue(0,1,0),new ue(0,1,0),new ue(0,1,0),new ue(0,1,0),new ue(0,0,1),new ue(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),za.setFromMatrixPosition(e.matrixWorld),i.position.copy(za),om.copy(i.position),om.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(om),i.updateMatrixWorld(),r.makeTranslation(-za.x,-za.y,-za.z),aR.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(aR)}}class dvt extends du{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new cvt}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class uvt extends jE{constructor(){super(new VE(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class CO extends du{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Yt.DEFAULT_UP),this.updateMatrix(),this.target=new Yt,this.shadow=new uvt}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class _vt extends du{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class sl{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ra.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){ra.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){r&&r(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}const QE="\\[\\]\\.:\\/",fvt=new RegExp("["+QE+"]","g"),XE="[^"+QE+"]",hvt="[^"+QE.replace("\\.","")+"]",mvt=/((?:WC+[\/:])*)/.source.replace("WC",XE),gvt=/(WCOD+)?/.source.replace("WCOD",hvt),Evt=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",XE),bvt=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",XE),Svt=new RegExp("^"+mvt+gvt+Evt+bvt+"$"),yvt=["material","materials","bones","map"];class vvt{constructor(e,t,i){const r=i||It.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class It{constructor(e,t,i){this.path=t,this.parsedPath=i||It.parseTrackName(t),this.node=It.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new It.Composite(e,t,i):new It(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(fvt,"")}static parseTrackName(e){const t=Svt.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);yvt.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let o=0;o=2.0 are supported."));return}const c=new tTt(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,s){i.parse(e,t,r,s)})}}function xvt(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const yt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Cvt{constructor(e){this.parser=e,this.name=yt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class Fvt{constructor(e){this.parser=e,this.name=yt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=r.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.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 Bvt{constructor(e){this.parser=e,this.name=yt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=r.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Gvt{constructor(e){this.name=yt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=r.byteOffset||0,c=r.byteLength||0,d=r.count,u=r.byteStride,_=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(d,u,_,r.mode,r.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(d*u);return o.decodeGltfBuffer(new Uint8Array(f),d,u,_,r.mode,r.filter),f})})}else return null}}class zvt{constructor(e){this.name=yt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const c of r.primitives)if(c.mode!==qn.TRIANGLES&&c.mode!==qn.TRIANGLE_STRIP&&c.mode!==qn.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=i.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(d=>(l[c]=d,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const d=c.pop(),u=d.isGroup?d.children:[d],_=c[0].count,f=[];for(const E of u){const b=new gt,g=new ue,h=new Zr,m=new ue(1,1,1),S=new qyt(E.geometry,E.material,_);for(let v=0;v<_;v++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,v),l.ROTATION&&h.fromBufferAttribute(l.ROTATION,v),l.SCALE&&m.fromBufferAttribute(l.SCALE,v),S.setMatrixAt(v,b.compose(g,h,m));for(const v in l)if(v==="_COLOR_0"){const T=l[v];S.instanceColor=new og(T.array,T.itemSize,T.normalized)}else v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"&&E.geometry.setAttribute(v,l[v]);Yt.prototype.copy.call(S,E),this.parser.assignFinalMaterial(S),f.push(S)}return d.isGroup?(d.clear(),d.add(...f),d):f[0]}))}}const RO="glTF",Ha=12,cR={JSON:1313821514,BIN:5130562};class Hvt{constructor(e){this.name=yt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ha),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==RO)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-Ha,s=new DataView(e,Ha);let o=0;for(;o0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const eTt=new gt;class tTt{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new xvt,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 i=!1,r=!1,s=-1;typeof navigator<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||r&&s<98?this.textureLoader=new xO(this.options.manager):this.textureLoader=new pvt(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new TO(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 i=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:i,userData:{}};return us(s,a,r),kr(a,r),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,s=t.length;r{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,d]of o.children.entries())s(d,a.children[c])};return s(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i=2&&g.setY(y,C[N*l+1]),l>=3&&g.setZ(y,C[N*l+2]),l>=4&&g.setW(y,C[N*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g})}loadTexture(e){const t=this.json,i=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const l=i.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,i){const r=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(d){d.flipY=!1,d.name=o.name||a.name||"",d.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(d.name=a.uri);const _=(s.samplers||{})[o.sampler]||{};return d.magFilter=dR[_.magFilter]||Mn,d.minFilter=dR[_.minFilter]||ks,d.wrapS=uR[_.wrapS]||Xo,d.wrapT=uR[_.wrapT]||Xo,r.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=r.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=i.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const _=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(_),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(l).then(function(u){return new Promise(function(_,f){let E=_;t.isImageBitmapLoader===!0&&(E=function(b){const g=new pn(b);g.needsUpdate=!0,_(g)}),t.load(sl.resolveURL(u,s.path),E,void 0,f)})}).then(function(u){return c===!0&&a.revokeObjectURL(l),u.userData.mimeType=o.mimeType||Jvt(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=d,d}assignTexture(e,t,i,r){const s=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),s.extensions[yt.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[yt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[yt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new SO,fi.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(a,l)),i=l}else if(e.isLine){const a="LineBasicMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new bO,fi.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(a,l)),i=l}if(r||s||o){let a="ClonedMaterial:"+i.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=i.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return KE}loadMaterial(e){const t=this,i=this.json,r=this.extensions,s=i.materials[e];let o;const a={},l=s.extensions||{},c=[];if(l[yt.KHR_MATERIALS_UNLIT]){const u=r[yt.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new at(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const _=u.baseColorFactor;a.color.setRGB(_[0],_[1],_[2],fn),a.opacity=_[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,Wt)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(_){return _.getMaterialType&&_.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(_){return _.extendMaterialParams&&_.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Ti);const d=s.alphaMode||lm.OPAQUE;if(d===lm.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,d===lm.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==Br&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new vt(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&o!==Br&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==Br){const u=s.emissiveFactor;a.emissive=new at().setRGB(u[0],u[1],u[2],fn)}return s.emissiveTexture!==void 0&&o!==Br&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,Wt)),Promise.all(c).then(function(){const u=new o(a);return s.name&&(u.name=s.name),kr(u,s),t.associations.set(u,{materials:e}),s.extensions&&us(r,u,s),u})}createUniqueName(e){const t=It.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function s(a){return i[yt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return _R(l,a,t)})}const o=[];for(let a=0,l=e.length;a0&&Xvt(h,s),h.name=t.createUniqueName(s.name||"mesh_"+e),kr(h,s),g.extensions&&us(r,h,g),t.assignFinalMaterial(h),u.push(h)}for(let f=0,E=u.length;f1?d=new Ts:c.length===1?d=c[0]:d=new Yt,d!==c[0])for(let u=0,_=c.length;u<_;u++)d.add(c[u]);if(s.name&&(d.userData.name=s.name,d.name=o),kr(d,s),s.extensions&&us(i,d,s),s.matrix!==void 0){const u=new gt;u.fromArray(s.matrix),d.applyMatrix4(u)}else s.translation!==void 0&&d.position.fromArray(s.translation),s.rotation!==void 0&&d.quaternion.fromArray(s.rotation),s.scale!==void 0&&d.scale.fromArray(s.scale);return r.associations.has(d)||r.associations.set(d,{}),r.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],r=this,s=new Ts;i.name&&(s.name=r.createUniqueName(i.name)),kr(s,i),i.extensions&&us(t,s,i);const o=i.nodes||[],a=[];for(let l=0,c=o.length;l{const u=new Map;for(const[_,f]of r.associations)(_ instanceof fi||_ instanceof pn)&&u.set(_,f);return d.traverse(_=>{const f=r.associations.get(_);f!=null&&u.set(_,f)}),u};return r.associations=c(s),s})}_createAnimationTracks(e,t,i,r,s){const o=[],a=e.name?e.name:e.uuid,l=[];Rr[s.path]===Rr.weights?e.traverse(function(_){_.morphTargetInfluences&&l.push(_.name?_.name:_.uuid)}):l.push(a);let c;switch(Rr[s.path]){case Rr.weights:c=na;break;case Rr.rotation:c=Fs;break;case Rr.position:case Rr.scale:c=ia;break;default:switch(i.itemSize){case 1:c=na;break;case 2:case 3:default:c=ia;break}break}const d=r.interpolation!==void 0?Kvt[r.interpolation]:Jo,u=this._getArrayFromAccessor(i);for(let _=0,f=l.length;_({})}},computed:{isReady:{get(){return this.$store.state.ready}}},watch:{"$store.state.mountedPersArr":"updatePersonality","$store.state.config.active_personality_id":"updatePersonality"},async mounted(){for(;this.isReady===!1;)await new Promise(n=>setTimeout(n,100));console.log("ready"),this.updatePersonality(),this.initWebGLScene()},beforeDestroy(){},methods:{initWebGLScene(){this.scene=new Uyt,this.camera=new Cn(75,window.innerWidth/window.innerHeight,.1,1e3),this.renderer=new gO,this.renderer.setSize(window.innerWidth,window.innerHeight),this.$refs.webglContainer.appendChild(this.renderer.domElement);const n=new $r,e=new iR({color:65280});this.cube=new An(n,e),this.scene.add(this.cube);const t=new _vt(4210752),i=new CO(16777215,.5);i.position.set(0,1,0),this.scene.add(t),this.scene.add(i),this.camera.position.z=5,this.animate()},updatePersonality(){const{mountedPersArr:n,config:e}=this.$store.state,t=n[e.active_personality_id];console.log("activePersonality:",t),this.$emit("update:personality",t)},loadScene(n){new Tvt().load(n,t=>{this.scene.remove(this.cube),this.cube=t.scene,this.scene.add(this.cube)})},showBoxWithAvatar(n){this.scene.remove(this.cube);const e=new $r,t=new xO().load(n),i=new Br({map:t});this.cube=new An(e,i),this.scene.add(this.cube)},showDefaultCube(){this.scene.remove(this.cube);const n=new $r,e=new iR({color:65280});this.cube=new An(n,e),this.scene.add(this.cube)},animate(){requestAnimationFrame(this.animate),this.cube&&(this.cube.rotation.x+=.01,this.cube.rotation.y+=.01),this.renderer.render(this.scene,this.camera)}}},rTt={ref:"webglContainer"},sTt={key:0};function oTt(n,e,t,i,r,s){return D(),L("div",rTt,[!t.personality.scene_path&&(!t.personality.avatar||t.personality.avatar==="")?(D(),L("div",sTt," Personality does not have an avatar. ")):se("",!0)],512)}const aTt=bt(iTt,[["render",oTt]]),lTt=rL({history:v2("/"),routes:[{path:"/playground/",name:"playground",component:uKe},{path:"/extensions/",name:"extensions",component:vKe},{path:"/help/",name:"help",component:HKe},{path:"/settings/",name:"settings",component:Vat},{path:"/training/",name:"training",component:dlt},{path:"/quantizing/",name:"quantizing",component:blt},{path:"/",name:"discussions",component:mht},{path:"/",name:"interactive",component:aTt}]});const uu=fI($L);console.log("Loaded main.js");function pR(n){const e={};for(const t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);return e}const cTt=zI({state(){return{ready:!1,loading_infos:"",loading_progress:0,version:"unknown",settingsChanged:!1,isConnected:!1,isModelOk:!1,isGenerating:!1,config:null,mountedPers:null,mountedPersArr:[],mountedExtensions:[],bindingsZoo:[],modelsArr:[],selectedModel:null,personalities:[],diskUsage:null,ramUsage:null,vramUsage:null,modelsZoo:[],installedModels:[],currentModel:null,extensionsZoo:[],databases:[]}},mutations:{setIsReady(n,e){n.ready=e},setIsConnected(n,e){n.isConnected=e},setIsModelOk(n,e){n.isModelOk=e},setIsGenerating(n,e){n.isGenerating=e},setConfig(n,e){n.config=e},setPersonalities(n,e){n.personalities=e},setMountedPers(n,e){n.mountedPers=e},setMountedPersArr(n,e){n.mountedPersArr=e},setMountedExtensions(n,e){n.mountedExtensions=e},setbindingsZoo(n,e){n.bindingsZoo=e},setModelsArr(n,e){n.modelsArr=e},setselectedModel(n,e){n.selectedModel=e},setDiskUsage(n,e){n.diskUsage=e},setRamUsage(n,e){n.ramUsage=e},setVramUsage(n,e){n.vramUsage=e},setModelsZoo(n,e){n.modelsZoo=e},setCurrentModel(n,e){n.currentModel=e},setExtensionsZoo(n,e){n.extensionsZoo=e},setDatabases(n,e){n.databases=e}},getters:{getIsConnected(n){return n.isConnected},getIsModelOk(n){return n.isModelOk},getIsGenerating(n){return n.isGenerating},getConfig(n){return n.config},getPersonalities(n){return n.personalities},getMountedPersArr(n){return n.mountedPersArr},getmmountedExtensions(n){return n.mountedExtensions},getMountedPers(n){return n.mountedPers},getbindingsZoo(n){return n.bindingsZoo},getModelsArr(n){return n.modelsArr},getDiskUsage(n){return n.diskUsage},getRamUsage(n){return n.ramUsage},getVramUsage(n){return n.vramUsage},getDatabasesList(n){return n.databases},getModelsZoo(n){return n.modelsZoo},getCurrentModel(n){return n.currentModel},getExtensionsZoo(n){return n.extensionsZoo}},actions:{async getVersion(){try{let n=await Be.get("/get_lollms_webui_version",{});n&&(this.state.version=n.data.version)}catch{console.log("Coudln't get version")}},async refreshConfig({commit:n}){console.log("Fetching configuration");try{const e=await oi("get_config");e.active_personality_id<0&&(e.active_personality_id=0);let t=e.personalities[e.active_personality_id].split("/");e.personality_category=t[0],e.personality_folder=t[1],e.extensions.length>0?e.extension_category=e.extensions[-1]:e.extension_category="ai_sensors",console.log("Recovered config"),console.log(e),console.log("Committing config"),console.log(e),console.log(this.state.config),n("setConfig",e)}catch(e){console.log(e.message,"refreshConfig")}},async refreshDatabase({commit:n}){let e=await oi("list_databases");console.log("databases:",e),n("setDatabases",e)},async refreshPersonalitiesZoo({commit:n}){let e=[];const t=await oi("get_all_personalities"),i=Object.keys(t);console.log("Personalities recovered:"+this.state.config.personalities);for(let r=0;r{let c=!1;for(const u of this.state.config.personalities)if(u.includes(s+"/"+l.folder)&&(c=!0,u.includes(":"))){const _=u.split(":");l.language=_[1]}let d={};return d=l,d.category=s,d.full_path=s+"/"+l.folder,d.isMounted=c,d});e.length==0?e=a:e=e.concat(a)}e.sort((r,s)=>r.name.localeCompare(s.name)),n("setPersonalities",e),console.log("Done loading personalities")},refreshMountedPersonalities({commit:n}){this.state.config.active_personality_id<0&&(this.state.config.active_personality_id=0);let e=[];const t=[];for(let i=0;ia.full_path==r||a.full_path==s[0]);if(o>=0){let a=pR(this.state.personalities[o]);s.length>1&&(a.language=s[1]),a?e.push(a):e.push(this.state.personalities[this.state.personalities.findIndex(l=>l.full_path=="generic/lollms")])}else t.push(i),console.log("Couldn't load personality : ",r)}for(let i=t.length-1;i>=0;i--)console.log("Removing personality : ",this.state.config.personalities[t[i]]),this.state.config.personalities.splice(t[i],1),this.state.config.active_personality_id>t[i]&&(this.state.config.active_personality_id-=1);n("setMountedPersArr",e),this.state.mountedPers=this.state.personalities[this.state.personalities.findIndex(i=>i.full_path==this.state.config.personalities[this.state.config.active_personality_id]||i.full_path+":"+i.language==this.state.config.personalities[this.state.config.active_personality_id])]},async refreshBindings({commit:n}){let e=await oi("list_bindings");n("setbindingsZoo",e)},async refreshModelsZoo({commit:n}){console.log("Fetching models");const e=await Be.get("/get_available_models");n("setModelsZoo",e.data.filter(t=>t.variants&&t.variants.length>0))},async refreshModelStatus({commit:n}){let e=await oi("get_model_status");n("setIsModelOk",e.status)},async refreshModels({commit:n}){console.log("Fetching models");let e=await oi("list_models");console.log(`Found ${e}`);let t=await oi("get_active_model");console.log("Selected model ",t),t!=null&&n("setselectedModel",t.model),n("setModelsArr",e),console.log("setModelsArr",e),this.state.modelsZoo.map(r=>{r.isInstalled=e.includes(r.name)}),this.state.installedModels=this.state.modelsZoo.filter(r=>r.isInstalled);const i=this.state.modelsZoo.findIndex(r=>r.name==this.state.config.model_name);i!=-1&&n("setCurrentModel",this.state.modelsZoo[i])},async refreshExtensionsZoo({commit:n}){let e=[],t=await oi("list_extensions");const i=Object.keys(t);console.log("Extensions recovered:"+t);for(let r=0;r{let c=!1;for(const u of this.state.config.extensions)u.includes(s+"/"+l.folder)&&(c=!0);let d={};return d=l,d.category=s,d.full_path=s+"/"+l.folder,d.isMounted=c,d});e.length==0?e=a:e=e.concat(a)}e.sort((r,s)=>r.name.localeCompare(s.name)),n("setActiveExtensions",this.state.config.extensions),console.log("Done loading extensions"),n("setExtensionsZoo",e)},refreshmountedExtensions({commit:n}){console.log("Mounting extensions");let e=[];const t=[];for(let i=0;io.full_path==r);if(s>=0){let o=pR(this.state.config.extensions[s]);o&&e.push(o)}else t.push(i),console.log("Couldn't load extension : ",r)}for(let i=t.length-1;i>=0;i--)console.log("Removing extensions : ",this.state.config.extensions[t[i]]),this.state.config.extensions.splice(t[i],1);n("setMountedExtensions",e)},async refreshDiskUsage({commit:n}){this.state.diskUsage=await oi("disk_usage")},async refreshRamUsage({commit:n}){this.state.ramUsage=await oi("ram_usage")},async refreshVramUsage({commit:n}){const e=await oi("vram_usage"),t=[];if(e.nb_gpus>0){for(let r=0;rd||r.y>d)&&(r.x>d&&(s.x=Math.floor(d/Y.x),r.x=s.x*Y.x,I.mapSize.x=s.x),r.y>d&&(s.y=Math.floor(d/Y.y),r.y=s.y*Y.y,I.mapSize.y=s.y)),I.map===null||k===!0||W===!0){const q=this.type!==Zi?{minFilter:ln,magFilter:ln}:{};I.map!==null&&I.map.dispose(),I.map=new Ps(r.x,r.y,q),I.map.texture.name=z.name+".shadowMap",I.camera.updateProjectionMatrix()}n.setRenderTarget(I.map),n.clear();const K=I.getViewportCount();for(let q=0;q0||C.map&&C.alphaTest>0){const P=y.uuid,k=C.uuid;let W=c[P];W===void 0&&(W={},c[P]=W);let M=W[k];M===void 0&&(M=y.clone(),W[k]=M),y=M}if(y.visible=C.visible,y.wireframe=C.wireframe,x===Zi?y.side=C.shadowSide!==null?C.shadowSide:C.side:y.side=C.shadowSide!==null?C.shadowSide:u[C.side],y.alphaMap=C.alphaMap,y.alphaTest=C.alphaTest,y.map=C.map,y.clipShadows=C.clipShadows,y.clippingPlanes=C.clippingPlanes,y.clipIntersection=C.clipIntersection,y.displacementMap=C.displacementMap,y.displacementScale=C.displacementScale,y.displacementBias=C.displacementBias,y.wireframeLinewidth=C.wireframeLinewidth,y.linewidth=C.linewidth,N.isPointLight===!0&&y.isMeshDistanceMaterial===!0){const P=n.properties.get(y);P.light=N}return y}function v(T,C,N,x,y){if(T.visible===!1)return;if(T.layers.test(C.layers)&&(T.isMesh||T.isLine||T.isPoints)&&(T.castShadow||T.receiveShadow&&y===Zi)&&(!T.frustumCulled||i.intersectsObject(T))){T.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,T.matrixWorld);const k=e.update(T),W=T.material;if(Array.isArray(W)){const M=k.groups;for(let H=0,z=M.length;H=1):q.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),Y=K>=2);let le=null,X={};const Z=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),fe=new kt().fromArray(Z),ye=new kt().fromArray(_e);function j(oe,He,Le,Ce){const ke=new Uint8Array(4),it=n.createTexture();n.bindTexture(oe,it),n.texParameteri(oe,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(oe,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let _t=0;_t"u"?!1:/OculusBrowser/g.test(navigator.userAgent),E=new WeakMap;let b;const g=new WeakMap;let h=!1;try{h=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(w,A){return h?new OffscreenCanvas(w,A):Cl("canvas")}function S(w,A,G,ce){let $=1;if((w.width>ce||w.height>ce)&&($=ce/Math.max(w.width,w.height)),$<1||A===!0)if(typeof HTMLImageElement<"u"&&w instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&w instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&w instanceof ImageBitmap){const J=A?Cd:Math.floor,ve=J($*w.width),Ee=J($*w.height);b===void 0&&(b=m(ve,Ee));const Me=G?m(ve,Ee):b;return Me.width=ve,Me.height=Ee,Me.getContext("2d").drawImage(w,0,0,ve,Ee),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+w.width+"x"+w.height+") to ("+ve+"x"+Ee+")."),Me}else return"data"in w&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+w.width+"x"+w.height+")."),w;return w}function v(w){return rg(w.width)&&rg(w.height)}function T(w){return a?!1:w.wrapS!==Wn||w.wrapT!==Wn||w.minFilter!==ln&&w.minFilter!==Mn}function C(w,A){return w.generateMipmaps&&A&&w.minFilter!==ln&&w.minFilter!==Mn}function N(w){n.generateMipmap(w)}function x(w,A,G,ce,$=!1){if(a===!1)return A;if(w!==null){if(n[w]!==void 0)return n[w];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+w+"'")}let J=A;if(A===n.RED&&(G===n.FLOAT&&(J=n.R32F),G===n.HALF_FLOAT&&(J=n.R16F),G===n.UNSIGNED_BYTE&&(J=n.R8)),A===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(J=n.R8UI),G===n.UNSIGNED_SHORT&&(J=n.R16UI),G===n.UNSIGNED_INT&&(J=n.R32UI),G===n.BYTE&&(J=n.R8I),G===n.SHORT&&(J=n.R16I),G===n.INT&&(J=n.R32I)),A===n.RG&&(G===n.FLOAT&&(J=n.RG32F),G===n.HALF_FLOAT&&(J=n.RG16F),G===n.UNSIGNED_BYTE&&(J=n.RG8)),A===n.RGBA){const ve=$?yd:Nt.getTransfer(ce);G===n.FLOAT&&(J=n.RGBA32F),G===n.HALF_FLOAT&&(J=n.RGBA16F),G===n.UNSIGNED_BYTE&&(J=ve===Gt?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT_4_4_4_4&&(J=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(J=n.RGB5_A1)}return(J===n.R16F||J===n.R32F||J===n.RG16F||J===n.RG32F||J===n.RGBA16F||J===n.RGBA32F)&&e.get("EXT_color_buffer_float"),J}function y(w,A,G){return C(w,G)===!0||w.isFramebufferTexture&&w.minFilter!==ln&&w.minFilter!==Mn?Math.log2(Math.max(A.width,A.height))+1:w.mipmaps!==void 0&&w.mipmaps.length>0?w.mipmaps.length:w.isCompressedTexture&&Array.isArray(w.image)?A.mipmaps.length:1}function R(w){return w===ln||w===eg||w===Kc?n.NEAREST:n.LINEAR}function P(w){const A=w.target;A.removeEventListener("dispose",P),W(A),A.isVideoTexture&&E.delete(A)}function k(w){const A=w.target;A.removeEventListener("dispose",k),H(A)}function W(w){const A=i.get(w);if(A.__webglInit===void 0)return;const G=w.source,ce=g.get(G);if(ce){const $=ce[A.__cacheKey];$.usedTimes--,$.usedTimes===0&&M(w),Object.keys(ce).length===0&&g.delete(G)}i.remove(w)}function M(w){const A=i.get(w);n.deleteTexture(A.__webglTexture);const G=w.source,ce=g.get(G);delete ce[A.__cacheKey],o.memory.textures--}function H(w){const A=w.texture,G=i.get(w),ce=i.get(A);if(ce.__webglTexture!==void 0&&(n.deleteTexture(ce.__webglTexture),o.memory.textures--),w.depthTexture&&w.depthTexture.dispose(),w.isWebGLCubeRenderTarget)for(let $=0;$<6;$++){if(Array.isArray(G.__webglFramebuffer[$]))for(let J=0;J=l&&console.warn("THREE.WebGLTextures: Trying to use "+w+" texture units while this GPU supports only "+l),z+=1,w}function K(w){const A=[];return A.push(w.wrapS),A.push(w.wrapT),A.push(w.wrapR||0),A.push(w.magFilter),A.push(w.minFilter),A.push(w.anisotropy),A.push(w.internalFormat),A.push(w.format),A.push(w.type),A.push(w.generateMipmaps),A.push(w.premultiplyAlpha),A.push(w.flipY),A.push(w.unpackAlignment),A.push(w.colorSpace),A.join()}function q(w,A){const G=i.get(w);if(w.isVideoTexture&&te(w),w.isRenderTargetTexture===!1&&w.version>0&&G.__version!==w.version){const ce=w.image;if(ce===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(ce.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Q(G,w,A);return}}t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+A)}function le(w,A){const G=i.get(w);if(w.version>0&&G.__version!==w.version){Q(G,w,A);return}t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+A)}function X(w,A){const G=i.get(w);if(w.version>0&&G.__version!==w.version){Q(G,w,A);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+A)}function Z(w,A){const G=i.get(w);if(w.version>0&&G.__version!==w.version){he(G,w,A);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+A)}const _e={[Xo]:n.REPEAT,[Wn]:n.CLAMP_TO_EDGE,[Sd]:n.MIRRORED_REPEAT},fe={[ln]:n.NEAREST,[eg]:n.NEAREST_MIPMAP_NEAREST,[Kc]:n.NEAREST_MIPMAP_LINEAR,[Mn]:n.LINEAR,[Hw]:n.LINEAR_MIPMAP_NEAREST,[ks]:n.LINEAR_MIPMAP_LINEAR},ye={[dmt]:n.NEVER,[mmt]:n.ALWAYS,[umt]:n.LESS,[Zw]:n.LEQUAL,[_mt]:n.EQUAL,[hmt]:n.GEQUAL,[pmt]:n.GREATER,[fmt]:n.NOTEQUAL};function j(w,A,G){if(G?(n.texParameteri(w,n.TEXTURE_WRAP_S,_e[A.wrapS]),n.texParameteri(w,n.TEXTURE_WRAP_T,_e[A.wrapT]),(w===n.TEXTURE_3D||w===n.TEXTURE_2D_ARRAY)&&n.texParameteri(w,n.TEXTURE_WRAP_R,_e[A.wrapR]),n.texParameteri(w,n.TEXTURE_MAG_FILTER,fe[A.magFilter]),n.texParameteri(w,n.TEXTURE_MIN_FILTER,fe[A.minFilter])):(n.texParameteri(w,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(w,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),(w===n.TEXTURE_3D||w===n.TEXTURE_2D_ARRAY)&&n.texParameteri(w,n.TEXTURE_WRAP_R,n.CLAMP_TO_EDGE),(A.wrapS!==Wn||A.wrapT!==Wn)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),n.texParameteri(w,n.TEXTURE_MAG_FILTER,R(A.magFilter)),n.texParameteri(w,n.TEXTURE_MIN_FILTER,R(A.minFilter)),A.minFilter!==ln&&A.minFilter!==Mn&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),A.compareFunction&&(n.texParameteri(w,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(w,n.TEXTURE_COMPARE_FUNC,ye[A.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const ce=e.get("EXT_texture_filter_anisotropic");if(A.magFilter===ln||A.minFilter!==Kc&&A.minFilter!==ks||A.type===nr&&e.has("OES_texture_float_linear")===!1||a===!1&&A.type===Tl&&e.has("OES_texture_half_float_linear")===!1)return;(A.anisotropy>1||i.get(A).__currentAnisotropy)&&(n.texParameterf(w,ce.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(A.anisotropy,r.getMaxAnisotropy())),i.get(A).__currentAnisotropy=A.anisotropy)}}function de(w,A){let G=!1;w.__webglInit===void 0&&(w.__webglInit=!0,A.addEventListener("dispose",P));const ce=A.source;let $=g.get(ce);$===void 0&&($={},g.set(ce,$));const J=K(A);if(J!==w.__cacheKey){$[J]===void 0&&($[J]={texture:n.createTexture(),usedTimes:0},o.memory.textures++,G=!0),$[J].usedTimes++;const ve=$[w.__cacheKey];ve!==void 0&&($[w.__cacheKey].usedTimes--,ve.usedTimes===0&&M(A)),w.__cacheKey=J,w.__webglTexture=$[J].texture}return G}function Q(w,A,G){let ce=n.TEXTURE_2D;(A.isDataArrayTexture||A.isCompressedArrayTexture)&&(ce=n.TEXTURE_2D_ARRAY),A.isData3DTexture&&(ce=n.TEXTURE_3D);const $=de(w,A),J=A.source;t.bindTexture(ce,w.__webglTexture,n.TEXTURE0+G);const ve=i.get(J);if(J.version!==ve.__version||$===!0){t.activeTexture(n.TEXTURE0+G);const Ee=Nt.getPrimaries(Nt.workingColorSpace),Me=A.colorSpace===jn?null:Nt.getPrimaries(A.colorSpace),Ue=A.colorSpace===jn||Ee===Me?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,A.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,A.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,A.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ue);const Je=T(A)&&v(A.image)===!1;let Ne=S(A.image,Je,!1,d);Ne=ie(A,Ne);const tt=v(Ne)||a,$e=s.convert(A.format,A.colorSpace);let Pe=s.convert(A.type),je=x(A.internalFormat,$e,Pe,A.colorSpace,A.isVideoTexture);j(ce,A,tt);let Ve;const ct=A.mipmaps,oe=a&&A.isVideoTexture!==!0&&je!==jw,He=ve.__version===void 0||$===!0,Le=y(A,Ne,tt);if(A.isDepthTexture)je=n.DEPTH_COMPONENT,a?A.type===nr?je=n.DEPTH_COMPONENT32F:A.type===Fr?je=n.DEPTH_COMPONENT24:A.type===ws?je=n.DEPTH24_STENCIL8:je=n.DEPTH_COMPONENT16:A.type===nr&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),A.format===Os&&je===n.DEPTH_COMPONENT&&A.type!==UE&&A.type!==Fr&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),A.type=Fr,Pe=s.convert(A.type)),A.format===Zo&&je===n.DEPTH_COMPONENT&&(je=n.DEPTH_STENCIL,A.type!==ws&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),A.type=ws,Pe=s.convert(A.type))),He&&(oe?t.texStorage2D(n.TEXTURE_2D,1,je,Ne.width,Ne.height):t.texImage2D(n.TEXTURE_2D,0,je,Ne.width,Ne.height,0,$e,Pe,null));else if(A.isDataTexture)if(ct.length>0&&tt){oe&&He&&t.texStorage2D(n.TEXTURE_2D,Le,je,ct[0].width,ct[0].height);for(let Ce=0,ke=ct.length;Ce>=1,ke>>=1}}else if(ct.length>0&&tt){oe&&He&&t.texStorage2D(n.TEXTURE_2D,Le,je,ct[0].width,ct[0].height);for(let Ce=0,ke=ct.length;Ce0&&He++,t.texStorage2D(n.TEXTURE_CUBE_MAP,He,Ve,Ne[0].width,Ne[0].height));for(let Ce=0;Ce<6;Ce++)if(Je){ct?t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,0,0,Ne[Ce].width,Ne[Ce].height,Pe,je,Ne[Ce].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,0,Ve,Ne[Ce].width,Ne[Ce].height,0,Pe,je,Ne[Ce].data);for(let ke=0;ke>J),Ne=Math.max(1,A.height>>J);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,J,Me,Je,Ne,A.depth,0,ve,Ee,null):t.texImage2D($,J,Me,Je,Ne,0,ve,Ee,null)}t.bindFramebuffer(n.FRAMEBUFFER,w),ae(A)?_.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,ce,$,i.get(G).__webglTexture,0,B(A)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,ce,$,i.get(G).__webglTexture,J),t.bindFramebuffer(n.FRAMEBUFFER,null)}function O(w,A,G){if(n.bindRenderbuffer(n.RENDERBUFFER,w),A.depthBuffer&&!A.stencilBuffer){let ce=a===!0?n.DEPTH_COMPONENT24:n.DEPTH_COMPONENT16;if(G||ae(A)){const $=A.depthTexture;$&&$.isDepthTexture&&($.type===nr?ce=n.DEPTH_COMPONENT32F:$.type===Fr&&(ce=n.DEPTH_COMPONENT24));const J=B(A);ae(A)?_.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,J,ce,A.width,A.height):n.renderbufferStorageMultisample(n.RENDERBUFFER,J,ce,A.width,A.height)}else n.renderbufferStorage(n.RENDERBUFFER,ce,A.width,A.height);n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,w)}else if(A.depthBuffer&&A.stencilBuffer){const ce=B(A);G&&ae(A)===!1?n.renderbufferStorageMultisample(n.RENDERBUFFER,ce,n.DEPTH24_STENCIL8,A.width,A.height):ae(A)?_.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ce,n.DEPTH24_STENCIL8,A.width,A.height):n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,A.width,A.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,w)}else{const ce=A.isWebGLMultipleRenderTargets===!0?A.texture:[A.texture];for(let $=0;$0){G.__webglFramebuffer[Ee]=[];for(let Me=0;Me0){G.__webglFramebuffer=[];for(let Ee=0;Ee0&&ae(w)===!1){const Ee=J?A:[A];G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let Me=0;Me0)for(let Me=0;Me0)for(let Me=0;Me0&&ae(w)===!1){const A=w.isWebGLMultipleRenderTargets?w.texture:[w.texture],G=w.width,ce=w.height;let $=n.COLOR_BUFFER_BIT;const J=[],ve=w.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,Ee=i.get(w),Me=w.isWebGLMultipleRenderTargets===!0;if(Me)for(let Ue=0;Ue0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&A.__useRenderToTexture!==!1}function te(w){const A=o.render.frame;E.get(w)!==A&&(E.set(w,A),w.update())}function ie(w,A){const G=w.colorSpace,ce=w.format,$=w.type;return w.isCompressedTexture===!0||w.isVideoTexture===!0||w.format===ig||G!==fn&&G!==jn&&(Nt.getTransfer(G)===Gt?a===!1?e.has("EXT_sRGB")===!0&&ce===Kn?(w.format=ig,w.minFilter=Mn,w.generateMipmaps=!1):A=eO.sRGBToLinear(A):(ce!==Kn||$!==Yr)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",G)),A}this.allocateTextureUnit=Y,this.resetTextureUnits=I,this.setTexture2D=q,this.setTexture2DArray=le,this.setTexture3D=X,this.setTextureCube=Z,this.rebindTextures=re,this.setupRenderTarget=ee,this.updateRenderTargetMipmap=be,this.updateMultisampleRenderTarget=xe,this.setupDepthRenderbuffer=V,this.setupFrameBufferTexture=Ae,this.useMultisampledRTT=ae}function Nyt(n,e,t){const i=t.isWebGL2;function r(s,o=jn){let a;const l=Nt.getTransfer(o);if(s===Yr)return n.UNSIGNED_BYTE;if(s===qw)return n.UNSIGNED_SHORT_4_4_4_4;if(s===Yw)return n.UNSIGNED_SHORT_5_5_5_1;if(s===Xht)return n.BYTE;if(s===Zht)return n.SHORT;if(s===UE)return n.UNSIGNED_SHORT;if(s===Vw)return n.INT;if(s===Fr)return n.UNSIGNED_INT;if(s===nr)return n.FLOAT;if(s===Tl)return i?n.HALF_FLOAT:(a=e.get("OES_texture_half_float"),a!==null?a.HALF_FLOAT_OES:null);if(s===Jht)return n.ALPHA;if(s===Kn)return n.RGBA;if(s===emt)return n.LUMINANCE;if(s===tmt)return n.LUMINANCE_ALPHA;if(s===Os)return n.DEPTH_COMPONENT;if(s===Zo)return n.DEPTH_STENCIL;if(s===ig)return a=e.get("EXT_sRGB"),a!==null?a.SRGB_ALPHA_EXT:null;if(s===nmt)return n.RED;if(s===$w)return n.RED_INTEGER;if(s===imt)return n.RG;if(s===Ww)return n.RG_INTEGER;if(s===Kw)return n.RGBA_INTEGER;if(s===Ah||s===wh||s===Oh||s===Nh)if(l===Gt)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(s===Ah)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===wh)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===Oh)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===Nh)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(s===Ah)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===wh)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===Oh)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===Nh)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===Ax||s===wx||s===Ox||s===Nx)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(s===Ax)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===wx)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===Ox)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===Nx)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===jw)return a=e.get("WEBGL_compressed_texture_etc1"),a!==null?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===Mx||s===Ix)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(s===Mx)return l===Gt?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(s===Ix)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===Dx||s===Lx||s===kx||s===Px||s===Ux||s===Fx||s===Bx||s===Gx||s===zx||s===Hx||s===Vx||s===qx||s===Yx||s===$x)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(s===Dx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===Lx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===kx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===Px)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===Ux)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===Fx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===Bx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===Gx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===zx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===Hx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===Vx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===qx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===Yx)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===$x)return l===Gt?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===Mh||s===Wx||s===Kx)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(s===Mh)return l===Gt?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===Wx)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===Kx)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===rmt||s===jx||s===Qx||s===Xx)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(s===Mh)return a.COMPRESSED_RED_RGTC1_EXT;if(s===jx)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===Qx)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===Xx)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===ws?i?n.UNSIGNED_INT_24_8:(a=e.get("WEBGL_depth_texture"),a!==null?a.UNSIGNED_INT_24_8_WEBGL:null):n[s]!==void 0?n[s]:null}return{convert:r}}class Myt extends Cn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Ts extends Yt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Iyt={type:"move"};class tm{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Ts,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Ts,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ue,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ue),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Ts,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ue,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ue),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const i of e.hand.values())this._getHandJoint(t,i)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,i){let r=null,s=null,o=null;const a=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){o=!0;for(const b of e.hand.values()){const g=t.getJointPose(b,i),h=this._getHandJoint(c,b);g!==null&&(h.matrix.fromArray(g.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),h.matrixWorldNeedsUpdate=!0,h.jointRadius=g.radius),h.visible=g!==null}const d=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],_=d.position.distanceTo(u.position),f=.02,E=.005;c.inputState.pinching&&_>f+E?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&_<=f-E&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(s=t.getPose(e.gripSpace,i),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));a!==null&&(r=t.getPose(e.targetRaySpace,i),r===null&&s!==null&&(r=s),r!==null&&(a.matrix.fromArray(r.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,r.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(r.linearVelocity)):a.hasLinearVelocity=!1,r.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(r.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Iyt)))}return a!==null&&(a.visible=r!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=o!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new Ts;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class Dyt extends ma{constructor(e,t){super();const i=this;let r=null,s=1,o=null,a="local-floor",l=1,c=null,d=null,u=null,_=null,f=null,E=null;const b=t.getContextAttributes();let g=null,h=null;const m=[],S=[],v=new vt;let T=null;const C=new Cn;C.layers.enable(1),C.viewport=new kt;const N=new Cn;N.layers.enable(2),N.viewport=new kt;const x=[C,N],y=new Myt;y.layers.enable(1),y.layers.enable(2);let R=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let _e=m[Z];return _e===void 0&&(_e=new tm,m[Z]=_e),_e.getTargetRaySpace()},this.getControllerGrip=function(Z){let _e=m[Z];return _e===void 0&&(_e=new tm,m[Z]=_e),_e.getGripSpace()},this.getHand=function(Z){let _e=m[Z];return _e===void 0&&(_e=new tm,m[Z]=_e),_e.getHandSpace()};function k(Z){const _e=S.indexOf(Z.inputSource);if(_e===-1)return;const fe=m[_e];fe!==void 0&&(fe.update(Z.inputSource,Z.frame,c||o),fe.dispatchEvent({type:Z.type,data:Z.inputSource}))}function W(){r.removeEventListener("select",k),r.removeEventListener("selectstart",k),r.removeEventListener("selectend",k),r.removeEventListener("squeeze",k),r.removeEventListener("squeezestart",k),r.removeEventListener("squeezeend",k),r.removeEventListener("end",W),r.removeEventListener("inputsourceschange",M);for(let Z=0;Z=0&&(S[ye]=null,m[ye].disconnect(fe))}for(let _e=0;_e=S.length){S.push(fe),ye=de;break}else if(S[de]===null){S[de]=fe,ye=de;break}if(ye===-1)break}const j=m[ye];j&&j.connect(fe)}}const H=new ue,z=new ue;function I(Z,_e,fe){H.setFromMatrixPosition(_e.matrixWorld),z.setFromMatrixPosition(fe.matrixWorld);const ye=H.distanceTo(z),j=_e.projectionMatrix.elements,de=fe.projectionMatrix.elements,Q=j[14]/(j[10]-1),he=j[14]/(j[10]+1),Ae=(j[9]+1)/j[5],O=(j[9]-1)/j[5],F=(j[8]-1)/j[0],V=(de[8]+1)/de[0],re=Q*F,ee=Q*V,be=ye/(-F+V),xe=be*-F;_e.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(xe),Z.translateZ(be),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert();const B=Q+be,ae=he+be,te=re-xe,ie=ee+(ye-xe),w=Ae*he/ae*B,A=O*he/ae*B;Z.projectionMatrix.makePerspective(te,ie,w,A,B,ae),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}function Y(Z,_e){_e===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(_e.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(r===null)return;y.near=N.near=C.near=Z.near,y.far=N.far=C.far=Z.far,(R!==y.near||P!==y.far)&&(r.updateRenderState({depthNear:y.near,depthFar:y.far}),R=y.near,P=y.far);const _e=Z.parent,fe=y.cameras;Y(y,_e);for(let ye=0;ye0&&(g.alphaTest.value=h.alphaTest);const m=e.get(h).envMap;if(m&&(g.envMap.value=m,g.flipEnvMap.value=m.isCubeTexture&&m.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=h.reflectivity,g.ior.value=h.ior,g.refractionRatio.value=h.refractionRatio),h.lightMap){g.lightMap.value=h.lightMap;const S=n._useLegacyLights===!0?Math.PI:1;g.lightMapIntensity.value=h.lightMapIntensity*S,t(h.lightMap,g.lightMapTransform)}h.aoMap&&(g.aoMap.value=h.aoMap,g.aoMapIntensity.value=h.aoMapIntensity,t(h.aoMap,g.aoMapTransform))}function o(g,h){g.diffuse.value.copy(h.color),g.opacity.value=h.opacity,h.map&&(g.map.value=h.map,t(h.map,g.mapTransform))}function a(g,h){g.dashSize.value=h.dashSize,g.totalSize.value=h.dashSize+h.gapSize,g.scale.value=h.scale}function l(g,h,m,S){g.diffuse.value.copy(h.color),g.opacity.value=h.opacity,g.size.value=h.size*m,g.scale.value=S*.5,h.map&&(g.map.value=h.map,t(h.map,g.uvTransform)),h.alphaMap&&(g.alphaMap.value=h.alphaMap,t(h.alphaMap,g.alphaMapTransform)),h.alphaTest>0&&(g.alphaTest.value=h.alphaTest)}function c(g,h){g.diffuse.value.copy(h.color),g.opacity.value=h.opacity,g.rotation.value=h.rotation,h.map&&(g.map.value=h.map,t(h.map,g.mapTransform)),h.alphaMap&&(g.alphaMap.value=h.alphaMap,t(h.alphaMap,g.alphaMapTransform)),h.alphaTest>0&&(g.alphaTest.value=h.alphaTest)}function d(g,h){g.specular.value.copy(h.specular),g.shininess.value=Math.max(h.shininess,1e-4)}function u(g,h){h.gradientMap&&(g.gradientMap.value=h.gradientMap)}function _(g,h){g.metalness.value=h.metalness,h.metalnessMap&&(g.metalnessMap.value=h.metalnessMap,t(h.metalnessMap,g.metalnessMapTransform)),g.roughness.value=h.roughness,h.roughnessMap&&(g.roughnessMap.value=h.roughnessMap,t(h.roughnessMap,g.roughnessMapTransform)),e.get(h).envMap&&(g.envMapIntensity.value=h.envMapIntensity)}function f(g,h,m){g.ior.value=h.ior,h.sheen>0&&(g.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),g.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(g.sheenColorMap.value=h.sheenColorMap,t(h.sheenColorMap,g.sheenColorMapTransform)),h.sheenRoughnessMap&&(g.sheenRoughnessMap.value=h.sheenRoughnessMap,t(h.sheenRoughnessMap,g.sheenRoughnessMapTransform))),h.clearcoat>0&&(g.clearcoat.value=h.clearcoat,g.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(g.clearcoatMap.value=h.clearcoatMap,t(h.clearcoatMap,g.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,t(h.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(g.clearcoatNormalMap.value=h.clearcoatNormalMap,t(h.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===Ln&&g.clearcoatNormalScale.value.negate())),h.iridescence>0&&(g.iridescence.value=h.iridescence,g.iridescenceIOR.value=h.iridescenceIOR,g.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(g.iridescenceMap.value=h.iridescenceMap,t(h.iridescenceMap,g.iridescenceMapTransform)),h.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=h.iridescenceThicknessMap,t(h.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),h.transmission>0&&(g.transmission.value=h.transmission,g.transmissionSamplerMap.value=m.texture,g.transmissionSamplerSize.value.set(m.width,m.height),h.transmissionMap&&(g.transmissionMap.value=h.transmissionMap,t(h.transmissionMap,g.transmissionMapTransform)),g.thickness.value=h.thickness,h.thicknessMap&&(g.thicknessMap.value=h.thicknessMap,t(h.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=h.attenuationDistance,g.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(g.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(g.anisotropyMap.value=h.anisotropyMap,t(h.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=h.specularIntensity,g.specularColor.value.copy(h.specularColor),h.specularColorMap&&(g.specularColorMap.value=h.specularColorMap,t(h.specularColorMap,g.specularColorMapTransform)),h.specularIntensityMap&&(g.specularIntensityMap.value=h.specularIntensityMap,t(h.specularIntensityMap,g.specularIntensityMapTransform))}function E(g,h){h.matcap&&(g.matcap.value=h.matcap)}function b(g,h){const m=e.get(h).light;g.referencePosition.value.setFromMatrixPosition(m.matrixWorld),g.nearDistance.value=m.shadow.camera.near,g.farDistance.value=m.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:r}}function kyt(n,e,t,i){let r={},s={},o=[];const a=t.isWebGL2?n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(m,S){const v=S.program;i.uniformBlockBinding(m,v)}function c(m,S){let v=r[m.id];v===void 0&&(E(m),v=d(m),r[m.id]=v,m.addEventListener("dispose",g));const T=S.program;i.updateUBOMapping(m,T);const C=e.render.frame;s[m.id]!==C&&(_(m),s[m.id]=C)}function d(m){const S=u();m.__bindingPointIndex=S;const v=n.createBuffer(),T=m.__size,C=m.usage;return n.bindBuffer(n.UNIFORM_BUFFER,v),n.bufferData(n.UNIFORM_BUFFER,T,C),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,S,v),v}function u(){for(let m=0;m0){C=v%T;const k=T-C;C!==0&&k-R.boundary<0&&(v+=T-C,y.__offset=v)}v+=R.storage}return C=v%T,C>0&&(v+=T-C),m.__size=v,m.__cache={},this}function b(m){const S={boundary:0,storage:0};return typeof m=="number"?(S.boundary=4,S.storage=4):m.isVector2?(S.boundary=8,S.storage=8):m.isVector3||m.isColor?(S.boundary=16,S.storage=12):m.isVector4?(S.boundary=16,S.storage=16):m.isMatrix3?(S.boundary=48,S.storage=48):m.isMatrix4?(S.boundary=64,S.storage=64):m.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",m),S}function g(m){const S=m.target;S.removeEventListener("dispose",g);const v=o.indexOf(S.__bindingPointIndex);o.splice(v,1),n.deleteBuffer(r[S.id]),delete r[S.id],delete s[S.id]}function h(){for(const m in r)n.deleteBuffer(r[m]);o=[],r={},s={}}return{bind:l,update:c,dispose:h}}class gO{constructor(e={}){const{canvas:t=Imt(),context:i=null,depth:r=!0,stencil:s=!0,alpha:o=!1,antialias:a=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let _;i!==null?_=i.getContextAttributes().alpha:_=o;const f=new Uint32Array(4),E=new Int32Array(4);let b=null,g=null;const h=[],m=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Wt,this._useLegacyLights=!1,this.toneMapping=qr,this.toneMappingExposure=1;const S=this;let v=!1,T=0,C=0,N=null,x=-1,y=null;const R=new kt,P=new kt;let k=null;const W=new at(0);let M=0,H=t.width,z=t.height,I=1,Y=null,K=null;const q=new kt(0,0,H,z),le=new kt(0,0,H,z);let X=!1;const Z=new zE;let _e=!1,fe=!1,ye=null;const j=new gt,de=new vt,Q=new ue,he={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ae(){return N===null?I:1}let O=i;function F(U,pe){for(let Se=0;Se{function qe(){if(Te.forEach(function(Qe){xe.get(Qe).currentProgram.isReady()&&Te.delete(Qe)}),Te.size===0){me(U);return}setTimeout(qe,10)}V.get("KHR_parallel_shader_compile")!==null?qe():setTimeout(qe,10)})};let _t=null;function $t(U){_t&&_t(U)}function tn(){Vt.stop()}function wt(){Vt.start()}const Vt=new dO;Vt.setAnimationLoop($t),typeof self<"u"&&Vt.setContext(self),this.setAnimationLoop=function(U){_t=U,Ve.setAnimationLoop(U),U===null?Vt.stop():Vt.start()},Ve.addEventListener("sessionstart",tn),Ve.addEventListener("sessionend",wt),this.render=function(U,pe){if(pe!==void 0&&pe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(v===!0)return;U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),pe.parent===null&&pe.matrixWorldAutoUpdate===!0&&pe.updateMatrixWorld(),Ve.enabled===!0&&Ve.isPresenting===!0&&(Ve.cameraAutoUpdate===!0&&Ve.updateCamera(pe),pe=Ve.getCamera()),U.isScene===!0&&U.onBeforeRender(S,U,pe,N),g=J.get(U,m.length),g.init(),m.push(g),j.multiplyMatrices(pe.projectionMatrix,pe.matrixWorldInverse),Z.setFromProjectionMatrix(j),fe=this.localClippingEnabled,_e=ve.init(this.clippingPlanes,fe),b=$.get(U,h.length),b.init(),h.push(b),On(U,pe,0,S.sortObjects),b.finish(),S.sortObjects===!0&&b.sort(Y,K),this.info.render.frame++,_e===!0&&ve.beginShadows();const Se=g.state.shadowsArray;if(Ee.render(Se,U,pe),_e===!0&&ve.endShadows(),this.info.autoReset===!0&&this.info.reset(),Me.render(b,U),g.setupLights(S._useLegacyLights),pe.isArrayCamera){const Te=pe.cameras;for(let me=0,qe=Te.length;me0?g=m[m.length-1]:g=null,h.pop(),h.length>0?b=h[h.length-1]:b=null};function On(U,pe,Se,Te){if(U.visible===!1)return;if(U.layers.test(pe.layers)){if(U.isGroup)Se=U.renderOrder;else if(U.isLOD)U.autoUpdate===!0&&U.update(pe);else if(U.isLight)g.pushLight(U),U.castShadow&&g.pushShadow(U);else if(U.isSprite){if(!U.frustumCulled||Z.intersectsSprite(U)){Te&&Q.setFromMatrixPosition(U.matrixWorld).applyMatrix4(j);const Qe=A.update(U),nt=U.material;nt.visible&&b.push(U,Qe,nt,Se,Q.z,null)}}else if((U.isMesh||U.isLine||U.isPoints)&&(!U.frustumCulled||Z.intersectsObject(U))){const Qe=A.update(U),nt=U.material;if(Te&&(U.boundingSphere!==void 0?(U.boundingSphere===null&&U.computeBoundingSphere(),Q.copy(U.boundingSphere.center)):(Qe.boundingSphere===null&&Qe.computeBoundingSphere(),Q.copy(Qe.boundingSphere.center)),Q.applyMatrix4(U.matrixWorld).applyMatrix4(j)),Array.isArray(nt)){const rt=Qe.groups;for(let dt=0,st=rt.length;dt0&&ya(me,qe,pe,Se),Te&&ee.viewport(R.copy(Te)),me.length>0&&Gi(me,pe,Se),qe.length>0&&Gi(qe,pe,Se),Qe.length>0&&Gi(Qe,pe,Se),ee.buffers.depth.setTest(!0),ee.buffers.depth.setMask(!0),ee.buffers.color.setMask(!0),ee.setPolygonOffset(!1)}function ya(U,pe,Se,Te){if((Se.isScene===!0?Se.overrideMaterial:null)!==null)return;const qe=re.isWebGL2;ye===null&&(ye=new Ps(1,1,{generateMipmaps:!0,type:V.has("EXT_color_buffer_half_float")?Tl:Yr,minFilter:ks,samples:qe?4:0})),S.getDrawingBufferSize(de),qe?ye.setSize(de.x,de.y):ye.setSize(Cd(de.x),Cd(de.y));const Qe=S.getRenderTarget();S.setRenderTarget(ye),S.getClearColor(W),M=S.getClearAlpha(),M<1&&S.setClearColor(16777215,.5),S.clear();const nt=S.toneMapping;S.toneMapping=qr,Gi(U,Se,Te),B.updateMultisampleRenderTarget(ye),B.updateRenderTargetMipmap(ye);let rt=!1;for(let dt=0,st=pe.length;dt0),lt=!!Se.morphAttributes.position,Ut=!!Se.morphAttributes.normal,dn=!!Se.morphAttributes.color;let qt=qr;Te.toneMapped&&(N===null||N.isXRRenderTarget===!0)&&(qt=S.toneMapping);const hn=Se.morphAttributes.position||Se.morphAttributes.normal||Se.morphAttributes.color,Bt=hn!==void 0?hn.length:0,pt=xe.get(Te),Ta=g.state.lights;if(_e===!0&&(fe===!0||U!==y)){const Nn=U===y&&Te.id===x;ve.setState(Te,U,Nn)}let Ht=!1;Te.version===pt.__version?(pt.needsLights&&pt.lightsStateVersion!==Ta.state.version||pt.outputColorSpace!==nt||me.isBatchedMesh&&pt.batching===!1||!me.isBatchedMesh&&pt.batching===!0||me.isInstancedMesh&&pt.instancing===!1||!me.isInstancedMesh&&pt.instancing===!0||me.isSkinnedMesh&&pt.skinning===!1||!me.isSkinnedMesh&&pt.skinning===!0||me.isInstancedMesh&&pt.instancingColor===!0&&me.instanceColor===null||me.isInstancedMesh&&pt.instancingColor===!1&&me.instanceColor!==null||pt.envMap!==rt||Te.fog===!0&&pt.fog!==qe||pt.numClippingPlanes!==void 0&&(pt.numClippingPlanes!==ve.numPlanes||pt.numIntersection!==ve.numIntersection)||pt.vertexAlphas!==dt||pt.vertexTangents!==st||pt.morphTargets!==lt||pt.morphNormals!==Ut||pt.morphColors!==dn||pt.toneMapping!==qt||re.isWebGL2===!0&&pt.morphTargetsCount!==Bt)&&(Ht=!0):(Ht=!0,pt.__version=Te.version);let Hi=pt.currentProgram;Ht===!0&&(Hi=zi(Te,pe,me));let Fl=!1,ns=!1,xa=!1;const on=Hi.getUniforms(),Vi=pt.uniforms;if(ee.useProgram(Hi.program)&&(Fl=!0,ns=!0,xa=!0),Te.id!==x&&(x=Te.id,ns=!0),Fl||y!==U){on.setValue(O,"projectionMatrix",U.projectionMatrix),on.setValue(O,"viewMatrix",U.matrixWorldInverse);const Nn=on.map.cameraPosition;Nn!==void 0&&Nn.setValue(O,Q.setFromMatrixPosition(U.matrixWorld)),re.logarithmicDepthBuffer&&on.setValue(O,"logDepthBufFC",2/(Math.log(U.far+1)/Math.LN2)),(Te.isMeshPhongMaterial||Te.isMeshToonMaterial||Te.isMeshLambertMaterial||Te.isMeshBasicMaterial||Te.isMeshStandardMaterial||Te.isShaderMaterial)&&on.setValue(O,"isOrthographic",U.isOrthographicCamera===!0),y!==U&&(y=U,ns=!0,xa=!0)}if(me.isSkinnedMesh){on.setOptional(O,me,"bindMatrix"),on.setOptional(O,me,"bindMatrixInverse");const Nn=me.skeleton;Nn&&(re.floatVertexTextures?(Nn.boneTexture===null&&Nn.computeBoneTexture(),on.setValue(O,"boneTexture",Nn.boneTexture,B)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}me.isBatchedMesh&&(on.setOptional(O,me,"batchingTexture"),on.setValue(O,"batchingTexture",me._matricesTexture,B));const Ca=Se.morphAttributes;if((Ca.position!==void 0||Ca.normal!==void 0||Ca.color!==void 0&&re.isWebGL2===!0)&&Ue.update(me,Se,Hi),(ns||pt.receiveShadow!==me.receiveShadow)&&(pt.receiveShadow=me.receiveShadow,on.setValue(O,"receiveShadow",me.receiveShadow)),Te.isMeshGouraudMaterial&&Te.envMap!==null&&(Vi.envMap.value=rt,Vi.flipEnvMap.value=rt.isCubeTexture&&rt.isRenderTargetTexture===!1?-1:1),ns&&(on.setValue(O,"toneMappingExposure",S.toneMappingExposure),pt.needsLights&&ts(Vi,xa),qe&&Te.fog===!0&&ce.refreshFogUniforms(Vi,qe),ce.refreshMaterialUniforms(Vi,Te,I,z,ye),jc.upload(O,es(pt),Vi,B)),Te.isShaderMaterial&&Te.uniformsNeedUpdate===!0&&(jc.upload(O,es(pt),Vi,B),Te.uniformsNeedUpdate=!1),Te.isSpriteMaterial&&on.setValue(O,"center",me.center),on.setValue(O,"modelViewMatrix",me.modelViewMatrix),on.setValue(O,"normalMatrix",me.normalMatrix),on.setValue(O,"modelMatrix",me.matrixWorld),Te.isShaderMaterial||Te.isRawShaderMaterial){const Nn=Te.uniformsGroups;for(let Ra=0,_u=Nn.length;Ra<_u;Ra++)if(re.isWebGL2){const Bl=Nn[Ra];Pe.update(Bl,Hi),Pe.bind(Bl,Hi)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Hi}function ts(U,pe){U.ambientLightColor.needsUpdate=pe,U.lightProbe.needsUpdate=pe,U.directionalLights.needsUpdate=pe,U.directionalLightShadows.needsUpdate=pe,U.pointLights.needsUpdate=pe,U.pointLightShadows.needsUpdate=pe,U.spotLights.needsUpdate=pe,U.spotLightShadows.needsUpdate=pe,U.rectAreaLights.needsUpdate=pe,U.hemisphereLights.needsUpdate=pe}function va(U){return U.isMeshLambertMaterial||U.isMeshToonMaterial||U.isMeshPhongMaterial||U.isMeshStandardMaterial||U.isShadowMaterial||U.isShaderMaterial&&U.lights===!0}this.getActiveCubeFace=function(){return T},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return N},this.setRenderTargetTextures=function(U,pe,Se){xe.get(U.texture).__webglTexture=pe,xe.get(U.depthTexture).__webglTexture=Se;const Te=xe.get(U);Te.__hasExternalTextures=!0,Te.__hasExternalTextures&&(Te.__autoAllocateDepthBuffer=Se===void 0,Te.__autoAllocateDepthBuffer||V.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),Te.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(U,pe){const Se=xe.get(U);Se.__webglFramebuffer=pe,Se.__useDefaultFramebuffer=pe===void 0},this.setRenderTarget=function(U,pe=0,Se=0){N=U,T=pe,C=Se;let Te=!0,me=null,qe=!1,Qe=!1;if(U){const rt=xe.get(U);rt.__useDefaultFramebuffer!==void 0?(ee.bindFramebuffer(O.FRAMEBUFFER,null),Te=!1):rt.__webglFramebuffer===void 0?B.setupRenderTarget(U):rt.__hasExternalTextures&&B.rebindTextures(U,xe.get(U.texture).__webglTexture,xe.get(U.depthTexture).__webglTexture);const dt=U.texture;(dt.isData3DTexture||dt.isDataArrayTexture||dt.isCompressedArrayTexture)&&(Qe=!0);const st=xe.get(U).__webglFramebuffer;U.isWebGLCubeRenderTarget?(Array.isArray(st[pe])?me=st[pe][Se]:me=st[pe],qe=!0):re.isWebGL2&&U.samples>0&&B.useMultisampledRTT(U)===!1?me=xe.get(U).__webglMultisampledFramebuffer:Array.isArray(st)?me=st[Se]:me=st,R.copy(U.viewport),P.copy(U.scissor),k=U.scissorTest}else R.copy(q).multiplyScalar(I).floor(),P.copy(le).multiplyScalar(I).floor(),k=X;if(ee.bindFramebuffer(O.FRAMEBUFFER,me)&&re.drawBuffers&&Te&&ee.drawBuffers(U,me),ee.viewport(R),ee.scissor(P),ee.setScissorTest(k),qe){const rt=xe.get(U.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+pe,rt.__webglTexture,Se)}else if(Qe){const rt=xe.get(U.texture),dt=pe||0;O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,rt.__webglTexture,Se||0,dt)}x=-1},this.readRenderTargetPixels=function(U,pe,Se,Te,me,qe,Qe){if(!(U&&U.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let nt=xe.get(U).__webglFramebuffer;if(U.isWebGLCubeRenderTarget&&Qe!==void 0&&(nt=nt[Qe]),nt){ee.bindFramebuffer(O.FRAMEBUFFER,nt);try{const rt=U.texture,dt=rt.format,st=rt.type;if(dt!==Kn&&tt.convert(dt)!==O.getParameter(O.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const lt=st===Tl&&(V.has("EXT_color_buffer_half_float")||re.isWebGL2&&V.has("EXT_color_buffer_float"));if(st!==Yr&&tt.convert(st)!==O.getParameter(O.IMPLEMENTATION_COLOR_READ_TYPE)&&!(st===nr&&(re.isWebGL2||V.has("OES_texture_float")||V.has("WEBGL_color_buffer_float")))&&!lt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}pe>=0&&pe<=U.width-Te&&Se>=0&&Se<=U.height-me&&O.readPixels(pe,Se,Te,me,tt.convert(dt),tt.convert(st),qe)}finally{const rt=N!==null?xe.get(N).__webglFramebuffer:null;ee.bindFramebuffer(O.FRAMEBUFFER,rt)}}},this.copyFramebufferToTexture=function(U,pe,Se=0){const Te=Math.pow(2,-Se),me=Math.floor(pe.image.width*Te),qe=Math.floor(pe.image.height*Te);B.setTexture2D(pe,0),O.copyTexSubImage2D(O.TEXTURE_2D,Se,0,0,U.x,U.y,me,qe),ee.unbindTexture()},this.copyTextureToTexture=function(U,pe,Se,Te=0){const me=pe.image.width,qe=pe.image.height,Qe=tt.convert(Se.format),nt=tt.convert(Se.type);B.setTexture2D(Se,0),O.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,Se.flipY),O.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Se.premultiplyAlpha),O.pixelStorei(O.UNPACK_ALIGNMENT,Se.unpackAlignment),pe.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,Te,U.x,U.y,me,qe,Qe,nt,pe.image.data):pe.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,Te,U.x,U.y,pe.mipmaps[0].width,pe.mipmaps[0].height,Qe,pe.mipmaps[0].data):O.texSubImage2D(O.TEXTURE_2D,Te,U.x,U.y,Qe,nt,pe.image),Te===0&&Se.generateMipmaps&&O.generateMipmap(O.TEXTURE_2D),ee.unbindTexture()},this.copyTextureToTexture3D=function(U,pe,Se,Te,me=0){if(S.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const qe=U.max.x-U.min.x+1,Qe=U.max.y-U.min.y+1,nt=U.max.z-U.min.z+1,rt=tt.convert(Te.format),dt=tt.convert(Te.type);let st;if(Te.isData3DTexture)B.setTexture3D(Te,0),st=O.TEXTURE_3D;else if(Te.isDataArrayTexture)B.setTexture2DArray(Te,0),st=O.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}O.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,Te.flipY),O.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Te.premultiplyAlpha),O.pixelStorei(O.UNPACK_ALIGNMENT,Te.unpackAlignment);const lt=O.getParameter(O.UNPACK_ROW_LENGTH),Ut=O.getParameter(O.UNPACK_IMAGE_HEIGHT),dn=O.getParameter(O.UNPACK_SKIP_PIXELS),qt=O.getParameter(O.UNPACK_SKIP_ROWS),hn=O.getParameter(O.UNPACK_SKIP_IMAGES),Bt=Se.isCompressedTexture?Se.mipmaps[0]:Se.image;O.pixelStorei(O.UNPACK_ROW_LENGTH,Bt.width),O.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Bt.height),O.pixelStorei(O.UNPACK_SKIP_PIXELS,U.min.x),O.pixelStorei(O.UNPACK_SKIP_ROWS,U.min.y),O.pixelStorei(O.UNPACK_SKIP_IMAGES,U.min.z),Se.isDataTexture||Se.isData3DTexture?O.texSubImage3D(st,me,pe.x,pe.y,pe.z,qe,Qe,nt,rt,dt,Bt.data):Se.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),O.compressedTexSubImage3D(st,me,pe.x,pe.y,pe.z,qe,Qe,nt,rt,Bt.data)):O.texSubImage3D(st,me,pe.x,pe.y,pe.z,qe,Qe,nt,rt,dt,Bt),O.pixelStorei(O.UNPACK_ROW_LENGTH,lt),O.pixelStorei(O.UNPACK_IMAGE_HEIGHT,Ut),O.pixelStorei(O.UNPACK_SKIP_PIXELS,dn),O.pixelStorei(O.UNPACK_SKIP_ROWS,qt),O.pixelStorei(O.UNPACK_SKIP_IMAGES,hn),me===0&&Te.generateMipmaps&&O.generateMipmap(st),ee.unbindTexture()},this.initTexture=function(U){U.isCubeTexture?B.setTextureCube(U,0):U.isData3DTexture?B.setTexture3D(U,0):U.isDataArrayTexture||U.isCompressedArrayTexture?B.setTexture2DArray(U,0):B.setTexture2D(U,0),ee.unbindTexture()},this.resetState=function(){T=0,C=0,N=null,ee.reset(),$e.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ir}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=e===BE?"display-p3":"srgb",t.unpackColorSpace=Nt.workingColorSpace===ou?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Wt?Ns:Xw}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ns?Wt:fn}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class Pyt extends gO{}Pyt.prototype.isWebGL1Renderer=!0;class Uyt extends Yt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class Fyt{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=ng,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=pi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,s=this.stride;rl)continue;_.applyMatrix4(this.matrixWorld);const x=e.ray.origin.distanceTo(_);xe.far||t.push({distance:x,point:u.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}else{const h=Math.max(0,o.start),m=Math.min(g.count,o.start+o.count);for(let S=h,v=m-1;Sl)continue;_.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(_);Ce.far||t.push({distance:C,point:u.clone().applyMatrix4(this.matrixWorld),index:S,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;s0){const r=t[i[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=r.length;sr.far)return;s.push({distance:c,distanceToRay:Math.sqrt(a),point:l,index:e,face:null,object:o})}}class KE extends fi{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new at(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new at(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=FE,this.normalScale=new vt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class mr extends KE{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new vt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return En(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new at(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new at(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new at(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class iR extends fi{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new at(16777215),this.specular=new at(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new at(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=FE,this.normalScale=new vt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=PE,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}function Lc(n,e,t){return!n||!t&&n.constructor===e?n:typeof e.BYTES_PER_ELEMENT=="number"?new e(n):Array.prototype.slice.call(n)}function Kyt(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function jyt(n){function e(r,s){return n[r]-n[s]}const t=n.length,i=new Array(t);for(let r=0;r!==t;++r)i[r]=r;return i.sort(e),i}function rR(n,e,t){const i=n.length,r=new n.constructor(i);for(let s=0,o=0;o!==i;++s){const a=t[s]*e;for(let l=0;l!==e;++l)r[o++]=n[a+l]}return r}function yO(n,e,t,i){let r=1,s=n[0];for(;s!==void 0&&s[i]===void 0;)s=n[r++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(e.push(s.time),t.push.apply(t,o)),s=n[r++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(e.push(s.time),o.toArray(t,t.length)),s=n[r++];while(s!==void 0);else do o=s[i],o!==void 0&&(e.push(s.time),t.push(o)),s=n[r++];while(s!==void 0)}class Ul{constructor(e,t,i,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(i),this.sampleValues=t,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let i=this._cachedIndex,r=t[i],s=t[i-1];e:{t:{let o;n:{i:if(!(e=s)){const a=t[1];e=s)break t}o=i,i=0;break n}break e}for(;i>>1;et;)--o;if(++o,s!==0||o!==r){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const i=this.times,r=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let o=null;for(let a=0;a!==s;a++){const l=i[a];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,l),e=!1;break}if(o!==null&&o>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,l,o),e=!1;break}o=l}if(r!==void 0&&Kyt(r))for(let a=0,l=r.length;a!==l;++a){const c=r[a];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,c),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),i=this.getValueSize(),r=this.getInterpolation()===Ih,s=e.length-1;let o=1;for(let a=1;a0){e[o]=e[s];for(let a=s*i,l=o*i,c=0;c!==i;++c)t[l+c]=t[a+c];++o}return o!==e.length?(this.times=e.slice(0,o),this.values=t.slice(0,o*i)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),i=this.constructor,r=new i(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Bi.prototype.TimeBufferType=Float32Array;Bi.prototype.ValueBufferType=Float32Array;Bi.prototype.DefaultInterpolation=Jo;class Ea extends Bi{}Ea.prototype.ValueTypeName="bool";Ea.prototype.ValueBufferType=Array;Ea.prototype.DefaultInterpolation=xl;Ea.prototype.InterpolantFactoryMethodLinear=void 0;Ea.prototype.InterpolantFactoryMethodSmooth=void 0;class vO extends Bi{}vO.prototype.ValueTypeName="color";class na extends Bi{}na.prototype.ValueTypeName="number";class Jyt extends Ul{constructor(e,t,i,r){super(e,t,i,r)}interpolate_(e,t,i,r){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=(i-t)/(r-t);let c=e*a;for(let d=c+a;c!==d;c+=4)Zr.slerpFlat(s,0,o,c-a,o,c,l);return s}}class Fs extends Bi{InterpolantFactoryMethodLinear(e){return new Jyt(this.times,this.values,this.getValueSize(),e)}}Fs.prototype.ValueTypeName="quaternion";Fs.prototype.DefaultInterpolation=Jo;Fs.prototype.InterpolantFactoryMethodSmooth=void 0;class ba extends Bi{}ba.prototype.ValueTypeName="string";ba.prototype.ValueBufferType=Array;ba.prototype.DefaultInterpolation=xl;ba.prototype.InterpolantFactoryMethodLinear=void 0;ba.prototype.InterpolantFactoryMethodSmooth=void 0;class ia extends Bi{}ia.prototype.ValueTypeName="vector";class evt{constructor(e,t=-1,i,r=smt){this.name=e,this.tracks=i,this.duration=t,this.blendMode=r,this.uuid=pi(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],i=e.tracks,r=1/(e.fps||1);for(let o=0,a=i.length;o!==a;++o)t.push(nvt(i[o]).scale(r));const s=new this(e.name,e.duration,t,e.blendMode);return s.uuid=e.uuid,s}static toJSON(e){const t=[],i=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let s=0,o=i.length;s!==o;++s)t.push(Bi.toJSON(i[s]));return r}static CreateFromMorphTargetSequence(e,t,i,r){const s=t.length,o=[];for(let a=0;a1){const u=d[1];let _=r[u];_||(r[u]=_=[]),_.push(c)}}const o=[];for(const a in r)o.push(this.CreateFromMorphTargetSequence(a,r[a],t,i));return o}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,_,f,E,b){if(f.length!==0){const g=[],h=[];yO(f,g,h,E),g.length!==0&&b.push(new u(_,g,h))}},r=[],s=e.name||"default",o=e.fps||30,a=e.blendMode;let l=e.length||-1;const c=e.hierarchy||[];for(let u=0;u{t&&t(s),this.manager.itemEnd(e)},0),s;if(Qi[e]!==void 0){Qi[e].push({onLoad:t,onProgress:i,onError:r});return}Qi[e]=[],Qi[e].push({onLoad:t,onProgress:i,onError:r});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,l=this.responseType;fetch(o).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const d=Qi[e],u=c.body.getReader(),_=c.headers.get("Content-Length")||c.headers.get("X-File-Size"),f=_?parseInt(_):0,E=f!==0;let b=0;const g=new ReadableStream({start(h){m();function m(){u.read().then(({done:S,value:v})=>{if(S)h.close();else{b+=v.byteLength;const T=new ProgressEvent("progress",{lengthComputable:E,loaded:b,total:f});for(let C=0,N=d.length;C{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(d=>new DOMParser().parseFromString(d,a));case"json":return c.json();default:if(a===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),_=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(_);return c.arrayBuffer().then(E=>f.decode(E))}}}).then(c=>{ra.add(e,c);const d=Qi[e];delete Qi[e];for(let u=0,_=d.length;u<_;u++){const f=d[u];f.onLoad&&f.onLoad(c)}}).catch(c=>{const d=Qi[e];if(d===void 0)throw this.manager.itemError(e),c;delete Qi[e];for(let u=0,_=d.length;u<_;u++){const f=d[u];f.onError&&f.onError(c)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class ovt extends Sa{constructor(e){super(e)}load(e,t,i,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ra.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a=Cl("img");function l(){d(),ra.add(e,this),t&&t(this),s.manager.itemEnd(e)}function c(u){d(),r&&r(u),s.manager.itemError(e),s.manager.itemEnd(e)}function d(){a.removeEventListener("load",l,!1),a.removeEventListener("error",c,!1)}return a.addEventListener("load",l,!1),a.addEventListener("error",c,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(e),a.src=e,a}}class xO extends Sa{constructor(e){super(e)}load(e,t,i,r){const s=new pn,o=new ovt(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(e,function(a){s.image=a,s.needsUpdate=!0,t!==void 0&&t(s)},i,r),s}}class du extends Yt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new at(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),t}}const sm=new gt,sR=new ue,oR=new ue;class jE{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new vt(512,512),this.map=null,this.mapPass=null,this.matrix=new gt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new zE,this._frameExtents=new vt(1,1),this._viewportCount=1,this._viewports=[new kt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,i=this.matrix;sR.setFromMatrixPosition(e.matrixWorld),t.position.copy(sR),oR.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(oR),t.updateMatrixWorld(),sm.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sm),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(sm)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class avt extends jE{constructor(){super(new Cn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,i=ea*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height,s=e.distance||t.far;(i!==t.fov||r!==t.aspect||s!==t.far)&&(t.fov=i,t.aspect=r,t.far=s,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class lvt extends du{constructor(e,t,i=0,r=Math.PI/3,s=0,o=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Yt.DEFAULT_UP),this.updateMatrix(),this.target=new Yt,this.distance=i,this.angle=r,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new avt}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const aR=new gt,za=new ue,om=new ue;class cvt extends jE{constructor(){super(new Cn(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new vt(4,2),this._viewportCount=6,this._viewports=[new kt(2,1,1,1),new kt(0,1,1,1),new kt(3,1,1,1),new kt(1,1,1,1),new kt(3,0,1,1),new kt(1,0,1,1)],this._cubeDirections=[new ue(1,0,0),new ue(-1,0,0),new ue(0,0,1),new ue(0,0,-1),new ue(0,1,0),new ue(0,-1,0)],this._cubeUps=[new ue(0,1,0),new ue(0,1,0),new ue(0,1,0),new ue(0,1,0),new ue(0,0,1),new ue(0,0,-1)]}updateMatrices(e,t=0){const i=this.camera,r=this.matrix,s=e.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),za.setFromMatrixPosition(e.matrixWorld),i.position.copy(za),om.copy(i.position),om.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(om),i.updateMatrixWorld(),r.makeTranslation(-za.x,-za.y,-za.z),aR.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(aR)}}class dvt extends du{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new cvt}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class uvt extends jE{constructor(){super(new VE(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class CO extends du{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Yt.DEFAULT_UP),this.updateMatrix(),this.target=new Yt,this.shadow=new uvt}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class _vt extends du{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class sl{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let t="";for(let i=0,r=e.length;i"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,i,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=this,o=ra.get(e);if(o!==void 0)return s.manager.itemStart(e),setTimeout(function(){t&&t(o),s.manager.itemEnd(e)},0),o;const a={};a.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(l){ra.add(e,l),t&&t(l),s.manager.itemEnd(e)}).catch(function(l){r&&r(l),s.manager.itemError(e),s.manager.itemEnd(e)}),s.manager.itemStart(e)}}const QE="\\[\\]\\.:\\/",fvt=new RegExp("["+QE+"]","g"),XE="[^"+QE+"]",hvt="[^"+QE.replace("\\.","")+"]",mvt=/((?:WC+[\/:])*)/.source.replace("WC",XE),gvt=/(WCOD+)?/.source.replace("WCOD",hvt),Evt=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",XE),bvt=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",XE),Svt=new RegExp("^"+mvt+gvt+Evt+bvt+"$"),yvt=["material","materials","bones","map"];class vvt{constructor(e,t,i){const r=i||It.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const i=this._targetGroup.nCachedObjects_,r=this._bindings[i];r!==void 0&&r.getValue(e,t)}setValue(e,t){const i=this._bindings;for(let r=this._targetGroup.nCachedObjects_,s=i.length;r!==s;++r)i[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,i=e.length;t!==i;++t)e[t].unbind()}}class It{constructor(e,t,i){this.path=t,this.parsedPath=i||It.parseTrackName(t),this.node=It.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,i){return e&&e.isAnimationObjectGroup?new It.Composite(e,t,i):new It(e,t,i)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(fvt,"")}static parseTrackName(e){const t=Svt.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const i={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=i.nodeName&&i.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const s=i.nodeName.substring(r+1);yvt.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,r),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return i}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const i=e.skeleton.getBoneByName(t);if(i!==void 0)return i}if(e.children){const i=function(s){for(let o=0;o=2.0 are supported."));return}const c=new tTt(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(i,r)}parseAsync(e,t){const i=this;return new Promise(function(r,s){i.parse(e,t,r,s)})}}function xvt(){let n={};return{get:function(e){return n[e]},add:function(e,t){n[e]=t},remove:function(e){delete n[e]},removeAll:function(){n={}}}}const yt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Cvt{constructor(e){this.parser=e,this.name=yt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let i=0,r=t.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class Fvt{constructor(e){this.parser=e,this.name=yt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=r.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.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 Bvt{constructor(e){this.parser=e,this.name=yt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,i=this.parser,r=i.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=r.images[o.source];let l=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(l=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(e,o.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class Gvt{constructor(e){this.name=yt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,i=t.bufferViews[e];if(i.extensions&&i.extensions[this.name]){const r=i.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=r.byteOffset||0,c=r.byteLength||0,d=r.count,u=r.byteStride,_=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(d,u,_,r.mode,r.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(d*u);return o.decodeGltfBuffer(new Uint8Array(f),d,u,_,r.mode,r.filter),f})})}else return null}}class zvt{constructor(e){this.name=yt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,i=t.nodes[e];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const r=t.meshes[i.mesh];for(const c of r.primitives)if(c.mode!==qn.TRIANGLES&&c.mode!==qn.TRIANGLE_STRIP&&c.mode!==qn.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=i.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(d=>(l[c]=d,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const d=c.pop(),u=d.isGroup?d.children:[d],_=c[0].count,f=[];for(const E of u){const b=new gt,g=new ue,h=new Zr,m=new ue(1,1,1),S=new qyt(E.geometry,E.material,_);for(let v=0;v<_;v++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,v),l.ROTATION&&h.fromBufferAttribute(l.ROTATION,v),l.SCALE&&m.fromBufferAttribute(l.SCALE,v),S.setMatrixAt(v,b.compose(g,h,m));for(const v in l)if(v==="_COLOR_0"){const T=l[v];S.instanceColor=new og(T.array,T.itemSize,T.normalized)}else v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"&&E.geometry.setAttribute(v,l[v]);Yt.prototype.copy.call(S,E),this.parser.assignFinalMaterial(S),f.push(S)}return d.isGroup?(d.clear(),d.add(...f),d):f[0]}))}}const RO="glTF",Ha=12,cR={JSON:1313821514,BIN:5130562};class Hvt{constructor(e){this.name=yt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ha),i=new TextDecoder;if(this.header={magic:i.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==RO)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-Ha,s=new DataView(e,Ha);let o=0;for(;o0||n.search(/^data\:image\/jpeg/)===0?"image/jpeg":n.search(/\.webp($|\?)/i)>0||n.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const eTt=new gt;class tTt{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new xvt,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 i=!1,r=!1,s=-1;typeof navigator<"u"&&(i=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||i||r&&s<98?this.textureLoader=new xO(this.options.manager):this.textureLoader=new pvt(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new TO(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 i=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(o){const a={scene:o[0][r.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:r.asset,parser:i,userData:{}};return us(s,a,r),kr(a,r),Promise.all(i._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],i=this.json.meshes||[];for(let r=0,s=t.length;r{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,d]of o.children.entries())s(d,a.children[c])};return s(i,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let i=0;i=2&&g.setY(y,C[N*l+1]),l>=3&&g.setZ(y,C[N*l+2]),l>=4&&g.setW(y,C[N*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g})}loadTexture(e){const t=this.json,i=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const l=i.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,i){const r=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,i).then(function(d){d.flipY=!1,d.name=o.name||a.name||"",d.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(d.name=a.uri);const _=(s.samplers||{})[o.sampler]||{};return d.magFilter=dR[_.magFilter]||Mn,d.minFilter=dR[_.minFilter]||ks,d.wrapS=uR[_.wrapS]||Xo,d.wrapT=uR[_.wrapT]||Xo,r.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const i=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=r.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=i.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const _=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(_),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(l).then(function(u){return new Promise(function(_,f){let E=_;t.isImageBitmapLoader===!0&&(E=function(b){const g=new pn(b);g.needsUpdate=!0,_(g)}),t.load(sl.resolveURL(u,s.path),E,void 0,f)})}).then(function(u){return c===!0&&a.revokeObjectURL(l),u.userData.mimeType=o.mimeType||Jvt(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=d,d}assignTexture(e,t,i,r){const s=this;return this.getDependency("texture",i.index).then(function(o){if(!o)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(o=o.clone(),o.channel=i.texCoord),s.extensions[yt.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[yt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[yt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return r!==void 0&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let i=e.material;const r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new SO,fi.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,l.sizeAttenuation=!1,this.cache.add(a,l)),i=l}else if(e.isLine){const a="LineBasicMaterial:"+i.uuid;let l=this.cache.get(a);l||(l=new bO,fi.prototype.copy.call(l,i),l.color.copy(i.color),l.map=i.map,this.cache.add(a,l)),i=l}if(r||s||o){let a="ClonedMaterial:"+i.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=i.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(i))),i=l}e.material=i}getMaterialType(){return KE}loadMaterial(e){const t=this,i=this.json,r=this.extensions,s=i.materials[e];let o;const a={},l=s.extensions||{},c=[];if(l[yt.KHR_MATERIALS_UNLIT]){const u=r[yt.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new at(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const _=u.baseColorFactor;a.color.setRGB(_[0],_[1],_[2],fn),a.opacity=_[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,Wt)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(_){return _.getMaterialType&&_.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(_){return _.extendMaterialParams&&_.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=Ti);const d=s.alphaMode||lm.OPAQUE;if(d===lm.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,d===lm.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==Br&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new vt(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&o!==Br&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==Br){const u=s.emissiveFactor;a.emissive=new at().setRGB(u[0],u[1],u[2],fn)}return s.emissiveTexture!==void 0&&o!==Br&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,Wt)),Promise.all(c).then(function(){const u=new o(a);return s.name&&(u.name=s.name),kr(u,s),t.associations.set(u,{materials:e}),s.extensions&&us(r,u,s),u})}createUniqueName(e){const t=It.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,i=this.extensions,r=this.primitiveCache;function s(a){return i[yt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return _R(l,a,t)})}const o=[];for(let a=0,l=e.length;a0&&Xvt(h,s),h.name=t.createUniqueName(s.name||"mesh_"+e),kr(h,s),g.extensions&&us(r,h,g),t.assignFinalMaterial(h),u.push(h)}for(let f=0,E=u.length;f1?d=new Ts:c.length===1?d=c[0]:d=new Yt,d!==c[0])for(let u=0,_=c.length;u<_;u++)d.add(c[u]);if(s.name&&(d.userData.name=s.name,d.name=o),kr(d,s),s.extensions&&us(i,d,s),s.matrix!==void 0){const u=new gt;u.fromArray(s.matrix),d.applyMatrix4(u)}else s.translation!==void 0&&d.position.fromArray(s.translation),s.rotation!==void 0&&d.quaternion.fromArray(s.rotation),s.scale!==void 0&&d.scale.fromArray(s.scale);return r.associations.has(d)||r.associations.set(d,{}),r.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,i=this.json.scenes[e],r=this,s=new Ts;i.name&&(s.name=r.createUniqueName(i.name)),kr(s,i),i.extensions&&us(t,s,i);const o=i.nodes||[],a=[];for(let l=0,c=o.length;l{const u=new Map;for(const[_,f]of r.associations)(_ instanceof fi||_ instanceof pn)&&u.set(_,f);return d.traverse(_=>{const f=r.associations.get(_);f!=null&&u.set(_,f)}),u};return r.associations=c(s),s})}_createAnimationTracks(e,t,i,r,s){const o=[],a=e.name?e.name:e.uuid,l=[];Rr[s.path]===Rr.weights?e.traverse(function(_){_.morphTargetInfluences&&l.push(_.name?_.name:_.uuid)}):l.push(a);let c;switch(Rr[s.path]){case Rr.weights:c=na;break;case Rr.rotation:c=Fs;break;case Rr.position:case Rr.scale:c=ia;break;default:switch(i.itemSize){case 1:c=na;break;case 2:case 3:default:c=ia;break}break}const d=r.interpolation!==void 0?Kvt[r.interpolation]:Jo,u=this._getArrayFromAccessor(i);for(let _=0,f=l.length;_({})}},computed:{isReady:{get(){return this.$store.state.ready}}},watch:{"$store.state.mountedPersArr":"updatePersonality","$store.state.config.active_personality_id":"updatePersonality"},async mounted(){for(;this.isReady===!1;)await new Promise(n=>setTimeout(n,100));console.log("ready"),this.initWebGLScene(),this.updatePersonality()},beforeDestroy(){},methods:{initWebGLScene(){this.scene=new Uyt,this.camera=new Cn(75,window.innerWidth/window.innerHeight,.1,1e3),this.renderer=new gO,this.renderer.setSize(window.innerWidth,window.innerHeight),this.$refs.webglContainer.appendChild(this.renderer.domElement);const n=new $r,e=new iR({color:65280});this.cube=new An(n,e),this.scene.add(this.cube);const t=new _vt(4210752),i=new CO(16777215,.5);i.position.set(0,1,0),this.scene.add(t),this.scene.add(i),this.camera.position.z=5,this.animate()},updatePersonality(){const{mountedPersArr:n,config:e}=this.$store.state,t=n[e.active_personality_id];t.avatar?this.showBoxWithAvatar(t.avatar):this.showDefaultCube(),this.$emit("update:personality",t)},loadScene(n){new Tvt().load(n,t=>{this.scene.remove(this.cube),this.cube=t.scene,this.scene.add(this.cube)})},showBoxWithAvatar(n){this.cube&&this.scene.remove(this.cube);const e=new $r,t=new xO().load(n),i=new Br({map:t});this.cube=new An(e,i),this.scene.add(this.cube)},showDefaultCube(){this.scene.remove(this.cube);const n=new $r,e=new iR({color:65280});this.cube=new An(n,e),this.scene.add(this.cube)},animate(){requestAnimationFrame(this.animate),this.cube&&(this.cube.rotation.x+=.01,this.cube.rotation.y+=.01),this.renderer.render(this.scene,this.camera)}}},rTt={ref:"webglContainer"},sTt={key:0};function oTt(n,e,t,i,r,s){return D(),L("div",rTt,[!t.personality.scene_path&&(!t.personality.avatar||t.personality.avatar==="")?(D(),L("div",sTt," Personality does not have an avatar. ")):se("",!0)],512)}const aTt=bt(iTt,[["render",oTt]]),lTt=rL({history:v2("/"),routes:[{path:"/playground/",name:"playground",component:uKe},{path:"/extensions/",name:"extensions",component:vKe},{path:"/help/",name:"help",component:HKe},{path:"/settings/",name:"settings",component:Vat},{path:"/training/",name:"training",component:dlt},{path:"/quantizing/",name:"quantizing",component:blt},{path:"/",name:"discussions",component:mht},{path:"/",name:"interactive",component:aTt}]});const uu=fI($L);console.log("Loaded main.js");function pR(n){const e={};for(const t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);return e}const cTt=zI({state(){return{ready:!1,loading_infos:"",loading_progress:0,version:"unknown",settingsChanged:!1,isConnected:!1,isModelOk:!1,isGenerating:!1,config:null,mountedPers:null,mountedPersArr:[],mountedExtensions:[],bindingsZoo:[],modelsArr:[],selectedModel:null,personalities:[],diskUsage:null,ramUsage:null,vramUsage:null,modelsZoo:[],installedModels:[],currentModel:null,extensionsZoo:[],databases:[]}},mutations:{setIsReady(n,e){n.ready=e},setIsConnected(n,e){n.isConnected=e},setIsModelOk(n,e){n.isModelOk=e},setIsGenerating(n,e){n.isGenerating=e},setConfig(n,e){n.config=e},setPersonalities(n,e){n.personalities=e},setMountedPers(n,e){n.mountedPers=e},setMountedPersArr(n,e){n.mountedPersArr=e},setMountedExtensions(n,e){n.mountedExtensions=e},setbindingsZoo(n,e){n.bindingsZoo=e},setModelsArr(n,e){n.modelsArr=e},setselectedModel(n,e){n.selectedModel=e},setDiskUsage(n,e){n.diskUsage=e},setRamUsage(n,e){n.ramUsage=e},setVramUsage(n,e){n.vramUsage=e},setModelsZoo(n,e){n.modelsZoo=e},setCurrentModel(n,e){n.currentModel=e},setExtensionsZoo(n,e){n.extensionsZoo=e},setDatabases(n,e){n.databases=e}},getters:{getIsConnected(n){return n.isConnected},getIsModelOk(n){return n.isModelOk},getIsGenerating(n){return n.isGenerating},getConfig(n){return n.config},getPersonalities(n){return n.personalities},getMountedPersArr(n){return n.mountedPersArr},getmmountedExtensions(n){return n.mountedExtensions},getMountedPers(n){return n.mountedPers},getbindingsZoo(n){return n.bindingsZoo},getModelsArr(n){return n.modelsArr},getDiskUsage(n){return n.diskUsage},getRamUsage(n){return n.ramUsage},getVramUsage(n){return n.vramUsage},getDatabasesList(n){return n.databases},getModelsZoo(n){return n.modelsZoo},getCurrentModel(n){return n.currentModel},getExtensionsZoo(n){return n.extensionsZoo}},actions:{async getVersion(){try{let n=await Be.get("/get_lollms_webui_version",{});n&&(this.state.version=n.data.version)}catch{console.log("Coudln't get version")}},async refreshConfig({commit:n}){console.log("Fetching configuration");try{const e=await oi("get_config");e.active_personality_id<0&&(e.active_personality_id=0);let t=e.personalities[e.active_personality_id].split("/");e.personality_category=t[0],e.personality_folder=t[1],e.extensions.length>0?e.extension_category=e.extensions[-1]:e.extension_category="ai_sensors",console.log("Recovered config"),console.log(e),console.log("Committing config"),console.log(e),console.log(this.state.config),n("setConfig",e)}catch(e){console.log(e.message,"refreshConfig")}},async refreshDatabase({commit:n}){let e=await oi("list_databases");console.log("databases:",e),n("setDatabases",e)},async refreshPersonalitiesZoo({commit:n}){let e=[];const t=await oi("get_all_personalities"),i=Object.keys(t);console.log("Personalities recovered:"+this.state.config.personalities);for(let r=0;r{let c=!1;for(const u of this.state.config.personalities)if(u.includes(s+"/"+l.folder)&&(c=!0,u.includes(":"))){const _=u.split(":");l.language=_[1]}let d={};return d=l,d.category=s,d.full_path=s+"/"+l.folder,d.isMounted=c,d});e.length==0?e=a:e=e.concat(a)}e.sort((r,s)=>r.name.localeCompare(s.name)),n("setPersonalities",e),console.log("Done loading personalities")},refreshMountedPersonalities({commit:n}){this.state.config.active_personality_id<0&&(this.state.config.active_personality_id=0);let e=[];const t=[];for(let i=0;ia.full_path==r||a.full_path==s[0]);if(o>=0){let a=pR(this.state.personalities[o]);s.length>1&&(a.language=s[1]),a?e.push(a):e.push(this.state.personalities[this.state.personalities.findIndex(l=>l.full_path=="generic/lollms")])}else t.push(i),console.log("Couldn't load personality : ",r)}for(let i=t.length-1;i>=0;i--)console.log("Removing personality : ",this.state.config.personalities[t[i]]),this.state.config.personalities.splice(t[i],1),this.state.config.active_personality_id>t[i]&&(this.state.config.active_personality_id-=1);n("setMountedPersArr",e),this.state.mountedPers=this.state.personalities[this.state.personalities.findIndex(i=>i.full_path==this.state.config.personalities[this.state.config.active_personality_id]||i.full_path+":"+i.language==this.state.config.personalities[this.state.config.active_personality_id])]},async refreshBindings({commit:n}){let e=await oi("list_bindings");n("setbindingsZoo",e)},async refreshModelsZoo({commit:n}){console.log("Fetching models");const e=await Be.get("/get_available_models");n("setModelsZoo",e.data.filter(t=>t.variants&&t.variants.length>0))},async refreshModelStatus({commit:n}){let e=await oi("get_model_status");n("setIsModelOk",e.status)},async refreshModels({commit:n}){console.log("Fetching models");let e=await oi("list_models");console.log(`Found ${e}`);let t=await oi("get_active_model");console.log("Selected model ",t),t!=null&&n("setselectedModel",t.model),n("setModelsArr",e),console.log("setModelsArr",e),this.state.modelsZoo.map(r=>{r.isInstalled=e.includes(r.name)}),this.state.installedModels=this.state.modelsZoo.filter(r=>r.isInstalled);const i=this.state.modelsZoo.findIndex(r=>r.name==this.state.config.model_name);i!=-1&&n("setCurrentModel",this.state.modelsZoo[i])},async refreshExtensionsZoo({commit:n}){let e=[],t=await oi("list_extensions");const i=Object.keys(t);console.log("Extensions recovered:"+t);for(let r=0;r{let c=!1;for(const u of this.state.config.extensions)u.includes(s+"/"+l.folder)&&(c=!0);let d={};return d=l,d.category=s,d.full_path=s+"/"+l.folder,d.isMounted=c,d});e.length==0?e=a:e=e.concat(a)}e.sort((r,s)=>r.name.localeCompare(s.name)),n("setActiveExtensions",this.state.config.extensions),console.log("Done loading extensions"),n("setExtensionsZoo",e)},refreshmountedExtensions({commit:n}){console.log("Mounting extensions");let e=[];const t=[];for(let i=0;io.full_path==r);if(s>=0){let o=pR(this.state.config.extensions[s]);o&&e.push(o)}else t.push(i),console.log("Couldn't load extension : ",r)}for(let i=t.length-1;i>=0;i--)console.log("Removing extensions : ",this.state.config.extensions[t[i]]),this.state.config.extensions.splice(t[i],1);n("setMountedExtensions",e)},async refreshDiskUsage({commit:n}){this.state.diskUsage=await oi("disk_usage")},async refreshRamUsage({commit:n}){this.state.ramUsage=await oi("ram_usage")},async refreshVramUsage({commit:n}){const e=await oi("vram_usage"),t=[];if(e.nb_gpus>0){for(let r=0;r LoLLMS WebUI - Welcome - + diff --git a/web/src/views/InteractiveView.vue b/web/src/views/InteractiveView.vue index 34ce5bca..50d34fe7 100644 --- a/web/src/views/InteractiveView.vue +++ b/web/src/views/InteractiveView.vue @@ -35,8 +35,8 @@ await new Promise((resolve) => setTimeout(resolve, 100)); // Wait for 100ms } console.log("ready") - this.updatePersonality(); this.initWebGLScene(); + this.updatePersonality(); }, beforeDestroy() { // Clean up WebGL resources here @@ -70,12 +70,17 @@ }, updatePersonality() { const { mountedPersArr, config } = this.$store.state; - + // Get the active personality based on active_personality_id const activePersonality = mountedPersArr[config.active_personality_id]; - console.log("activePersonality:",activePersonality) - + // Check if the active personality has an avatar + if (activePersonality.avatar) { + this.showBoxWithAvatar(activePersonality.avatar); + } else { + this.showDefaultCube(); + } + // Update the personality property this.$emit('update:personality', activePersonality); }, @@ -91,8 +96,11 @@ }); }, showBoxWithAvatar(avatarUrl) { - // Remove existing cube - this.scene.remove(this.cube); + // Check if the cube exists in the scene + if (this.cube) { + // Remove existing cube + this.scene.remove(this.cube); + } // Create a box with avatar texture const geometry = new THREE.BoxGeometry(); diff --git a/zoos/models_zoo b/zoos/models_zoo index cf08de77..4b3bd0b2 160000 --- a/zoos/models_zoo +++ b/zoos/models_zoo @@ -1 +1 @@ -Subproject commit cf08de77a73d737584a979a61652878134d7ce0b +Subproject commit 4b3bd0b21937a4618edcf45c0e5ee736360bc38b diff --git a/zoos/personalities_zoo b/zoos/personalities_zoo index 3a686417..da337352 160000 --- a/zoos/personalities_zoo +++ b/zoos/personalities_zoo @@ -1 +1 @@ -Subproject commit 3a686417015113168c7dcb3fdd9943347d4088de +Subproject commit da337352ac0d4f77ea3057bf1b086a1288b8ae85