/*! For license information please see LICENSES */ (window.webpackJsonp=window.webpackJsonp||[]).push([[6],{244:function(t,e,n){"use strict";n.d(e,"a",(function(){return Sc})),n.d(e,"b",(function(){return Tc})),n.d(e,"c",(function(){return _c})),n.d(e,"d",(function(){return Ec})),n.d(e,"e",(function(){return wc}));const r="136",o=100,l=301,c=302,h=303,d=304,f=306,m=307,v=1e3,x=1001,y=1002,_=1003,M=1004,w=1005,S=1006,T=1008,E=1009,A=1012,L=1014,C=1015,R=1016,P=1020,I=1022,D=1023,N=1026,z=1027,O=2300,B=2301,F=2302,U=2400,H=2401,k=2402,V=2500,G=3e3,W=3001,j=3201,X=7680,Y=35044,J=35048,Z="300 es";class ${addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let i=0,e=n.length;i>8&255]+Q[t>>16&255]+Q[t>>24&255]+"-"+Q[255&e]+Q[e>>8&255]+"-"+Q[e>>16&15|64]+Q[e>>24&255]+"-"+Q[63&n|128]+Q[n>>8&255]+"-"+Q[n>>16&255]+Q[n>>24&255]+Q[255&r]+Q[r>>8&255]+Q[r>>16&255]+Q[r>>24&255]).toUpperCase()}function it(t,e,n){return Math.max(e,Math.min(n,t))}function st(t,e){return(t%e+e)%e}function at(t,e,n){return(1-n)*t+n*e}function ot(t){return 0==(t&t-1)&&0!==t}function lt(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function ct(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var ht=Object.freeze({__proto__:null,DEG2RAD:tt,RAD2DEG:et,generateUUID:nt,clamp:it,euclideanModulo:st,mapLinear:function(t,e,n,r,o){return r+(t-e)*(o-r)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:at,damp:function(t,e,n,dt){return at(t,e,1-Math.exp(-n*dt))},pingpong:function(t,e=1){return e-Math.abs(st(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(s){return void 0!==s&&(K=s%2147483647),K=16807*K%2147483647,(K-1)/2147483646},degToRad:function(t){return t*tt},radToDeg:function(t){return t*et},isPowerOfTwo:ot,ceilPowerOfTwo:lt,floorPowerOfTwo:ct,setQuaternionFromProperEuler:function(q,a,b,t,e){const n=Math.cos,r=Math.sin,o=n(b/2),l=r(b/2),c=n((a+t)/2),h=r((a+t)/2),d=n((a-t)/2),f=r((a-t)/2),m=n((t-a)/2),v=r((t-a)/2);switch(e){case"XYX":q.set(o*h,l*d,l*f,o*c);break;case"YZY":q.set(l*f,o*h,l*d,o*c);break;case"ZXZ":q.set(l*d,l*f,o*h,o*c);break;case"XZX":q.set(o*h,l*v,l*m,o*c);break;case"YXY":q.set(l*m,o*h,l*v,o*c);break;case"ZYZ":q.set(l*v,l*m,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+e)}}});class ut{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)}addScalar(s){return this.x+=s,this.y+=s,this}addVectors(a,b){return this.x=a.x+b.x,this.y=a.y+b.y,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)}subScalar(s){return this.x-=s,this.y-=s,this}subVectors(a,b){return this.x=a.x-b.x,this.y=a.y-b.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),s=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*n-o*s+t.x,this.y=r*s+o*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}ut.prototype.isVector2=!0;class pt{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(t,e,n,r,o,l,c,h,d){const f=this.elements;return f[0]=t,f[1]=r,f[2]=c,f[3]=e,f[4]=o,f[5]=h,f[6]=n,f[7]=l,f[8]=d,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(a,b){const t=a.elements,e=b.elements,n=this.elements,r=t[0],o=t[3],l=t[6],c=t[1],h=t[4],d=t[7],f=t[2],m=t[5],v=t[8],x=e[0],y=e[3],_=e[6],M=e[1],w=e[4],S=e[7],T=e[2],E=e[5],A=e[8];return n[0]=r*x+o*M+l*T,n[3]=r*y+o*w+l*E,n[6]=r*_+o*S+l*A,n[1]=c*x+h*M+d*T,n[4]=c*y+h*w+d*E,n[7]=c*_+h*S+d*A,n[2]=f*x+m*M+v*T,n[5]=f*y+m*w+v*E,n[8]=f*_+m*S+v*A,this}multiplyScalar(s){const t=this.elements;return t[0]*=s,t[3]*=s,t[6]*=s,t[1]*=s,t[4]*=s,t[7]*=s,t[2]*=s,t[5]*=s,t[8]*=s,this}determinant(){const t=this.elements,a=t[0],b=t[1],e=t[2],n=t[3],r=t[4],o=t[5],g=t[6],l=t[7],i=t[8];return a*r*i-a*o*l-b*n*i+b*o*g+e*n*l-e*r*g}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],o=t[3],l=t[4],c=t[5],h=t[6],d=t[7],f=t[8],m=f*l-c*d,v=c*h-f*o,x=d*o-l*h,y=e*m+n*v+r*x;if(0===y)return this.set(0,0,0,0,0,0,0,0,0);const _=1/y;return t[0]=m*_,t[1]=(r*d-f*n)*_,t[2]=(c*n-r*l)*_,t[3]=v*_,t[4]=(f*e-r*h)*_,t[5]=(r*o-c*e)*_,t[6]=x*_,t[7]=(n*h-d*e)*_,t[8]=(l*e-n*o)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,o,l,c){const h=Math.cos(o),s=Math.sin(o);return this.set(n*h,n*s,-n*(h*l+s*c)+l+t,-r*s,r*h,-r*(-s*l+h*c)+c+e,0,0,1),this}scale(t,e){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=e,n[4]*=e,n[7]*=e,this}rotate(t){const e=Math.cos(t),s=Math.sin(t),n=this.elements,r=n[0],o=n[3],l=n[6],c=n[1],h=n[4],d=n[7];return n[0]=e*r+s*c,n[3]=e*o+s*h,n[6]=e*l+s*d,n[1]=-s*r+e*c,n[4]=-s*o+e*h,n[7]=-s*l+e*d,this}translate(t,e){const n=this.elements;return n[0]+=t*n[2],n[3]+=t*n[5],n[6]+=t*n[8],n[1]+=e*n[2],n[4]+=e*n[5],n[7]+=e*n[8],this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}function ft(t){if(0===t.length)return-1/0;let e=t[0];for(let i=1,n=t.length;ie&&(e=t[i]);return e}pt.prototype.isMatrix3=!0;Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array;function mt(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}let gt;class vt{static getDataURL(image){if(/^data:/i.test(image.src))return image.src;if("undefined"==typeof HTMLCanvasElement)return image.src;let canvas;if(image instanceof HTMLCanvasElement)canvas=image;else{void 0===gt&&(gt=mt("canvas")),gt.width=image.width,gt.height=image.height;const t=gt.getContext("2d");image instanceof ImageData?t.putImageData(image,0,0):t.drawImage(image,0,0,image.width,image.height),canvas=gt}return canvas.width>2048||canvas.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",image),canvas.toDataURL("image/jpeg",.6)):canvas.toDataURL("image/png")}}let xt=0;class yt extends ${constructor(image=yt.DEFAULT_IMAGE,t=yt.DEFAULT_MAPPING,e=1001,n=1001,r=1006,o=1008,l=1023,c=1009,h=1,d=3e3){super(),Object.defineProperty(this,"id",{value:xt++}),this.uuid=nt(),this.name="",this.image=image,this.mipmaps=[],this.mapping=t,this.wrapS=e,this.wrapT=n,this.magFilter=r,this.minFilter=o,this.anisotropy=h,this.format=l,this.internalFormat=null,this.type=c,this.offset=new ut(0,0),this.repeat=new ut(1,1),this.center=new ut(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new pt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=d,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(source){return this.name=source.name,this.image=source.image,this.mipmaps=source.mipmaps.slice(0),this.mapping=source.mapping,this.wrapS=source.wrapS,this.wrapT=source.wrapT,this.magFilter=source.magFilter,this.minFilter=source.minFilter,this.anisotropy=source.anisotropy,this.format=source.format,this.internalFormat=source.internalFormat,this.type=source.type,this.offset.copy(source.offset),this.repeat.copy(source.repeat),this.center.copy(source.center),this.rotation=source.rotation,this.matrixAutoUpdate=source.matrixAutoUpdate,this.matrix.copy(source.matrix),this.generateMipmaps=source.generateMipmaps,this.premultiplyAlpha=source.premultiplyAlpha,this.flipY=source.flipY,this.unpackAlignment=source.unpackAlignment,this.encoding=source.encoding,this.userData=JSON.parse(JSON.stringify(source.userData)),this}toJSON(meta){const t=void 0===meta||"string"==typeof meta;if(!t&&void 0!==meta.textures[this.uuid])return meta.textures[this.uuid];const output={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(void 0!==this.image){const image=this.image;if(void 0===image.uuid&&(image.uuid=nt()),!t&&void 0===meta.images[image.uuid]){let t;if(Array.isArray(image)){t=[];for(let i=0,e=image.length;i1)switch(this.wrapS){case v:t.x=t.x-Math.floor(t.x);break;case x:t.x=t.x<0?0:1;break;case y:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case v:t.y=t.y-Math.floor(t.y);break;case x:t.y=t.y<0?0:1;break;case y:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&this.version++}}function _t(image){return"undefined"!=typeof HTMLImageElement&&image instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&image instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&image instanceof ImageBitmap?vt.getDataURL(image):image.data?{data:Array.prototype.slice.call(image.data),width:image.width,height:image.height,type:image.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}yt.DEFAULT_IMAGE=void 0,yt.DEFAULT_MAPPING=300,yt.prototype.isTexture=!0;class bt{constructor(t=0,e=0,n=0,r=1){this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)}addScalar(s){return this.x+=s,this.y+=s,this.z+=s,this.w+=s,this}addVectors(a,b){return this.x=a.x+b.x,this.y=a.y+b.y,this.z=a.z+b.z,this.w=a.w+b.w,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,this.z+=t.z*s,this.w+=t.w*s,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)}subScalar(s){return this.x-=s,this.y-=s,this.z-=s,this.w-=s,this}subVectors(a,b){return this.x=a.x-b.x,this.y=a.y-b.y,this.z=a.z-b.z,this.w=a.w-b.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,o=this.w,l=t.elements;return this.x=l[0]*e+l[4]*n+l[8]*r+l[12]*o,this.y=l[1]*e+l[5]*n+l[9]*r+l[13]*o,this.z=l[2]*e+l[6]*n+l[10]*r+l[14]*o,this.w=l[3]*e+l[7]*n+l[11]*r+l[15]*o,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(q){this.w=2*Math.acos(q.w);const s=Math.sqrt(1-q.w*q.w);return s<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=q.x/s,this.y=q.y/s,this.z=q.z/s),this}setAxisAngleFromRotationMatrix(t){let e,n,r,o;const l=.01,c=.1,h=t.elements,d=h[0],f=h[4],m=h[8],v=h[1],x=h[5],y=h[9],_=h[2],M=h[6],w=h[10];if(Math.abs(f-v)h&&t>S?tS?h=0?1:-1,n=1-t*t;if(n>Number.EPSILON){const r=Math.sqrt(n),o=Math.atan2(r,t*e);s=Math.sin(s*o)/r,c=Math.sin(c*o)/r}const r=c*e;if(h=h*s+v*r,d=d*s+x*r,f=f*s+y*r,m=m*s+_*r,s===1-c){const t=1/Math.sqrt(h*h+d*d+f*f+m*m);h*=t,d*=t,f*=t,m*=t}}t[e]=h,t[e+1]=d,t[e+2]=f,t[e+3]=m}static multiplyQuaternionsFlat(t,e,n,r,o,l){const c=n[r],h=n[r+1],d=n[r+2],f=n[r+3],m=o[l],v=o[l+1],x=o[l+2],y=o[l+3];return t[e]=c*y+f*m+h*x-d*v,t[e+1]=h*y+f*v+d*m-c*x,t[e+2]=d*y+f*x+c*v-h*m,t[e+3]=f*y-c*m-h*v-d*x,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=t._x,r=t._y,o=t._z,l=t._order,c=Math.cos,h=Math.sin,d=c(n/2),f=c(r/2),m=c(o/2),v=h(n/2),x=h(r/2),y=h(o/2);switch(l){case"XYZ":this._x=v*f*m+d*x*y,this._y=d*x*m-v*f*y,this._z=d*f*y+v*x*m,this._w=d*f*m-v*x*y;break;case"YXZ":this._x=v*f*m+d*x*y,this._y=d*x*m-v*f*y,this._z=d*f*y-v*x*m,this._w=d*f*m+v*x*y;break;case"ZXY":this._x=v*f*m-d*x*y,this._y=d*x*m+v*f*y,this._z=d*f*y+v*x*m,this._w=d*f*m-v*x*y;break;case"ZYX":this._x=v*f*m-d*x*y,this._y=d*x*m+v*f*y,this._z=d*f*y-v*x*m,this._w=d*f*m+v*x*y;break;case"YZX":this._x=v*f*m+d*x*y,this._y=d*x*m+v*f*y,this._z=d*f*y-v*x*m,this._w=d*f*m-v*x*y;break;case"XZY":this._x=v*f*m-d*x*y,this._y=d*x*m-v*f*y,this._z=d*f*y+v*x*m,this._w=d*f*m+v*x*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+l)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],o=e[8],l=e[1],c=e[5],h=e[9],d=e[2],f=e[6],m=e[10],v=n+c+m;if(v>0){const s=.5/Math.sqrt(v+1);this._w=.25/s,this._x=(f-h)*s,this._y=(o-d)*s,this._z=(l-r)*s}else if(n>c&&n>m){const s=2*Math.sqrt(1+n-c-m);this._w=(f-h)/s,this._x=.25*s,this._y=(r+l)/s,this._z=(o+d)/s}else if(c>m){const s=2*Math.sqrt(1+c-n-m);this._w=(o-d)/s,this._x=(r+l)/s,this._y=.25*s,this._z=(h+f)/s}else{const s=2*Math.sqrt(1+m-n-c);this._w=(l-r)/s,this._x=(o+d)/s,this._y=(h+f)/s,this._z=.25*s}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(q){return 2*Math.acos(Math.abs(it(this.dot(q),-1,1)))}rotateTowards(q,t){const e=this.angleTo(q);if(0===e)return this;const n=Math.min(1,t/e);return this.slerp(q,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(q,p){return void 0!==p?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(q,p)):this.multiplyQuaternions(this,q)}premultiply(q){return this.multiplyQuaternions(q,this)}multiplyQuaternions(a,b){const t=a._x,e=a._y,n=a._z,r=a._w,o=b._x,l=b._y,c=b._z,h=b._w;return this._x=t*h+r*o+e*c-n*l,this._y=e*h+r*l+n*o-t*c,this._z=n*h+r*c+t*l-e*o,this._w=r*h-t*o-e*l-n*c,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,r=this._y,o=this._z,l=this._w;let c=l*t._w+n*t._x+r*t._y+o*t._z;if(c<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,c=-c):this.copy(t),c>=1)return this._w=l,this._x=n,this._y=r,this._z=o,this;const h=1-c*c;if(h<=Number.EPSILON){const s=1-e;return this._w=s*l+e*this._w,this._x=s*n+e*this._x,this._y=s*r+e*this._y,this._z=s*o+e*this._z,this.normalize(),this._onChangeCallback(),this}const d=Math.sqrt(h),f=Math.atan2(d,c),m=Math.sin((1-e)*f)/d,v=Math.sin(e*f)/d;return this._w=l*m+this._w*v,this._x=n*m+this._x*v,this._y=r*m+this._y*v,this._z=o*m+this._z*v,this._onChangeCallback(),this}slerpQuaternions(t,e,n){this.copy(t).slerp(e,n)}random(){const t=Math.random(),e=Math.sqrt(1-t),n=Math.sqrt(t),r=2*Math.PI*Math.random(),o=2*Math.PI*Math.random();return this.set(e*Math.cos(r),n*Math.sin(o),n*Math.cos(o),e*Math.sin(r))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}St.prototype.isQuaternion=!0;class Tt{constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)}addScalar(s){return this.x+=s,this.y+=s,this.z+=s,this}addVectors(a,b){return this.x=a.x+b.x,this.y=a.y+b.y,this.z=a.z+b.z,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,this.z+=t.z*s,this}sub(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)}subScalar(s){return this.x-=s,this.y-=s,this.z-=s,this}subVectors(a,b){return this.x=a.x-b.x,this.y=a.y-b.y,this.z=a.z-b.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(a,b){return this.x=a.x*b.x,this.y=a.y*b.y,this.z=a.z*b.z,this}applyEuler(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(At.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(At.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,o=t.elements;return this.x=o[0]*e+o[3]*n+o[6]*r,this.y=o[1]*e+o[4]*n+o[7]*r,this.z=o[2]*e+o[5]*n+o[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,o=t.elements,l=1/(o[3]*e+o[7]*n+o[11]*r+o[15]);return this.x=(o[0]*e+o[4]*n+o[8]*r+o[12])*l,this.y=(o[1]*e+o[5]*n+o[9]*r+o[13])*l,this.z=(o[2]*e+o[6]*n+o[10]*r+o[14])*l,this}applyQuaternion(q){const t=this.x,e=this.y,n=this.z,r=q.x,o=q.y,l=q.z,c=q.w,h=c*t+o*n-l*e,d=c*e+l*t-r*n,f=c*n+r*e-o*t,m=-r*t-o*e-l*n;return this.x=h*c+m*-r+d*-l-f*-o,this.y=d*c+m*-o+f*-r-h*-l,this.z=f*c+m*-l+h*-o-d*-r,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,o=t.elements;return this.x=o[0]*e+o[4]*n+o[8]*r,this.y=o[1]*e+o[5]*n+o[9]*r,this.z=o[2]*e+o[6]*n+o[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t,e){return void 0!==e?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e)):this.crossVectors(this,t)}crossVectors(a,b){const t=a.x,e=a.y,n=a.z,r=b.x,o=b.y,l=b.z;return this.x=e*l-n*o,this.y=n*r-t*l,this.z=t*o-e*r,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Et.copy(this).projectOnVector(t),this.sub(Et)}reflect(t){return this.sub(Et.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(it(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(s){return this.setFromSphericalCoords(s.radius,s.phi,s.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e,n){return void 0!==n&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const u=2*(Math.random()-.5),t=Math.random()*Math.PI*2,e=Math.sqrt(1-u**2);return this.x=e*Math.cos(t),this.y=e*Math.sin(t),this.z=u,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}Tt.prototype.isVector3=!0;const Et=new Tt,At=new St;class Lt{constructor(t=new Tt(1/0,1/0,1/0),e=new Tt(-1/0,-1/0,-1/0)){this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,n=1/0,r=1/0,o=-1/0,l=-1/0,c=-1/0;for(let i=0,h=t.length;io&&(o=h),d>l&&(l=d),f>c&&(c=f)}return this.min.set(e,n,r),this.max.set(o,l,c),this}setFromBufferAttribute(t){let e=1/0,n=1/0,r=1/0,o=-1/0,l=-1/0,c=-1/0;for(let i=0,h=t.count;io&&(o=h),d>l&&(l=d),f>c&&(c=f)}return this.min.set(e,n,r),this.max.set(o,l,c),this}setFromPoints(t){this.makeEmpty();for(let i=0,e=t.length;ithis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Rt),Rt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ft),Ut.subVectors(this.max,Ft),It.subVectors(t.a,Ft),Dt.subVectors(t.b,Ft),Nt.subVectors(t.c,Ft),zt.subVectors(Dt,It),Ot.subVectors(Nt,Dt),Bt.subVectors(It,Nt);let e=[0,-zt.z,zt.y,0,-Ot.z,Ot.y,0,-Bt.z,Bt.y,zt.z,0,-zt.x,Ot.z,0,-Ot.x,Bt.z,0,-Bt.x,-zt.y,zt.x,0,-Ot.y,Ot.x,0,-Bt.y,Bt.x,0];return!!Vt(e,It,Dt,Nt,Ut)&&(e=[1,0,0,0,1,0,0,0,1],!!Vt(e,It,Dt,Nt,Ut)&&(Ht.crossVectors(zt,Ot),e=[Ht.x,Ht.y,Ht.z],Vt(e,It,Dt,Nt,Ut)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Rt.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=.5*this.getSize(Rt).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Ct[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ct[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ct[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ct[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ct[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ct[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ct[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ct[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ct)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}Lt.prototype.isBox3=!0;const Ct=[new Tt,new Tt,new Tt,new Tt,new Tt,new Tt,new Tt,new Tt],Rt=new Tt,Pt=new Lt,It=new Tt,Dt=new Tt,Nt=new Tt,zt=new Tt,Ot=new Tt,Bt=new Tt,Ft=new Tt,Ut=new Tt,Ht=new Tt,kt=new Tt;function Vt(t,e,n,r,o){for(let i=0,l=t.length-3;i<=l;i+=3){kt.fromArray(t,i);const l=o.x*Math.abs(kt.x)+o.y*Math.abs(kt.y)+o.z*Math.abs(kt.z),c=e.dot(kt),h=n.dot(kt),d=r.dot(kt);if(Math.max(-Math.max(c,h,d),Math.min(c,h,d))>l)return!1}return!0}const Gt=new Lt,Wt=new Tt,jt=new Tt,qt=new Tt;class Xt{constructor(t=new Tt,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):Gt.setFromPoints(t).getCenter(n);let r=0;for(let i=0,e=t.length;ithis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){qt.subVectors(t,this.center);const e=qt.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.add(qt.multiplyScalar(n/t)),this.radius+=n}return this}union(t){return!0===this.center.equals(t.center)?jt.set(0,0,1).multiplyScalar(t.radius):jt.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint(Wt.copy(t.center).add(jt)),this.expandByPoint(Wt.copy(t.center).sub(jt)),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Yt=new Tt,Jt=new Tt,Zt=new Tt,$t=new Tt,Qt=new Tt,Kt=new Tt,te=new Tt;class ee{constructor(t=new Tt,e=new Tt(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Yt)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Yt.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Yt.copy(this.direction).multiplyScalar(e).add(this.origin),Yt.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){Jt.copy(t).add(e).multiplyScalar(.5),Zt.copy(e).sub(t).normalize(),$t.copy(this.origin).sub(Jt);const o=.5*t.distanceTo(e),l=-this.direction.dot(Zt),c=$t.dot(this.direction),h=-$t.dot(Zt),d=$t.lengthSq(),f=Math.abs(1-l*l);let m,v,x,y;if(f>0)if(m=l*h-c,v=l*c-h,y=o*f,m>=0)if(v>=-y)if(v<=y){const t=1/f;m*=t,v*=t,x=m*(m+l*v+2*c)+v*(l*m+v+2*h)+d}else v=o,m=Math.max(0,-(l*v+c)),x=-m*m+v*(v+2*h)+d;else v=-o,m=Math.max(0,-(l*v+c)),x=-m*m+v*(v+2*h)+d;else v<=-y?(m=Math.max(0,-(-l*o+c)),v=m>0?-o:Math.min(Math.max(-o,-h),o),x=-m*m+v*(v+2*h)+d):v<=y?(m=0,v=Math.min(Math.max(-o,-h),o),x=v*(v+2*h)+d):(m=Math.max(0,-(l*o+c)),v=m>0?o:Math.min(Math.max(-o,-h),o),x=-m*m+v*(v+2*h)+d);else v=l>0?-o:o,m=Math.max(0,-(l*v+c)),x=-m*m+v*(v+2*h)+d;return n&&n.copy(this.direction).multiplyScalar(m).add(this.origin),r&&r.copy(Zt).multiplyScalar(v).add(Jt),x}intersectSphere(t,e){Yt.subVectors(t.center,this.origin);const n=Yt.dot(this.direction),r=Yt.dot(Yt)-n*n,o=t.radius*t.radius;if(r>o)return null;const l=Math.sqrt(o-r),c=n-l,h=n+l;return c<0&&h<0?null:c<0?this.at(h,e):this.at(c,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,r,o,l,c,h;const d=1/this.direction.x,f=1/this.direction.y,m=1/this.direction.z,v=this.origin;return d>=0?(n=(t.min.x-v.x)*d,r=(t.max.x-v.x)*d):(n=(t.max.x-v.x)*d,r=(t.min.x-v.x)*d),f>=0?(o=(t.min.y-v.y)*f,l=(t.max.y-v.y)*f):(o=(t.max.y-v.y)*f,l=(t.min.y-v.y)*f),n>l||o>r?null:((o>n||n!=n)&&(n=o),(l=0?(c=(t.min.z-v.z)*m,h=(t.max.z-v.z)*m):(c=(t.max.z-v.z)*m,h=(t.min.z-v.z)*m),n>h||c>r?null:((c>n||n!=n)&&(n=c),(h=0?n:r,e)))}intersectsBox(t){return null!==this.intersectBox(t,Yt)}intersectTriangle(a,b,t,e,n){Qt.subVectors(b,a),Kt.subVectors(t,a),te.crossVectors(Qt,Kt);let r,o=this.direction.dot(te);if(o>0){if(e)return null;r=1}else{if(!(o<0))return null;r=-1,o=-o}$t.subVectors(this.origin,a);const l=r*this.direction.dot(Kt.crossVectors($t,Kt));if(l<0)return null;const c=r*this.direction.dot(Qt.cross($t));if(c<0)return null;if(l+c>o)return null;const h=-r*$t.dot(te);return h<0?null:this.at(h/o,n)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class ne{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(t,e,n,r,o,l,c,h,d,f,m,v,x,y,_,M){const w=this.elements;return w[0]=t,w[4]=e,w[8]=n,w[12]=r,w[1]=o,w[5]=l,w[9]=c,w[13]=h,w[2]=d,w[6]=f,w[10]=m,w[14]=v,w[3]=x,w[7]=y,w[11]=_,w[15]=M,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new ne).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,r=1/ie.setFromMatrixColumn(t,0).length(),o=1/ie.setFromMatrixColumn(t,1).length(),l=1/ie.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*o,e[5]=n[5]*o,e[6]=n[6]*o,e[7]=0,e[8]=n[8]*l,e[9]=n[9]*l,e[10]=n[10]*l,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const e=this.elements,n=t.x,r=t.y,o=t.z,a=Math.cos(n),b=Math.sin(n),l=Math.cos(r),c=Math.sin(r),h=Math.cos(o),d=Math.sin(o);if("XYZ"===t.order){const t=a*h,n=a*d,r=b*h,o=b*d;e[0]=l*h,e[4]=-l*d,e[8]=c,e[1]=n+r*c,e[5]=t-o*c,e[9]=-b*l,e[2]=o-t*c,e[6]=r+n*c,e[10]=a*l}else if("YXZ"===t.order){const t=l*h,n=l*d,r=c*h,o=c*d;e[0]=t+o*b,e[4]=r*b-n,e[8]=a*c,e[1]=a*d,e[5]=a*h,e[9]=-b,e[2]=n*b-r,e[6]=o+t*b,e[10]=a*l}else if("ZXY"===t.order){const t=l*h,n=l*d,r=c*h,o=c*d;e[0]=t-o*b,e[4]=-a*d,e[8]=r+n*b,e[1]=n+r*b,e[5]=a*h,e[9]=o-t*b,e[2]=-a*c,e[6]=b,e[10]=a*l}else if("ZYX"===t.order){const t=a*h,n=a*d,r=b*h,o=b*d;e[0]=l*h,e[4]=r*c-n,e[8]=t*c+o,e[1]=l*d,e[5]=o*c+t,e[9]=n*c-r,e[2]=-c,e[6]=b*l,e[10]=a*l}else if("YZX"===t.order){const t=a*l,n=a*c,r=b*l,o=b*c;e[0]=l*h,e[4]=o-t*d,e[8]=r*d+n,e[1]=d,e[5]=a*h,e[9]=-b*h,e[2]=-c*h,e[6]=n*d+r,e[10]=t-o*d}else if("XZY"===t.order){const t=a*l,n=a*c,r=b*l,o=b*c;e[0]=l*h,e[4]=-d,e[8]=c*h,e[1]=t*d+o,e[5]=a*h,e[9]=n*d-r,e[2]=r*d-n,e[6]=b*h,e[10]=o*d+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(q){return this.compose(se,q,ae)}lookAt(t,e,n){const r=this.elements;return ce.subVectors(t,e),0===ce.lengthSq()&&(ce.z=1),ce.normalize(),oe.crossVectors(n,ce),0===oe.lengthSq()&&(1===Math.abs(n.z)?ce.x+=1e-4:ce.z+=1e-4,ce.normalize(),oe.crossVectors(n,ce)),oe.normalize(),le.crossVectors(ce,oe),r[0]=oe.x,r[4]=le.x,r[8]=ce.x,r[1]=oe.y,r[5]=le.y,r[9]=ce.y,r[2]=oe.z,r[6]=le.z,r[10]=ce.z,this}multiply(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(a,b){const t=a.elements,e=b.elements,n=this.elements,r=t[0],o=t[4],l=t[8],c=t[12],h=t[1],d=t[5],f=t[9],m=t[13],v=t[2],x=t[6],y=t[10],_=t[14],M=t[3],w=t[7],S=t[11],T=t[15],E=e[0],A=e[4],L=e[8],C=e[12],R=e[1],P=e[5],I=e[9],D=e[13],N=e[2],z=e[6],O=e[10],B=e[14],F=e[3],U=e[7],H=e[11],k=e[15];return n[0]=r*E+o*R+l*N+c*F,n[4]=r*A+o*P+l*z+c*U,n[8]=r*L+o*I+l*O+c*H,n[12]=r*C+o*D+l*B+c*k,n[1]=h*E+d*R+f*N+m*F,n[5]=h*A+d*P+f*z+m*U,n[9]=h*L+d*I+f*O+m*H,n[13]=h*C+d*D+f*B+m*k,n[2]=v*E+x*R+y*N+_*F,n[6]=v*A+x*P+y*z+_*U,n[10]=v*L+x*I+y*O+_*H,n[14]=v*C+x*D+y*B+_*k,n[3]=M*E+w*R+S*N+T*F,n[7]=M*A+w*P+S*z+T*U,n[11]=M*L+w*I+S*O+T*H,n[15]=M*C+w*D+S*B+T*k,this}multiplyScalar(s){const t=this.elements;return t[0]*=s,t[4]*=s,t[8]*=s,t[12]*=s,t[1]*=s,t[5]*=s,t[9]*=s,t[13]*=s,t[2]*=s,t[6]*=s,t[10]*=s,t[14]*=s,t[3]*=s,t[7]*=s,t[11]*=s,t[15]*=s,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],o=t[12],l=t[1],c=t[5],h=t[9],d=t[13],f=t[2],m=t[6],v=t[10],x=t[14];return t[3]*(+o*h*m-r*d*m-o*c*v+n*d*v+r*c*x-n*h*x)+t[7]*(+e*h*x-e*d*v+o*l*v-r*l*x+r*d*f-o*h*f)+t[11]*(+e*d*m-e*c*x-o*l*m+n*l*x+o*c*f-n*d*f)+t[15]*(-r*c*f-e*h*m+e*c*v+r*l*m-n*l*v+n*h*f)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],o=t[3],l=t[4],c=t[5],h=t[6],d=t[7],f=t[8],m=t[9],v=t[10],x=t[11],y=t[12],_=t[13],M=t[14],w=t[15],S=m*M*d-_*v*d+_*h*x-c*M*x-m*h*w+c*v*w,T=y*v*d-f*M*d-y*h*x+l*M*x+f*h*w-l*v*w,E=f*_*d-y*m*d+y*c*x-l*_*x-f*c*w+l*m*w,A=y*m*h-f*_*h-y*c*v+l*_*v+f*c*M-l*m*M,L=e*S+n*T+r*E+o*A;if(0===L)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/L;return t[0]=S*C,t[1]=(_*v*o-m*M*o-_*r*x+n*M*x+m*r*w-n*v*w)*C,t[2]=(c*M*o-_*h*o+_*r*d-n*M*d-c*r*w+n*h*w)*C,t[3]=(m*h*o-c*v*o-m*r*d+n*v*d+c*r*x-n*h*x)*C,t[4]=T*C,t[5]=(f*M*o-y*v*o+y*r*x-e*M*x-f*r*w+e*v*w)*C,t[6]=(y*h*o-l*M*o-y*r*d+e*M*d+l*r*w-e*h*w)*C,t[7]=(l*v*o-f*h*o+f*r*d-e*v*d-l*r*x+e*h*x)*C,t[8]=E*C,t[9]=(y*m*o-f*_*o-y*n*x+e*_*x+f*n*w-e*m*w)*C,t[10]=(l*_*o-y*c*o+y*n*d-e*_*d-l*n*w+e*c*w)*C,t[11]=(f*c*o-l*m*o-f*n*d+e*m*d+l*n*x-e*c*x)*C,t[12]=A*C,t[13]=(f*_*r-y*m*r+y*n*v-e*_*v-f*n*M+e*m*M)*C,t[14]=(y*c*r-l*_*r-y*n*h+e*_*h+l*n*M-e*c*M)*C,t[15]=(l*m*r-f*c*r+f*n*h-e*m*h-l*n*v+e*c*v)*C,this}scale(t){const e=this.elements,n=t.x,r=t.y,o=t.z;return e[0]*=n,e[4]*=r,e[8]*=o,e[1]*=n,e[5]*=r,e[9]*=o,e[2]*=n,e[6]*=r,e[10]*=o,e[3]*=n,e[7]*=r,e[11]*=o,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),s=Math.sin(e),r=1-n,o=t.x,l=t.y,c=t.z,h=r*o,d=r*l;return this.set(h*o+n,h*l-s*c,h*c+s*l,0,h*l+s*c,d*l+n,d*c-s*o,0,h*c-s*l,d*c+s*o,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,o,l){return this.set(1,n,o,0,t,1,l,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,o=e._x,l=e._y,c=e._z,h=e._w,d=o+o,f=l+l,m=c+c,v=o*d,x=o*f,y=o*m,_=l*f,M=l*m,w=c*m,S=h*d,T=h*f,E=h*m,A=n.x,L=n.y,C=n.z;return r[0]=(1-(_+w))*A,r[1]=(x+E)*A,r[2]=(y-T)*A,r[3]=0,r[4]=(x-E)*L,r[5]=(1-(v+w))*L,r[6]=(M+S)*L,r[7]=0,r[8]=(y+T)*C,r[9]=(M-S)*C,r[10]=(1-(v+_))*C,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;let o=ie.set(r[0],r[1],r[2]).length();const l=ie.set(r[4],r[5],r[6]).length(),c=ie.set(r[8],r[9],r[10]).length();this.determinant()<0&&(o=-o),t.x=r[12],t.y=r[13],t.z=r[14],re.copy(this);const h=1/o,d=1/l,f=1/c;return re.elements[0]*=h,re.elements[1]*=h,re.elements[2]*=h,re.elements[4]*=d,re.elements[5]*=d,re.elements[6]*=d,re.elements[8]*=f,re.elements[9]*=f,re.elements[10]*=f,e.setFromRotationMatrix(re),n.x=o,n.y=l,n.z=c,this}makePerspective(t,e,n,r,o,l){void 0===l&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const c=this.elements,h=2*o/(e-t),d=2*o/(n-r),a=(e+t)/(e-t),b=(n+r)/(n-r),f=-(l+o)/(l-o),m=-2*l*o/(l-o);return c[0]=h,c[4]=0,c[8]=a,c[12]=0,c[1]=0,c[5]=d,c[9]=b,c[13]=0,c[2]=0,c[6]=0,c[10]=f,c[14]=m,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,n,r,o,l){const c=this.elements,h=1/(e-t),d=1/(n-r),p=1/(l-o),f=(e+t)*h,m=(n+r)*d,v=(l+o)*p;return c[0]=2*h,c[4]=0,c[8]=0,c[12]=-f,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=-2*p,c[14]=-v,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}ne.prototype.isMatrix4=!0;const ie=new Tt,re=new ne,se=new Tt(0,0,0),ae=new Tt(1,1,1),oe=new Tt,le=new Tt,ce=new Tt,he=new ne,ue=new St;class de{constructor(t=0,e=0,n=0,r=de.DefaultOrder){this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,o=r[0],l=r[4],c=r[8],h=r[1],d=r[5],f=r[9],m=r[2],v=r[6],x=r[10];switch(e){case"XYZ":this._y=Math.asin(it(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-f,x),this._z=Math.atan2(-l,o)):(this._x=Math.atan2(v,d),this._z=0);break;case"YXZ":this._x=Math.asin(-it(f,-1,1)),Math.abs(f)<.9999999?(this._y=Math.atan2(c,x),this._z=Math.atan2(h,d)):(this._y=Math.atan2(-m,o),this._z=0);break;case"ZXY":this._x=Math.asin(it(v,-1,1)),Math.abs(v)<.9999999?(this._y=Math.atan2(-m,x),this._z=Math.atan2(-l,d)):(this._y=0,this._z=Math.atan2(h,o));break;case"ZYX":this._y=Math.asin(-it(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(v,x),this._z=Math.atan2(h,o)):(this._x=0,this._z=Math.atan2(-l,d));break;case"YZX":this._z=Math.asin(it(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-f,d),this._y=Math.atan2(-m,o)):(this._x=0,this._y=Math.atan2(c,x));break;case"XZY":this._z=Math.asin(-it(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(v,d),this._y=Math.atan2(c,o)):(this._x=Math.atan2(-f,x),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(q,t,e){return he.makeRotationFromQuaternion(q),this.setFromRotationMatrix(he,t,e)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return ue.setFromEuler(this),this.setFromQuaternion(ue,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}toVector3(t){return t?t.set(this._x,this._y,this._z):new Tt(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}de.prototype.isEuler=!0,de.DefaultOrder="XYZ",de.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class pe{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let i=0;i1){for(let i=0;i0){object.children=[];for(let i=0;i0){object.animations=[];for(let i=0;i0&&(output.geometries=t),e.length>0&&(output.materials=e),r.length>0&&(output.textures=r),o.length>0&&(output.images=o),l.length>0&&(output.shapes=l),c.length>0&&(output.skeletons=c),h.length>0&&(output.animations=h)}return output.object=object,output;function n(t){const e=[];for(const n in t){const data=t[n];delete data.metadata,e.push(data)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(source,t=!0){if(this.name=source.name,this.up.copy(source.up),this.position.copy(source.position),this.rotation.order=source.rotation.order,this.quaternion.copy(source.quaternion),this.scale.copy(source.scale),this.matrix.copy(source.matrix),this.matrixWorld.copy(source.matrixWorld),this.matrixAutoUpdate=source.matrixAutoUpdate,this.matrixWorldNeedsUpdate=source.matrixWorldNeedsUpdate,this.layers.mask=source.layers.mask,this.visible=source.visible,this.castShadow=source.castShadow,this.receiveShadow=source.receiveShadow,this.frustumCulled=source.frustumCulled,this.renderOrder=source.renderOrder,this.userData=JSON.parse(JSON.stringify(source.userData)),!0===t)for(let i=0;i0?e.multiplyScalar(1/Math.sqrt(n)):e.set(0,0,0)}static getBarycoord(t,a,b,e,n){Le.subVectors(e,a),Ce.subVectors(b,a),Re.subVectors(t,a);const r=Le.dot(Le),o=Le.dot(Ce),l=Le.dot(Re),c=Ce.dot(Ce),h=Ce.dot(Re),d=r*c-o*o;if(0===d)return n.set(-2,-1,-1);const f=1/d,u=(c*l-o*h)*f,m=(r*h-o*l)*f;return n.set(1-u-m,m,u)}static containsPoint(t,a,b,e){return this.getBarycoord(t,a,b,e,Pe),Pe.x>=0&&Pe.y>=0&&Pe.x+Pe.y<=1}static getUV(t,e,n,r,o,l,c,h){return this.getBarycoord(t,e,n,r,Pe),h.set(0,0),h.addScaledVector(o,Pe.x),h.addScaledVector(l,Pe.y),h.addScaledVector(c,Pe.z),h}static isFrontFacing(a,b,t,e){return Le.subVectors(t,b),Ce.subVectors(a,b),Le.cross(Ce).dot(e)<0}set(a,b,t){return this.a.copy(a),this.b.copy(b),this.c.copy(t),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}setFromAttributeAndIndices(t,e,n,r){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,r),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Le.subVectors(this.c,this.b),Ce.subVectors(this.a,this.b),.5*Le.cross(Ce).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Fe.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Fe.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,r,o){return Fe.getUV(t,this.a,this.b,this.c,e,n,r,o)}containsPoint(t){return Fe.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Fe.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(p,t){const a=this.a,b=this.b,e=this.c;let n,r;Ie.subVectors(b,a),De.subVectors(e,a),ze.subVectors(p,a);const o=Ie.dot(ze),l=De.dot(ze);if(o<=0&&l<=0)return t.copy(a);Oe.subVectors(p,b);const c=Ie.dot(Oe),h=De.dot(Oe);if(c>=0&&h<=c)return t.copy(b);const d=o*h-c*l;if(d<=0&&o>=0&&c<=0)return n=o/(o-c),t.copy(a).addScaledVector(Ie,n);Be.subVectors(p,e);const f=Ie.dot(Be),m=De.dot(Be);if(m>=0&&f<=m)return t.copy(e);const v=f*l-o*m;if(v<=0&&l>=0&&m<=0)return r=l/(l-m),t.copy(a).addScaledVector(De,r);const x=c*m-f*h;if(x<=0&&h-c>=0&&f-m>=0)return Ne.subVectors(e,b),r=(h-c)/(h-c+(f-m)),t.copy(b).addScaledVector(Ne,r);const y=1/(x+v+d);return n=v*y,r=d*y,t.copy(a).addScaledVector(Ie,n).addScaledVector(De,r)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let Ue=0;class He extends ${constructor(){super(),Object.defineProperty(this,"id",{value:Ue++}),this.uuid=nt(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.format=D,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=o,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=X,this.stencilZFail=X,this.stencilZPass=X,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}if("shading"===e){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;continue}const r=this[e];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}}toJSON(meta){const t=void 0===meta||"string"==typeof meta;t&&(meta={textures:{},images:{}});const data={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function e(t){const e=[];for(const n in t){const data=t[n];delete data.metadata,e.push(data)}return e}if(data.uuid=this.uuid,data.type=this.type,""!==this.name&&(data.name=this.name),this.color&&this.color.isColor&&(data.color=this.color.getHex()),void 0!==this.roughness&&(data.roughness=this.roughness),void 0!==this.metalness&&(data.metalness=this.metalness),void 0!==this.sheen&&(data.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(data.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(data.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(data.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(data.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(data.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(data.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(data.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(data.shininess=this.shininess),void 0!==this.clearcoat&&(data.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(data.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(data.clearcoatMap=this.clearcoatMap.toJSON(meta).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(data.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(meta).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(data.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(meta).uuid,data.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(data.map=this.map.toJSON(meta).uuid),this.matcap&&this.matcap.isTexture&&(data.matcap=this.matcap.toJSON(meta).uuid),this.alphaMap&&this.alphaMap.isTexture&&(data.alphaMap=this.alphaMap.toJSON(meta).uuid),this.lightMap&&this.lightMap.isTexture&&(data.lightMap=this.lightMap.toJSON(meta).uuid,data.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(data.aoMap=this.aoMap.toJSON(meta).uuid,data.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(data.bumpMap=this.bumpMap.toJSON(meta).uuid,data.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(data.normalMap=this.normalMap.toJSON(meta).uuid,data.normalMapType=this.normalMapType,data.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(data.displacementMap=this.displacementMap.toJSON(meta).uuid,data.displacementScale=this.displacementScale,data.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(data.roughnessMap=this.roughnessMap.toJSON(meta).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(data.metalnessMap=this.metalnessMap.toJSON(meta).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(data.emissiveMap=this.emissiveMap.toJSON(meta).uuid),this.specularMap&&this.specularMap.isTexture&&(data.specularMap=this.specularMap.toJSON(meta).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(data.specularIntensityMap=this.specularIntensityMap.toJSON(meta).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(data.specularColorMap=this.specularColorMap.toJSON(meta).uuid),this.envMap&&this.envMap.isTexture&&(data.envMap=this.envMap.toJSON(meta).uuid,void 0!==this.combine&&(data.combine=this.combine)),void 0!==this.envMapIntensity&&(data.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(data.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(data.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(data.gradientMap=this.gradientMap.toJSON(meta).uuid),void 0!==this.transmission&&(data.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(data.transmissionMap=this.transmissionMap.toJSON(meta).uuid),void 0!==this.thickness&&(data.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(data.thicknessMap=this.thicknessMap.toJSON(meta).uuid),void 0!==this.attenuationDistance&&(data.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(data.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(data.size=this.size),null!==this.shadowSide&&(data.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(data.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(data.blending=this.blending),0!==this.side&&(data.side=this.side),this.vertexColors&&(data.vertexColors=!0),this.opacity<1&&(data.opacity=this.opacity),this.format!==D&&(data.format=this.format),!0===this.transparent&&(data.transparent=this.transparent),data.depthFunc=this.depthFunc,data.depthTest=this.depthTest,data.depthWrite=this.depthWrite,data.colorWrite=this.colorWrite,data.stencilWrite=this.stencilWrite,data.stencilWriteMask=this.stencilWriteMask,data.stencilFunc=this.stencilFunc,data.stencilRef=this.stencilRef,data.stencilFuncMask=this.stencilFuncMask,data.stencilFail=this.stencilFail,data.stencilZFail=this.stencilZFail,data.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(data.rotation=this.rotation),!0===this.polygonOffset&&(data.polygonOffset=!0),0!==this.polygonOffsetFactor&&(data.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(data.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(data.linewidth=this.linewidth),void 0!==this.dashSize&&(data.dashSize=this.dashSize),void 0!==this.gapSize&&(data.gapSize=this.gapSize),void 0!==this.scale&&(data.scale=this.scale),!0===this.dithering&&(data.dithering=!0),this.alphaTest>0&&(data.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(data.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(data.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(data.wireframe=this.wireframe),this.wireframeLinewidth>1&&(data.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(data.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(data.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(data.flatShading=this.flatShading),!1===this.visible&&(data.visible=!1),!1===this.toneMapped&&(data.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(data.userData=this.userData),t){const t=e(meta.textures),n=e(meta.images);t.length>0&&(data.textures=t),n.length>0&&(data.images=n)}return data}clone(){return(new this.constructor).copy(this)}copy(source){this.name=source.name,this.fog=source.fog,this.blending=source.blending,this.side=source.side,this.vertexColors=source.vertexColors,this.opacity=source.opacity,this.format=source.format,this.transparent=source.transparent,this.blendSrc=source.blendSrc,this.blendDst=source.blendDst,this.blendEquation=source.blendEquation,this.blendSrcAlpha=source.blendSrcAlpha,this.blendDstAlpha=source.blendDstAlpha,this.blendEquationAlpha=source.blendEquationAlpha,this.depthFunc=source.depthFunc,this.depthTest=source.depthTest,this.depthWrite=source.depthWrite,this.stencilWriteMask=source.stencilWriteMask,this.stencilFunc=source.stencilFunc,this.stencilRef=source.stencilRef,this.stencilFuncMask=source.stencilFuncMask,this.stencilFail=source.stencilFail,this.stencilZFail=source.stencilZFail,this.stencilZPass=source.stencilZPass,this.stencilWrite=source.stencilWrite;const t=source.clippingPlanes;let e=null;if(null!==t){const n=t.length;e=new Array(n);for(let i=0;i!==n;++i)e[i]=t[i].clone()}return this.clippingPlanes=e,this.clipIntersection=source.clipIntersection,this.clipShadows=source.clipShadows,this.shadowSide=source.shadowSide,this.colorWrite=source.colorWrite,this.precision=source.precision,this.polygonOffset=source.polygonOffset,this.polygonOffsetFactor=source.polygonOffsetFactor,this.polygonOffsetUnits=source.polygonOffsetUnits,this.dithering=source.dithering,this.alphaTest=source.alphaTest,this.alphaToCoverage=source.alphaToCoverage,this.premultipliedAlpha=source.premultipliedAlpha,this.visible=source.visible,this.toneMapped=source.toneMapped,this.userData=JSON.parse(JSON.stringify(source.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}He.prototype.isMaterial=!0;const ke={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ve={h:0,s:0,l:0},Ge={h:0,s:0,l:0};function We(p,q,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?p+6*(q-p)*t:t<.5?q:t<2/3?p+6*(q-p)*(2/3-t):p}function je(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function qe(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class Xe{constructor(t,g,b){return void 0===g&&void 0===b?this.set(t):this.setRGB(t,g,b)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this}setRGB(t,g,b){return this.r=t,this.g=g,this.b=b,this}setHSL(t,s,e){if(t=st(t,1),s=it(s,0,1),e=it(e,0,1),0===s)this.r=this.g=this.b=e;else{const p=e<=.5?e*(1+s):e+s-e*s,q=2*e-p;this.r=We(q,p,t+1/3),this.g=We(q,p,t),this.b=We(q,p,t-1/3)}return this}setStyle(style){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+style+" will be ignored.")}let e;if(e=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(style)){let n;const r=e[1],o=e[2];switch(r){case"rgb":case"rgba":if(n=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,t(n[4]),this;if(n=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,t(n[4]),this;break;case"hsl":case"hsla":if(n=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const e=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,r=parseInt(n[3],10)/100;return t(n[4]),this.setHSL(e,s,r)}}}else if(e=/^\#([A-Fa-f\d]+)$/.exec(style)){const t=e[1],n=t.length;if(3===n)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,this;if(6===n)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,this}return style&&style.length>0?this.setColorName(style):this}setColorName(style){const t=ke[style.toLowerCase()];return void 0!==t?this.setHex(t):console.warn("THREE.Color: Unknown color "+style),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=je(t.r),this.g=je(t.g),this.b=je(t.b),this}copyLinearToSRGB(t){return this.r=qe(t.r),this.g=qe(t.g),this.b=qe(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(t){const e=this.r,g=this.g,b=this.b,n=Math.max(e,g,b),r=Math.min(e,g,b);let o,l;const c=(r+n)/2;if(r===n)o=0,l=0;else{const t=n-r;switch(l=c<=.5?t/(n+r):t/(2-n-r),n){case e:o=(g-b)/t+(g65535?Ke:Qe)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new pt).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(t),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(q){return nn.makeRotationFromQuaternion(q),this.applyMatrix4(nn),this}rotateX(t){return nn.makeRotationX(t),this.applyMatrix4(nn),this}rotateY(t){return nn.makeRotationY(t),this.applyMatrix4(nn),this}rotateZ(t){return nn.makeRotationZ(t),this.applyMatrix4(nn),this}translate(t,e,n){return nn.makeTranslation(t,e,n),this.applyMatrix4(nn),this}scale(t,e,n){return nn.makeScale(t,e,n),this.applyMatrix4(nn),this}lookAt(t){return rn.lookAt(t),rn.updateMatrix(),this.applyMatrix4(rn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(sn).negate(),this.translate(sn.x,sn.y,sn.z),this}setFromPoints(t){const e=[];for(let i=0,n=t.length;i0&&(data.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const e in t)void 0!==t[e]&&(data[e]=t[e]);return data}data.data={attributes:{}};const t=this.index;null!==t&&(data.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const e=this.attributes;for(const t in e){const n=e[t];data.data.attributes[t]=n.toJSON(data.data)}const n={};let r=!1;for(const t in this.morphAttributes){const e=this.morphAttributes[t],o=[];for(let i=0,t=e.length;i0&&(n[t]=o,r=!0)}r&&(data.data.morphAttributes=n,data.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(data.data.groups=JSON.parse(JSON.stringify(o)));const l=this.boundingSphere;return null!==l&&(data.data.boundingSphere={center:l.center.toArray(),radius:l.radius}),data}clone(){return(new this.constructor).copy(this)}copy(source){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const data={};this.name=source.name;const t=source.index;null!==t&&this.setIndex(t.clone(data));const e=source.attributes;for(const t in e){const n=e[t];this.setAttribute(t,n.clone(data))}const n=source.morphAttributes;for(const t in n){const e=[],r=n[t];for(let i=0,t=r.length;i0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(t,e){const n=this.geometry,r=this.material,o=this.matrixWorld;if(void 0===r)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),dn.copy(n.boundingSphere),dn.applyMatrix4(o),!1===t.ray.intersectsSphere(dn))return;if(hn.copy(o).invert(),un.copy(t.ray).applyMatrix4(hn),null!==n.boundingBox&&!1===un.intersectsBox(n.boundingBox))return;let l;if(n.isBufferGeometry){const o=n.index,c=n.attributes.position,h=n.morphAttributes.position,d=n.morphTargetsRelative,f=n.attributes.uv,m=n.attributes.uv2,v=n.groups,x=n.drawRange;if(null!==o)if(Array.isArray(r))for(let i=0,n=v.length;ie.far?null:{distance:d,point:En.clone(),object:object}}(object,t,e,n,pn,fn,mn,Tn);if(m){c&&(Mn.fromBufferAttribute(c,a),wn.fromBufferAttribute(c,b),Sn.fromBufferAttribute(c,d),m.uv=Fe.getUV(Tn,pn,fn,mn,Mn,wn,Sn,new ut)),h&&(Mn.fromBufferAttribute(h,a),wn.fromBufferAttribute(h,b),Sn.fromBufferAttribute(h,d),m.uv2=Fe.getUV(Tn,pn,fn,mn,Mn,wn,Sn,new ut));const t={a:a,b:b,c:d,normal:new Tt,materialIndex:0};Fe.getNormal(pn,fn,mn,t.normal),m.face=t}return m}An.prototype.isMesh=!0;class Cn extends cn{constructor(t=1,e=1,n=1,r=1,o=1,l=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:r,heightSegments:o,depthSegments:l};const c=this;r=Math.floor(r),o=Math.floor(o),l=Math.floor(l);const h=[],d=[],f=[],m=[];let v=0,x=0;function y(u,t,e,n,r,o,l,y,_,M,w){const S=o/_,T=l/M,E=o/2,A=l/2,L=y/2,C=_+1,R=M+1;let P=0,I=0;const D=new Tt;for(let o=0;o0?1:-1,f.push(D.x,D.y,D.z),m.push(c/_),m.push(1-o/M),P+=1}}for(let t=0;t0&&(data.defines=this.defines),data.vertexShader=this.vertexShader,data.fragmentShader=this.fragmentShader;const t={};for(const e in this.extensions)!0===this.extensions[e]&&(t[e]=!0);return Object.keys(t).length>0&&(data.extensions=t),data}}Dn.prototype.isShaderMaterial=!0;class Nn extends Ae{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new ne,this.projectionMatrix=new ne,this.projectionMatrixInverse=new ne}copy(source,t){return super.copy(source,t),this.matrixWorldInverse.copy(source.matrixWorldInverse),this.projectionMatrix.copy(source.projectionMatrix),this.projectionMatrixInverse.copy(source.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}Nn.prototype.isCamera=!0;class zn extends Nn{constructor(t=50,e=1,n=.1,r=2e3){super(),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(source,t){return super.copy(source,t),this.fov=source.fov,this.zoom=source.zoom,this.near=source.near,this.far=source.far,this.focus=source.focus,this.aspect=source.aspect,this.view=null===source.view?null:Object.assign({},source.view),this.filmGauge=source.filmGauge,this.filmOffset=source.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*et*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*tt*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*et*Math.atan(Math.tan(.5*tt*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,n,r,o,l){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=o,this.view.height=l,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*tt*this.fov)/this.zoom,n=2*e,r=this.aspect*n,o=-.5*r;const view=this.view;if(null!==this.view&&this.view.enabled){const t=view.fullWidth,l=view.fullHeight;o+=view.offsetX*r/t,e-=view.offsetY*n/l,r*=view.width/t,n*=view.height/l}const l=this.filmOffset;0!==l&&(o+=t*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+r,e,e-n,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(meta){const data=super.toJSON(meta);return data.object.fov=this.fov,data.object.zoom=this.zoom,data.object.near=this.near,data.object.far=this.far,data.object.focus=this.focus,data.object.aspect=this.aspect,null!==this.view&&(data.object.view=Object.assign({},this.view)),data.object.filmGauge=this.filmGauge,data.object.filmOffset=this.filmOffset,data}}zn.prototype.isPerspectiveCamera=!0;const On=90;class Bn extends Ae{constructor(t,e,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const r=new zn(On,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Tt(1,0,0)),this.add(r);const o=new zn(On,1,t,e);o.layers=this.layers,o.up.set(0,-1,0),o.lookAt(new Tt(-1,0,0)),this.add(o);const l=new zn(On,1,t,e);l.layers=this.layers,l.up.set(0,0,1),l.lookAt(new Tt(0,1,0)),this.add(l);const c=new zn(On,1,t,e);c.layers=this.layers,c.up.set(0,0,-1),c.lookAt(new Tt(0,-1,0)),this.add(c);const h=new zn(On,1,t,e);h.layers=this.layers,h.up.set(0,-1,0),h.lookAt(new Tt(0,0,1)),this.add(h);const d=new zn(On,1,t,e);d.layers=this.layers,d.up.set(0,-1,0),d.lookAt(new Tt(0,0,-1)),this.add(d)}update(t,e){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[r,o,l,c,h,d]=this.children,f=t.xr.enabled,m=t.getRenderTarget();t.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,r),t.setRenderTarget(n,1),t.render(e,o),t.setRenderTarget(n,2),t.render(e,l),t.setRenderTarget(n,3),t.render(e,c),t.setRenderTarget(n,4),t.render(e,h),n.texture.generateMipmaps=v,t.setRenderTarget(n,5),t.render(e,d),t.setRenderTarget(m),t.xr.enabled=f}}class Fn extends yt{constructor(t,e,n,r,o,c,h,d,f,m){super(t=void 0!==t?t:[],e=void 0!==e?e:l,n,r,o,c,h,d,f,m),this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}Fn.prototype.isCubeTexture=!0;class Un extends Mt{constructor(t,e,n){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=n),super(t,t,e),e=e||{},this.texture=new Fn(void 0,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:S,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.format=D,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.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"},r=new Cn(5,5,5),o=new Dn({name:"CubemapFromEquirect",uniforms:Rn(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});o.uniforms.tEquirect.value=e;const l=new An(r,o),c=e.minFilter;e.minFilter===T&&(e.minFilter=S);return new Bn(1,10,this).update(t,l),e.minFilter=c,l.geometry.dispose(),l.material.dispose(),this}clear(t,e,n,r){const o=t.getRenderTarget();for(let i=0;i<6;i++)t.setRenderTarget(this,i),t.clear(e,n,r);t.setRenderTarget(o)}}Un.prototype.isWebGLCubeRenderTarget=!0;const Hn=new Tt,kn=new Tt,Vn=new pt;class Gn{constructor(t=new Tt(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(a,b,t){const e=Hn.subVectors(t,b).cross(kn.subVectors(a,b)).normalize();return this.setFromNormalAndCoplanarPoint(e,a),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(line,t){const e=line.delta(Hn),n=this.normal.dot(e);if(0===n)return 0===this.distanceToPoint(line.start)?t.copy(line.start):null;const r=-(line.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(e).multiplyScalar(r).add(line.start)}intersectsLine(line){const t=this.distanceToPoint(line.start),e=this.distanceToPoint(line.end);return t<0&&e>0||e<0&&t>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Vn.getNormalMatrix(t),r=this.coplanarPoint(Hn).applyMatrix4(t),o=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(o),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}Gn.prototype.isPlane=!0;const Wn=new Xt,jn=new Tt;class qn{constructor(t=new Gn,e=new Gn,n=new Gn,r=new Gn,o=new Gn,l=new Gn){this.planes=[t,e,n,r,o,l]}set(t,e,n,r,o,l){const c=this.planes;return c[0].copy(t),c[1].copy(e),c[2].copy(n),c[3].copy(r),c[4].copy(o),c[5].copy(l),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t){const e=this.planes,n=t.elements,r=n[0],o=n[1],l=n[2],c=n[3],h=n[4],d=n[5],f=n[6],m=n[7],v=n[8],x=n[9],y=n[10],_=n[11],M=n[12],w=n[13],S=n[14],T=n[15];return e[0].setComponents(c-r,m-h,_-v,T-M).normalize(),e[1].setComponents(c+r,m+h,_+v,T+M).normalize(),e[2].setComponents(c+o,m+d,_+x,T+w).normalize(),e[3].setComponents(c-o,m-d,_-x,T-w).normalize(),e[4].setComponents(c-l,m-f,_-y,T-S).normalize(),e[5].setComponents(c+l,m+f,_+y,T+S).normalize(),this}intersectsObject(object){const t=object.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Wn.copy(t.boundingSphere).applyMatrix4(object.matrixWorld),this.intersectsSphere(Wn)}intersectsSprite(t){return Wn.center.set(0,0,0),Wn.radius=.7071067811865476,Wn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Wn)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let i=0;i<6;i++){if(e[i].distanceToPoint(n)0?t.max.x:t.min.x,jn.y=n.normal.y>0?t.max.y:t.min.y,jn.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(jn)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Xn(){let t=null,e=!1,n=null,r=null;function o(time,e){n(time,e),r=t.requestAnimationFrame(o)}return{start:function(){!0!==e&&null!==n&&(r=t.requestAnimationFrame(o),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function Yn(t,e){const n=e.isWebGL2,r=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),r.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const data=r.get(e);data&&(t.deleteBuffer(data.buffer),r.delete(e))},update:function(e,o){if(e.isGLBufferAttribute){const t=r.get(e);return void((!t||t.version 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_maxMipLevel 8.0\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_maxTileSize 256.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tfloat texelSize = 1.0 / ( 3.0 * cubeUV_maxTileSize );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 1.0 ) + 0.5;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tif ( mipInt < cubeUV_maxMipLevel ) {\n\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t}\n\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\tuv.x += 3.0 * max( 0.0, cubeUV_maxTileSize - 2.0 * faceSize );\n\t\tuv *= texelSize;\n\t\treturn texture2D( envMap, uv ).rgb;\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, cubeUV_maxMipLevel );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t\tenvColor = envMapTexelToLinear( envColor );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec;\n\t\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\t\treflectVec = reflect( - viewDir, normal );\n\t\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\t#else\n\t\t\t\treflectVec = refract( - viewDir, normal, refractionRatio );\n\t\t\t#endif\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tlightMapIrradiance *= PI;\n\t#endif\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= specularColorMapTexelToLinear( texture2D( specularColorMap, vUv ) ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= sheenColorMapTexelToLinear( texture2D( sheenColorMap, vUv ) ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\tvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1, 2 ) * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform vec2 morphTargetsTextureSize;\n\t\tvec3 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset, const in int stride ) {\n\t\t\tfloat texelIndex = float( vertexIndex * stride + offset );\n\t\t\tfloat y = floor( texelIndex / morphTargetsTextureSize.x );\n\t\t\tfloat x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tvec3 morphUV = vec3( ( x + 0.5 ) / morphTargetsTextureSize.x, y / morphTargetsTextureSize.y, morphTargetIndex );\n\t\t\treturn texture( morphTargetsTexture, morphUV ).xyz;\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\t#ifndef USE_MORPHNORMALS\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 1 ) * morphTargetInfluences[ i ];\n\t\t\t#else\n\t\t\t\tif ( morphTargetInfluences[ i ] > 0.0 ) transformed += getMorph( gl_VertexID, i, 0, 2 ) * morphTargetInfluences[ i ];\n\t\t\t#endif\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( vec3 n, vec3 v, float thickness, float ior, mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( float roughness, float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( vec2 fragCoord, float roughness, float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( vec3 radiance, float transmissionDistance, vec3 attenuationColor, float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( vec3 n, vec3 v, float roughness, vec3 diffuseColor, vec3 specularColor, float specularF90,\n\t\tvec3 position, mat4 modelMatrix, mat4 viewMatrix, mat4 projMatrix, float ior, float thickness,\n\t\tvec3 attenuationColor, float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},$n={common:{diffuse:{value:new Xe(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new pt},uv2Transform:{value:new pt},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new ut(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Xe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Xe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new pt}},sprite:{diffuse:{value:new Xe(16777215)},opacity:{value:1},center:{value:new ut(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new pt}}},Qn={basic:{uniforms:Pn([$n.common,$n.specularmap,$n.envmap,$n.aomap,$n.lightmap,$n.fog]),vertexShader:Zn.meshbasic_vert,fragmentShader:Zn.meshbasic_frag},lambert:{uniforms:Pn([$n.common,$n.specularmap,$n.envmap,$n.aomap,$n.lightmap,$n.emissivemap,$n.fog,$n.lights,{emissive:{value:new Xe(0)}}]),vertexShader:Zn.meshlambert_vert,fragmentShader:Zn.meshlambert_frag},phong:{uniforms:Pn([$n.common,$n.specularmap,$n.envmap,$n.aomap,$n.lightmap,$n.emissivemap,$n.bumpmap,$n.normalmap,$n.displacementmap,$n.fog,$n.lights,{emissive:{value:new Xe(0)},specular:{value:new Xe(1118481)},shininess:{value:30}}]),vertexShader:Zn.meshphong_vert,fragmentShader:Zn.meshphong_frag},standard:{uniforms:Pn([$n.common,$n.envmap,$n.aomap,$n.lightmap,$n.emissivemap,$n.bumpmap,$n.normalmap,$n.displacementmap,$n.roughnessmap,$n.metalnessmap,$n.fog,$n.lights,{emissive:{value:new Xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Zn.meshphysical_vert,fragmentShader:Zn.meshphysical_frag},toon:{uniforms:Pn([$n.common,$n.aomap,$n.lightmap,$n.emissivemap,$n.bumpmap,$n.normalmap,$n.displacementmap,$n.gradientmap,$n.fog,$n.lights,{emissive:{value:new Xe(0)}}]),vertexShader:Zn.meshtoon_vert,fragmentShader:Zn.meshtoon_frag},matcap:{uniforms:Pn([$n.common,$n.bumpmap,$n.normalmap,$n.displacementmap,$n.fog,{matcap:{value:null}}]),vertexShader:Zn.meshmatcap_vert,fragmentShader:Zn.meshmatcap_frag},points:{uniforms:Pn([$n.points,$n.fog]),vertexShader:Zn.points_vert,fragmentShader:Zn.points_frag},dashed:{uniforms:Pn([$n.common,$n.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Zn.linedashed_vert,fragmentShader:Zn.linedashed_frag},depth:{uniforms:Pn([$n.common,$n.displacementmap]),vertexShader:Zn.depth_vert,fragmentShader:Zn.depth_frag},normal:{uniforms:Pn([$n.common,$n.bumpmap,$n.normalmap,$n.displacementmap,{opacity:{value:1}}]),vertexShader:Zn.meshnormal_vert,fragmentShader:Zn.meshnormal_frag},sprite:{uniforms:Pn([$n.sprite,$n.fog]),vertexShader:Zn.sprite_vert,fragmentShader:Zn.sprite_frag},background:{uniforms:{uvTransform:{value:new pt},t2D:{value:null}},vertexShader:Zn.background_vert,fragmentShader:Zn.background_frag},cube:{uniforms:Pn([$n.envmap,{opacity:{value:1}}]),vertexShader:Zn.cube_vert,fragmentShader:Zn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Zn.equirect_vert,fragmentShader:Zn.equirect_frag},distanceRGBA:{uniforms:Pn([$n.common,$n.displacementmap,{referencePosition:{value:new Tt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Zn.distanceRGBA_vert,fragmentShader:Zn.distanceRGBA_frag},shadow:{uniforms:Pn([$n.lights,$n.fog,{color:{value:new Xe(0)},opacity:{value:1}}]),vertexShader:Zn.shadow_vert,fragmentShader:Zn.shadow_frag}};function Kn(t,e,n,r,o){const l=new Xe(0);let c,h,d=0,m=null,v=0,x=null;function y(t,e){n.buffers.color.setClear(t.r,t.g,t.b,e,o)}return{getClearColor:function(){return l},setClearColor:function(t,e=1){l.set(t),d=e,y(l,d)},getClearAlpha:function(){return d},setClearAlpha:function(t){d=t,y(l,d)},render:function(n,o){let _=!1,M=!0===o.isScene?o.background:null;M&&M.isTexture&&(M=e.get(M));const w=t.xr,S=w.getSession&&w.getSession();S&&"additive"===S.environmentBlendMode&&(M=null),null===M?y(l,d):M&&M.isColor&&(y(M,1),_=!0),(t.autoClear||_)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),M&&(M.isCubeTexture||M.mapping===f)?(void 0===h&&(h=new An(new Cn(1,1,1),new Dn({name:"BackgroundCubeMaterial",uniforms:Rn(Qn.cube.uniforms),vertexShader:Qn.cube.vertexShader,fragmentShader:Qn.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(t,e,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(h)),h.material.uniforms.envMap.value=M,h.material.uniforms.flipEnvMap.value=M.isCubeTexture&&!1===M.isRenderTargetTexture?-1:1,m===M&&v===M.version&&x===t.toneMapping||(h.material.needsUpdate=!0,m=M,v=M.version,x=t.toneMapping),n.unshift(h,h.geometry,h.material,0,0,null)):M&&M.isTexture&&(void 0===c&&(c=new An(new Jn(2,2),new Dn({name:"BackgroundMaterial",uniforms:Rn(Qn.background.uniforms),vertexShader:Qn.background.vertexShader,fragmentShader:Qn.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(c)),c.material.uniforms.t2D.value=M,!0===M.matrixAutoUpdate&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),m===M&&v===M.version&&x===t.toneMapping||(c.material.needsUpdate=!0,m=M,v=M.version,x=t.toneMapping),n.unshift(c,c.geometry,c.material,0,0,null))}}}function ti(t,e,n,r){const o=t.getParameter(34921),l=r.isWebGL2?null:e.get("OES_vertex_array_object"),c=r.isWebGL2||null!==l,h={},d=x(null);let f=d;function m(e){return r.isWebGL2?t.bindVertexArray(e):l.bindVertexArrayOES(e)}function v(e){return r.isWebGL2?t.deleteVertexArray(e):l.deleteVertexArrayOES(e)}function x(t){const e=[],n=[],r=[];for(let i=0;i=0){let o=h[e];if(void 0===o&&("instanceMatrix"===e&&object.instanceMatrix&&(o=object.instanceMatrix),"instanceColor"===e&&object.instanceColor&&(o=object.instanceColor)),void 0!==o){const e=o.normalized,l=o.itemSize,h=n.get(o);if(void 0===h)continue;const d=h.buffer,f=h.type,m=h.bytesPerElement;if(o.isInterleavedBufferAttribute){const data=o.data,n=data.stride,h=o.offset;if(data&&data.isInstancedInterleavedBuffer){for(let i=0;i0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const l="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;let c=void 0!==n.precision?n.precision:"highp";const h=o(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const d=l||e.has("WEBGL_draw_buffers"),f=!0===n.logarithmicDepthBuffer,m=t.getParameter(34930),v=t.getParameter(35660),x=t.getParameter(3379),y=t.getParameter(34076),_=t.getParameter(34921),M=t.getParameter(36347),w=t.getParameter(36348),S=t.getParameter(36349),T=v>0,E=l||e.has("OES_texture_float");return{isWebGL2:l,drawBuffers:d,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:o,precision:c,logarithmicDepthBuffer:f,maxTextures:m,maxVertexTextures:v,maxTextureSize:x,maxCubemapSize:y,maxAttributes:_,maxVertexUniforms:M,maxVaryings:w,maxFragmentUniforms:S,vertexTextures:T,floatFragmentTextures:E,floatVertexTextures:T&&E,maxSamples:l?t.getParameter(36183):0}}function ii(t){const e=this;let n=null,r=0,o=!1,l=!1;const c=new Gn,h=new pt,d={value:null,needsUpdate:!1};function f(){d.value!==n&&(d.value=n,d.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function m(t,n,r,o){const l=null!==t?t.length:0;let f=null;if(0!==l){if(f=d.value,!0!==o||null===f){const e=r+4*l,o=n.matrixWorldInverse;h.getNormalMatrix(o),(null===f||f.length0){const l=t.getRenderTarget(),c=new Un(image.height/2);return c.fromEquirectangularTexture(t,o),e.set(o,c),t.setRenderTarget(l),o.addEventListener("dispose",r),n(c.texture,o.mapping)}return null}}}return o},dispose:function(){e=new WeakMap}}}Qn.physical={uniforms:Pn([Qn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new ut(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new Xe(0)},sheenColorMap:{value:null},sheenRoughness:{value:0},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new ut},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Xe(0)},specularIntensity:{value:0},specularIntensityMap:{value:null},specularColor:{value:new Xe(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Zn.meshphysical_vert,fragmentShader:Zn.meshphysical_frag};class si extends Nn{constructor(t=-1,e=1,n=1,r=-1,o=.1,l=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=r,this.near=o,this.far=l,this.updateProjectionMatrix()}copy(source,t){return super.copy(source,t),this.left=source.left,this.right=source.right,this.top=source.top,this.bottom=source.bottom,this.near=source.near,this.far=source.far,this.zoom=source.zoom,this.view=null===source.view?null:Object.assign({},source.view),this}setViewOffset(t,e,n,r,o,l){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=o,this.view.height=l,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let o=n-t,l=n+t,c=r+e,h=r-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=t*this.view.offsetX,l=o+t*this.view.width,c-=e*this.view.offsetY,h=c-e*this.view.height}this.projectionMatrix.makeOrthographic(o,l,c,h,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(meta){const data=super.toJSON(meta);return data.object.zoom=this.zoom,data.object.left=this.left,data.object.right=this.right,data.object.top=this.top,data.object.bottom=this.bottom,data.object.near=this.near,data.object.far=this.far,null!==this.view&&(data.object.view=Object.assign({},this.view)),data}}si.prototype.isOrthographicCamera=!0;class ai extends Dn{constructor(t){super(t),this.type="RawShaderMaterial"}}ai.prototype.isRawShaderMaterial=!0;const oi=Math.pow(2,8),ci=[.125,.215,.35,.446,.526,.582],hi=5+ci.length,ui=20,di={[G]:0,[W]:1},pi=new si,{_lodPlanes:fi,_sizeLods:mi,_sigmas:gi}=wi(),vi=new Xe;let xi=null;const yi=(1+Math.sqrt(5))/2,_i=1/yi,bi=[new Tt(1,1,1),new Tt(-1,1,1),new Tt(1,1,-1),new Tt(-1,1,-1),new Tt(0,yi,_i),new Tt(0,yi,-_i),new Tt(_i,0,yi),new Tt(-_i,0,yi),new Tt(yi,_i,0),new Tt(-yi,_i,0)];class Mi{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._blurMaterial=function(t){const e=new Float32Array(t),n=new Tt(0,1,0);return new ai({name:"SphericalGaussianBlur",defines:{n:t},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:n}},vertexShader:Li(),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${Ci()}\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:0,depthTest:!1,depthWrite:!1})}(ui),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,r=100){xi=this._renderer.getRenderTarget();const o=this._allocateTargets();return this._sceneToCubeUV(t,n,r,o),e>0&&this._blur(o,0,0,e),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(t){return this._fromTexture(t)}fromCubemap(t){return this._fromTexture(t)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=Ai(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=Ei(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let i=0;i2?oi:0,oi,oi),h.setRenderTarget(r),x&&h.render(v,o),h.render(t,o)}v.geometry.dispose(),v.material.dispose(),h.toneMapping=f,h.autoClear=d,t.background=y}_setEncoding(t,e){!0===this._renderer.capabilities.isWebGL2&&e.format===D&&e.type===E&&e.encoding===W?t.value=di[3e3]:t.value=di[e.encoding]}_textureToCubeUV(t,e){const n=this._renderer,r=t.mapping===l||t.mapping===c;r?null==this._cubemapShader&&(this._cubemapShader=Ai()):null==this._equirectShader&&(this._equirectShader=Ei());const o=r?this._cubemapShader:this._equirectShader,h=new An(fi[0],o),d=o.uniforms;d.envMap.value=t,r||d.texelSize.value.set(1/t.image.width,1/t.image.height),this._setEncoding(d.inputEncoding,t),Ti(e,0,0,3*oi,2*oi),n.setRenderTarget(e),n.render(h,pi)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;for(let i=1;iui&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${_} samples when the maximum is set to 20`);const M=[];let w=0;for(let i=0;i4?r-8+4:0),3*S,2*S),h.setRenderTarget(e),h.render(f,pi)}}function wi(){const t=[],e=[],n=[];let r=8;for(let i=0;i4?l=ci[i-8+4-1]:0==i&&(l=0),n.push(l);const c=1/(o-1),h=-c/2,d=1+c/2,f=[h,h,d,h,d,d,h,h,d,d,h,d],m=6,v=6,x=3,y=2,_=1,M=new Float32Array(x*v*m),w=new Float32Array(y*v*m),S=new Float32Array(_*v*m);for(let t=0;t2?0:-1,r=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];M.set(r,x*v*t),w.set(f,y*v*t);const o=[t,t,t,t,t,t];S.set(o,_*v*t)}const T=new cn;T.setAttribute("position",new $e(M,x)),T.setAttribute("uv",new $e(w,y)),T.setAttribute("faceIndex",new $e(S,_)),t.push(T),r>4&&r--}return{_lodPlanes:t,_sizeLods:e,_sigmas:n}}function Si(t){const e=new Mt(3*oi,3*oi,t);return e.texture.mapping=f,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Ti(t,e,n,r,o){t.viewport.set(e,n,r,o),t.scissor.set(e,n,r,o)}function Ei(){const t=new ut(1,1);return new ai({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:t},inputEncoding:{value:di[3e3]}},vertexShader:Li(),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 vec2 texelSize;\n\n\t\t\t${Ci()}\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tvec2 f = fract( uv / texelSize - 0.5 );\n\t\t\t\tuv -= f * texelSize;\n\t\t\t\tvec3 tl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x += texelSize.x;\n\t\t\t\tvec3 tr = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.y += texelSize.y;\n\t\t\t\tvec3 br = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\t\t\t\tuv.x -= texelSize.x;\n\t\t\t\tvec3 bl = envMapTexelToLinear( texture2D ( envMap, uv ) ).rgb;\n\n\t\t\t\tvec3 tm = mix( tl, tr, f.x );\n\t\t\t\tvec3 bm = mix( bl, br, f.x );\n\t\t\t\tgl_FragColor.rgb = mix( tm, bm, f.y );\n\n\t\t\t}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1})}function Ai(){return new ai({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:di[3e3]}},vertexShader:Li(),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 samplerCube envMap;\n\n\t\t\t${Ci()}\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = envMapTexelToLinear( textureCube( envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ) ) );\n\n\t\t\t}\n\t\t`,blending:0,depthTest:!1,depthWrite:!1})}function Li(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\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"}function Ci(){return"\n\n\t\tuniform int inputEncoding;\n\n\t\t#include \n\n\t\tvec4 inputTexelToLinear( vec4 value ) {\n\n\t\t\tif ( inputEncoding == 0 ) {\n\n\t\t\t\treturn value;\n\n\t\t\t} else {\n\n\t\t\t\treturn sRGBToLinear( value );\n\n\t\t\t}\n\n\t\t}\n\n\t\tvec4 envMapTexelToLinear( vec4 color ) {\n\n\t\t\treturn inputTexelToLinear( color );\n\n\t\t}\n\t"}function Ri(t){let e=new WeakMap,n=null;function r(t){const n=t.target;n.removeEventListener("dispose",r);const o=e.get(n);void 0!==o&&(e.delete(n),o.dispose())}return{get:function(o){if(o&&o.isTexture&&!1===o.isRenderTargetTexture){const f=o.mapping,m=f===h||f===d,v=f===l||f===c;if(m||v){if(e.has(o))return e.get(o).texture;{const image=o.image;if(m&&image&&image.height>0||v&&image&&function(image){let t=0;const e=6;for(let i=0;i65535?Ke:Qe)(n,1);h.version=c;const d=l.get(t);d&&e.remove(d),l.set(t,h)}return{get:function(object,t){return!0===o[t.id]||(t.addEventListener("dispose",c),o[t.id]=!0,n.memory.geometries++),t},update:function(t){const n=t.attributes;for(const t in n)e.update(n[t],34962);const r=t.morphAttributes;for(const t in r){const n=r[t];for(let i=0,t=n.length;ie.maxTextureSize&&(v=Math.ceil(m/e.maxTextureSize),m=e.maxTextureSize);const x=new Float32Array(m*v*4*r),y=new zi(x,m,v,r);y.format=D,y.type=C,y.needsUpdate=!0;const _=4*f;for(let i=0;i0)return t;const o=e*n;let l=qi[o];if(void 0===l&&(l=new Float32Array(o),qi[o]=l),0!==e){r.toArray(l,0);for(let i=1,r=0;i!==e;++i)r+=n,t[i].toArray(l,r)}return l}function Qi(a,b){if(a.length!==b.length)return!1;for(let i=0,t=a.length;i/gm;function as(t){return t.replace(ss,os)}function os(t,e){const n=Zn[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return as(n)}const ls=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,cs=/#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 hs(t){return t.replace(cs,ds).replace(ls,us)}function us(t,e,n,r){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),ds(t,e,n,r)}function ds(t,e,n,r){let o="";for(let i=parseInt(e);i0&&(E+="\n"),A=[w,S].filter(ns).join("\n"),A.length>0&&(A+="\n")):(E=[ps(n),"#define SHADER_NAME "+n.shaderName,S,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define MAX_BONES "+n.maxBones,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 "+_:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargets&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+x:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","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","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ns).join("\n"),A=[w,ps(n),"#define SHADER_NAME "+n.shaderName,S,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+y:"",n.envMap?"#define "+_:"",n.envMap?"#define "+M:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",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 "+x:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?Zn.tonemapping_pars_fragment:"",0!==n.toneMapping?es("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.format===I?"#define OPAQUE":"",Zn.encodings_pars_fragment,n.map?Kr("mapTexelToLinear",n.mapEncoding):"",n.matcap?Kr("matcapTexelToLinear",n.matcapEncoding):"",n.envMap?Kr("envMapTexelToLinear",n.envMapEncoding):"",n.emissiveMap?Kr("emissiveMapTexelToLinear",n.emissiveMapEncoding):"",n.specularColorMap?Kr("specularColorMapTexelToLinear",n.specularColorMapEncoding):"",n.sheenColorMap?Kr("sheenColorMapTexelToLinear",n.sheenColorMapEncoding):"",n.lightMap?Kr("lightMapTexelToLinear",n.lightMapEncoding):"",ts("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(ns).join("\n")),d=as(d),d=is(d,n),d=rs(d,n),v=as(v),v=is(v,n),v=rs(v,n),d=hs(d),v=hs(v),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(L="#version 300 es\n",E=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+E,A=["#define varying in",n.glslVersion===Z?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Z?"":"#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"+A);const C=L+A+v,R=Jr(o,35633,L+E+d),P=Jr(o,35632,C);if(o.attachShader(T,R),o.attachShader(T,P),void 0!==n.index0AttributeName?o.bindAttribLocation(T,0,n.index0AttributeName):!0===n.morphTargets&&o.bindAttribLocation(T,0,"position"),o.linkProgram(T),t.debug.checkShaderErrors){const t=o.getProgramInfoLog(T).trim(),e=o.getShaderInfoLog(R).trim(),n=o.getShaderInfoLog(P).trim();let r=!0,l=!0;if(!1===o.getProgramParameter(T,35714)){r=!1;const e=Qr(o,R,"vertex"),n=Qr(o,P,"fragment");console.error("THREE.WebGLProgram: Shader Error "+o.getError()+" - VALIDATE_STATUS "+o.getProgramParameter(T,35715)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==e&&""!==n||(l=!1);l&&(this.diagnostics={runnable:r,programLog:t,vertexShader:{log:e,prefix:E},fragmentShader:{log:n,prefix:A}})}let D,N;return o.deleteShader(R),o.deleteShader(P),this.getUniforms=function(){return void 0===D&&(D=new Yr(o,T)),D},this.getAttributes=function(){return void 0===N&&(N=function(t,e){const n={},r=t.getProgramParameter(e,35721);for(let i=0;i0,U=l.clearcoat>0;return{isWebGL2:x,shaderID:P,shaderName:l.type,vertexShader:D,fragmentShader:N,defines:l.defines,customVertexShaderID:z,customFragmentShaderID:O,isRawShaderMaterial:!0===l.isRawShaderMaterial,glslVersion:l.glslVersion,precision:S,instancing:!0===object.isInstancedMesh,instancingColor:!0===object.isInstancedMesh&&null!==object.instanceColor,supportsVertexTextures:w,outputEncoding:null!==B?A(B.texture):t.outputEncoding,map:!!l.map,mapEncoding:A(l.map),matcap:!!l.matcap,matcapEncoding:A(l.matcap),envMap:!!R,envMapMode:R&&R.mapping,envMapEncoding:A(R),envMapCubeUV:!!R&&(R.mapping===f||R.mapping===m),lightMap:!!l.lightMap,lightMapEncoding:A(l.lightMap),aoMap:!!l.aoMap,emissiveMap:!!l.emissiveMap,emissiveMapEncoding:A(l.emissiveMap),bumpMap:!!l.bumpMap,normalMap:!!l.normalMap,objectSpaceNormalMap:1===l.normalMapType,tangentSpaceNormalMap:0===l.normalMapType,clearcoat:U,clearcoatMap:U&&!!l.clearcoatMap,clearcoatRoughnessMap:U&&!!l.clearcoatRoughnessMap,clearcoatNormalMap:U&&!!l.clearcoatNormalMap,displacementMap:!!l.displacementMap,roughnessMap:!!l.roughnessMap,metalnessMap:!!l.metalnessMap,specularMap:!!l.specularMap,specularIntensityMap:!!l.specularIntensityMap,specularColorMap:!!l.specularColorMap,specularColorMapEncoding:A(l.specularColorMap),alphaMap:!!l.alphaMap,alphaTest:F,gradientMap:!!l.gradientMap,sheen:l.sheen>0,sheenColorMap:!!l.sheenColorMap,sheenColorMapEncoding:A(l.sheenColorMap),sheenRoughnessMap:!!l.sheenRoughnessMap,transmission:l.transmission>0,transmissionMap:!!l.transmissionMap,thicknessMap:!!l.thicknessMap,combine:l.combine,vertexTangents:!!l.normalMap&&!!object.geometry&&!!object.geometry.attributes.tangent,vertexColors:l.vertexColors,vertexAlphas:!0===l.vertexColors&&!!object.geometry&&!!object.geometry.attributes.color&&4===object.geometry.attributes.color.itemSize,vertexUvs:!!(l.map||l.bumpMap||l.normalMap||l.specularMap||l.alphaMap||l.emissiveMap||l.roughnessMap||l.metalnessMap||l.clearcoatMap||l.clearcoatRoughnessMap||l.clearcoatNormalMap||l.displacementMap||l.transmissionMap||l.thicknessMap||l.specularIntensityMap||l.specularColorMap||l.sheenColorMap||l.sheenRoughnessMap),uvsVertexOnly:!(l.map||l.bumpMap||l.normalMap||l.specularMap||l.alphaMap||l.emissiveMap||l.roughnessMap||l.metalnessMap||l.clearcoatNormalMap||l.transmission>0||l.transmissionMap||l.thicknessMap||l.specularIntensityMap||l.specularColorMap||l.sheen>0||l.sheenColorMap||l.sheenRoughnessMap||!l.displacementMap),fog:!!L,useFog:l.fog,fogExp2:L&&L.isFogExp2,flatShading:!!l.flatShading,sizeAttenuation:l.sizeAttenuation,logarithmicDepthBuffer:y,skinning:!0===object.isSkinnedMesh&&I>0,maxBones:I,useVertexTexture:_,morphTargets:!!object.geometry&&!!object.geometry.morphAttributes.position,morphNormals:!!object.geometry&&!!object.geometry.morphAttributes.normal,morphTargetsCount:object.geometry&&object.geometry.morphAttributes.position?object.geometry.morphAttributes.position.length:0,numDirLights:h.directional.length,numPointLights:h.point.length,numSpotLights:h.spot.length,numRectAreaLights:h.rectArea.length,numHemiLights:h.hemi.length,numDirLightShadows:h.directionalShadowMap.length,numPointLightShadows:h.pointShadowMap.length,numSpotLightShadows:h.spotShadowMap.length,numClippingPlanes:c.numPlanes,numClipIntersection:c.numIntersection,format:l.format,dithering:l.dithering,shadowMapEnabled:t.shadowMap.enabled&&v.length>0,shadowMapType:t.shadowMap.type,toneMapping:l.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:l.premultipliedAlpha,doubleSided:2===l.side,flipSided:1===l.side,depthPacking:void 0!==l.depthPacking&&l.depthPacking,index0AttributeName:l.index0AttributeName,extensionDerivatives:l.extensions&&l.extensions.derivatives,extensionFragDepth:l.extensions&&l.extensions.fragDepth,extensionDrawBuffers:l.extensions&&l.extensions.drawBuffers,extensionShaderTextureLOD:l.extensions&&l.extensions.shaderTextureLOD,rendererExtensionFragDepth:x||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:x||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:x||r.has("EXT_shader_texture_lod"),customProgramCacheKey:l.customProgramCacheKey()}},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputEncoding),t.push(e.mapEncoding),t.push(e.matcapEncoding),t.push(e.envMapMode),t.push(e.envMapEncoding),t.push(e.lightMapEncoding),t.push(e.emissiveMapEncoding),t.push(e.combine),t.push(e.vertexUvs),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.maxBones),t.push(e.morphTargetsCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.format),t.push(e.specularColorMapEncoding),t.push(e.sheenColorMapEncoding)}(n,e),function(t,e){h.disableAll(),e.isWebGL2&&h.enable(0);e.supportsVertexTextures&&h.enable(1);e.instancing&&h.enable(2);e.instancingColor&&h.enable(3);e.map&&h.enable(4);e.matcap&&h.enable(5);e.envMap&&h.enable(6);e.envMapCubeUV&&h.enable(7);e.lightMap&&h.enable(8);e.aoMap&&h.enable(9);e.emissiveMap&&h.enable(10);e.bumpMap&&h.enable(11);e.normalMap&&h.enable(12);e.objectSpaceNormalMap&&h.enable(13);e.tangentSpaceNormalMap&&h.enable(14);e.clearcoat&&h.enable(15);e.clearcoatMap&&h.enable(16);e.clearcoatRoughnessMap&&h.enable(17);e.clearcoatNormalMap&&h.enable(18);e.displacementMap&&h.enable(19);e.specularMap&&h.enable(20);e.roughnessMap&&h.enable(21);e.metalnessMap&&h.enable(22);e.gradientMap&&h.enable(23);e.alphaMap&&h.enable(24);e.alphaTest&&h.enable(25);e.vertexColors&&h.enable(26);e.vertexAlphas&&h.enable(27);e.vertexUvs&&h.enable(28);e.vertexTangents&&h.enable(29);e.uvsVertexOnly&&h.enable(30);e.fog&&h.enable(31);t.push(h.mask),h.disableAll(),e.useFog&&h.enable(0);e.flatShading&&h.enable(1);e.logarithmicDepthBuffer&&h.enable(2);e.skinning&&h.enable(3);e.useVertexTexture&&h.enable(4);e.morphTargets&&h.enable(5);e.morphNormals&&h.enable(6);e.premultipliedAlpha&&h.enable(7);e.shadowMapEnabled&&h.enable(8);e.physicallyCorrectLights&&h.enable(9);e.doubleSided&&h.enable(10);e.flipSided&&h.enable(11);e.depthPacking&&h.enable(12);e.dithering&&h.enable(13);e.specularIntensityMap&&h.enable(14);e.specularColorMap&&h.enable(15);e.transmission&&h.enable(16);e.transmissionMap&&h.enable(17);e.thicknessMap&&h.enable(18);e.sheen&&h.enable(19);e.sheenColorMap&&h.enable(20);e.sheenRoughnessMap&&h.enable(21);t.push(h.mask)}(n,e),n.push(t.outputEncoding)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=T[t.type];let n;if(e){const t=Qn[e];n=In.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let r;for(let p=0,t=v.length;p0?r.push(f):!0===e.transparent?o.push(f):n.push(f)},unshift:function(object,t,e,c,h,d){const f=l(object,t,e,c,h,d);e.transmission>0?r.unshift(f):!0===e.transparent?o.unshift(f):n.unshift(f)},finish:function(){for(let i=e,n=t.length;i1&&n.sort(t||_s),r.length>1&&r.sort(e||bs),o.length>1&&o.sort(e||bs)}}}function ws(){let t=new WeakMap;return{get:function(e,n){let r;return!1===t.has(e)?(r=new Ms,t.set(e,[r])):n>=t.get(e).length?(r=new Ms,t.get(e).push(r)):r=t.get(e)[n],r},dispose:function(){t=new WeakMap}}}function Ss(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Tt,color:new Xe};break;case"SpotLight":n={position:new Tt,direction:new Tt,color:new Xe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Tt,color:new Xe,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Tt,skyColor:new Xe,groundColor:new Xe};break;case"RectAreaLight":n={color:new Xe,position:new Tt,halfWidth:new Tt,halfHeight:new Tt}}return t[e.id]=n,n}}}let Ts=0;function Es(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function As(t,e){const n=new Ss,r=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ut};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ut,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),o={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let i=0;i<9;i++)o.probe.push(new Tt);const l=new Tt,c=new ne,h=new ne;return{setup:function(l,c){let h=0,g=0,b=0;for(let i=0;i<9;i++)o.probe[i].set(0,0,0);let d=0,f=0,m=0,v=0,x=0,y=0,_=0,M=0;l.sort(Es);const w=!0!==c?Math.PI:1;for(let i=0,t=l.length;i0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(o.rectAreaLTC1=$n.LTC_FLOAT_1,o.rectAreaLTC2=$n.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(o.rectAreaLTC1=$n.LTC_HALF_1,o.rectAreaLTC2=$n.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),o.ambient[0]=h,o.ambient[1]=g,o.ambient[2]=b;const S=o.hash;S.directionalLength===d&&S.pointLength===f&&S.spotLength===m&&S.rectAreaLength===v&&S.hemiLength===x&&S.numDirectionalShadows===y&&S.numPointShadows===_&&S.numSpotShadows===M||(o.directional.length=d,o.spot.length=m,o.rectArea.length=v,o.point.length=f,o.hemi.length=x,o.directionalShadow.length=y,o.directionalShadowMap.length=y,o.pointShadow.length=_,o.pointShadowMap.length=_,o.spotShadow.length=M,o.spotShadowMap.length=M,o.directionalShadowMatrix.length=y,o.pointShadowMatrix.length=_,o.spotShadowMatrix.length=M,S.directionalLength=d,S.pointLength=f,S.spotLength=m,S.rectAreaLength=v,S.hemiLength=x,S.numDirectionalShadows=y,S.numPointShadows=_,S.numSpotShadows=M,o.version=Ts++)},setupView:function(t,e){let n=0,r=0,d=0,f=0,m=0;const v=e.matrixWorldInverse;for(let i=0,e=t.length;i=n.get(r).length?(l=new Ls(t,e),n.get(r).push(l)):l=n.get(r)[o],l},dispose:function(){n=new WeakMap}}}class Rs extends He{constructor(t){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}copy(source){return super.copy(source),this.depthPacking=source.depthPacking,this.map=source.map,this.alphaMap=source.alphaMap,this.displacementMap=source.displacementMap,this.displacementScale=source.displacementScale,this.displacementBias=source.displacementBias,this.wireframe=source.wireframe,this.wireframeLinewidth=source.wireframeLinewidth,this}}Rs.prototype.isMeshDepthMaterial=!0;class Ps extends He{constructor(t){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Tt,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}copy(source){return super.copy(source),this.referencePosition.copy(source.referencePosition),this.nearDistance=source.nearDistance,this.farDistance=source.farDistance,this.map=source.map,this.alphaMap=source.alphaMap,this.displacementMap=source.displacementMap,this.displacementScale=source.displacementScale,this.displacementBias=source.displacementBias,this}}Ps.prototype.isMeshDistanceMaterial=!0;function Is(t,e,n){let r=new qn;const o=new ut,l=new ut,c=new bt,h=new Rs({depthPacking:j}),d=new Ps,f={},m=n.maxTextureSize,v={0:1,1:0,2:2},x=new Dn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ut},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \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 = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\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 = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\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( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),y=x.clone();y.defines.HORIZONTAL_PASS=1;const M=new cn;M.setAttribute("position",new $e(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const w=new An(M,x),T=this;function E(shadow,n){const r=e.update(w);x.defines.VSM_SAMPLES!==shadow.blurSamples&&(x.defines.VSM_SAMPLES=shadow.blurSamples,y.defines.VSM_SAMPLES=shadow.blurSamples,x.needsUpdate=!0,y.needsUpdate=!0),x.uniforms.shadow_pass.value=shadow.map.texture,x.uniforms.resolution.value=shadow.mapSize,x.uniforms.radius.value=shadow.radius,t.setRenderTarget(shadow.mapPass),t.clear(),t.renderBufferDirect(n,null,r,x,w,null),y.uniforms.shadow_pass.value=shadow.mapPass.texture,y.uniforms.resolution.value=shadow.mapSize,y.uniforms.radius.value=shadow.radius,t.setRenderTarget(shadow.map),t.clear(),t.renderBufferDirect(n,null,r,y,w,null)}function A(object,e,n,r,o,l,c){let m=null;const x=!0===r.isPointLight?object.customDistanceMaterial:object.customDepthMaterial;if(m=void 0!==x?x:!0===r.isPointLight?d:h,t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const t=m.uuid,e=n.uuid;let r=f[t];void 0===r&&(r={},f[t]=r);let o=r[e];void 0===o&&(o=m.clone(),r[e]=o),m=o}return m.visible=n.visible,m.wireframe=n.wireframe,m.side=3===c?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:v[n.side],m.alphaMap=n.alphaMap,m.alphaTest=n.alphaTest,m.clipShadows=n.clipShadows,m.clippingPlanes=n.clippingPlanes,m.clipIntersection=n.clipIntersection,m.displacementMap=n.displacementMap,m.displacementScale=n.displacementScale,m.displacementBias=n.displacementBias,m.wireframeLinewidth=n.wireframeLinewidth,m.linewidth=n.linewidth,!0===r.isPointLight&&!0===m.isMeshDistanceMaterial&&(m.referencePosition.setFromMatrixPosition(r.matrixWorld),m.nearDistance=o,m.farDistance=l),m}function L(object,n,o,l,c){if(!1===object.visible)return;if(object.layers.test(n.layers)&&(object.isMesh||object.isLine||object.isPoints)&&(object.castShadow||object.receiveShadow&&3===c)&&(!object.frustumCulled||r.intersectsObject(object))){object.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,object.matrixWorld);const n=e.update(object),r=object.material;if(Array.isArray(r)){const e=n.groups;for(let h=0,d=e.length;hm||o.y>m)&&(o.x>m&&(l.x=Math.floor(m/f.x),o.x=l.x*f.x,shadow.mapSize.x=l.x),o.y>m&&(l.y=Math.floor(m/f.y),o.y=l.y*f.y,shadow.mapSize.y=l.y)),null===shadow.map&&!shadow.isPointLightShadow&&3===this.type){const t={minFilter:S,magFilter:S,format:D};shadow.map=new Mt(o.x,o.y,t),shadow.map.texture.name=d.name+".shadowMap",shadow.mapPass=new Mt(o.x,o.y,t),shadow.camera.updateProjectionMatrix()}if(null===shadow.map){const t={minFilter:_,magFilter:_,format:D};shadow.map=new Mt(o.x,o.y,t),shadow.map.texture.name=d.name+".shadowMap",shadow.camera.updateProjectionMatrix()}t.setRenderTarget(shadow.map),t.clear();const v=shadow.getViewportCount();for(let t=0;t=1):-1!==z.indexOf("OpenGL ES")&&(N=parseFloat(/^OpenGL ES (\d)/.exec(z)[1]),D=N>=2);let O=null,B={};const F=t.getParameter(3088),U=t.getParameter(2978),H=(new bt).fromArray(F),k=(new bt).fromArray(U);function V(e,n,r){const data=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let i=0;in||image.height>n)&&(r=n/Math.max(image.width,image.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&image instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&image instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&image instanceof ImageBitmap){const n=t?ct:Math.floor,o=n(r*image.width),l=n(r*image.height);void 0===F&&(F=H(o,l));const canvas=e?H(o,l):F;canvas.width=o,canvas.height=l;return canvas.getContext("2d").drawImage(image,0,0,o,l),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+image.width+"x"+image.height+") to ("+o+"x"+l+")."),canvas}return"data"in image&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+image.width+"x"+image.height+")."),image}return image}function V(image){return ot(image.width)&&ot(image.height)}function G(t,e){return t.generateMipmaps&&e&&t.minFilter!==_&&t.minFilter!==S}function j(e){t.generateMipmap(e)}function X(n,r,o,l){if(!1===h)return r;if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let c=r;return 6403===r&&(5126===o&&(c=33326),5131===o&&(c=33325),5121===o&&(c=33321)),6407===r&&(5126===o&&(c=34837),5131===o&&(c=34843),5121===o&&(c=32849)),6408===r&&(5126===o&&(c=34836),5131===o&&(c=34842),5121===o&&(c=l===W?35907:32856)),33325!==c&&33326!==c&&34842!==c&&34836!==c||e.get("EXT_color_buffer_float"),c}function Y(t,image,e){return!0===G(t,e)||t.isFramebufferTexture&&t.minFilter!==_&&t.minFilter!==S?Math.log2(Math.max(image.width,image.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?image.mipmaps.length:1}function J(t){return t===_||t===M||t===w?9728:9729}function Z(e){const n=e.target;n.removeEventListener("dispose",Z),function(e){const n=r.get(e);if(void 0===n.__webglInit)return;t.deleteTexture(n.__webglTexture),r.remove(e)}(n),n.isVideoTexture&&B.delete(n),c.memory.textures--}function $(e){const n=e.target;n.removeEventListener("dispose",$),function(e){const n=e.texture,o=r.get(e),l=r.get(n);if(!e)return;void 0!==l.__webglTexture&&(t.deleteTexture(l.__webglTexture),c.memory.textures--);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let i=0;i<6;i++)t.deleteFramebuffer(o.__webglFramebuffer[i]),o.__webglDepthbuffer&&t.deleteRenderbuffer(o.__webglDepthbuffer[i]);else t.deleteFramebuffer(o.__webglFramebuffer),o.__webglDepthbuffer&&t.deleteRenderbuffer(o.__webglDepthbuffer),o.__webglMultisampledFramebuffer&&t.deleteFramebuffer(o.__webglMultisampledFramebuffer),o.__webglColorRenderbuffer&&t.deleteRenderbuffer(o.__webglColorRenderbuffer),o.__webglDepthRenderbuffer&&t.deleteRenderbuffer(o.__webglDepthRenderbuffer);if(e.isWebGLMultipleRenderTargets)for(let i=0,e=n.length;i0&&e.__version!==t.version){const image=t.image;if(void 0===image)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==image.complete)return void at(e,t,slot);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+slot),n.bindTexture(3553,e.__webglTexture)}function tt(e,slot){const o=r.get(e);e.version>0&&o.__version!==e.version?function(e,r,slot){if(6!==r.image.length)return;st(e,r),n.activeTexture(33984+slot),n.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment),t.pixelStorei(37443,0);const o=r&&(r.isCompressedTexture||r.image[0].isCompressedTexture),c=r.image[0]&&r.image[0].isDataTexture,d=[];for(let i=0;i<6;i++)d[i]=o||c?c?r.image[i].image:r.image[i]:k(r.image[i],!1,!0,f);const image=d[0],m=V(image)||h,v=l.convert(r.format),x=l.convert(r.type),y=X(r.internalFormat,v,x,r.encoding),_=h&&!0!==r.isVideoTexture,M=void 0===e.__version;let w,S=Y(r,image,m);if(it(34067,r,m),o){_&&M&&n.texStorage2D(34067,S,y,image.width,image.height);for(let i=0;i<6;i++){w=d[i].mipmaps;for(let t=0;t0&&S++,n.texStorage2D(34067,S,y,d[0].width,d[0].height));for(let i=0;i<6;i++)if(c){_?n.texSubImage2D(34069+i,0,0,0,d[i].width,d[i].height,v,x,d[i].data):n.texImage2D(34069+i,0,y,d[i].width,d[i].height,0,v,x,d[i].data);for(let t=0;t1||r.get(l).__currentAnisotropy)&&(t.texParameterf(n,c.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(l.anisotropy,o.getMaxAnisotropy())),r.get(l).__currentAnisotropy=l.anisotropy)}}function st(e,n){void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",Z),e.__webglTexture=t.createTexture(),c.memory.textures++)}function at(e,r,slot){let o=3553;r.isDataTexture2DArray&&(o=35866),r.isDataTexture3D&&(o=32879),st(e,r),n.activeTexture(33984+slot),n.bindTexture(o,e.__webglTexture),t.pixelStorei(37440,r.flipY),t.pixelStorei(37441,r.premultiplyAlpha),t.pixelStorei(3317,r.unpackAlignment),t.pixelStorei(37443,0);const c=function(t){return!h&&(t.wrapS!==x||t.wrapT!==x||t.minFilter!==_&&t.minFilter!==S)}(r)&&!1===V(r.image),image=k(r.image,c,!1,m),d=V(image)||h,f=l.convert(r.format);let v,y=l.convert(r.type),M=X(r.internalFormat,f,y,r.encoding);it(o,r,d);const w=r.mipmaps,T=h&&!0!==r.isVideoTexture,E=void 0===e.__version,R=Y(r,image,d);if(r.isDepthTexture)M=6402,h?M=r.type===C?36012:r.type===L?33190:r.type===P?35056:33189:r.type===C&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===N&&6402===M&&r.type!==A&&r.type!==L&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=A,y=l.convert(r.type)),r.format===z&&6402===M&&(M=34041,r.type!==P&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=P,y=l.convert(r.type))),T&&E?n.texStorage2D(3553,1,M,image.width,image.height):n.texImage2D(3553,0,M,image.width,image.height,0,f,y,null);else if(r.isDataTexture)if(w.length>0&&d){T&&E&&n.texStorage2D(3553,R,M,w[0].width,w[0].height);for(let i=0,t=w.length;i0&&d){T&&E&&n.texStorage2D(3553,R,M,w[0].width,w[0].height);for(let i=0,t=w.length;i=d&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+d),Q+=1,t},this.resetTextureUnits=function(){Q=0},this.setTexture2D=K,this.setTexture2DArray=function(t,slot){const e=r.get(t);t.version>0&&e.__version!==t.version?at(e,t,slot):(n.activeTexture(33984+slot),n.bindTexture(35866,e.__webglTexture))},this.setTexture3D=function(t,slot){const e=r.get(t);t.version>0&&e.__version!==t.version?at(e,t,slot):(n.activeTexture(33984+slot),n.bindTexture(32879,e.__webglTexture))},this.setTextureCube=tt,this.rebindTextures=function(t,e,n){const o=r.get(t);void 0!==e&<(o.__webglFramebuffer,t,t.texture,36064,3553),void 0!==n&&ut(t)},this.setupRenderTarget=function(e){const d=e.texture,f=r.get(e),m=r.get(d);e.addEventListener("dispose",$),!0!==e.isWebGLMultipleRenderTargets&&(void 0===m.__webglTexture&&(m.__webglTexture=t.createTexture()),m.__version=d.version,c.memory.textures++);const v=!0===e.isWebGLCubeRenderTarget,x=!0===e.isWebGLMultipleRenderTargets,y=d.isDataTexture3D||d.isDataTexture2DArray,_=V(e)||h;if(!h||d.format!==I||d.type!==C&&d.type!==R||(d.format=D,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),v){f.__webglFramebuffer=[];for(let i=0;i<6;i++)f.__webglFramebuffer[i]=t.createFramebuffer()}else if(f.__webglFramebuffer=t.createFramebuffer(),x)if(o.drawBuffers){const n=e.texture;for(let i=0,e=n.length;ih+f?(d.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!d.inputState.pinching&&c<=h-f&&(d.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==h&&t.gripSpace&&(o=e.getPose(t.gripSpace,n),null!==o&&(h.matrix.fromArray(o.transform.matrix),h.matrix.decompose(h.position,h.rotation,h.scale),o.linearVelocity?(h.hasLinearVelocity=!0,h.linearVelocity.copy(o.linearVelocity)):h.hasLinearVelocity=!1,o.angularVelocity?(h.hasAngularVelocity=!0,h.angularVelocity.copy(o.angularVelocity)):h.hasAngularVelocity=!1));return null!==c&&(c.visible=null!==r),null!==h&&(h.visible=null!==o),null!==d&&(d.visible=null!==l),this}}class Hs extends yt{constructor(t,e,n,r,o,l,c,h,d,f){if((f=void 0!==f?f:N)!==N&&f!==z)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&f===N&&(n=A),void 0===n&&f===z&&(n=P),super(null,r,o,l,c,h,f,n,d),this.image={width:t,height:e},this.magFilter=void 0!==c?c:_,this.minFilter=void 0!==h?h:_,this.flipY=!1,this.generateMipmaps=!1}}Hs.prototype.isDepthTexture=!0;class ks extends ${constructor(t,e){super();const n=this;let r=null,o=1,l=null,c="local-floor";const h=t.extensions.has("WEBGL_multisampled_render_to_texture");let d=null,f=null,m=null,v=null,x=!1,y=null;const _=e.getContextAttributes();let M=null,w=null;const S=[],T=new Map,L=new zn;L.layers.enable(1),L.viewport=new bt;const C=new zn;C.layers.enable(2),C.viewport=new bt;const R=[L,C],O=new Os;O.layers.enable(1),O.layers.enable(2);let B=null,F=null;function U(t){const e=T.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function H(){T.forEach((function(t,e){t.disconnect(e)})),T.clear(),B=null,F=null,t.setRenderTarget(M),v=null,m=null,f=null,r=null,w=null,X.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function k(t){const e=r.inputSources;for(let i=0;i0&&(e.alphaTest.value=n.alphaTest);const r=t.get(n).envMap;let o,l;r&&(e.envMap.value=r,e.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,e.reflectivity.value=n.reflectivity,e.ior.value=n.ior,e.refractionRatio.value=n.refractionRatio),n.lightMap&&(e.lightMap.value=n.lightMap,e.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(e.aoMap.value=n.aoMap,e.aoMapIntensity.value=n.aoMapIntensity),n.map?o=n.map:n.specularMap?o=n.specularMap:n.displacementMap?o=n.displacementMap:n.normalMap?o=n.normalMap:n.bumpMap?o=n.bumpMap:n.roughnessMap?o=n.roughnessMap:n.metalnessMap?o=n.metalnessMap:n.alphaMap?o=n.alphaMap:n.emissiveMap?o=n.emissiveMap:n.clearcoatMap?o=n.clearcoatMap:n.clearcoatNormalMap?o=n.clearcoatNormalMap:n.clearcoatRoughnessMap?o=n.clearcoatRoughnessMap:n.specularIntensityMap?o=n.specularIntensityMap:n.specularColorMap?o=n.specularColorMap:n.transmissionMap?o=n.transmissionMap:n.thicknessMap?o=n.thicknessMap:n.sheenColorMap?o=n.sheenColorMap:n.sheenRoughnessMap&&(o=n.sheenRoughnessMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),e.uvTransform.value.copy(o.matrix)),n.aoMap?l=n.aoMap:n.lightMap&&(l=n.lightMap),void 0!==l&&(l.isWebGLRenderTarget&&(l=l.texture),!0===l.matrixAutoUpdate&&l.updateMatrix(),e.uv2Transform.value.copy(l.matrix))}function n(e,n){e.roughness.value=n.roughness,e.metalness.value=n.metalness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(e.emissiveMap.value=n.emissiveMap),n.bumpMap&&(e.bumpMap.value=n.bumpMap,e.bumpScale.value=n.bumpScale,1===n.side&&(e.bumpScale.value*=-1)),n.normalMap&&(e.normalMap.value=n.normalMap,e.normalScale.value.copy(n.normalScale),1===n.side&&e.normalScale.value.negate()),n.displacementMap&&(e.displacementMap.value=n.displacementMap,e.displacementScale.value=n.displacementScale,e.displacementBias.value=n.displacementBias);t.get(n).envMap&&(e.envMapIntensity.value=n.envMapIntensity)}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,r,o,l,c){r.isMeshBasicMaterial?e(t,r):r.isMeshLambertMaterial?(e(t,r),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,r)):r.isMeshToonMaterial?(e(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap);e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshPhongMaterial?(e(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4),e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshStandardMaterial?(e(t,r),r.isMeshPhysicalMaterial?function(t,e,r){n(t,e),t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap),e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate()));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=r.texture,t.transmissionSamplerSize.value.set(r.width,r.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap);e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap)}(t,r,c):n(t,r)):r.isMeshMatcapMaterial?(e(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap);e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshDepthMaterial?(e(t,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isMeshDistanceMaterial?(e(t,r),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias);t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,r)):r.isMeshNormalMaterial?(e(t,r),function(t,e){e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale,1===e.side&&(t.bumpScale.value*=-1));e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale),1===e.side&&t.normalScale.value.negate());e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,r)):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);e.alphaTest>0&&(t.alphaTest.value=e.alphaTest);let o;e.map?o=e.map:e.alphaMap&&(o=e.alphaMap);void 0!==o&&(!0===o.matrixAutoUpdate&&o.updateMatrix(),t.uvTransform.value.copy(o.matrix))}(t,r,o,l):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);e.alphaTest>0&&(t.alphaTest.value=e.alphaTest);let n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Gs(t={}){const e=void 0!==t.canvas?t.canvas:function(){const canvas=mt("canvas");return canvas.style.display="block",canvas}(),n=void 0!==t.context?t.context:null,r=void 0!==t.alpha&&t.alpha,o=void 0===t.depth||t.depth,l=void 0===t.stencil||t.stencil,c=void 0!==t.antialias&&t.antialias,h=void 0===t.premultipliedAlpha||t.premultipliedAlpha,d=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,f=void 0!==t.powerPreference?t.powerPreference:"default",m=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat;let v=null,y=null;const M=[],w=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=G,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1;const S=this;let A=!1,L=0,P=0,I=null,N=-1,z=null;const O=new bt,B=new bt;let F=null,U=e.width,H=e.height,k=1,V=null,W=null;const j=new bt(0,0,U,H),X=new bt(0,0,U,H);let Y=!1;const J=[],Z=new qn;let $=!1,Q=!1,K=null;const tt=new ne,et=new Tt,nt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function it(){return null===I?k:1}let st,at,ot,lt,ct,ht,ut,pt,ft,gt,vt,xt,yt,_t,St,Et,At,Lt,Ct,Rt,Pt,It,Dt,Nt=n;function zt(t,n){for(let i=0;i0&&function(t,e,n){if(null===K){const t=!0===c&&!0===at.isWebGL2;K=new(t?wt:Mt)(1024,1024,{generateMipmaps:!0,type:null!==It.convert(R)?R:E,minFilter:T,magFilter:_,wrapS:x,wrapT:x,useRenderToTexture:st.has("WEBGL_multisampled_render_to_texture")})}const r=S.getRenderTarget();S.setRenderTarget(K),S.clear();const o=S.toneMapping;S.toneMapping=0,Xt(t,e,n),S.toneMapping=o,ht.updateMultisampleRenderTarget(K),ht.updateRenderTargetMipmap(K),S.setRenderTarget(r)}(o,e,n),r&&ot.viewport(O.copy(r)),o.length>0&&Xt(o,e,n),l.length>0&&Xt(l,e,n),h.length>0&&Xt(h,e,n)}function Xt(t,e,n){const r=!0===e.isScene?e.overrideMaterial:null;for(let i=0,o=t.length;i0?w[w.length-1]:null,M.pop(),v=M.length>0?M[M.length-1]:null},this.getActiveCubeFace=function(){return L},this.getActiveMipmapLevel=function(){return P},this.getRenderTarget=function(){return I},this.setRenderTargetTextures=function(t,e,n){ct.get(t.texture).__webglTexture=e,ct.get(t.depthTexture).__webglTexture=n;const r=ct.get(t);r.__hasExternalTextures=!0,r.__hasExternalTextures&&(r.__autoAllocateDepthBuffer=void 0===n,r.__autoAllocateDepthBuffer||t.useRenderToTexture&&(console.warn("render-to-texture extension was disabled because an external texture was provided"),t.useRenderToTexture=!1,t.useRenderbuffer=!0))},this.setRenderTargetFramebuffer=function(t,e){const n=ct.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,n=0){I=t,L=e,P=n;let r=!0;if(t){const e=ct.get(t);void 0!==e.__useDefaultFramebuffer?(ot.bindFramebuffer(36160,null),r=!1):void 0===e.__webglFramebuffer?ht.setupRenderTarget(t):e.__hasExternalTextures&&ht.rebindTextures(t,ct.get(t.texture).__webglTexture,ct.get(t.depthTexture).__webglTexture)}let o=null,l=!1,c=!1;if(t){const n=t.texture;(n.isDataTexture3D||n.isDataTexture2DArray)&&(c=!0);const r=ct.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(o=r[e],l=!0):o=t.useRenderbuffer?ct.get(t).__webglMultisampledFramebuffer:r,O.copy(t.viewport),B.copy(t.scissor),F=t.scissorTest}else O.copy(j).multiplyScalar(k).floor(),B.copy(X).multiplyScalar(k).floor(),F=Y;if(ot.bindFramebuffer(36160,o)&&at.drawBuffers&&r){let e=!1;if(t)if(t.isWebGLMultipleRenderTargets){const n=t.texture;if(J.length!==n.length||36064!==J[0]){for(let i=0,t=n.length;i=0&&e<=t.width-r&&n>=0&&n<=t.height-o&&Nt.readPixels(e,n,r,o,It.convert(h),It.convert(d),l):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const t=null!==I?ct.get(I).__webglFramebuffer:null;ot.bindFramebuffer(36160,t)}}},this.copyFramebufferToTexture=function(t,e,n=0){if(!0!==e.isFramebufferTexture)return void console.error("THREE.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.");const r=Math.pow(2,-n),o=Math.floor(e.image.width*r),l=Math.floor(e.image.height*r);ht.setTexture2D(e,0),Nt.copyTexSubImage2D(3553,n,0,0,t.x,t.y,o,l),ot.unbindTexture()},this.copyTextureToTexture=function(t,e,n,r=0){const o=e.image.width,l=e.image.height,c=It.convert(n.format),h=It.convert(n.type);ht.setTexture2D(n,0),Nt.pixelStorei(37440,n.flipY),Nt.pixelStorei(37441,n.premultiplyAlpha),Nt.pixelStorei(3317,n.unpackAlignment),e.isDataTexture?Nt.texSubImage2D(3553,r,t.x,t.y,o,l,c,h,e.image.data):e.isCompressedTexture?Nt.compressedTexSubImage2D(3553,r,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,c,e.mipmaps[0].data):Nt.texSubImage2D(3553,r,t.x,t.y,c,h,e.image),0===r&&n.generateMipmaps&&Nt.generateMipmap(3553),ot.unbindTexture()},this.copyTextureToTexture3D=function(t,e,n,r,o=0){if(S.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const l=t.max.x-t.min.x+1,c=t.max.y-t.min.y+1,h=t.max.z-t.min.z+1,d=It.convert(r.format),f=It.convert(r.type);let m;if(r.isDataTexture3D)ht.setTexture3D(r,0),m=32879;else{if(!r.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");ht.setTexture2DArray(r,0),m=35866}Nt.pixelStorei(37440,r.flipY),Nt.pixelStorei(37441,r.premultiplyAlpha),Nt.pixelStorei(3317,r.unpackAlignment);const v=Nt.getParameter(3314),x=Nt.getParameter(32878),y=Nt.getParameter(3316),_=Nt.getParameter(3315),M=Nt.getParameter(32877),image=n.isCompressedTexture?n.mipmaps[0]:n.image;Nt.pixelStorei(3314,image.width),Nt.pixelStorei(32878,image.height),Nt.pixelStorei(3316,t.min.x),Nt.pixelStorei(3315,t.min.y),Nt.pixelStorei(32877,t.min.z),n.isDataTexture||n.isDataTexture3D?Nt.texSubImage3D(m,o,e.x,e.y,e.z,l,c,h,d,f,image.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Nt.compressedTexSubImage3D(m,o,e.x,e.y,e.z,l,c,h,d,image.data)):Nt.texSubImage3D(m,o,e.x,e.y,e.z,l,c,h,d,f,image),Nt.pixelStorei(3314,v),Nt.pixelStorei(32878,x),Nt.pixelStorei(3316,y),Nt.pixelStorei(3315,_),Nt.pixelStorei(32877,M),0===o&&r.generateMipmaps&&Nt.generateMipmap(m),ot.unbindTexture()},this.initTexture=function(t){ht.setTexture2D(t,0),ot.unbindTexture()},this.resetState=function(){L=0,P=0,I=null,ot.reset(),Dt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}Gs.prototype.isWebGLRenderer=!0;(class extends Gs{}).prototype.isWebGL1Renderer=!0;class Ws{constructor(t,e=25e-5){this.name="",this.color=new Xe(t),this.density=e}clone(){return new Ws(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Ws.prototype.isFogExp2=!0;class js{constructor(t,e=1,n=1e3){this.name="",this.color=new Xe(t),this.near=e,this.far=n}clone(){return new js(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}js.prototype.isFog=!0;class qs extends Ae{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(source,t){return super.copy(source,t),null!==source.background&&(this.background=source.background.clone()),null!==source.environment&&(this.environment=source.environment.clone()),null!==source.fog&&(this.fog=source.fog.clone()),null!==source.overrideMaterial&&(this.overrideMaterial=source.overrideMaterial.clone()),this.autoUpdate=source.autoUpdate,this.matrixAutoUpdate=source.matrixAutoUpdate,this}toJSON(meta){const data=super.toJSON(meta);return null!==this.fog&&(data.object.fog=this.fog.toJSON()),data}}qs.prototype.isScene=!0;class Xs{constructor(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Y,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=nt()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(source){return this.array=new source.array.constructor(source.array),this.count=source.count,this.stride=source.stride,this.usage=source.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;it.far||e.push({distance:h,point:Qs.clone(),uv:Fe.getUV(Qs,ra,sa,aa,oa,la,ca,new ut),face:null,object:this})}copy(source){return super.copy(source),void 0!==source.center&&this.center.copy(source.center),this.material=source.material,this}}function ua(t,e,n,r,o,l){ea.subVectors(t,n).addScalar(.5).multiply(r),void 0!==o?(na.x=l*ea.x-o*ea.y,na.y=o*ea.x+l*ea.y):na.copy(ea),t.copy(e),t.x+=na.x,t.y+=na.y,t.applyMatrix4(ia)}ha.prototype.isSprite=!0;const da=new Tt,pa=new bt,fa=new bt,ma=new Tt,ga=new ne;class va extends An{constructor(t,e){super(t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new ne,this.bindMatrixInverse=new ne}copy(source){return super.copy(source),this.bindMode=source.bindMode,this.bindMatrix.copy(source.bindMatrix),this.bindMatrixInverse.copy(source.bindMatrixInverse),this.skeleton=source.skeleton,this}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new bt,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;ih)continue;v.applyMatrix4(this.matrixWorld);const n=t.ray.origin.distanceTo(v);nt.far||e.push({distance:n,point:m.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else{for(let i=Math.max(0,l.start),n=Math.min(o.count,l.start+l.count)-1;ih)continue;v.applyMatrix4(this.matrixWorld);const n=t.ray.origin.distanceTo(v);nt.far||e.push({distance:n,point:m.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}}else n.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const t=this.geometry;if(t.isBufferGeometry){const e=t.morphAttributes,n=Object.keys(e);if(n.length>0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Ia.prototype.isLine=!0;const Da=new Tt,Na=new Tt;class za extends Ia{constructor(t,e){super(t,e),this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.isBufferGeometry)if(null===t.index){const e=t.attributes.position,n=[];for(let i=0,t=e.count;i0){const t=e[n[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,n=t.length;e0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function Ga(t,e,n,r,o,l,object){const c=Ua.distanceSqToPoint(t);if(co.far)return;l.push({distance:h,distanceToRay:Math.sqrt(c),point:n,index:e,face:null,object:object})}}Va.prototype.isPoints=!0;(class extends yt{constructor(video,t,e,n,r,o,l,c,h){super(video,t,e,n,r,o,l,c,h),this.format=void 0!==l?l:I,this.minFilter=void 0!==o?o:S,this.magFilter=void 0!==r?r:S,this.generateMipmaps=!1;const d=this;"requestVideoFrameCallback"in video&&video.requestVideoFrameCallback((function t(){d.needsUpdate=!0,video.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const video=this.image;!1==="requestVideoFrameCallback"in video&&video.readyState>=video.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}).prototype.isVideoTexture=!0;(class extends yt{constructor(t,e,n){super({width:t,height:e}),this.format=n,this.magFilter=_,this.minFilter=_,this.generateMipmaps=!1,this.needsUpdate=!0}}).prototype.isFramebufferTexture=!0;class Wa extends yt{constructor(t,e,n,r,o,l,c,h,d,f,m,v){super(null,l,c,h,d,f,r,o,m,v),this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}Wa.prototype.isCompressedTexture=!0;(class extends yt{constructor(canvas,t,e,n,r,o,l,c,h){super(canvas,t,e,n,r,o,l,c,h),this.needsUpdate=!0}}).prototype.isCanvasTexture=!0;new Tt,new Tt,new Tt,new Fe;class ja{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(u,t){const e=this.getUtoTmapping(u);return this.getPoint(e,t)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,r=this.getPoint(0),o=0;e.push(0);for(let p=1;p<=t;p++)n=this.getPoint(p/t),o+=n.distanceTo(r),e.push(o),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(u,t){const e=this.getLengths();let i=0;const n=e.length;let r;r=t||u*e[n-1];let o,l=0,c=n-1;for(;l<=c;)if(i=Math.floor(l+(c-l)/2),o=e[i]-r,o<0)l=i+1;else{if(!(o>0)){c=i;break}c=i-1}if(i=c,e[i]===r)return i/(n-1);const h=e[i];return(i+(r-h)/(e[i+1]-h))/(n-1)}getTangent(t,e){const n=1e-4;let r=t-n,o=t+n;r<0&&(r=0),o>1&&(o=1);const l=this.getPoint(r),c=this.getPoint(o),h=e||(l.isVector2?new ut:new Tt);return h.copy(c).sub(l).normalize(),h}getTangentAt(u,t){const e=this.getUtoTmapping(u);return this.getTangent(e,t)}computeFrenetFrames(t,e){const n=new Tt,r=[],o=[],l=[],c=new Tt,h=new ne;for(let i=0;i<=t;i++){const u=i/t;r[i]=this.getTangentAt(u,new Tt)}o[0]=new Tt,l[0]=new Tt;let d=Number.MAX_VALUE;const f=Math.abs(r[0].x),m=Math.abs(r[0].y),v=Math.abs(r[0].z);f<=d&&(d=f,n.set(1,0,0)),m<=d&&(d=m,n.set(0,1,0)),v<=d&&n.set(0,0,1),c.crossVectors(r[0],n).normalize(),o[0].crossVectors(r[0],c),l[0].crossVectors(r[0],o[0]);for(let i=1;i<=t;i++){if(o[i]=o[i-1].clone(),l[i]=l[i-1].clone(),c.crossVectors(r[i-1],r[i]),c.length()>Number.EPSILON){c.normalize();const t=Math.acos(it(r[i-1].dot(r[i]),-1,1));o[i].applyMatrix4(h.makeRotationAxis(c,t))}l[i].crossVectors(r[i],o[i])}if(!0===e){let e=Math.acos(it(o[0].dot(o[t]),-1,1));e/=t,r[0].dot(c.crossVectors(o[0],o[t]))>0&&(e=-e);for(let i=1;i<=t;i++)o[i].applyMatrix4(h.makeRotationAxis(r[i],e*i)),l[i].crossVectors(r[i],o[i])}return{tangents:r,normals:o,binormals:l}}clone(){return(new this.constructor).copy(this)}copy(source){return this.arcLengthDivisions=source.arcLengthDivisions,this}toJSON(){const data={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return data.arcLengthDivisions=this.arcLengthDivisions,data.type=this.type,data}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class qa extends ja{constructor(t=0,e=0,n=1,r=1,o=0,l=2*Math.PI,c=!1,h=0){super(),this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=o,this.aEndAngle=l,this.aClockwise=c,this.aRotation=h}getPoint(t,e){const n=e||new ut,r=2*Math.PI;let o=this.aEndAngle-this.aStartAngle;const l=Math.abs(o)r;)o-=r;o0?0:(Math.floor(Math.abs(h)/o)+1)*o:0===d&&h===o-1&&(h=o-2,d=1),this.closed||h>0?l=r[(h-1)%o]:(Ja.subVectors(r[0],r[1]).add(r[0]),l=Ja);const f=r[h%o],m=r[(h+1)%o];if(this.closed||h+2r.length-2?r.length-1:o+1],f=r[o>r.length-3?r.length-1:o+2];return n.set(to(l,c.x,h.x,d.x,f.x),to(l,c.y,h.y,d.y,f.y)),n}copy(source){super.copy(source),this.points=[];for(let i=0,t=source.points.length;i=n){const t=r[i]-n,o=this.curves[i],l=o.getLength(),u=0===l?0:1-t/l;return o.getPointAt(u,e)}i++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let i=0,n=this.curves.length;i1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(source){super.copy(source),this.curves=[];for(let i=0,t=source.curves.length;i0){const t=d.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(d);const f=d.getPoint(1);return this.currentPoint.copy(f),this}copy(source){return super.copy(source),this.currentPoint.copy(source.currentPoint),this}toJSON(){const data=super.toJSON();return data.currentPoint=this.currentPoint.toArray(),data}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class po extends uo{constructor(t){super(t),this.uuid=nt(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let i=0,n=this.holes.length;i80*e){c=d=data[0],h=f=data[1];for(let i=e;id&&(d=m),v>f&&(f=v);x=Math.max(d-c,f-h),x=0!==x?1/x:0}return vo(o,l,e,c,h,x),l};function mo(data,t,e,n,r){let i,o;if(r===function(data,t,e,n){let r=0;for(let i=t,o=e-n;i0)for(i=t;i=t;i-=n)o=Oo(i,data[i],data[i+1],o);return o&&Ro(o,o.next)&&(Bo(o),o=o.next),o}function go(t,e){if(!t)return t;e||(e=t);let n,p=t;do{if(n=!1,p.steiner||!Ro(p,p.next)&&0!==Co(p.prev,p,p.next))p=p.next;else{if(Bo(p),p=e=p.prev,p===p.next)break;n=!0}}while(n||p!==e);return e}function vo(t,e,n,r,o,l,c){if(!t)return;!c&&l&&function(t,e,n,r){let p=t;do{null===p.z&&(p.z=To(p.x,p.y,e,n,r)),p.prevZ=p.prev,p.nextZ=p.next,p=p.next}while(p!==t);p.prevZ.nextZ=null,p.prevZ=null,function(t){let i,p,q,e,n,r,o,l,c=1;do{for(p=t,t=null,n=null,r=0;p;){for(r++,q=p,o=0,i=0;i0||l>0&&q;)0!==o&&(0===l||!q||p.z<=q.z)?(e=p,p=p.nextZ,o--):(e=q,q=q.nextZ,l--),n?n.nextZ=e:t=e,e.prevZ=n,n=e;p=q}n.nextZ=null,c*=2}while(r>1)}(p)}(t,r,o,l);let h,d,f=t;for(;t.prev!==t.next;)if(h=t.prev,d=t.next,l?yo(t,r,o,l):xo(t))e.push(h.i/n),e.push(t.i/n),e.push(d.i/n),Bo(t),t=d.next,f=d.next;else if((t=d)===f){c?1===c?vo(t=_o(go(t),e,n),e,n,r,o,l,2):2===c&&bo(t,e,n,r,o,l):vo(go(t),e,n,r,o,l,1);break}}function xo(t){const a=t.prev,b=t,e=t.next;if(Co(a,b,e)>=0)return!1;let p=t.next.next;for(;p!==t.prev;){if(Ao(a.x,a.y,b.x,b.y,e.x,e.y,p.x,p.y)&&Co(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function yo(t,e,n,r){const a=t.prev,b=t,o=t.next;if(Co(a,b,o)>=0)return!1;const l=a.xb.x?a.x>o.x?a.x:o.x:b.x>o.x?b.x:o.x,d=a.y>b.y?a.y>o.y?a.y:o.y:b.y>o.y?b.y:o.y,f=To(l,c,e,n,r),m=To(h,d,e,n,r);let p=t.prevZ,v=t.nextZ;for(;p&&p.z>=f&&v&&v.z<=m;){if(p!==t.prev&&p!==t.next&&Ao(a.x,a.y,b.x,b.y,o.x,o.y,p.x,p.y)&&Co(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,v!==t.prev&&v!==t.next&&Ao(a.x,a.y,b.x,b.y,o.x,o.y,v.x,v.y)&&Co(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;p&&p.z>=f;){if(p!==t.prev&&p!==t.next&&Ao(a.x,a.y,b.x,b.y,o.x,o.y,p.x,p.y)&&Co(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;v&&v.z<=m;){if(v!==t.prev&&v!==t.next&&Ao(a.x,a.y,b.x,b.y,o.x,o.y,v.x,v.y)&&Co(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function _o(t,e,n){let p=t;do{const a=p.prev,b=p.next.next;!Ro(a,b)&&Po(a,p,p.next,b)&&No(a,b)&&No(b,a)&&(e.push(a.i/n),e.push(p.i/n),e.push(b.i/n),Bo(p),Bo(p.next),p=t=b),p=p.next}while(p!==t);return go(p)}function bo(t,e,n,r,o,l){let a=t;do{let b=a.next.next;for(;b!==a.prev;){if(a.i!==b.i&&Lo(a,b)){let t=zo(a,b);return a=go(a,a.next),t=go(t,t.next),vo(a,e,n,r,o,l),void vo(t,e,n,r,o,l)}b=b.next}a=a.next}while(a!==t)}function Mo(a,b){return a.x-b.x}function wo(t,e){if(e=function(t,e){let p=e;const n=t.x,r=t.y;let o,l=-1/0;do{if(r<=p.y&&r>=p.next.y&&p.next.y!==p.y){const t=p.x+(r-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(t<=n&&t>l){if(l=t,t===n){if(r===p.y)return p;if(r===p.next.y)return p.next}o=p.x=p.x&&p.x>=h&&n!==p.x&&Ao(ro.x||p.x===o.x&&So(o,p)))&&(o=p,m=f)),p=p.next}while(p!==c);return o}(t,e),e){const b=zo(e,t);go(e,e.next),go(b,b.next)}}function So(t,p){return Co(t.prev,t,p.prev)<0&&Co(p.next,t,t.next)<0}function To(t,e,n,r,o){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*o)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*o)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Eo(t){let p=t,e=t;do{(p.x=0&&(t-c)*(r-h)-(n-c)*(e-h)>=0&&(n-c)*(l-h)-(o-c)*(r-h)>=0}function Lo(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!function(a,b){let p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&Po(p,p.next,a,b))return!0;p=p.next}while(p!==a);return!1}(a,b)&&(No(a,b)&&No(b,a)&&function(a,b){let p=a,t=!1;const e=(a.x+b.x)/2,n=(a.y+b.y)/2;do{p.y>n!=p.next.y>n&&p.next.y!==p.y&&e<(p.next.x-p.x)*(n-p.y)/(p.next.y-p.y)+p.x&&(t=!t),p=p.next}while(p!==a);return t}(a,b)&&(Co(a.prev,a,b.prev)||Co(a,b.prev,b))||Ro(a,b)&&Co(a.prev,a,a.next)>0&&Co(b.prev,b,b.next)>0)}function Co(p,q,t){return(q.y-p.y)*(t.x-q.x)-(q.x-p.x)*(t.y-q.y)}function Ro(t,e){return t.x===e.x&&t.y===e.y}function Po(t,e,n,r){const o=Do(Co(t,e,n)),l=Do(Co(t,e,r)),c=Do(Co(n,r,t)),h=Do(Co(n,r,e));return o!==l&&c!==h||(!(0!==o||!Io(t,n,e))||(!(0!==l||!Io(t,r,e))||(!(0!==c||!Io(n,t,r))||!(0!==h||!Io(n,e,r)))))}function Io(p,q,t){return q.x<=Math.max(p.x,t.x)&&q.x>=Math.min(p.x,t.x)&&q.y<=Math.max(p.y,t.y)&&q.y>=Math.min(p.y,t.y)}function Do(t){return t>0?1:t<0?-1:0}function No(a,b){return Co(a.prev,a,a.next)<0?Co(a,b,a.next)>=0&&Co(a,a.prev,b)>=0:Co(a,b,a.prev)<0||Co(a,a.next,b)<0}function zo(a,b){const t=new Fo(a.i,a.x,a.y),e=new Fo(b.i,b.x,b.y),n=a.next,r=b.prev;return a.next=b,b.prev=a,t.next=n,n.prev=t,e.next=t,t.prev=e,r.next=e,e.prev=r,e}function Oo(i,t,e,n){const p=new Fo(i,t,e);return n?(p.next=n.next,p.prev=n,n.next.prev=p,n.next=p):(p.prev=p,p.next=p),p}function Bo(p){p.next.prev=p.prev,p.prev.next=p.next,p.prevZ&&(p.prevZ.nextZ=p.nextZ),p.nextZ&&(p.nextZ.prevZ=p.prevZ)}function Fo(i,t,e){this.i=i,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class Uo{static area(t){const e=t.length;let a=0;for(let p=e-1,q=0;q2&&t[e-1].equals(t[0])&&t.pop()}function ko(t,e){for(let i=0;iNumber.EPSILON){const v=Math.sqrt(m),x=Math.sqrt(d*d+f*f),y=e.x-h/v,_=e.y+c/v,M=((n.x-f/x-y)*f-(n.y+d/x-_)*d)/(c*f-h*d);r=y+c*M-t.x,o=_+h*M-t.y;const w=r*r+o*o;if(w<=2)return new ut(r,o);l=Math.sqrt(w/2)}else{let t=!1;c>Number.EPSILON?d>Number.EPSILON&&(t=!0):c<-Number.EPSILON?d<-Number.EPSILON&&(t=!0):Math.sign(h)===Math.sign(f)&&(t=!0),t?(r=-h,o=c,l=Math.sqrt(m)):(r=c,o=h,l=Math.sqrt(m/2))}return new ut(r/l,o/l)}const F=[];for(let i=0,t=D.length,e=t-1,n=i+1;i=0;b--){const t=b/y,e=m*Math.cos(t*Math.PI/2),n=v*Math.sin(t*Math.PI/2)+x;for(let i=0,t=D.length;i=0;){const n=i;let r=i-1;r<0&&(r=t.length-1);for(let s=0,t=h+2*y;s0!=t>0&&this.version++,this._sheen=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(source){return super.copy(source),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=source.clearcoat,this.clearcoatMap=source.clearcoatMap,this.clearcoatRoughness=source.clearcoatRoughness,this.clearcoatRoughnessMap=source.clearcoatRoughnessMap,this.clearcoatNormalMap=source.clearcoatNormalMap,this.clearcoatNormalScale.copy(source.clearcoatNormalScale),this.ior=source.ior,this.sheen=source.sheen,this.sheenColor.copy(source.sheenColor),this.sheenColorMap=source.sheenColorMap,this.sheenRoughness=source.sheenRoughness,this.sheenRoughnessMap=source.sheenRoughnessMap,this.transmission=source.transmission,this.transmissionMap=source.transmissionMap,this.thickness=source.thickness,this.thicknessMap=source.thicknessMap,this.attenuationDistance=source.attenuationDistance,this.attenuationColor.copy(source.attenuationColor),this.specularIntensity=source.specularIntensity,this.specularIntensityMap=source.specularIntensityMap,this.specularColor.copy(source.specularColor),this.specularColorMap=source.specularColorMap,this}}Xo.prototype.isMeshPhysicalMaterial=!0;class Yo extends He{constructor(t){super(),this.type="MeshPhongMaterial",this.color=new Xe(16777215),this.specular=new Xe(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ut(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(t)}copy(source){return super.copy(source),this.color.copy(source.color),this.specular.copy(source.specular),this.shininess=source.shininess,this.map=source.map,this.lightMap=source.lightMap,this.lightMapIntensity=source.lightMapIntensity,this.aoMap=source.aoMap,this.aoMapIntensity=source.aoMapIntensity,this.emissive.copy(source.emissive),this.emissiveMap=source.emissiveMap,this.emissiveIntensity=source.emissiveIntensity,this.bumpMap=source.bumpMap,this.bumpScale=source.bumpScale,this.normalMap=source.normalMap,this.normalMapType=source.normalMapType,this.normalScale.copy(source.normalScale),this.displacementMap=source.displacementMap,this.displacementScale=source.displacementScale,this.displacementBias=source.displacementBias,this.specularMap=source.specularMap,this.alphaMap=source.alphaMap,this.envMap=source.envMap,this.combine=source.combine,this.reflectivity=source.reflectivity,this.refractionRatio=source.refractionRatio,this.wireframe=source.wireframe,this.wireframeLinewidth=source.wireframeLinewidth,this.wireframeLinecap=source.wireframeLinecap,this.wireframeLinejoin=source.wireframeLinejoin,this.flatShading=source.flatShading,this}}Yo.prototype.isMeshPhongMaterial=!0;class Jo extends He{constructor(t){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Xe(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ut(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(t)}copy(source){return super.copy(source),this.color.copy(source.color),this.map=source.map,this.gradientMap=source.gradientMap,this.lightMap=source.lightMap,this.lightMapIntensity=source.lightMapIntensity,this.aoMap=source.aoMap,this.aoMapIntensity=source.aoMapIntensity,this.emissive.copy(source.emissive),this.emissiveMap=source.emissiveMap,this.emissiveIntensity=source.emissiveIntensity,this.bumpMap=source.bumpMap,this.bumpScale=source.bumpScale,this.normalMap=source.normalMap,this.normalMapType=source.normalMapType,this.normalScale.copy(source.normalScale),this.displacementMap=source.displacementMap,this.displacementScale=source.displacementScale,this.displacementBias=source.displacementBias,this.alphaMap=source.alphaMap,this.wireframe=source.wireframe,this.wireframeLinewidth=source.wireframeLinewidth,this.wireframeLinecap=source.wireframeLinecap,this.wireframeLinejoin=source.wireframeLinejoin,this}}Jo.prototype.isMeshToonMaterial=!0;class Zo extends He{constructor(t){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ut(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(t)}copy(source){return super.copy(source),this.bumpMap=source.bumpMap,this.bumpScale=source.bumpScale,this.normalMap=source.normalMap,this.normalMapType=source.normalMapType,this.normalScale.copy(source.normalScale),this.displacementMap=source.displacementMap,this.displacementScale=source.displacementScale,this.displacementBias=source.displacementBias,this.wireframe=source.wireframe,this.wireframeLinewidth=source.wireframeLinewidth,this.flatShading=source.flatShading,this}}Zo.prototype.isMeshNormalMaterial=!0;class $o extends He{constructor(t){super(),this.type="MeshLambertMaterial",this.color=new Xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(t)}copy(source){return super.copy(source),this.color.copy(source.color),this.map=source.map,this.lightMap=source.lightMap,this.lightMapIntensity=source.lightMapIntensity,this.aoMap=source.aoMap,this.aoMapIntensity=source.aoMapIntensity,this.emissive.copy(source.emissive),this.emissiveMap=source.emissiveMap,this.emissiveIntensity=source.emissiveIntensity,this.specularMap=source.specularMap,this.alphaMap=source.alphaMap,this.envMap=source.envMap,this.combine=source.combine,this.reflectivity=source.reflectivity,this.refractionRatio=source.refractionRatio,this.wireframe=source.wireframe,this.wireframeLinewidth=source.wireframeLinewidth,this.wireframeLinecap=source.wireframeLinecap,this.wireframeLinejoin=source.wireframeLinejoin,this}}$o.prototype.isMeshLambertMaterial=!0;class Qo extends He{constructor(t){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Xe(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ut(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(t)}copy(source){return super.copy(source),this.defines={MATCAP:""},this.color.copy(source.color),this.matcap=source.matcap,this.map=source.map,this.bumpMap=source.bumpMap,this.bumpScale=source.bumpScale,this.normalMap=source.normalMap,this.normalMapType=source.normalMapType,this.normalScale.copy(source.normalScale),this.displacementMap=source.displacementMap,this.displacementScale=source.displacementScale,this.displacementBias=source.displacementBias,this.alphaMap=source.alphaMap,this.flatShading=source.flatShading,this}}Qo.prototype.isMeshMatcapMaterial=!0;class Ko extends Ea{constructor(t){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(source){return super.copy(source),this.scale=source.scale,this.dashSize=source.dashSize,this.gapSize=source.gapSize,this}}Ko.prototype.isLineDashedMaterial=!0;const tl={arraySlice:function(t,e,n){return tl.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==n?n:t.length)):t.slice(e,n)},convertArray:function(t,e,n){return!t||!n&&t.constructor===e?t:"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t)},isTypedArray:function(object){return ArrayBuffer.isView(object)&&!(object instanceof DataView)},getKeyframeOrder:function(t){const e=t.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort((function(i,e){return t[i]-t[e]})),n},sortedArray:function(t,e,n){const r=t.length,o=new t.constructor(r);for(let i=0,l=0;l!==r;++i){const r=n[i]*e;for(let n=0;n!==e;++n)o[l++]=t[r+n]}return o},flattenJSON:function(t,e,n,r){let i=1,o=t[0];for(;void 0!==o&&void 0===o[r];)o=t[i++];if(void 0===o)return;let l=o[r];if(void 0!==l)if(Array.isArray(l))do{l=o[r],void 0!==l&&(e.push(o.time),n.push.apply(n,l)),o=t[i++]}while(void 0!==o);else if(void 0!==l.toArray)do{l=o[r],void 0!==l&&(e.push(o.time),l.toArray(n,n.length)),o=t[i++]}while(void 0!==o);else do{l=o[r],void 0!==l&&(e.push(o.time),n.push(l)),o=t[i++]}while(void 0!==o)},subclip:function(t,e,n,r,o=30){const l=t.clone();l.name=e;const c=[];for(let i=0;i=r)){e.push(track.times[l]);for(let e=0;el.tracks[i].times[0]&&(h=l.tracks[i].times[0]);for(let i=0;i=e.times[m]){const t=m*h+c,n=t+h-c;v=tl.arraySlice(e.values,t,n)}else{const t=e.createInterpolant(),n=c,r=h-c;t.evaluate(l),v=tl.arraySlice(t.resultBuffer,n,r)}if("quaternion"===r){(new St).fromArray(v).normalize().conjugate().toArray(v)}const x=o.times.length;for(let t=0;t=o)break t;{const c=e[1];t=o)break e}l=n,n=0}}for(;n>>1;te;)--l;if(++l,0!==o||l!==r){o>=l&&(l=Math.max(l,1),o=l-1);const t=this.getValueSize();this.times=tl.arraySlice(n,o,l),this.values=tl.arraySlice(this.values,o*t,l*t)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,r=this.values,o=n.length;0===o&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let l=null;for(let i=0;i!==o;i++){const e=n[i];if("number"==typeof e&&isNaN(e)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,i,e),t=!1;break}if(null!==l&&l>e){console.error("THREE.KeyframeTrack: Out of order keys.",this,i,e,l),t=!1;break}l=e}if(void 0!==r&&tl.isTypedArray(r))for(let i=0,e=r.length;i!==e;++i){const e=r[i];if(isNaN(e)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,i,e),t=!1;break}}return t}optimize(){const t=tl.arraySlice(this.times),e=tl.arraySlice(this.values),n=this.getValueSize(),r=this.getInterpolation()===F,o=t.length-1;let l=1;for(let i=1;i0){t[l]=t[o];for(let t=o*n,r=l*n,c=0;c!==n;++c)e[r+c]=e[t+c];++l}return l!==t.length?(this.times=tl.arraySlice(t,0,l),this.values=tl.arraySlice(e,0,l*n)):(this.times=t,this.values=e),this}clone(){const t=tl.arraySlice(this.times,0),e=tl.arraySlice(this.values,0),track=new(0,this.constructor)(this.name,t,e);return track.createInterpolant=this.createInterpolant,track}}sl.prototype.TimeBufferType=Float32Array,sl.prototype.ValueBufferType=Float32Array,sl.prototype.DefaultInterpolation=B;class al extends sl{}al.prototype.ValueTypeName="bool",al.prototype.ValueBufferType=Array,al.prototype.DefaultInterpolation=O,al.prototype.InterpolantFactoryMethodLinear=void 0,al.prototype.InterpolantFactoryMethodSmooth=void 0;class ll extends sl{}ll.prototype.ValueTypeName="color";class cl extends sl{}cl.prototype.ValueTypeName="number";class hl extends el{constructor(t,e,n,r){super(t,e,n,r)}interpolate_(t,e,n,r){const o=this.resultBuffer,l=this.sampleValues,c=this.valueSize,h=(n-e)/(r-e);let d=t*c;for(let t=d+c;d!==t;d+=4)St.slerpFlat(o,0,l,d-c,l,d,h);return o}}class pl extends sl{InterpolantFactoryMethodLinear(t){return new hl(this.times,this.values,this.getValueSize(),t)}}pl.prototype.ValueTypeName="quaternion",pl.prototype.DefaultInterpolation=B,pl.prototype.InterpolantFactoryMethodSmooth=void 0;class fl extends sl{}fl.prototype.ValueTypeName="string",fl.prototype.ValueBufferType=Array,fl.prototype.DefaultInterpolation=O,fl.prototype.InterpolantFactoryMethodLinear=void 0,fl.prototype.InterpolantFactoryMethodSmooth=void 0;class ml extends sl{}ml.prototype.ValueTypeName="vector";class gl{constructor(t,e=-1,n,r=2500){this.name=t,this.tracks=n,this.duration=e,this.blendMode=r,this.uuid=nt(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,r=1/(t.fps||1);for(let i=0,t=n.length;i!==t;++i)e.push(vl(n[i]).scale(r));const o=new this(t.name,t.duration,e,t.blendMode);return o.uuid=t.uuid,o}static toJSON(t){const e=[],n=t.tracks,r={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let i=0,t=n.length;i!==t;++i)e.push(sl.toJSON(n[i]));return r}static CreateFromMorphTargetSequence(t,e,n,r){const o=e.length,l=[];for(let i=0;i1){const t=n[1];let o=r[t];o||(r[t]=o=[]),o.push(e)}}const o=[];for(const t in r)o.push(this.CreateFromMorphTargetSequence(t,r[t],e,n));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(t,e,n,r,o){if(0!==n.length){const l=[],c=[];tl.flattenJSON(n,l,c,r),0!==l.length&&o.push(new t(e,l,c))}},r=[],o=t.name||"default",l=t.fps||30,c=t.blendMode;let h=t.length||-1;const d=t.hierarchy||[];for(let t=0;t{e&&e(o),this.manager.itemEnd(t)}),0),o;if(void 0!==Ml[t])return void Ml[t].push({onLoad:e,onProgress:n,onError:r});Ml[t]=[],Ml[t].push({onLoad:e,onProgress:n,onError:r});const l=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"});fetch(l).then((e=>{if(200===e.status||0===e.status){if(0===e.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===e.body.getReader)return e;const n=Ml[t],r=e.body.getReader(),o=e.headers.get("Content-Length"),l=o?parseInt(o):0,c=0!==l;let h=0;const d=new ReadableStream({start(t){!function e(){r.read().then((({done:r,value:o})=>{if(r)t.close();else{h+=o.byteLength;const r=new ProgressEvent("progress",{lengthComputable:c,loaded:h,total:l});for(let i=0,t=n.length;i{switch(this.responseType){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then((text=>(new DOMParser).parseFromString(text,this.mimeType)));case"json":return t.json();default:return t.text()}})).then((data=>{xl.add(t,data);const e=Ml[t];delete Ml[t];for(let i=0,t=e.length;i{const n=Ml[t];if(void 0===n)throw this.manager.itemError(t),e;delete Ml[t];for(let i=0,t=n.length;i{this.manager.itemEnd(t)})),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Sl extends bl{constructor(t){super(t)}load(t,e,n,r){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const o=this,l=xl.get(t);if(void 0!==l)return o.manager.itemStart(t),setTimeout((function(){e&&e(l),o.manager.itemEnd(t)}),0),l;const image=mt("img");function c(){d(),xl.add(t,this),e&&e(this),o.manager.itemEnd(t)}function h(e){d(),r&&r(e),o.manager.itemError(t),o.manager.itemEnd(t)}function d(){image.removeEventListener("load",c,!1),image.removeEventListener("error",h,!1)}return image.addEventListener("load",c,!1),image.addEventListener("error",h,!1),"data:"!==t.substr(0,5)&&void 0!==this.crossOrigin&&(image.crossOrigin=this.crossOrigin),o.manager.itemStart(t),image.src=t,image}}class Tl extends bl{constructor(t){super(t)}load(t,e,n,r){const o=new Fn,l=new Sl(this.manager);l.setCrossOrigin(this.crossOrigin),l.setPath(this.path);let c=0;function h(i){l.load(t[i],(function(image){o.images[i]=image,c++,6===c&&(o.needsUpdate=!0,e&&e(o))}),void 0,r)}for(let i=0;i0){this.source.connect(this.filters[0]);for(let i=1,t=this.filters.length;i0){this.source.disconnect(this.filters[0]);for(let i=1,t=this.filters.length;i0&&this._mixBufferRegionAdditive(n,r,this._addIndex*e,1,e);for(let i=e,t=e+e;i!==t;++i)if(n[i]!==n[i+e]){c.setValue(n,r);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,r=n*this._origIndex;t.getValue(e,r);for(let i=n,t=r;i!==t;++i)e[i]=e[r+i%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i=.5)for(let i=0;i!==o;++i)t[e+i]=t[n+i]}_slerp(t,e,n,r){St.slerpFlat(t,e,t,e,t,n,r)}_slerpAdditive(t,e,n,r,o){const l=this._workIndex*o;St.multiplyQuaternionsFlat(t,l,t,e,t,n),St.slerpFlat(t,e,t,e,t,l,r)}_lerp(t,e,n,r,o){const s=1-r;for(let i=0;i!==o;++i){const o=e+i;t[o]=t[o]*s+t[n+i]*r}}_lerpAdditive(t,e,n,r,o){for(let i=0;i!==o;++i){const o=e+i;t[o]=t[o]+t[n+i]*r}}}const Kl="\\[\\]\\.:\\/",tc=new RegExp("[\\[\\]\\.:\\/]","g"),ec="[^\\[\\]\\.:\\/]",nc="[^"+Kl.replace("\\.","")+"]",ic=/((?:WC+[\/:])*)/.source.replace("WC",ec),rc=/(WCOD+)?/.source.replace("WCOD",nc),sc=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",ec),ac=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",ec),oc=new RegExp("^"+ic+rc+sc+ac+"$"),lc=["material","materials","bones"];class cc{constructor(t,path,e){this.path=path,this.parsedPath=e||cc.parseTrackName(path),this.node=cc.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,path,e){return t&&t.isAnimationObjectGroup?new cc.Composite(t,path,e):new cc(t,path,e)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(tc,"")}static parseTrackName(t){const e=oc.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==r&&-1!==r){const t=n.nodeName.substring(r+1);-1!==lc.indexOf(t)&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=t)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(void 0!==n)return n}if(t.children){const n=function(t){for(let i=0;i0){const t=this._interpolants,e=this._propertyBindings;if(2501===this.blendMode)for(let n=0,r=t.length;n!==r;++n)t[n].evaluate(o),e[n].accumulateAdditive(l);else for(let r=0,c=t.length;r!==c;++r)t[r].evaluate(o),e[r].accumulate(n,l)}}_updateWeight(time){let t=0;if(this.enabled){t=this.weight;const e=this._weightInterpolant;if(null!==e){const n=e.evaluate(time)[0];t*=n,time>e.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(time){let t=0;if(!this.paused){t=this.timeScale;const e=this._timeScaleInterpolant;if(null!==e){t*=e.evaluate(time)[0],time>e.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(t){const e=this._clip.duration,n=this.loop;let time=this.time+t,r=this._loopCount;const o=2202===n;if(0===t)return-1===r?time:o&&1==(1&r)?e-time:time;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(time>=e)time=e;else{if(!(time<0)){this.time=time;break t}time=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=time,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),time>=e||time<0){const n=Math.floor(time/e);time-=e*n,r+=Math.abs(n);const l=this.repetitions-r;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,time=t>0?e:0,this.time=time,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===l){const e=t<0;this._setEndings(e,!e,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=time,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=time;if(o&&1==(1&r))return e-time}return time}_setEndings(t,e,n){const r=this._interpolantSettings;n?(r.endingStart=H,r.endingEnd=H):(r.endingStart=t?this.zeroSlopeAtStart?H:U:k,r.endingEnd=e?this.zeroSlopeAtEnd?H:U:k)}_scheduleFading(t,e,n){const r=this._mixer,o=r.time;let l=this._weightInterpolant;null===l&&(l=r._lendControlInterpolant(),this._weightInterpolant=l);const c=l.parameterPositions,h=l.sampleValues;return c[0]=o,h[0]=e,c[1]=o+t,h[1]=n,this}}(class extends ${constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,r=t._clip.tracks,o=r.length,l=t._propertyBindings,c=t._interpolants,h=n.uuid,d=this._bindingsByRootAndName;let f=d[h];void 0===f&&(f={},d[h]=f);for(let i=0;i!==o;++i){const track=r[i],t=track.name;let o=f[t];if(void 0!==o)l[i]=o;else{if(o=l[i],void 0!==o){null===o._cacheIndex&&(++o.referenceCount,this._addInactiveBinding(o,h,t));continue}const path=e&&e._propertyBindings[i].binding.parsedPath;o=new Ql(cc.create(n,t,path),track.ValueTypeName,track.getValueSize()),++o.referenceCount,this._addInactiveBinding(o,h,t),l[i]=o}c[i].resultBuffer=o.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,n=t._clip.uuid,r=this._actionsByClip[n];this._bindAction(t,r&&r.knownActions[0]),this._addInactiveAction(t,n,e)}const e=t._propertyBindings;for(let i=0,t=e.length;i!==t;++i){const t=e[i];0==t.useCount++&&(this._lendBinding(t),t.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let i=0,t=e.length;i!==t;++i){const t=e[i];0==--t.useCount&&(t.restoreOriginalState(),this._takeBackBinding(t))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return null!==e&&e=0;--i)t[i].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,time=this.time+=t,r=Math.sign(t),o=this._accuIndex^=1;for(let i=0;i!==n;++i){e[i]._update(time,t,r,o)}const l=this._bindings,c=this._nActiveBindings;for(let i=0;i!==c;++i)l[i].apply(o);return this}setTime(t){this.time=0;for(let i=0;ithis.max.x||t.ythis.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return dc.copy(t).clamp(this.min,this.max).sub(t).length()}intersect(t){return this.min.max(t.min),this.max.min(t.max),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}pc.prototype.isBox2=!0;const fc=new Tt,mc=new ne,gc=new ne;function vc(object){const t=[];object&&object.isBone&&t.push(object);for(let i=0;i{t[e]=t.uniformValues[e]})),delete t.uniformValues),Object.keys(t).forEach((e=>{this[e]=t[e]})),this.setValues(t),this.uniforms=In.merge([e,t.uniforms||{}]),this.setUniformValues(t)}setUniformValues(t){if(!t)return;Object.keys(t).forEach((e=>{e in this.uniforms&&(this.uniforms[e].value=t[e])}))}stringifyChunk(t){let e;return e=this[t]?"string"==typeof this[t]?this[t]:this[t].join("\n"):"",e}}class _c extends yc{constructor(t){super(t,Qn.points.uniforms),this.vertexShader=this.concatVertexShader(),this.fragmentShader=this.concatFragmentShader()}concatVertexShader(){return Qn.points.vertexShader.replace("void main() {",`\n ${this.stringifyChunk("vertexParameters")}\n ${this.stringifyChunk("varyingParameters")}\n ${this.stringifyChunk("vertexFunctions")}\n\n void main() {\n ${this.stringifyChunk("vertexInit")}\n `).replace("#include ",`\n #include \n\n ${this.stringifyChunk("vertexPosition")}\n ${this.stringifyChunk("vertexColor")}\n `).replace("#include ",`\n #include \n\n ${this.stringifyChunk("vertexPostMorph")}\n `)}concatFragmentShader(){return Qn.points.fragmentShader.replace("void main() {",`\n ${this.stringifyChunk("fragmentParameters")}\n ${this.stringifyChunk("varyingParameters")}\n ${this.stringifyChunk("fragmentFunctions")}\n\n void main() {\n ${this.stringifyChunk("fragmentInit")}\n `).replace("#include ",`\n ${this.stringifyChunk("fragmentDiffuse")}\n ${this.stringifyChunk("fragmentMap")||"#include "}\n\n `).replace("#include ",`\n ${this.stringifyChunk("fragmentShape")}\n\n #include \n `)}}class bc extends yc{constructor(t){super(t,Qn.depth.uniforms),this.depthPacking=j,this.clipping=!0,this.vertexShader=this.concatVertexShader(),this.fragmentShader=Qn.depth.fragmentShader}concatVertexShader(){return Qn.depth.vertexShader.replace("void main() {",`\n ${this.stringifyChunk("vertexParameters")}\n ${this.stringifyChunk("vertexFunctions")}\n\n void main() {\n ${this.stringifyChunk("vertexInit")}\n `).replace("#include ",`\n #include \n\n ${this.stringifyChunk("vertexPosition")}\n `).replace("#include ",`\n #include \n\n ${this.stringifyChunk("vertexPostMorph")}\n `).replace("#include ",`\n #include \n\n ${this.stringifyChunk("vertexPostSkinning")}\n `)}}class Mc extends yc{constructor(t){super(t,Qn.distanceRGBA.uniforms),this.depthPacking=j,this.clipping=!0,this.vertexShader=this.concatVertexShader(),this.fragmentShader=Qn.distanceRGBA.fragmentShader}concatVertexShader(){return Qn.distanceRGBA.vertexShader.replace("void main() {",`\n ${this.stringifyChunk("vertexParameters")}\n ${this.stringifyChunk("vertexFunctions")}\n\n void main() {\n ${this.stringifyChunk("vertexInit")}\n `).replace("#include ",`\n #include \n\n ${this.stringifyChunk("vertexPosition")}\n `).replace("#include ",`\n #include \n\n ${this.stringifyChunk("vertexPostMorph")}\n `).replace("#include ",`\n #include \n\n ${this.stringifyChunk("vertexPostSkinning")}\n `)}}const wc={separateFaces:function(t){let e=[];for(let i=0,n=t.faces.length;i 2.220446049250313e-16) {\n float sn = sqrt(sqrSn);\n float len = atan(sn, c * dir);\n s = sin(s * len) / sn;\n t = sin(t * len) / sn;\n }\n float tDir = t * dir;\n return normalize(q0 * s + q1 * tDir);\n}\n"};function Ac(t,e,n,r,o){this.key=t,this.start=e,this.duration=n,this.transition=r,this.compiler=o,this.trail=0}function Lc(){this.duration=0,this.timeKey="tTime",this.segments={},this.__key=0}Ac.prototype.compile=function(){return this.compiler(this)},Object.defineProperty(Ac.prototype,"end",{get:function(){return this.start+this.duration}}),Lc.segmentDefinitions={},Lc.register=function(t,e){return Lc.segmentDefinitions[t]=e,e},Lc.prototype.add=function(t,e,n){const r=eval;let o=this.duration;void 0!==n?("number"==typeof n?o=n:"string"==typeof n&&r("start"+n),this.duration=Math.max(this.duration,o+t)):this.duration+=t;let l,c=Object.keys(e);for(let i=0;it.toPrecision(4))).join(", ")}`:""});`:""}\n `},Dc=function(t){return`if (time < ${t.start.toPrecision(4)} || time > ${(t.end+t.trail).toPrecision(4)}) return;`},Nc={compiler:function(t){return`\n ${Pc(t)}\n ${Cc(`cTranslateFrom${t.key}`,t.transition.from,2)}\n ${Cc(`cTranslateTo${t.key}`,t.transition.to,2)}\n \n void applyTransform${t.key}(float time, inout vec3 v) {\n \n ${Dc(t)}\n ${Ic(t)}\n \n v += mix(cTranslateFrom${t.key}, cTranslateTo${t.key}, progress);\n }\n `},defaultFrom:new Tt(0,0,0)};Lc.register("translate",Nc);const zc={compiler:function(t){const e=t.transition.origin;return`\n ${Pc(t)}\n ${Cc(`cScaleFrom${t.key}`,t.transition.from,2)}\n ${Cc(`cScaleTo${t.key}`,t.transition.to,2)}\n ${e?Cc(`cOrigin${t.key}`,e,2):""}\n \n void applyTransform${t.key}(float time, inout vec3 v) {\n \n ${Dc(t)}\n ${Ic(t)}\n \n ${e?`v -= cOrigin${t.key};`:""}\n v *= mix(cScaleFrom${t.key}, cScaleTo${t.key}, progress);\n ${e?`v += cOrigin${t.key};`:""}\n }\n `},defaultFrom:new Tt(1,1,1)};Lc.register("scale",zc);const Oc={compiler(t){const e=new bt(t.transition.from.axis.x,t.transition.from.axis.y,t.transition.from.axis.z,t.transition.from.angle),n=t.transition.to.axis||t.transition.from.axis,r=new bt(n.x,n.y,n.z,t.transition.to.angle),o=t.transition.origin;return`\n ${Pc(t)}\n ${Rc(`cRotationFrom${t.key}`,e,8)}\n ${Rc(`cRotationTo${t.key}`,r,8)}\n ${o?Cc(`cOrigin${t.key}`,o,2):""}\n \n void applyTransform${t.key}(float time, inout vec3 v) {\n ${Dc(t)}\n ${Ic(t)}\n\n ${o?`v -= cOrigin${t.key};`:""}\n vec3 axis = normalize(mix(cRotationFrom${t.key}.xyz, cRotationTo${t.key}.xyz, progress));\n float angle = mix(cRotationFrom${t.key}.w, cRotationTo${t.key}.w, progress);\n vec4 q = quatFromAxisAngle(axis, angle);\n v = rotateVector(q, v);\n ${o?`v += cOrigin${t.key};`:""}\n }\n `},defaultFrom:{axis:new Tt,angle:0}};Lc.register("rotate",Oc)},263:function(t,e){function n(t){return"function"==typeof t.value||(console.warn("[Vue-click-outside:] provided expression",t.expression,"is not a function."),!1)}function r(t){return void 0!==t.componentInstance&&t.componentInstance.$isServer}t.exports={bind:function(t,e,o){if(!n(e))return;function l(e){if(o.context){var n=e.path||e.composedPath&&e.composedPath();n&&n.length>0&&n.unshift(e.target),t.contains(e.target)||function(t,e){if(!t||!e)return!1;for(var i=0,n=e.length;i