// three@0.183.2 downloaded from https://ga.jspm.io/npm:three@0.183.2/build/three.module.js import{c as e,V as t,C as n,f$ as a,a as r,u as l,d as c,at as d,a8 as u,a7 as p,fe as m,B as h,g0 as _,h as v,S as E,b0 as S,b1 as T,g1 as x,n as R,as as b,al as C,aG as L,Y as U,w,aM as N,an as y,x as O,y as B,ar as G,aa as V,ap as W,ao as k,N as z,ah as X,e as Y,aq as K,fU as q,a3 as $,v as J,_ as te,ab as ne,ac as ae,ad as ie,m as re,aB as oe,aC as se,b as le,X as ce,dQ as fe,cX as ue,cW as pe,cV as me,cU as he,cT as _e,cS as ge,aP as ve,f9 as Ee,T as Se,$ as Me,dS as Te,q as xe,p as Re,cq as Ae,aR as be,aS as Ce,ae as Pe,af as Le,ag as Ue,e8 as De,eu as we,t as Ie,aH as Ne,z as ye,O as Fe,g2 as Oe,R as Be,b8 as Ge,eK as He,eL as Ve,aT as We,aE as ke,r as ze,aV as Xe,U as Ye,bB as Ke,bC as qe,bD as je,bE as Ze,bF as $e,bG as Qe,bH as Je,bI as tt,bJ as nt,bw as at,bl as it,bm as rt,aK as ot,cK as st,cJ as lt,eR as ut,dG as pt,eS as mt,dH as ht,bn as _t,bo as gt,aJ as vt,bp as Et,bq as St,br as Mt,bs as Tt,aI as xt,bt as Rt,bu as At,b3 as bt,b2 as Ct,by as Pt,bz as Lt,bA as Ut,bv as Dt,bx as wt,g3 as It,aF as Nt,bi as yt,cj as Ft,am as Ot,ck as Bt,aX as Gt,aY as Ht,cl as Vt,cm as Wt,G as kt,cn as zt,L as Xt,co as Yt,cp as Kt,k as qt,aD as jt,cr as Zt,bK as $t,bL as Qt,bM as Jt,bN as tn,bh as nn,bg as an,bO as rn,be as on,bb as sn,ba as ln,bc as cn,bf as un,bP as pn,bQ as mn,bR as hn,bS as _n,bT as gn,bU as vn,bV as En,bW as Sn,bX as Mn,bY as Tn,bZ as xn,b_ as Rn,b$ as An,K as bn,c0 as Cn,c1 as Pn,c2 as Ln,c3 as Un,c4 as Dn,c5 as wn,c6 as In,c7 as Nn,c8 as yn,c9 as Fn,ca as On,cb as Bn,cc as Gn,cd as Hn,ce as Vn,cf as Wn,f6 as kn,f7 as zn,cg as Xn,ch as Yn,J as Kn,ci as qn,e2 as jn,E as Zn,a$ as $n,b6 as Qn,b7 as Jn,ak as ta,bk as na,a5 as aa,a_ as ia,l as ra,W as oa,g4 as sa}from"../_/nWl398M7.js";export{d1 as AdditiveAnimationBlendMode,cz as AlwaysStencilFunc,cP as AmbientLight,d2 as AnimationAction,d3 as AnimationClip,d4 as AnimationLoader,d5 as AnimationMixer,d6 as AnimationObjectGroup,d7 as AnimationUtils,d8 as ArcCurve,d9 as ArrowHelper,da as AttachedBindMode,db as Audio,dc as AudioAnalyser,dd as AudioContext,de as AudioListener,df as AudioLoader,dg as AxesHelper,dh as BasicDepthPacking,aU as BasicShadowMap,di as BatchedMesh,dj as BezierInterpolant,dk as Bone,dl as BooleanKeyframeTrack,dm as Box2,dn as Box3,dp as Box3Helper,dq as BoxHelper,dr as BufferGeometryLoader,ds as Cache,dt as Camera,du as CameraHelper,dv as CanvasTexture,dw as CapsuleGeometry,dx as CatmullRomCurve3,dy as CircleGeometry,dz as Clock,dA as ColorKeyframeTrack,o as Compatibility,dB as CompressedArrayTexture,dC as CompressedCubeTexture,dD as CompressedTexture,dE as CompressedTextureLoader,dF as ConeGeometry,dI as Controls,dJ as CubeTextureLoader,dK as CubicBezierCurve,dL as CubicBezierCurve3,dM as CubicInterpolant,dN as CullFaceFrontBack,dO as Curve,dP as CurvePath,b4 as CylinderGeometry,dR as Cylindrical,dT as DataTextureLoader,dU as DataUtils,cD as DecrementStencilOp,cB as DecrementWrapStencilOp,dV as DefaultLoadingManager,dW as DetachedBindMode,cN as DirectionalLight,dX as DirectionalLightHelper,dY as DiscreteInterpolant,dZ as DodecahedronGeometry,d_ as DynamicCopyUsage,D as DynamicDrawUsage,d$ as DynamicReadUsage,e0 as EdgesGeometry,e1 as EllipseCurve,cw as EqualStencilFunc,e3 as ExtrudeGeometry,c_ as FileLoader,aZ as Float16BufferAttribute,e4 as Fog,e5 as FogExp2,Z as FramebufferTexture,b9 as FrustumArray,e6 as GLBufferAttribute,e7 as GLSL1,cv as GreaterEqualStencilFunc,cu as GreaterStencilFunc,e9 as GridHelper,cY as Group,cQ as HemisphereLight,ea as HemisphereLightHelper,eb as IcosahedronGeometry,ec as ImageBitmapLoader,ed as ImageLoader,ee as ImageUtils,cE as IncrementStencilOp,cC as IncrementWrapStencilOp,P as InstancedBufferAttribute,ef as InstancedBufferGeometry,Q as InstancedInterleavedBuffer,eg as InstancedMesh,eh as Int16BufferAttribute,ei as Int32BufferAttribute,ej as Int8BufferAttribute,I as InterleavedBuffer,j as InterleavedBufferAttribute,ek as Interpolant,el as InterpolateBezier,em as InterpolateDiscrete,en as InterpolateLinear,eo as InterpolateSmooth,ep as InterpolationSamplingMode,eq as InterpolationSamplingType,cF as InvertStencilOp,cI as KeepStencilOp,er as KeyframeTrack,es as LOD,et as LatheGeometry,cx as LessEqualStencilFunc,cy as LessStencilFunc,ev as Light,cR as LightProbe,ew as Line,ex as Line3,a1 as LineBasicMaterial,ey as LineCurve,ez as LineCurve3,a2 as LineDashedMaterial,eA as LineLoop,eB as LineSegments,eC as LinearInterpolant,aO as LinearMipMapLinearFilter,eD as LinearMipMapNearestFilter,cZ as Loader,eE as LoaderUtils,eF as LoadingManager,eG as LoopOnce,eH as LoopPingPong,eI as LoopRepeat,eJ as MOUSE,a0 as Material,aL as MaterialBlending,c$ as MaterialLoader,f as MathUtils,M as Matrix2,ai as MeshLambertMaterial,ax as MeshMatcapMaterial,a4 as MeshNormalMaterial,aj as MeshPhongMaterial,av as MeshPhysicalMaterial,au as MeshStandardMaterial,aw as MeshToonMaterial,eM as NearestMipMapLinearFilter,eN as NearestMipMapNearestFilter,cA as NeverStencilFunc,A as NoNormalPacking,eO as NormalAnimationBlendMode,H as NormalGAPacking,F as NormalRGPacking,ct as NotEqualStencilFunc,eP as NumberKeyframeTrack,aN as Object3D,d0 as ObjectLoader,eQ as OctahedronGeometry,eT as Path,eU as PlaneHelper,cM as PointLight,eV as PointLightHelper,eW as Points,az as PointsMaterial,eX as PolarGridHelper,eY as PolyhedronGeometry,eZ as PositionalAudio,e_ as PropertyBinding,e$ as PropertyMixer,f0 as QuadraticBezierCurve,f1 as QuadraticBezierCurve3,b5 as Quaternion,f2 as QuaternionKeyframeTrack,f3 as QuaternionLinearInterpolant,f4 as RGBADepthPacking,f5 as RGBDepthPacking,bd as RGBIntegerFormat,f8 as RGDepthPacking,fa as Ray,fb as Raycaster,cO as RectAreaLight,a6 as RenderTarget,fc as RenderTarget3D,cG as ReplaceStencilOp,fd as RingGeometry,a9 as Scene,aA as ShadowMaterial,ff as Shape,fg as ShapeGeometry,fh as ShapePath,fi as ShapeUtils,fj as Skeleton,fk as SkeletonHelper,fl as SkinnedMesh,fm as Source,s as Sphere,aW as SphereGeometry,fn as Spherical,fo as SphericalHarmonics3,fp as SplineCurve,cL as SpotLight,fq as SpotLightHelper,fr as Sprite,ay as SpriteMaterial,fs as StaticCopyUsage,i as StaticDrawUsage,ft as StaticReadUsage,fu as StereoCamera,fv as StreamCopyUsage,fw as StreamDrawUsage,fx as StreamReadUsage,fy as StringKeyframeTrack,fz as TOUCH,fA as TetrahedronGeometry,fB as TextureLoader,fC as TextureUtils,fD as Timer,bj as TimestampQuery,fE as TorusGeometry,fF as TorusKnotGeometry,fG as Triangle,fH as TriangleFanDrawMode,fI as TriangleStripDrawMode,fJ as TrianglesDrawMode,fK as TubeGeometry,aQ as UVMapping,fL as Uint8BufferAttribute,fM as Uint8ClampedBufferAttribute,fN as Uniform,fO as UniformsGroup,fP as VectorKeyframeTrack,fQ as VideoFrameTexture,fR as VideoTexture,fS as WebGL3DRenderTarget,fT as WebGLArrayRenderTarget,g as WebGPUCoordinateSystem,fV as WireframeGeometry,fW as WrapAroundEnding,fX as ZeroCurvatureEnding,fY as ZeroSlopeEnding,cH as ZeroStencilOp,fZ as getConsoleFunction,f_ as setConsoleFunction}from"../_/nWl398M7.js"; /** * @license * Copyright 2010-2026 Three.js Authors * SPDX-License-Identifier: MIT */function la(){let e=null;let t=false;let n=null;let a=null;function i(t,r){n(t,r);a=e.requestAnimationFrame(i)}return{start:function(){if(t!==true&&n!==null){a=e.requestAnimationFrame(i);t=true}},stop:function(){e.cancelAnimationFrame(a);t=false},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function ca(e){const t=new WeakMap;function n(t,n){const a=t.array;const i=t.usage;const r=a.byteLength;const o=e.createBuffer();e.bindBuffer(n,o);e.bufferData(n,a,i);t.onUploadCallback();let s;if(a instanceof Float32Array)s=e.FLOAT;else if(typeof Float16Array!=="undefined"&&a instanceof Float16Array)s=e.HALF_FLOAT;else if(a instanceof Uint16Array)s=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(a instanceof Int16Array)s=e.SHORT;else if(a instanceof Uint32Array)s=e.UNSIGNED_INT;else if(a instanceof Int32Array)s=e.INT;else if(a instanceof Int8Array)s=e.BYTE;else if(a instanceof Uint8Array)s=e.UNSIGNED_BYTE;else{if(!(a instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+a);s=e.UNSIGNED_BYTE}return{buffer:o,type:s,bytesPerElement:a.BYTES_PER_ELEMENT,version:t.version,size:r}}function a(t,n,a){const i=n.array;const r=n.updateRanges;e.bindBuffer(a,t);if(r.length===0)e.bufferSubData(a,0,i);else{r.sort(((e,t)=>e.start-t.start));let t=0;for(let e=1;e0;n=t.get(n,a)}return n}function b(t){let n=false;const i=A(t);if(i===null)P(s,l);else if(i&&i.isColor){P(i,1);n=true}const r=e.xr.getEnvironmentBlendMode();r==="additive"?a.buffers.color.setClear(0,0,0,1,o):r==="alpha-blend"&&a.buffers.color.setClear(0,0,0,0,o);if(e.autoClear||n){a.buffers.depth.setTest(true);a.buffers.depth.setMask(true);a.buffers.color.setMask(true);e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil)}}function C(t,n){const a=A(n);if(a&&(a.isCubeTexture||a.mapping===d)){if(f===void 0){f=new u(new p(1,1,1),new m({name:"BackgroundCubeMaterial",uniforms:_(to.backgroundCube.uniforms),vertexShader:to.backgroundCube.vertexShader,fragmentShader:to.backgroundCube.fragmentShader,side:h,depthTest:false,depthWrite:false,fog:false,allowOverride:false}));f.geometry.deleteAttribute("normal");f.geometry.deleteAttribute("uv");f.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)};Object.defineProperty(f.material,"envMap",{get:function(){return this.uniforms.envMap.value}});i.update(f)}ao.copy(n.backgroundRotation);ao.x*=-1;ao.y*=-1;ao.z*=-1;if(a.isCubeTexture&&a.isRenderTargetTexture===false){ao.y*=-1;ao.z*=-1}f.material.uniforms.envMap.value=a;f.material.uniforms.flipEnvMap.value=a.isCubeTexture&&a.isRenderTargetTexture===false?-1:1;f.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness;f.material.uniforms.backgroundIntensity.value=n.backgroundIntensity;f.material.uniforms.backgroundRotation.value.setFromMatrix4(io.makeRotationFromEuler(ao));f.material.toneMapped=v.getTransfer(a.colorSpace)!==E;if(g!==a||M!==a.version||R!==e.toneMapping){f.material.needsUpdate=true;g=a;M=a.version;R=e.toneMapping}f.layers.enableAll();t.unshift(f,f.geometry,f.material,0,0,null)}else if(a&&a.isTexture){if(c===void 0){c=new u(new S(2,2),new m({name:"BackgroundMaterial",uniforms:_(to.background.uniforms),vertexShader:to.background.vertexShader,fragmentShader:to.background.fragmentShader,side:T,depthTest:false,depthWrite:false,fog:false,allowOverride:false}));c.geometry.deleteAttribute("normal");Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}});i.update(c)}c.material.uniforms.t2D.value=a;c.material.uniforms.backgroundIntensity.value=n.backgroundIntensity;c.material.toneMapped=v.getTransfer(a.colorSpace)!==E;a.matrixAutoUpdate===true&&a.updateMatrix();c.material.uniforms.uvTransform.value.copy(a.matrix);if(g!==a||M!==a.version||R!==e.toneMapping){c.material.needsUpdate=true;g=a;M=a.version;R=e.toneMapping}c.layers.enableAll();t.unshift(c,c.geometry,c.material,0,0,null)}}function P(t,n){t.getRGB(no,x(e));a.buffers.color.setClear(no.r,no.g,no.b,n,o)}function L(){if(f!==void 0){f.geometry.dispose();f.material.dispose();f=void 0}if(c!==void 0){c.geometry.dispose();c.material.dispose();c=void 0}}return{getClearColor:function(){return s},setClearColor:function(e,t=1){s.set(e);l=t;P(s,l)},getClearAlpha:function(){return l},setClearAlpha:function(e){l=e;P(s,l)},render:b,addToRenderList:C,dispose:L}}function oo(e,t){const n=e.getParameter(e.MAX_VERTEX_ATTRIBS);const a={};const i=u(null);let r=i;let o=false;function s(n,a,i,s,l){let d=false;const u=f(n,s,i,a);if(r!==u){r=u;c(r.object)}d=p(n,s,i,l);d&&m(n,s,i,l);l!==null&&t.update(l,e.ELEMENT_ARRAY_BUFFER);if(d||o){o=false;S(n,a,i,s);l!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.get(l).buffer)}}function l(){return e.createVertexArray()}function c(t){return e.bindVertexArray(t)}function d(t){return e.deleteVertexArray(t)}function f(e,t,n,i){const r=i.wireframe===true;let o=a[t.id];if(o===void 0){o={};a[t.id]=o}const s=e.isInstancedMesh===true?e.id:0;let c=o[s];if(c===void 0){c={};o[s]=c}let d=c[n.id];if(d===void 0){d={};c[n.id]=d}let f=d[r];if(f===void 0){f=u(l());d[r]=f}return f}function u(e){const t=[];const a=[];const i=[];for(let e=0;e=0){const n=i[t];let a=o[t];if(a===void 0){t==="instanceMatrix"&&e.instanceMatrix&&(a=e.instanceMatrix);t==="instanceColor"&&e.instanceColor&&(a=e.instanceColor)}if(n===void 0)return true;if(n.attribute!==a)return true;if(a&&n.data!==a.data)return true;s++}}return r.attributesNum!==s||r.index!==a}function m(e,t,n,a){const i={};const o=t.attributes;let s=0;const l=n.getAttributes();for(const t in l){const n=l[t];if(n.location>=0){let n=o[t];if(n===void 0){t==="instanceMatrix"&&e.instanceMatrix&&(n=e.instanceMatrix);t==="instanceColor"&&e.instanceColor&&(n=e.instanceColor)}const a={};a.attribute=n;n&&n.data&&(a.data=n.data);i[t]=a;s++}}r.attributes=i;r.attributesNum=s;r.index=a}function h(){const e=r.newAttributes;for(let t=0,n=e.length;t=0){let s=o[a];if(s===void 0){a==="instanceMatrix"&&n.instanceMatrix&&(s=n.instanceMatrix);a==="instanceColor"&&n.instanceColor&&(s=n.instanceColor)}if(s!==void 0){const a=s.normalized;const o=s.itemSize;const l=t.get(s);if(l===void 0)continue;const c=l.buffer;const d=l.type;const f=l.bytesPerElement;const u=d===e.INT||d===e.UNSIGNED_INT||s.gpuType===R;if(s.isInterleavedBufferAttribute){const t=s.data;const l=t.stride;const p=s.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return t==="mediump"&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=n.precision!==void 0?n.precision:"highp";const d=l(c);if(d!==c){w("WebGLRenderer:",c,"not supported, using",d,"instead.");c=d}const f=n.logarithmicDepthBuffer===true;const u=n.reversedDepthBuffer===true&&t.has("EXT_clip_control");const p=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);const m=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);const h=e.getParameter(e.MAX_TEXTURE_SIZE);const _=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE);const g=e.getParameter(e.MAX_VERTEX_ATTRIBS);const v=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS);const E=e.getParameter(e.MAX_VARYING_VECTORS);const S=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS);const M=e.getParameter(e.MAX_SAMPLES);const T=e.getParameter(e.SAMPLES);return{isWebGL2:true,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:o,textureTypeReadable:s,precision:c,logarithmicDepthBuffer:f,reversedDepthBuffer:u,maxTextures:p,maxVertexTextures:m,maxTextureSize:h,maxCubemapSize:_,maxAttributes:g,maxVertexUniforms:v,maxVaryings:E,maxFragmentUniforms:S,maxSamples:M,samples:T}}function co(t){const n=this;let a=null,i=0,r=false,o=false;const s=new N,l=new e,c={value:null,needsUpdate:false};this.uniform=c;this.numPlanes=0;this.numIntersection=0;this.init=function(e,t){const n=e.length!==0||t||i!==0||r;r=t;i=e.length;return n};this.beginShadows=function(){o=true;f(null)};this.endShadows=function(){o=false};this.setGlobalState=function(e,t){a=f(e,t,0)};this.setState=function(e,n,s){const l=e.clippingPlanes,u=e.clipIntersection,p=e.clipShadows;const m=t.get(e);if(!r||l===null||l.length===0||o&&!p)o?f(null):d();else{const e=o?0:i,t=e*4;let r=m.clippingState||null;c.value=r;r=f(l,n,t,s);for(let e=0;e!==t;++e)r[e]=a[e];m.clippingState=r;this.numIntersection=u?this.numPlanes:0;this.numPlanes+=e}};function d(){if(c.value!==a){c.value=a;c.needsUpdate=i>0}n.numPlanes=i;n.numIntersection=0}function f(e,t,a,i){const r=e!==null?e.length:0;let o=null;if(r!==0){o=c.value;if(i!==true||o===null){const n=a+r*4,i=t.matrixWorldInverse;l.getNormalMatrix(i);(o===null||o.length0&&this._blur(s,0,0,t);this._applyPMREM(s);this._cleanup(s);return s} /** * Generates a PMREM from an equirectangular texture, which can be either LDR * or HDR. The ideal input image size is 1k (1024 x 512), * as this matches best with the 256 x 256 cubemap output. * * @param {Texture} equirectangular - The equirectangular texture to be converted. * @param {?WebGLRenderTarget} [renderTarget=null] - The render target to use. * @return {WebGLRenderTarget} The resulting PMREM. */fromEquirectangular(e,t=null){return this._fromTexture(e,t)} /** * Generates a PMREM from an cubemap texture, which can be either LDR * or HDR. The ideal input cube size is 256 x 256, * as this matches best with the 256 x 256 cubemap output. * * @param {Texture} cubemap - The cubemap texture to be converted. * @param {?WebGLRenderTarget} [renderTarget=null] - The render target to use. * @return {WebGLRenderTarget} The resulting PMREM. */fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){if(this._cubemapMaterial===null){this._cubemapMaterial=Lo();this._compileMaterial(this._cubemapMaterial)}}compileEquirectangularShader(){if(this._equirectMaterial===null){this._equirectMaterial=Po();this._compileMaterial(this._equirectMaterial)}}dispose(){this._dispose();this._cubemapMaterial!==null&&this._cubemapMaterial.dispose();this._equirectMaterial!==null&&this._equirectMaterial.dispose();if(this._backgroundBox!==null){this._backgroundBox.geometry.dispose();this._backgroundBox.material.dispose()}}_setSize(e){this._lodMax=Math.floor(Math.log2(e));this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose();this._ggxMaterial!==null&&this._ggxMaterial.dispose();this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?r:0,r,r);d.setRenderTarget(a);E&&d.render(g,s);d.render(e,s)}d.toneMapping=m;d.autoClear=f;e.background=S}_textureToCubeUV(e,t){const n=this._renderer;const a=e.mapping===O||e.mapping===B;if(a){this._cubemapMaterial===null&&(this._cubemapMaterial=Lo());this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===false?-1:1}else this._equirectMaterial===null&&(this._equirectMaterial=Po());const i=a?this._cubemapMaterial:this._equirectMaterial;const r=this._lodMeshes[0];r.material=i;const o=i.uniforms;o.envMap.value=e;const s=this._cubeSize;Ao(t,0,0,3*s,2*s);n.setRenderTarget(t);n.render(r,_o)}_applyPMREM(e){const t=this._renderer;const n=t.autoClear;t.autoClear=false;const a=this._lodMeshes.length;for(let t=1;tp-uo?n-p+uo:0);const _=4*(this._cubeSize-m);s.envMap.value=e.texture;s.roughness.value=u;s.mipInt.value=p-t;Ao(i,h,_,3*m,2*m);a.setRenderTarget(i);a.render(o,_o);s.envMap.value=i.texture;s.roughness.value=0;s.mipInt.value=p-n;Ao(e,h,_,3*m,2*m);a.setRenderTarget(e);a.render(o,_o)} /** * This is a two-pass Gaussian blur for a cubemap. Normally this is done * vertically and horizontally, but this breaks down on a cube. Here we apply * the blur latitudinally (around the poles), and then longitudinally (towards * the poles) to approximate the orthogonally-separable blur. It is least * accurate at the poles, but still does a decent job. * * Used for initial scene blur in fromScene() method when sigma > 0. * * @private * @param {WebGLRenderTarget} cubeUVRenderTarget * @param {number} lodIn * @param {number} lodOut * @param {number} sigma * @param {Vector3} [poleAxis] */_blur(e,t,n,a,i){const r=this._pingPongRenderTarget;this._halfBlur(e,r,t,n,a,"latitudinal",i);this._halfBlur(r,e,n,n,a,"longitudinal",i)}_halfBlur(e,t,n,a,i,r,o){const s=this._renderer;const l=this._blurMaterial;r!=="latitudinal"&&r!=="longitudinal"&&Y("blur direction must be either latitudinal or longitudinal!");const c=3;const d=this._lodMeshes[a];d.material=l;const f=l.uniforms;const u=this._sizeLods[n]-1;const p=isFinite(i)?Math.PI/(2*u):2*Math.PI/(2*mo-1);const m=i/p;const h=isFinite(i)?1+Math.floor(c*m):mo;h>mo&&w(`sigmaRadians, ${i}, is too large and will clip, as it requested ${h} samples when the maximum is set to ${mo}`);const _=[];let g=0;for(let e=0;ev-uo?a-v+uo:0);const M=4*(this._cubeSize-E);Ao(t,S,M,3*E,2*E);s.setRenderTarget(t);s.render(d,_o)}}function xo(e){const t=[];const n=[];const a=[];let i=e;const r=e-uo+1+po.length;for(let o=0;oe-uo?s=po[o-e+uo-1]:o===0&&(s=0);n.push(s);const l=1/(r-2);const c=-l;const d=1+l;const f=[c,c,d,c,d,d,c,c,d,d,c,d];const p=6;const m=6;const h=3;const _=2;const g=1;const v=new Float32Array(h*m*p);const E=new Float32Array(_*m*p);const S=new Float32Array(g*m*p);for(let e=0;e2?0:-1;const a=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(a,h*m*e);E.set(f,_*m*e);const i=[e,e,e,e,e,e];S.set(i,g*m*e)}const M=new W;M.setAttribute("position",new K(v,h));M.setAttribute("uv",new K(E,_));M.setAttribute("faceIndex",new K(S,g));a.push(new u(M,null));i>uo&&i--}return{lodMeshes:a,sizeLods:t,sigmas:n}}function Ro(e,t,n){const a=new q(e,t,n);a.texture.mapping=d;a.texture.name="PMREM.cubeUv";a.scissorTest=true;return a}function Ao(e,t,n,a,i){e.viewport.set(t,n,a,i);e.scissor.set(t,n,a,i)}function bo(e,t,n){const a=new m({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:ho,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Uo(),fragmentShader:'\n\n\t\t\tprecision highp float;\n\t\t\tprecision highp int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform float roughness;\n\t\t\tuniform float mipInt;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\t#define PI 3.14159265359\n\n\t\t\t// Van der Corput radical inverse\n\t\t\tfloat radicalInverse_VdC(uint bits) {\n\t\t\t\tbits = (bits << 16u) | (bits >> 16u);\n\t\t\t\tbits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n\t\t\t\tbits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n\t\t\t\tbits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n\t\t\t\tbits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n\t\t\t\treturn float(bits) * 2.3283064365386963e-10; // / 0x100000000\n\t\t\t}\n\n\t\t\t// Hammersley sequence\n\t\t\tvec2 hammersley(uint i, uint N) {\n\t\t\t\treturn vec2(float(i) / float(N), radicalInverse_VdC(i));\n\t\t\t}\n\n\t\t\t// GGX VNDF importance sampling (Eric Heitz 2018)\n\t\t\t// "Sampling the GGX Distribution of Visible Normals"\n\t\t\t// https://jcgt.org/published/0007/04/01/\n\t\t\tvec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\n\t\t\t\tfloat alpha = roughness * roughness;\n\n\t\t\t\t// Section 4.1: Orthonormal basis\n\t\t\t\tvec3 T1 = vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 T2 = cross(V, T1);\n\n\t\t\t\t// Section 4.2: Parameterization of projected area\n\t\t\t\tfloat r = sqrt(Xi.x);\n\t\t\t\tfloat phi = 2.0 * PI * Xi.y;\n\t\t\t\tfloat t1 = r * cos(phi);\n\t\t\t\tfloat t2 = r * sin(phi);\n\t\t\t\tfloat s = 0.5 * (1.0 + V.z);\n\t\t\t\tt2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n\t\t\t\t// Section 4.3: Reprojection onto hemisphere\n\t\t\t\tvec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n\t\t\t\t// Section 3.4: Transform back to ellipsoid configuration\n\t\t\t\treturn normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n\t\t\t}\n\n\t\t\tvoid main() {\n\t\t\t\tvec3 N = normalize(vOutputDirection);\n\t\t\t\tvec3 V = N; // Assume view direction equals normal for pre-filtering\n\n\t\t\t\tvec3 prefilteredColor = vec3(0.0);\n\t\t\t\tfloat totalWeight = 0.0;\n\n\t\t\t\t// For very low roughness, just sample the environment directly\n\t\t\t\tif (roughness < 0.001) {\n\t\t\t\t\tgl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Tangent space basis for VNDF sampling\n\t\t\t\tvec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n\t\t\t\tvec3 tangent = normalize(cross(up, N));\n\t\t\t\tvec3 bitangent = cross(N, tangent);\n\n\t\t\t\tfor(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n\t\t\t\t\tvec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n\t\t\t\t\t// For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n\t\t\t\t\tvec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n\t\t\t\t\t// Transform H back to world space\n\t\t\t\t\tvec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n\t\t\t\t\tvec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n\t\t\t\t\tfloat NdotL = max(dot(N, L), 0.0);\n\n\t\t\t\t\tif(NdotL > 0.0) {\n\t\t\t\t\t\t// Sample environment at fixed mip level\n\t\t\t\t\t\t// VNDF importance sampling handles the distribution filtering\n\t\t\t\t\t\tvec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n\t\t\t\t\t\t// Weight by NdotL for the split-sum approximation\n\t\t\t\t\t\t// VNDF PDF naturally accounts for the visible microfacet distribution\n\t\t\t\t\t\tprefilteredColor += sampleColor * NdotL;\n\t\t\t\t\t\ttotalWeight += NdotL;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (totalWeight > 0.0) {\n\t\t\t\t\tprefilteredColor = prefilteredColor / totalWeight;\n\t\t\t\t}\n\n\t\t\t\tgl_FragColor = vec4(prefilteredColor, 1.0);\n\t\t\t}\n\t\t',blending:$,depthTest:false,depthWrite:false});return a}function Co(e,t,n){const a=new Float32Array(mo);const i=new r(0,1,0);const o=new m({name:"SphericalGaussianBlur",defines:{n:mo,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:a},latitudinal:{value:false},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Uo(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:$,depthTest:false,depthWrite:false});return o}function Po(){return new m({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Uo(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:$,depthTest:false,depthWrite:false})}function Lo(){return new m({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Uo(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:$,depthTest:false,depthWrite:false})}function Uo(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}class WebGLCubeRenderTarget extends q{ /** * Constructs a new cube render target. * * @param {number} [size=1] - The size of the render target. * @param {RenderTarget~Options} [options] - The configuration object. */ constructor(e=1,t={}){super(e,e,t); /** * This flag can be used for type testing. * * @type {boolean} * @readonly * @default true */this.isWebGLCubeRenderTarget=true;const n={width:e,height:e,depth:1};const a=[n,n,n,n,n,n]; /** * Overwritten with a different texture type. * * @type {DataArrayTexture} */this.texture=new J(a);this._setTextureOptions(t);this.texture.isRenderTargetTexture=true} /** * Converts the given equirectangular texture to a cube map. * * @param {WebGLRenderer} renderer - The renderer. * @param {Texture} texture - The equirectangular texture. * @return {WebGLCubeRenderTarget} A reference to this cube render target. */fromEquirectangularTexture(e,t){this.texture.type=t.type;this.texture.colorSpace=t.colorSpace;this.texture.generateMipmaps=t.generateMipmaps;this.texture.minFilter=t.minFilter;this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"};const a=new p(5,5,5);const i=new m({name:"CubemapFromEquirect",uniforms:_(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:h,blending:$});i.uniforms.tEquirect.value=t;const r=new u(a,i);const o=t.minFilter;t.minFilter===te&&(t.minFilter=V);const s=new ne(1,10,this);s.update(e,r);t.minFilter=o;r.geometry.dispose();r.material.dispose();return this} /** * Clears this cube render target. * * @param {WebGLRenderer} renderer - The renderer. * @param {boolean} [color=true] - Whether the color buffer should be cleared or not. * @param {boolean} [depth=true] - Whether the depth buffer should be cleared or not. * @param {boolean} [stencil=true] - Whether the stencil buffer should be cleared or not. */clear(e,t=true,n=true,a=true){const i=e.getRenderTarget();for(let i=0;i<6;i++){e.setRenderTarget(this,i);e.clear(t,n,a)}e.setRenderTarget(i)}}function Do(e){let t=new WeakMap;let n=new WeakMap;let a=null;function i(e,t=false){return e===null||e===void 0?null:t?o(e):r(e)}function r(n){if(n&&n.isTexture){const a=n.mapping;if(a===ae||a===ie){if(t.has(n)){const e=t.get(n).texture;return s(e,n.mapping)}{const a=n.image;if(a&&a.height>0){const i=new WebGLCubeRenderTarget(a.height);i.fromEquirectangularTexture(e,n);t.set(n,i);n.addEventListener("dispose",c);return s(i.texture,n.mapping)}return null}}}return n}function o(t){if(t&&t.isTexture){const i=t.mapping;const r=i===ae||i===ie;const o=i===O||i===B;if(r||o){let i=n.get(t);const s=i!==void 0?i.texture.pmremVersion:0;if(t.isRenderTargetTexture&&t.pmremVersion!==s){a===null&&(a=new PMREMGenerator(e));i=r?a.fromEquirectangular(t,i):a.fromCubemap(t,i);i.texture.pmremVersion=t.pmremVersion;n.set(t,i);return i.texture}if(i!==void 0)return i.texture;{const s=t.image;if(r&&s&&s.height>0||o&&s&&l(s)){a===null&&(a=new PMREMGenerator(e));i=r?a.fromEquirectangular(t):a.fromCubemap(t);i.texture.pmremVersion=t.pmremVersion;n.set(t,i);t.addEventListener("dispose",d);return i.texture}return null}}}return t}function s(e,t){t===ae?e.mapping=O:t===ie&&(e.mapping=B);return e}function l(e){let t=0;const n=6;for(let a=0;a=65535?oe:se)(n,1);s.version=o;const l=r.get(e);l&&t.remove(l);r.set(e,s)}function d(e){const t=r.get(e);if(t){const n=e.index;n!==null&&t.versionn.maxTextureSize){M=Math.ceil(S/n.maxTextureSize);S=n.maxTextureSize}const T=new Float32Array(S*M*4*f);const x=new ce(T,S,M,f);x.type=U;x.needsUpdate=true;const R=E*4;for(let b=0;b\n\t\t\t#include \n\n\t\t\tvoid main() {\n\t\t\t\tgl_FragColor = texture2D( tDiffuse, vUv );\n\n\t\t\t\t#ifdef LINEAR_TONE_MAPPING\n\t\t\t\t\tgl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( REINHARD_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CINEON_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( ACES_FILMIC_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( AGX_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( NEUTRAL_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n\t\t\t\t#elif defined( CUSTOM_TONE_MAPPING )\n\t\t\t\t\tgl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n\t\t\t\t#endif\n\n\t\t\t\t#ifdef SRGB_TRANSFER\n\t\t\t\t\tgl_FragColor = sRGBTransferOETF( gl_FragColor );\n\t\t\t\t#endif\n\t\t\t}",depthTest:false,depthWrite:false});const c=new u(s,l);const d=new y(-1,1,1,-1,0,1);let f=null;let p=null;let m=false;let h;let _=null;let g=[];let S=false;this.setSize=function(e,t){r.setSize(e,t);o.setSize(e,t);for(let n=0;n0&&g[0].isRenderPass===true;const t=r.width;const n=r.height;for(let e=0;e0)return e;const i=t*n;let r=Xo[i];if(r===void 0){r=new Float32Array(i);Xo[i]=r}if(t!==0){a.toArray(r,0);for(let a=1,i=0;a!==t;++a){i+=n;e[a].toArray(r,i)}}return r}function $o(e,t){if(e.length!==t.length)return false;for(let n=0,a=e.length;n0&&(this.seq=a.concat(i))}setValue(e,t,n,a){const i=this.map[t];i!==void 0&&i.setValue(e,n,a)}setOptional(e,t,n){const a=t[n];a!==void 0&&this.setValue(e,n,a)}static upload(e,t,n,a){for(let i=0,r=t.length;i!==r;++i){const r=t[i],o=n[r.id];o.needsUpdate!==false&&r.setValue(e,o.value,a)}}static seqWithValue(e,t){const n=[];for(let a=0,i=e.length;a!==i;++a){const i=e[a];i.id in t&&n.push(i)}return n}}function Ys(e,t,n){const a=e.createShader(t);e.shaderSource(a,n);e.compileShader(a);return a}const Ks=37297;let qs=0;function js(e,t){const n=e.split("\n");const a=[];const i=Math.max(t-6,0);const r=Math.min(t+6,n.length);for(let e=i;e":" "} ${i}: ${n[e]}`)}return a.join("\n")}const Zs=new e;function $s(e){v._getMatrix(Zs,v.workingColorSpace,e);const t=`mat3( ${Zs.elements.map((e=>e.toFixed(4)))} )`;switch(v.getTransfer(e)){case Ae:return[t,"LinearTransferOETF"];case E:return[t,"sRGBTransferOETF"];default:w("WebGLProgram: Unsupported color space: ",e);return[t,"LinearTransferOETF"]}}function Qs(e,t,n){const a=e.getShaderParameter(t,e.COMPILE_STATUS);const i=e.getShaderInfoLog(t)||"";const r=i.trim();if(a&&r==="")return"";const o=/ERROR: 0:(\d+)/.exec(r);if(o){const a=parseInt(o[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+js(e.getShaderSource(t),a)}return r}function Js(e,t){const n=$s(t);return[`vec4 ${e}( vec4 value ) {`,`\treturn ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join("\n")}const tl={[ge]:"Linear",[_e]:"Reinhard",[he]:"Cineon",[me]:"ACESFilmic",[pe]:"AgX",[ue]:"Neutral",[fe]:"Custom"};function nl(e,t){const n=tl[t];if(n===void 0){w("WebGLProgram: Unsupported toneMapping:",t);return"vec3 "+e+"( vec3 color ) { return LinearToneMapping( color ); }"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const al=new r;function il(){v.getLuminanceCoefficients(al);const e=al.x.toFixed(4);const t=al.y.toFixed(4);const n=al.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",`\tconst vec3 weights = vec3( ${e}, ${t}, ${n} );`,"\treturn dot( weights, rgb );","}"].join("\n")}function rl(e){const t=[e.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",e.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""];return t.filter(ll).join("\n")}function ol(e){const t=[];for(const n in e){const a=e[n];a!==false&&t.push("#define "+n+" "+a)}return t.join("\n")}function sl(e,t){const n={};const a=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function ml(e){return e.replace(pl,_l)}const hl=new Map;function _l(e,t){let n=Qr[t];if(n===void 0){const e=hl.get(t);if(e===void 0)throw new Error("Can not resolve #include <"+t+">");n=Qr[e];w('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return ml(n)}const gl=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function vl(e){return e.replace(gl,El)}function El(e,t,n,a){let i="";for(let e=parseInt(t);e0&&(_+="\n");g=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ll).join("\n");g.length>0&&(g+="\n")}else{_=[Sl(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===false?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===false?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ll).join("\n");g=[Sl(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",u?"#define CUBEUV_TEXEL_WIDTH "+u.texelWidth:"",u?"#define CUBEUV_TEXEL_HEIGHT "+u.texelHeight:"",u?"#define CUBEUV_MAX_MIP "+u.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&n.flatShading===false?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas||n.batchingColor?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==z?"#define TONE_MAPPING":"",n.toneMapping!==z?Qr.tonemapping_pars_fragment:"",n.toneMapping!==z?nl("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Qr.colorspace_pars_fragment,Js("linearToOutputTexel",n.outputColorSpace),il(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(ll).join("\n")}o=ml(o);o=cl(o,n);o=ul(o,n);s=ml(s);s=cl(s,n);s=ul(s,n);o=vl(o);s=vl(s);if(n.isRawShaderMaterial!==true){v="#version 300 es\n";_=[p,"#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+_;g=["#define varying in",n.glslVersion===De?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===De?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+g}const E=v+_+o;const S=v+g+s;const M=Ys(i,i.VERTEX_SHADER,E);const T=Ys(i,i.FRAGMENT_SHADER,S);i.attachShader(h,M);i.attachShader(h,T);n.index0AttributeName!==void 0?i.bindAttribLocation(h,0,n.index0AttributeName):n.morphTargets===true&&i.bindAttribLocation(h,0,"position");i.linkProgram(h);function x(t){if(e.debug.checkShaderErrors){const n=i.getProgramInfoLog(h)||"";const a=i.getShaderInfoLog(M)||"";const r=i.getShaderInfoLog(T)||"";const o=n.trim();const s=a.trim();const l=r.trim();let c=true;let d=true;if(i.getProgramParameter(h,i.LINK_STATUS)===false){c=false;if(typeof e.debug.onShaderError==="function")e.debug.onShaderError(i,h,M,T);else{const e=Qs(i,M,"vertex");const n=Qs(i,T,"fragment");Y("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(h,i.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+o+"\n"+e+"\n"+n)}}else o!==""?w("WebGLProgram: Program Info Log:",o):s!==""&&l!==""||(d=false);d&&(t.diagnostics={runnable:c,programLog:o,vertexShader:{log:s,prefix:_},fragmentShader:{log:l,prefix:g}})}i.deleteShader(M);i.deleteShader(T);R=new WebGLUniforms(i,h);A=sl(i,h)}let R;this.getUniforms=function(){R===void 0&&x(this);return R};let A;this.getAttributes=function(){A===void 0&&x(this);return A};let b=n.rendererExtensionParallelShaderCompile===false;this.isReady=function(){b===false&&(b=i.getProgramParameter(h,Ks));return b};this.destroy=function(){a.releaseStatesOfProgram(this);i.deleteProgram(h);this.program=void 0};this.type=n.shaderType;this.name=n.shaderName;this.id=qs++;this.cacheKey=t;this.usedTimes=1;this.program=h;this.vertexShader=M;this.fragmentShader=T;return this}let Dl=0;class WebGLShaderCache{constructor(){this.shaderCache=new Map;this.materialCache=new Map}update(e){const t=e.vertexShader;const n=e.fragmentShader;const a=this._getShaderStage(t);const i=this._getShaderStage(n);const r=this._getShaderCacheForMaterial(e);if(r.has(a)===false){r.add(a);a.usedTimes++}if(r.has(i)===false){r.add(i);i.usedTimes++}return this}remove(e){const t=this.materialCache.get(e);for(const e of t){e.usedTimes--;e.usedTimes===0&&this.shaderCache.delete(e.code)}this.materialCache.delete(e);return this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear();this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);if(n===void 0){n=new Set;t.set(e,n)}return n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);if(n===void 0){n=new WebGLShaderStage(e);t.set(e,n)}return n}}class WebGLShaderStage{constructor(e){this.id=Dl++;this.code=e;this.usedTimes=0}}function wl(e,t,n,a,i,r){const o=new we;const s=new WebGLShaderCache;const l=new Set;const c=[];const f=new Map;const u=a.logarithmicDepthBuffer;let p=a.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(e){l.add(e);return e===0?"uv":`uv${e}`}function g(i,o,c,f,g){const S=f.fog;const M=g.geometry;const T=i.isMeshStandardMaterial||i.isMeshLambertMaterial||i.isMeshPhongMaterial?f.environment:null;const x=i.isMeshStandardMaterial||i.isMeshLambertMaterial&&!i.envMap||i.isMeshPhongMaterial&&!i.envMap;const R=t.get(i.envMap||T,x);const A=!R||R.mapping!==d?null:R.image.height;const b=m[i.type];if(i.precision!==null){p=a.getMaxPrecision(i.precision);p!==i.precision&&w("WebGLProgram.getParameters:",i.precision,"not supported, using",p,"instead.")}const C=M.morphAttributes.position||M.morphAttributes.normal||M.morphAttributes.color;const P=C!==void 0?C.length:0;let L=0;M.morphAttributes.position!==void 0&&(L=1);M.morphAttributes.normal!==void 0&&(L=2);M.morphAttributes.color!==void 0&&(L=3);let U,D;let I,N;if(b){const e=to[b];U=e.vertexShader;D=e.fragmentShader}else{U=i.vertexShader;D=i.fragmentShader;s.update(i);I=s.getVertexShaderID(i);N=s.getFragmentShaderID(i)}const y=e.getRenderTarget();const F=e.state.buffers.depth.getReversed();const O=g.isInstancedMesh===true;const B=g.isBatchedMesh===true;const H=!!i.map;const V=!!i.matcap;const W=!!R;const k=!!i.aoMap;const X=!!i.lightMap;const Y=!!i.bumpMap;const K=!!i.normalMap;const q=!!i.displacementMap;const j=!!i.emissiveMap;const Z=!!i.metalnessMap;const $=!!i.roughnessMap;const Q=i.anisotropy>0;const J=i.clearcoat>0;const ee=i.dispersion>0;const te=i.iridescence>0;const ne=i.sheen>0;const ae=i.transmission>0;const ie=Q&&!!i.anisotropyMap;const re=J&&!!i.clearcoatMap;const oe=J&&!!i.clearcoatNormalMap;const se=J&&!!i.clearcoatRoughnessMap;const le=te&&!!i.iridescenceMap;const ce=te&&!!i.iridescenceThicknessMap;const de=ne&&!!i.sheenColorMap;const fe=ne&&!!i.sheenRoughnessMap;const ue=!!i.specularMap;const pe=!!i.specularColorMap;const me=!!i.specularIntensityMap;const he=ae&&!!i.transmissionMap;const _e=ae&&!!i.thicknessMap;const ge=!!i.gradientMap;const ve=!!i.alphaMap;const Ee=i.alphaTest>0;const Se=!!i.alphaHash;const Me=!!i.extensions;let Te=z;i.toneMapped&&(y!==null&&y.isXRRenderTarget!==true||(Te=e.toneMapping));const xe={shaderID:b,shaderType:i.type,shaderName:i.name,vertexShader:U,fragmentShader:D,defines:i.defines,customVertexShaderID:I,customFragmentShaderID:N,isRawShaderMaterial:i.isRawShaderMaterial===true,glslVersion:i.glslVersion,precision:p,batching:B,batchingColor:B&&g._colorsTexture!==null,instancing:O,instancingColor:O&&g.instanceColor!==null,instancingMorph:O&&g.morphTexture!==null,outputColorSpace:y===null?e.outputColorSpace:y.isXRRenderTarget===true?y.texture.colorSpace:G,alphaToCoverage:!!i.alphaToCoverage,map:H,matcap:V,envMap:W,envMapMode:W&&R.mapping,envMapCubeUVHeight:A,aoMap:k,lightMap:X,bumpMap:Y,normalMap:K,displacementMap:q,emissiveMap:j,normalMapObjectSpace:K&&i.normalMapType===Fe,normalMapTangentSpace:K&&i.normalMapType===ye,metalnessMap:Z,roughnessMap:$,anisotropy:Q,anisotropyMap:ie,clearcoat:J,clearcoatMap:re,clearcoatNormalMap:oe,clearcoatRoughnessMap:se,dispersion:ee,iridescence:te,iridescenceMap:le,iridescenceThicknessMap:ce,sheen:ne,sheenColorMap:de,sheenRoughnessMap:fe,specularMap:ue,specularColorMap:pe,specularIntensityMap:me,transmission:ae,transmissionMap:he,thicknessMap:_e,gradientMap:ge,opaque:i.transparent===false&&i.blending===Ne&&i.alphaToCoverage===false,alphaMap:ve,alphaTest:Ee,alphaHash:Se,combine:i.combine,mapUv:H&&_(i.map.channel),aoMapUv:k&&_(i.aoMap.channel),lightMapUv:X&&_(i.lightMap.channel),bumpMapUv:Y&&_(i.bumpMap.channel),normalMapUv:K&&_(i.normalMap.channel),displacementMapUv:q&&_(i.displacementMap.channel),emissiveMapUv:j&&_(i.emissiveMap.channel),metalnessMapUv:Z&&_(i.metalnessMap.channel),roughnessMapUv:$&&_(i.roughnessMap.channel),anisotropyMapUv:ie&&_(i.anisotropyMap.channel),clearcoatMapUv:re&&_(i.clearcoatMap.channel),clearcoatNormalMapUv:oe&&_(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:se&&_(i.clearcoatRoughnessMap.channel),iridescenceMapUv:le&&_(i.iridescenceMap.channel),iridescenceThicknessMapUv:ce&&_(i.iridescenceThicknessMap.channel),sheenColorMapUv:de&&_(i.sheenColorMap.channel),sheenRoughnessMapUv:fe&&_(i.sheenRoughnessMap.channel),specularMapUv:ue&&_(i.specularMap.channel),specularColorMapUv:pe&&_(i.specularColorMap.channel),specularIntensityMapUv:me&&_(i.specularIntensityMap.channel),transmissionMapUv:he&&_(i.transmissionMap.channel),thicknessMapUv:_e&&_(i.thicknessMap.channel),alphaMapUv:ve&&_(i.alphaMap.channel),vertexTangents:!!M.attributes.tangent&&(K||Q),vertexColors:i.vertexColors,vertexAlphas:i.vertexColors===true&&!!M.attributes.color&&M.attributes.color.itemSize===4,pointsUvs:g.isPoints===true&&!!M.attributes.uv&&(H||ve),fog:!!S,useFog:i.fog===true,fogExp2:!!S&&S.isFogExp2,flatShading:i.wireframe===false&&(i.flatShading===true||M.attributes.normal===void 0&&K===false&&(i.isMeshLambertMaterial||i.isMeshPhongMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial)),sizeAttenuation:i.sizeAttenuation===true,logarithmicDepthBuffer:u,reversedDepthBuffer:F,skinning:g.isSkinnedMesh===true,morphTargets:M.morphAttributes.position!==void 0,morphNormals:M.morphAttributes.normal!==void 0,morphColors:M.morphAttributes.color!==void 0,morphTargetsCount:P,morphTextureStride:L,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:Te,decodeVideoTexture:H&&i.map.isVideoTexture===true&&v.getTransfer(i.map.colorSpace)===E,decodeVideoTextureEmissive:j&&i.emissiveMap.isVideoTexture===true&&v.getTransfer(i.emissiveMap.colorSpace)===E,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===Ie,flipSided:i.side===h,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:Me&&i.extensions.clipCullDistance===true&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Me&&i.extensions.multiDraw===true||B)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:i.customProgramCacheKey()};xe.vertexUv1s=l.has(1);xe.vertexUv2s=l.has(2);xe.vertexUv3s=l.has(3);l.clear();return xe}function S(t){const n=[];if(t.shaderID)n.push(t.shaderID);else{n.push(t.customVertexShaderID);n.push(t.customFragmentShaderID)}if(t.defines!==void 0)for(const e in t.defines){n.push(e);n.push(t.defines[e])}if(t.isRawShaderMaterial===false){M(n,t);T(n,t);n.push(e.outputColorSpace)}n.push(t.customProgramCacheKey);return n.join()}function M(e,t){e.push(t.precision);e.push(t.outputColorSpace);e.push(t.envMapMode);e.push(t.envMapCubeUVHeight);e.push(t.mapUv);e.push(t.alphaMapUv);e.push(t.lightMapUv);e.push(t.aoMapUv);e.push(t.bumpMapUv);e.push(t.normalMapUv);e.push(t.displacementMapUv);e.push(t.emissiveMapUv);e.push(t.metalnessMapUv);e.push(t.roughnessMapUv);e.push(t.anisotropyMapUv);e.push(t.clearcoatMapUv);e.push(t.clearcoatNormalMapUv);e.push(t.clearcoatRoughnessMapUv);e.push(t.iridescenceMapUv);e.push(t.iridescenceThicknessMapUv);e.push(t.sheenColorMapUv);e.push(t.sheenRoughnessMapUv);e.push(t.specularMapUv);e.push(t.specularColorMapUv);e.push(t.specularIntensityMapUv);e.push(t.transmissionMapUv);e.push(t.thicknessMapUv);e.push(t.combine);e.push(t.fogExp2);e.push(t.sizeAttenuation);e.push(t.morphTargetsCount);e.push(t.morphAttributeCount);e.push(t.numDirLights);e.push(t.numPointLights);e.push(t.numSpotLights);e.push(t.numSpotLightMaps);e.push(t.numHemiLights);e.push(t.numRectAreaLights);e.push(t.numDirLightShadows);e.push(t.numPointLightShadows);e.push(t.numSpotLightShadows);e.push(t.numSpotLightShadowsWithMaps);e.push(t.numLightProbes);e.push(t.shadowMapType);e.push(t.toneMapping);e.push(t.numClippingPlanes);e.push(t.numClipIntersection);e.push(t.depthPacking)}function T(e,t){o.disableAll();t.instancing&&o.enable(0);t.instancingColor&&o.enable(1);t.instancingMorph&&o.enable(2);t.matcap&&o.enable(3);t.envMap&&o.enable(4);t.normalMapObjectSpace&&o.enable(5);t.normalMapTangentSpace&&o.enable(6);t.clearcoat&&o.enable(7);t.iridescence&&o.enable(8);t.alphaTest&&o.enable(9);t.vertexColors&&o.enable(10);t.vertexAlphas&&o.enable(11);t.vertexUv1s&&o.enable(12);t.vertexUv2s&&o.enable(13);t.vertexUv3s&&o.enable(14);t.vertexTangents&&o.enable(15);t.anisotropy&&o.enable(16);t.alphaHash&&o.enable(17);t.batching&&o.enable(18);t.dispersion&&o.enable(19);t.batchingColor&&o.enable(20);t.gradientMap&&o.enable(21);e.push(o.mask);o.disableAll();t.fog&&o.enable(0);t.useFog&&o.enable(1);t.flatShading&&o.enable(2);t.logarithmicDepthBuffer&&o.enable(3);t.reversedDepthBuffer&&o.enable(4);t.skinning&&o.enable(5);t.morphTargets&&o.enable(6);t.morphNormals&&o.enable(7);t.morphColors&&o.enable(8);t.premultipliedAlpha&&o.enable(9);t.shadowMapEnabled&&o.enable(10);t.doubleSided&&o.enable(11);t.flipSided&&o.enable(12);t.useDepthPacking&&o.enable(13);t.dithering&&o.enable(14);t.transmission&&o.enable(15);t.sheen&&o.enable(16);t.opaque&&o.enable(17);t.pointsUvs&&o.enable(18);t.decodeVideoTexture&&o.enable(19);t.decodeVideoTextureEmissive&&o.enable(20);t.alphaToCoverage&&o.enable(21);e.push(o.mask)}function x(e){const t=m[e.type];let n;if(t){const e=to[t];n=Oe.clone(e.uniforms)}else n=e.uniforms;return n}function R(t,n){let a=f.get(n);if(a!==void 0)++a.usedTimes;else{a=new Ul(e,n,t,i);c.push(a);f.set(n,a)}return a}function A(e){if(--e.usedTimes===0){const t=c.indexOf(e);c[t]=c[c.length-1];c.pop();f.delete(e.cacheKey);e.destroy()}}function b(e){s.remove(e)}function C(){s.dispose()}return{getParameters:g,getProgramCacheKey:S,getUniforms:x,acquireProgram:R,releaseProgram:A,releaseShaderCache:b,programs:c,dispose:C}}function Il(){let e=new WeakMap;function t(t){return e.has(t)}function n(t){let n=e.get(t);if(n===void 0){n={};e.set(t,n)}return n}function a(t){e.delete(t)}function i(t,n,a){e.get(t)[n]=a}function r(){e=new WeakMap}return{has:t,get:n,remove:a,update:i,dispose:r}}function Nl(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.materialVariant!==t.materialVariant?e.materialVariant-t.materialVariant:e.z!==t.z?e.z-t.z:e.id-t.id}function yl(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Fl(){const e=[];let t=0;const n=[];const a=[];const i=[];function r(){t=0;n.length=0;a.length=0;i.length=0}function o(e){let t=0;e.isInstancedMesh&&(t+=2);e.isSkinnedMesh&&(t+=1);return t}function s(n,a,i,r,s,l){let c=e[t];if(c===void 0){c={id:n.id,object:n,geometry:a,material:i,materialVariant:o(n),groupOrder:r,renderOrder:n.renderOrder,z:s,group:l};e[t]=c}else{c.id=n.id;c.object=n;c.geometry=a;c.material=i;c.materialVariant=o(n);c.groupOrder=r;c.renderOrder=n.renderOrder;c.z=s;c.group=l}t++;return c}function l(e,t,r,o,l,c){const d=s(e,t,r,o,l,c);r.transmission>0?a.push(d):r.transparent===true?i.push(d):n.push(d)}function c(e,t,r,o,l,c){const d=s(e,t,r,o,l,c);r.transmission>0?a.unshift(d):r.transparent===true?i.unshift(d):n.unshift(d)}function d(e,t){n.length>1&&n.sort(e||Nl);a.length>1&&a.sort(t||yl);i.length>1&&i.sort(t||yl)}function f(){for(let n=t,a=e.length;n=a.length){i=new Fl;a.push(i)}else i=a[n];return i}function n(){e=new WeakMap}return{get:t,dispose:n}}function Bl(){const e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let a;switch(t.type){case"DirectionalLight":a={direction:new r,color:new n};break;case"SpotLight":a={position:new r,direction:new r,color:new n,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":a={position:new r,color:new n,distance:0,decay:0};break;case"HemisphereLight":a={direction:new r,skyColor:new n,groundColor:new n};break;case"RectAreaLight":a={color:new n,position:new r,halfWidth:new r,halfHeight:new r};break}e[t.id]=a;return a}}}function Gl(){const e={};return{get:function(n){if(e[n.id]!==void 0)return e[n.id];let a;switch(n.type){case"DirectionalLight":a={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new t};break;case"SpotLight":a={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new t};break;case"PointLight":a={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new t,shadowCameraNear:1,shadowCameraFar:1e3};break}e[n.id]=a;return a}}}let Hl=0;function Vl(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Wl(e){const t=new Bl;const n=Gl();const a={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)a.probe.push(new r);const i=new r;const o=new c;const s=new c;function l(i){let r=0,o=0,s=0;for(let e=0;e<9;e++)a.probe[e].set(0,0,0);let l=0;let c=0;let d=0;let f=0;let u=0;let p=0;let m=0;let h=0;let _=0;let g=0;let v=0;i.sort(Vl);for(let e=0,E=i.length;e0)if(e.has("OES_texture_float_linear")===true){a.rectAreaLTC1=Jr.LTC_FLOAT_1;a.rectAreaLTC2=Jr.LTC_FLOAT_2}else{a.rectAreaLTC1=Jr.LTC_HALF_1;a.rectAreaLTC2=Jr.LTC_HALF_2}a.ambient[0]=r;a.ambient[1]=o;a.ambient[2]=s;const E=a.hash;if(E.directionalLength!==l||E.pointLength!==c||E.spotLength!==d||E.rectAreaLength!==f||E.hemiLength!==u||E.numDirectionalShadows!==p||E.numPointShadows!==m||E.numSpotShadows!==h||E.numSpotMaps!==_||E.numLightProbes!==v){a.directional.length=l;a.spot.length=d;a.rectArea.length=f;a.point.length=c;a.hemi.length=u;a.directionalShadow.length=p;a.directionalShadowMap.length=p;a.pointShadow.length=m;a.pointShadowMap.length=m;a.spotShadow.length=h;a.spotShadowMap.length=h;a.directionalShadowMatrix.length=p;a.pointShadowMatrix.length=m;a.spotLightMatrix.length=h+_-g;a.spotLightMap.length=_;a.numSpotLightShadowsWithMaps=g;a.numLightProbes=v;E.directionalLength=l;E.pointLength=c;E.spotLength=d;E.rectAreaLength=f;E.hemiLength=u;E.numDirectionalShadows=p;E.numPointShadows=m;E.numSpotShadows=h;E.numSpotMaps=_;E.numLightProbes=v;a.version=Hl++}}function d(e,t){let n=0;let r=0;let l=0;let c=0;let d=0;const f=t.matrixWorldInverse;for(let t=0,u=e.length;t=i.length){r=new kl(e);i.push(r)}else r=i[a];return r}function a(){t=new WeakMap}return{get:n,dispose:a}}const Xl="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}";const Yl="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n\tgl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}";const Kl=[new r(1,0,0),new r(-1,0,0),new r(0,1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1)];const ql=[new r(0,-1,0),new r(0,-1,0),new r(0,0,1),new r(0,0,-1),new r(0,-1,0),new r(0,-1,0)];const jl=new c;const Zl=new r;const $l=new r;function Ql(e,n,a){let i=new Ge;const r=new t,o=new t,s=new le,l=new He,c=new Ve,d={},f=a.maxTextureSize;const p={[T]:h,[h]:T,[Ie]:Ie};const _=new m({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new t},radius:{value:4}},vertexShader:Xl,fragmentShader:Yl});const g=_.clone();g.defines.HORIZONTAL_PASS=1;const v=new W;v.setAttribute("position",new K(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const E=new u(v,_);const S=this;this.enabled=false;this.autoUpdate=true;this.needsUpdate=false;this.type=Ce;let M=this.type;this.render=function(t,n,a){if(S.enabled===false)return;if(S.autoUpdate===false&&S.needsUpdate===false)return;if(t.length===0)return;if(this.type===We){w("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead.");this.type=Ce}const l=e.getRenderTarget();const c=e.getActiveCubeFace();const d=e.getActiveMipmapLevel();const u=e.state;u.setBlending($);u.buffers.depth.getReversed()===true?u.buffers.color.setClear(0,0,0,0):u.buffers.color.setClear(1,1,1,1);u.buffers.depth.setTest(true);u.setScissorTest(false);const p=M!==this.type;p&&n.traverse((function(e){e.material&&(Array.isArray(e.material)?e.material.forEach((e=>e.needsUpdate=true)):e.material.needsUpdate=true)}));for(let l=0,c=t.length;lf||r.y>f){if(r.x>f){o.x=Math.floor(f/m.x);r.x=o.x*m.x;d.mapSize.x=o.x}if(r.y>f){o.y=Math.floor(f/m.y);r.y=o.y*m.y;d.mapSize.y=o.y}}const h=e.state.buffers.depth.getReversed();d.camera._reversedDepth=h;if(d.map===null||p===true){if(d.map!==null){if(d.map.depthTexture!==null){d.map.depthTexture.dispose();d.map.depthTexture=null}d.map.dispose()}if(this.type===be){if(c.isPointLight){w("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}d.map=new q(r.x,r.y,{format:Be,type:C,minFilter:V,magFilter:V,generateMipmaps:false});d.map.texture.name=c.name+".shadowMap";d.map.depthTexture=new Me(r.x,r.y,U);d.map.depthTexture.name=c.name+".shadowMapDepth";d.map.depthTexture.format=ke;d.map.depthTexture.compareFunction=null;d.map.depthTexture.minFilter=ze;d.map.depthTexture.magFilter=ze}else{if(c.isPointLight){d.map=new WebGLCubeRenderTarget(r.x);d.map.depthTexture=new Xe(r.x,Ye)}else{d.map=new q(r.x,r.y);d.map.depthTexture=new Me(r.x,r.y,Ye)}d.map.depthTexture.name=c.name+".shadowMap";d.map.depthTexture.format=ke;if(this.type===Ce){d.map.depthTexture.compareFunction=h?xe:Re;d.map.depthTexture.minFilter=V;d.map.depthTexture.magFilter=V}else{d.map.depthTexture.compareFunction=null;d.map.depthTexture.minFilter=ze;d.map.depthTexture.magFilter=ze}}d.camera.updateProjectionMatrix()}const _=d.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t<_;t++){if(d.map.isWebGLCubeRenderTarget){e.setRenderTarget(d.map,t);e.clear()}else{if(t===0){e.setRenderTarget(d.map);e.clear()}const n=d.getViewport(t);s.set(o.x*n.x,o.y*n.y,o.x*n.z,o.y*n.w);u.viewport(s)}if(c.isPointLight){const e=d.camera;const n=d.matrix;const a=c.distance||e.far;if(a!==e.far){e.far=a;e.updateProjectionMatrix()}Zl.setFromMatrixPosition(c.matrixWorld);e.position.copy(Zl);$l.copy(e.position);$l.add(Kl[t]);e.up.copy(ql[t]);e.lookAt($l);e.updateMatrixWorld();n.makeTranslation(-Zl.x,-Zl.y,-Zl.z);jl.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse);d._frustum.setFromProjectionMatrix(jl,e.coordinateSystem,e.reversedDepth)}else d.updateMatrices(c);i=d.getFrustum();A(n,a,d.camera,c,this.type)}d.isPointLightShadow!==true&&this.type===be&&x(d,a);d.needsUpdate=false}M=this.type;S.needsUpdate=false;e.setRenderTarget(l,c,d)};function x(t,a){const i=n.update(E);if(_.defines.VSM_SAMPLES!==t.blurSamples){_.defines.VSM_SAMPLES=t.blurSamples;g.defines.VSM_SAMPLES=t.blurSamples;_.needsUpdate=true;g.needsUpdate=true}t.mapPass===null&&(t.mapPass=new q(r.x,r.y,{format:Be,type:C}));_.uniforms.shadow_pass.value=t.map.depthTexture;_.uniforms.resolution.value=t.mapSize;_.uniforms.radius.value=t.radius;e.setRenderTarget(t.mapPass);e.clear();e.renderBufferDirect(a,null,i,_,E,null);g.uniforms.shadow_pass.value=t.mapPass.texture;g.uniforms.resolution.value=t.mapSize;g.uniforms.radius.value=t.radius;e.setRenderTarget(t.map);e.clear();e.renderBufferDirect(a,null,i,g,E,null)}function R(t,n,a,i){let r=null;const o=a.isPointLight===true?t.customDistanceMaterial:t.customDepthMaterial;if(o!==void 0)r=o;else{r=a.isPointLight===true?c:l;if(e.localClippingEnabled&&n.clipShadows===true&&Array.isArray(n.clippingPlanes)&&n.clippingPlanes.length!==0||n.displacementMap&&n.displacementScale!==0||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||n.alphaToCoverage===true){const e=r.uuid,t=n.uuid;let a=d[e];if(a===void 0){a={};d[e]=a}let i=a[t];if(i===void 0){i=r.clone();a[t]=i;n.addEventListener("dispose",b)}r=i}}r.visible=n.visible;r.wireframe=n.wireframe;r.side=i===be?n.shadowSide!==null?n.shadowSide:n.side:n.shadowSide!==null?n.shadowSide:p[n.side];r.alphaMap=n.alphaMap;r.alphaTest=n.alphaToCoverage===true?.5:n.alphaTest;r.map=n.map;r.clipShadows=n.clipShadows;r.clippingPlanes=n.clippingPlanes;r.clipIntersection=n.clipIntersection;r.displacementMap=n.displacementMap;r.displacementScale=n.displacementScale;r.displacementBias=n.displacementBias;r.wireframeLinewidth=n.wireframeLinewidth;r.linewidth=n.linewidth;if(a.isPointLight===true&&r.isMeshDistanceMaterial===true){const t=e.properties.get(r);t.light=a}return r}function A(t,a,r,o,s){if(t.visible===false)return;const l=t.layers.test(a.layers);if(l&&(t.isMesh||t.isLine||t.isPoints)&&(t.castShadow||t.receiveShadow&&s===be)&&(!t.frustumCulled||i.intersectsObject(t))){t.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,t.matrixWorld);const i=n.update(t);const l=t.material;if(Array.isArray(l)){const n=i.groups;for(let c=0,d=n.length;c=1}else if(F.indexOf("OpenGL ES")!==-1){y=parseFloat(/^OpenGL ES (\d)/.exec(F)[1]);N=y>=2}let O=null;let B={};const G=e.getParameter(e.SCISSOR_BOX);const H=e.getParameter(e.VIEWPORT);const V=(new le).fromArray(G);const W=(new le).fromArray(H);function k(t,n,a,i){const r=new Uint8Array(4);const o=e.createTexture();e.bindTexture(t,o);e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST);e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;on||i.height>n)&&(a=n/Math.max(i.width,i.height));if(a<1){if(typeof HTMLImageElement!=="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!=="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!=="undefined"&&e instanceof ImageBitmap||typeof VideoFrame!=="undefined"&&e instanceof VideoFrame){const n=Math.floor(a*i.width);const r=Math.floor(a*i.height);u===void 0&&(u=h(n,r));const o=t?h(n,r):u;o.width=n;o.height=r;const s=o.getContext("2d");s.drawImage(e,0,0,n,r);w("WebGLRenderer: Texture has been resized from ("+i.width+"x"+i.height+") to ("+n+"x"+r+").");return o}"data"in e&&w("WebGLRenderer: Image in DataTexture is too big ("+i.width+"x"+i.height+").");return e}return e}function g(e){return e.generateMipmaps}function S(t){e.generateMipmap(t)}function M(t){return t.isWebGLCubeRenderTarget?e.TEXTURE_CUBE_MAP:t.isWebGL3DRenderTarget?e.TEXTURE_3D:t.isWebGLArrayRenderTarget||t.isCompressedArrayTexture?e.TEXTURE_2D_ARRAY:e.TEXTURE_2D}function T(t,a,i,r,o=false){if(t!==null){if(e[t]!==void 0)return e[t];w("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+t+"'")}let s=a;if(a===e.RED){i===e.FLOAT&&(s=e.R32F);i===e.HALF_FLOAT&&(s=e.R16F);i===e.UNSIGNED_BYTE&&(s=e.R8)}if(a===e.RED_INTEGER){i===e.UNSIGNED_BYTE&&(s=e.R8UI);i===e.UNSIGNED_SHORT&&(s=e.R16UI);i===e.UNSIGNED_INT&&(s=e.R32UI);i===e.BYTE&&(s=e.R8I);i===e.SHORT&&(s=e.R16I);i===e.INT&&(s=e.R32I)}if(a===e.RG){i===e.FLOAT&&(s=e.RG32F);i===e.HALF_FLOAT&&(s=e.RG16F);i===e.UNSIGNED_BYTE&&(s=e.RG8)}if(a===e.RG_INTEGER){i===e.UNSIGNED_BYTE&&(s=e.RG8UI);i===e.UNSIGNED_SHORT&&(s=e.RG16UI);i===e.UNSIGNED_INT&&(s=e.RG32UI);i===e.BYTE&&(s=e.RG8I);i===e.SHORT&&(s=e.RG16I);i===e.INT&&(s=e.RG32I)}if(a===e.RGB_INTEGER){i===e.UNSIGNED_BYTE&&(s=e.RGB8UI);i===e.UNSIGNED_SHORT&&(s=e.RGB16UI);i===e.UNSIGNED_INT&&(s=e.RGB32UI);i===e.BYTE&&(s=e.RGB8I);i===e.SHORT&&(s=e.RGB16I);i===e.INT&&(s=e.RGB32I)}if(a===e.RGBA_INTEGER){i===e.UNSIGNED_BYTE&&(s=e.RGBA8UI);i===e.UNSIGNED_SHORT&&(s=e.RGBA16UI);i===e.UNSIGNED_INT&&(s=e.RGBA32UI);i===e.BYTE&&(s=e.RGBA8I);i===e.SHORT&&(s=e.RGBA16I);i===e.INT&&(s=e.RGBA32I)}if(a===e.RGB){i===e.UNSIGNED_INT_5_9_9_9_REV&&(s=e.RGB9_E5);i===e.UNSIGNED_INT_10F_11F_11F_REV&&(s=e.R11F_G11F_B10F)}if(a===e.RGBA){const t=o?Ae:v.getTransfer(r);i===e.FLOAT&&(s=e.RGBA32F);i===e.HALF_FLOAT&&(s=e.RGBA16F);i===e.UNSIGNED_BYTE&&(s=t===E?e.SRGB8_ALPHA8:e.RGBA8);i===e.UNSIGNED_SHORT_4_4_4_4&&(s=e.RGBA4);i===e.UNSIGNED_SHORT_5_5_5_1&&(s=e.RGB5_A1)}s!==e.R16F&&s!==e.R32F&&s!==e.RG16F&&s!==e.RG32F&&s!==e.RGBA16F&&s!==e.RGBA32F||n.get("EXT_color_buffer_float");return s}function x(t,n){let a;if(t){if(n===null||n===Ye||n===Nt)a=e.DEPTH24_STENCIL8;else if(n===U)a=e.DEPTH32F_STENCIL8;else if(n===yt){a=e.DEPTH24_STENCIL8;w("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}}else n===null||n===Ye||n===Nt?a=e.DEPTH_COMPONENT24:n===U?a=e.DEPTH_COMPONENT32F:n===yt&&(a=e.DEPTH_COMPONENT16);return a}function R(e,t){return g(e)===true||e.isFramebufferTexture&&e.minFilter!==ze&&e.minFilter!==V?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function A(e){const t=e.target;t.removeEventListener("dispose",A);P(t);t.isVideoTexture&&f.delete(t)}function C(e){const t=e.target;t.removeEventListener("dispose",C);I(t)}function P(e){const t=i.get(e);if(t.__webglInit===void 0)return;const n=e.source;const a=p.get(n);if(a){const i=a[t.__cacheKey];i.usedTimes--;i.usedTimes===0&&D(e);Object.keys(a).length===0&&p.delete(n)}i.remove(e)}function D(t){const n=i.get(t);e.deleteTexture(n.__webglTexture);const a=t.source;const r=p.get(a);delete r[n.__cacheKey];s.memory.textures--}function I(t){const n=i.get(t);if(t.depthTexture){t.depthTexture.dispose();i.remove(t.depthTexture)}if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let a=0;a=r.maxTextures&&w("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures);N+=1;return e}function O(e){const t=[];t.push(e.wrapS);t.push(e.wrapT);t.push(e.wrapR||0);t.push(e.magFilter);t.push(e.minFilter);t.push(e.anisotropy);t.push(e.internalFormat);t.push(e.format);t.push(e.type);t.push(e.generateMipmaps);t.push(e.premultiplyAlpha);t.push(e.flipY);t.push(e.unpackAlignment);t.push(e.colorSpace);return t.join()}function B(t,n){const r=i.get(t);t.isVideoTexture&&pe(t);if(t.isRenderTargetTexture===false&&t.isExternalTexture!==true&&t.version>0&&r.__version!==t.version){const e=t.image;if(e===null)w("WebGLRenderer: Texture marked for update but no image data found.");else{if(e.complete!==false){Q(r,t,n);return}w("WebGLRenderer: Texture marked for update but image is incomplete")}}else t.isExternalTexture&&(r.__webglTexture=t.sourceTexture?t.sourceTexture:null);a.bindTexture(e.TEXTURE_2D,r.__webglTexture,e.TEXTURE0+n)}function H(t,n){const r=i.get(t);if(t.isRenderTargetTexture===false&&t.version>0&&r.__version!==t.version)Q(r,t,n);else{t.isExternalTexture&&(r.__webglTexture=t.sourceTexture?t.sourceTexture:null);a.bindTexture(e.TEXTURE_2D_ARRAY,r.__webglTexture,e.TEXTURE0+n)}}function W(t,n){const r=i.get(t);t.isRenderTargetTexture===false&&t.version>0&&r.__version!==t.version?Q(r,t,n):a.bindTexture(e.TEXTURE_3D,r.__webglTexture,e.TEXTURE0+n)}function k(t,n){const r=i.get(t);t.isCubeDepthTexture!==true&&t.version>0&&r.__version!==t.version?J(r,t,n):a.bindTexture(e.TEXTURE_CUBE_MAP,r.__webglTexture,e.TEXTURE0+n)}const z={[Bt]:e.REPEAT,[Ot]:e.CLAMP_TO_EDGE,[Ft]:e.MIRRORED_REPEAT};const X={[ze]:e.NEAREST,[Vt]:e.NEAREST_MIPMAP_NEAREST,[Ht]:e.NEAREST_MIPMAP_LINEAR,[V]:e.LINEAR,[Gt]:e.LINEAR_MIPMAP_NEAREST,[te]:e.LINEAR_MIPMAP_LINEAR};const K={[Kt]:e.NEVER,[Yt]:e.ALWAYS,[Xt]:e.LESS,[Re]:e.LEQUAL,[zt]:e.EQUAL,[xe]:e.GEQUAL,[kt]:e.GREATER,[Wt]:e.NOTEQUAL};function q(t,a){a.type!==U||n.has("OES_texture_float_linear")!==false||a.magFilter!==V&&a.magFilter!==Gt&&a.magFilter!==Ht&&a.magFilter!==te&&a.minFilter!==V&&a.minFilter!==Gt&&a.minFilter!==Ht&&a.minFilter!==te||w("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");e.texParameteri(t,e.TEXTURE_WRAP_S,z[a.wrapS]);e.texParameteri(t,e.TEXTURE_WRAP_T,z[a.wrapT]);t!==e.TEXTURE_3D&&t!==e.TEXTURE_2D_ARRAY||e.texParameteri(t,e.TEXTURE_WRAP_R,z[a.wrapR]);e.texParameteri(t,e.TEXTURE_MAG_FILTER,X[a.magFilter]);e.texParameteri(t,e.TEXTURE_MIN_FILTER,X[a.minFilter]);if(a.compareFunction){e.texParameteri(t,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE);e.texParameteri(t,e.TEXTURE_COMPARE_FUNC,K[a.compareFunction])}if(n.has("EXT_texture_filter_anisotropic")===true){if(a.magFilter===ze)return;if(a.minFilter!==Ht&&a.minFilter!==te)return;if(a.type===U&&n.has("OES_texture_float_linear")===false)return;if(a.anisotropy>1||i.get(a).__currentAnisotropy){const o=n.get("EXT_texture_filter_anisotropic");e.texParameterf(t,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy()));i.get(a).__currentAnisotropy=a.anisotropy}}}function j(t,n){let a=false;if(t.__webglInit===void 0){t.__webglInit=true;n.addEventListener("dispose",A)}const i=n.source;let r=p.get(i);if(r===void 0){r={};p.set(i,r)}const o=O(n);if(o!==t.__cacheKey){if(r[o]===void 0){r[o]={texture:e.createTexture(),usedTimes:0};s.memory.textures++;a=true}r[o].usedTimes++;const i=r[t.__cacheKey];if(i!==void 0){r[t.__cacheKey].usedTimes--;i.usedTimes===0&&D(n)}t.__cacheKey=o;t.__webglTexture=r[o].texture}return a}function Z(e,t,n){return Math.floor(Math.floor(e/n)/t)}function $(t,n,i,r){const o=4;const s=t.updateRanges;if(s.length===0)a.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,i,r,n.data);else{s.sort(((e,t)=>e.start-t.start));let l=0;for(let e=1;e0){C&&P&&a.texStorage2D(e.TEXTURE_2D,U,E,A[0].width,A[0].height);for(let t=0,n=A.length;t0){const i=Zt(M.width,M.height,n.format,n.type);for(const r of n.layerUpdates){const n=M.data.subarray(r*i/M.data.BYTES_PER_ELEMENT,(r+1)*i/M.data.BYTES_PER_ELEMENT);a.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,r,M.width,M.height,1,m,n)}n.clearLayerUpdates()}else a.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,M.width,M.height,p.depth,m,M.data)}else a.compressedTexImage3D(e.TEXTURE_2D_ARRAY,t,E,M.width,M.height,p.depth,0,M.data,0,0);else w("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else C?L&&a.texSubImage3D(e.TEXTURE_2D_ARRAY,t,0,0,0,M.width,M.height,p.depth,m,h,M.data):a.texImage3D(e.TEXTURE_2D_ARRAY,t,E,M.width,M.height,p.depth,0,m,h,M.data)}}else{C&&P&&a.texStorage2D(e.TEXTURE_2D,U,E,A[0].width,A[0].height);for(let t=0,i=A.length;t0){const t=Zt(p.width,p.height,n.format,n.type);for(const i of n.layerUpdates){const n=p.data.subarray(i*t/p.data.BYTES_PER_ELEMENT,(i+1)*t/p.data.BYTES_PER_ELEMENT);a.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,i,p.width,p.height,1,m,h,n)}n.clearLayerUpdates()}else a.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,p.width,p.height,p.depth,m,h,p.data)}else a.texImage3D(e.TEXTURE_2D_ARRAY,0,E,p.width,p.height,p.depth,0,m,h,p.data);else if(n.isData3DTexture)if(C){P&&a.texStorage3D(e.TEXTURE_3D,U,E,p.width,p.height,p.depth);L&&a.texSubImage3D(e.TEXTURE_3D,0,0,0,0,p.width,p.height,p.depth,m,h,p.data)}else a.texImage3D(e.TEXTURE_3D,0,E,p.width,p.height,p.depth,0,m,h,p.data);else if(n.isFramebufferTexture){if(P)if(C)a.texStorage2D(e.TEXTURE_2D,U,E,p.width,p.height);else{let t=p.width,n=p.height;for(let i=0;i>=1;n>>=1}}}else if(A.length>0){if(C&&P){const t=he(A[0]);a.texStorage2D(e.TEXTURE_2D,U,E,t.width,t.height)}for(let t=0,n=A.length;t0&&L++;const t=he(m[0]);a.texStorage2D(e.TEXTURE_CUBE_MAP,L,x,t.width,t.height)}for(let t=0;t<6;t++)if(p){A?P&&a.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,m[t].width,m[t].height,E,M,m[t].data):a.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,x,m[t].width,m[t].height,0,E,M,m[t].data);for(let n=0;n>d);const i=Math.max(1,n.height>>d);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?a.texImage3D(c,d,p,t,i,n.depth,0,f,u,null):a.texImage2D(c,d,p,t,i,0,f,u,null)}a.bindFramebuffer(e.FRAMEBUFFER,t);ue(n)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,s,c,h.__webglTexture,0,fe(n)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,s,c,h.__webglTexture,d);a.bindFramebuffer(e.FRAMEBUFFER,null)}function ne(t,n,a){e.bindRenderbuffer(e.RENDERBUFFER,t);if(n.depthBuffer){const i=n.depthTexture;const r=i&&i.isDepthTexture?i.type:null;const o=x(n.stencilBuffer,r);const s=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;ue(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,fe(n),o,n.width,n.height):a?e.renderbufferStorageMultisample(e.RENDERBUFFER,fe(n),o,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,o,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,s,e.RENDERBUFFER,t)}else{const t=n.textures;for(let i=0;i{delete n.__boundDepthTexture;delete n.__depthDisposeCallback;e.removeEventListener("dispose",t)};e.addEventListener("dispose",t);n.__depthDisposeCallback=t}n.__boundDepthTexture=e}if(t.depthTexture&&!n.__autoAllocateDepthBuffer)if(r)for(let e=0;e<6;e++)ae(n.__webglFramebuffer[e],t,e);else{const e=t.texture.mipmaps;e&&e.length>0?ae(n.__webglFramebuffer[0],t,0):ae(n.__webglFramebuffer,t,0)}else if(r){n.__webglDepthbuffer=[];for(let i=0;i<6;i++){a.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer[i]);if(n.__webglDepthbuffer[i]===void 0){n.__webglDepthbuffer[i]=e.createRenderbuffer();ne(n.__webglDepthbuffer[i],t,false)}else{const a=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;const r=n.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,r);e.framebufferRenderbuffer(e.FRAMEBUFFER,a,e.RENDERBUFFER,r)}}}else{const i=t.texture.mipmaps;i&&i.length>0?a.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer[0]):a.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer);if(n.__webglDepthbuffer===void 0){n.__webglDepthbuffer=e.createRenderbuffer();ne(n.__webglDepthbuffer,t,false)}else{const a=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;const i=n.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i);e.framebufferRenderbuffer(e.FRAMEBUFFER,a,e.RENDERBUFFER,i)}}a.bindFramebuffer(e.FRAMEBUFFER,null)}function re(t,n,a){const r=i.get(t);n!==void 0&&ee(r.__webglFramebuffer,t,t.texture,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,0);a!==void 0&&ie(t)}function oe(t){const n=t.texture;const r=i.get(t);const l=i.get(n);t.addEventListener("dispose",C);const c=t.textures;const d=t.isWebGLCubeRenderTarget===true;const f=c.length>1;if(!f){l.__webglTexture===void 0&&(l.__webglTexture=e.createTexture());l.__version=n.version;s.memory.textures++}if(d){r.__webglFramebuffer=[];for(let t=0;t<6;t++)if(n.mipmaps&&n.mipmaps.length>0){r.__webglFramebuffer[t]=[];for(let a=0;a0){r.__webglFramebuffer=[];for(let t=0;t0&&ue(t)===false){r.__webglMultisampledFramebuffer=e.createFramebuffer();r.__webglColorRenderbuffer=[];a.bindFramebuffer(e.FRAMEBUFFER,r.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let a=0;a0)if(ue(t)===false){const n=t.textures;const r=t.width;const o=t.height;let s=e.COLOR_BUFFER_BIT;const l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;const d=i.get(t);const f=n.length>1;if(f)for(let t=0;t0?a.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglFramebuffer[0]):a.bindFramebuffer(e.DRAW_FRAMEBUFFER,d.__webglFramebuffer);for(let a=0;a0&&n.has("WEBGL_multisampled_render_to_texture")===true&&t.__useRenderToTexture!==false}function pe(e){const t=s.render.frame;if(f.get(e)!==t){f.set(e,t);e.update()}}function me(e,t){const n=e.colorSpace;const a=e.format;const i=e.type;if(e.isCompressedTexture===true||e.isVideoTexture===true)return t;n!==G&&n!==qt&&(v.getTransfer(n)===E?a===b&&i===L||w("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Y("WebGLTextures: Unsupported texture color space:",n));return t}function he(e){if(typeof HTMLImageElement!=="undefined"&&e instanceof HTMLImageElement){d.width=e.naturalWidth||e.width;d.height=e.naturalHeight||e.height}else if(typeof VideoFrame!=="undefined"&&e instanceof VideoFrame){d.width=e.displayWidth;d.height=e.displayHeight}else{d.width=e.width;d.height=e.height}return d}this.allocateTextureUnit=F;this.resetTextureUnits=y;this.setTexture2D=B;this.setTexture2DArray=H;this.setTexture3D=W;this.setTextureCube=k;this.rebindTextures=re;this.setupRenderTarget=oe;this.updateRenderTargetMipmap=se;this.updateMultisampleRenderTarget=de;this.setupDepthRenderbuffer=ie;this.setupFrameBufferTexture=ee;this.useMultisampledRTT=ue;this.isReversedDepthBuffer=function(){return a.buffers.depth.getReversed()}}function nc(e,t){function n(n,a=qt){let i;const r=v.getTransfer(a);if(n===L)return e.UNSIGNED_BYTE;if(n===$t)return e.UNSIGNED_SHORT_4_4_4_4;if(n===Qt)return e.UNSIGNED_SHORT_5_5_5_1;if(n===Jt)return e.UNSIGNED_INT_5_9_9_9_REV;if(n===tn)return e.UNSIGNED_INT_10F_11F_11F_REV;if(n===nn)return e.BYTE;if(n===an)return e.SHORT;if(n===yt)return e.UNSIGNED_SHORT;if(n===R)return e.INT;if(n===Ye)return e.UNSIGNED_INT;if(n===U)return e.FLOAT;if(n===C)return e.HALF_FLOAT;if(n===rn)return e.ALPHA;if(n===on)return e.RGB;if(n===b)return e.RGBA;if(n===ke)return e.DEPTH_COMPONENT;if(n===jt)return e.DEPTH_STENCIL;if(n===sn)return e.RED;if(n===ln)return e.RED_INTEGER;if(n===Be)return e.RG;if(n===cn)return e.RG_INTEGER;if(n===un)return e.RGBA_INTEGER;if(n===pn||n===mn||n===hn||n===_n)if(r===E){i=t.get("WEBGL_compressed_texture_s3tc_srgb");if(i===null)return null;if(n===pn)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===mn)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===hn)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===_n)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{i=t.get("WEBGL_compressed_texture_s3tc");if(i===null)return null;if(n===pn)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===mn)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===hn)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===_n)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===gn||n===vn||n===En||n===Sn){i=t.get("WEBGL_compressed_texture_pvrtc");if(i===null)return null;if(n===gn)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===vn)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===En)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Sn)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Mn||n===Tn||n===xn||n===Rn||n===An||n===bn||n===Cn){i=t.get("WEBGL_compressed_texture_etc");if(i===null)return null;if(n===Mn||n===Tn)return r===E?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===xn)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC;if(n===Rn)return i.COMPRESSED_R11_EAC;if(n===An)return i.COMPRESSED_SIGNED_R11_EAC;if(n===bn)return i.COMPRESSED_RG11_EAC;if(n===Cn)return i.COMPRESSED_SIGNED_RG11_EAC}if(n===Pn||n===Ln||n===Un||n===Dn||n===wn||n===In||n===Nn||n===yn||n===Fn||n===On||n===Bn||n===Gn||n===Hn||n===Vn){i=t.get("WEBGL_compressed_texture_astc");if(i===null)return null;if(n===Pn)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ln)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Un)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Dn)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===wn)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===In)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Nn)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===yn)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Fn)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===On)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Bn)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Gn)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Hn)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Vn)return r===E?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===Wn||n===kn||n===zn){i=t.get("EXT_texture_compression_bptc");if(i===null)return null;if(n===Wn)return r===E?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===kn)return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===zn)return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}if(n===Xn||n===Yn||n===Kn||n===qn){i=t.get("EXT_texture_compression_rgtc");if(i===null)return null;if(n===Xn)return i.COMPRESSED_RED_RGTC1_EXT;if(n===Yn)return i.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Kn)return i.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===qn)return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===Nt?e.UNSIGNED_INT_24_8:e[n]!==void 0?e[n]:null}return{convert:n}}const ac="\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}";const ic="\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n\tvec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n\tif ( coord.x >= 1.0 ) {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n\t} else {\n\n\t\tgl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n\t}\n\n}";class WebXRDepthSensing{constructor(){ /** * An opaque texture representing the depth of the user's environment. * * @type {?ExternalTexture} */ this.texture=null; /** * A plane mesh for visualizing the depth texture. * * @type {?Mesh} */this.mesh=null; /** * The depth near value. * * @type {number} */this.depthNear=0; /** * The depth near far. * * @type {number} */this.depthFar=0} /** * Inits the depth sensing module * * @param {XRWebGLDepthInformation} depthData - The XR depth data. * @param {XRRenderState} renderState - The XR render state. */init(e,t){if(this.texture===null){const n=new jn(e.texture);if(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar){this.depthNear=e.depthNear;this.depthFar=e.depthFar}this.texture=n}} /** * Returns a plane mesh that visualizes the depth texture. * * @param {ArrayCamera} cameraXR - The XR camera. * @return {?Mesh} The plane mesh. */getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport;const n=new m({vertexShader:ac,fragmentShader:ic,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new u(new S(20,20),n)}return this.mesh}reset(){this.texture=null;this.mesh=null}getDepthTexture(){return this.texture}}class WebXRManager extends Zn{ /** * Constructs a new WebGL renderer. * * @param {WebGLRenderer} renderer - The renderer. * @param {WebGL2RenderingContext} gl - The rendering context. */ constructor(e,n){super();const a=this;let i=null;let o=1;let s=null;let l="local-floor";let c=1;let d=null;let f=null;let u=null;let p=null;let m=null;let h=null;const _=typeof XRWebGLBinding!=="undefined";const g=new WebXRDepthSensing;const v={};const E=n.getContextAttributes();let S=null;let M=null;const T=[];const x=[];const R=new t;let A=null;const C=new k;C.viewport=new le;const P=new k;P.viewport=new le;const U=[C,P];const D=new $n;let I=null;let N=null; /** * Whether the manager's XR camera should be automatically updated or not. * * @type {boolean} * @default true */this.cameraAutoUpdate=true; /** * This flag notifies the renderer to be ready for XR rendering. Set it to `true` * if you are going to use XR in your app. * * @type {boolean} * @default false */this.enabled=false; /** * Whether XR presentation is active or not. * * @type {boolean} * @readonly * @default false */this.isPresenting=false; /** * Returns a group representing the `target ray` space of the XR controller. * Use this space for visualizing 3D objects that support the user in pointing * tasks like UI interaction. * * @param {number} index - The index of the controller. * @return {Group} A group representing the `target ray` space. */this.getController=function(e){let t=T[e];if(t===void 0){t=new Qn;T[e]=t}return t.getTargetRaySpace()}; /** * Returns a group representing the `grip` space of the XR controller. * Use this space for visualizing 3D objects that support the user in pointing * tasks like UI interaction. * * Note: If you want to show something in the user's hand AND offer a * pointing ray at the same time, you'll want to attached the handheld object * to the group returned by `getControllerGrip()` and the ray to the * group returned by `getController()`. The idea is to have two * different groups in two different coordinate spaces for the same WebXR * controller. * * @param {number} index - The index of the controller. * @return {Group} A group representing the `grip` space. */this.getControllerGrip=function(e){let t=T[e];if(t===void 0){t=new Qn;T[e]=t}return t.getGripSpace()}; /** * Returns a group representing the `hand` space of the XR controller. * Use this space for visualizing 3D objects that support the user in pointing * tasks like UI interaction. * * @param {number} index - The index of the controller. * @return {Group} A group representing the `hand` space. */this.getHand=function(e){let t=T[e];if(t===void 0){t=new Qn;T[e]=t}return t.getHandSpace()};function y(e){const t=x.indexOf(e.inputSource);if(t===-1)return;const n=T[t];if(n!==void 0){n.update(e.inputSource,e.frame,d||s);n.dispatchEvent({type:e.type,data:e.inputSource})}}function F(){i.removeEventListener("select",y);i.removeEventListener("selectstart",y);i.removeEventListener("selectend",y);i.removeEventListener("squeeze",y);i.removeEventListener("squeezestart",y);i.removeEventListener("squeezeend",y);i.removeEventListener("end",F);i.removeEventListener("inputsourceschange",O);for(let e=0;e=0){x[a]=null;T[a].disconnect(n)}}for(let t=0;t=x.length){x.push(n);a=e;break}if(x[e]===null){x[e]=n;a=e;break}}if(a===-1)break}const i=T[a];i&&i.connect(n)}}const B=new r;const G=new r; /** * Assumes 2 cameras that are parallel and share an X-axis, and that * the cameras' projection and world matrices have already been set. * And that near and far planes are identical for both cameras. * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765 * * @param {ArrayCamera} camera - The camera to update. * @param {PerspectiveCamera} cameraL - The left camera. * @param {PerspectiveCamera} cameraR - The right camera. */function H(e,t,n){B.setFromMatrixPosition(t.matrixWorld);G.setFromMatrixPosition(n.matrixWorld);const a=B.distanceTo(G);const i=t.projectionMatrix.elements;const r=n.projectionMatrix.elements;const o=i[14]/(i[10]-1);const s=i[14]/(i[10]+1);const l=(i[9]+1)/i[5];const c=(i[9]-1)/i[5];const d=(i[8]-1)/i[0];const f=(r[8]+1)/r[0];const u=o*d;const p=o*f;const m=a/(-d+f);const h=m*-d;t.matrixWorld.decompose(e.position,e.quaternion,e.scale);e.translateX(h);e.translateZ(m);e.matrixWorld.compose(e.position,e.quaternion,e.scale);e.matrixWorldInverse.copy(e.matrixWorld).invert();if(i[10]===-1){e.projectionMatrix.copy(t.projectionMatrix);e.projectionMatrixInverse.copy(t.projectionMatrixInverse)}else{const t=o+m;const n=s+m;const i=u-h;const r=p+(a-h);const d=l*s/n*t;const f=c*s/n*t;e.projectionMatrix.makePerspective(i,r,d,f,t,n);e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function V(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix);e.matrixWorldInverse.copy(e.matrixWorld).invert()} /** * Updates the state of the XR camera. Use this method on app level if you * set `cameraAutoUpdate` to `false`. The method requires the non-XR * camera of the scene as a parameter. The passed in camera's transformation * is automatically adjusted to the position of the XR camera when calling * this method. * * @param {Camera} camera - The camera. */this.updateCamera=function(e){if(i===null)return;let t=e.near;let n=e.far;if(g.texture!==null){g.depthNear>0&&(t=g.depthNear);g.depthFar>0&&(n=g.depthFar)}D.near=P.near=C.near=t;D.far=P.far=C.far=n;if(I!==D.near||N!==D.far){i.updateRenderState({depthNear:D.near,depthFar:D.far});I=D.near;N=D.far}D.layers.mask=e.layers.mask|6;C.layers.mask=D.layers.mask&-5;P.layers.mask=D.layers.mask&-3;const a=e.parent;const r=D.cameras;V(D,a);for(let e=0;e0&&(e.alphaTest.value=a.alphaTest);const i=t.get(a);const r=i.envMap;const o=i.envMapRotation;if(r){e.envMap.value=r;rc.copy(o);rc.x*=-1;rc.y*=-1;rc.z*=-1;if(r.isCubeTexture&&r.isRenderTargetTexture===false){rc.y*=-1;rc.z*=-1}e.envMapRotation.value.setFromMatrix4(oc.makeRotationFromEuler(rc));e.flipEnvMap.value=r.isCubeTexture&&r.isRenderTargetTexture===false?-1:1;e.reflectivity.value=a.reflectivity;e.ior.value=a.ior;e.refractionRatio.value=a.refractionRatio}if(a.lightMap){e.lightMap.value=a.lightMap;e.lightMapIntensity.value=a.lightMapIntensity;n(a.lightMap,e.lightMapTransform)}if(a.aoMap){e.aoMap.value=a.aoMap;e.aoMapIntensity.value=a.aoMapIntensity;n(a.aoMap,e.aoMapTransform)}}function o(e,t){e.diffuse.value.copy(t.color);e.opacity.value=t.opacity;if(t.map){e.map.value=t.map;n(t.map,e.mapTransform)}}function s(e,t){e.dashSize.value=t.dashSize;e.totalSize.value=t.dashSize+t.gapSize;e.scale.value=t.scale}function l(e,t,a,i){e.diffuse.value.copy(t.color);e.opacity.value=t.opacity;e.size.value=t.size*a;e.scale.value=i*.5;if(t.map){e.map.value=t.map;n(t.map,e.uvTransform)}if(t.alphaMap){e.alphaMap.value=t.alphaMap;n(t.alphaMap,e.alphaMapTransform)}t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function c(e,t){e.diffuse.value.copy(t.color);e.opacity.value=t.opacity;e.rotation.value=t.rotation;if(t.map){e.map.value=t.map;n(t.map,e.mapTransform)}if(t.alphaMap){e.alphaMap.value=t.alphaMap;n(t.alphaMap,e.alphaMapTransform)}t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function d(e,t){e.specular.value.copy(t.specular);e.shininess.value=Math.max(t.shininess,1e-4)}function f(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function u(e,t){e.metalness.value=t.metalness;if(t.metalnessMap){e.metalnessMap.value=t.metalnessMap;n(t.metalnessMap,e.metalnessMapTransform)}e.roughness.value=t.roughness;if(t.roughnessMap){e.roughnessMap.value=t.roughnessMap;n(t.roughnessMap,e.roughnessMapTransform)}t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,a){e.ior.value=t.ior;if(t.sheen>0){e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen);e.sheenRoughness.value=t.sheenRoughness;if(t.sheenColorMap){e.sheenColorMap.value=t.sheenColorMap;n(t.sheenColorMap,e.sheenColorMapTransform)}if(t.sheenRoughnessMap){e.sheenRoughnessMap.value=t.sheenRoughnessMap;n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)}}if(t.clearcoat>0){e.clearcoat.value=t.clearcoat;e.clearcoatRoughness.value=t.clearcoatRoughness;if(t.clearcoatMap){e.clearcoatMap.value=t.clearcoatMap;n(t.clearcoatMap,e.clearcoatMapTransform)}if(t.clearcoatRoughnessMap){e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap;n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)}if(t.clearcoatNormalMap){e.clearcoatNormalMap.value=t.clearcoatNormalMap;n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform);e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale);t.side===h&&e.clearcoatNormalScale.value.negate()}}t.dispersion>0&&(e.dispersion.value=t.dispersion);if(t.iridescence>0){e.iridescence.value=t.iridescence;e.iridescenceIOR.value=t.iridescenceIOR;e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0];e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1];if(t.iridescenceMap){e.iridescenceMap.value=t.iridescenceMap;n(t.iridescenceMap,e.iridescenceMapTransform)}if(t.iridescenceThicknessMap){e.iridescenceThicknessMap.value=t.iridescenceThicknessMap;n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)}}if(t.transmission>0){e.transmission.value=t.transmission;e.transmissionSamplerMap.value=a.texture;e.transmissionSamplerSize.value.set(a.width,a.height);if(t.transmissionMap){e.transmissionMap.value=t.transmissionMap;n(t.transmissionMap,e.transmissionMapTransform)}e.thickness.value=t.thickness;if(t.thicknessMap){e.thicknessMap.value=t.thicknessMap;n(t.thicknessMap,e.thicknessMapTransform)}e.attenuationDistance.value=t.attenuationDistance;e.attenuationColor.value.copy(t.attenuationColor)}if(t.anisotropy>0){e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation));if(t.anisotropyMap){e.anisotropyMap.value=t.anisotropyMap;n(t.anisotropyMap,e.anisotropyMapTransform)}}e.specularIntensity.value=t.specularIntensity;e.specularColor.value.copy(t.specularColor);if(t.specularColorMap){e.specularColorMap.value=t.specularColorMap;n(t.specularColorMap,e.specularColorMapTransform)}if(t.specularIntensityMap){e.specularIntensityMap.value=t.specularIntensityMap;n(t.specularIntensityMap,e.specularIntensityMapTransform)}}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function _(e,n){const a=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(a.matrixWorld);e.nearDistance.value=a.shadow.camera.near;e.farDistance.value=a.shadow.camera.far}return{refreshFogUniforms:a,refreshMaterialUniforms:i}}function lc(e,t,n,a){let i={};let r={};let o=[];const s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e,t){const n=t.program;a.uniformBlockBinding(e,n)}function c(e,n){let o=i[e.id];if(o===void 0){m(e);o=d(e);i[e.id]=o;e.addEventListener("dispose",_)}const s=n.program;a.updateUBOMapping(e,s);const l=t.render.frame;if(r[e.id]!==l){u(e);r[e.id]=l}}function d(t){const n=f();t.__bindingPointIndex=n;const a=e.createBuffer();const i=t.__size;const r=t.usage;e.bindBuffer(e.UNIFORM_BUFFER,a);e.bufferData(e.UNIFORM_BUFFER,i,r);e.bindBuffer(e.UNIFORM_BUFFER,null);e.bindBufferBase(e.UNIFORM_BUFFER,n,a);return a}function f(){for(let e=0;e0&&(n+=a-i);e.__size=n;e.__cache={};return this}function h(e){const t={boundary:0,storage:0};if(typeof e==="number"||typeof e==="boolean"){t.boundary=4;t.storage=4}else if(e.isVector2){t.boundary=8;t.storage=8}else if(e.isVector3||e.isColor){t.boundary=16;t.storage=12}else if(e.isVector4){t.boundary=16;t.storage=16}else if(e.isMatrix3){t.boundary=48;t.storage=48}else if(e.isMatrix4){t.boundary=64;t.storage=64}else e.isTexture?w("WebGLRenderer: Texture samplers can not be part of an uniforms group."):w("WebGLRenderer: Unsupported uniform value type.",e);return t}function _(t){const n=t.target;n.removeEventListener("dispose",_);const a=o.indexOf(n.__bindingPointIndex);o.splice(a,1);e.deleteBuffer(i[n.id]);delete i[n.id];delete r[n.id]}function g(){for(const t in i)e.deleteBuffer(i[t]);o=[];i={};r={}}return{bind:l,update:c,dispose:g}}const cc=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let uc=null;function pc(){if(uc===null){uc=new ta(cc,16,16,Be,C);uc.name="DFG_LUT";uc.minFilter=V;uc.magFilter=V;uc.wrapS=Ot;uc.wrapT=Ot;uc.generateMipmaps=false;uc.needsUpdate=true}return uc}class WebGLRenderer{ /** * Constructs a new WebGL renderer. * * @param {WebGLRenderer~Options} [parameters] - The configuration parameter. */ constructor(e={}){const{canvas:t=na(),context:a=null,depth:i=true,stencil:o=false,alpha:s=false,antialias:l=false,premultipliedAlpha:d=true,preserveDrawingBuffer:f=false,powerPreference:u="default",failIfMajorPerformanceCaveat:p=false,reversedDepthBuffer:m=false,outputBufferType:_=L}=e; /** * This flag can be used for type testing. * * @type {boolean} * @readonly * @default true */this.isWebGLRenderer=true;let g;if(a!==null){if(typeof WebGLRenderingContext!=="undefined"&&a instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=a.getContextAttributes().alpha}else g=s;const E=_;const S=new Set([un,cn,ln]);const M=new Set([L,Ye,yt,Nt,$t,Qt]);const x=new Uint32Array(4);const R=new Int32Array(4);let A=null;let b=null;const P=[];const U=[];let D=null; /** * A canvas where the renderer draws its output. This is automatically created by the renderer * in the constructor (if not provided already); you just need to add it to your page like so: * ```js * document.body.appendChild( renderer.domElement ); * ``` * * @type {HTMLCanvasElement|OffscreenCanvas} */this.domElement=t; /** * A object with debug configuration settings. * * - `checkShaderErrors`: If it is `true`, defines whether material shader programs are * checked for errors during compilation and linkage process. It may be useful to disable * this check in production for performance gain. It is strongly recommended to keep these * checks enabled during development. If the shader does not compile and link, it will not * work and associated material will not render. * - `onShaderError(gl, program, glVertexShader,glFragmentShader)`: A callback function that * can be used for custom error reporting. The callback receives the WebGL context, an instance * of WebGLProgram as well two instances of WebGLShader representing the vertex and fragment shader. * Assigning a custom function disables the default error reporting. * * @type {Object} */this.debug={ /** * Enables error checking and reporting when shader programs are being compiled. * @type {boolean} */ checkShaderErrors:true, /** * Callback for custom error reporting. * @type {?Function} */ onShaderError:null}; /** * Whether the renderer should automatically clear its output before rendering a frame or not. * * @type {boolean} * @default true */this.autoClear=true; /** * If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear * the color buffer or not. * * @type {boolean} * @default true */this.autoClearColor=true; /** * If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear * the depth buffer or not. * * @type {boolean} * @default true */this.autoClearDepth=true; /** * If {@link WebGLRenderer#autoClear} set to `true`, whether the renderer should clear * the stencil buffer or not. * * @type {boolean} * @default true */this.autoClearStencil=true; /** * Whether the renderer should sort objects or not. * * Note: Sorting is used to attempt to properly render objects that have some * degree of transparency. By definition, sorting objects may not work in all * cases. Depending on the needs of application, it may be necessary to turn * off sorting and use other methods to deal with transparency rendering e.g. * manually determining each object's rendering order. * * @type {boolean} * @default true */this.sortObjects=true; /** * User-defined clipping planes specified in world space. These planes apply globally. * Points in space whose dot product with the plane is negative are cut away. * * @type {Array} */this.clippingPlanes=[]; /** * Whether the renderer respects object-level clipping planes or not. * * @type {boolean} * @default false */this.localClippingEnabled=false; /** * The tone mapping technique of the renderer. * * @type {(NoToneMapping|LinearToneMapping|ReinhardToneMapping|CineonToneMapping|ACESFilmicToneMapping|CustomToneMapping|AgXToneMapping|NeutralToneMapping)} * @default NoToneMapping */this.toneMapping=z; /** * Exposure level of tone mapping. * * @type {number} * @default 1 */this.toneMappingExposure=1; /** * The normalized resolution scale for the transmission render target, measured in percentage * of viewport dimensions. Lowering this value can result in significant performance improvements * when using {@link MeshPhysicalMaterial#transmission}. * * @type {number} * @default 1 */this.transmissionResolutionScale=1;const I=this;let N=false;this._outputColorSpace=aa;let y=0;let F=0;let O=null;let B=-1;let H=null;const V=new le;const W=new le;let k=null;const X=new n(0);let K=0;let j=t.width;let Z=t.height;let $=1;let Q=null;let J=null;const ee=new le(0,0,j,Z);const ne=new le(0,0,j,Z);let ae=false;const ie=new Ge;let oe=false;let se=false;const ce=new c;const de=new r;const fe=new le;const ue={background:null,fog:null,environment:null,overrideMaterial:null,isScene:true};let pe=false;function me(){return O===null?$:1}let he=a;function _e(e,n){return t.getContext(e,n)}try{const e={alpha:true,depth:i,stencil:o,antialias:l,premultipliedAlpha:d,preserveDrawingBuffer:f,powerPreference:u,failIfMajorPerformanceCaveat:p};"setAttribute"in t&&t.setAttribute("data-engine",`three.js r${ia}`);t.addEventListener("webglcontextlost",ze,false);t.addEventListener("webglcontextrestored",Xe,false);t.addEventListener("webglcontextcreationerror",Ke,false);if(he===null){const t="webgl2";he=_e(t,e);if(he===null)throw _e(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(e){Y("WebGLRenderer: "+e.message);throw e}let ge,ve,Ee,Se;let Me,Te,xe,Re,Ae,be;let Ce,Pe,Le,Ue,De,we;let Ne,ye,Fe,Oe;let Be,He,Ve;function We(){ge=new wo(he);ge.init();Be=new nc(he,ge);ve=new lo(he,ge,e,Be);Ee=new Jl(he,ge);ve.reversedDepthBuffer&&m&&Ee.buffers.depth.setReversed(true);Se=new yo(he);Me=new Il;Te=new tc(he,ge,Ee,Me,ve,Be,Se);xe=new Do(I);Re=new ca(he);He=new oo(he,Re);Ae=new Io(he,Re,Se,He);be=new Oo(he,Ae,Re,He,Se);ye=new Fo(he,ve,Te);De=new co(Me);Ce=new wl(I,xe,ge,ve,He,De);Pe=new sc(I,Me);Le=new Ol;Ue=new zl(ge);Ne=new ro(I,xe,Ee,be,g,d);we=new Ql(I,be,ve);Ve=new lc(he,Se,ve,Ee);Fe=new so(he,ge,Se);Oe=new No(he,ge,Se);Se.programs=Ce.programs; /** * Holds details about the capabilities of the current rendering context. * * @name WebGLRenderer#capabilities * @type {WebGLRenderer~Capabilities} */I.capabilities=ve; /** * Provides methods for retrieving and testing WebGL extensions. * * - `get(extensionName:string)`: Used to check whether a WebGL extension is supported * and return the extension object if available. * - `has(extensionName:string)`: returns `true` if the extension is supported. * * @name WebGLRenderer#extensions * @type {Object} */I.extensions=ge; /** * Used to track properties of other objects like native WebGL objects. * * @name WebGLRenderer#properties * @type {Object} */I.properties=Me; /** * Manages the render lists of the renderer. * * @name WebGLRenderer#renderLists * @type {Object} */I.renderLists=Le; /** * Interface for managing shadows. * * @name WebGLRenderer#shadowMap * @type {WebGLRenderer~ShadowMap} */I.shadowMap=we; /** * Interface for managing the WebGL state. * * @name WebGLRenderer#state * @type {Object} */I.state=Ee; /** * Holds a series of statistical information about the GPU memory * and the rendering process. Useful for debugging and monitoring. * * By default these data are reset at each render call but when having * multiple render passes per frame (e.g. when using post processing) it can * be preferred to reset with a custom pattern. First, set `autoReset` to * `false`. * ```js * renderer.info.autoReset = false; * ``` * Call `reset()` whenever you have finished to render a single frame. * ```js * renderer.info.reset(); * ``` * * @name WebGLRenderer#info * @type {WebGLRenderer~Info} */I.info=Se}We();E!==L&&(D=new Go(E,t.width,t.height,i,o));const ke=new WebXRManager(I,he); /** * A reference to the XR manager. * * @type {WebXRManager} */this.xr=ke;this.getContext=function(){return he};this.getContextAttributes=function(){return he.getContextAttributes()};this.forceContextLoss=function(){const e=ge.get("WEBGL_lose_context");e&&e.loseContext()};this.forceContextRestore=function(){const e=ge.get("WEBGL_lose_context");e&&e.restoreContext()};this.getPixelRatio=function(){return $}; /** * Sets the given pixel ratio and resizes the canvas if necessary. * * @param {number} value - The pixel ratio. */this.setPixelRatio=function(e){if(e!==void 0){$=e;this.setSize(j,Z,false)}}; /** * Returns the renderer's size in logical pixels. This method does not honor the pixel ratio. * * @param {Vector2} target - The method writes the result in this target object. * @return {Vector2} The renderer's size in logical pixels. */this.getSize=function(e){return e.set(j,Z)}; /** * Resizes the output canvas to (width, height) with device pixel ratio taken * into account, and also sets the viewport to fit that size, starting in (0, * 0). Setting `updateStyle` to false prevents any style changes to the output canvas. * * @param {number} width - The width in logical pixels. * @param {number} height - The height in logical pixels. * @param {boolean} [updateStyle=true] - Whether to update the `style` attribute of the canvas or not. */this.setSize=function(e,n,a=true){if(ke.isPresenting)w("WebGLRenderer: Can't change size while VR device is presenting.");else{j=e;Z=n;t.width=Math.floor(e*$);t.height=Math.floor(n*$);if(a===true){t.style.width=e+"px";t.style.height=n+"px"}D!==null&&D.setSize(t.width,t.height);this.setViewport(0,0,e,n)}}; /** * Returns the drawing buffer size in physical pixels. This method honors the pixel ratio. * * @param {Vector2} target - The method writes the result in this target object. * @return {Vector2} The drawing buffer size. */this.getDrawingBufferSize=function(e){return e.set(j*$,Z*$).floor()}; /** * This method allows to define the drawing buffer size by specifying * width, height and pixel ratio all at once. The size of the drawing * buffer is computed with this formula: * ```js * size.x = width * pixelRatio; * size.y = height * pixelRatio; * ``` * * @param {number} width - The width in logical pixels. * @param {number} height - The height in logical pixels. * @param {number} pixelRatio - The pixel ratio. */this.setDrawingBufferSize=function(e,n,a){j=e;Z=n;$=a;t.width=Math.floor(e*a);t.height=Math.floor(n*a);this.setViewport(0,0,e,n)}; /** * Sets the post-processing effects to be applied after rendering. * * @param {Array} effects - An array of post-processing effects. */this.setEffects=function(e){if(E!==L){if(e)for(let t=0;t} The precompiled materials. */this.compile=function(e,t,n=null){n===null&&(n=e);b=Ue.get(n);b.init(t);U.push(b);n.traverseVisible((function(e){if(e.isLight&&e.layers.test(t.layers)){b.pushLight(e);e.castShadow&&b.pushShadow(e)}}));e!==n&&e.traverseVisible((function(e){if(e.isLight&&e.layers.test(t.layers)){b.pushLight(e);e.castShadow&&b.pushShadow(e)}}));b.setupLights();const a=new Set;e.traverse((function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;const t=e.material;if(t)if(Array.isArray(t))for(let i=0;i{function n(){a.forEach((function(e){const t=Me.get(e);const n=t.currentProgram;n.isReady()&&a.delete(e)}));a.size!==0?setTimeout(n,10):t(e)}ge.get("KHR_parallel_shader_compile")!==null?n():setTimeout(n,10)}))};let Qe=null;function Je(e){Qe&&Qe(e)}function et(){nt.stop()}function tt(){nt.start()}const nt=new la;nt.setAnimationLoop(Je);typeof self!=="undefined"&&nt.setContext(self) /** * Applications are advised to always define the animation loop * with this method and not manually with `requestAnimationFrame()` * for best compatibility. * * @param {?onAnimationCallback} callback - The application's animation loop. */;this.setAnimationLoop=function(e){Qe=e;ke.setAnimationLoop(e);e===null?nt.stop():nt.start()};ke.addEventListener("sessionstart",et);ke.addEventListener("sessionend",tt); /** * Renders the given scene (or other type of 3D object) using the given camera. * * The render is done to a previously specified render target set by calling {@link WebGLRenderer#setRenderTarget} * or to the canvas as usual. * * By default render buffers are cleared before rendering but you can prevent * this by setting the property `autoClear` to `false`. If you want to prevent * only certain buffers being cleared you can `autoClearColor`, `autoClearDepth` * or `autoClearStencil` to `false`. To force a clear, use {@link WebGLRenderer#clear}. * * @param {Object3D} scene - The scene to render. * @param {Camera} camera - The camera. */this.render=function(e,t){if(t!==void 0&&t.isCamera!==true){Y("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(N===true)return;const n=ke.enabled===true&&ke.isPresenting===true;const a=D!==null&&(O===null||n)&&D.begin(I,O);e.matrixWorldAutoUpdate===true&&e.updateMatrixWorld();t.parent===null&&t.matrixWorldAutoUpdate===true&&t.updateMatrixWorld();if(ke.enabled===true&&ke.isPresenting===true&&(D===null||D.isCompositing()===false)){ke.cameraAutoUpdate===true&&ke.updateCamera(t);t=ke.getCamera()}e.isScene===true&&e.onBeforeRender(I,e,t,O);b=Ue.get(e,U.length);b.init(t);U.push(b);ce.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse);ie.setFromProjectionMatrix(ce,oa,t.reversedDepth);se=this.localClippingEnabled;oe=De.init(this.clippingPlanes,se);A=Le.get(e,P.length);A.init();P.push(A);if(ke.enabled===true&&ke.isPresenting===true){const e=I.xr.getDepthSensingMesh();e!==null&&at(e,t,-Infinity,I.sortObjects)}at(e,t,0,I.sortObjects);A.finish();I.sortObjects===true&&A.sort(Q,J);pe=ke.enabled===false||ke.isPresenting===false||ke.hasDepthSensing()===false;pe&&Ne.addToRenderList(A,e);this.info.render.frame++;oe===true&&De.beginShadows();const i=b.state.shadowsArray;we.render(i,e,t);oe===true&&De.endShadows();this.info.autoReset===true&&this.info.reset();const r=a&&D.hasRenderPass();if(r===false){const n=A.opaque;const a=A.transmissive;b.setupLights();if(t.isArrayCamera){const i=t.cameras;if(a.length>0)for(let t=0,r=i.length;t0&&rt(n,a,e,t);pe&&Ne.render(e);it(A,e,t)}}if(O!==null&&F===0){Te.updateMultisampleRenderTarget(O);Te.updateRenderTargetMipmap(O)}a&&D.end(I);e.isScene===true&&e.onAfterRender(I,e,t);He.resetDefaultState();B=-1;H=null;U.pop();if(U.length>0){b=U[U.length-1];oe===true&&De.setGlobalState(I.clippingPlanes,b.state.camera)}else b=null;P.pop();A=P.length>0?P[P.length-1]:null};function at(e,t,n,a){if(e.visible===false)return;const i=e.layers.test(t.layers);if(i)if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===true&&e.update(t);else if(e.isLight){b.pushLight(e);e.castShadow&&b.pushShadow(e)}else if(e.isSprite){if(!e.frustumCulled||ie.intersectsSprite(e)){a&&fe.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ce);const t=be.update(e);const i=e.material;i.visible&&A.push(e,t,i,n,fe.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||ie.intersectsObject(e))){const t=be.update(e);const i=e.material;if(a){if(e.boundingSphere!==void 0){e.boundingSphere===null&&e.computeBoundingSphere();fe.copy(e.boundingSphere.center)}else{t.boundingSphere===null&&t.computeBoundingSphere();fe.copy(t.boundingSphere.center)}fe.applyMatrix4(e.matrixWorld).applyMatrix4(ce)}if(Array.isArray(i)){const a=t.groups;for(let r=0,o=a.length;r0&&ot(i,t,n);r.length>0&&ot(r,t,n);o.length>0&&ot(o,t,n);Ee.buffers.depth.setTest(true);Ee.buffers.depth.setMask(true);Ee.buffers.color.setMask(true);Ee.setPolygonOffset(false)}function rt(e,t,n,a){const i=n.isScene===true?n.overrideMaterial:null;if(i!==null)return;if(b.state.transmissionRenderTarget[a.id]===void 0){const e=ge.has("EXT_color_buffer_half_float")||ge.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[a.id]=new q(1,1,{generateMipmaps:true,type:e?C:L,minFilter:te,samples:Math.max(4,ve.samples),stencilBuffer:o,resolveDepthBuffer:false,resolveStencilBuffer:false,colorSpace:v.workingColorSpace})}const r=b.state.transmissionRenderTarget[a.id];const s=a.viewport||V;r.setSize(s.z*I.transmissionResolutionScale,s.w*I.transmissionResolutionScale);const l=I.getRenderTarget();const c=I.getActiveCubeFace();const d=I.getActiveMipmapLevel();I.setRenderTarget(r);I.getClearColor(X);K=I.getClearAlpha();K<1&&I.setClearColor(16777215,.5);I.clear();pe&&Ne.render(n);const f=I.toneMapping;I.toneMapping=z;const u=a.viewport;a.viewport!==void 0&&(a.viewport=void 0);b.setupLightsView(a);oe===true&&De.setGlobalState(I.clippingPlanes,a);ot(e,n,a);Te.updateMultisampleRenderTarget(r);Te.updateRenderTargetMipmap(r);if(ge.has("WEBGL_multisampled_render_to_texture")===false){let e=false;for(let i=0,r=t.length;i0);const u=!!n.morphAttributes.position;const p=!!n.morphAttributes.normal;const m=!!n.morphAttributes.color;let h=z;a.toneMapped&&(O!==null&&O.isXRRenderTarget!==true||(h=I.toneMapping));const _=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color;const g=_!==void 0?_.length:0;const v=Me.get(a);const E=b.state.lights;if(oe===true&&(se===true||e!==H)){const t=e===H&&a.id===B;De.setState(a,e,t)}let S=false;if(a.version===v.__version)v.needsLights&&v.lightsStateVersion!==E.state.version||v.outputColorSpace!==s||i.isBatchedMesh&&v.batching===false?S=true:i.isBatchedMesh||v.batching!==true?i.isBatchedMesh&&v.batchingColor===true&&i.colorTexture===null||i.isBatchedMesh&&v.batchingColor===false&&i.colorTexture!==null||i.isInstancedMesh&&v.instancing===false?S=true:i.isInstancedMesh||v.instancing!==true?i.isSkinnedMesh&&v.skinning===false?S=true:i.isSkinnedMesh||v.skinning!==true?i.isInstancedMesh&&v.instancingColor===true&&i.instanceColor===null||i.isInstancedMesh&&v.instancingColor===false&&i.instanceColor!==null||i.isInstancedMesh&&v.instancingMorph===true&&i.morphTexture===null||i.isInstancedMesh&&v.instancingMorph===false&&i.morphTexture!==null||v.envMap!==c||a.fog===true&&v.fog!==r?S=true:v.numClippingPlanes===void 0||v.numClippingPlanes===De.numPlanes&&v.numIntersection===De.numIntersection?(v.vertexAlphas!==d||v.vertexTangents!==f||v.morphTargets!==u||v.morphNormals!==p||v.morphColors!==m||v.toneMapping!==h||v.morphTargetsCount!==g)&&(S=true):S=true:S=true:S=true:S=true;else{S=true;v.__version=a.version}let M=v.currentProgram;S===true&&(M=lt(a,t,i));let T=false;let x=false;let R=false;const A=M.getUniforms(),C=v.uniforms;if(Ee.useProgram(M.program)){T=true;x=true;R=true}if(a.id!==B){B=a.id;x=true}if(T||H!==e){const t=Ee.buffers.depth.getReversed();if(t&&e.reversedDepth!==true){e._reversedDepth=true;e.updateProjectionMatrix()}A.setValue(he,"projectionMatrix",e.projectionMatrix);A.setValue(he,"viewMatrix",e.matrixWorldInverse);const n=A.map.cameraPosition;n!==void 0&&n.setValue(he,de.setFromMatrixPosition(e.matrixWorld));ve.logarithmicDepthBuffer&&A.setValue(he,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2));(a.isMeshPhongMaterial||a.isMeshToonMaterial||a.isMeshLambertMaterial||a.isMeshBasicMaterial||a.isMeshStandardMaterial||a.isShaderMaterial)&&A.setValue(he,"isOrthographic",e.isOrthographicCamera===true);if(H!==e){H=e;x=true;R=true}}if(v.needsLights){E.state.directionalShadowMap.length>0&&A.setValue(he,"directionalShadowMap",E.state.directionalShadowMap,Te);E.state.spotShadowMap.length>0&&A.setValue(he,"spotShadowMap",E.state.spotShadowMap,Te);E.state.pointShadowMap.length>0&&A.setValue(he,"pointShadowMap",E.state.pointShadowMap,Te)}if(i.isSkinnedMesh){A.setOptional(he,i,"bindMatrix");A.setOptional(he,i,"bindMatrixInverse");const e=i.skeleton;if(e){e.boneTexture===null&&e.computeBoneTexture();A.setValue(he,"boneTexture",e.boneTexture,Te)}}if(i.isBatchedMesh){A.setOptional(he,i,"batchingTexture");A.setValue(he,"batchingTexture",i._matricesTexture,Te);A.setOptional(he,i,"batchingIdTexture");A.setValue(he,"batchingIdTexture",i._indirectTexture,Te);A.setOptional(he,i,"batchingColorTexture");i._colorsTexture!==null&&A.setValue(he,"batchingColorTexture",i._colorsTexture,Te)}const P=n.morphAttributes;P.position===void 0&&P.normal===void 0&&P.color===void 0||ye.update(i,n,M);if(x||v.receiveShadow!==i.receiveShadow){v.receiveShadow=i.receiveShadow;A.setValue(he,"receiveShadow",i.receiveShadow)}(a.isMeshStandardMaterial||a.isMeshLambertMaterial||a.isMeshPhongMaterial)&&a.envMap===null&&t.environment!==null&&(C.envMapIntensity.value=t.environmentIntensity);C.dfgLUT!==void 0&&(C.dfgLUT.value=pc());if(x){A.setValue(he,"toneMappingExposure",I.toneMappingExposure);v.needsLights&&ut(C,R);r&&a.fog===true&&Pe.refreshFogUniforms(C,r);Pe.refreshMaterialUniforms(C,a,$,Z,b.state.transmissionRenderTarget[e.id]);WebGLUniforms.upload(he,ct(v),C,Te)}if(a.isShaderMaterial&&a.uniformsNeedUpdate===true){WebGLUniforms.upload(he,ct(v),C,Te);a.uniformsNeedUpdate=false}a.isSpriteMaterial&&A.setValue(he,"center",i.center);A.setValue(he,"modelViewMatrix",i.modelViewMatrix);A.setValue(he,"normalMatrix",i.normalMatrix);A.setValue(he,"modelMatrix",i.matrixWorld);if(a.isShaderMaterial||a.isRawShaderMaterial){const e=a.uniformsGroups;for(let t=0,n=e.length;t0&&Te.useMultisampledRTT(e)===false?Me.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l;V.copy(e.viewport);W.copy(e.scissor);k=e.scissorTest}else{V.copy(ee).multiplyScalar($).floor();W.copy(ne).multiplyScalar($).floor();k=ae}n!==0&&(a=mt);const o=Ee.bindFramebuffer(he.FRAMEBUFFER,a);o&&Ee.drawBuffers(e,a);Ee.viewport(V);Ee.scissor(W);Ee.setScissorTest(k);if(i){const a=Me.get(e.texture);he.framebufferTexture2D(he.FRAMEBUFFER,he.COLOR_ATTACHMENT0,he.TEXTURE_CUBE_MAP_POSITIVE_X+t,a.__webglTexture,n)}else if(r){const a=t;for(let t=0;t1&&he.readBuffer(he.COLOR_ATTACHMENT0+s);if(!ve.textureFormatReadable(l)){Y("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ve.textureTypeReadable(c)){Y("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}t>=0&&t<=e.width-a&&n>=0&&n<=e.height-i&&he.readPixels(t,n,a,i,Be.convert(l),Be.convert(c),r)}finally{const e=O!==null?Me.get(O).__webglFramebuffer:null;Ee.bindFramebuffer(he.FRAMEBUFFER,e)}}}; /** * Asynchronous, non-blocking version of {@link WebGLRenderer#readRenderTargetPixels}. * * It is recommended to use this version of `readRenderTargetPixels()` whenever possible. * * @async * @param {WebGLRenderTarget} renderTarget - The render target to read from. * @param {number} x - The `x` coordinate of the copy region's origin. * @param {number} y - The `y` coordinate of the copy region's origin. * @param {number} width - The width of the copy region. * @param {number} height - The height of the copy region. * @param {TypedArray} buffer - The result buffer. * @param {number} [activeCubeFaceIndex] - The active cube face index. * @param {number} [textureIndex=0] - The texture index of an MRT render target. * @return {Promise} A Promise that resolves when the read has been finished. The resolve provides the read data as a typed array. */this.readRenderTargetPixelsAsync=async function(e,t,n,a,i,r,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let l=Me.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget&&o!==void 0&&(l=l[o]);if(l){if(t>=0&&t<=e.width-a&&n>=0&&n<=e.height-i){Ee.bindFramebuffer(he.FRAMEBUFFER,l);const o=e.textures[s];const c=o.format;const d=o.type;e.textures.length>1&&he.readBuffer(he.COLOR_ATTACHMENT0+s);if(!ve.textureFormatReadable(c))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ve.textureTypeReadable(d))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const f=he.createBuffer();he.bindBuffer(he.PIXEL_PACK_BUFFER,f);he.bufferData(he.PIXEL_PACK_BUFFER,r.byteLength,he.STREAM_READ);he.readPixels(t,n,a,i,Be.convert(c),Be.convert(d),0);const u=O!==null?Me.get(O).__webglFramebuffer:null;Ee.bindFramebuffer(he.FRAMEBUFFER,u);const p=he.fenceSync(he.SYNC_GPU_COMMANDS_COMPLETE,0);he.flush();await sa(he,p,4);he.bindBuffer(he.PIXEL_PACK_BUFFER,f);he.getBufferSubData(he.PIXEL_PACK_BUFFER,0,r);he.deleteBuffer(f);he.deleteSync(p);return r}throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")}}; /** * Copies pixels from the current bound framebuffer into the given texture. * * @param {FramebufferTexture} texture - The texture. * @param {?Vector2} [position=null] - The start position of the copy operation. * @param {number} [level=0] - The mip level. The default represents the base mip. */this.copyFramebufferToTexture=function(e,t=null,n=0){const a=Math.pow(2,-n);const i=Math.floor(e.image.width*a);const r=Math.floor(e.image.height*a);const o=t!==null?t.x:0;const s=t!==null?t.y:0;Te.setTexture2D(e,0);he.copyTexSubImage2D(he.TEXTURE_2D,n,0,0,o,s,i,r);Ee.unbindTexture()};const ht=he.createFramebuffer();const _t=he.createFramebuffer(); /** * Copies data of the given source texture into a destination texture. * * When using render target textures as `srcTexture` and `dstTexture`, you must make sure both render targets are initialized * {@link WebGLRenderer#initRenderTarget}. * * @param {Texture} srcTexture - The source texture. * @param {Texture} dstTexture - The destination texture. * @param {?(Box2|Box3)} [srcRegion=null] - A bounding box which describes the source region. Can be two or three-dimensional. * @param {?(Vector2|Vector3)} [dstPosition=null] - A vector that represents the origin of the destination region. Can be two or three-dimensional. * @param {number} [srcLevel=0] - The source mipmap level to copy. * @param {?number} [dstLevel=0] - The destination mipmap level. */this.copyTextureToTexture=function(e,t,n=null,a=null,i=0,r=0){let o,s,l,c,d,f;let u,p,m;const h=e.isCompressedTexture?e.mipmaps[r]:e.image;if(n!==null){o=n.max.x-n.min.x;s=n.max.y-n.min.y;l=n.isBox3?n.max.z-n.min.z:1;c=n.min.x;d=n.min.y;f=n.isBox3?n.min.z:0}else{const t=Math.pow(2,-i);o=Math.floor(h.width*t);s=Math.floor(h.height*t);l=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1;c=0;d=0;f=0}if(a!==null){u=a.x;p=a.y;m=a.z}else{u=0;p=0;m=0}const _=Be.convert(t.format);const g=Be.convert(t.type);let v;if(t.isData3DTexture){Te.setTexture3D(t,0);v=he.TEXTURE_3D}else if(t.isDataArrayTexture||t.isCompressedArrayTexture){Te.setTexture2DArray(t,0);v=he.TEXTURE_2D_ARRAY}else{Te.setTexture2D(t,0);v=he.TEXTURE_2D}he.pixelStorei(he.UNPACK_FLIP_Y_WEBGL,t.flipY);he.pixelStorei(he.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha);he.pixelStorei(he.UNPACK_ALIGNMENT,t.unpackAlignment);const E=he.getParameter(he.UNPACK_ROW_LENGTH);const S=he.getParameter(he.UNPACK_IMAGE_HEIGHT);const M=he.getParameter(he.UNPACK_SKIP_PIXELS);const T=he.getParameter(he.UNPACK_SKIP_ROWS);const x=he.getParameter(he.UNPACK_SKIP_IMAGES);he.pixelStorei(he.UNPACK_ROW_LENGTH,h.width);he.pixelStorei(he.UNPACK_IMAGE_HEIGHT,h.height);he.pixelStorei(he.UNPACK_SKIP_PIXELS,c);he.pixelStorei(he.UNPACK_SKIP_ROWS,d);he.pixelStorei(he.UNPACK_SKIP_IMAGES,f);const R=e.isDataArrayTexture||e.isData3DTexture;const A=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){const n=Me.get(e);const a=Me.get(t);const h=Me.get(n.__renderTarget);const _=Me.get(a.__renderTarget);Ee.bindFramebuffer(he.READ_FRAMEBUFFER,h.__webglFramebuffer);Ee.bindFramebuffer(he.DRAW_FRAMEBUFFER,_.__webglFramebuffer);for(let n=0;n