!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).skinview3d={})}(this,function(e){"use strict";let t,i;let r={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},a={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},n="srgb",s="srgb-linear",o="display-p3",l="300 es";class h{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let i=this._listeners,r=i[e];if(void 0!==r){let e=r.indexOf(t);-1!==e&&r.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let t=this._listeners,i=t[e.type];if(void 0!==i){e.target=this;let t=i.slice(0);for(let i=0,r=t.length;i>8&255]+c[e>>16&255]+c[e>>24&255]+"-"+c[255&t]+c[t>>8&255]+"-"+c[t>>16&15|64]+c[t>>24&255]+"-"+c[63&i|128]+c[i>>8&255]+"-"+c[i>>16&255]+c[i>>24&255]+c[255&r]+c[r>>8&255]+c[r>>16&255]+c[r>>24&255];return a.toLowerCase()}function f(e,t,i){return Math.max(t,Math.min(i,e))}function m(e){return(e&e-1)==0&&0!==e}function g(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function v(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("Invalid component type.")}}function _(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw Error("Invalid component type.")}}class x{constructor(e=0,t=0){x.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6],this.y=r[1]*t+r[4]*i+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.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(){let e=Math.atan2(-this.y,-this.x)+Math.PI;return e}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(f(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),r=Math.sin(t),a=this.x-e.x,n=this.y-e.y;return this.x=a*i-n*r+e.x,this.y=a*r+n*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class y{constructor(e,t,i,r,a,n,s,o,l){y.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,i,r,a,n,s,o,l)}set(e,t,i,r,a,n,s,o,l){let h=this.elements;return h[0]=e,h[1]=r,h[2]=s,h[3]=t,h[4]=a,h[5]=o,h[6]=i,h[7]=n,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,a=this.elements,n=i[0],s=i[3],o=i[6],l=i[1],h=i[4],c=i[7],u=i[2],d=i[5],p=i[8],f=r[0],m=r[3],g=r[6],v=r[1],_=r[4],x=r[7],y=r[2],M=r[5],S=r[8];return a[0]=n*f+s*v+o*y,a[3]=n*m+s*_+o*M,a[6]=n*g+s*x+o*S,a[1]=l*f+h*v+c*y,a[4]=l*m+h*_+c*M,a[7]=l*g+h*x+c*S,a[2]=u*f+d*v+p*y,a[5]=u*m+d*_+p*M,a[8]=u*g+d*x+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],n=e[4],s=e[5],o=e[6],l=e[7],h=e[8];return t*n*h-t*s*l-i*a*h+i*s*o+r*a*l-r*n*o}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],n=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=h*n-s*l,u=s*o-h*a,d=l*a-n*o,p=t*c+i*u+r*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(r*l-h*i)*f,e[2]=(s*i-r*n)*f,e[3]=u*f,e[4]=(h*t-r*o)*f,e[5]=(r*a-s*t)*f,e[6]=d*f,e[7]=(i*o-l*t)*f,e[8]=(n*t-i*a)*f,this}transpose(){let e;let t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,r,a,n,s){let o=Math.cos(a),l=Math.sin(a);return this.set(i*o,i*l,-i*(o*n+l*s)+n+e,-r*l,r*o,-r*(-l*n+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(M.makeScale(e,t)),this}rotate(e){return this.premultiply(M.makeRotation(-e)),this}translate(e,t){return this.premultiply(M.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let e=0;e<9;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}}let M=new y;function S(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function b(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}let w={};function T(e){e in w||(w[e]=!0,console.warn(e))}function E(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function A(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let C=new y().fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-.0000001,1e-7,.9105199]),L=new y().fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]),P={[s]:e=>e,[n]:e=>e.convertSRGBToLinear(),[o]:function(e){return e.convertSRGBToLinear().applyMatrix3(L)}},R={[s]:e=>e,[n]:e=>e.convertLinearToSRGB(),[o]:function(e){return e.applyMatrix3(C).convertLinearToSRGB()}},D={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(legacyMode){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!legacyMode},get workingColorSpace(){return s},set workingColorSpace(colorSpace){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,i){if(!1===this.enabled||t===i||!t||!i)return e;let r=P[t],a=R[i];if(void 0===r||void 0===a)throw Error(`Unsupported color space conversion, "${t}" to "${i}".`);return a(r(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}};class U{static getDataURL(e){let i;if(/^data:/i.test(e.src)||"undefined"==typeof HTMLCanvasElement)return e.src;if(e instanceof HTMLCanvasElement)i=e;else{void 0===t&&(t=b("canvas")),t.width=e.width,t.height=e.height;let r=t.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),i=t}return i.width>2048||i.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),i.toDataURL("image/jpeg",.6)):i.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let t=b("canvas");t.width=e.width,t.height=e.height;let i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);let r=i.getImageData(0,0,e.width,e.height),a=r.data;for(let e=0;e0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1e3:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case 1e3:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return T("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===n?3001:3e3}set encoding(e){T("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=3001===e?n:""}}F.DEFAULT_IMAGE=null,F.DEFAULT_MAPPING=300,F.DEFAULT_ANISOTROPY=1;class k{constructor(e=0,t=0,i=0,r=1){k.prototype.isVector4=!0,this.x=e,this.y=t,this.z=i,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,a=this.w,n=e.elements;return this.x=n[0]*t+n[4]*i+n[8]*r+n[12]*a,this.y=n[1]*t+n[5]*i+n[9]*r+n[13]*a,this.z=n[2]*t+n[6]*i+n[10]*r+n[14]*a,this.w=n[3]*t+n[7]*i+n[11]*r+n[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,r;let a=e.elements,n=a[0],s=a[4],o=a[8],l=a[1],h=a[5],c=a[9],u=a[2],d=a[6],p=a[10];if(.01>Math.abs(s-l)&&.01>Math.abs(o-u)&&.01>Math.abs(c-d)){if(.1>Math.abs(s+l)&&.1>Math.abs(o+u)&&.1>Math.abs(c+d)&&.1>Math.abs(n+h+p-3))return this.set(1,0,0,0),this;let e=(n+1)/2,a=(h+1)/2,f=(p+1)/2,m=(s+l)/4,g=(o+u)/4,v=(c+d)/4;return e>a&&e>f?e<.01?(t=0,i=.707106781,r=.707106781):(i=m/(t=Math.sqrt(e)),r=g/t):a>f?a<.01?(t=.707106781,i=0,r=.707106781):(t=m/(i=Math.sqrt(a)),r=v/i):f<.01?(t=.707106781,i=.707106781,r=0):(t=g/(r=Math.sqrt(f)),i=v/r),this.set(t,i,r,Math.PI),this}let f=Math.sqrt((d-c)*(d-c)+(o-u)*(o-u)+(l-s)*(l-s));return .001>Math.abs(f)&&(f=1),this.x=(d-c)/f,this.y=(o-u)/f,this.z=(l-s)/f,this.w=Math.acos((n+h+p-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class B extends h{constructor(e=1,t=1,i={}){super(),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new k(0,0,e,t),this.scissorTest=!1,this.viewport=new k(0,0,e,t),void 0!==i.encoding&&(T("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),i.colorSpace=3001===i.encoding?n:""),this.texture=new F({width:e,height:t,depth:1},i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,this.texture.internalFormat=void 0!==i.internalFormat?i.internalFormat:null,this.texture.minFilter=void 0!==i.minFilter?i.minFilter:1006,this.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,this.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,this.depthTexture=void 0!==i.depthTexture?i.depthTexture:null,this.samples=void 0!==i.samples?i.samples:0}setSize(e,t,i=1){(this.width!==e||this.height!==t||this.depth!==i)&&(this.width=e,this.height=t,this.depth=i,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=i,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;let t=Object.assign({},e.texture.image);return this.texture.source=new N(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class H extends B{constructor(e=1,t=1,i={}){super(e,t,i),this.isWebGLRenderTarget=!0}}class V extends F{constructor(e=null,t=1,i=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:i,depth:r},this.magFilter=1003,this.minFilter=1003,this.wrapR=1001,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class G{constructor(e=0,t=0,i=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=r}static slerpFlat(e,t,i,r,a,n,s){let o=i[r+0],l=i[r+1],h=i[r+2],c=i[r+3],u=a[n+0],d=a[n+1],p=a[n+2],f=a[n+3];if(0===s){e[t+0]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c;return}if(1===s){e[t+0]=u,e[t+1]=d,e[t+2]=p,e[t+3]=f;return}if(c!==f||o!==u||l!==d||h!==p){let e=1-s,t=o*u+l*d+h*p+c*f,i=t>=0?1:-1,r=1-t*t;if(r>Number.EPSILON){let a=Math.sqrt(r),n=Math.atan2(a,t*i);e=Math.sin(e*n)/a,s=Math.sin(s*n)/a}let a=s*i;if(o=o*e+u*a,l=l*e+d*a,h=h*e+p*a,c=c*e+f*a,e===1-s){let e=1/Math.sqrt(o*o+l*l+h*h+c*c);o*=e,l*=e,h*=e,c*=e}}e[t]=o,e[t+1]=l,e[t+2]=h,e[t+3]=c}static multiplyQuaternionsFlat(e,t,i,r,a,n){let s=i[r],o=i[r+1],l=i[r+2],h=i[r+3],c=a[n],u=a[n+1],d=a[n+2],p=a[n+3];return e[t]=s*p+h*c+o*d-l*u,e[t+1]=o*p+h*u+l*c-s*d,e[t+2]=l*p+h*d+s*u-o*c,e[t+3]=h*p-s*c-o*u-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,r){return this._x=e,this._y=t,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){let i=e._x,r=e._y,a=e._z,n=e._order,s=Math.cos,o=Math.sin,l=s(i/2),h=s(r/2),c=s(a/2),u=o(i/2),d=o(r/2),p=o(a/2);switch(n){case"XYZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"YXZ":this._x=u*h*c+l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"ZXY":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c-u*d*p;break;case"ZYX":this._x=u*h*c-l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c+u*d*p;break;case"YZX":this._x=u*h*c+l*d*p,this._y=l*d*c+u*h*p,this._z=l*h*p-u*d*c,this._w=l*h*c-u*d*p;break;case"XZY":this._x=u*h*c-l*d*p,this._y=l*d*c-u*h*p,this._z=l*h*p+u*d*c,this._w=l*h*c+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,r=Math.sin(i);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],r=t[4],a=t[8],n=t[1],s=t[5],o=t[9],l=t[2],h=t[6],c=t[10],u=i+s+c;if(u>0){let e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(h-o)*e,this._y=(a-l)*e,this._z=(n-r)*e}else if(i>s&&i>c){let e=2*Math.sqrt(1+i-s-c);this._w=(h-o)/e,this._x=.25*e,this._y=(r+n)/e,this._z=(a+l)/e}else if(s>c){let e=2*Math.sqrt(1+s-i-c);this._w=(a-l)/e,this._x=(r+n)/e,this._y=.25*e,this._z=(o+h)/e}else{let e=2*Math.sqrt(1+c-i-s);this._w=(n-r)/e,this._x=(a+l)/e,this._y=(o+h)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return iMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(f(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);return 0===i||this.slerp(e,Math.min(1,t/i)),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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,r=e._y,a=e._z,n=e._w,s=t._x,o=t._y,l=t._z,h=t._w;return this._x=i*h+n*s+r*l-a*o,this._y=r*h+n*o+a*s-i*l,this._z=a*h+n*l+i*o-r*s,this._w=n*h-i*s-r*o-a*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);let i=this._x,r=this._y,a=this._z,n=this._w,s=n*e._w+i*e._x+r*e._y+a*e._z;if(s<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,s=-s):this.copy(e),s>=1)return this._w=n,this._x=i,this._y=r,this._z=a,this;let o=1-s*s;if(o<=Number.EPSILON){let e=1-t;return this._w=e*n+t*this._w,this._x=e*i+t*this._x,this._y=e*r+t*this._y,this._z=e*a+t*this._z,this.normalize(),this._onChangeCallback(),this}let l=Math.sqrt(o),h=Math.atan2(l,s),c=Math.sin((1-t)*h)/l,u=Math.sin(t*h)/l;return this._w=n*c+this._w*u,this._x=i*c+this._x*u,this._y=r*c+this._y*u,this._z=a*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=Math.random(),t=Math.sqrt(1-e),i=Math.sqrt(e),r=2*Math.PI*Math.random(),a=2*Math.PI*Math.random();return this.set(t*Math.cos(r),i*Math.sin(a),i*Math.cos(a),t*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class W{constructor(e=0,t=0,i=0){W.prototype.isVector3=!0,this.x=e,this.y=t,this.z=i}set(e,t,i){return void 0===i&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(q.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(q.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[3]*i+a[6]*r,this.y=a[1]*t+a[4]*i+a[7]*r,this.z=a[2]*t+a[5]*i+a[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,r=this.z,a=e.elements,n=1/(a[3]*t+a[7]*i+a[11]*r+a[15]);return this.x=(a[0]*t+a[4]*i+a[8]*r+a[12])*n,this.y=(a[1]*t+a[5]*i+a[9]*r+a[13])*n,this.z=(a[2]*t+a[6]*i+a[10]*r+a[14])*n,this}applyQuaternion(e){let t=this.x,i=this.y,r=this.z,a=e.x,n=e.y,s=e.z,o=e.w,l=o*t+n*r-s*i,h=o*i+s*t-a*r,c=o*r+a*i-n*t,u=-a*t-n*i-s*r;return this.x=l*o+-(u*a)+-(h*s)- -(c*n),this.y=h*o+-(u*n)+-(c*a)- -(l*s),this.z=c*o+-(u*s)+-(l*n)- -(h*a),this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,r=this.z,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*r,this.y=a[1]*t+a[5]*i+a[9]*r,this.z=a[2]*t+a[6]*i+a[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}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=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,r=e.y,a=e.z,n=t.x,s=t.y,o=t.z;return this.x=r*o-a*s,this.y=a*n-i*o,this.z=i*s-r*n,this}projectOnVector(e){let t=e.lengthSq();if(0===t)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return j.copy(this).projectOnVector(e),this.sub(j)}reflect(e){return this.sub(j.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(f(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,r=this.z-e.z;return t*t+i*i+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let r=Math.sin(t)*e;return this.x=r*Math.sin(i),this.y=Math.cos(t)*e,this.z=r*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,i=Math.sqrt(1-e**2);return this.x=i*Math.cos(t),this.y=i*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}let j=new W,q=new G;class X{constructor(e=new W(Infinity,Infinity,Infinity),t=new W(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;tthis.max.x)&&!(e.ythis.max.y)&&!(e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x)&&!(e.max.ythis.max.y)&&!(e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Z),Z.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(er),ea.subVectors(this.max,er),J.subVectors(e.a,er),Q.subVectors(e.b,er),$.subVectors(e.c,er),ee.subVectors(Q,J),et.subVectors($,Q),ei.subVectors(J,$);let t=[0,-ee.z,ee.y,0,-et.z,et.y,0,-ei.z,ei.y,ee.z,0,-ee.x,et.z,0,-et.x,ei.z,0,-ei.x,-ee.y,ee.x,0,-et.y,et.x,0,-ei.y,ei.x,0];return!!(eo(t,J,Q,$,ea)&&eo(t=[1,0,0,0,1,0,0,0,1],J,Q,$,ea))&&(en.crossVectors(ee,et),eo(t=[en.x,en.y,en.z],J,Q,$,ea))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Z).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Z).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Y[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Y[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Y[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Y[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Y[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Y[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Y[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Y[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Y)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}let Y=[new W,new W,new W,new W,new W,new W,new W,new W],Z=new W,K=new X,J=new W,Q=new W,$=new W,ee=new W,et=new W,ei=new W,er=new W,ea=new W,en=new W,es=new W;function eo(e,t,i,r,a){for(let n=0,s=e.length-3;n<=s;n+=3){es.fromArray(e,n);let s=a.x*Math.abs(es.x)+a.y*Math.abs(es.y)+a.z*Math.abs(es.z),o=t.dot(es),l=i.dot(es),h=r.dot(es);if(Math.max(-Math.max(o,l,h),Math.min(o,l,h))>s)return!1}return!0}let el=new X,eh=new W,ec=new W;class eu{constructor(e=new W,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let i=this.center;void 0!==t?i.copy(t):el.setFromPoints(e).getCenter(i);let r=0;for(let t=0,a=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;eh.subVectors(e,this.center);let t=eh.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),i=(e-this.radius)*.5;this.center.addScaledVector(eh,i/e),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(ec.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(eh.copy(e.center).add(ec)),this.expandByPoint(eh.copy(e.center).sub(ec))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}let ed=new W,ep=new W,ef=new W,em=new W,eg=new W,ev=new W,e_=new W;class ex{constructor(e=new W,t=new W(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ed)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=ed.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ed.copy(this.origin).addScaledVector(this.direction,t),ed.distanceToSquared(e))}distanceSqToSegment(e,t,i,r){let a,n,s,o;ep.copy(e).add(t).multiplyScalar(.5),ef.copy(t).sub(e).normalize(),em.copy(this.origin).sub(ep);let l=.5*e.distanceTo(t),h=-this.direction.dot(ef),c=em.dot(this.direction),u=-em.dot(ef),d=em.lengthSq(),p=Math.abs(1-h*h);if(p>0){if(a=h*u-c,n=h*c-u,o=l*p,a>=0){if(n>=-o){if(n<=o){let e=1/p;a*=e,n*=e,s=a*(a+h*n+2*c)+n*(h*a+n+2*u)+d}else s=-(a=Math.max(0,-(h*(n=l)+c)))*a+n*(n+2*u)+d}else s=-(a=Math.max(0,-(h*(n=-l)+c)))*a+n*(n+2*u)+d}else n<=-o?(n=(a=Math.max(0,-(-h*l+c)))>0?-l:Math.min(Math.max(-l,-u),l),s=-a*a+n*(n+2*u)+d):n<=o?(a=0,s=(n=Math.min(Math.max(-l,-u),l))*(n+2*u)+d):(n=(a=Math.max(0,-(h*l+c)))>0?l:Math.min(Math.max(-l,-u),l),s=-a*a+n*(n+2*u)+d)}else n=h>0?-l:l,s=-(a=Math.max(0,-(h*n+c)))*a+n*(n+2*u)+d;return i&&i.copy(this.origin).addScaledVector(this.direction,a),r&&r.copy(ep).addScaledVector(ef,n),s}intersectSphere(e,t){ed.subVectors(e.center,this.origin);let i=ed.dot(this.direction),r=ed.dot(ed)-i*i,a=e.radius*e.radius;if(r>a)return null;let n=Math.sqrt(a-r),s=i-n,o=i+n;return o<0?null:s<0?this.at(o,t):this.at(s,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;let i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){let i=this.distanceToPlane(e);return null===i?null:this.at(i,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);if(0===t)return!0;let i=e.normal.dot(this.direction);return i*t<0}intersectBox(e,t){let i,r,a,n,s,o;let l=1/this.direction.x,h=1/this.direction.y,c=1/this.direction.z,u=this.origin;return(l>=0?(i=(e.min.x-u.x)*l,r=(e.max.x-u.x)*l):(i=(e.max.x-u.x)*l,r=(e.min.x-u.x)*l),h>=0?(a=(e.min.y-u.y)*h,n=(e.max.y-u.y)*h):(a=(e.max.y-u.y)*h,n=(e.min.y-u.y)*h),i>n||a>r)?null:((a>i||isNaN(i))&&(i=a),(n=0?(s=(e.min.z-u.z)*c,o=(e.max.z-u.z)*c):(s=(e.max.z-u.z)*c,o=(e.min.z-u.z)*c),i>o||s>r)?null:((s>i||i!=i)&&(i=s),(o=0?i:r,t)}intersectsBox(e){return null!==this.intersectBox(e,ed)}intersectTriangle(e,t,i,r,a){let n;eg.subVectors(t,e),ev.subVectors(i,e),e_.crossVectors(eg,ev);let s=this.direction.dot(e_);if(s>0){if(r)return null;n=1}else{if(!(s<0))return null;n=-1,s=-s}em.subVectors(this.origin,e);let o=n*this.direction.dot(ev.crossVectors(em,ev));if(o<0)return null;let l=n*this.direction.dot(eg.cross(em));if(l<0||o+l>s)return null;let h=-n*em.dot(e_);return h<0?null:this.at(h/s,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class ey{constructor(e,t,i,r,a,n,s,o,l,h,c,u,d,p,f,m){ey.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,i,r,a,n,s,o,l,h,c,u,d,p,f,m)}set(e,t,i,r,a,n,s,o,l,h,c,u,d,p,f,m){let g=this.elements;return g[0]=e,g[4]=t,g[8]=i,g[12]=r,g[1]=a,g[5]=n,g[9]=s,g[13]=o,g[2]=l,g[6]=h,g[10]=c,g[14]=u,g[3]=d,g[7]=p,g[11]=f,g[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 ey().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,i=e.elements,r=1/eM.setFromMatrixColumn(e,0).length(),a=1/eM.setFromMatrixColumn(e,1).length(),n=1/eM.setFromMatrixColumn(e,2).length();return t[0]=i[0]*r,t[1]=i[1]*r,t[2]=i[2]*r,t[3]=0,t[4]=i[4]*a,t[5]=i[5]*a,t[6]=i[6]*a,t[7]=0,t[8]=i[8]*n,t[9]=i[9]*n,t[10]=i[10]*n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,r=e.y,a=e.z,n=Math.cos(i),s=Math.sin(i),o=Math.cos(r),l=Math.sin(r),h=Math.cos(a),c=Math.sin(a);if("XYZ"===e.order){let e=n*h,i=n*c,r=s*h,a=s*c;t[0]=o*h,t[4]=-o*c,t[8]=l,t[1]=i+r*l,t[5]=e-a*l,t[9]=-s*o,t[2]=a-e*l,t[6]=r+i*l,t[10]=n*o}else if("YXZ"===e.order){let e=o*h,i=o*c,r=l*h,a=l*c;t[0]=e+a*s,t[4]=r*s-i,t[8]=n*l,t[1]=n*c,t[5]=n*h,t[9]=-s,t[2]=i*s-r,t[6]=a+e*s,t[10]=n*o}else if("ZXY"===e.order){let e=o*h,i=o*c,r=l*h,a=l*c;t[0]=e-a*s,t[4]=-n*c,t[8]=r+i*s,t[1]=i+r*s,t[5]=n*h,t[9]=a-e*s,t[2]=-n*l,t[6]=s,t[10]=n*o}else if("ZYX"===e.order){let e=n*h,i=n*c,r=s*h,a=s*c;t[0]=o*h,t[4]=r*l-i,t[8]=e*l+a,t[1]=o*c,t[5]=a*l+e,t[9]=i*l-r,t[2]=-l,t[6]=s*o,t[10]=n*o}else if("YZX"===e.order){let e=n*o,i=n*l,r=s*o,a=s*l;t[0]=o*h,t[4]=a-e*c,t[8]=r*c+i,t[1]=c,t[5]=n*h,t[9]=-s*h,t[2]=-l*h,t[6]=i*c+r,t[10]=e-a*c}else if("XZY"===e.order){let e=n*o,i=n*l,r=s*o,a=s*l;t[0]=o*h,t[4]=-c,t[8]=l*h,t[1]=e*c+a,t[5]=n*h,t[9]=i*c-r,t[2]=r*c-i,t[6]=s*h,t[10]=a*c+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(eb,e,ew)}lookAt(e,t,i){let r=this.elements;return eA.subVectors(e,t),0===eA.lengthSq()&&(eA.z=1),eA.normalize(),eT.crossVectors(i,eA),0===eT.lengthSq()&&(1===Math.abs(i.z)?eA.x+=1e-4:eA.z+=1e-4,eA.normalize(),eT.crossVectors(i,eA)),eT.normalize(),eE.crossVectors(eA,eT),r[0]=eT.x,r[4]=eE.x,r[8]=eA.x,r[1]=eT.y,r[5]=eE.y,r[9]=eA.y,r[2]=eT.z,r[6]=eE.z,r[10]=eA.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,r=t.elements,a=this.elements,n=i[0],s=i[4],o=i[8],l=i[12],h=i[1],c=i[5],u=i[9],d=i[13],p=i[2],f=i[6],m=i[10],g=i[14],v=i[3],_=i[7],x=i[11],y=i[15],M=r[0],S=r[4],b=r[8],w=r[12],T=r[1],E=r[5],A=r[9],C=r[13],L=r[2],P=r[6],R=r[10],D=r[14],U=r[3],I=r[7],N=r[11],O=r[15];return a[0]=n*M+s*T+o*L+l*U,a[4]=n*S+s*E+o*P+l*I,a[8]=n*b+s*A+o*R+l*N,a[12]=n*w+s*C+o*D+l*O,a[1]=h*M+c*T+u*L+d*U,a[5]=h*S+c*E+u*P+d*I,a[9]=h*b+c*A+u*R+d*N,a[13]=h*w+c*C+u*D+d*O,a[2]=p*M+f*T+m*L+g*U,a[6]=p*S+f*E+m*P+g*I,a[10]=p*b+f*A+m*R+g*N,a[14]=p*w+f*C+m*D+g*O,a[3]=v*M+_*T+x*L+y*U,a[7]=v*S+_*E+x*P+y*I,a[11]=v*b+_*A+x*R+y*N,a[15]=v*w+_*C+x*D+y*O,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],r=e[8],a=e[12],n=e[1],s=e[5],o=e[9],l=e[13],h=e[2],c=e[6],u=e[10],d=e[14],p=e[3],f=e[7],m=e[11],g=e[15];return p*(+a*o*c-r*l*c-a*s*u+i*l*u+r*s*d-i*o*d)+f*(+t*o*d-t*l*u+a*n*u-r*n*d+r*l*h-a*o*h)+m*(+t*l*c-t*s*d-a*n*c+i*n*d+a*s*h-i*l*h)+g*(-r*s*h-t*o*c+t*s*u+r*n*c-i*n*u+i*o*h)}transpose(){let e;let t=this.elements;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(e,t,i){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],r=e[2],a=e[3],n=e[4],s=e[5],o=e[6],l=e[7],h=e[8],c=e[9],u=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=c*m*l-f*u*l+f*o*d-s*m*d-c*o*g+s*u*g,_=p*u*l-h*m*l-p*o*d+n*m*d+h*o*g-n*u*g,x=h*f*l-p*c*l+p*s*d-n*f*d-h*s*g+n*c*g,y=p*c*o-h*f*o-p*s*u+n*f*u+h*s*m-n*c*m,M=t*v+i*_+r*x+a*y;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/M;return e[0]=v*S,e[1]=(f*u*a-c*m*a-f*r*d+i*m*d+c*r*g-i*u*g)*S,e[2]=(s*m*a-f*o*a+f*r*l-i*m*l-s*r*g+i*o*g)*S,e[3]=(c*o*a-s*u*a-c*r*l+i*u*l+s*r*d-i*o*d)*S,e[4]=_*S,e[5]=(h*m*a-p*u*a+p*r*d-t*m*d-h*r*g+t*u*g)*S,e[6]=(p*o*a-n*m*a-p*r*l+t*m*l+n*r*g-t*o*g)*S,e[7]=(n*u*a-h*o*a+h*r*l-t*u*l-n*r*d+t*o*d)*S,e[8]=x*S,e[9]=(p*c*a-h*f*a-p*i*d+t*f*d+h*i*g-t*c*g)*S,e[10]=(n*f*a-p*s*a+p*i*l-t*f*l-n*i*g+t*s*g)*S,e[11]=(h*s*a-n*c*a-h*i*l+t*c*l+n*i*d-t*s*d)*S,e[12]=y*S,e[13]=(h*f*r-p*c*r+p*i*u-t*f*u-h*i*m+t*c*m)*S,e[14]=(p*s*r-n*f*r-p*i*o+t*f*o+n*i*m-t*s*m)*S,e[15]=(n*c*r-h*s*r+h*i*o-t*c*o-n*i*u+t*s*u)*S,this}scale(e){let t=this.elements,i=e.x,r=e.y,a=e.z;return t[0]*=i,t[4]*=r,t[8]*=a,t[1]*=i,t[5]*=r,t[9]*=a,t[2]*=i,t[6]*=r,t[10]*=a,t[3]*=i,t[7]*=r,t[11]*=a,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,r))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),r=Math.sin(t),a=1-i,n=e.x,s=e.y,o=e.z,l=a*n,h=a*s;return this.set(l*n+i,l*s-r*o,l*o+r*s,0,l*s+r*o,h*s+i,h*o-r*n,0,l*o-r*s,h*o+r*n,a*o*o+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,r,a,n){return this.set(1,i,a,0,e,1,n,0,t,r,1,0,0,0,0,1),this}compose(e,t,i){let r=this.elements,a=t._x,n=t._y,s=t._z,o=t._w,l=a+a,h=n+n,c=s+s,u=a*l,d=a*h,p=a*c,f=n*h,m=n*c,g=s*c,v=o*l,_=o*h,x=o*c,y=i.x,M=i.y,S=i.z;return r[0]=(1-(f+g))*y,r[1]=(d+x)*y,r[2]=(p-_)*y,r[3]=0,r[4]=(d-x)*M,r[5]=(1-(u+g))*M,r[6]=(m+v)*M,r[7]=0,r[8]=(p+_)*S,r[9]=(m-v)*S,r[10]=(1-(u+f))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,i){let r=this.elements,a=eM.set(r[0],r[1],r[2]).length(),n=eM.set(r[4],r[5],r[6]).length(),s=eM.set(r[8],r[9],r[10]).length(),o=this.determinant();o<0&&(a=-a),e.x=r[12],e.y=r[13],e.z=r[14],eS.copy(this);let l=1/a,h=1/n,c=1/s;return eS.elements[0]*=l,eS.elements[1]*=l,eS.elements[2]*=l,eS.elements[4]*=h,eS.elements[5]*=h,eS.elements[6]*=h,eS.elements[8]*=c,eS.elements[9]*=c,eS.elements[10]*=c,t.setFromRotationMatrix(eS),i.x=a,i.y=n,i.z=s,this}makePerspective(e,t,i,r,a,n,s=2e3){let o,l;let h=this.elements;if(2e3===s)o=-(n+a)/(n-a),l=-2*n*a/(n-a);else if(2001===s)o=-n/(n-a),l=-n*a/(n-a);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);return h[0]=2*a/(t-e),h[4]=0,h[8]=(t+e)/(t-e),h[12]=0,h[1]=0,h[5]=2*a/(i-r),h[9]=(i+r)/(i-r),h[13]=0,h[2]=0,h[6]=0,h[10]=o,h[14]=l,h[3]=0,h[7]=0,h[11]=-1,h[15]=0,this}makeOrthographic(e,t,i,r,a,n,s=2e3){let o,l;let h=this.elements,c=1/(t-e),u=1/(i-r),d=1/(n-a);if(2e3===s)o=(n+a)*d,l=-2*d;else if(2001===s)o=a*d,l=-1*d;else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);return h[0]=2*c,h[4]=0,h[8]=0,h[12]=-((t+e)*c),h[1]=0,h[5]=2*u,h[9]=0,h[13]=-((i+r)*u),h[2]=0,h[6]=0,h[10]=l,h[14]=-o,h[3]=0,h[7]=0,h[11]=0,h[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let e=0;e<16;e++)if(t[e]!==i[e])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}}let eM=new W,eS=new ey,eb=new W(0,0,0),ew=new W(1,1,1),eT=new W,eE=new W,eA=new W,eC=new ey,eL=new G;class eP{constructor(e=0,t=0,i=0,r=eP.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=i,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,r=this._order){return this._x=e,this._y=t,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){let r=e.elements,a=r[0],n=r[4],s=r[8],o=r[1],l=r[5],h=r[9],c=r[2],u=r[6],d=r[10];switch(t){case"XYZ":this._y=Math.asin(f(s,-1,1)),.9999999>Math.abs(s)?(this._x=Math.atan2(-h,d),this._z=Math.atan2(-n,a)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-f(h,-1,1)),.9999999>Math.abs(h)?(this._y=Math.atan2(s,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,a),this._z=0);break;case"ZXY":this._x=Math.asin(f(u,-1,1)),.9999999>Math.abs(u)?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-n,l)):(this._y=0,this._z=Math.atan2(o,a));break;case"ZYX":this._y=Math.asin(-f(c,-1,1)),.9999999>Math.abs(c)?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,a)):(this._x=0,this._z=Math.atan2(-n,l));break;case"YZX":this._z=Math.asin(f(o,-1,1)),.9999999>Math.abs(o)?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-c,a)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-f(n,-1,1)),.9999999>Math.abs(n)?(this._x=Math.atan2(u,l),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-h,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===i&&this._onChangeCallback(),this}setFromQuaternion(e,t,i){return eC.makeRotationFromQuaternion(e),this.setFromRotationMatrix(eC,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return eL.setFromEuler(this),this.setFromQuaternion(eL,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}eP.DEFAULT_ORDER="XYZ";class eR{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i=i.concat(a))}return i}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ez,e,eF),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ez,ek,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);let t=this.children;for(let i=0,r=t.length;i0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=a(e.geometries,this.geometry);let t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){let i=t.shapes;if(Array.isArray(i))for(let t=0,r=i.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(i.geometries=t),r.length>0&&(i.materials=r),a.length>0&&(i.textures=a),s.length>0&&(i.images=s),o.length>0&&(i.shapes=o),l.length>0&&(i.skeletons=l),h.length>0&&(i.animations=h),c.length>0&&(i.nodes=c)}return i.object=r,i;function n(e){let t=[];for(let i in e){let r=e[i];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?r.multiplyScalar(1/Math.sqrt(a)):r.set(0,0,0)}static getBarycoord(e,t,i,r,a){eq.subVectors(r,t),eX.subVectors(i,t),eY.subVectors(e,t);let n=eq.dot(eq),s=eq.dot(eX),o=eq.dot(eY),l=eX.dot(eX),h=eX.dot(eY),c=n*l-s*s;if(0===c)return a.set(-2,-1,-1);let u=1/c,d=(l*o-s*h)*u,p=(n*h-s*o)*u;return a.set(1-d-p,p,d)}static containsPoint(e,t,i,r){return this.getBarycoord(e,t,i,r,eZ),eZ.x>=0&&eZ.y>=0&&eZ.x+eZ.y<=1}static getUV(e,t,i,r,a,n,s,o){return!1===e3&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),e3=!0),this.getInterpolation(e,t,i,r,a,n,s,o)}static getInterpolation(e,t,i,r,a,n,s,o){return this.getBarycoord(e,t,i,r,eZ),o.setScalar(0),o.addScaledVector(a,eZ.x),o.addScaledVector(n,eZ.y),o.addScaledVector(s,eZ.z),o}static isFrontFacing(e,t,i,r){return eq.subVectors(i,t),eX.subVectors(e,t),0>eq.cross(eX).dot(r)}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,r){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,i,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return eq.subVectors(this.c,this.b),eX.subVectors(this.a,this.b),.5*eq.cross(eX).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return e2.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return e2.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,i,r,a){return!1===e3&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),e3=!0),e2.getInterpolation(e,this.a,this.b,this.c,t,i,r,a)}getInterpolation(e,t,i,r,a){return e2.getInterpolation(e,this.a,this.b,this.c,t,i,r,a)}containsPoint(e){return e2.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return e2.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let i,r;let a=this.a,n=this.b,s=this.c;eK.subVectors(n,a),eJ.subVectors(s,a),e$.subVectors(e,a);let o=eK.dot(e$),l=eJ.dot(e$);if(o<=0&&l<=0)return t.copy(a);e0.subVectors(e,n);let h=eK.dot(e0),c=eJ.dot(e0);if(h>=0&&c<=h)return t.copy(n);let u=o*c-h*l;if(u<=0&&o>=0&&h<=0)return i=o/(o-h),t.copy(a).addScaledVector(eK,i);e1.subVectors(e,s);let d=eK.dot(e1),p=eJ.dot(e1);if(p>=0&&d<=p)return t.copy(s);let f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return r=l/(l-p),t.copy(a).addScaledVector(eJ,r);let m=h*p-d*c;if(m<=0&&c-h>=0&&d-p>=0)return eQ.subVectors(s,n),r=(c-h)/(c-h+(d-p)),t.copy(n).addScaledVector(eQ,r);let g=1/(m+f+u);return i=f*g,r=u*g,t.copy(a).addScaledVector(eK,i).addScaledVector(eJ,r)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let e4=0;class e5 extends h{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:e4++}),this.uuid=p(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=100,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=7680,this.stencilZFail=7680,this.stencilZPass=7680,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.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(let t in e){let i=e[t];if(void 0===i){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(void 0===r){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(i):r&&r.isVector3&&i&&i.isVector3?r.copy(i):this[t]=i}}toJSON(e){let t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});let i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function r(e){let t=[];for(let i in e){let r=e[i];delete r.metadata,t.push(r)}return t}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=this.alphaHash),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(i.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=this.flatShading),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),t){let t=r(e.textures),a=r(e.images);t.length>0&&(i.textures=t),a.length>0&&(i.images=a)}return i}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,i=null;if(null!==t){let e=t.length;i=Array(e);for(let r=0;r!==e;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}let e6={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},e8={h:0,s:0,l:0},e7={h:0,s:0,l:0};function e9(e,t,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?e+(t-e)*6*i:i<.5?t:i<2/3?e+(t-e)*6*(2/3-i):e}class te{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){return void 0===t&&void 0===i?e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e):this.setRGB(e,t,i),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=n){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,D.toWorkingColorSpace(this,t),this}setRGB(e,t,i,r=D.workingColorSpace){return this.r=e,this.g=t,this.b=i,D.toWorkingColorSpace(this,r),this}setHSL(e,t,i,r=D.workingColorSpace){if(e=(e%1+1)%1,t=f(t,0,1),i=f(i,0,1),0===t)this.r=this.g=this.b=i;else{let r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=e9(a,r,e+1/3),this.g=e9(a,r,e),this.b=e9(a,r,e-1/3)}return D.toWorkingColorSpace(this,r),this}setStyle(e,t=n){let i;function r(t){void 0!==t&&1>parseFloat(t)&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;let n=i[1],s=i[2];switch(n){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,t);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,t);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=i[1],a=r.length;if(3===a)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(6===a)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=n){let i=e6[e.toLowerCase()];return void 0!==i?this.setHex(i,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=E(e.r),this.g=E(e.g),this.b=E(e.b),this}copyLinearToSRGB(e){return this.r=A(e.r),this.g=A(e.g),this.b=A(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=n){return D.fromWorkingColorSpace(tt.copy(this),e),65536*Math.round(f(255*tt.r,0,255))+256*Math.round(f(255*tt.g,0,255))+Math.round(f(255*tt.b,0,255))}getHexString(e=n){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=D.workingColorSpace){let i,r;D.fromWorkingColorSpace(tt.copy(this),t);let a=tt.r,n=tt.g,s=tt.b,o=Math.max(a,n,s),l=Math.min(a,n,s),h=(l+o)/2;if(l===o)i=0,r=0;else{let e=o-l;switch(r=h<=.5?e/(o+l):e/(2-o-l),o){case a:i=(n-s)/e+(n0&&(e.userData=this.userData),void 0!==this.parameters){let t=this.parameters;for(let i in t)void 0!==t[i]&&(e[i]=t[i]);return e}e.data={attributes:{}};let t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let i=this.attributes;for(let t in i){let r=i[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},a=!1;for(let t in this.morphAttributes){let i=this.morphAttributes[t],n=[];for(let t=0,r=i.length;t0&&(r[t]=n,a=!0)}a&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let n=this.groups;n.length>0&&(e.data.groups=JSON.parse(JSON.stringify(n)));let s=this.boundingSphere;return null!==s&&(e.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let i=e.index;null!==i&&this.setIndex(i.clone(t));let r=e.attributes;for(let e in r){let i=r[e];this.setAttribute(e,i.clone(t))}let a=e.morphAttributes;for(let e in a){let i=[],r=a[e];for(let e=0,a=r.length;e0){let e=t[i[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,i=e.length;t(e.far-e.near)**2)||(tv.copy(a).invert(),t_.copy(e.ray).applyMatrix4(tv),null!==i.boundingBox&&!1===t_.intersectsBox(i.boundingBox)))return;this._computeIntersections(e,t,t_)}}_computeIntersections(e,t,i){let r;let a=this.geometry,n=this.material,s=a.index,o=a.attributes.position,l=a.attributes.uv,h=a.attributes.uv1,c=a.attributes.normal,u=a.groups,d=a.drawRange;if(null!==s){if(Array.isArray(n))for(let a=0,o=u.length;ai.far?null:{distance:l,point:tU.clone(),object:e}}(e,t,i,r,tM,tS,tb,tD);if(c){a&&(tE.fromBufferAttribute(a,o),tA.fromBufferAttribute(a,l),tC.fromBufferAttribute(a,h),c.uv=e2.getInterpolation(tD,tM,tS,tb,tE,tA,tC,new x)),n&&(tE.fromBufferAttribute(n,o),tA.fromBufferAttribute(n,l),tC.fromBufferAttribute(n,h),c.uv1=e2.getInterpolation(tD,tM,tS,tb,tE,tA,tC,new x),c.uv2=c.uv1),s&&(tL.fromBufferAttribute(s,o),tP.fromBufferAttribute(s,l),tR.fromBufferAttribute(s,h),c.normal=e2.getInterpolation(tD,tM,tS,tb,tL,tP,tR,new W),c.normal.dot(r.direction)>0&&c.normal.multiplyScalar(-1));let e={a:o,b:l,c:h,normal:new W,materialIndex:0};e2.getNormal(tM,tS,tb,e.normal),c.face=e}return c}class tO extends tg{constructor(e=1,t=1,i=1,r=1,a=1,n=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:i,widthSegments:r,heightSegments:a,depthSegments:n};let s=this;r=Math.floor(r),a=Math.floor(a),n=Math.floor(n);let o=[],l=[],h=[],c=[],u=0,d=0;function p(e,t,i,r,a,n,p,f,m,g,v){let _=n/m,x=p/g,y=n/2,M=p/2,S=f/2,b=m+1,w=g+1,T=0,E=0,A=new W;for(let n=0;n0?1:-1,h.push(A.x,A.y,A.z),c.push(o/m),c.push(1-n/g),T+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let i={};for(let e in this.extensions)!0===this.extensions[e]&&(i[e]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}}class tV extends ej{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ey,this.projectionMatrix=new ey,this.projectionMatrixInverse=new ey,this.coordinateSystem=2e3}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class tG extends tV{constructor(e=50,t=1,i=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=2*d*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*u*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*d*Math.atan(Math.tan(.5*u*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,r,a,n){this.aspect=e/t,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=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(.5*u*this.fov)/this.zoom,i=2*t,r=this.aspect*i,a=-.5*r,n=this.view;if(null!==this.view&&this.view.enabled){let e=n.fullWidth,s=n.fullHeight;a+=n.offsetX*r/e,t-=n.offsetY*i/s,r*=n.width/e,i*=n.height/s}let s=this.filmOffset;0!==s&&(a+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,t,t-i,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class tW extends ej{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null;let r=new tG(-90,1,e,t);r.layers=this.layers,this.add(r);let a=new tG(-90,1,e,t);a.layers=this.layers,this.add(a);let n=new tG(-90,1,e,t);n.layers=this.layers,this.add(n);let s=new tG(-90,1,e,t);s.layers=this.layers,this.add(s);let o=new tG(-90,1,e,t);o.layers=this.layers,this.add(o);let l=new tG(-90,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[i,r,a,n,s,o]=t;for(let e of t)this.remove(e);if(2e3===e)i.up.set(0,1,0),i.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),n.up.set(0,0,1),n.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(2001===e)i.up.set(0,-1,0),i.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),n.up.set(0,0,-1),n.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();let i=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,a,n,s,o,l]=this.children,h=e.getRenderTarget(),c=e.xr.enabled;e.xr.enabled=!1;let u=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,e.setRenderTarget(i,0),e.render(t,r),e.setRenderTarget(i,1),e.render(t,a),e.setRenderTarget(i,2),e.render(t,n),e.setRenderTarget(i,3),e.render(t,s),e.setRenderTarget(i,4),e.render(t,o),i.texture.generateMipmaps=u,e.setRenderTarget(i,5),e.render(t,l),e.setRenderTarget(h),e.xr.enabled=c,i.texture.needsPMREMUpdate=!0}}class tj extends F{constructor(e,t,i,r,a,n,s,o,l,h){super(e=void 0!==e?e:[],t=void 0!==t?t:301,i,r,a,n,s,o,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class tq extends H{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let i={width:e,height:e,depth:1};void 0!==t.encoding&&(T("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=3001===t.encoding?n:""),this.texture=new tj([i,i,i,i,i,i],t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:1006}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:`varying vec3 vWorldDirection;vec3 transformDirection(in vec3 dir,in mat4 matrix){return normalize((matrix*vec4(dir,0.0)).xyz);}void main(){vWorldDirection=transformDirection(position,modelMatrix); #include #include }`,fragmentShader:`uniform sampler2D tEquirect;varying vec3 vWorldDirection; #include void main(){vec3 direction=normalize(vWorldDirection);vec2 sampleUV=equirectUv(direction);gl_FragColor=texture2D(tEquirect,sampleUV);}`},r=new tO(5,5,5),a=new tH({name:"CubemapFromEquirect",uniforms:tz(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});a.uniforms.tEquirect.value=t;let n=new tI(r,a),s=t.minFilter;1008===t.minFilter&&(t.minFilter=1006);let o=new tW(1,10,this);return o.update(e,n),t.minFilter=s,n.geometry.dispose(),n.material.dispose(),this}clear(e,t,i,r){let a=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,r);e.setRenderTarget(a)}}let tX=new W,tY=new W,tZ=new y;class tK{constructor(e=new W(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,r){return this.normal.set(e,t,i),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let r=tX.subVectors(i,t).cross(tY.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let i=e.delta(tX),r=this.normal.dot(i);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;let a=-(e.start.dot(this.normal)+this.constant)/r;return a<0||a>1?null:t.copy(e.start).addScaledVector(i,a)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||tZ.getNormalMatrix(e),r=this.coplanarPoint(tX).applyMatrix4(e),a=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}let tJ=new eu,tQ=new W;class t${constructor(e=new tK,t=new tK,i=new tK,r=new tK,a=new tK,n=new tK){this.planes=[e,t,i,r,a,n]}set(e,t,i,r,a,n){let s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(i),s[3].copy(r),s[4].copy(a),s[5].copy(n),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=2e3){let i=this.planes,r=e.elements,a=r[0],n=r[1],s=r[2],o=r[3],l=r[4],h=r[5],c=r[6],u=r[7],d=r[8],p=r[9],f=r[10],m=r[11],g=r[12],v=r[13],_=r[14],x=r[15];if(i[0].setComponents(o-a,u-l,m-d,x-g).normalize(),i[1].setComponents(o+a,u+l,m+d,x+g).normalize(),i[2].setComponents(o+n,u+h,m+p,x+v).normalize(),i[3].setComponents(o-n,u-h,m-p,x-v).normalize(),i[4].setComponents(o-s,u-c,m-f,x-_).normalize(),2e3===t)i[5].setComponents(o+s,u+c,m+f,x+_).normalize();else if(2001===t)i[5].setComponents(s,c,f,_).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),tJ.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),tJ.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(tJ)}intersectsSprite(e){return tJ.center.set(0,0,0),tJ.radius=.7071067811865476,tJ.applyMatrix4(e.matrixWorld),this.intersectsSphere(tJ)}intersectsSphere(e){let t=this.planes,i=e.center,r=-e.radius;for(let e=0;e<6;e++){let a=t[e].distanceToPoint(i);if(a0?e.max.x:e.min.x,tQ.y=r.normal.y>0?e.max.y:e.min.y,tQ.z=r.normal.z>0?e.max.z:e.min.z,0>r.distanceToPoint(tQ))return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(0>t[i].distanceToPoint(e))return!1;return!0}clone(){return new this.constructor().copy(this)}}function t0(){let e=null,t=!1,i=null,r=null;function a(t,n){i(t,n),r=e.requestAnimationFrame(a)}return{start:function(){!0!==t&&null!==i&&(r=e.requestAnimationFrame(a),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){i=e},setContext:function(t){e=t}}}function t1(e,t){let i=t.isWebGL2,r=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);let i=r.get(t);i&&(e.deleteBuffer(i.buffer),r.delete(t))},update:function(t,a){if(t.isGLBufferAttribute){let e=r.get(t);(!e||e.version0 vec4 plane; #pragma unroll_loop_start for(int i=0;iplane.w)discard;} #pragma unroll_loop_end #if UNION_CLIPPING_PLANESplane.w)&&clipped;} #pragma unroll_loop_end if(clipped)discard; #endif #endif`,io=`#if NUM_CLIPPING_PLANES>0 varying vec3 vClipPosition;uniform vec4 clippingPlanes[NUM_CLIPPING_PLANES]; #endif`,il=`#if NUM_CLIPPING_PLANES>0 varying vec3 vClipPosition; #endif`,ih=`#if NUM_CLIPPING_PLANES>0 vClipPosition=-mvPosition.xyz; #endif`,ic=`#if defined(USE_COLOR_ALPHA) diffuseColor*=vColor; #elif defined(USE_COLOR) diffuseColor.rgb*=vColor; #endif`,iu=`#if defined(USE_COLOR_ALPHA) varying vec4 vColor; #elif defined(USE_COLOR) varying vec3 vColor; #endif`,id=`#if defined(USE_COLOR_ALPHA) varying vec4 vColor; #elif defined(USE_COLOR)||defined(USE_INSTANCING_COLOR) varying vec3 vColor; #endif`,ip=`#if defined(USE_COLOR_ALPHA) vColor=vec4(1.0); #elif defined(USE_COLOR)||defined(USE_INSTANCING_COLOR) vColor=vec3(1.0); #endif #ifdef USE_COLOR vColor*=color; #endif #ifdef USE_INSTANCING_COLOR vColor.xyz*=instanceColor.xyz; #endif`,im=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate(a)clamp(a,0.0,1.0) #endif #define whiteComplement(a)(1.0-saturate(a)) float pow2(const in float x){return x*x;}vec3 pow2(const in vec3 x){return x*x;}float pow3(const in float x){return x*x*x;}float pow4(const in float x){float x2=x*x;return x2*x2;}float max3(const in vec3 v){return max(max(v.x,v.y),v.z);}float average(const in vec3 v){return dot(v,vec3(0.3333333));}highp float rand(const in vec2 uv){const highp float a=12.9898,b=78.233,c=43758.5453;highp float dt=dot(uv.xy,vec2(a,b)),sn=mod(dt,PI);return fract(sin(sn)*c);} #ifdef HIGH_PRECISION float precisionSafeLength(vec3 v){return length(v);} #else float precisionSafeLength(vec3 v){float maxComponent=max3(abs(v));return length(v/maxComponent)*maxComponent;} #endif struct IncidentLight{vec3 color;vec3 direction;bool visible;};struct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct GeometricContext{vec3 position;vec3 normal;vec3 viewDir; #ifdef USE_CLEARCOAT vec3 clearcoatNormal; #endif }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection(in vec3 dir,in mat4 matrix){return normalize((matrix*vec4(dir,0.0)).xyz);}vec3 inverseTransformDirection(in vec3 dir,in mat4 matrix){return normalize((vec4(dir,0.0)*matrix).xyz);}mat3 transposeMat3(const in mat3 m){mat3 tmp;tmp[0]=vec3(m[0].x,m[1].x,m[2].x);tmp[1]=vec3(m[0].y,m[1].y,m[2].y);tmp[2]=vec3(m[0].z,m[1].z,m[2].z);return tmp;}float luminance(const in vec3 rgb){const vec3 weights=vec3(0.2126729,0.7151522,0.0721750);return dot(weights,rgb);}bool isPerspectiveMatrix(mat4 m){return m[2][3]==-1.0;}vec2 equirectUv(in vec3 dir){float u=atan(dir.z,dir.x)*RECIPROCAL_PI2+0.5;float v=asin(clamp(dir.y,-1.0,1.0))*RECIPROCAL_PI+0.5;return vec2(u,v);}vec3 BRDF_Lambert(const in vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}vec3 F_Schlick(const in vec3 f0,const in float f90,const in float dotVH){float fresnel=exp2((-5.55473*dotVH-6.98316)*dotVH);return f0*(1.0-fresnel)+(f90*fresnel);}float F_Schlick(const in float f0,const in float f90,const in float dotVH){float fresnel=exp2((-5.55473*dotVH-6.98316)*dotVH);return f0*(1.0-fresnel)+(f90*fresnel);}`,ig=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace(vec3 direction){vec3 absDirection=abs(direction);float face=-1.0;if(absDirection.x>absDirection.z){if(absDirection.x>absDirection.y)face=direction.x>0.0?0.0:3.0;else face=direction.y>0.0?1.0:4.0;}else{if(absDirection.z>absDirection.y)face=direction.z>0.0?2.0:5.0;else face=direction.y>0.0?1.0:4.0;}return face;}vec2 getUV(vec3 direction,float face){vec2 uv;if(face==0.0){uv=vec2(direction.z,direction.y)/abs(direction.x);}else if(face==1.0){uv=vec2(-direction.x,-direction.z)/abs(direction.y);}else if(face==2.0){uv=vec2(-direction.x,direction.y)/abs(direction.z);}else if(face==3.0){uv=vec2(-direction.z,direction.y)/abs(direction.x);}else if(face==4.0){uv=vec2(-direction.x,direction.z)/abs(direction.y);}else{uv=vec2(direction.x,direction.y)/abs(direction.z);}return 0.5*(uv+1.0);}vec3 bilinearCubeUV(sampler2D envMap,vec3 direction,float mipInt){float face=getFace(direction);float filterInt=max(cubeUV_minMipLevel-mipInt,0.0);mipInt=max(mipInt,cubeUV_minMipLevel);float faceSize=exp2(mipInt);highp vec2 uv=getUV(direction,face)*(faceSize-2.0)+1.0;if(face>2.0){uv.y+=faceSize;face-=3.0;}uv.x+=face*faceSize;uv.x+=filterInt*3.0*cubeUV_minTileSize;uv.y+=4.0*(exp2(CUBEUV_MAX_MIP)-faceSize);uv.x*=CUBEUV_TEXEL_WIDTH;uv.y*=CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT(envMap,uv,vec2(0.0),vec2(0.0)).rgb; #else return texture2D(envMap,uv).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_v0 0.339 #define cubeUV_m0-2.0 #define cubeUV_r1 0.8 #define cubeUV_v1 0.276 #define cubeUV_m1-1.0 #define cubeUV_r4 0.4 #define cubeUV_v4 0.046 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_v5 0.016 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_v6 0.0038 #define cubeUV_m6 4.0 float roughnessToMip(float roughness){float mip=0.0;if(roughness>=cubeUV_r1){mip=(cubeUV_r0-roughness)*(cubeUV_m1-cubeUV_m0)/(cubeUV_r0-cubeUV_r1)+cubeUV_m0;}else if(roughness>=cubeUV_r4){mip=(cubeUV_r1-roughness)*(cubeUV_m4-cubeUV_m1)/(cubeUV_r1-cubeUV_r4)+cubeUV_m1;}else if(roughness>=cubeUV_r5){mip=(cubeUV_r4-roughness)*(cubeUV_m5-cubeUV_m4)/(cubeUV_r4-cubeUV_r5)+cubeUV_m4;}else if(roughness>=cubeUV_r6){mip=(cubeUV_r5-roughness)*(cubeUV_m6-cubeUV_m5)/(cubeUV_r5-cubeUV_r6)+cubeUV_m5;}else{mip=-2.0*log2(1.16*roughness);}return mip;}vec4 textureCubeUV(sampler2D envMap,vec3 sampleDir,float roughness){float mip=clamp(roughnessToMip(roughness),cubeUV_m0,CUBEUV_MAX_MIP);float mipF=fract(mip);float mipInt=floor(mip);vec3 color0=bilinearCubeUV(envMap,sampleDir,mipInt);if(mipF==0.0){return vec4(color0,1.0);}else{vec3 color1=bilinearCubeUV(envMap,sampleDir,mipInt+1.0);return vec4(mix(color0,color1,mipF),1.0);}} #endif`,iv=`vec3 transformedNormal=objectNormal; #ifdef USE_INSTANCING mat3 m=mat3(instanceMatrix);transformedNormal/=vec3(dot(m[0],m[0]),dot(m[1],m[1]),dot(m[2],m[2]));transformedNormal=m*transformedNormal; #endif transformedNormal=normalMatrix*transformedNormal; #ifdef FLIP_SIDED transformedNormal=-transformedNormal; #endif #ifdef USE_TANGENT vec3 transformedTangent=(modelViewMatrix*vec4(objectTangent,0.0)).xyz; #ifdef FLIP_SIDED transformedTangent=-transformedTangent; #endif #endif`,i_=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap;uniform float displacementScale;uniform float displacementBias; #endif`,ix=`#ifdef USE_DISPLACEMENTMAP transformed+=normalize(objectNormal)*(texture2D(displacementMap,vDisplacementMapUv).x*displacementScale+displacementBias); #endif`,iy=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor=texture2D(emissiveMap,vEmissiveMapUv);totalEmissiveRadiance*=emissiveColor.rgb; #endif`,iM=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,iS=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag;if(isOrthographic){cameraToFrag=normalize(vec3(-viewMatrix[0][2],-viewMatrix[1][2],-viewMatrix[2][2]));}else{cameraToFrag=normalize(vWorldPosition-cameraPosition);}vec3 worldNormal=inverseTransformDirection(normal,viewMatrix); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec=reflect(cameraToFrag,worldNormal); #else vec3 reflectVec=refract(cameraToFrag,worldNormal,refractionRatio); #endif #else vec3 reflectVec=vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor=textureCube(envMap,vec3(flipEnvMap*reflectVec.x,reflectVec.yz)); #else vec4 envColor=vec4(0.0); #endif #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight=mix(outgoingLight,outgoingLight*envColor.xyz,specularStrength*reflectivity); #elif defined(ENVMAP_BLENDING_MIX) outgoingLight=mix(outgoingLight,envColor.xyz,specularStrength*reflectivity); #elif defined(ENVMAP_BLENDING_ADD) outgoingLight+=envColor.xyz*specularStrength*reflectivity; #endif #endif`,ib=`#ifdef USE_ENVMAP uniform float envMapIntensity;uniform float flipEnvMap; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,iw=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined(USE_BUMPMAP)||defined(USE_NORMALMAP)||defined(PHONG)||defined(LAMBERT) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition;uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,iT=`#ifdef USE_ENVMAP #if defined(USE_BUMPMAP)||defined(USE_NORMALMAP)||defined(PHONG)||defined(LAMBERT) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect;uniform float refractionRatio; #endif #endif`,iE=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition=worldPosition.xyz; #else vec3 cameraToVertex;if(isOrthographic){cameraToVertex=normalize(vec3(-viewMatrix[0][2],-viewMatrix[1][2],-viewMatrix[2][2]));}else{cameraToVertex=normalize(worldPosition.xyz-cameraPosition);}vec3 worldNormal=inverseTransformDirection(transformedNormal,viewMatrix); #ifdef ENVMAP_MODE_REFLECTION vReflect=reflect(cameraToVertex,worldNormal); #else vReflect=refract(cameraToVertex,worldNormal,refractionRatio); #endif #endif #endif`,iA=`#ifdef USE_FOG vFogDepth=-mvPosition.z; #endif`,iC=`#ifdef USE_FOG varying float vFogDepth; #endif`,iL=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor=1.0-exp(-fogDensity*fogDensity*vFogDepth*vFogDepth); #else float fogFactor=smoothstep(fogNear,fogFar,vFogDepth); #endif gl_FragColor.rgb=mix(gl_FragColor.rgb,fogColor,fogFactor); #endif`,iP=`#ifdef USE_FOG uniform vec3 fogColor;varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear;uniform float fogFar; #endif #endif`,iR=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance(vec3 normal,vec3 lightDirection){float dotNL=dot(normal,lightDirection);vec2 coord=vec2(dotNL*0.5+0.5,0.0); #ifdef USE_GRADIENTMAP return vec3(texture2D(gradientMap,coord).r); #else vec2 fw=fwidth(coord)*0.5;return mix(vec3(0.7),vec3(1.0),smoothstep(0.7-fw.x,0.7+fw.x,coord.x)); #endif }`,iD=`#ifdef USE_LIGHTMAP vec4 lightMapTexel=texture2D(lightMap,vLightMapUv);vec3 lightMapIrradiance=lightMapTexel.rgb*lightMapIntensity;reflectedLight.indirectDiffuse+=lightMapIrradiance; #endif`,iU=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap;uniform float lightMapIntensity; #endif`,iI=`varying vec3 vViewPosition;struct LambertMaterial{vec3 diffuseColor;float specularStrength;};void RE_Direct_Lambert(const in IncidentLight directLight,const in GeometricContext geometry,const in LambertMaterial material,inout ReflectedLight reflectedLight){float dotNL=saturate(dot(geometry.normal,directLight.direction));vec3 irradiance=dotNL*directLight.color;reflectedLight.directDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);}void RE_IndirectDiffuse_Lambert(const in vec3 irradiance,const in GeometricContext geometry,const in LambertMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);} #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,iN=`uniform bool receiveShadow;uniform vec3 ambientLightColor;uniform vec3 lightProbe[9];vec3 shGetIrradianceAt(in vec3 normal,in vec3 shCoefficients[9]){float x=normal.x,y=normal.y,z=normal.z;vec3 result=shCoefficients[0]*0.886227;result+=shCoefficients[1]*2.0*0.511664*y;result+=shCoefficients[2]*2.0*0.511664*z;result+=shCoefficients[3]*2.0*0.511664*x;result+=shCoefficients[4]*2.0*0.429043*x*y;result+=shCoefficients[5]*2.0*0.429043*y*z;result+=shCoefficients[6]*(0.743125*z*z-0.247708);result+=shCoefficients[7]*2.0*0.429043*x*z;result+=shCoefficients[8]*0.429043*(x*x-y*y);return result;}vec3 getLightProbeIrradiance(const in vec3 lightProbe[9],const in vec3 normal){vec3 worldNormal=inverseTransformDirection(normal,viewMatrix);vec3 irradiance=shGetIrradianceAt(worldNormal,lightProbe);return irradiance;}vec3 getAmbientLightIrradiance(const in vec3 ambientLightColor){vec3 irradiance=ambientLightColor;return irradiance;}float getDistanceAttenuation(const in float lightDistance,const in float cutoffDistance,const in float decayExponent){ #if defined(LEGACY_LIGHTS) if(cutoffDistance>0.0&&decayExponent>0.0){return pow(saturate(-lightDistance/cutoffDistance+1.0),decayExponent);}return 1.0; #else float distanceFalloff=1.0/max(pow(lightDistance,decayExponent),0.01);if(cutoffDistance>0.0){distanceFalloff*=pow2(saturate(1.0-pow4(lightDistance/cutoffDistance)));}return distanceFalloff; #endif }float getSpotAttenuation(const in float coneCosine,const in float penumbraCosine,const in float angleCosine){return smoothstep(coneCosine,penumbraCosine,angleCosine);} #if NUM_DIR_LIGHTS>0 struct DirectionalLight{vec3 direction;vec3 color;};uniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];void getDirectionalLightInfo(const in DirectionalLight directionalLight,const in GeometricContext geometry,out IncidentLight light){light.color=directionalLight.color;light.direction=directionalLight.direction;light.visible=true;} #endif #if NUM_POINT_LIGHTS>0 struct PointLight{vec3 position;vec3 color;float distance;float decay;};uniform PointLight pointLights[NUM_POINT_LIGHTS];void getPointLightInfo(const in PointLight pointLight,const in GeometricContext geometry,out IncidentLight light){vec3 lVector=pointLight.position-geometry.position;light.direction=normalize(lVector);float lightDistance=length(lVector);light.color=pointLight.color;light.color*=getDistanceAttenuation(lightDistance,pointLight.distance,pointLight.decay);light.visible=(light.color!=vec3(0.0));} #endif #if NUM_SPOT_LIGHTS>0 struct SpotLight{vec3 position;vec3 direction;vec3 color;float distance;float decay;float coneCos;float penumbraCos;};uniform SpotLight spotLights[NUM_SPOT_LIGHTS];void getSpotLightInfo(const in SpotLight spotLight,const in GeometricContext geometry,out IncidentLight light){vec3 lVector=spotLight.position-geometry.position;light.direction=normalize(lVector);float angleCos=dot(light.direction,spotLight.direction);float spotAttenuation=getSpotAttenuation(spotLight.coneCos,spotLight.penumbraCos,angleCos);if(spotAttenuation>0.0){float lightDistance=length(lVector);light.color=spotLight.color*spotAttenuation;light.color*=getDistanceAttenuation(lightDistance,spotLight.distance,spotLight.decay);light.visible=(light.color!=vec3(0.0));}else{light.color=vec3(0.0);light.visible=false;}} #endif #if NUM_RECT_AREA_LIGHTS>0 struct RectAreaLight{vec3 color;vec3 position;vec3 halfWidth;vec3 halfHeight;};uniform sampler2D ltc_1;uniform sampler2D ltc_2;uniform RectAreaLight rectAreaLights[NUM_RECT_AREA_LIGHTS]; #endif #if NUM_HEMI_LIGHTS>0 struct HemisphereLight{vec3 direction;vec3 skyColor;vec3 groundColor;};uniform HemisphereLight hemisphereLights[NUM_HEMI_LIGHTS];vec3 getHemisphereLightIrradiance(const in HemisphereLight hemiLight,const in vec3 normal){float dotNL=dot(normal,hemiLight.direction);float hemiDiffuseWeight=0.5*dotNL+0.5;vec3 irradiance=mix(hemiLight.groundColor,hemiLight.skyColor,hemiDiffuseWeight);return irradiance;} #endif`,iO=`#ifdef USE_ENVMAP vec3 getIBLIrradiance(const in vec3 normal){ #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal=inverseTransformDirection(normal,viewMatrix);vec4 envMapColor=textureCubeUV(envMap,worldNormal,1.0);return PI*envMapColor.rgb*envMapIntensity; #else return vec3(0.0); #endif }vec3 getIBLRadiance(const in vec3 viewDir,const in vec3 normal,const in float roughness){ #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec=reflect(-viewDir,normal);reflectVec=normalize(mix(reflectVec,normal,roughness*roughness));reflectVec=inverseTransformDirection(reflectVec,viewMatrix);vec4 envMapColor=textureCubeUV(envMap,reflectVec,roughness);return envMapColor.rgb*envMapIntensity; #else return vec3(0.0); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance(const in vec3 viewDir,const in vec3 normal,const in float roughness,const in vec3 bitangent,const in float anisotropy){ #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal=cross(bitangent,viewDir);bentNormal=normalize(cross(bentNormal,bitangent));bentNormal=normalize(mix(bentNormal,normal,pow2(pow2(1.0-anisotropy*(1.0-roughness)))));return getIBLRadiance(viewDir,bentNormal,roughness); #else return vec3(0.0); #endif } #endif #endif`,iz=`varying vec3 vViewPosition;struct ToonMaterial{vec3 diffuseColor;};void RE_Direct_Toon(const in IncidentLight directLight,const in GeometricContext geometry,const in ToonMaterial material,inout ReflectedLight reflectedLight){vec3 irradiance=getGradientIrradiance(geometry.normal,directLight.direction)*directLight.color;reflectedLight.directDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);}void RE_IndirectDiffuse_Toon(const in vec3 irradiance,const in GeometricContext geometry,const in ToonMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);} #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,iF=`varying vec3 vViewPosition;struct BlinnPhongMaterial{vec3 diffuseColor;vec3 specularColor;float specularShininess;float specularStrength;};void RE_Direct_BlinnPhong(const in IncidentLight directLight,const in GeometricContext geometry,const in BlinnPhongMaterial material,inout ReflectedLight reflectedLight){float dotNL=saturate(dot(geometry.normal,directLight.direction));vec3 irradiance=dotNL*directLight.color;reflectedLight.directDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);reflectedLight.directSpecular+=irradiance*BRDF_BlinnPhong(directLight.direction,geometry.viewDir,geometry.normal,material.specularColor,material.specularShininess)*material.specularStrength;}void RE_IndirectDiffuse_BlinnPhong(const in vec3 irradiance,const in GeometricContext geometry,const in BlinnPhongMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);} #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,ik=`PhysicalMaterial material;material.diffuseColor=diffuseColor.rgb*(1.0-metalnessFactor);vec3 dxy=max(abs(dFdx(geometryNormal)),abs(dFdy(geometryNormal)));float geometryRoughness=max(max(dxy.x,dxy.y),dxy.z);material.roughness=max(roughnessFactor,0.0525);material.roughness+=geometryRoughness;material.roughness=min(material.roughness,1.0); #ifdef IOR material.ior=ior; #ifdef USE_SPECULAR float specularIntensityFactor=specularIntensity;vec3 specularColorFactor=specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor*=texture2D(specularColorMap,vSpecularColorMapUv).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor*=texture2D(specularIntensityMap,vSpecularIntensityMapUv).a; #endif material.specularF90=mix(specularIntensityFactor,1.0,metalnessFactor); #else float specularIntensityFactor=1.0;vec3 specularColorFactor=vec3(1.0);material.specularF90=1.0; #endif material.specularColor=mix(min(pow2((material.ior-1.0)/(material.ior+1.0))*specularColorFactor,vec3(1.0))*specularIntensityFactor,diffuseColor.rgb,metalnessFactor); #else material.specularColor=mix(vec3(0.04),diffuseColor.rgb,metalnessFactor);material.specularF90=1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat=clearcoat;material.clearcoatRoughness=clearcoatRoughness;material.clearcoatF0=vec3(0.04);material.clearcoatF90=1.0; #ifdef USE_CLEARCOATMAP material.clearcoat*=texture2D(clearcoatMap,vClearcoatMapUv).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness*=texture2D(clearcoatRoughnessMap,vClearcoatRoughnessMapUv).y; #endif material.clearcoat=saturate(material.clearcoat);material.clearcoatRoughness=max(material.clearcoatRoughness,0.0525);material.clearcoatRoughness+=geometryRoughness;material.clearcoatRoughness=min(material.clearcoatRoughness,1.0); #endif #ifdef USE_IRIDESCENCE material.iridescence=iridescence;material.iridescenceIOR=iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence*=texture2D(iridescenceMap,vIridescenceMapUv).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness=(iridescenceThicknessMaximum-iridescenceThicknessMinimum)*texture2D(iridescenceThicknessMap,vIridescenceThicknessMapUv).g+iridescenceThicknessMinimum; #else material.iridescenceThickness=iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor=sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor*=texture2D(sheenColorMap,vSheenColorMapUv).rgb; #endif material.sheenRoughness=clamp(sheenRoughness,0.07,1.0); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness*=texture2D(sheenRoughnessMap,vSheenRoughnessMapUv).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat=mat2(anisotropyVector.x,anisotropyVector.y,-anisotropyVector.y,anisotropyVector.x);vec3 anisotropyPolar=texture2D(anisotropyMap,vAnisotropyMapUv).rgb;vec2 anisotropyV=anisotropyMat*normalize(2.0*anisotropyPolar.rg-vec2(1.0))*anisotropyPolar.b; #else vec2 anisotropyV=anisotropyVector; #endif material.anisotropy=length(anisotropyV);anisotropyV/=material.anisotropy;material.anisotropy=saturate(material.anisotropy);material.alphaT=mix(pow2(material.roughness),1.0,pow2(material.anisotropy));material.anisotropyT=tbn[0]*anisotropyV.x-tbn[1]*anisotropyV.y;material.anisotropyB=tbn[1]*anisotropyV.x+tbn[0]*anisotropyV.y; #endif`,iB=`struct PhysicalMaterial{vec3 diffuseColor;float roughness;vec3 specularColor;float specularF90; #ifdef USE_CLEARCOAT float clearcoat;float clearcoatRoughness;vec3 clearcoatF0;float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence;float iridescenceIOR;float iridescenceThickness;vec3 iridescenceFresnel;vec3 iridescenceF0; #endif #ifdef USE_SHEEN vec3 sheenColor;float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission;float transmissionAlpha;float thickness;float attenuationDistance;vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy;float alphaT;vec3 anisotropyT;vec3 anisotropyB; #endif };vec3 clearcoatSpecular=vec3(0.0);vec3 sheenSpecular=vec3(0.0);vec3 Schlick_to_F0(const in vec3 f,const in float f90,const in float dotVH){float x=clamp(1.0-dotVH,0.0,1.0);float x2=x*x;float x5=clamp(x*x2*x2,0.0,0.9999);return(f-vec3(f90)*x5)/(1.0-x5);}float V_GGX_SmithCorrelated(const in float alpha,const in float dotNL,const in float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}float D_GGX(const in float alpha,const in float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);} #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic(const in float alphaT,const in float alphaB,const in float dotTV,const in float dotBV,const in float dotTL,const in float dotBL,const in float dotNV,const in float dotNL){float gv=dotNL*length(vec3(alphaT*dotTV,alphaB*dotBV,dotNV));float gl=dotNV*length(vec3(alphaT*dotTL,alphaB*dotBL,dotNL));float v=0.5/(gv+gl);return saturate(v);}float D_GGX_Anisotropic(const in float alphaT,const in float alphaB,const in float dotNH,const in float dotTH,const in float dotBH){float a2=alphaT*alphaB;highp vec3 v=vec3(alphaB*dotTH,alphaT*dotBH,a2*dotNH);highp float v2=dot(v,v);float w2=a2/v2;return RECIPROCAL_PI*a2*pow2(w2);} #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat(const in vec3 lightDir,const in vec3 viewDir,const in vec3 normal,const in PhysicalMaterial material){vec3 f0=material.clearcoatF0;float f90=material.clearcoatF90;float roughness=material.clearcoatRoughness;float alpha=pow2(roughness);vec3 halfDir=normalize(lightDir+viewDir);float dotNL=saturate(dot(normal,lightDir));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotVH=saturate(dot(viewDir,halfDir));vec3 F=F_Schlick(f0,f90,dotVH);float V=V_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(V*D);} #endif vec3 BRDF_GGX(const in vec3 lightDir,const in vec3 viewDir,const in vec3 normal,const in PhysicalMaterial material){vec3 f0=material.specularColor;float f90=material.specularF90;float roughness=material.roughness;float alpha=pow2(roughness);vec3 halfDir=normalize(lightDir+viewDir);float dotNL=saturate(dot(normal,lightDir));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotVH=saturate(dot(viewDir,halfDir));vec3 F=F_Schlick(f0,f90,dotVH); #ifdef USE_IRIDESCENCE F=mix(F,material.iridescenceFresnel,material.iridescence); #endif #ifdef USE_ANISOTROPY float dotTL=dot(material.anisotropyT,lightDir);float dotTV=dot(material.anisotropyT,viewDir);float dotTH=dot(material.anisotropyT,halfDir);float dotBL=dot(material.anisotropyB,lightDir);float dotBV=dot(material.anisotropyB,viewDir);float dotBH=dot(material.anisotropyB,halfDir);float V=V_GGX_SmithCorrelated_Anisotropic(material.alphaT,alpha,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);float D=D_GGX_Anisotropic(material.alphaT,alpha,dotNH,dotTH,dotBH); #else float V=V_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH); #endif return F*(V*D);}vec2 LTC_Uv(const in vec3 N,const in vec3 V,const in float roughness){const float LUT_SIZE=64.0;const float LUT_SCALE=(LUT_SIZE-1.0)/LUT_SIZE;const float LUT_BIAS=0.5/LUT_SIZE;float dotNV=saturate(dot(N,V));vec2 uv=vec2(roughness,sqrt(1.0-dotNV));uv=uv*LUT_SCALE+LUT_BIAS;return uv;}float LTC_ClippedSphereFormFactor(const in vec3 f){float l=length(f);return max((l*l+f.z)/(l+1.0),0.0);}vec3 LTC_EdgeVectorFormFactor(const in vec3 v1,const in vec3 v2){float x=dot(v1,v2);float y=abs(x);float a=0.8543985+(0.4965155+0.0145206*y)*y;float b=3.4175940+(4.1616724+y)*y;float v=a/b;float theta_sintheta=(x>0.0)?v:0.5*inversesqrt(max(1.0-x*x,1e-7))-v;return cross(v1,v2)*theta_sintheta;}vec3 LTC_Evaluate(const in vec3 N,const in vec3 V,const in vec3 P,const in mat3 mInv,const in vec3 rectCoords[4]){vec3 v1=rectCoords[1]-rectCoords[0];vec3 v2=rectCoords[3]-rectCoords[0];vec3 lightNormal=cross(v1,v2);if(dot(lightNormal,P-rectCoords[0])<0.0)return vec3(0.0);vec3 T1,T2;T1=normalize(V-N*dot(V,N));T2=-cross(N,T1);mat3 mat=mInv*transposeMat3(mat3(T1,T2,N));vec3 coords[4];coords[0]=mat*(rectCoords[0]-P);coords[1]=mat*(rectCoords[1]-P);coords[2]=mat*(rectCoords[2]-P);coords[3]=mat*(rectCoords[3]-P);coords[0]=normalize(coords[0]);coords[1]=normalize(coords[1]);coords[2]=normalize(coords[2]);coords[3]=normalize(coords[3]);vec3 vectorFormFactor=vec3(0.0);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[0],coords[1]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[1],coords[2]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[2],coords[3]);vectorFormFactor+=LTC_EdgeVectorFormFactor(coords[3],coords[0]);float result=LTC_ClippedSphereFormFactor(vectorFormFactor);return vec3(result);} #if defined(USE_SHEEN) float D_Charlie(float roughness,float dotNH){float alpha=pow2(roughness);float invAlpha=1.0/alpha;float cos2h=dotNH*dotNH;float sin2h=max(1.0-cos2h,0.0078125);return(2.0+invAlpha)*pow(sin2h,invAlpha*0.5)/(2.0*PI);}float V_Neubelt(float dotNV,float dotNL){return saturate(1.0/(4.0*(dotNL+dotNV-dotNL*dotNV)));}vec3 BRDF_Sheen(const in vec3 lightDir,const in vec3 viewDir,const in vec3 normal,vec3 sheenColor,const in float sheenRoughness){vec3 halfDir=normalize(lightDir+viewDir);float dotNL=saturate(dot(normal,lightDir));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float D=D_Charlie(sheenRoughness,dotNH);float V=V_Neubelt(dotNV,dotNL);return sheenColor*(D*V);} #endif float IBLSheenBRDF(const in vec3 normal,const in vec3 viewDir,const in float roughness){float dotNV=saturate(dot(normal,viewDir));float r2=roughness*roughness;float a=roughness<0.25?-339.2*r2+161.4*roughness-25.9:-8.48*r2+14.3*roughness-9.95;float b=roughness<0.25?44.0*r2-23.7*roughness+3.26:1.97*r2-3.27*roughness+0.72;float DG=exp(a*dotNV+b)+(roughness<0.25?0.0:0.1*(roughness-0.25));return saturate(DG*RECIPROCAL_PI);}vec2 DFGApprox(const in vec3 normal,const in vec3 viewDir,const in float roughness){float dotNV=saturate(dot(normal,viewDir));const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 fab=vec2(-1.04,1.04)*a004+r.zw;return fab;}vec3 EnvironmentBRDF(const in vec3 normal,const in vec3 viewDir,const in vec3 specularColor,const in float specularF90,const in float roughness){vec2 fab=DFGApprox(normal,viewDir,roughness);return specularColor*fab.x+specularF90*fab.y;} #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence(const in vec3 normal,const in vec3 viewDir,const in vec3 specularColor,const in float specularF90,const in float iridescence,const in vec3 iridescenceF0,const in float roughness,inout vec3 singleScatter,inout vec3 multiScatter){ #else void 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){ #endif vec2 fab=DFGApprox(normal,viewDir,roughness); #ifdef USE_IRIDESCENCE vec3 Fr=mix(specularColor,iridescenceF0,iridescence); #else vec3 Fr=specularColor; #endif vec3 FssEss=Fr*fab.x+specularF90*fab.y;float Ess=fab.x+fab.y;float Ems=1.0-Ess;vec3 Favg=Fr+(1.0-Fr)*0.047619;vec3 Fms=FssEss*Favg/(1.0-Ems*Favg);singleScatter+=FssEss;multiScatter+=Fms*Ems;} #if NUM_RECT_AREA_LIGHTS>0 void RE_Direct_RectArea_Physical(const in RectAreaLight rectAreaLight,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){vec3 normal=geometry.normal;vec3 viewDir=geometry.viewDir;vec3 position=geometry.position;vec3 lightPos=rectAreaLight.position;vec3 halfWidth=rectAreaLight.halfWidth;vec3 halfHeight=rectAreaLight.halfHeight;vec3 lightColor=rectAreaLight.color;float roughness=material.roughness;vec3 rectCoords[4];rectCoords[0]=lightPos+halfWidth-halfHeight;rectCoords[1]=lightPos-halfWidth-halfHeight;rectCoords[2]=lightPos-halfWidth+halfHeight;rectCoords[3]=lightPos+halfWidth+halfHeight;vec2 uv=LTC_Uv(normal,viewDir,roughness);vec4 t1=texture2D(ltc_1,uv);vec4 t2=texture2D(ltc_2,uv);mat3 mInv=mat3(vec3(t1.x,0,t1.y),vec3(0,1,0),vec3(t1.z,0,t1.w));vec3 fresnel=(material.specularColor*t2.x+(vec3(1.0)-material.specularColor)*t2.y);reflectedLight.directSpecular+=lightColor*fresnel*LTC_Evaluate(normal,viewDir,position,mInv,rectCoords);reflectedLight.directDiffuse+=lightColor*material.diffuseColor*LTC_Evaluate(normal,viewDir,position,mat3(1.0),rectCoords);} #endif void RE_Direct_Physical(const in IncidentLight directLight,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){float dotNL=saturate(dot(geometry.normal,directLight.direction));vec3 irradiance=dotNL*directLight.color; #ifdef USE_CLEARCOAT float dotNLcc=saturate(dot(geometry.clearcoatNormal,directLight.direction));vec3 ccIrradiance=dotNLcc*directLight.color;clearcoatSpecular+=ccIrradiance*BRDF_GGX_Clearcoat(directLight.direction,geometry.viewDir,geometry.clearcoatNormal,material); #endif #ifdef USE_SHEEN sheenSpecular+=irradiance*BRDF_Sheen(directLight.direction,geometry.viewDir,geometry.normal,material.sheenColor,material.sheenRoughness); #endif reflectedLight.directSpecular+=irradiance*BRDF_GGX(directLight.direction,geometry.viewDir,geometry.normal,material);reflectedLight.directDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);}void RE_IndirectDiffuse_Physical(const in vec3 irradiance,const in GeometricContext geometry,const in PhysicalMaterial material,inout ReflectedLight reflectedLight){reflectedLight.indirectDiffuse+=irradiance*BRDF_Lambert(material.diffuseColor);}void 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){ #ifdef USE_CLEARCOAT clearcoatSpecular+=clearcoatRadiance*EnvironmentBRDF(geometry.clearcoatNormal,geometry.viewDir,material.clearcoatF0,material.clearcoatF90,material.clearcoatRoughness); #endif #ifdef USE_SHEEN sheenSpecular+=irradiance*material.sheenColor*IBLSheenBRDF(geometry.normal,geometry.viewDir,material.sheenRoughness); #endif vec3 singleScattering=vec3(0.0);vec3 multiScattering=vec3(0.0);vec3 cosineWeightedIrradiance=irradiance*RECIPROCAL_PI; #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence(geometry.normal,geometry.viewDir,material.specularColor,material.specularF90,material.iridescence,material.iridescenceFresnel,material.roughness,singleScattering,multiScattering); #else computeMultiscattering(geometry.normal,geometry.viewDir,material.specularColor,material.specularF90,material.roughness,singleScattering,multiScattering); #endif vec3 totalScattering=singleScattering+multiScattering;vec3 diffuse=material.diffuseColor*(1.0-max(max(totalScattering.r,totalScattering.g),totalScattering.b));reflectedLight.indirectSpecular+=radiance*singleScattering;reflectedLight.indirectSpecular+=multiScattering*cosineWeightedIrradiance;reflectedLight.indirectDiffuse+=diffuse*cosineWeightedIrradiance;} #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion(const in float dotNV,const in float ambientOcclusion,const in float roughness){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}`,iH=`GeometricContext geometry;geometry.position=-vViewPosition;geometry.normal=normal;geometry.viewDir=(isOrthographic)?vec3(0,0,1):normalize(vViewPosition); #ifdef USE_CLEARCOAT geometry.clearcoatNormal=clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi=saturate(dot(normal,geometry.viewDir));if(material.iridescenceThickness==0.0){material.iridescence=0.0;}else{material.iridescence=saturate(material.iridescence);}if(material.iridescence>0.0){material.iridescenceFresnel=evalIridescence(1.0,material.iridescenceIOR,dotNVi,material.iridescenceThickness,material.specularColor);material.iridescenceF0=Schlick_to_F0(material.iridescenceFresnel,1.0,dotNVi);} #endif IncidentLight directLight; #if (NUM_POINT_LIGHTS>0)&&defined(RE_Direct) PointLight pointLight; #if defined(USE_SHADOWMAP)&&NUM_POINT_LIGHT_SHADOWS>0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for(int i=0;i0)&&defined(RE_Direct) SpotLight spotLight;vec4 spotColor;vec3 spotLightCoord;bool inSpotLightMap; #if defined(USE_SHADOWMAP)&&NUM_SPOT_LIGHT_SHADOWS>0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for(int i=0;i0)&&defined(RE_Direct) DirectionalLight directionalLight; #if defined(USE_SHADOWMAP)&&NUM_DIR_LIGHT_SHADOWS>0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for(int i=0;i0)&&defined(RE_Direct_RectArea) RectAreaLight rectAreaLight; #pragma unroll_loop_start for(int i=0;i0) #pragma unroll_loop_start for(int i=0;i0 varying vec4 vSpotLightCoord[NUM_SPOT_LIGHT_COORDS]; #endif #if NUM_SPOT_LIGHT_MAPS>0 uniform sampler2D spotLightMap[NUM_SPOT_LIGHT_MAPS]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS>0 uniform sampler2D directionalShadowMap[NUM_DIR_LIGHT_SHADOWS];varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];struct DirectionalLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS]; #endif #if NUM_SPOT_LIGHT_SHADOWS>0 uniform sampler2D spotShadowMap[NUM_SPOT_LIGHT_SHADOWS];struct SpotLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS]; #endif #if NUM_POINT_LIGHT_SHADOWS>0 uniform sampler2D pointShadowMap[NUM_POINT_LIGHT_SHADOWS];varying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];struct PointLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;float shadowCameraNear;float shadowCameraFar;};uniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS]; #endif float texture2DCompare(sampler2D depths,vec2 uv,float compare){return step(compare,unpackRGBAToDepth(texture2D(depths,uv)));}vec2 texture2DDistribution(sampler2D shadow,vec2 uv){return unpackRGBATo2Half(texture2D(shadow,uv));}float VSMShadow(sampler2D shadow,vec2 uv,float compare){float occlusion=1.0;vec2 distribution=texture2DDistribution(shadow,uv);float hard_shadow=step(compare,distribution.x);if(hard_shadow!=1.0){float distance=compare-distribution.x;float variance=max(0.00000,distribution.y*distribution.y);float softness_probability=variance/(variance+distance*distance);softness_probability=clamp((softness_probability-0.3)/(0.95-0.3),0.0,1.0);occlusion=clamp(max(hard_shadow,softness_probability),0.0,1.0);}return occlusion;}float getShadow(sampler2D shadowMap,vec2 shadowMapSize,float shadowBias,float shadowRadius,vec4 shadowCoord){float shadow=1.0;shadowCoord.xyz/=shadowCoord.w;shadowCoord.z+=shadowBias;bool inFrustum=shadowCoord.x>=0.0&&shadowCoord.x<=1.0&&shadowCoord.y>=0.0&&shadowCoord.y<=1.0;bool frustumTest=inFrustum&&shadowCoord.z<=1.0;if(frustumTest){ #if defined(SHADOWMAP_TYPE_PCF) vec2 texelSize=vec2(1.0)/shadowMapSize;float dx0=-texelSize.x*shadowRadius;float dy0=-texelSize.y*shadowRadius;float dx1=+texelSize.x*shadowRadius;float dy1=+texelSize.y*shadowRadius;float dx2=dx0/2.0;float dy2=dy0/2.0;float dx3=dx1/2.0;float dy3=dy1/2.0;shadow=(texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,dy0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,dy2),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy,shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,0.0),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx2,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx3,dy3),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx0,dy1),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(0.0,dy1),shadowCoord.z)+texture2DCompare(shadowMap,shadowCoord.xy+vec2(dx1,dy1),shadowCoord.z))*(1.0/17.0); #elif defined(SHADOWMAP_TYPE_PCF_SOFT) vec2 texelSize=vec2(1.0)/shadowMapSize;float dx=texelSize.x;float dy=texelSize.y;vec2 uv=shadowCoord.xy;vec2 f=fract(uv*shadowMapSize+0.5);uv-=f*texelSize;shadow=(texture2DCompare(shadowMap,uv,shadowCoord.z)+texture2DCompare(shadowMap,uv+vec2(dx,0.0),shadowCoord.z)+texture2DCompare(shadowMap,uv+vec2(0.0,dy),shadowCoord.z)+texture2DCompare(shadowMap,uv+texelSize,shadowCoord.z)+mix(texture2DCompare(shadowMap,uv+vec2(-dx,0.0),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,0.0),shadowCoord.z),f.x)+mix(texture2DCompare(shadowMap,uv+vec2(-dx,dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,dy),shadowCoord.z),f.x)+mix(texture2DCompare(shadowMap,uv+vec2(0.0,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(0.0,2.0*dy),shadowCoord.z),f.y)+mix(texture2DCompare(shadowMap,uv+vec2(dx,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(dx,2.0*dy),shadowCoord.z),f.y)+mix(mix(texture2DCompare(shadowMap,uv+vec2(-dx,-dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,-dy),shadowCoord.z),f.x),mix(texture2DCompare(shadowMap,uv+vec2(-dx,2.0*dy),shadowCoord.z),texture2DCompare(shadowMap,uv+vec2(2.0*dx,2.0*dy),shadowCoord.z),f.x),f.y))*(1.0/9.0); #elif defined(SHADOWMAP_TYPE_VSM) shadow=VSMShadow(shadowMap,shadowCoord.xy,shadowCoord.z); #else shadow=texture2DCompare(shadowMap,shadowCoord.xy,shadowCoord.z); #endif }return shadow;}vec2 cubeToUV(vec3 v,float texelSizeY){vec3 absV=abs(v);float scaleToCube=1.0/max(absV.x,max(absV.y,absV.z));absV*=scaleToCube;v*=scaleToCube*(1.0-2.0*texelSizeY);vec2 planar=v.xy;float almostATexel=1.5*texelSizeY;float almostOne=1.0-almostATexel;if(absV.z>=almostOne){if(v.z>0.0)planar.x=4.0-v.x;}else if(absV.x>=almostOne){float signX=sign(v.x);planar.x=v.z*signX+2.0*signX;}else if(absV.y>=almostOne){float signY=sign(v.y);planar.x=v.x+2.0*signY+2.0;planar.y=v.z*signY-2.0;}return vec2(0.125,0.25)*planar+vec2(0.375,0.75);}float getPointShadow(sampler2D shadowMap,vec2 shadowMapSize,float shadowBias,float shadowRadius,vec4 shadowCoord,float shadowCameraNear,float shadowCameraFar){vec2 texelSize=vec2(1.0)/(shadowMapSize*vec2(4.0,2.0));vec3 lightToPosition=shadowCoord.xyz;float dp=(length(lightToPosition)-shadowCameraNear)/(shadowCameraFar-shadowCameraNear);dp+=shadowBias;vec3 bd3D=normalize(lightToPosition); #if defined(SHADOWMAP_TYPE_PCF)||defined(SHADOWMAP_TYPE_PCF_SOFT)||defined(SHADOWMAP_TYPE_VSM) vec2 offset=vec2(-1,1)*shadowRadius*texelSize.y;return(texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xyy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yyy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xyx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yyx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xxy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yxy,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.xxx,texelSize.y),dp)+texture2DCompare(shadowMap,cubeToUV(bd3D+offset.yxx,texelSize.y),dp))*(1.0/9.0); #else return texture2DCompare(shadowMap,cubeToUV(bd3D,texelSize.y),dp); #endif } #endif`,rd=`#if NUM_SPOT_LIGHT_COORDS>0 uniform mat4 spotLightMatrix[NUM_SPOT_LIGHT_COORDS];varying vec4 vSpotLightCoord[NUM_SPOT_LIGHT_COORDS]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS>0 uniform mat4 directionalShadowMatrix[NUM_DIR_LIGHT_SHADOWS];varying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];struct DirectionalLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS]; #endif #if NUM_SPOT_LIGHT_SHADOWS>0 struct SpotLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;};uniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS]; #endif #if NUM_POINT_LIGHT_SHADOWS>0 uniform mat4 pointShadowMatrix[NUM_POINT_LIGHT_SHADOWS];varying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];struct PointLightShadow{float shadowBias;float shadowNormalBias;float shadowRadius;vec2 shadowMapSize;float shadowCameraNear;float shadowCameraFar;};uniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS]; #endif #endif`,rp=`#if (defined(USE_SHADOWMAP)&&(NUM_DIR_LIGHT_SHADOWS>0||NUM_POINT_LIGHT_SHADOWS>0))||(NUM_SPOT_LIGHT_COORDS>0) vec3 shadowWorldNormal=inverseTransformDirection(transformedNormal,viewMatrix);vec4 shadowWorldPosition; #endif #if defined(USE_SHADOWMAP) #if NUM_DIR_LIGHT_SHADOWS>0 #pragma unroll_loop_start for(int i=0;i0 #pragma unroll_loop_start for(int i=0;i0 #pragma unroll_loop_start for(int i=0;i0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for(int i=0;i0 SpotLightShadow spotLight; #pragma unroll_loop_start for(int i=0;i0 PointLightShadow pointLight; #pragma unroll_loop_start for(int i=0;i0 vec4 worldPosition=vec4(transformed,1.0); #ifdef USE_INSTANCING worldPosition=instanceMatrix*worldPosition; #endif worldPosition=modelMatrix*worldPosition; #endif`;let rL=`uniform sampler2D t2D;uniform float backgroundIntensity;varying vec2 vUv;void main(){vec4 texColor=texture2D(t2D,vUv); #ifdef DECODE_VIDEO_TEXTURE texColor=vec4(mix(pow(texColor.rgb*0.9478672986+vec3(0.0521327014),vec3(2.4)),texColor.rgb*0.0773993808,vec3(lessThanEqual(texColor.rgb,vec3(0.04045)))),texColor.w); #endif texColor.rgb*=backgroundIntensity;gl_FragColor=texColor; #include #include }`,rP=`varying vec3 vWorldDirection; #include void main(){vWorldDirection=transformDirection(position,modelMatrix); #include #include gl_Position.z=gl_Position.w;}`,rR=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined(ENVMAP_TYPE_CUBE_UV) uniform sampler2D envMap; #endif uniform float flipEnvMap;uniform float backgroundBlurriness;uniform float backgroundIntensity;varying vec3 vWorldDirection; #include void main(){ #ifdef ENVMAP_TYPE_CUBE vec4 texColor=textureCube(envMap,vec3(flipEnvMap*vWorldDirection.x,vWorldDirection.yz)); #elif defined(ENVMAP_TYPE_CUBE_UV) vec4 texColor=textureCubeUV(envMap,vWorldDirection,backgroundBlurriness); #else vec4 texColor=vec4(0.0,0.0,0.0,1.0); #endif texColor.rgb*=backgroundIntensity;gl_FragColor=texColor; #include #include }`,rD=`varying vec3 vWorldDirection; #include void main(){vWorldDirection=transformDirection(position,modelMatrix); #include #include gl_Position.z=gl_Position.w;}`,rU=`uniform samplerCube tCube;uniform float tFlip;uniform float opacity;varying vec3 vWorldDirection;void main(){vec4 texColor=textureCube(tCube,vec3(tFlip*vWorldDirection.x,vWorldDirection.yz));gl_FragColor=texColor;gl_FragColor.a*=opacity; #include #include }`,rI=`#include #include #include #include #include #include #include varying vec2 vHighPrecisionZW;void main(){ #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW=gl_Position.zw;}`,rN=`#if DEPTH_PACKING==3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW;void main(){ #include vec4 diffuseColor=vec4(1.0); #if DEPTH_PACKING==3200 diffuseColor.a=opacity; #endif #include #include #include #include #include float fragCoordZ=0.5*vHighPrecisionZW[0]/vHighPrecisionZW[1]+0.5; #if DEPTH_PACKING==3200 gl_FragColor=vec4(vec3(1.0-fragCoordZ),opacity); #elif DEPTH_PACKING==3201 gl_FragColor=packDepthToRGBA(fragCoordZ); #endif }`,rO=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include void main(){ #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition=worldPosition.xyz;}`,rz=`#define DISTANCE uniform vec3 referencePosition;uniform float nearDistance;uniform float farDistance;varying vec3 vWorldPosition; #include #include #include #include #include #include #include #include void main(){ #include vec4 diffuseColor=vec4(1.0); #include #include #include #include float dist=length(vWorldPosition-referencePosition);dist=(dist-nearDistance)/(farDistance-nearDistance);dist=saturate(dist);gl_FragColor=packDepthToRGBA(dist);}`,rF=`varying vec3 vWorldDirection; #include void main(){vWorldDirection=transformDirection(position,modelMatrix); #include #include }`,rk=`uniform sampler2D tEquirect;varying vec3 vWorldDirection; #include void main(){vec3 direction=normalize(vWorldDirection);vec2 sampleUV=equirectUv(direction);gl_FragColor=texture2D(tEquirect,sampleUV); #include #include }`,rB=`uniform float scale;attribute float lineDistance;varying float vLineDistance; #include #include #include #include #include #include #include void main(){vLineDistance=scale*lineDistance; #include #include #include #include #include #include #include #include #include }`,rH=`uniform vec3 diffuse;uniform float opacity;uniform float dashSize;uniform float totalSize;varying float vLineDistance; #include #include #include #include #include #include #include void main(){ #include if(mod(vLineDistance,totalSize)>dashSize){discard;}vec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity); #include #include #include outgoingLight=diffuseColor.rgb; #include #include #include #include #include }`,rV=`#include #include #include #include #include #include #include #include #include void main(){ #include #include #include #if defined(USE_ENVMAP)||defined(USE_SKINNING) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,rG=`uniform vec3 diffuse;uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main(){ #include vec4 diffuseColor=vec4(diffuse,opacity); #include #include #include #include #include #include #include ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0)); #ifdef USE_LIGHTMAP vec4 lightMapTexel=texture2D(lightMap,vLightMapUv);reflectedLight.indirectDiffuse+=lightMapTexel.rgb*lightMapIntensity*RECIPROCAL_PI; #else reflectedLight.indirectDiffuse+=vec3(1.0); #endif #include reflectedLight.indirectDiffuse*=diffuseColor.rgb;vec3 outgoingLight=reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,rW=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main(){ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition=-mvPosition.xyz; #include #include #include #include }`,rj=`#define LAMBERT uniform vec3 diffuse;uniform vec3 emissive;uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main(){ #include vec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+totalEmissiveRadiance; #include #include #include #include #include #include #include }`,rq=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include void main(){ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition=-mvPosition.xyz;}`,rX=`#define MATCAP uniform vec3 diffuse;uniform float opacity;uniform sampler2D matcap;varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main(){ #include vec4 diffuseColor=vec4(diffuse,opacity); #include #include #include #include #include #include #include #include vec3 viewDir=normalize(vViewPosition);vec3 x=normalize(vec3(viewDir.z,0.0,-viewDir.x));vec3 y=cross(viewDir,x);vec2 uv=vec2(dot(x,normal),dot(y,normal))*0.495+0.5; #ifdef USE_MATCAP vec4 matcapColor=texture2D(matcap,uv); #else vec4 matcapColor=vec4(vec3(mix(0.2,0.8,uv.y)),1.0); #endif vec3 outgoingLight=diffuseColor.rgb*matcapColor.rgb; #include #include #include #include #include #include }`,rY=`#define NORMAL #if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(USE_NORMALMAP_TANGENTSPACE) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include void main(){ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(USE_NORMALMAP_TANGENTSPACE) vViewPosition=-mvPosition.xyz; #endif }`,rZ=`#define NORMAL uniform float opacity; #if defined(FLAT_SHADED)||defined(USE_BUMPMAP)||defined(USE_NORMALMAP_TANGENTSPACE) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include void main(){ #include #include #include #include gl_FragColor=vec4(packNormalToRGB(normal),opacity); #ifdef OPAQUE gl_FragColor.a=1.0; #endif }`,rK=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main(){ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition=-mvPosition.xyz; #include #include #include #include }`,rJ=`#define PHONG uniform vec3 diffuse;uniform vec3 emissive;uniform vec3 specular;uniform float shininess;uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main(){ #include vec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+totalEmissiveRadiance; #include #include #include #include #include #include #include }`,rQ=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include void main(){ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition=-mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition=worldPosition.xyz; #endif }`,r$=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse;uniform vec3 emissive;uniform float roughness;uniform float metalness;uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity;uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat;uniform float clearcoatRoughness; #endif #ifdef USE_IRIDESCENCE uniform float iridescence;uniform float iridescenceIOR;uniform float iridescenceThicknessMinimum;uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor;uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main(){ #include vec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse;vec3 totalSpecular=reflectedLight.directSpecular+reflectedLight.indirectSpecular; #include vec3 outgoingLight=totalDiffuse+totalSpecular+totalEmissiveRadiance; #ifdef USE_SHEEN float sheenEnergyComp=1.0-0.157*max3(material.sheenColor);outgoingLight=outgoingLight*sheenEnergyComp+sheenSpecular; #endif #ifdef USE_CLEARCOAT float dotNVcc=saturate(dot(geometry.clearcoatNormal,geometry.viewDir));vec3 Fcc=F_Schlick(material.clearcoatF0,material.clearcoatF90,dotNVcc);outgoingLight=outgoingLight*(1.0-material.clearcoat*Fcc)+clearcoatSpecular*material.clearcoat; #endif #include #include #include #include #include #include }`,r0=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main(){ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition=-mvPosition.xyz; #include #include #include }`,r1=`#define TOON uniform vec3 diffuse;uniform vec3 emissive;uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main(){ #include vec4 diffuseColor=vec4(diffuse,opacity);ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));vec3 totalEmissiveRadiance=emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+totalEmissiveRadiance; #include #include #include #include #include #include }`,r3=`uniform float size;uniform float scale; #include #include #include #include #include #include #ifdef USE_POINTS_UV varying vec2 vUv;uniform mat3 uvTransform; #endif void main(){ #ifdef USE_POINTS_UV vUv=(uvTransform*vec3(uv,1)).xy; #endif #include #include #include #include #include gl_PointSize=size; #ifdef USE_SIZEATTENUATION bool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective)gl_PointSize*=(scale/-mvPosition.z); #endif #include #include #include #include }`,r2=`uniform vec3 diffuse;uniform float opacity; #include #include #include #include #include #include #include #include void main(){ #include vec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity); #include #include #include #include #include outgoingLight=diffuseColor.rgb; #include #include #include #include #include }`,r4=`#include #include #include #include #include #include void main(){ #include #include #include #include #include #include #include #include #include #include #include #include #include }`,r5=`uniform vec3 color;uniform float opacity; #include #include #include #include #include #include #include #include void main(){ #include gl_FragColor=vec4(color,opacity*(1.0-getShadowMask())); #include #include #include }`,r6=`uniform float rotation;uniform vec2 center; #include #include #include #include #include void main(){ #include vec4 mvPosition=modelViewMatrix*vec4(0.0,0.0,0.0,1.0);vec2 scale;scale.x=length(vec3(modelMatrix[0].x,modelMatrix[0].y,modelMatrix[0].z));scale.y=length(vec3(modelMatrix[1].x,modelMatrix[1].y,modelMatrix[1].z)); #ifndef USE_SIZEATTENUATION bool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective)scale*=-mvPosition.z; #endif vec2 alignedPosition=(position.xy-(center-vec2(0.5)))*scale;vec2 rotatedPosition;rotatedPosition.x=cos(rotation)*alignedPosition.x-sin(rotation)*alignedPosition.y;rotatedPosition.y=sin(rotation)*alignedPosition.x+cos(rotation)*alignedPosition.y;mvPosition.xy+=rotatedPosition;gl_Position=projectionMatrix*mvPosition; #include #include #include }`,r8=`uniform vec3 diffuse;uniform float opacity; #include #include #include #include #include #include #include #include #include void main(){ #include vec3 outgoingLight=vec3(0.0);vec4 diffuseColor=vec4(diffuse,opacity); #include #include #include #include #include outgoingLight=diffuseColor.rgb; #include #include #include #include }`,r7={alphahash_fragment:t2,alphahash_pars_fragment:t4,alphamap_fragment:t5,alphamap_pars_fragment:t6,alphatest_fragment:t8,alphatest_pars_fragment:t7,aomap_fragment:t9,aomap_pars_fragment:ie,begin_vertex:it,beginnormal_vertex:ii,bsdfs:"float G_BlinnPhong_Implicit(){return 0.25;}float D_BlinnPhong(const in float shininess,const in float dotNH){return RECIPROCAL_PI*(shininess*0.5+1.0)*pow(dotNH,shininess);}vec3 BRDF_BlinnPhong(const in vec3 lightDir,const in vec3 viewDir,const in vec3 normal,const in vec3 specularColor,const in float shininess){vec3 halfDir=normalize(lightDir+viewDir);float dotNH=saturate(dot(normal,halfDir));float dotVH=saturate(dot(viewDir,halfDir));vec3 F=F_Schlick(specularColor,1.0,dotVH);float G=G_BlinnPhong_Implicit();float D=D_BlinnPhong(shininess,dotNH);return F*(G*D);}",iridescence_fragment:ir,bumpmap_pars_fragment:ia,clipping_planes_fragment:is,clipping_planes_pars_fragment:io,clipping_planes_pars_vertex:il,clipping_planes_vertex:ih,color_fragment:ic,color_pars_fragment:iu,color_pars_vertex:id,color_vertex:ip,common:im,cube_uv_reflection_fragment:ig,defaultnormal_vertex:iv,displacementmap_pars_vertex:i_,displacementmap_vertex:ix,emissivemap_fragment:iy,emissivemap_pars_fragment:iM,colorspace_fragment:"gl_FragColor=linearToOutputTexel(gl_FragColor);",colorspace_pars_fragment:"vec4 LinearToLinear(in vec4 value){return value;}vec4 LinearTosRGB(in vec4 value){return 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);}",envmap_fragment:iS,envmap_common_pars_fragment:ib,envmap_pars_fragment:iw,envmap_pars_vertex:iT,envmap_physical_pars_fragment:iO,envmap_vertex:iE,fog_vertex:iA,fog_pars_vertex:iC,fog_fragment:iL,fog_pars_fragment:iP,gradientmap_pars_fragment:iR,lightmap_fragment:iD,lightmap_pars_fragment:iU,lights_lambert_fragment:"LambertMaterial material;material.diffuseColor=diffuseColor.rgb;material.specularStrength=specularStrength;",lights_lambert_pars_fragment:iI,lights_pars_begin:iN,lights_toon_fragment:"ToonMaterial material;material.diffuseColor=diffuseColor.rgb;",lights_toon_pars_fragment:iz,lights_phong_fragment:"BlinnPhongMaterial material;material.diffuseColor=diffuseColor.rgb;material.specularColor=specular;material.specularShininess=shininess;material.specularStrength=specularStrength;",lights_phong_pars_fragment:iF,lights_physical_fragment:ik,lights_physical_pars_fragment:iB,lights_fragment_begin:iH,lights_fragment_maps:iV,lights_fragment_end:iG,logdepthbuf_fragment:iW,logdepthbuf_pars_fragment:ij,logdepthbuf_pars_vertex:iq,logdepthbuf_vertex:iX,map_fragment:iY,map_pars_fragment:iZ,map_particle_fragment:iK,map_particle_pars_fragment:iJ,metalnessmap_fragment:iQ,metalnessmap_pars_fragment:i$,morphcolor_vertex:i0,morphnormal_vertex:i1,morphtarget_pars_vertex:i3,morphtarget_vertex:i2,normal_fragment_begin:i4,normal_fragment_maps:i5,normal_pars_fragment:i6,normal_pars_vertex:i8,normal_vertex:i7,normalmap_pars_fragment:i9,clearcoat_normal_fragment_begin:re,clearcoat_normal_fragment_maps:rt,clearcoat_pars_fragment:ri,iridescence_pars_fragment:rr,opaque_fragment:ra,packing:"vec3 packNormalToRGB(const in vec3 normal){return normalize(normal)*0.5+0.5;}vec3 unpackRGBToNormal(const in vec3 rgb){return 2.0*rgb.xyz-1.0;}const float PackUpscale=256./255.;const float UnpackDownscale=255./256.;const vec3 PackFactors=vec3(256.*256.*256.,256.*256.,256.);const vec4 UnpackFactors=UnpackDownscale/vec4(PackFactors,1.);const float ShiftRight8=1./256.;vec4 packDepthToRGBA(const in float v){vec4 r=vec4(fract(v*PackFactors),v);r.yzw-=r.xyz*ShiftRight8;return r*PackUpscale;}float unpackRGBAToDepth(const in vec4 v){return dot(v,UnpackFactors);}vec2 packDepthToRG(in highp float v){return packDepthToRGBA(v).yx;}float unpackRGToDepth(const in highp vec2 v){return unpackRGBAToDepth(vec4(v.xy,0.0,0.0));}vec4 pack2HalfToRGBA(vec2 v){vec4 r=vec4(v.x,fract(v.x*255.0),v.y,fract(v.y*255.0));return vec4(r.x-r.y/255.0,r.y,r.z-r.w/255.0,r.w);}vec2 unpackRGBATo2Half(vec4 v){return vec2(v.x+(v.y/255.0),v.z+(v.w/255.0));}float viewZToOrthographicDepth(const in float viewZ,const in float near,const in float far){return(viewZ+near)/(near-far);}float orthographicDepthToViewZ(const in float depth,const in float near,const in float far){return depth*(near-far)-near;}float viewZToPerspectiveDepth(const in float viewZ,const in float near,const in float far){return((near+viewZ)*far)/((far-near)*viewZ);}float perspectiveDepthToViewZ(const in float depth,const in float near,const in float far){return(near*far)/((far-near)*depth-far);}",premultiplied_alpha_fragment:rn,project_vertex:rs,dithering_fragment:ro,dithering_pars_fragment:rl,roughnessmap_fragment:rh,roughnessmap_pars_fragment:rc,shadowmap_pars_fragment:ru,shadowmap_pars_vertex:rd,shadowmap_vertex:rp,shadowmask_pars_fragment:rf,skinbase_vertex:rm,skinning_pars_vertex:rg,skinning_vertex:rv,skinnormal_vertex:r_,specularmap_fragment:rx,specularmap_pars_fragment:ry,tonemapping_fragment:rM,tonemapping_pars_fragment:rS,transmission_fragment:rb,transmission_pars_fragment:rw,uv_pars_fragment:rT,uv_pars_vertex:rE,uv_vertex:rA,worldpos_vertex:rC,background_vert:"varying vec2 vUv;uniform mat3 uvTransform;void main(){vUv=(uvTransform*vec3(uv,1)).xy;gl_Position=vec4(position.xy,1.0,1.0);}",background_frag:rL,backgroundCube_vert:rP,backgroundCube_frag:rR,cube_vert:rD,cube_frag:rU,depth_vert:rI,depth_frag:rN,distanceRGBA_vert:rO,distanceRGBA_frag:rz,equirect_vert:rF,equirect_frag:rk,linedashed_vert:rB,linedashed_frag:rH,meshbasic_vert:rV,meshbasic_frag:rG,meshlambert_vert:rW,meshlambert_frag:rj,meshmatcap_vert:rq,meshmatcap_frag:rX,meshnormal_vert:rY,meshnormal_frag:rZ,meshphong_vert:rK,meshphong_frag:rJ,meshphysical_vert:rQ,meshphysical_frag:r$,meshtoon_vert:r0,meshtoon_frag:r1,points_vert:r3,points_frag:r2,shadow_vert:r4,shadow_frag:r5,sprite_vert:r6,sprite_frag:r8},r9={common:{diffuse:{value:new te(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new y},alphaMap:{value:null},alphaMapTransform:{value:new y},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new y}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new y}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new y}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new y},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new y},normalScale:{value:new x(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new y},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new y}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new y}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new y}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new te(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:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{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 te(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new y},alphaTest:{value:0},uvTransform:{value:new y}},sprite:{diffuse:{value:new te(16777215)},opacity:{value:1},center:{value:new x(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new y},alphaMap:{value:null},alphaMapTransform:{value:new y},alphaTest:{value:0}}},ae={basic:{uniforms:tF([r9.common,r9.specularmap,r9.envmap,r9.aomap,r9.lightmap,r9.fog]),vertexShader:r7.meshbasic_vert,fragmentShader:r7.meshbasic_frag},lambert:{uniforms:tF([r9.common,r9.specularmap,r9.envmap,r9.aomap,r9.lightmap,r9.emissivemap,r9.bumpmap,r9.normalmap,r9.displacementmap,r9.fog,r9.lights,{emissive:{value:new te(0)}}]),vertexShader:r7.meshlambert_vert,fragmentShader:r7.meshlambert_frag},phong:{uniforms:tF([r9.common,r9.specularmap,r9.envmap,r9.aomap,r9.lightmap,r9.emissivemap,r9.bumpmap,r9.normalmap,r9.displacementmap,r9.fog,r9.lights,{emissive:{value:new te(0)},specular:{value:new te(1118481)},shininess:{value:30}}]),vertexShader:r7.meshphong_vert,fragmentShader:r7.meshphong_frag},standard:{uniforms:tF([r9.common,r9.envmap,r9.aomap,r9.lightmap,r9.emissivemap,r9.bumpmap,r9.normalmap,r9.displacementmap,r9.roughnessmap,r9.metalnessmap,r9.fog,r9.lights,{emissive:{value:new te(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:r7.meshphysical_vert,fragmentShader:r7.meshphysical_frag},toon:{uniforms:tF([r9.common,r9.aomap,r9.lightmap,r9.emissivemap,r9.bumpmap,r9.normalmap,r9.displacementmap,r9.gradientmap,r9.fog,r9.lights,{emissive:{value:new te(0)}}]),vertexShader:r7.meshtoon_vert,fragmentShader:r7.meshtoon_frag},matcap:{uniforms:tF([r9.common,r9.bumpmap,r9.normalmap,r9.displacementmap,r9.fog,{matcap:{value:null}}]),vertexShader:r7.meshmatcap_vert,fragmentShader:r7.meshmatcap_frag},points:{uniforms:tF([r9.points,r9.fog]),vertexShader:r7.points_vert,fragmentShader:r7.points_frag},dashed:{uniforms:tF([r9.common,r9.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:r7.linedashed_vert,fragmentShader:r7.linedashed_frag},depth:{uniforms:tF([r9.common,r9.displacementmap]),vertexShader:r7.depth_vert,fragmentShader:r7.depth_frag},normal:{uniforms:tF([r9.common,r9.bumpmap,r9.normalmap,r9.displacementmap,{opacity:{value:1}}]),vertexShader:r7.meshnormal_vert,fragmentShader:r7.meshnormal_frag},sprite:{uniforms:tF([r9.sprite,r9.fog]),vertexShader:r7.sprite_vert,fragmentShader:r7.sprite_frag},background:{uniforms:{uvTransform:{value:new y},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:r7.background_vert,fragmentShader:r7.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:r7.backgroundCube_vert,fragmentShader:r7.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:r7.cube_vert,fragmentShader:r7.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:r7.equirect_vert,fragmentShader:r7.equirect_frag},distanceRGBA:{uniforms:tF([r9.common,r9.displacementmap,{referencePosition:{value:new W},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:r7.distanceRGBA_vert,fragmentShader:r7.distanceRGBA_frag},shadow:{uniforms:tF([r9.lights,r9.fog,{color:{value:new te(0)},opacity:{value:1}}]),vertexShader:r7.shadow_vert,fragmentShader:r7.shadow_frag}};ae.physical={uniforms:tF([ae.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new y},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new y},clearcoatNormalScale:{value:new x(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new y},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new y},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new y},sheen:{value:0},sheenColor:{value:new te(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new y},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new y},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new y},transmissionSamplerSize:{value:new x},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new y},attenuationDistance:{value:0},attenuationColor:{value:new te(0)},specularColor:{value:new te(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new y},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new y},anisotropyVector:{value:new x},anisotropyMap:{value:null},anisotropyMapTransform:{value:new y}}]),vertexShader:r7.meshphysical_vert,fragmentShader:r7.meshphysical_frag};let at={r:0,b:0,g:0};function ai(e,t,i,r,a,s,o){let l,h;let c=new te(0),u=!0===s?0:1,d=null,p=0,f=null;function m(t,i){t.getRGB(at,tk(e)),r.buffers.color.setClear(at.r,at.g,at.b,i,o)}return{getClearColor:function(){return c},setClearColor:function(e,t=1){c.set(e),m(c,u=t)},getClearAlpha:function(){return u},setClearAlpha:function(e){m(c,u=e)},render:function(s,g){let v=!1,_=!0===g.isScene?g.background:null;if(_&&_.isTexture){let e=g.backgroundBlurriness>0;_=(e?i:t).get(_)}null===_?m(c,u):_&&_.isColor&&(m(_,1),v=!0);let x=e.xr.getEnvironmentBlendMode();"additive"===x?r.buffers.color.setClear(0,0,0,1,o):"alpha-blend"===x&&r.buffers.color.setClear(0,0,0,0,o),(e.autoClear||v)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),_&&(_.isCubeTexture||306===_.mapping)?(void 0===h&&((h=new tI(new tO(1,1,1),new tH({name:"BackgroundCubeMaterial",uniforms:tz(ae.backgroundCube.uniforms),vertexShader:ae.backgroundCube.vertexShader,fragmentShader:ae.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(e,t,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(h)),h.material.uniforms.envMap.value=_,h.material.uniforms.flipEnvMap.value=_.isCubeTexture&&!1===_.isRenderTargetTexture?-1:1,h.material.uniforms.backgroundBlurriness.value=g.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,h.material.toneMapped=_.colorSpace!==n,(d!==_||p!==_.version||f!==e.toneMapping)&&(h.material.needsUpdate=!0,d=_,p=_.version,f=e.toneMapping),h.layers.enableAll(),s.unshift(h,h.geometry,h.material,0,0,null)):_&&_.isTexture&&(void 0===l&&((l=new tI(new t3(2,2),new tH({name:"BackgroundMaterial",uniforms:tz(ae.background.uniforms),vertexShader:ae.background.vertexShader,fragmentShader:ae.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=g.backgroundIntensity,l.material.toneMapped=_.colorSpace!==n,!0===_.matrixAutoUpdate&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(d!==_||p!==_.version||f!==e.toneMapping)&&(l.material.needsUpdate=!0,d=_,p=_.version,f=e.toneMapping),l.layers.enableAll(),s.unshift(l,l.geometry,l.material,0,0,null))}}}function ar(e,t,i,r){let a=e.getParameter(34921),n=r.isWebGL2?null:t.get("OES_vertex_array_object"),s=r.isWebGL2||null!==n,o={},l=p(null),h=l,c=!1;function u(t){return r.isWebGL2?e.bindVertexArray(t):n.bindVertexArrayOES(t)}function d(t){return r.isWebGL2?e.deleteVertexArray(t):n.deleteVertexArrayOES(t)}function p(e){let t=[],i=[],r=[];for(let e=0;e=0){let i=a[t],r=n[t];if(void 0===r&&("instanceMatrix"===t&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(r=e.instanceColor)),void 0===i||i.attribute!==r||r&&i.data!==r.data)return!0;s++}}return h.attributesNum!==s||h.index!==r}(a,x,d,y))&&function(e,t,i,r){let a={},n=t.attributes,s=0,o=i.getAttributes();for(let t in o){let i=o[t];if(i.location>=0){let i=n[t];void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor));let r={};r.attribute=i,i&&i.data&&(r.data=i.data),a[t]=r,s++}}h.attributes=a,h.attributesNum=s,h.index=r}(a,x,d,y)}else{let e=!0===l.wireframe;(h.geometry!==x.id||h.program!==d.id||h.wireframe!==e)&&(h.geometry=x.id,h.program=d.id,h.wireframe=e,M=!0)}null!==y&&i.update(y,34963),(M||c)&&(c=!1,function(a,n,s,o){if(!1===r.isWebGL2&&(a.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();let l=o.attributes,h=s.getAttributes(),c=n.defaultAttributeValues;for(let t in h){let n=h[t];if(n.location>=0){let s=l[t];if(void 0===s&&("instanceMatrix"===t&&a.instanceMatrix&&(s=a.instanceMatrix),"instanceColor"===t&&a.instanceColor&&(s=a.instanceColor)),void 0!==s){let t=s.normalized,l=s.itemSize,h=i.get(s);if(void 0===h)continue;let c=h.buffer,u=h.type,d=h.bytesPerElement,p=!0===r.isWebGL2&&(5124===u||5125===u||1013===s.gpuType);if(s.isInterleavedBufferAttribute){let i=s.data,r=i.stride,h=s.offset;if(i.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}let n="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name,s=void 0!==i.precision?i.precision:"highp",o=a(s);o!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",o,"instead."),s=o);let l=n||t.has("WEBGL_draw_buffers"),h=!0===i.logarithmicDepthBuffer,c=e.getParameter(34930),u=e.getParameter(35660),d=e.getParameter(3379),p=e.getParameter(34076),f=e.getParameter(34921),m=e.getParameter(36347),g=e.getParameter(36348),v=e.getParameter(36349),_=u>0,x=n||t.has("OES_texture_float"),y=n?e.getParameter(36183):0;return{isWebGL2:n,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){let i=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,precision:s,logarithmicDepthBuffer:h,maxTextures:c,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:_,floatFragmentTextures:x,floatVertexTextures:_&&x,maxSamples:y}}function as(e){let t=this,i=null,r=0,a=!1,n=!1,s=new tK,o=new y,l={value:null,needsUpdate:!1};function h(e,i,r,a){let n=null!==e?e.length:0,h=null;if(0!==n){if(h=l.value,!0!==a||null===h){let t=r+4*n,a=i.matrixWorldInverse;o.getNormalMatrix(a),(null===h||h.length0),t.numPlanes=r,t.numIntersection=0)}}function ao(e){let t=new WeakMap;function i(e,t){return 303===t?e.mapping=301:304===t&&(e.mapping=302),e}function r(e){let i=e.target;i.removeEventListener("dispose",r);let a=t.get(i);void 0!==a&&(t.delete(i),a.dispose())}return{get:function(a){if(a&&a.isTexture&&!1===a.isRenderTargetTexture){let n=a.mapping;if(303===n||304===n){if(t.has(a)){let e=t.get(a).texture;return i(e,a.mapping)}{let n=a.image;if(!n||!(n.height>0))return null;{let s=new tq(n.height/2);return s.fromEquirectangularTexture(e,a),t.set(a,s),a.addEventListener("dispose",r),i(s.texture,a.mapping)}}}}return a},dispose:function(){t=new WeakMap}}}class al extends tV{constructor(e=-1,t=1,i=1,r=-1,a=.1,n=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=r,this.near=a,this.far=n,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,i,r,a,n){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=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=r,this.view.width=a,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,r=(this.top+this.bottom)/2,a=i-e,n=i+e,s=r+t,o=r-t;if(null!==this.view&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a+=e*this.view.offsetX,n=a+e*this.view.width,s-=t*this.view.offsetY,o=s-t*this.view.height}this.projectionMatrix.makeOrthographic(a,n,s,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}let ah=[.125,.215,.35,.446,.526,.582],ac=new al,au=new te,ad=null,ap=(1+Math.sqrt(5))/2,af=1/ap,am=[new W(1,1,1),new W(-1,1,1),new W(1,1,-1),new W(-1,1,-1),new W(0,ap,af),new W(0,ap,-af),new W(af,0,ap),new W(-af,0,ap),new W(ap,af,0),new W(-ap,af,0)];class ag{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,i=.1,r=100){ad=this._renderer.getRenderTarget(),this._setSize(256);let a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,i,r,a),t>0&&this._blur(a,0,0,t),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=ay(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=ax(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=ah[s-e+4-1]:0===s&&(o=0),r.push(o);let l=1/(n-2),h=-l,c=1+l,u=[h,h,c,h,c,c,h,h,c,c,h,c],d=new Float32Array(108),p=new Float32Array(72),f=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,i=e>2?0:-1,r=[t,i,0,t+2/3,i,0,t+2/3,i+1,0,t,i,0,t+2/3,i+1,0,t,i+1,0];d.set(r,18*e),p.set(u,12*e);let a=[e,e,e,e,e,e];f.set(a,6*e)}let m=new tg;m.setAttribute("position",new tn(d,3)),m.setAttribute("uv",new tn(p,2)),m.setAttribute("faceIndex",new tn(f,1)),t.push(m),a>4&&a--}return{lodPlanes:t,sizeLods:i,sigmas:r}}(r)),this._blurMaterial=function(e,t,i){let r=new Float32Array(20),a=new W(0,1,0),n=new tH({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/i,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:a}},vertexShader:aM(),fragmentShader:`precision mediump float;precision mediump int;varying vec3 vOutputDirection;uniform sampler2D envMap;uniform int samples;uniform float weights[n];uniform bool latitudinal;uniform float dTheta;uniform float mipInt;uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample(float theta,vec3 axis){float cosTheta=cos(theta);vec3 sampleDirection=vOutputDirection*cosTheta+cross(axis,vOutputDirection)*sin(theta)+axis*dot(axis,vOutputDirection)*(1.0-cosTheta);return bilinearCubeUV(envMap,sampleDirection,mipInt);}void main(){vec3 axis=latitudinal?poleAxis:cross(poleAxis,vOutputDirection);if(all(equal(axis,vec3(0.0)))){axis=vec3(vOutputDirection.z,0.0,-vOutputDirection.x);}axis=normalize(axis);gl_FragColor=vec4(0.0,0.0,0.0,1.0);gl_FragColor.rgb+=weights[0]*getSample(0.0,axis);for(int i=1;i=samples){break;}float theta=dTheta*float(i);gl_FragColor.rgb+=weights[i]*getSample(-1.0*theta,axis);gl_FragColor.rgb+=weights[i]*getSample(theta,axis);}}`,blending:0,depthTest:!1,depthWrite:!1});return n}(r,e,t)}return r}_compileMaterial(e){let t=new tI(this._lodPlanes[0],e);this._renderer.compile(t,ac)}_sceneToCubeUV(e,t,i,r){let a=new tG(90,1,t,i),n=[1,-1,1,1,1,1],s=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,h=o.toneMapping;o.getClearColor(au),o.toneMapping=0,o.autoClear=!1;let c=new ti({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),u=new tI(new tO,c),d=!1,p=e.background;p?p.isColor&&(c.color.copy(p),e.background=null,d=!0):(c.color.copy(au),d=!0);for(let t=0;t<6;t++){let i=t%3;0===i?(a.up.set(0,n[t],0),a.lookAt(s[t],0,0)):1===i?(a.up.set(0,0,n[t]),a.lookAt(0,s[t],0)):(a.up.set(0,n[t],0),a.lookAt(0,0,s[t]));let l=this._cubeSize;a_(r,i*l,t>2?l:0,l,l),o.setRenderTarget(r),d&&o.render(u,a),o.render(e,a)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=h,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){let i=this._renderer,r=301===e.mapping||302===e.mapping;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=ay()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=ax());let a=r?this._cubemapMaterial:this._equirectMaterial,n=new tI(this._lodPlanes[0],a),s=a.uniforms;s.envMap.value=e;let o=this._cubeSize;a_(t,0,0,3*o,2*o),i.setRenderTarget(t),i.render(n,ac)}_applyPMREM(e){let t=this._renderer,i=t.autoClear;t.autoClear=!1;for(let t=1;t20&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);let m=[],g=0;for(let e=0;e<20;++e){let t=e/p,i=Math.exp(-t*t/2);m.push(i),0===e?g+=i:ev-4?r-v+4:0),x,3*_,2*_),o.setRenderTarget(t),o.render(h,ac)}}function av(e,t,i){let r=new H(e,t,i);return r.texture.mapping=306,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function a_(e,t,i,r,a){e.viewport.set(t,i,r,a),e.scissor.set(t,i,r,a)}function ax(){return new tH({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:aM(),fragmentShader:`precision mediump float;precision mediump int;varying vec3 vOutputDirection;uniform sampler2D envMap; #include void main(){vec3 outputDirection=normalize(vOutputDirection);vec2 uv=equirectUv(outputDirection);gl_FragColor=vec4(texture2D(envMap,uv).rgb,1.0);}`,blending:0,depthTest:!1,depthWrite:!1})}function ay(){return new tH({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:aM(),fragmentShader:"precision mediump float;precision mediump int;uniform float flipEnvMap;varying vec3 vOutputDirection;uniform samplerCube envMap;void main(){gl_FragColor=textureCube(envMap,vec3(flipEnvMap*vOutputDirection.x,vOutputDirection.yz));}",blending:0,depthTest:!1,depthWrite:!1})}function aM(){return"precision mediump float;precision mediump int;attribute float faceIndex;varying vec3 vOutputDirection;vec3 getDirection(vec2 uv,float face){uv=2.0*uv-1.0;vec3 direction=vec3(uv,1.0);if(face==0.0){direction=direction.zyx;}else if(face==1.0){direction=direction.xzy;direction.xz*=-1.0;}else if(face==2.0){direction.x*=-1.0;}else if(face==3.0){direction=direction.zyx;direction.xz*=-1.0;}else if(face==4.0){direction=direction.xzy;direction.xy*=-1.0;}else if(face==5.0){direction.z*=-1.0;}return direction;}void main(){vOutputDirection=getDirection(uv,faceIndex);gl_Position=vec4(position,1.0);}"}function aS(e){let t=new WeakMap,i=null;function r(e){let i=e.target;i.removeEventListener("dispose",r);let a=t.get(i);void 0!==a&&(t.delete(i),a.dispose())}return{get:function(a){if(a&&a.isTexture){let n=a.mapping,s=303===n||304===n,o=301===n||302===n;if(s||o){if(a.isRenderTargetTexture&&!0===a.needsPMREMUpdate){a.needsPMREMUpdate=!1;let r=t.get(a);return null===i&&(i=new ag(e)),r=s?i.fromEquirectangular(a,r):i.fromCubemap(a,r),t.set(a,r),r.texture}if(t.has(a))return t.get(a).texture;{let n=a.image;if(!(s&&n&&n.height>0||o&&n&&function(e){let t=0;for(let i=0;i<6;i++)void 0!==e[i]&&t++;return 6===t}(n)))return null;{null===i&&(i=new ag(e));let n=s?i.fromEquirectangular(a):i.fromCubemap(a);return t.set(a,n),a.addEventListener("dispose",r),n.texture}}}}return a},dispose:function(){t=new WeakMap,null!==i&&(i.dispose(),i=null)}}}function ab(e){let t={};function i(i){let r;if(void 0!==t[i])return t[i];switch(i){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(i)}return t[i]=r,r}return{has:function(e){return null!==i(e)},init:function(e){e.isWebGL2?i("EXT_color_buffer_float"):(i("WEBGL_depth_texture"),i("OES_texture_float"),i("OES_texture_half_float"),i("OES_texture_half_float_linear"),i("OES_standard_derivatives"),i("OES_element_index_uint"),i("OES_vertex_array_object"),i("ANGLE_instanced_arrays")),i("OES_texture_float_linear"),i("EXT_color_buffer_half_float"),i("WEBGL_multisampled_render_to_texture")},get:function(e){let t=i(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function aw(e,t,i,r){let a={},n=new WeakMap;function s(e){let o=e.target;for(let e in null!==o.index&&t.remove(o.index),o.attributes)t.remove(o.attributes[e]);for(let e in o.morphAttributes){let i=o.morphAttributes[e];for(let e=0,r=i.length;et.maxTextureSize&&(f=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let m=new Float32Array(p*f*4*a),g=new V(m,p,f,a);g.type=1015,g.needsUpdate=!0;let v=4*d;for(let t=0;t0)return e;let a=t*i,n=aN[a];if(void 0===n&&(n=new Float32Array(a),aN[a]=n),0!==t){r.toArray(n,0);for(let r=1,a=0;r!==t;++r)a+=i,e[r].toArray(n,a)}return n}function aH(e,t){if(e.length!==t.length)return!1;for(let i=0,r=e.length;i":" "} ${a}: ${i[e]}`)}return r.join("\n")}(e.getShaderSource(t),r)}}function nA(e){return""!==e}function nC(e,t){let i=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,i).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function nL(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}let nP=/^[ \t]*#include +<([\w\d./]+)>/gm;function nR(e){return e.replace(nP,nU)}let nD=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function nU(e,t){let i=r7[t];if(void 0===i){let e=nD.get(t);if(void 0!==e)i=r7[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e);else throw Error("Can not resolve #include <"+t+">")}return nR(i)}let nI=/#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 nN(e){return e.replace(nI,nO)}function nO(e,t,i,r){let a="";for(let e=parseInt(t);e0&&(a+="\n"),(o=[S,"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,b].filter(nA).join("\n")).length>0&&(o+="\n")):(a=[nz(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,b,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+x:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.displacementMap?"#define USE_DISPLACEMENTMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.mapUv?"#define MAP_UV "+i.mapUv:"",i.alphaMapUv?"#define ALPHAMAP_UV "+i.alphaMapUv:"",i.lightMapUv?"#define LIGHTMAP_UV "+i.lightMapUv:"",i.aoMapUv?"#define AOMAP_UV "+i.aoMapUv:"",i.emissiveMapUv?"#define EMISSIVEMAP_UV "+i.emissiveMapUv:"",i.bumpMapUv?"#define BUMPMAP_UV "+i.bumpMapUv:"",i.normalMapUv?"#define NORMALMAP_UV "+i.normalMapUv:"",i.displacementMapUv?"#define DISPLACEMENTMAP_UV "+i.displacementMapUv:"",i.metalnessMapUv?"#define METALNESSMAP_UV "+i.metalnessMapUv:"",i.roughnessMapUv?"#define ROUGHNESSMAP_UV "+i.roughnessMapUv:"",i.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+i.anisotropyMapUv:"",i.clearcoatMapUv?"#define CLEARCOATMAP_UV "+i.clearcoatMapUv:"",i.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+i.clearcoatNormalMapUv:"",i.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+i.clearcoatRoughnessMapUv:"",i.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+i.iridescenceMapUv:"",i.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+i.iridescenceThicknessMapUv:"",i.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+i.sheenColorMapUv:"",i.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+i.sheenRoughnessMapUv:"",i.specularMapUv?"#define SPECULARMAP_UV "+i.specularMapUv:"",i.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+i.specularColorMapUv:"",i.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+i.specularIntensityMapUv:"",i.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+i.transmissionMapUv:"",i.thicknessMapUv?"#define THICKNESSMAP_UV "+i.thicknessMapUv:"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.morphColors&&i.isWebGL2?"#define USE_MORPHCOLORS":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+i.morphTextureStride:"",i.morphTargetsCount>0&&i.isWebGL2?"#define MORPHTARGETS_COUNT "+i.morphTargetsCount:"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+v:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.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"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif","\n"].filter(nA).join("\n"),o=[S,nz(i),"#define SHADER_TYPE "+i.shaderType,"#define SHADER_NAME "+i.shaderName,b,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+_:"",i.envMap?"#define "+x:"",i.envMap?"#define "+y:"",M?"#define CUBEUV_TEXEL_WIDTH "+M.texelWidth:"",M?"#define CUBEUV_TEXEL_HEIGHT "+M.texelHeight:"",M?"#define CUBEUV_MAX_MIP "+M.maxMip+".0":"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",i.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.anisotropy?"#define USE_ANISOTROPY":"",i.anisotropyMap?"#define USE_ANISOTROPYMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.iridescence?"#define USE_IRIDESCENCE":"",i.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",i.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",i.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.alphaHash?"#define USE_ALPHAHASH":"",i.sheen?"#define USE_SHEEN":"",i.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",i.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents&&!1===i.flatShading?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUv1s?"#define USE_UV1":"",i.vertexUv2s?"#define USE_UV2":"",i.vertexUv3s?"#define USE_UV3":"",i.pointsUvs?"#define USE_POINTS_UV":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+v:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.useLegacyLights?"#define LEGACY_LIGHTS":"",i.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?r7.tonemapping_pars_fragment:"",0!==i.toneMapping?function(e,t){let i;switch(t){case 1:i="Linear";break;case 2:i="Reinhard";break;case 3:i="OptimizedCineon";break;case 4:i="ACESFilmic";break;case 5:i="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),i="Linear"}return"vec3 "+e+"( vec3 color ) { return "+i+"ToneMapping( color ); }"}("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.opaque?"#define OPAQUE":"",r7.colorspace_pars_fragment,function(e,t){let i=function(e){switch(e){case s:return["Linear","( value )"];case n:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+i[0]+i[1]+"; }"}("linearToOutputTexel",i.outputColorSpace),i.useDepthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(nA).join("\n")),m=nL(m=nC(m=nR(m),i),i),g=nL(g=nC(g=nR(g),i),i),m=nN(m),g=nN(g),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(T="#version 300 es\n",a="precision mediump sampler2DArray;\n#define attribute in\n#define varying out\n#define texture2D texture\n"+a,o=["#define varying in",i.glslVersion===l?"":"layout(location = 0) out highp vec4 pc_fragColor;",i.glslVersion===l?"":"#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"+o);let E=T+a+m,A=T+o+g,C=nw(p,35633,E),L=nw(p,35632,A);if(p.attachShader(w,C),p.attachShader(w,L),void 0!==i.index0AttributeName?p.bindAttribLocation(w,0,i.index0AttributeName):!0===i.morphTargets&&p.bindAttribLocation(w,0,"position"),p.linkProgram(w),e.debug.checkShaderErrors){let t=p.getProgramInfoLog(w).trim(),i=p.getShaderInfoLog(C).trim(),r=p.getShaderInfoLog(L).trim(),n=!0,s=!0;if(!1===p.getProgramParameter(w,35714)){if(n=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(p,w,C,L);else{let e=nE(p,C,"vertex"),i=nE(p,L,"fragment");console.error("THREE.WebGLProgram: Shader Error "+p.getError()+" - VALIDATE_STATUS "+p.getProgramParameter(w,35715)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+i)}}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):(""===i||""===r)&&(s=!1);s&&(this.diagnostics={runnable:n,programLog:t,vertexShader:{log:i,prefix:a},fragmentShader:{log:r,prefix:o}})}return p.deleteShader(C),p.deleteShader(L),this.getUniforms=function(){return void 0===h&&(h=new nb(p,w)),h},this.getAttributes=function(){return void 0===c&&(c=function(e,t){let i={},r=e.getProgramParameter(t,35721);for(let a=0;a0,X=o.clearcoat>0,Y=o.iridescence>0,Z=o.sheen>0,K=o.transmission>0,J=q&&!!o.anisotropyMap,Q=X&&!!o.clearcoatMap,$=X&&!!o.clearcoatNormalMap,ee=X&&!!o.clearcoatRoughnessMap,et=Y&&!!o.iridescenceMap,ei=Y&&!!o.iridescenceThicknessMap,er=Z&&!!o.sheenColorMap,ea=Z&&!!o.sheenRoughnessMap,en=!!o.specularMap,es=!!o.specularColorMap,eo=!!o.specularIntensityMap,el=K&&!!o.transmissionMap,eh=K&&!!o.thicknessMap,ec=!!o.gradientMap,eu=!!o.alphaMap,ed=o.alphaTest>0,ep=!!o.alphaHash,ef=!!o.extensions,em=!!T.attributes.uv1,eg=!!T.attributes.uv2,ev=!!T.attributes.uv3,e_=0;o.toneMapped&&(null===U||!0===U.isXRRenderTarget)&&(e_=e.toneMapping);let ex={isWebGL2:d,shaderID:L,shaderType:o.type,shaderName:o.name,vertexShader:y,fragmentShader:M,defines:o.defines,customVertexShaderID:S,customFragmentShaderID:b,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:m,instancing:I,instancingColor:I&&null!==x.instanceColor,supportsVertexTextures:f,outputColorSpace:null===U?e.outputColorSpace:!0===U.isXRRenderTarget?U.texture.colorSpace:s,map:N,matcap:O,envMap:z,envMapMode:z&&A.mapping,envMapCubeUVHeight:C,aoMap:F,lightMap:k,bumpMap:B,normalMap:H,displacementMap:f&&V,emissiveMap:G,normalMapObjectSpace:H&&1===o.normalMapType,normalMapTangentSpace:H&&0===o.normalMapType,metalnessMap:W,roughnessMap:j,anisotropy:q,anisotropyMap:J,clearcoat:X,clearcoatMap:Q,clearcoatNormalMap:$,clearcoatRoughnessMap:ee,iridescence:Y,iridescenceMap:et,iridescenceThicknessMap:ei,sheen:Z,sheenColorMap:er,sheenRoughnessMap:ea,specularMap:en,specularColorMap:es,specularIntensityMap:eo,transmission:K,transmissionMap:el,thicknessMap:eh,gradientMap:ec,opaque:!1===o.transparent&&1===o.blending,alphaMap:eu,alphaTest:ed,alphaHash:ep,combine:o.combine,mapUv:N&&v(o.map.channel),aoMapUv:F&&v(o.aoMap.channel),lightMapUv:k&&v(o.lightMap.channel),bumpMapUv:B&&v(o.bumpMap.channel),normalMapUv:H&&v(o.normalMap.channel),displacementMapUv:V&&v(o.displacementMap.channel),emissiveMapUv:G&&v(o.emissiveMap.channel),metalnessMapUv:W&&v(o.metalnessMap.channel),roughnessMapUv:j&&v(o.roughnessMap.channel),anisotropyMapUv:J&&v(o.anisotropyMap.channel),clearcoatMapUv:Q&&v(o.clearcoatMap.channel),clearcoatNormalMapUv:$&&v(o.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ee&&v(o.clearcoatRoughnessMap.channel),iridescenceMapUv:et&&v(o.iridescenceMap.channel),iridescenceThicknessMapUv:ei&&v(o.iridescenceThicknessMap.channel),sheenColorMapUv:er&&v(o.sheenColorMap.channel),sheenRoughnessMapUv:ea&&v(o.sheenRoughnessMap.channel),specularMapUv:en&&v(o.specularMap.channel),specularColorMapUv:es&&v(o.specularColorMap.channel),specularIntensityMapUv:eo&&v(o.specularIntensityMap.channel),transmissionMapUv:el&&v(o.transmissionMap.channel),thicknessMapUv:eh&&v(o.thicknessMap.channel),alphaMapUv:eu&&v(o.alphaMap.channel),vertexTangents:!!T.attributes.tangent&&(H||q),vertexColors:o.vertexColors,vertexAlphas:!0===o.vertexColors&&!!T.attributes.color&&4===T.attributes.color.itemSize,vertexUv1s:em,vertexUv2s:eg,vertexUv3s:ev,pointsUvs:!0===x.isPoints&&!!T.attributes.uv&&(N||eu),fog:!!w,useFog:!0===o.fog,fogExp2:w&&w.isFogExp2,flatShading:!0===o.flatShading,sizeAttenuation:!0===o.sizeAttenuation,logarithmicDepthBuffer:p,skinning:!0===x.isSkinnedMesh,morphTargets:void 0!==T.morphAttributes.position,morphNormals:void 0!==T.morphAttributes.normal,morphColors:void 0!==T.morphAttributes.color,morphTargetsCount:R,morphTextureStride:D,numDirLights:h.directional.length,numPointLights:h.point.length,numSpotLights:h.spot.length,numSpotLightMaps:h.spotLightMap.length,numRectAreaLights:h.rectArea.length,numHemiLights:h.hemi.length,numDirLightShadows:h.directionalShadowMap.length,numPointLightShadows:h.pointShadowMap.length,numSpotLightShadows:h.spotShadowMap.length,numSpotLightShadowsWithMaps:h.numSpotLightShadowsWithMaps,numClippingPlanes:l.numPlanes,numClipIntersection:l.numIntersection,dithering:o.dithering,shadowMapEnabled:e.shadowMap.enabled&&u.length>0,shadowMapType:e.shadowMap.type,toneMapping:e_,useLegacyLights:e._useLegacyLights,decodeVideoTexture:N&&!0===o.map.isVideoTexture&&o.map.colorSpace===n,premultipliedAlpha:o.premultipliedAlpha,doubleSided:2===o.side,flipSided:1===o.side,useDepthPacking:o.depthPacking>=0,depthPacking:o.depthPacking||0,index0AttributeName:o.index0AttributeName,extensionDerivatives:ef&&!0===o.extensions.derivatives,extensionFragDepth:ef&&!0===o.extensions.fragDepth,extensionDrawBuffers:ef&&!0===o.extensions.drawBuffers,extensionShaderTextureLOD:ef&&!0===o.extensions.shaderTextureLOD,rendererExtensionFragDepth:d||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:d||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:d||r.has("EXT_shader_texture_lod"),customProgramCacheKey:o.customProgramCacheKey()};return ex},getProgramCacheKey:function(t){let i=[];if(t.shaderID?i.push(t.shaderID):(i.push(t.customVertexShaderID),i.push(t.customFragmentShaderID)),void 0!==t.defines)for(let e in t.defines)i.push(e),i.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(i.push(t.precision),i.push(t.outputColorSpace),i.push(t.envMapMode),i.push(t.envMapCubeUVHeight),i.push(t.mapUv),i.push(t.alphaMapUv),i.push(t.lightMapUv),i.push(t.aoMapUv),i.push(t.bumpMapUv),i.push(t.normalMapUv),i.push(t.displacementMapUv),i.push(t.emissiveMapUv),i.push(t.metalnessMapUv),i.push(t.roughnessMapUv),i.push(t.anisotropyMapUv),i.push(t.clearcoatMapUv),i.push(t.clearcoatNormalMapUv),i.push(t.clearcoatRoughnessMapUv),i.push(t.iridescenceMapUv),i.push(t.iridescenceThicknessMapUv),i.push(t.sheenColorMapUv),i.push(t.sheenRoughnessMapUv),i.push(t.specularMapUv),i.push(t.specularColorMapUv),i.push(t.specularIntensityMapUv),i.push(t.transmissionMapUv),i.push(t.thicknessMapUv),i.push(t.combine),i.push(t.fogExp2),i.push(t.sizeAttenuation),i.push(t.morphTargetsCount),i.push(t.morphAttributeCount),i.push(t.numDirLights),i.push(t.numPointLights),i.push(t.numSpotLights),i.push(t.numSpotLightMaps),i.push(t.numHemiLights),i.push(t.numRectAreaLights),i.push(t.numDirLightShadows),i.push(t.numPointLightShadows),i.push(t.numSpotLightShadows),i.push(t.numSpotLightShadowsWithMaps),i.push(t.shadowMapType),i.push(t.toneMapping),i.push(t.numClippingPlanes),i.push(t.numClipIntersection),i.push(t.depthPacking),h.disableAll(),t.isWebGL2&&h.enable(0),t.supportsVertexTextures&&h.enable(1),t.instancing&&h.enable(2),t.instancingColor&&h.enable(3),t.matcap&&h.enable(4),t.envMap&&h.enable(5),t.normalMapObjectSpace&&h.enable(6),t.normalMapTangentSpace&&h.enable(7),t.clearcoat&&h.enable(8),t.iridescence&&h.enable(9),t.alphaTest&&h.enable(10),t.vertexColors&&h.enable(11),t.vertexAlphas&&h.enable(12),t.vertexUv1s&&h.enable(13),t.vertexUv2s&&h.enable(14),t.vertexUv3s&&h.enable(15),t.vertexTangents&&h.enable(16),t.anisotropy&&h.enable(17),i.push(h.mask),h.disableAll(),t.fog&&h.enable(0),t.useFog&&h.enable(1),t.flatShading&&h.enable(2),t.logarithmicDepthBuffer&&h.enable(3),t.skinning&&h.enable(4),t.morphTargets&&h.enable(5),t.morphNormals&&h.enable(6),t.morphColors&&h.enable(7),t.premultipliedAlpha&&h.enable(8),t.shadowMapEnabled&&h.enable(9),t.useLegacyLights&&h.enable(10),t.doubleSided&&h.enable(11),t.flipSided&&h.enable(12),t.useDepthPacking&&h.enable(13),t.dithering&&h.enable(14),t.transmission&&h.enable(15),t.sheen&&h.enable(16),t.opaque&&h.enable(17),t.pointsUvs&&h.enable(18),t.decodeVideoTexture&&h.enable(19),i.push(h.mask),i.push(e.outputColorSpace)),i.push(t.customProgramCacheKey),i.join()},getUniforms:function(e){let t;let i=g[e.type];if(i){let e=ae[i];t=tB.clone(e.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,i){let r;for(let e=0,t=u.length;e0?r.push(c):!0===s.transparent?a.push(c):i.push(c)},unshift:function(e,t,s,o,l,h){let c=n(e,t,s,o,l,h);s.transmission>0?r.unshift(c):!0===s.transparent?a.unshift(c):i.unshift(c)},finish:function(){for(let i=t,r=e.length;i1&&i.sort(e||nW),r.length>1&&r.sort(t||nj),a.length>1&&a.sort(t||nj)}}}function nX(){let e=new WeakMap;return{get:function(t,i){let r;let a=e.get(t);return void 0===a?(r=new nq,e.set(t,[r])):i>=a.length?(r=new nq,a.push(r)):r=a[i],r},dispose:function(){e=new WeakMap}}}function nY(){let e={};return{get:function(t){let i;if(void 0!==e[t.id])return e[t.id];switch(t.type){case"DirectionalLight":i={direction:new W,color:new te};break;case"SpotLight":i={position:new W,direction:new W,color:new te,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new W,color:new te,distance:0,decay:0};break;case"HemisphereLight":i={direction:new W,skyColor:new te,groundColor:new te};break;case"RectAreaLight":i={color:new te,position:new W,halfWidth:new W,halfHeight:new W}}return e[t.id]=i,i}}}let nZ=0;function nK(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function nJ(e,t){let i=new nY,r=function(){let e={};return{get:function(t){let i;if(void 0!==e[t.id])return e[t.id];switch(t.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new x};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new x,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=i,i}}}(),a={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let e=0;e<9;e++)a.probe.push(new W);let n=new W,s=new ey,o=new ey;return{setup:function(n,s){let o=0,l=0,h=0;for(let e=0;e<9;e++)a.probe[e].set(0,0,0);let c=0,u=0,d=0,p=0,f=0,m=0,g=0,v=0,_=0,x=0;n.sort(nK);let y=!0===s?Math.PI:1;for(let e=0,t=n.length;e0&&(t.isWebGL2?(a.rectAreaLTC1=r9.LTC_FLOAT_1,a.rectAreaLTC2=r9.LTC_FLOAT_2):!0===e.has("OES_texture_float_linear")?(a.rectAreaLTC1=r9.LTC_FLOAT_1,a.rectAreaLTC2=r9.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(a.rectAreaLTC1=r9.LTC_HALF_1,a.rectAreaLTC2=r9.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),a.ambient[0]=o,a.ambient[1]=l,a.ambient[2]=h;let M=a.hash;(M.directionalLength!==c||M.pointLength!==u||M.spotLength!==d||M.rectAreaLength!==p||M.hemiLength!==f||M.numDirectionalShadows!==m||M.numPointShadows!==g||M.numSpotShadows!==v||M.numSpotMaps!==_)&&(a.directional.length=c,a.spot.length=d,a.rectArea.length=p,a.point.length=u,a.hemi.length=f,a.directionalShadow.length=m,a.directionalShadowMap.length=m,a.pointShadow.length=g,a.pointShadowMap.length=g,a.spotShadow.length=v,a.spotShadowMap.length=v,a.directionalShadowMatrix.length=m,a.pointShadowMatrix.length=g,a.spotLightMatrix.length=v+_-x,a.spotLightMap.length=_,a.numSpotLightShadowsWithMaps=x,M.directionalLength=c,M.pointLength=u,M.spotLength=d,M.rectAreaLength=p,M.hemiLength=f,M.numDirectionalShadows=m,M.numPointShadows=g,M.numSpotShadows=v,M.numSpotMaps=_,a.version=nZ++)},setupView:function(e,t){let i=0,r=0,l=0,h=0,c=0,u=t.matrixWorldInverse;for(let t=0,d=e.length;t=s.length?(n=new nQ(e,t),s.push(n)):n=s[a],n},dispose:function(){i=new WeakMap}}}class n0 extends e5{constructor(e){super(),this.isMeshDepthMaterial=!0,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.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class n1 extends e5{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}let n3=`uniform sampler2D shadow_pass;uniform vec2 resolution;uniform float radius; #include void main(){const float samples=float(VSM_SAMPLES);float mean=0.0;float squared_mean=0.0;float uvStride=samples<=1.0?0.0:2.0/(samples-1.0);float uvStart=samples<=1.0?0.0:-1.0;for(float i=0.0;i0||i.map&&i.alphaTest>0){let e=n.uuid,t=i.uuid,r=h[e];void 0===r&&(r={},h[e]=r);let a=r[t];void 0===a&&(a=n.clone(),r[t]=a),n=a}if(n.visible=i.visible,n.wireframe=i.wireframe,3===a?n.side=null!==i.shadowSide?i.shadowSide:i.side:n.side=null!==i.shadowSide?i.shadowSide:u[i.side],n.alphaMap=i.alphaMap,n.alphaTest=i.alphaTest,n.map=i.map,n.clipShadows=i.clipShadows,n.clippingPlanes=i.clippingPlanes,n.clipIntersection=i.clipIntersection,n.displacementMap=i.displacementMap,n.displacementScale=i.displacementScale,n.displacementBias=i.displacementBias,n.wireframeLinewidth=i.wireframeLinewidth,n.linewidth=i.linewidth,!0===r.isPointLight&&!0===n.isMeshDistanceMaterial){let t=e.properties.get(n);t.light=r}return n}this.render=function(i,o,l){if(!1===g.enabled||!1===g.autoUpdate&&!1===g.needsUpdate||0===i.length)return;let h=e.getRenderTarget(),u=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),x=e.state;x.setBlending(0),x.buffers.color.setClear(1,1,1,1),x.buffers.depth.setTest(!0),x.setScissorTest(!1);let y=3!==v&&3===this.type,M=3===v&&3!==this.type;for(let h=0,u=i.length;hc||a.y>c)&&(a.x>c&&(n.x=Math.floor(c/g.x),a.x=n.x*g.x,f.mapSize.x=n.x),a.y>c&&(n.y=Math.floor(c/g.y),a.y=n.y*g.y,f.mapSize.y=n.y)),null===f.map||!0===y||!0===M){let e=3!==this.type?{minFilter:1003,magFilter:1003}:{};null!==f.map&&f.map.dispose(),f.map=new H(a.x,a.y,e),f.map.texture.name=u.name+".shadowMap",f.camera.updateProjectionMatrix()}e.setRenderTarget(f.map),e.clear();let v=f.getViewportCount();for(let i=0;i=1:-1!==P.indexOf("OpenGL ES")&&(L=parseFloat(/^OpenGL ES (\d)/.exec(P)[1])>=2);let R=null,D={},U=e.getParameter(3088),I=e.getParameter(2978),N=new k().fromArray(U),O=new k().fromArray(I);function z(t,i,a,n){let s=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let o=0;or||e.height>r)&&(a=r/Math.max(e.width,e.height)),a<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){let r=t?g:Math.floor,n=r(a*e.width),s=r(a*e.height);void 0===c&&(c=w(n,s));let o=i?w(n,s):c;o.width=n,o.height=s;let l=o.getContext("2d");return l.drawImage(e,0,0,n,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+n+"x"+s+")."),o}"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+").")}return e}function E(e){return m(e.width)&&m(e.height)}function A(e,t){return e.generateMipmaps&&t&&1003!==e.minFilter&&1006!==e.minFilter}function C(t){e.generateMipmap(t)}function L(i,r,a,s,o=!1){if(!1===u)return r;if(null!==i){if(void 0!==e[i])return e[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let l=r;return 6403===r&&(5126===a&&(l=33326),5131===a&&(l=33325),5121===a&&(l=33321)),36244===r&&(5121===a&&(l=33330),5123===a&&(l=33332),5125===a&&(l=33334),5120===a&&(l=33329),5122===a&&(l=33331),5124===a&&(l=33333)),33319===r&&(5126===a&&(l=33328),5131===a&&(l=33327),5121===a&&(l=33323)),6408===r&&(5126===a&&(l=34836),5131===a&&(l=34842),5121===a&&(l=s===n&&!1===o?35907:32856),32819===a&&(l=32854),32820===a&&(l=32855)),(33325===l||33326===l||33327===l||33328===l||34842===l||34836===l)&&t.get("EXT_color_buffer_float"),l}function P(e,t,i){return!0===A(e,i)||e.isFramebufferTexture&&1003!==e.minFilter&&1006!==e.minFilter?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function R(e){return 1003===e||1004===e||1005===e?9728:9729}function D(e){let t=e.target;t.removeEventListener("dispose",D),function(e){let t=r.get(e);if(void 0===t.__webglInit)return;let i=e.source,a=M.get(i);if(a){let r=a[t.__cacheKey];r.usedTimes--,0===r.usedTimes&&N(e),0===Object.keys(a).length&&M.delete(i)}r.remove(e)}(t),t.isVideoTexture&&y.delete(t)}function I(t){let i=t.target;i.removeEventListener("dispose",I),function(t){let i=t.texture,a=r.get(t),n=r.get(i);if(void 0!==n.__webglTexture&&(e.deleteTexture(n.__webglTexture),h.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(a.__webglFramebuffer[t]))for(let i=0;i0&&a.__version!==e.version){let i=e.image;if(null===i)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(!1===i.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{G(a,e,t);return}}i.bindTexture(3553,a.__webglTexture,33984+t)}let F={1e3:10497,1001:33071,1002:33648},k={1003:9728,1004:9984,1005:9986,1006:9729,1007:9985,1008:9987},B={512:512,519:519,513:513,515:515,514:514,518:518,516:516,517:517};function H(i,n,s){if(s?(e.texParameteri(i,10242,F[n.wrapS]),e.texParameteri(i,10243,F[n.wrapT]),(32879===i||35866===i)&&e.texParameteri(i,32882,F[n.wrapR]),e.texParameteri(i,10240,k[n.magFilter]),e.texParameteri(i,10241,k[n.minFilter])):(e.texParameteri(i,10242,33071),e.texParameteri(i,10243,33071),(32879===i||35866===i)&&e.texParameteri(i,32882,33071),(1001!==n.wrapS||1001!==n.wrapT)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(i,10240,R(n.magFilter)),e.texParameteri(i,10241,R(n.minFilter)),1003!==n.minFilter&&1006!==n.minFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),n.compareFunction&&(e.texParameteri(i,34892,34894),e.texParameteri(i,34893,B[n.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){let s=t.get("EXT_texture_filter_anisotropic");1003!==n.magFilter&&(1005===n.minFilter||1008===n.minFilter)&&(1015!==n.type||!1!==t.has("OES_texture_float_linear"))&&(!1!==u||1016!==n.type||!1!==t.has("OES_texture_half_float_linear"))&&(n.anisotropy>1||r.get(n).__currentAnisotropy)&&(e.texParameterf(i,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(n.anisotropy,a.getMaxAnisotropy())),r.get(n).__currentAnisotropy=n.anisotropy)}}function V(t,i){let r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,i.addEventListener("dispose",D));let a=i.source,n=M.get(a);void 0===n&&(n={},M.set(a,n));let s=function(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(i);if(s!==t.__cacheKey){void 0===n[s]&&(n[s]={texture:e.createTexture(),usedTimes:0},h.memory.textures++,r=!0),n[s].usedTimes++;let a=n[t.__cacheKey];void 0!==a&&(n[t.__cacheKey].usedTimes--,0===a.usedTimes&&N(i)),t.__cacheKey=s,t.__webglTexture=n[s].texture}return r}function G(t,a,n){let s=3553;(a.isDataArrayTexture||a.isCompressedArrayTexture)&&(s=35866),a.isData3DTexture&&(s=32879);let o=V(t,a),h=a.source;i.bindTexture(s,t.__webglTexture,33984+n);let c=r.get(h);if(h.version!==c.__version||!0===o){let t;i.activeTexture(33984+n),e.pixelStorei(37440,a.flipY),e.pixelStorei(37441,a.premultiplyAlpha),e.pixelStorei(3317,a.unpackAlignment),e.pixelStorei(37443,0);let r=!u&&(1001!==a.wrapS||1001!==a.wrapT||1003!==a.minFilter&&1006!==a.minFilter)&&!1===E(a.image),d=T(a.image,r,!1,f);d=Z(a,d);let p=E(d)||u,m=l.convert(a.format,a.colorSpace),g=l.convert(a.type),v=L(a.internalFormat,m,g,a.colorSpace,a.isVideoTexture);H(s,a,p);let _=a.mipmaps,x=u&&!0!==a.isVideoTexture,y=void 0===c.__version||!0===o,M=P(a,d,p);if(a.isDepthTexture)v=6402,u?v=1015===a.type?36012:1014===a.type?33190:1020===a.type?35056:33189:1015===a.type&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),1026===a.format&&6402===v&&1012!==a.type&&1014!==a.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),a.type=1014,g=l.convert(a.type)),1027===a.format&&6402===v&&(v=34041,1020!==a.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),a.type=1020,g=l.convert(a.type))),y&&(x?i.texStorage2D(3553,1,v,d.width,d.height):i.texImage2D(3553,0,v,d.width,d.height,0,m,g,null));else if(a.isDataTexture){if(_.length>0&&p){x&&y&&i.texStorage2D(3553,M,v,_[0].width,_[0].height);for(let e=0,r=_.length;e>=1,t>>=1}}}else if(_.length>0&&p){x&&y&&i.texStorage2D(3553,M,v,_[0].width,_[0].height);for(let e=0,r=_.length;e>h),t=Math.max(1,a.height>>h);32879===o||35866===o?i.texImage3D(o,h,d,e,t,a.depth,0,c,u,null):i.texImage2D(o,h,d,e,t,0,c,u,null)}i.bindFramebuffer(36160,t),Y(a)?_.framebufferTexture2DMultisampleEXT(36160,s,o,r.get(n).__webglTexture,0,X(a)):(3553===o||o>=34069&&o<=34074)&&e.framebufferTexture2D(36160,s,o,r.get(n).__webglTexture,h),i.bindFramebuffer(36160,null)}function j(t,i,r){if(e.bindRenderbuffer(36161,t),i.depthBuffer&&!i.stencilBuffer){let a=33189;if(r||Y(i)){let t=i.depthTexture;t&&t.isDepthTexture&&(1015===t.type?a=36012:1014===t.type&&(a=33190));let r=X(i);Y(i)?_.renderbufferStorageMultisampleEXT(36161,r,a,i.width,i.height):e.renderbufferStorageMultisample(36161,r,a,i.width,i.height)}else e.renderbufferStorage(36161,a,i.width,i.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(i.depthBuffer&&i.stencilBuffer){let a=X(i);r&&!1===Y(i)?e.renderbufferStorageMultisample(36161,a,35056,i.width,i.height):Y(i)?_.renderbufferStorageMultisampleEXT(36161,a,35056,i.width,i.height):e.renderbufferStorage(36161,34041,i.width,i.height),e.framebufferRenderbuffer(36160,33306,36161,t)}else{let t=!0===i.isWebGLMultipleRenderTargets?i.texture:[i.texture];for(let a=0;a0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==i.__useRenderToTexture}function Z(e,i){let r=e.colorSpace,a=e.format,l=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||1035===e.format||r!==s&&""!==r&&(r===n||r===o?!1===u?!0===t.has("EXT_sRGB")&&1023===a?(e.format=1035,e.minFilter=1006,e.generateMipmaps=!1):i=U.sRGBToLinear(i):(1023!==a||1009!==l)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",r)),i}this.allocateTextureUnit=function(){let e=O;return e>=d&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+d),O+=1,e},this.resetTextureUnits=function(){O=0},this.setTexture2D=z,this.setTexture2DArray=function(e,t){let a=r.get(e);if(e.version>0&&a.__version!==e.version){G(a,e,t);return}i.bindTexture(35866,a.__webglTexture,33984+t)},this.setTexture3D=function(e,t){let a=r.get(e);if(e.version>0&&a.__version!==e.version){G(a,e,t);return}i.bindTexture(32879,a.__webglTexture,33984+t)},this.setTextureCube=function(t,a){let n=r.get(t);if(t.version>0&&n.__version!==t.version){(function(t,a,n){if(6!==a.image.length)return;let s=V(t,a),o=a.source;i.bindTexture(34067,t.__webglTexture,33984+n);let h=r.get(o);if(o.version!==h.__version||!0===s){let t;i.activeTexture(33984+n),e.pixelStorei(37440,a.flipY),e.pixelStorei(37441,a.premultiplyAlpha),e.pixelStorei(3317,a.unpackAlignment),e.pixelStorei(37443,0);let r=a.isCompressedTexture||a.image[0].isCompressedTexture,c=a.image[0]&&a.image[0].isDataTexture,d=[];for(let e=0;e<6;e++)r||c?d[e]=c?a.image[e].image:a.image[e]:d[e]=T(a.image[e],!1,!0,p),d[e]=Z(a,d[e]);let f=d[0],m=E(f)||u,g=l.convert(a.format,a.colorSpace),v=l.convert(a.type),_=L(a.internalFormat,g,v,a.colorSpace),x=u&&!0!==a.isVideoTexture,y=void 0===h.__version||!0===s,M=P(a,f,m);if(H(34067,a,m),r){x&&y&&i.texStorage2D(34067,M,_,f.width,f.height);for(let e=0;e<6;e++){t=d[e].mipmaps;for(let r=0;r0&&M++,i.texStorage2D(34067,M,_,d[0].width,d[0].height));for(let e=0;e<6;e++)if(c){x?i.texSubImage2D(34069+e,0,0,0,d[e].width,d[e].height,g,v,d[e].data):i.texImage2D(34069+e,0,_,d[e].width,d[e].height,0,g,v,d[e].data);for(let r=0;r0){s.__webglFramebuffer[t]=[];for(let i=0;i0){s.__webglFramebuffer=[];for(let t=0;t0&&!1===Y(t)){let r=d?n:[n];s.__webglMultisampledFramebuffer=e.createFramebuffer(),s.__webglColorRenderbuffer=[],i.bindFramebuffer(36160,s.__webglMultisampledFramebuffer);for(let i=0;i0)for(let i=0;i0)for(let i=0;i0&&!1===Y(t)){let a=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],n=t.width,s=t.height,o=16384,l=[],h=t.stencilBuffer?33306:36096,c=r.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;t.025?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=.015&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&null!==(a=t.getPose(e.gripSpace,i))&&(o.matrix.fromArray(a.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,a.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(a.linearVelocity)):o.hasLinearVelocity=!1,a.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(a.angularVelocity)):o.hasAngularVelocity=!1);null!==s&&(null===(r=t.getPose(e.targetRaySpace,i))&&null!==a&&(r=a),null!==r&&(s.matrix.fromArray(r.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,r.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(r.linearVelocity)):s.hasLinearVelocity=!1,r.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(r.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(n9)))}return null!==s&&(s.visible=null!==r),null!==o&&(o.visible=null!==a),null!==l&&(l.visible=null!==n),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){let i=new n7;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}class st extends F{constructor(e,t,i,r,a,n,s,o,l,h){if(1026!==(h=void 0!==h?h:1026)&&1027!==h)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&1026===h&&(i=1014),void 0===i&&1027===h&&(i=1020),super(null,r,a,n,s,o,h,i,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==s?s:1003,this.minFilter=void 0!==o?o:1003,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class si extends h{constructor(e,t){super();let i=this,r=null,a=1,n=null,s="local-floor",o=1,l=null,h=null,c=null,u=null,p=null,f=null,m=t.getContextAttributes(),g=null,v=null,_=[],x=[],y=new tG;y.layers.enable(1),y.viewport=new k;let M=new tG;M.layers.enable(2),M.viewport=new k;let S=[y,M],b=new n8;b.layers.enable(1),b.layers.enable(2);let w=null,T=null;function E(e){let t=x.indexOf(e.inputSource);if(-1===t)return;let i=_[t];void 0!==i&&(i.update(e.inputSource,e.frame,l||n),i.dispatchEvent({type:e.type,data:e.inputSource}))}function A(){r.removeEventListener("select",E),r.removeEventListener("selectstart",E),r.removeEventListener("selectend",E),r.removeEventListener("squeeze",E),r.removeEventListener("squeezestart",E),r.removeEventListener("squeezeend",E),r.removeEventListener("end",A),r.removeEventListener("inputsourceschange",C);for(let e=0;e<_.length;e++){let t=x[e];null!==t&&(x[e]=null,_[e].disconnect(t))}w=null,T=null,e.setRenderTarget(g),p=null,u=null,c=null,r=null,v=null,U.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function C(e){for(let t=0;t=0&&(x[r]=null,_[r].disconnect(i))}for(let t=0;t=x.length){x.push(i),r=e;break}if(null===x[e]){x[e]=i,r=e;break}}if(-1===r)break}let a=_[r];a&&a.connect(i)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=_[e];return void 0===t&&(t=new se,_[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=_[e];return void 0===t&&(t=new se,_[e]=t),t.getGripSpace()},this.getHand=function(e){let t=_[e];return void 0===t&&(t=new se,_[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){a=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||n},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==u?u:p},this.getBinding=function(){return c},this.getFrame=function(){return f},this.getSession=function(){return r},this.setSession=async function(h){if(null!==(r=h)){if(g=e.getRenderTarget(),r.addEventListener("select",E),r.addEventListener("selectstart",E),r.addEventListener("selectend",E),r.addEventListener("squeeze",E),r.addEventListener("squeezestart",E),r.addEventListener("squeezeend",E),r.addEventListener("end",A),r.addEventListener("inputsourceschange",C),!0!==m.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers||!1===e.capabilities.isWebGL2){let i={antialias:void 0!==r.renderState.layers||m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:a};p=new XRWebGLLayer(r,t,i),r.updateRenderState({baseLayer:p}),v=new H(p.framebufferWidth,p.framebufferHeight,{format:1023,type:1009,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let i=null,n=null,s=null;m.depth&&(s=m.stencil?35056:33190,i=m.stencil?1027:1026,n=m.stencil?1020:1014);let o={colorFormat:32856,depthFormat:s,scaleFactor:a};u=(c=new XRWebGLBinding(r,t)).createProjectionLayer(o),r.updateRenderState({layers:[u]}),v=new H(u.textureWidth,u.textureHeight,{format:1023,type:1009,depthTexture:new st(u.textureWidth,u.textureHeight,n,void 0,void 0,void 0,void 0,void 0,void 0,i),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0});let l=e.properties.get(v);l.__ignoreDepthValues=u.ignoreDepthValues}v.isXRRenderTarget=!0,this.setFoveation(o),l=null,n=await r.requestReferenceSpace(s),U.setContext(r),U.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==r)return r.environmentBlendMode};let L=new W,P=new W;function R(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){var t;if(null===r)return;b.near=M.near=y.near=e.near,b.far=M.far=y.far=e.far,(w!==b.near||T!==b.far)&&(r.updateRenderState({depthNear:b.near,depthFar:b.far}),w=b.near,T=b.far);let i=e.parent,a=b.cameras;R(b,i);for(let e=0;e0&&(r.alphaTest.value=a.alphaTest);let n=t.get(a).envMap;if(n&&(r.envMap.value=n,r.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,r.reflectivity.value=a.reflectivity,r.ior.value=a.ior,r.refractionRatio.value=a.refractionRatio),a.lightMap){r.lightMap.value=a.lightMap;let t=!0===e._useLegacyLights?Math.PI:1;r.lightMapIntensity.value=a.lightMapIntensity*t,i(a.lightMap,r.lightMapTransform)}a.aoMap&&(r.aoMap.value=a.aoMap,r.aoMapIntensity.value=a.aoMapIntensity,i(a.aoMap,r.aoMapTransform))}return{refreshFogUniforms:function(t,i){i.color.getRGB(t.fogColor.value,tk(e)),i.isFog?(t.fogNear.value=i.near,t.fogFar.value=i.far):i.isFogExp2&&(t.fogDensity.value=i.density)},refreshMaterialUniforms:function(e,a,n,s,o){var l,h,c,u,d,p,f,m;a.isMeshBasicMaterial?r(e,a):a.isMeshLambertMaterial?r(e,a):a.isMeshToonMaterial?(r(e,a),l=e,a.gradientMap&&(l.gradientMap.value=a.gradientMap)):a.isMeshPhongMaterial?(r(e,a),(h=e).specular.value.copy(a.specular),h.shininess.value=Math.max(a.shininess,1e-4)):a.isMeshStandardMaterial?(r(e,a),function(e,r){e.metalness.value=r.metalness,r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap,i(r.metalnessMap,e.metalnessMapTransform)),e.roughness.value=r.roughness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap,i(r.roughnessMap,e.roughnessMapTransform));let a=t.get(r).envMap;a&&(e.envMapIntensity.value=r.envMapIntensity)}(e,a),a.isMeshPhysicalMaterial&&((c=e).ior.value=a.ior,a.sheen>0&&(c.sheenColor.value.copy(a.sheenColor).multiplyScalar(a.sheen),c.sheenRoughness.value=a.sheenRoughness,a.sheenColorMap&&(c.sheenColorMap.value=a.sheenColorMap,i(a.sheenColorMap,c.sheenColorMapTransform)),a.sheenRoughnessMap&&(c.sheenRoughnessMap.value=a.sheenRoughnessMap,i(a.sheenRoughnessMap,c.sheenRoughnessMapTransform))),a.clearcoat>0&&(c.clearcoat.value=a.clearcoat,c.clearcoatRoughness.value=a.clearcoatRoughness,a.clearcoatMap&&(c.clearcoatMap.value=a.clearcoatMap,i(a.clearcoatMap,c.clearcoatMapTransform)),a.clearcoatRoughnessMap&&(c.clearcoatRoughnessMap.value=a.clearcoatRoughnessMap,i(a.clearcoatRoughnessMap,c.clearcoatRoughnessMapTransform)),a.clearcoatNormalMap&&(c.clearcoatNormalMap.value=a.clearcoatNormalMap,i(a.clearcoatNormalMap,c.clearcoatNormalMapTransform),c.clearcoatNormalScale.value.copy(a.clearcoatNormalScale),1===a.side&&c.clearcoatNormalScale.value.negate())),a.iridescence>0&&(c.iridescence.value=a.iridescence,c.iridescenceIOR.value=a.iridescenceIOR,c.iridescenceThicknessMinimum.value=a.iridescenceThicknessRange[0],c.iridescenceThicknessMaximum.value=a.iridescenceThicknessRange[1],a.iridescenceMap&&(c.iridescenceMap.value=a.iridescenceMap,i(a.iridescenceMap,c.iridescenceMapTransform)),a.iridescenceThicknessMap&&(c.iridescenceThicknessMap.value=a.iridescenceThicknessMap,i(a.iridescenceThicknessMap,c.iridescenceThicknessMapTransform))),a.transmission>0&&(c.transmission.value=a.transmission,c.transmissionSamplerMap.value=o.texture,c.transmissionSamplerSize.value.set(o.width,o.height),a.transmissionMap&&(c.transmissionMap.value=a.transmissionMap,i(a.transmissionMap,c.transmissionMapTransform)),c.thickness.value=a.thickness,a.thicknessMap&&(c.thicknessMap.value=a.thicknessMap,i(a.thicknessMap,c.thicknessMapTransform)),c.attenuationDistance.value=a.attenuationDistance,c.attenuationColor.value.copy(a.attenuationColor)),a.anisotropy>0&&(c.anisotropyVector.value.set(a.anisotropy*Math.cos(a.anisotropyRotation),a.anisotropy*Math.sin(a.anisotropyRotation)),a.anisotropyMap&&(c.anisotropyMap.value=a.anisotropyMap,i(a.anisotropyMap,c.anisotropyMapTransform))),c.specularIntensity.value=a.specularIntensity,c.specularColor.value.copy(a.specularColor),a.specularColorMap&&(c.specularColorMap.value=a.specularColorMap,i(a.specularColorMap,c.specularColorMapTransform)),a.specularIntensityMap&&(c.specularIntensityMap.value=a.specularIntensityMap,i(a.specularIntensityMap,c.specularIntensityMapTransform)))):a.isMeshMatcapMaterial?(r(e,a),u=e,a.matcap&&(u.matcap.value=a.matcap)):a.isMeshDepthMaterial?r(e,a):a.isMeshDistanceMaterial?(r(e,a),function(e,i){let r=t.get(i).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}(e,a)):a.isMeshNormalMaterial?r(e,a):a.isLineBasicMaterial?((d=e).diffuse.value.copy(a.color),d.opacity.value=a.opacity,a.map&&(d.map.value=a.map,i(a.map,d.mapTransform)),a.isLineDashedMaterial&&((p=e).dashSize.value=a.dashSize,p.totalSize.value=a.dashSize+a.gapSize,p.scale.value=a.scale)):a.isPointsMaterial?((f=e).diffuse.value.copy(a.color),f.opacity.value=a.opacity,f.size.value=a.size*n,f.scale.value=.5*s,a.map&&(f.map.value=a.map,i(a.map,f.uvTransform)),a.alphaMap&&(f.alphaMap.value=a.alphaMap,i(a.alphaMap,f.alphaMapTransform)),a.alphaTest>0&&(f.alphaTest.value=a.alphaTest)):a.isSpriteMaterial?((m=e).diffuse.value.copy(a.color),m.opacity.value=a.opacity,m.rotation.value=a.rotation,a.map&&(m.map.value=a.map,i(a.map,m.mapTransform)),a.alphaMap&&(m.alphaMap.value=a.alphaMap,i(a.alphaMap,m.alphaMapTransform)),a.alphaTest>0&&(m.alphaTest.value=a.alphaTest)):a.isShadowMaterial?(e.color.value.copy(a.color),e.opacity.value=a.opacity):a.isShaderMaterial&&(a.uniformsNeedUpdate=!1)}}}function sa(e,t,i,r){let a={},n={},s=[],o=i.isWebGL2?e.getParameter(35375):0;function l(e){let t={boundary:0,storage:0};return"number"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function h(t){let i=t.target;i.removeEventListener("dispose",h);let r=s.indexOf(i.__bindingPointIndex);s.splice(r,1),e.deleteBuffer(a[i.id]),delete a[i.id],delete n[i.id]}return{bind:function(e,t){let i=t.program;r.uniformBlockBinding(e,i)},update:function(i,c){let u=a[i.id];void 0===u&&(function(e){let t=e.uniforms,i=0,r=0;for(let e=0,a=t.length;e0){r=i%16;let e=16-r;0!==r&&e-n.boundary<0&&(i+=16-r,a.__offset=i)}i+=n.storage}(r=i%16)>0&&(i+=16-r),e.__size=i,e.__cache={}}(i),u=function(t){let i=function(){for(let e=0;eo.matrixWorld.determinant(),_=function(e,t,i,n,o){var d,p;!0!==t.isScene&&(t=ew),h.resetTextureUnits();let f=t.fog,m=n.isMeshStandardMaterial?t.environment:null,g=null===ee?K.outputColorSpace:!0===ee.isXRRenderTarget?ee.texture.colorSpace:s,_=(n.isMeshStandardMaterial?u:c).get(n.envMap||m),x=!0===n.vertexColors&&!!i.attributes.color&&4===i.attributes.color.itemSize,y=!!i.attributes.tangent&&(!!n.normalMap||n.anisotropy>0),S=!!i.morphAttributes.position,b=!!i.morphAttributes.normal,w=!!i.morphAttributes.color,E=0;n.toneMapped&&(null===ee||!0===ee.isXRRenderTarget)&&(E=K.toneMapping);let A=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,C=void 0!==A?A.length:0,L=l.get(n),R=X.state.lights;if(!0===ev&&(!0===e_||e!==ei)){let t=e===ei&&n.id===et;M.setState(n,e,t)}let D=!1;n.version===L.__version?L.needsLights&&L.lightsStateVersion!==R.state.version?D=!0:L.outputColorSpace!==g?D=!0:o.isInstancedMesh&&!1===L.instancing?D=!0:o.isInstancedMesh||!0!==L.instancing?o.isSkinnedMesh&&!1===L.skinning?D=!0:o.isSkinnedMesh||!0!==L.skinning?o.isInstancedMesh&&!0===L.instancingColor&&null===o.instanceColor?D=!0:o.isInstancedMesh&&!1===L.instancingColor&&null!==o.instanceColor?D=!0:L.envMap!==_?D=!0:!0===n.fog&&L.fog!==f?D=!0:void 0!==L.numClippingPlanes&&(L.numClippingPlanes!==M.numPlanes||L.numIntersection!==M.numIntersection)?D=!0:L.vertexAlphas!==x?D=!0:L.vertexTangents!==y?D=!0:L.morphTargets!==S?D=!0:L.morphNormals!==b?D=!0:L.morphColors!==w?D=!0:L.toneMapping!==E?D=!0:!0===r.isWebGL2&&L.morphTargetsCount!==C&&(D=!0):D=!0:D=!0:(D=!0,L.__version=n.version);let U=L.currentProgram;!0===D&&(U=eH(n,t,o));let I=!1,N=!1,O=!1,z=U.getUniforms(),F=L.uniforms;if(a.useProgram(U.program)&&(I=!0,N=!0,O=!0),n.id!==et&&(et=n.id,N=!0),I||ei!==e){z.setValue(eE,"projectionMatrix",e.projectionMatrix),z.setValue(eE,"viewMatrix",e.matrixWorldInverse);let t=z.map.cameraPosition;void 0!==t&&t.setValue(eE,eb.setFromMatrixPosition(e.matrixWorld)),r.logarithmicDepthBuffer&&z.setValue(eE,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(n.isMeshPhongMaterial||n.isMeshToonMaterial||n.isMeshLambertMaterial||n.isMeshBasicMaterial||n.isMeshStandardMaterial||n.isShaderMaterial)&&z.setValue(eE,"isOrthographic",!0===e.isOrthographicCamera),ei!==e&&(ei=e,N=!0,O=!0)}if(o.isSkinnedMesh){z.setOptional(eE,o,"bindMatrix"),z.setOptional(eE,o,"bindMatrixInverse");let e=o.skeleton;e&&(r.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),z.setValue(eE,"boneTexture",e.boneTexture,h),z.setValue(eE,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let k=i.morphAttributes;if((void 0!==k.position||void 0!==k.normal||void 0!==k.color&&!0===r.isWebGL2)&&T.update(o,i,U),(N||L.receiveShadow!==o.receiveShadow)&&(L.receiveShadow=o.receiveShadow,z.setValue(eE,"receiveShadow",o.receiveShadow)),n.isMeshGouraudMaterial&&null!==n.envMap&&(F.envMap.value=_,F.flipEnvMap.value=_.isCubeTexture&&!1===_.isRenderTargetTexture?-1:1),N&&(z.setValue(eE,"toneMappingExposure",K.toneMappingExposure),L.needsLights&&(d=F,p=O,d.ambientLightColor.needsUpdate=p,d.lightProbe.needsUpdate=p,d.directionalLights.needsUpdate=p,d.directionalLightShadows.needsUpdate=p,d.pointLights.needsUpdate=p,d.pointLightShadows.needsUpdate=p,d.spotLights.needsUpdate=p,d.spotLightShadows.needsUpdate=p,d.rectAreaLights.needsUpdate=p,d.hemisphereLights.needsUpdate=p),f&&!0===n.fog&&v.refreshFogUniforms(F,f),v.refreshMaterialUniforms(F,n,ec,eh,ex),nb.upload(eE,L.uniformsList,F,h)),n.isShaderMaterial&&!0===n.uniformsNeedUpdate&&(nb.upload(eE,L.uniformsList,F,h),n.uniformsNeedUpdate=!1),n.isSpriteMaterial&&z.setValue(eE,"center",o.center),z.setValue(eE,"modelViewMatrix",o.modelViewMatrix),z.setValue(eE,"normalMatrix",o.normalMatrix),z.setValue(eE,"modelMatrix",o.matrixWorld),n.isShaderMaterial||n.isRawShaderMaterial){let e=n.uniformsGroups;for(let t=0,i=e.length;t0&&function(e,t,a,n){let s=r.isWebGL2;null===ex&&(ex=new H(1,1,{generateMipmaps:!0,type:i.has("EXT_color_buffer_half_float")?1016:1009,minFilter:1008,samples:s?4:0})),K.getDrawingBufferSize(eS),s?ex.setSize(eS.x,eS.y):ex.setSize(g(eS.x),g(eS.y));let o=K.getRenderTarget();K.setRenderTarget(ex),K.getClearColor(es),(eo=K.getClearAlpha())<1&&K.setClearColor(16777215,.5),K.clear();let l=K.toneMapping;K.toneMapping=0,ek(e,a,n),h.updateMultisampleRenderTarget(ex),h.updateRenderTargetMipmap(ex);let c=!1;for(let e=0,i=t.length;e0&&ek(o,t,n),l.length>0&&ek(l,t,n),c.length>0&&ek(c,t,n),a.buffers.depth.setTest(!0),a.buffers.depth.setMask(!0),a.buffers.color.setMask(!0),a.setPolygonOffset(!1)}function ek(e,t,i){let r=!0===t.isScene?t.overrideMaterial:null;for(let a=0,n=e.length;a0?Z[Z.length-1]:null,Y.pop(),q=Y.length>0?Y[Y.length-1]:null},this.getActiveCubeFace=function(){return Q},this.getActiveMipmapLevel=function(){return $},this.getRenderTarget=function(){return ee},this.setRenderTargetTextures=function(e,t,r){l.get(e.texture).__webglTexture=t,l.get(e.depthTexture).__webglTexture=r;let a=l.get(e);a.__hasExternalTextures=!0,a.__hasExternalTextures&&(a.__autoAllocateDepthBuffer=void 0===r,a.__autoAllocateDepthBuffer||!0!==i.has("WEBGL_multisampled_render_to_texture")||(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),a.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){let i=l.get(e);i.__webglFramebuffer=t,i.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,i=0){ee=e,Q=t,$=i;let n=!0,s=null,o=!1,c=!1;if(e){let u=l.get(e);void 0!==u.__useDefaultFramebuffer?(a.bindFramebuffer(36160,null),n=!1):void 0===u.__webglFramebuffer?h.setupRenderTarget(e):u.__hasExternalTextures&&h.rebindTextures(e,l.get(e.texture).__webglTexture,l.get(e.depthTexture).__webglTexture);let d=e.texture;(d.isData3DTexture||d.isDataArrayTexture||d.isCompressedArrayTexture)&&(c=!0);let p=l.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(s=Array.isArray(p[t])?p[t][i]:p[t],o=!0):s=r.isWebGL2&&e.samples>0&&!1===h.useMultisampledRTT(e)?l.get(e).__webglMultisampledFramebuffer:Array.isArray(p)?p[i]:p,er.copy(e.viewport),ea.copy(e.scissor),en=e.scissorTest}else er.copy(ep).multiplyScalar(ec).floor(),ea.copy(ef).multiplyScalar(ec).floor(),en=em;let u=a.bindFramebuffer(36160,s);if(u&&r.drawBuffers&&n&&a.drawBuffers(e,s),a.viewport(er),a.scissor(ea),a.setScissorTest(en),o){let r=l.get(e.texture);eE.framebufferTexture2D(36160,36064,34069+t,r.__webglTexture,i)}else if(c){let r=l.get(e.texture);eE.framebufferTextureLayer(36160,36064,r.__webglTexture,i||0,t||0)}et=-1},this.readRenderTargetPixels=function(e,t,n,s,o,h,c){if(!(e&&e.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let u=l.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==c&&(u=u[c]),u){a.bindFramebuffer(36160,u);try{let a=e.texture,l=a.format,c=a.type;if(1023!==l&&C.convert(l)!==eE.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let u=1016===c&&(i.has("EXT_color_buffer_half_float")||r.isWebGL2&&i.has("EXT_color_buffer_float"));if(1009!==c&&C.convert(c)!==eE.getParameter(35738)&&!(1015===c&&(r.isWebGL2||i.has("OES_texture_float")||i.has("WEBGL_color_buffer_float")))&&!u){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}t>=0&&t<=e.width-s&&n>=0&&n<=e.height-o&&eE.readPixels(t,n,s,o,C.convert(l),C.convert(c),h)}finally{let e=null!==ee?l.get(ee).__webglFramebuffer:null;a.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,i=0){let r=Math.pow(2,-i),n=Math.floor(t.image.width*r),s=Math.floor(t.image.height*r);h.setTexture2D(t,0),eE.copyTexSubImage2D(3553,i,0,0,e.x,e.y,n,s),a.unbindTexture()},this.copyTextureToTexture=function(e,t,i,r=0){let n=t.image.width,s=t.image.height,o=C.convert(i.format),l=C.convert(i.type);h.setTexture2D(i,0),eE.pixelStorei(37440,i.flipY),eE.pixelStorei(37441,i.premultiplyAlpha),eE.pixelStorei(3317,i.unpackAlignment),t.isDataTexture?eE.texSubImage2D(3553,r,e.x,e.y,n,s,o,l,t.image.data):t.isCompressedTexture?eE.compressedTexSubImage2D(3553,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):eE.texSubImage2D(3553,r,e.x,e.y,o,l,t.image),0===r&&i.generateMipmaps&&eE.generateMipmap(3553),a.unbindTexture()},this.copyTextureToTexture3D=function(e,t,i,r,n=0){let s;if(K.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let o=e.max.x-e.min.x+1,l=e.max.y-e.min.y+1,c=e.max.z-e.min.z+1,u=C.convert(r.format),d=C.convert(r.type);if(r.isData3DTexture)h.setTexture3D(r,0),s=32879;else if(r.isDataArrayTexture)h.setTexture2DArray(r,0),s=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}eE.pixelStorei(37440,r.flipY),eE.pixelStorei(37441,r.premultiplyAlpha),eE.pixelStorei(3317,r.unpackAlignment);let p=eE.getParameter(3314),f=eE.getParameter(32878),m=eE.getParameter(3316),g=eE.getParameter(3315),v=eE.getParameter(32877),_=i.isCompressedTexture?i.mipmaps[0]:i.image;eE.pixelStorei(3314,_.width),eE.pixelStorei(32878,_.height),eE.pixelStorei(3316,e.min.x),eE.pixelStorei(3315,e.min.y),eE.pixelStorei(32877,e.min.z),i.isDataTexture||i.isData3DTexture?eE.texSubImage3D(s,n,t.x,t.y,t.z,o,l,c,u,d,_.data):i.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),eE.compressedTexSubImage3D(s,n,t.x,t.y,t.z,o,l,c,u,_.data)):eE.texSubImage3D(s,n,t.x,t.y,t.z,o,l,c,u,d,_),eE.pixelStorei(3314,p),eE.pixelStorei(32878,f),eE.pixelStorei(3316,m),eE.pixelStorei(3315,g),eE.pixelStorei(32877,v),0===n&&r.generateMipmaps&&eE.generateMipmap(s),a.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?h.setTextureCube(e,0):e.isData3DTexture?h.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?h.setTexture2DArray(e,0):h.setTexture2D(e,0),a.unbindTexture()},this.resetState=function(){Q=0,$=0,ee=null,a.reset(),L.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return 2e3}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===n?3001:3e3}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=3001===e?n:s}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(e){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=e}}class ss extends ej{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class so{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=35044,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=p()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,i){e*=this.stride,i*=t.stride;for(let r=0,a=this.stride;re.far||t.push({distance:o,point:su.clone(),uv:e2.getInterpolation(su,sv,s_,sx,sy,sM,sS,new x),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function sw(e,t,i,r,a,n){sf.subVectors(e,i).addScalar(.5).multiply(r),void 0!==a?(sm.x=n*sf.x-a*sf.y,sm.y=a*sf.x+n*sf.y):sm.copy(sf),e.copy(t),e.x+=sm.x,e.y+=sm.y,e.applyMatrix4(sg)}class sT extends F{constructor(e,t,i,r,a,n,s,o,l){super(e,t,i,r,a,n,s,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class sE extends e5{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new te(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new te(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new x(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class sA extends ej{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new te(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){let t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}let sC=new ey,sL=new W,sP=new W;class sR{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new x(512,512),this.map=null,this.mapPass=null,this.matrix=new ey,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new t$,this._frameExtents=new x(1,1),this._viewportCount=1,this._viewports=[new k(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){let t=this.camera,i=this.matrix;sL.setFromMatrixPosition(e.matrixWorld),t.position.copy(sL),sP.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(sP),t.updateMatrixWorld(),sC.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sC),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(sC)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){let e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),(512!==this.mapSize.x||512!==this.mapSize.y)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}let sD=new ey,sU=new W,sI=new W;class sN extends sR{constructor(){super(new tG(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new x(4,2),this._viewportCount=6,this._viewports=[new k(2,1,1,1),new k(0,1,1,1),new k(3,1,1,1),new k(1,1,1,1),new k(3,0,1,1),new k(1,0,1,1)],this._cubeDirections=[new W(1,0,0),new W(-1,0,0),new W(0,0,1),new W(0,0,-1),new W(0,1,0),new W(0,-1,0)],this._cubeUps=[new W(0,1,0),new W(0,1,0),new W(0,1,0),new W(0,1,0),new W(0,0,1),new W(0,0,-1)]}updateMatrices(e,t=0){let i=this.camera,r=this.matrix,a=e.distance||i.far;a!==i.far&&(i.far=a,i.updateProjectionMatrix()),sU.setFromMatrixPosition(e.matrixWorld),i.position.copy(sU),sI.copy(i.position),sI.add(this._cubeDirections[t]),i.up.copy(this._cubeUps[t]),i.lookAt(sI),i.updateMatrixWorld(),r.makeTranslation(-sU.x,-sU.y,-sU.z),sD.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(sD)}}class sO extends sA{constructor(e,t,i=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=r,this.shadow=new sN}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class sz extends sA{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class sF{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=sk(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=sk();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function sk(){return("undefined"==typeof performance?Date:performance).now()}class sB{constructor(e=1,t=0,i=0){return this.radius=e,this.phi=t,this.theta=i,this}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(f(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}function sH(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function sV(e,t,i,r,a,n,s,o){let l=(e,t,i,r)=>[new x(e/s,1-r/o),new x(i/s,1-r/o),new x(i/s,1-t/o),new x(e/s,1-t/o)],h=l(t+n,i,t+r+n,i+n),c=l(t+r+n,i,t+2*r+n,i+n),u=l(t,i+n,t+n,i+n+a),d=l(t+n,i+n,t+r+n,i+n+a),p=l(t+r+n,i+n,t+r+2*n,i+a+n),f=l(t+r+2*n,i+n,t+2*r+2*n,i+a+n),m=e.attributes.uv,g=[p[3],p[2],p[0],p[1]],v=[u[3],u[2],u[0],u[1]],_=[h[3],h[2],h[0],h[1]],y=[c[0],c[1],c[3],c[2]],M=[d[3],d[2],d[0],d[1]],S=[f[3],f[2],f[0],f[1]],b=[];for(let e of[g,v,_,y,M,S])for(let t of e)b.push(t.x,t.y);m.set(new Float32Array(b)),m.needsUpdate=!0}function sG(e,t,i,r,a,n){sV(e,t,i,r,a,n,64,64)}function sW(e,t,i,r,a,n){sV(e,t,i,r,a,n,64,32)}class sj extends n7{constructor(e,t){super(),sH(this,"innerLayer",void 0),sH(this,"outerLayer",void 0),this.innerLayer=e,this.outerLayer=t,e.name="inner",t.name="outer"}}class sq extends n7{get map(){return this._map}set map(e){this._map=e,this.layer1Material.map=e,this.layer1Material.needsUpdate=!0,this.layer1MaterialBiased.map=e,this.layer1MaterialBiased.needsUpdate=!0,this.layer2Material.map=e,this.layer2Material.needsUpdate=!0,this.layer2MaterialBiased.map=e,this.layer2MaterialBiased.needsUpdate=!0}get modelType(){return this.slim?"slim":"default"}set modelType(e){this.slim="slim"===e,this.modelListeners.forEach(e=>e())}getBodyParts(){return this.children.filter(e=>e instanceof sj)}setInnerLayerVisible(e){this.getBodyParts().forEach(t=>t.innerLayer.visible=e)}setOuterLayerVisible(e){this.getBodyParts().forEach(t=>t.outerLayer.visible=e)}resetJoints(){this.head.rotation.set(0,0,0),this.leftArm.rotation.set(0,0,0),this.rightArm.rotation.set(0,0,0),this.leftLeg.rotation.set(0,0,0),this.rightLeg.rotation.set(0,0,0)}constructor(){super(),sH(this,"head",void 0),sH(this,"body",void 0),sH(this,"rightArm",void 0),sH(this,"leftArm",void 0),sH(this,"rightLeg",void 0),sH(this,"leftLeg",void 0),sH(this,"modelListeners",[]),sH(this,"slim",!1),sH(this,"_map",null),sH(this,"layer1Material",void 0),sH(this,"layer1MaterialBiased",void 0),sH(this,"layer2Material",void 0),sH(this,"layer2MaterialBiased",void 0),this.layer1Material=new sE({side:0}),this.layer2Material=new sE({side:2,transparent:!0,alphaTest:1e-5}),this.layer1MaterialBiased=this.layer1Material.clone(),this.layer1MaterialBiased.polygonOffset=!0,this.layer1MaterialBiased.polygonOffsetFactor=1,this.layer1MaterialBiased.polygonOffsetUnits=1,this.layer2MaterialBiased=this.layer2Material.clone(),this.layer2MaterialBiased.polygonOffset=!0,this.layer2MaterialBiased.polygonOffsetFactor=1,this.layer2MaterialBiased.polygonOffsetUnits=1;let e=new tO(8,8,8);sG(e,0,0,8,8,8);let t=new tI(e,this.layer1Material),i=new tO(9,9,9);sG(i,32,0,8,8,8);let r=new tI(i,this.layer2Material);this.head=new sj(t,r),this.head.name="head",this.head.add(t,r),t.position.y=4,r.position.y=4,this.add(this.head);let a=new tO(8,12,4);sG(a,16,16,8,12,4);let n=new tI(a,this.layer1Material),s=new tO(8.5,12.5,4.5);sG(s,16,32,8,12,4);let o=new tI(s,this.layer2Material);this.body=new sj(n,o),this.body.name="body",this.body.add(n,o),this.body.position.y=-6,this.add(this.body);let l=new tO,h=new tI(l,this.layer1MaterialBiased);this.modelListeners.push(()=>{h.scale.x=this.slim?3:4,h.scale.y=12,h.scale.z=4,sG(l,40,16,this.slim?3:4,12,4)});let c=new tO,u=new tI(c,this.layer2MaterialBiased);this.modelListeners.push(()=>{u.scale.x=this.slim?3.5:4.5,u.scale.y=12.5,u.scale.z=4.5,sG(c,40,32,this.slim?3:4,12,4)});let d=new n7;d.add(h,u),this.modelListeners.push(()=>{d.position.x=this.slim?-.5:-1}),d.position.y=-4,this.rightArm=new sj(h,u),this.rightArm.name="rightArm",this.rightArm.add(d),this.rightArm.position.x=-5,this.rightArm.position.y=-2,this.add(this.rightArm);let p=new tO,f=new tI(p,this.layer1MaterialBiased);this.modelListeners.push(()=>{f.scale.x=this.slim?3:4,f.scale.y=12,f.scale.z=4,sG(p,32,48,this.slim?3:4,12,4)});let m=new tO,g=new tI(m,this.layer2MaterialBiased);this.modelListeners.push(()=>{g.scale.x=this.slim?3.5:4.5,g.scale.y=12.5,g.scale.z=4.5,sG(m,48,48,this.slim?3:4,12,4)});let v=new n7;v.add(f,g),this.modelListeners.push(()=>{v.position.x=this.slim?.5:1}),v.position.y=-4,this.leftArm=new sj(f,g),this.leftArm.name="leftArm",this.leftArm.add(v),this.leftArm.position.x=5,this.leftArm.position.y=-2,this.add(this.leftArm);let _=new tO(4,12,4);sG(_,0,16,4,12,4);let x=new tI(_,this.layer1MaterialBiased),y=new tO(4.5,12.5,4.5);sG(y,0,32,4,12,4);let M=new tI(y,this.layer2MaterialBiased),S=new n7;S.add(x,M),S.position.y=-6,this.rightLeg=new sj(x,M),this.rightLeg.name="rightLeg",this.rightLeg.add(S),this.rightLeg.position.x=-1.9,this.rightLeg.position.y=-12,this.rightLeg.position.z=-.1,this.add(this.rightLeg);let b=new tO(4,12,4);sG(b,16,48,4,12,4);let w=new tI(b,this.layer1MaterialBiased),T=new tO(4.5,12.5,4.5);sG(T,0,48,4,12,4);let E=new tI(T,this.layer2MaterialBiased),A=new n7;A.add(w,E),A.position.y=-6,this.leftLeg=new sj(w,E),this.leftLeg.name="leftLeg",this.leftLeg.add(A),this.leftLeg.position.x=1.9,this.leftLeg.position.y=-12,this.leftLeg.position.z=-.1,this.add(this.leftLeg),this.modelType="default"}}class sX extends n7{get map(){return this.material.map}set map(e){this.material.map=e,this.material.needsUpdate=!0}constructor(){super(),sH(this,"cape",void 0),sH(this,"material",void 0),this.material=new sE({side:2,transparent:!0,alphaTest:1e-5});let e=new tO(10,16,1);sW(e,0,0,10,16,1),this.cape=new tI(e,this.material),this.cape.position.y=-8,this.cape.position.z=.5,this.add(this.cape)}}class sY extends n7{resetJoints(){this.leftWing.rotation.y=.01,this.leftWing.rotation.z=.2617994,this.updateRightWing()}updateRightWing(){this.rightWing.position.x=-this.leftWing.position.x,this.rightWing.position.y=this.leftWing.position.y,this.rightWing.rotation.x=this.leftWing.rotation.x,this.rightWing.rotation.y=-this.leftWing.rotation.y,this.rightWing.rotation.z=-this.leftWing.rotation.z}get map(){return this.material.map}set map(e){this.material.map=e,this.material.needsUpdate=!0}constructor(){super(),sH(this,"leftWing",void 0),sH(this,"rightWing",void 0),sH(this,"material",void 0),this.material=new sE({side:2,transparent:!0,alphaTest:1e-5});let e=new tO(12,22,4);sW(e,22,0,10,20,2);let t=new tI(e,this.material);t.position.x=-5,t.position.y=-10,t.position.z=-1,this.leftWing=new n7,this.leftWing.add(t),this.add(this.leftWing);let i=new tO(12,22,4);sW(i,22,0,10,20,2);let r=new tI(i,this.material);r.scale.x=-1,r.position.x=5,r.position.y=-10,r.position.z=-1,this.rightWing=new n7,this.rightWing.add(r),this.add(this.rightWing),this.leftWing.position.x=5,this.leftWing.rotation.x=.2617994,this.resetJoints()}}class sZ extends n7{get map(){return this.material.map}set map(e){this.material.map=e,this.material.needsUpdate=!0}constructor(){super(),sH(this,"rightEar",void 0),sH(this,"leftEar",void 0),sH(this,"material",void 0),this.material=new sE({side:0});let e=new tO(8,8,4/3);sV(e,0,0,6,6,1,14,7),this.rightEar=new tI(e,this.material),this.rightEar.name="rightEar",this.rightEar.position.x=-6,this.add(this.rightEar),this.leftEar=new tI(e,this.material),this.leftEar.name="leftEar",this.leftEar.position.x=6,this.add(this.leftEar)}}let sK=10.8*Math.PI/180;class sJ extends n7{get backEquipment(){return this.cape.visible?"cape":this.elytra.visible?"elytra":null}set backEquipment(e){this.cape.visible="cape"===e,this.elytra.visible="elytra"===e}resetJoints(){this.skin.resetJoints(),this.cape.rotation.x=sK,this.elytra.resetJoints()}constructor(){super(),sH(this,"skin",void 0),sH(this,"cape",void 0),sH(this,"elytra",void 0),sH(this,"ears",void 0),this.skin=new sq,this.skin.name="skin",this.skin.position.y=8,this.add(this.skin),this.cape=new sX,this.cape.name="cape",this.cape.position.y=8,this.cape.position.z=-2,this.cape.rotation.x=sK,this.cape.rotation.y=Math.PI,this.add(this.cape),this.elytra=new sY,this.elytra.name="elytra",this.elytra.position.y=8,this.elytra.position.z=-2,this.elytra.visible=!1,this.add(this.elytra),this.ears=new sZ,this.ears.name="ears",this.ears.position.y=10,this.ears.position.z=2/3,this.ears.visible=!1,this.skin.head.add(this.ears)}}function sQ(e){return e instanceof HTMLImageElement||e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas}function s$(e,t,i,r,a){let n=e.getImageData(t,i,r,a);for(let e=0;ee.clearRect(t*r,i*r,a*r,n*r);a(40,0,8,8),a(48,0,8,8),a(32,8,8,8),a(40,8,8,8),a(48,8,8,8),a(56,8,8,8),i&&(a(4,32,4,4),a(8,32,4,4),a(0,36,4,12),a(4,36,4,12),a(8,36,4,12),a(12,36,4,12),a(20,32,8,4),a(28,32,8,4),a(16,36,4,12),a(20,36,8,12),a(28,36,4,12),a(32,36,8,12),a(44,32,4,4),a(48,32,4,4),a(40,36,4,12),a(44,36,4,12),a(48,36,4,12),a(52,36,12,12),a(4,48,4,4),a(8,48,4,4),a(0,52,4,12),a(4,52,4,12),a(8,52,4,12),a(12,52,4,12),a(52,48,4,4),a(56,48,4,4),a(48,52,4,12),a(52,52,4,12),a(56,52,4,12),a(60,52,4,12))}function s1(e,t){if(t.width!==t.height&&t.width!==2*t.height)throw Error(`Bad skin size: ${t.width}x${t.height}`);let i=t.width/64,r=14*i,a=7*i;e.width=r,e.height=a;let n=e.getContext("2d",{willReadFrequently:!0});n.clearRect(0,0,r,a),n.drawImage(t,24*i,0,r,a,0,0,r,a)}async function s3(e){let t=document.createElement("img");return new Promise((i,r)=>{t.onload=()=>i(t),t.onerror=r,t.crossOrigin="anonymous","string"==typeof e?t.src=e:(void 0!==e.crossOrigin&&(t.crossOrigin=e.crossOrigin),void 0!==e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.src=e.src)})}let s2={type:"change"},s4={type:"start"},s5={type:"end"},s6=new ex,s8=new tK,s7=Math.cos(70*u);class s9 extends h{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new W,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:r.ROTATE,MIDDLE:r.DOLLY,RIGHT:r.PAN},this.touches={ONE:a.ROTATE,TWO:a.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return l.phi},this.getAzimuthalAngle=function(){return l.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(e){e.addEventListener("keydown",J),this._domElementKeyEvents=e},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",J),this._domElementKeyEvents=null},this.saveState=function(){i.target0.copy(i.target),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.reset=function(){i.target.copy(i.target0),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(s2),i.update(),s=n.NONE},this.update=function(){let t=new W,r=new G().setFromUnitVectors(e.up,new W(0,1,0)),a=r.clone().invert(),d=new W,p=new G,f=new W,m=2*Math.PI;return function(g=null){let v=i.object.position;t.copy(v).sub(i.target),t.applyQuaternion(r),l.setFromVector3(t),i.autoRotate&&s===n.NONE&&C(null!==g?2*Math.PI/60*i.autoRotateSpeed*g:2*Math.PI/60/60*i.autoRotateSpeed),i.enableDamping?(l.theta+=h.theta*i.dampingFactor,l.phi+=h.phi*i.dampingFactor):(l.theta+=h.theta,l.phi+=h.phi);let _=i.minAzimuthAngle,x=i.maxAzimuthAngle;isFinite(_)&&isFinite(x)&&(_<-Math.PI?_+=m:_>Math.PI&&(_-=m),x<-Math.PI?x+=m:x>Math.PI&&(x-=m),_<=x?l.theta=Math.max(_,Math.min(x,l.theta)):l.theta=l.theta>(_+x)/2?Math.max(_,l.theta):Math.min(x,l.theta)),l.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,l.phi)),l.makeSafe(),!0===i.enableDamping?i.target.addScaledVector(u,i.dampingFactor):i.target.add(u),i.zoomToCursor&&w||i.object.isOrthographicCamera?l.radius=O(l.radius):l.radius=O(l.radius*c),t.setFromSpherical(l),t.applyQuaternion(a),v.copy(i.target).add(t),i.object.lookAt(i.target),!0===i.enableDamping?(h.theta*=1-i.dampingFactor,h.phi*=1-i.dampingFactor,u.multiplyScalar(1-i.dampingFactor)):(h.set(0,0,0),u.set(0,0,0));let y=!1;if(i.zoomToCursor&&w){let r=null;if(i.object.isPerspectiveCamera){let e=t.length();r=O(e*c);let a=e-r;i.object.position.addScaledVector(S,a),i.object.updateMatrixWorld()}else if(i.object.isOrthographicCamera){let e=new W(b.x,b.y,0);e.unproject(i.object),i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom/c)),i.object.updateProjectionMatrix(),y=!0;let a=new W(b.x,b.y,0);a.unproject(i.object),i.object.position.sub(a).add(e),i.object.updateMatrixWorld(),r=t.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),i.zoomToCursor=!1;null!==r&&(this.screenSpacePanning?i.target.set(0,0,-1).transformDirection(i.object.matrix).multiplyScalar(r).add(i.object.position):(s6.origin.copy(i.object.position),s6.direction.set(0,0,-1).transformDirection(i.object.matrix),Math.abs(i.object.up.dot(s6.direction))o||8*(1-p.dot(i.object.quaternion))>o||f.distanceToSquared(i.target)>0)&&(i.dispatchEvent(s2),d.copy(i.object.position),p.copy(i.object.quaternion),f.copy(i.target),y=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",Q),i.domElement.removeEventListener("pointerdown",X),i.domElement.removeEventListener("pointercancel",Z),i.domElement.removeEventListener("wheel",K),i.domElement.removeEventListener("pointermove",Y),i.domElement.removeEventListener("pointerup",Z),null!==i._domElementKeyEvents&&(i._domElementKeyEvents.removeEventListener("keydown",J),i._domElementKeyEvents=null)};let i=this,n={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},s=n.NONE,o=1e-6,l=new sB,h=new sB,c=1,u=new W,d=new x,p=new x,f=new x,m=new x,g=new x,v=new x,_=new x,y=new x,M=new x,S=new W,b=new x,w=!1,T=[],E={};function A(){return Math.pow(.95,i.zoomSpeed)}function C(e){h.theta-=e}function L(e){h.phi-=e}let P=function(){let e=new W;return function(t,i){e.setFromMatrixColumn(i,0),e.multiplyScalar(-t),u.add(e)}}(),R=function(){let e=new W;return function(t,r){!0===i.screenSpacePanning?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(i.object.up,e)),e.multiplyScalar(t),u.add(e)}}(),D=function(){let e=new W;return function(t,r){let a=i.domElement;if(i.object.isPerspectiveCamera){let n=i.object.position;e.copy(n).sub(i.target);let s=e.length();P(2*t*(s*=Math.tan(i.object.fov/2*Math.PI/180))/a.clientHeight,i.object.matrix),R(2*r*s/a.clientHeight,i.object.matrix)}else i.object.isOrthographicCamera?(P(t*(i.object.right-i.object.left)/i.object.zoom/a.clientWidth,i.object.matrix),R(r*(i.object.top-i.object.bottom)/i.object.zoom/a.clientHeight,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)}}();function U(e){i.object.isPerspectiveCamera||i.object.isOrthographicCamera?c/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function I(e){i.object.isPerspectiveCamera||i.object.isOrthographicCamera?c*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function N(e){if(!i.zoomToCursor)return;w=!0;let t=i.domElement.getBoundingClientRect(),r=e.clientX-t.left,a=e.clientY-t.top,n=t.width,s=t.height;b.x=r/n*2-1,b.y=-(2*(a/s))+1,S.set(b.x,b.y,1).unproject(i.object).sub(i.object.position).normalize()}function O(e){return Math.max(i.minDistance,Math.min(i.maxDistance,e))}function z(e){d.set(e.clientX,e.clientY)}function F(e){m.set(e.clientX,e.clientY)}function k(){if(1===T.length)d.set(T[0].pageX,T[0].pageY);else{let e=.5*(T[0].pageX+T[1].pageX),t=.5*(T[0].pageY+T[1].pageY);d.set(e,t)}}function B(){if(1===T.length)m.set(T[0].pageX,T[0].pageY);else{let e=.5*(T[0].pageX+T[1].pageX),t=.5*(T[0].pageY+T[1].pageY);m.set(e,t)}}function H(){let e=T[0].pageX-T[1].pageX,t=T[0].pageY-T[1].pageY;_.set(0,Math.sqrt(e*e+t*t))}function V(e){if(1==T.length)p.set(e.pageX,e.pageY);else{let t=ee(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);p.set(i,r)}f.subVectors(p,d).multiplyScalar(i.rotateSpeed);let t=i.domElement;C(2*Math.PI*f.x/t.clientHeight),L(2*Math.PI*f.y/t.clientHeight),d.copy(p)}function j(e){if(1===T.length)g.set(e.pageX,e.pageY);else{let t=ee(e),i=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);g.set(i,r)}v.subVectors(g,m).multiplyScalar(i.panSpeed),D(v.x,v.y),m.copy(g)}function q(e){let t=ee(e),r=e.pageX-t.x,a=e.pageY-t.y;y.set(0,Math.sqrt(r*r+a*a)),M.set(0,Math.pow(y.y/_.y,i.zoomSpeed)),U(M.y),_.copy(y)}function X(e){!1!==i.enabled&&(0===T.length&&(i.domElement.setPointerCapture(e.pointerId),i.domElement.addEventListener("pointermove",Y),i.domElement.addEventListener("pointerup",Z)),T.push(e),"touch"===e.pointerType?function(e){switch($(e),T.length){case 1:switch(i.touches.ONE){case a.ROTATE:if(!1===i.enableRotate)return;k(),s=n.TOUCH_ROTATE;break;case a.PAN:if(!1===i.enablePan)return;B(),s=n.TOUCH_PAN;break;default:s=n.NONE}break;case 2:switch(i.touches.TWO){case a.DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&H(),i.enablePan&&B(),s=n.TOUCH_DOLLY_PAN;break;case a.DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&H(),i.enableRotate&&k(),s=n.TOUCH_DOLLY_ROTATE;break;default:s=n.NONE}break;default:s=n.NONE}s!==n.NONE&&i.dispatchEvent(s4)}(e):function(e){let t;switch(e.button){case 0:t=i.mouseButtons.LEFT;break;case 1:t=i.mouseButtons.MIDDLE;break;case 2:t=i.mouseButtons.RIGHT;break;default:t=-1}switch(t){case r.DOLLY:if(!1===i.enableZoom)return;N(e),_.set(e.clientX,e.clientY),s=n.DOLLY;break;case r.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===i.enablePan)return;F(e),s=n.PAN}else{if(!1===i.enableRotate)return;z(e),s=n.ROTATE}break;case r.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===i.enableRotate)return;z(e),s=n.ROTATE}else{if(!1===i.enablePan)return;F(e),s=n.PAN}break;default:s=n.NONE}s!==n.NONE&&i.dispatchEvent(s4)}(e))}function Y(e){!1!==i.enabled&&("touch"===e.pointerType?function(e){switch($(e),s){case n.TOUCH_ROTATE:if(!1===i.enableRotate)return;V(e),i.update();break;case n.TOUCH_PAN:if(!1===i.enablePan)return;j(e),i.update();break;case n.TOUCH_DOLLY_PAN:if(!1===i.enableZoom&&!1===i.enablePan)return;i.enableZoom&&q(e),i.enablePan&&j(e),i.update();break;case n.TOUCH_DOLLY_ROTATE:if(!1===i.enableZoom&&!1===i.enableRotate)return;i.enableZoom&&q(e),i.enableRotate&&V(e),i.update();break;default:s=n.NONE}}(e):function(e){switch(s){case n.ROTATE:if(!1===i.enableRotate)return;!function(e){p.set(e.clientX,e.clientY),f.subVectors(p,d).multiplyScalar(i.rotateSpeed);let t=i.domElement;C(2*Math.PI*f.x/t.clientHeight),L(2*Math.PI*f.y/t.clientHeight),d.copy(p),i.update()}(e);break;case n.DOLLY:if(!1===i.enableZoom)return;y.set(e.clientX,e.clientY),M.subVectors(y,_),M.y>0?U(A()):M.y<0&&I(A()),_.copy(y),i.update();break;case n.PAN:if(!1===i.enablePan)return;g.set(e.clientX,e.clientY),v.subVectors(g,m).multiplyScalar(i.panSpeed),D(v.x,v.y),m.copy(g),i.update()}}(e))}function Z(e){(function(e){delete E[e.pointerId];for(let t=0;t0&&U(A()),i.update(),i.dispatchEvent(s5))}function J(e){!1!==i.enabled&&!1!==i.enablePan&&function(e){let t=!1;switch(e.code){case i.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?L(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):D(0,i.keyPanSpeed),t=!0;break;case i.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?L(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):D(0,-i.keyPanSpeed),t=!0;break;case i.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?C(2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):D(i.keyPanSpeed,0),t=!0;break;case i.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?C(-2*Math.PI*i.rotateSpeed/i.domElement.clientHeight):D(-i.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),i.update())}(e)}function Q(e){!1!==i.enabled&&e.preventDefault()}function $(e){let t=E[e.pointerId];void 0===t&&(t=new x,E[e.pointerId]=t),t.set(e.pageX,e.pageY)}function ee(e){let t=e.pointerId===T[0].pointerId?T[1]:T[0];return E[t.pointerId]}i.domElement.addEventListener("contextmenu",Q),i.domElement.addEventListener("pointerdown",X),i.domElement.addEventListener("pointercancel",Z),i.domElement.addEventListener("wheel",K,{passive:!1}),this.update()}}let oe={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:"varying vec2 vUv;void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}",fragmentShader:"uniform float opacity;uniform sampler2D tDiffuse;varying vec2 vUv;void main(){vec4 texel=texture2D(tDiffuse,vUv);gl_FragColor=opacity*texel;}"};class ot{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}let oi=new al(-1,1,1,-1,0,1),or=new tg;or.setAttribute("position",new tl([-1,3,0,-1,-1,0,3,-1,0],3)),or.setAttribute("uv",new tl([0,2,0,0,2,0],2));class oa{constructor(e){this._mesh=new tI(or,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,oi)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class on extends ot{constructor(e,t){super(),this.textureID=void 0!==t?t:"tDiffuse",e instanceof tH?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=tB.clone(e.uniforms),this.material=new tH({name:void 0!==e.name?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new oa(this.material)}render(e,t,i){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=i.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose(),this.fsQuad.dispose()}}class os extends ot{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,i){let r,a;let n=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0),this.inverse?(r=0,a=1):(r=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(n.REPLACE,n.REPLACE,n.REPLACE),s.buffers.stencil.setFunc(n.ALWAYS,r,4294967295),s.buffers.stencil.setClear(a),s.buffers.stencil.setLocked(!0),e.setRenderTarget(i),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(n.EQUAL,1,4294967295),s.buffers.stencil.setOp(n.KEEP,n.KEEP,n.KEEP),s.buffers.stencil.setLocked(!0)}}class oo extends ot{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class ol{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),void 0===t){let i=e.getSize(new x);this._width=i.width,this._height=i.height,(t=new H(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:1016})).texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new on(oe),this.copyPass.material.blending=0,this.clock=new sF}swapBuffers(){let e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){let t=this.passes.indexOf(e);-1!==t&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t0.;if(abs(relativeVContrast)<.3){vec2 dirToEdge;dirToEdge.x=contrastE>contrastW?1.:-1.;dirToEdge.y=contrastS>contrastN?1.:-1.;vec4 rgbaAlongH=FxaaTexOff(tex,posM,vec2(dirToEdge.x,-dirToEdge.y),fxaaQualityRcpFrame.xy);float matchAlongH=contrast(rgbaM,rgbaAlongH);vec4 rgbaAlongV=FxaaTexOff(tex,posM,vec2(-dirToEdge.x,dirToEdge.y),fxaaQualityRcpFrame.xy);float matchAlongV=contrast(rgbaM,rgbaAlongV);relativeVContrast=matchAlongV-matchAlongH;relativeVContrast*=fxaaQualityinvEdgeThreshold;if(abs(relativeVContrast)<.3){return mix(rgbaM,(rgbaN+rgbaS+rgbaE+rgbaW)*.25,.4);}horzSpan=relativeVContrast>0.;}if(!horzSpan)rgbaN=rgbaW;if(!horzSpan)rgbaS=rgbaE;bool pairN=contrast(rgbaM,rgbaN)>contrast(rgbaM,rgbaS);if(!pairN)rgbaN=rgbaS;vec2 offNP;offNP.x=(!horzSpan)?0.0:fxaaQualityRcpFrame.x;offNP.y=(horzSpan)?0.0:fxaaQualityRcpFrame.y;bool doneN=false;bool doneP=false;float nDist=0.;float pDist=0.;vec2 posN=posM;vec2 posP=posM;int iterationsUsed=0;int iterationsUsedN=0;int iterationsUsedP=0;for(int i=0;icontrast(rgbaEndN,rgbaN);iterationsUsedN=i;}if(!doneP){pDist+=increment;posP=posM-offNP*pDist;vec4 rgbaEndP=FxaaTexTop(tex,posP.xy);doneP=contrast(rgbaEndP,rgbaM)>contrast(rgbaEndP,rgbaN);iterationsUsedP=i;}if(doneN||doneP)break;}if(!doneP&&!doneN)return rgbaM;float dist=min(doneN?float(iterationsUsedN)/float(NUM_SAMPLES-1):1.,doneP?float(iterationsUsedP)/float(NUM_SAMPLES-1):1.);dist=pow(dist,.5);dist=1.-dist;return mix(rgbaM,rgbaN,dist*.5);}void main(){const float edgeDetectionQuality=.2;const float invEdgeDetectionQuality=1./edgeDetectionQuality;gl_FragColor=FxaaPixelShader(vUv,tDiffuse,resolution,edgeDetectionQuality,invEdgeDetectionQuality);}`};function ou(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class od extends sb{async loadAndPaint(){await document.fonts.load(this.font,this.text),this.paint()}paint(){let e=document.createElement("canvas"),t=e.getContext("2d");t.font=this.font;let i=t.measureText(this.text);e.width=this.margin[3]+i.actualBoundingBoxLeft+i.actualBoundingBoxRight+this.margin[1],e.height=this.margin[0]+i.actualBoundingBoxAscent+i.actualBoundingBoxDescent+this.margin[2],(t=e.getContext("2d")).font=this.font,t.fillStyle=this.backgroundStyle,t.fillRect(0,0,e.width,e.height),t.fillStyle=this.textStyle,t.fillText(this.text,this.margin[3]+i.actualBoundingBoxLeft,this.margin[0]+i.actualBoundingBoxAscent);let r=new sT(e);r.magFilter=1003,r.minFilter=1003,this.textMaterial.map=r,this.textMaterial.needsUpdate=!0,this.scale.x=e.width/e.height*this.height,this.scale.y=this.height}constructor(e="",t={}){let i=new sc({transparent:!0,alphaTest:1e-5});super(i),ou(this,"painted",void 0),ou(this,"text",void 0),ou(this,"font",void 0),ou(this,"margin",void 0),ou(this,"textStyle",void 0),ou(this,"backgroundStyle",void 0),ou(this,"height",void 0),ou(this,"textMaterial",void 0),this.textMaterial=i,this.text=e,this.font=void 0===t.font?"48px Minecraft":t.font,this.margin=void 0===t.margin?[5,10,5,10]:t.margin,this.textStyle=void 0===t.textStyle?"white":t.textStyle,this.backgroundStyle=void 0===t.backgroundStyle?"rgba(0,0,0,.25)":t.backgroundStyle,this.height=void 0===t.height?4:t.height;let r=void 0===t.repaintAfterLoaded||t.repaintAfterLoaded;r&&!document.fonts.check(this.font,this.text)?(this.paint(),this.painted=this.loadAndPaint()):(this.paint(),this.painted=Promise.resolve())}}function op(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function of(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class om{update(e,t){if(this.paused)return;let i=t*this.speed;this.animate(e,i),this.progress+=i}constructor(){of(this,"speed",1),of(this,"paused",!1),of(this,"progress",0)}}e.BodyPart=sj,e.CapeObject=sX,e.EarsObject=sZ,e.ElytraObject=sY,e.FlyingAnimation=class extends om{animate(e){var t;let i=this.progress>0?20*this.progress:0,r=(t=i*i/100)<=0?0:t>=1?1:t;e.rotation.x=r*Math.PI/2,e.skin.head.rotation.x=r>.5?Math.PI/4-e.rotation.x:0;let a=.25*Math.PI*r;e.skin.leftArm.rotation.z=a,e.skin.rightArm.rotation.z=-a;let n=Math.PI/2,s=Math.pow(.9,i);e.elytra.leftWing.rotation.x=.34906584+-.08726644*s,e.elytra.leftWing.rotation.z=n+s*(.2617994-n),e.elytra.updateRightWing()}},e.FunctionAnimation=class extends om{animate(e,t){this.fn(e,this.progress,t)}constructor(e){super(),of(this,"fn",void 0),this.fn=e}},e.IdleAnimation=class extends om{animate(e){let t=2*this.progress,i=.02*Math.PI;e.skin.leftArm.rotation.z=.03*Math.cos(t)+i,e.skin.rightArm.rotation.z=.03*Math.cos(t+Math.PI)-i,e.cape.rotation.x=.01*Math.sin(t)+.06*Math.PI}},e.NameTagObject=od,e.PlayerAnimation=om,e.PlayerObject=sJ,e.RunningAnimation=class extends om{animate(e){let t=15*this.progress+.5*Math.PI;e.skin.leftLeg.rotation.x=1.3*Math.cos(t+Math.PI),e.skin.rightLeg.rotation.x=1.3*Math.cos(t),e.skin.leftArm.rotation.x=1.5*Math.cos(t),e.skin.rightArm.rotation.x=1.5*Math.cos(t+Math.PI);let i=.1*Math.PI;e.skin.leftArm.rotation.z=.1*Math.cos(t)+i,e.skin.rightArm.rotation.z=.1*Math.cos(t+Math.PI)-i,e.position.y=Math.cos(2*t),e.position.x=.15*Math.cos(t),e.rotation.z=.01*Math.cos(t+Math.PI),e.cape.rotation.x=.1*Math.sin(2*t)+.3*Math.PI}},e.SkinObject=sq,e.SkinViewer=class{updateComposerSize(){this.composer.setSize(this.width,this.height);let e=this.renderer.getPixelRatio();this.composer.setPixelRatio(e),this.fxaaPass.material.uniforms.resolution.value.x=1/(this.width*e),this.fxaaPass.material.uniforms.resolution.value.y=1/(this.height*e)}recreateSkinTexture(){null!==this.skinTexture&&this.skinTexture.dispose(),this.skinTexture=new sT(this.skinCanvas),this.skinTexture.magFilter=1003,this.skinTexture.minFilter=1003,this.playerObject.skin.map=this.skinTexture}recreateCapeTexture(){null!==this.capeTexture&&this.capeTexture.dispose(),this.capeTexture=new sT(this.capeCanvas),this.capeTexture.magFilter=1003,this.capeTexture.minFilter=1003,this.playerObject.cape.map=this.capeTexture,this.playerObject.elytra.map=this.capeTexture}recreateEarsTexture(){null!==this.earsTexture&&this.earsTexture.dispose(),this.earsTexture=new sT(this.earsCanvas),this.earsTexture.magFilter=1003,this.earsTexture.minFilter=1003,this.playerObject.ears.map=this.earsTexture}loadSkin(e,t={}){if(null===e)this.resetSkin();else{if(!sQ(e))return s3(e).then(e=>this.loadSkin(e,t));(function(e,t){let i=!1;if(t.width!==t.height){if(t.width===2*t.height)i=!0;else throw Error(`Bad skin size: ${t.width}x${t.height}`)}let r=e.getContext("2d",{willReadFrequently:!0});if(i){let i=t.width;e.width=i,e.height=i,r.clearRect(0,0,i,i),r.drawImage(t,0,0,i,i/2),function(e,t){e.save(),e.scale(-1,1);let i=t/64,r=(t,r,a,n,s,o)=>e.drawImage(e.canvas,t*i,r*i,a*i,n*i,-s*i,o*i,-a*i,n*i);r(4,16,4,4,20,48),r(8,16,4,4,24,48),r(0,20,4,12,24,52),r(4,20,4,12,20,52),r(8,20,4,12,16,52),r(12,20,4,12,28,52),r(44,16,4,4,36,48),r(48,16,4,4,40,48),r(40,20,4,12,40,52),r(44,20,4,12,36,52),r(48,20,4,12,32,52),r(52,20,4,12,44,52),e.restore()}(r,i),s0(r,e.width,!1)}else e.width=t.width,e.height=t.height,r.clearRect(0,0,t.width,t.height),r.drawImage(t,0,0,e.width,e.height),s0(r,e.width,!0)})(this.skinCanvas,e),this.recreateSkinTexture(),void 0===t.model||"auto-detect"===t.model?this.playerObject.skin.modelType=function(e){let t=e.width/64,i=e.getContext("2d",{willReadFrequently:!0}),r=(e,r,a,n)=>s$(i,e*t,r*t,a*t,n*t),a=(e,r,a,n)=>(function(e,t,i,r,a){let n=e.getImageData(t,i,r,a);for(let e=0;e(function(e,t,i,r,a){let n=e.getImageData(t,i,r,a);for(let e=0;ethis.loadCape(e,t));(function(e,t){let i=function(e){if(e.width===2*e.height)return e.width/64;if(17*e.width==22*e.height)return e.width/22;if(11*e.width==23*e.height)return e.width/46;throw Error(`Bad cape size: ${e.width}x${e.height}`)}(t);e.width=64*i,e.height=32*i;let r=e.getContext("2d",{willReadFrequently:!0});r.clearRect(0,0,e.width,e.height),r.drawImage(t,0,0,t.width,t.height)})(this.capeCanvas,e),this.recreateCapeTexture(),!1!==t.makeVisible&&(this.playerObject.backEquipment=void 0===t.backEquipment?"cape":t.backEquipment)}}resetCape(){this.playerObject.backEquipment=null,this.playerObject.cape.map=null,this.playerObject.elytra.map=null,null!==this.capeTexture&&(this.capeTexture.dispose(),this.capeTexture=null)}loadEars(e,t={}){if(null===e)this.resetEars();else{if(!sQ(e))return s3(e).then(e=>this.loadEars(e,t));"skin"===t.textureType?s1(this.earsCanvas,e):function(e,t){let i=function(e){if(e.width===2*e.height&&e.height%7==0)return e.height/7;throw Error(`Bad ears size: ${e.width}x${e.height}`)}(t);e.width=14*i,e.height=7*i;let r=e.getContext("2d",{willReadFrequently:!0});r.clearRect(0,0,e.width,e.height),r.drawImage(t,0,0,t.width,t.height)}(this.earsCanvas,e),this.recreateEarsTexture(),!1!==t.makeVisible&&(this.playerObject.ears.visible=!0)}}resetEars(){this.playerObject.ears.visible=!1,this.playerObject.ears.map=null,null!==this.earsTexture&&(this.earsTexture.dispose(),this.earsTexture=null)}loadPanorama(e){return this.loadBackground(e,303)}loadBackground(e,t){if(!sQ(e))return s3(e).then(e=>this.loadBackground(e,t));null!==this.backgroundTexture&&this.backgroundTexture.dispose(),this.backgroundTexture=new F,this.backgroundTexture.image=e,void 0!==t&&(this.backgroundTexture.mapping=t),this.backgroundTexture.needsUpdate=!0,this.scene.background=this.backgroundTexture}draw(){let e=this.clock.getDelta();null!==this._animation&&this._animation.update(this.playerObject,e),this.autoRotate&&(this.playerWrapper.rotation.y+=e*this.autoRotateSpeed),this.controls.update(),this.render(),this.animationID=window.requestAnimationFrame(()=>this.draw())}render(){this.composer.render()}setSize(e,t){this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.updateComposerSize()}dispose(){this._disposed=!0,this.canvas.removeEventListener("webglcontextlost",this.onContextLost,!1),this.canvas.removeEventListener("webglcontextrestored",this.onContextRestored,!1),null!==this.devicePixelRatioQuery&&(this.devicePixelRatioQuery.removeEventListener("change",this.onDevicePixelRatioChange),this.devicePixelRatioQuery=null),null!==this.animationID&&(window.cancelAnimationFrame(this.animationID),this.animationID=null),this.controls.dispose(),this.renderer.dispose(),this.resetSkin(),this.resetCape(),this.resetEars(),this.background=null,this.fxaaPass.fsQuad.dispose()}get disposed(){return this._disposed}get renderPaused(){return this._renderPaused}set renderPaused(e){this._renderPaused=e,this._renderPaused&&null!==this.animationID?(window.cancelAnimationFrame(this.animationID),this.animationID=null,this.clock.stop(),this.clock.autoStart=!0):this._renderPaused||this._disposed||this.renderer.getContext().isContextLost()||null!=this.animationID||(this.animationID=window.requestAnimationFrame(()=>this.draw()))}get width(){return this.renderer.getSize(new x).width}set width(e){this.setSize(e,this.height)}get height(){return this.renderer.getSize(new x).height}set height(e){this.setSize(this.width,e)}get background(){return this.scene.background}set background(e){null===e||e instanceof te||e instanceof F?this.scene.background=e:this.scene.background=new te(e),null!==this.backgroundTexture&&e!==this.backgroundTexture&&(this.backgroundTexture.dispose(),this.backgroundTexture=null)}adjustCameraDistance(){let e=4.5+16.5/Math.tan(this.fov/180*Math.PI/2)/this.zoom;e<10?e=10:e>256&&(e=256),this.camera.position.multiplyScalar(e/this.camera.position.length()),this.camera.updateProjectionMatrix()}resetCameraPose(){this.camera.position.set(0,0,1),this.camera.rotation.set(0,0,0),this.adjustCameraDistance()}get fov(){return this.camera.fov}set fov(e){this.camera.fov=e,this.adjustCameraDistance()}get zoom(){return this._zoom}set zoom(e){this._zoom=e,this.adjustCameraDistance()}get pixelRatio(){return this._pixelRatio}set pixelRatio(e){"match-device"===e?"match-device"!==this._pixelRatio&&(this._pixelRatio=e,this.onDevicePixelRatioChange()):("match-device"===this._pixelRatio&&null!==this.devicePixelRatioQuery&&(this.devicePixelRatioQuery.removeEventListener("change",this.onDevicePixelRatioChange),this.devicePixelRatioQuery=null),this._pixelRatio=e,this.renderer.setPixelRatio(e),this.updateComposerSize())}get animation(){return this._animation}set animation(e){this._animation!==e&&(this.playerObject.resetJoints(),this.playerObject.position.set(0,0,0),this.playerObject.rotation.set(0,0,0),this.clock.stop(),this.clock.autoStart=!0),null!==e&&(e.progress=0),this._animation=e}get nameTag(){return this._nameTag}set nameTag(e){null!==this._nameTag&&this.playerWrapper.remove(this._nameTag),null!==e&&(e instanceof ej||(e=new od(e)),this.playerWrapper.add(e),e.position.y=20),this._nameTag=e}constructor(e={}){let t;op(this,"canvas",void 0),op(this,"scene",void 0),op(this,"camera",void 0),op(this,"renderer",void 0),op(this,"controls",void 0),op(this,"playerObject",void 0),op(this,"playerWrapper",void 0),op(this,"globalLight",new sz(16777215,3)),op(this,"cameraLight",new sO(16777215,.6)),op(this,"composer",void 0),op(this,"renderPass",void 0),op(this,"fxaaPass",void 0),op(this,"skinCanvas",void 0),op(this,"capeCanvas",void 0),op(this,"earsCanvas",void 0),op(this,"skinTexture",null),op(this,"capeTexture",null),op(this,"earsTexture",null),op(this,"backgroundTexture",null),op(this,"_disposed",!1),op(this,"_renderPaused",!1),op(this,"_zoom",void 0),op(this,"autoRotate",!1),op(this,"autoRotateSpeed",1),op(this,"_animation",void 0),op(this,"clock",void 0),op(this,"animationID",void 0),op(this,"onContextLost",void 0),op(this,"onContextRestored",void 0),op(this,"_pixelRatio",void 0),op(this,"devicePixelRatioQuery",void 0),op(this,"onDevicePixelRatioChange",void 0),op(this,"_nameTag",null),this.canvas=void 0===e.canvas?document.createElement("canvas"):e.canvas,this.skinCanvas=document.createElement("canvas"),this.capeCanvas=document.createElement("canvas"),this.earsCanvas=document.createElement("canvas"),this.scene=new ss,this.camera=new tG,this.camera.add(this.cameraLight),this.scene.add(this.camera),this.scene.add(this.globalLight),this.renderer=new sn({canvas:this.canvas,preserveDrawingBuffer:!0===e.preserveDrawingBuffer}),this.onDevicePixelRatioChange=()=>{this.renderer.setPixelRatio(window.devicePixelRatio),this.updateComposerSize(),"match-device"===this._pixelRatio&&(this.devicePixelRatioQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this.devicePixelRatioQuery.addEventListener("change",this.onDevicePixelRatioChange,{once:!0}))},void 0===e.pixelRatio||"match-device"===e.pixelRatio?(this._pixelRatio="match-device",this.devicePixelRatioQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this.devicePixelRatioQuery.addEventListener("change",this.onDevicePixelRatioChange,{once:!0}),this.renderer.setPixelRatio(window.devicePixelRatio)):(this._pixelRatio=e.pixelRatio,this.devicePixelRatioQuery=null,this.renderer.setPixelRatio(e.pixelRatio)),this.renderer.setClearColor(0,0),this.renderer.capabilities.isWebGL2&&(t=new H(0,0,{depthTexture:new st(0,0,1015)})),this.composer=new ol(this.renderer,t),this.renderPass=new oh(this.scene,this.camera),this.fxaaPass=new on(oc),this.composer.addPass(this.renderPass),this.composer.addPass(this.fxaaPass),this.playerObject=new sJ,this.playerObject.name="player",this.playerObject.skin.visible=!1,this.playerObject.cape.visible=!1,this.playerWrapper=new n7,this.playerWrapper.add(this.playerObject),this.scene.add(this.playerWrapper),this.controls=new s9(this.camera,this.canvas),this.controls.enablePan=!1,this.controls.minDistance=10,this.controls.maxDistance=256,!1===e.enableControls&&(this.controls.enabled=!1),void 0!==e.skin&&this.loadSkin(e.skin,{model:e.model,ears:"current-skin"===e.ears}),void 0!==e.cape&&this.loadCape(e.cape),void 0!==e.ears&&"current-skin"!==e.ears&&this.loadEars(e.ears.source,{textureType:e.ears.textureType}),void 0!==e.width&&(this.width=e.width),void 0!==e.height&&(this.height=e.height),void 0!==e.background&&(this.background=e.background),void 0!==e.panorama&&this.loadPanorama(e.panorama),void 0!==e.nameTag&&(this.nameTag=e.nameTag),this.camera.position.z=1,this._zoom=void 0===e.zoom?.9:e.zoom,this.fov=void 0===e.fov?50:e.fov,this._animation=void 0===e.animation?null:e.animation,this.clock=new sF,!0===e.renderPaused?(this._renderPaused=!0,this.animationID=null):this.animationID=window.requestAnimationFrame(()=>this.draw()),this.onContextLost=e=>{e.preventDefault(),null!==this.animationID&&(window.cancelAnimationFrame(this.animationID),this.animationID=null)},this.onContextRestored=()=>{this.renderer.setClearColor(0,0),this._renderPaused||this._disposed||null!==this.animationID||(this.animationID=window.requestAnimationFrame(()=>this.draw()))},this.canvas.addEventListener("webglcontextlost",this.onContextLost,!1),this.canvas.addEventListener("webglcontextrestored",this.onContextRestored,!1)}},e.WalkingAnimation=class extends om{animate(e){let t=8*this.progress;e.skin.leftLeg.rotation.x=.5*Math.sin(t),e.skin.rightLeg.rotation.x=.5*Math.sin(t+Math.PI),e.skin.leftArm.rotation.x=.5*Math.sin(t+Math.PI),e.skin.rightArm.rotation.x=.5*Math.sin(t);let i=.02*Math.PI;e.skin.leftArm.rotation.z=.03*Math.cos(t)+i,e.skin.rightArm.rotation.z=.03*Math.cos(t+Math.PI)-i,this.headBobbing?(e.skin.head.rotation.y=.2*Math.sin(t/4),e.skin.head.rotation.x=.1*Math.sin(t/5)):(e.skin.head.rotation.y=0,e.skin.head.rotation.x=0),e.cape.rotation.x=.06*Math.sin(t/1.5)+.06*Math.PI}constructor(...e){super(...e),of(this,"headBobbing",!0)}},e.WaveAnimation=class extends om{animate(e){let t=2*this.progress*Math.PI*.5,i="left"===this.whichArm?e.skin.leftArm:e.skin.rightArm;i.rotation.x=180,i.rotation.z=.5*Math.sin(t)}constructor(e="left"){super(),of(this,"whichArm",void 0),this.whichArm=e}}});//# sourceMappingURL=skinview3d.bundle.js.map