Created
September 4, 2024 02:26
-
-
Save nartc/42deb7d0d030582c4d9d13b38ba0be49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @license | |
* Copyright 2010-2024 Three.js Authors | |
* SPDX-License-Identifier: MIT | |
*/ | |
const t="166",e=0,n=1,i="attached",r=1e3,a=1001,o=1003,s=1006,l=1014,c=1015,h=1016,d=1023,u=1026,f=1033,p=3201,m="srgb",g="srgb-linear",v="display-p3-linear",x="linear",_="srgb",y="rec709",S=7680,M=35044,b=35048,w=2e3,T=2001;class C{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,i=n.length;e<i;e++)n[e].call(this,t);t.target=null}}}const A=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let D=1234567;const U=Math.PI/180,E=180/Math.PI;function P(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(A[255&t]+A[t>>8&255]+A[t>>16&255]+A[t>>24&255]+"-"+A[255&e]+A[e>>8&255]+"-"+A[e>>16&15|64]+A[e>>24&255]+"-"+A[63&n|128]+A[n>>8&255]+"-"+A[n>>16&255]+A[n>>24&255]+A[255&i]+A[i>>8&255]+A[i>>16&255]+A[i>>24&255]).toLowerCase()}function I(t,e,n){return Math.max(e,Math.min(n,t))}function R(t,e){return(t%e+e)%e}function L(t,e,n){return(1-n)*t+n*e}function N(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function z(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}const O={DEG2RAD:U,RAD2DEG:E,generateUUID:P,clamp:I,euclideanModulo:R,mapLinear:function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:L,damp:function(t,e,n,i){return L(t,e,1-Math.exp(-n*i))},pingpong:function(t,e=1){return e-Math.abs(R(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(D=t);let e=D+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*U},radToDeg:function(t){return t*E},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,n,i,r){const a=Math.cos,o=Math.sin,s=a(n/2),l=o(n/2),c=a((e+i)/2),h=o((e+i)/2),d=a((e-i)/2),u=o((e-i)/2),f=a((i-e)/2),p=o((i-e)/2);switch(r){case"XYX":t.set(s*h,l*d,l*u,s*c);break;case"YZY":t.set(l*u,s*h,l*d,s*c);break;case"ZXZ":t.set(l*d,l*u,s*h,s*c);break;case"XZX":t.set(s*h,l*p,l*f,s*c);break;case"YXY":t.set(l*f,s*h,l*p,s*c);break;case"ZYZ":t.set(l*p,l*f,s*h,s*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:z,denormalize:N};class k{constructor(t=0,e=0){k.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(I(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class F{constructor(t,e,n,i,r,a,o,s,l){F.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,a,o,s,l)}set(t,e,n,i,r,a,o,s,l){const c=this.elements;return c[0]=t,c[1]=i,c[2]=o,c[3]=e,c[4]=r,c[5]=s,c[6]=n,c[7]=a,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[3],s=n[6],l=n[1],c=n[4],h=n[7],d=n[2],u=n[5],f=n[8],p=i[0],m=i[3],g=i[6],v=i[1],x=i[4],_=i[7],y=i[2],S=i[5],M=i[8];return r[0]=a*p+o*v+s*y,r[3]=a*m+o*x+s*S,r[6]=a*g+o*_+s*M,r[1]=l*p+c*v+h*y,r[4]=l*m+c*x+h*S,r[7]=l*g+c*_+h*M,r[2]=d*p+u*v+f*y,r[5]=d*m+u*x+f*S,r[8]=d*g+u*_+f*M,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],s=t[6],l=t[7],c=t[8];return e*a*c-e*o*l-n*r*c+n*o*s+i*r*l-i*a*s}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],s=t[6],l=t[7],c=t[8],h=c*a-o*l,d=o*s-c*r,u=l*r-a*s,f=e*h+n*d+i*u;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);const p=1/f;return t[0]=h*p,t[1]=(i*l-c*n)*p,t[2]=(o*n-i*a)*p,t[3]=d*p,t[4]=(c*e-i*s)*p,t[5]=(i*r-o*e)*p,t[6]=u*p,t[7]=(n*s-l*e)*p,t[8]=(a*e-n*r)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,a,o){const s=Math.cos(r),l=Math.sin(r);return this.set(n*s,n*l,-n*(s*a+l*o)+a+t,-i*l,i*s,-i*(-l*a+s*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(B.makeScale(t,e)),this}rotate(t){return this.premultiply(B.makeRotation(-t)),this}translate(t,e){return this.premultiply(B.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}const B=new F;function V(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}const G={};function H(t){t in G||(G[t]=!0,console.warn(t))}const W=(new F).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),j=(new F).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),X={[g]:{transfer:x,primaries:y,toReference:t=>t,fromReference:t=>t},[m]:{transfer:_,primaries:y,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[v]:{transfer:x,primaries:"p3",toReference:t=>t.applyMatrix3(j),fromReference:t=>t.applyMatrix3(W)},"display-p3":{transfer:_,primaries:"p3",toReference:t=>t.convertSRGBToLinear().applyMatrix3(j),fromReference:t=>t.applyMatrix3(W).convertLinearToSRGB()}},q=new Set([g,v]),Y={enabled:!0,_workingColorSpace:g,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(t){if(!q.has(t))throw new Error(`Unsupported working color space, "${t}".`);this._workingColorSpace=t},convert:function(t,e,n){if(!1===this.enabled||e===n||!e||!n)return t;const i=X[e].toReference;return(0,X[n].fromReference)(i(t))},fromWorkingColorSpace:function(t,e){return this.convert(t,this._workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this._workingColorSpace)},getPrimaries:function(t){return X[t].primaries},getTransfer:function(t){return""===t?x:X[t].transfer}};function Z(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function $(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}let J;class Q{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===J&&(J=V("canvas")),J.width=t.width,J.height=t.height;const n=J.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=J}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=V("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let t=0;t<r.length;t++)r[t]=255*Z(r[t]/255);return n.putImageData(i,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*Z(e[t]/255)):e[t]=Z(e[t]);return{data:e,width:t.width,height:t.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let K=0;class tt{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:K++}),this.uuid=P(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let t;if(Array.isArray(i)){t=[];for(let e=0,n=i.length;e<n;e++)i[e].isDataTexture?t.push(et(i[e].image)):t.push(et(i[e]))}else t=et(i);n.url=t}return e||(t.images[this.uuid]=n),n}}function et(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Q.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let nt=0;class it extends C{constructor(t=it.DEFAULT_IMAGE,e=it.DEFAULT_MAPPING,n=1001,i=1001,r=s,a=1008,o=d,l=1009,c=it.DEFAULT_ANISOTROPY,h=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:nt++}),this.uuid=P(),this.name="",this.source=new tt(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new k(0,0),this.repeat=new k(1,1),this.center=new k(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new F,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case r:t.x=t.x-Math.floor(t.x);break;case a:t.x=t.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case r:t.y=t.y-Math.floor(t.y);break;case a:t.y=t.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}it.DEFAULT_IMAGE=null,it.DEFAULT_MAPPING=300,it.DEFAULT_ANISOTROPY=1;class rt{constructor(t=0,e=0,n=0,i=1){rt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const a=.01,o=.1,s=t.elements,l=s[0],c=s[4],h=s[8],d=s[1],u=s[5],f=s[9],p=s[2],m=s[6],g=s[10];if(Math.abs(c-d)<a&&Math.abs(h-p)<a&&Math.abs(f-m)<a){if(Math.abs(c+d)<o&&Math.abs(h+p)<o&&Math.abs(f+m)<o&&Math.abs(l+u+g-3)<o)return this.set(1,0,0,0),this;e=Math.PI;const t=(l+1)/2,s=(u+1)/2,v=(g+1)/2,x=(c+d)/4,_=(h+p)/4,y=(f+m)/4;return t>s&&t>v?t<a?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(t),i=x/n,r=_/n):s>v?s<a?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(s),n=x/i,r=y/i):v<a?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(v),n=_/r,i=y/r),this.set(n,i,r,e),this}let v=Math.sqrt((m-f)*(m-f)+(h-p)*(h-p)+(d-c)*(d-c));return Math.abs(v)<.001&&(v=1),this.x=(m-f)/v,this.y=(h-p)/v,this.z=(d-c)/v,this.w=Math.acos((l+u+g-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}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(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}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 at extends C{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new rt(0,0,t,e),this.scissorTest=!1,this.viewport=new rt(0,0,t,e);const i={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:s,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const r=new it(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);r.flipY=!1,r.generateMipmaps=n.generateMipmaps,r.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let t=0;t<a;t++)this.textures[t]=r.clone(),this.textures[t].isRenderTargetTexture=!0;this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this.depthTexture=n.depthTexture,this.samples=n.samples}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n;this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++)this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new tt(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ot extends at{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class st{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,a,o){let s=n[i+0],l=n[i+1],c=n[i+2],h=n[i+3];const d=r[a+0],u=r[a+1],f=r[a+2],p=r[a+3];if(0===o)return t[e+0]=s,t[e+1]=l,t[e+2]=c,void(t[e+3]=h);if(1===o)return t[e+0]=d,t[e+1]=u,t[e+2]=f,void(t[e+3]=p);if(h!==p||s!==d||l!==u||c!==f){let t=1-o;const e=s*d+l*u+c*f+h*p,n=e>=0?1:-1,i=1-e*e;if(i>Number.EPSILON){const r=Math.sqrt(i),a=Math.atan2(r,e*n);t=Math.sin(t*a)/r,o=Math.sin(o*a)/r}const r=o*n;if(s=s*t+d*r,l=l*t+u*r,c=c*t+f*r,h=h*t+p*r,t===1-o){const t=1/Math.sqrt(s*s+l*l+c*c+h*h);s*=t,l*=t,c*=t,h*=t}}t[e]=s,t[e+1]=l,t[e+2]=c,t[e+3]=h}static multiplyQuaternionsFlat(t,e,n,i,r,a){const o=n[i],s=n[i+1],l=n[i+2],c=n[i+3],h=r[a],d=r[a+1],u=r[a+2],f=r[a+3];return t[e]=o*f+c*h+s*u-l*d,t[e+1]=s*f+c*d+l*h-o*u,t[e+2]=l*f+c*u+o*d-s*h,t[e+3]=c*f-o*h-s*d-l*u,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,a=t._order,o=Math.cos,s=Math.sin,l=o(n/2),c=o(i/2),h=o(r/2),d=s(n/2),u=s(i/2),f=s(r/2);switch(a){case"XYZ":this._x=d*c*h+l*u*f,this._y=l*u*h-d*c*f,this._z=l*c*f+d*u*h,this._w=l*c*h-d*u*f;break;case"YXZ":this._x=d*c*h+l*u*f,this._y=l*u*h-d*c*f,this._z=l*c*f-d*u*h,this._w=l*c*h+d*u*f;break;case"ZXY":this._x=d*c*h-l*u*f,this._y=l*u*h+d*c*f,this._z=l*c*f+d*u*h,this._w=l*c*h-d*u*f;break;case"ZYX":this._x=d*c*h-l*u*f,this._y=l*u*h+d*c*f,this._z=l*c*f-d*u*h,this._w=l*c*h+d*u*f;break;case"YZX":this._x=d*c*h+l*u*f,this._y=l*u*h+d*c*f,this._z=l*c*f-d*u*h,this._w=l*c*h-d*u*f;break;case"XZY":this._x=d*c*h-l*u*f,this._y=l*u*h-d*c*f,this._z=l*c*f+d*u*h,this._w=l*c*h+d*u*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],a=e[1],o=e[5],s=e[9],l=e[2],c=e[6],h=e[10],d=n+o+h;if(d>0){const t=.5/Math.sqrt(d+1);this._w=.25/t,this._x=(c-s)*t,this._y=(r-l)*t,this._z=(a-i)*t}else if(n>o&&n>h){const t=2*Math.sqrt(1+n-o-h);this._w=(c-s)/t,this._x=.25*t,this._y=(i+a)/t,this._z=(r+l)/t}else if(o>h){const t=2*Math.sqrt(1+o-n-h);this._w=(r-l)/t,this._x=(i+a)/t,this._y=.25*t,this._z=(s+c)/t}else{const t=2*Math.sqrt(1+h-n-o);this._w=(a-i)/t,this._x=(r+l)/t,this._y=(s+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(I(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const i=Math.min(1,e/n);return this.slerp(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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,a=t._w,o=e._x,s=e._y,l=e._z,c=e._w;return this._x=n*c+a*o+i*l-r*s,this._y=i*c+a*s+r*o-n*l,this._z=r*c+a*l+n*s-i*o,this._w=a*c-n*o-i*s-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,i=this._y,r=this._z,a=this._w;let o=a*t._w+n*t._x+i*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=i,this._z=r,this;const s=1-o*o;if(s<=Number.EPSILON){const t=1-e;return this._w=t*a+e*this._w,this._x=t*n+e*this._x,this._y=t*i+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const l=Math.sqrt(s),c=Math.atan2(l,o),h=Math.sin((1-e)*c)/l,d=Math.sin(e*c)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=i*h+this._y*d,this._z=r*h+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class lt{constructor(t=0,e=0,n=0){lt.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(ht.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(ht.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,o=t.z,s=t.w,l=2*(a*i-o*n),c=2*(o*e-r*i),h=2*(r*n-a*e);return this.x=e+s*l+a*h-o*c,this.y=n+s*c+o*l-r*h,this.z=i+s*h+r*c-a*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=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(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,a=e.x,o=e.y,s=e.z;return this.x=i*s-r*o,this.y=r*a-n*s,this.z=n*o-i*a,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return ct.copy(this).projectOnVector(t),this.sub(ct)}reflect(t){return this.sub(ct.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(I(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const ct=new lt,ht=new st;class dt{constructor(t=new lt(1/0,1/0,1/0),e=new lt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(ft.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(ft.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=ft.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n){const i=n.getAttribute("position");if(!0===e&&void 0!==i&&!0!==t.isInstancedMesh)for(let e=0,n=i.count;e<n;e++)!0===t.isMesh?t.getVertexPosition(e,ft):ft.fromBufferAttribute(i,e),ft.applyMatrix4(t.matrixWorld),this.expandByPoint(ft);else void 0!==t.boundingBox?(null===t.boundingBox&&t.computeBoundingBox(),pt.copy(t.boundingBox)):(null===n.boundingBox&&n.computeBoundingBox(),pt.copy(n.boundingBox)),pt.applyMatrix4(t.matrixWorld),this.union(pt)}const i=t.children;for(let t=0,n=i.length;t<n;t++)this.expandByObject(i[t],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,ft),ft.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(St),Mt.subVectors(this.max,St),mt.subVectors(t.a,St),gt.subVectors(t.b,St),vt.subVectors(t.c,St),xt.subVectors(gt,mt),_t.subVectors(vt,gt),yt.subVectors(mt,vt);let e=[0,-xt.z,xt.y,0,-_t.z,_t.y,0,-yt.z,yt.y,xt.z,0,-xt.x,_t.z,0,-_t.x,yt.z,0,-yt.x,-xt.y,xt.x,0,-_t.y,_t.x,0,-yt.y,yt.x,0];return!!Tt(e,mt,gt,vt,Mt)&&(e=[1,0,0,0,1,0,0,0,1],!!Tt(e,mt,gt,vt,Mt)&&(bt.crossVectors(xt,_t),e=[bt.x,bt.y,bt.z],Tt(e,mt,gt,vt,Mt)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,ft).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(ft).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(ut[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ut[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ut[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ut[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ut[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ut[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ut[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ut[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ut)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const ut=[new lt,new lt,new lt,new lt,new lt,new lt,new lt,new lt],ft=new lt,pt=new dt,mt=new lt,gt=new lt,vt=new lt,xt=new lt,_t=new lt,yt=new lt,St=new lt,Mt=new lt,bt=new lt,wt=new lt;function Tt(t,e,n,i,r){for(let a=0,o=t.length-3;a<=o;a+=3){wt.fromArray(t,a);const o=r.x*Math.abs(wt.x)+r.y*Math.abs(wt.y)+r.z*Math.abs(wt.z),s=e.dot(wt),l=n.dot(wt),c=i.dot(wt);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>o)return!1}return!0}const Ct=new dt,At=new lt,Dt=new lt;class Ut{constructor(t=new lt,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):Ct.setFromPoints(t).getCenter(n);let i=0;for(let e=0,r=t.length;e<r;e++)i=Math.max(i,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;At.subVectors(t,this.center);const e=At.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(At,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(Dt.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(At.copy(t.center).add(Dt)),this.expandByPoint(At.copy(t.center).sub(Dt))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Et=new lt,Pt=new lt,It=new lt,Rt=new lt,Lt=new lt,Nt=new lt,zt=new lt;class Ot{constructor(t=new lt,e=new lt(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Et)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Et.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Et.copy(this.origin).addScaledVector(this.direction,e),Et.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Pt.copy(t).add(e).multiplyScalar(.5),It.copy(e).sub(t).normalize(),Rt.copy(this.origin).sub(Pt);const r=.5*t.distanceTo(e),a=-this.direction.dot(It),o=Rt.dot(this.direction),s=-Rt.dot(It),l=Rt.lengthSq(),c=Math.abs(1-a*a);let h,d,u,f;if(c>0)if(h=a*s-o,d=a*o-s,f=r*c,h>=0)if(d>=-f)if(d<=f){const t=1/c;h*=t,d*=t,u=h*(h+a*d+2*o)+d*(a*h+d+2*s)+l}else d=r,h=Math.max(0,-(a*d+o)),u=-h*h+d*(d+2*s)+l;else d=-r,h=Math.max(0,-(a*d+o)),u=-h*h+d*(d+2*s)+l;else d<=-f?(h=Math.max(0,-(-a*r+o)),d=h>0?-r:Math.min(Math.max(-r,-s),r),u=-h*h+d*(d+2*s)+l):d<=f?(h=0,d=Math.min(Math.max(-r,-s),r),u=d*(d+2*s)+l):(h=Math.max(0,-(a*r+o)),d=h>0?r:Math.min(Math.max(-r,-s),r),u=-h*h+d*(d+2*s)+l);else d=a>0?-r:r,h=Math.max(0,-(a*d+o)),u=-h*h+d*(d+2*s)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(Pt).addScaledVector(It,d),u}intersectSphere(t,e){Et.subVectors(t.center,this.origin);const n=Et.dot(this.direction),i=Et.dot(Et)-n*n,r=t.radius*t.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,a,o,s;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l),c>=0?(r=(t.min.y-d.y)*c,a=(t.max.y-d.y)*c):(r=(t.max.y-d.y)*c,a=(t.min.y-d.y)*c),n>a||r>i?null:((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),h>=0?(o=(t.min.z-d.z)*h,s=(t.max.z-d.z)*h):(o=(t.max.z-d.z)*h,s=(t.min.z-d.z)*h),n>s||o>i?null:((o>n||n!=n)&&(n=o),(s<i||i!=i)&&(i=s),i<0?null:this.at(n>=0?n:i,e)))}intersectsBox(t){return null!==this.intersectBox(t,Et)}intersectTriangle(t,e,n,i,r){Lt.subVectors(e,t),Nt.subVectors(n,t),zt.crossVectors(Lt,Nt);let a,o=this.direction.dot(zt);if(o>0){if(i)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Rt.subVectors(this.origin,t);const s=a*this.direction.dot(Nt.crossVectors(Rt,Nt));if(s<0)return null;const l=a*this.direction.dot(Lt.cross(Rt));if(l<0)return null;if(s+l>o)return null;const c=-a*Rt.dot(zt);return c<0?null:this.at(c/o,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class kt{constructor(t,e,n,i,r,a,o,s,l,c,h,d,u,f,p,m){kt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,n,i,r,a,o,s,l,c,h,d,u,f,p,m)}set(t,e,n,i,r,a,o,s,l,c,h,d,u,f,p,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=o,g[13]=s,g[2]=l,g[6]=c,g[10]=h,g[14]=d,g[3]=u,g[7]=f,g[11]=p,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 kt).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/Ft.setFromMatrixColumn(t,0).length(),r=1/Ft.setFromMatrixColumn(t,1).length(),a=1/Ft.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===t.order){const t=a*c,n=a*h,i=o*c,r=o*h;e[0]=s*c,e[4]=-s*h,e[8]=l,e[1]=n+i*l,e[5]=t-r*l,e[9]=-o*s,e[2]=r-t*l,e[6]=i+n*l,e[10]=a*s}else if("YXZ"===t.order){const t=s*c,n=s*h,i=l*c,r=l*h;e[0]=t+r*o,e[4]=i*o-n,e[8]=a*l,e[1]=a*h,e[5]=a*c,e[9]=-o,e[2]=n*o-i,e[6]=r+t*o,e[10]=a*s}else if("ZXY"===t.order){const t=s*c,n=s*h,i=l*c,r=l*h;e[0]=t-r*o,e[4]=-a*h,e[8]=i+n*o,e[1]=n+i*o,e[5]=a*c,e[9]=r-t*o,e[2]=-a*l,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){const t=a*c,n=a*h,i=o*c,r=o*h;e[0]=s*c,e[4]=i*l-n,e[8]=t*l+r,e[1]=s*h,e[5]=r*l+t,e[9]=n*l-i,e[2]=-l,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){const t=a*s,n=a*l,i=o*s,r=o*l;e[0]=s*c,e[4]=r-t*h,e[8]=i*h+n,e[1]=h,e[5]=a*c,e[9]=-o*c,e[2]=-l*c,e[6]=n*h+i,e[10]=t-r*h}else if("XZY"===t.order){const t=a*s,n=a*l,i=o*s,r=o*l;e[0]=s*c,e[4]=-h,e[8]=l*c,e[1]=t*h+r,e[5]=a*c,e[9]=n*h-i,e[2]=i*h-n,e[6]=o*c,e[10]=r*h+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Vt,t,Gt)}lookAt(t,e,n){const i=this.elements;return jt.subVectors(t,e),0===jt.lengthSq()&&(jt.z=1),jt.normalize(),Ht.crossVectors(n,jt),0===Ht.lengthSq()&&(1===Math.abs(n.z)?jt.x+=1e-4:jt.z+=1e-4,jt.normalize(),Ht.crossVectors(n,jt)),Ht.normalize(),Wt.crossVectors(jt,Ht),i[0]=Ht.x,i[4]=Wt.x,i[8]=jt.x,i[1]=Ht.y,i[5]=Wt.y,i[9]=jt.y,i[2]=Ht.z,i[6]=Wt.z,i[10]=jt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[4],s=n[8],l=n[12],c=n[1],h=n[5],d=n[9],u=n[13],f=n[2],p=n[6],m=n[10],g=n[14],v=n[3],x=n[7],_=n[11],y=n[15],S=i[0],M=i[4],b=i[8],w=i[12],T=i[1],C=i[5],A=i[9],D=i[13],U=i[2],E=i[6],P=i[10],I=i[14],R=i[3],L=i[7],N=i[11],z=i[15];return r[0]=a*S+o*T+s*U+l*R,r[4]=a*M+o*C+s*E+l*L,r[8]=a*b+o*A+s*P+l*N,r[12]=a*w+o*D+s*I+l*z,r[1]=c*S+h*T+d*U+u*R,r[5]=c*M+h*C+d*E+u*L,r[9]=c*b+h*A+d*P+u*N,r[13]=c*w+h*D+d*I+u*z,r[2]=f*S+p*T+m*U+g*R,r[6]=f*M+p*C+m*E+g*L,r[10]=f*b+p*A+m*P+g*N,r[14]=f*w+p*D+m*I+g*z,r[3]=v*S+x*T+_*U+y*R,r[7]=v*M+x*C+_*E+y*L,r[11]=v*b+x*A+_*P+y*N,r[15]=v*w+x*D+_*I+y*z,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],a=t[1],o=t[5],s=t[9],l=t[13],c=t[2],h=t[6],d=t[10],u=t[14];return t[3]*(+r*s*h-i*l*h-r*o*d+n*l*d+i*o*u-n*s*u)+t[7]*(+e*s*u-e*l*d+r*a*d-i*a*u+i*l*c-r*s*c)+t[11]*(+e*l*h-e*o*u-r*a*h+n*a*u+r*o*c-n*l*c)+t[15]*(-i*o*c-e*s*h+e*o*d+i*a*h-n*a*d+n*s*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],s=t[6],l=t[7],c=t[8],h=t[9],d=t[10],u=t[11],f=t[12],p=t[13],m=t[14],g=t[15],v=h*m*l-p*d*l+p*s*u-o*m*u-h*s*g+o*d*g,x=f*d*l-c*m*l-f*s*u+a*m*u+c*s*g-a*d*g,_=c*p*l-f*h*l+f*o*u-a*p*u-c*o*g+a*h*g,y=f*h*s-c*p*s-f*o*d+a*p*d+c*o*m-a*h*m,S=e*v+n*x+i*_+r*y;if(0===S)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/S;return t[0]=v*M,t[1]=(p*d*r-h*m*r-p*i*u+n*m*u+h*i*g-n*d*g)*M,t[2]=(o*m*r-p*s*r+p*i*l-n*m*l-o*i*g+n*s*g)*M,t[3]=(h*s*r-o*d*r-h*i*l+n*d*l+o*i*u-n*s*u)*M,t[4]=x*M,t[5]=(c*m*r-f*d*r+f*i*u-e*m*u-c*i*g+e*d*g)*M,t[6]=(f*s*r-a*m*r-f*i*l+e*m*l+a*i*g-e*s*g)*M,t[7]=(a*d*r-c*s*r+c*i*l-e*d*l-a*i*u+e*s*u)*M,t[8]=_*M,t[9]=(f*h*r-c*p*r-f*n*u+e*p*u+c*n*g-e*h*g)*M,t[10]=(a*p*r-f*o*r+f*n*l-e*p*l-a*n*g+e*o*g)*M,t[11]=(c*o*r-a*h*r-c*n*l+e*h*l+a*n*u-e*o*u)*M,t[12]=y*M,t[13]=(c*p*i-f*h*i+f*n*d-e*p*d-c*n*m+e*h*m)*M,t[14]=(f*o*i-a*p*i-f*n*s+e*p*s+a*n*m-e*o*m)*M,t[15]=(a*h*i-c*o*i+c*n*s-e*h*s-a*n*d+e*o*d)*M,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,a=t.x,o=t.y,s=t.z,l=r*a,c=r*o;return this.set(l*a+n,l*o-i*s,l*s+i*o,0,l*o+i*s,c*o+n,c*s-i*a,0,l*s-i*o,c*s+i*a,r*s*s+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,a){return this.set(1,n,r,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,a=e._y,o=e._z,s=e._w,l=r+r,c=a+a,h=o+o,d=r*l,u=r*c,f=r*h,p=a*c,m=a*h,g=o*h,v=s*l,x=s*c,_=s*h,y=n.x,S=n.y,M=n.z;return i[0]=(1-(p+g))*y,i[1]=(u+_)*y,i[2]=(f-x)*y,i[3]=0,i[4]=(u-_)*S,i[5]=(1-(d+g))*S,i[6]=(m+v)*S,i[7]=0,i[8]=(f+x)*M,i[9]=(m-v)*M,i[10]=(1-(d+p))*M,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let r=Ft.set(i[0],i[1],i[2]).length();const a=Ft.set(i[4],i[5],i[6]).length(),o=Ft.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],Bt.copy(this);const s=1/r,l=1/a,c=1/o;return Bt.elements[0]*=s,Bt.elements[1]*=s,Bt.elements[2]*=s,Bt.elements[4]*=l,Bt.elements[5]*=l,Bt.elements[6]*=l,Bt.elements[8]*=c,Bt.elements[9]*=c,Bt.elements[10]*=c,e.setFromRotationMatrix(Bt),n.x=r,n.y=a,n.z=o,this}makePerspective(t,e,n,i,r,a,o=2e3){const s=this.elements,l=2*r/(e-t),c=2*r/(n-i),h=(e+t)/(e-t),d=(n+i)/(n-i);let u,f;if(o===w)u=-(a+r)/(a-r),f=-2*a*r/(a-r);else{if(o!==T)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);u=-a/(a-r),f=-a*r/(a-r)}return s[0]=l,s[4]=0,s[8]=h,s[12]=0,s[1]=0,s[5]=c,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=u,s[14]=f,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(t,e,n,i,r,a,o=2e3){const s=this.elements,l=1/(e-t),c=1/(n-i),h=1/(a-r),d=(e+t)*l,u=(n+i)*c;let f,p;if(o===w)f=(a+r)*h,p=-2*h;else{if(o!==T)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);f=r*h,p=-1*h}return s[0]=2*l,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*c,s[9]=0,s[13]=-u,s[2]=0,s[6]=0,s[10]=p,s[14]=-f,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Ft=new lt,Bt=new kt,Vt=new lt(0,0,0),Gt=new lt(1,1,1),Ht=new lt,Wt=new lt,jt=new lt,Xt=new kt,qt=new st;class Yt{constructor(t=0,e=0,n=0,i=Yt.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],a=i[4],o=i[8],s=i[1],l=i[5],c=i[9],h=i[2],d=i[6],u=i[10];switch(e){case"XYZ":this._y=Math.asin(I(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,u),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-I(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(o,u),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(I(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-h,u),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(s,r));break;case"ZYX":this._y=Math.asin(-I(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(d,u),this._z=Math.atan2(s,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(I(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(o,u));break;case"XZY":this._z=Math.asin(-I(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-c,u),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Xt.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Xt,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return qt.setFromEuler(this),this.setFromQuaternion(qt,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Yt.DEFAULT_ORDER="XYZ";class Zt{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return 0!=(this.mask&t.mask)}isEnabled(t){return 0!=(this.mask&(1<<t|0))}}let $t=0;const Jt=new lt,Qt=new st,Kt=new kt,te=new lt,ee=new lt,ne=new lt,ie=new st,re=new lt(1,0,0),ae=new lt(0,1,0),oe=new lt(0,0,1),se={type:"added"},le={type:"removed"},ce={type:"childadded",child:null},he={type:"childremoved",child:null};class de extends C{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:$t++}),this.uuid=P(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=de.DEFAULT_UP.clone();const t=new lt,e=new Yt,n=new st,i=new lt(1,1,1);e._onChange((function(){n.setFromEuler(e,!1)})),n._onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new kt},normalMatrix:{value:new F}}),this.matrix=new kt,this.matrixWorld=new kt,this.matrixAutoUpdate=de.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=de.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Zt,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Qt.setFromAxisAngle(t,e),this.quaternion.multiply(Qt),this}rotateOnWorldAxis(t,e){return Qt.setFromAxisAngle(t,e),this.quaternion.premultiply(Qt),this}rotateX(t){return this.rotateOnAxis(re,t)}rotateY(t){return this.rotateOnAxis(ae,t)}rotateZ(t){return this.rotateOnAxis(oe,t)}translateOnAxis(t,e){return Jt.copy(t).applyQuaternion(this.quaternion),this.position.add(Jt.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(re,t)}translateY(t){return this.translateOnAxis(ae,t)}translateZ(t){return this.translateOnAxis(oe,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Kt.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?te.copy(t):te.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),ee.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Kt.lookAt(ee,te,this.up):Kt.lookAt(te,ee,this.up),this.quaternion.setFromRotationMatrix(Kt),i&&(Kt.extractRotation(i.matrixWorld),Qt.setFromRotationMatrix(Kt),this.quaternion.premultiply(Qt.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(se),ce.child=t,this.dispatchEvent(ce),ce.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(le),he.child=t,this.dispatchEvent(he),he.child=null),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Kt.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),Kt.multiply(t.parent.matrixWorld)),t.applyMatrix4(Kt),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(se),ce.child=t,this.dispatchEvent(ce),ce.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(t,e);if(void 0!==i)return i}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ee,t,ne),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ee,ie,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++){e[n].updateMatrixWorld(t)}}updateWorldMatrix(t,e){const n=this.parent;if(!0===t&&null!==n&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),!0===this.matrixWorldAutoUpdate&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),!0===e){const t=this.children;for(let e=0,n=t.length;e<n;e++){t[e].updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};function r(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((t=>({boxInitialized:t.boxInitialized,boxMin:t.box.min.toArray(),boxMax:t.box.max.toArray(),sphereInitialized:t.sphereInitialized,sphereRadius:t.sphere.radius,sphereCenter:t.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,i=n.length;e<i;e++){const i=n[e];r(t.shapes,i)}else r(t.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,i=this.material.length;n<i;n++)e.push(r(t.materials,this.material[n]));i.material=e}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let e=0;e<this.children.length;e++)i.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];i.animations.push(r(t.animations,n))}}if(e){const e=a(t.geometries),i=a(t.materials),r=a(t.textures),o=a(t.images),s=a(t.shapes),l=a(t.skeletons),c=a(t.animations),h=a(t.nodes);e.length>0&&(n.geometries=e),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function a(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}}de.DEFAULT_UP=new lt(0,1,0),de.DEFAULT_MATRIX_AUTO_UPDATE=!0,de.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const ue=new lt,fe=new lt,pe=new lt,me=new lt,ge=new lt,ve=new lt,xe=new lt,_e=new lt,ye=new lt,Se=new lt;class Me{constructor(t=new lt,e=new lt,n=new lt){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),ue.subVectors(t,e),i.cross(ue);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){ue.subVectors(i,e),fe.subVectors(n,e),pe.subVectors(t,e);const a=ue.dot(ue),o=ue.dot(fe),s=ue.dot(pe),l=fe.dot(fe),c=fe.dot(pe),h=a*l-o*o;if(0===h)return r.set(0,0,0),null;const d=1/h,u=(l*s-o*c)*d,f=(a*c-o*s)*d;return r.set(1-u-f,f,u)}static containsPoint(t,e,n,i){return null!==this.getBarycoord(t,e,n,i,me)&&(me.x>=0&&me.y>=0&&me.x+me.y<=1)}static getInterpolation(t,e,n,i,r,a,o,s){return null===this.getBarycoord(t,e,n,i,me)?(s.x=0,s.y=0,"z"in s&&(s.z=0),"w"in s&&(s.w=0),null):(s.setScalar(0),s.addScaledVector(r,me.x),s.addScaledVector(a,me.y),s.addScaledVector(o,me.z),s)}static isFrontFacing(t,e,n,i){return ue.subVectors(n,e),fe.subVectors(t,e),ue.cross(fe).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return ue.subVectors(this.c,this.b),fe.subVectors(this.a,this.b),.5*ue.cross(fe).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Me.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Me.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Me.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Me.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Me.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let a,o;ge.subVectors(i,n),ve.subVectors(r,n),_e.subVectors(t,n);const s=ge.dot(_e),l=ve.dot(_e);if(s<=0&&l<=0)return e.copy(n);ye.subVectors(t,i);const c=ge.dot(ye),h=ve.dot(ye);if(c>=0&&h<=c)return e.copy(i);const d=s*h-c*l;if(d<=0&&s>=0&&c<=0)return a=s/(s-c),e.copy(n).addScaledVector(ge,a);Se.subVectors(t,r);const u=ge.dot(Se),f=ve.dot(Se);if(f>=0&&u<=f)return e.copy(r);const p=u*l-s*f;if(p<=0&&l>=0&&f<=0)return o=l/(l-f),e.copy(n).addScaledVector(ve,o);const m=c*f-u*h;if(m<=0&&h-c>=0&&u-f>=0)return xe.subVectors(r,i),o=(h-c)/(h-c+(u-f)),e.copy(i).addScaledVector(xe,o);const g=1/(m+p+d);return a=p*g,o=d*g,e.copy(n).addScaledVector(ge,a).addScaledVector(ve,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const be={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},we={h:0,s:0,l:0},Te={h:0,s:0,l:0};function Ce(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}class Ae{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(void 0===e&&void 0===n){const e=t;e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=m){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,Y.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=Y.workingColorSpace){return this.r=t,this.g=e,this.b=n,Y.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=Y.workingColorSpace){if(t=R(t,1),e=I(e,0,1),n=I(n,0,1),0===e)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+e):n+e-n*e,r=2*n-i;this.r=Ce(r,i,t+1/3),this.g=Ce(r,i,t),this.b=Ce(r,i,t-1/3)}return Y.toWorkingColorSpace(this,i),this}setStyle(t,e=m){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(n,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=m){const n=be[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Z(t.r),this.g=Z(t.g),this.b=Z(t.b),this}copyLinearToSRGB(t){return this.r=$(t.r),this.g=$(t.g),this.b=$(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=m){return Y.fromWorkingColorSpace(De.copy(this),t),65536*Math.round(I(255*De.r,0,255))+256*Math.round(I(255*De.g,0,255))+Math.round(I(255*De.b,0,255))}getHexString(t=m){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Y.workingColorSpace){Y.fromWorkingColorSpace(De.copy(this),e);const n=De.r,i=De.g,r=De.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let s,l;const c=(o+a)/2;if(o===a)s=0,l=0;else{const t=a-o;switch(l=c<=.5?t/(a+o):t/(2-a-o),a){case n:s=(i-r)/t+(i<r?6:0);break;case i:s=(r-n)/t+2;break;case r:s=(n-i)/t+4}s/=6}return t.h=s,t.s=l,t.l=c,t}getRGB(t,e=Y.workingColorSpace){return Y.fromWorkingColorSpace(De.copy(this),e),t.r=De.r,t.g=De.g,t.b=De.b,t}getStyle(t=m){Y.fromWorkingColorSpace(De.copy(this),t);const e=De.r,n=De.g,i=De.b;return t!==m?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(255*e)},${Math.round(255*n)},${Math.round(255*i)})`}offsetHSL(t,e,n){return this.getHSL(we),this.setHSL(we.h+t,we.s+e,we.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(we),t.getHSL(Te);const n=L(we.h,Te.h,e),i=L(we.s,Te.s,e),r=L(we.l,Te.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const De=new Ae;Ae.NAMES=be;let Ue=0;class Ee extends C{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ue++}),this.uuid=P(),this.name="",this.type="Material",this.blending=1,this.side=e,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.blendColor=new Ae(0,0,0),this.blendAlpha=0,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=S,this.stencilZFail=S,this.stencilZPass=S,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(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n:console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`)}}toJSON(t){const n=void 0===t||"string"==typeof t;n&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function r(t){const e=[];for(const n in t){const i=t[n];delete i.metadata,e.push(i)}return e}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()),void 0!==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(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(i.dispersion=this.dispersion),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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).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(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapRotation&&(i.envMapRotation=this.envMapRotation.toArray()),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(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).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),this.side!==e&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),204!==this.blendSrc&&(i.blendSrc=this.blendSrc),205!==this.blendDst&&(i.blendDst=this.blendDst),100!==this.blendEquation&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==S&&(i.stencilFail=this.stencilFail),this.stencilZFail!==S&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==S&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),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=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!0===this.wireframe&&(i.wireframe=!0),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=!0),!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),n){const e=r(t.textures),n=r(t.images);e.length>0&&(i.textures=e),n.length>0&&(i.images=n)}return i}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let i=0;i!==t;++i)n[i]=e[i].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}onBeforeRender(){console.warn("Material: onBeforeRender() has been removed.")}}class Pe extends Ee{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Ae(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Yt,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Ie=new lt,Re=new k;class Le{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=n,this.usage=M,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=c,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}get updateRange(){return H("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)Re.fromBufferAttribute(this,e),Re.applyMatrix3(t),this.setXY(e,Re.x,Re.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)Ie.fromBufferAttribute(this,e),Ie.applyMatrix3(t),this.setXYZ(e,Ie.x,Ie.y,Ie.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Ie.fromBufferAttribute(this,e),Ie.applyMatrix4(t),this.setXYZ(e,Ie.x,Ie.y,Ie.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ie.fromBufferAttribute(this,e),Ie.applyNormalMatrix(t),this.setXYZ(e,Ie.x,Ie.y,Ie.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ie.fromBufferAttribute(this,e),Ie.transformDirection(t),this.setXYZ(e,Ie.x,Ie.y,Ie.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=N(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=z(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=N(e,this.array)),e}setX(t,e){return this.normalized&&(e=z(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=N(e,this.array)),e}setY(t,e){return this.normalized&&(e=z(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=N(e,this.array)),e}setZ(t,e){return this.normalized&&(e=z(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=N(e,this.array)),e}setW(t,e){return this.normalized&&(e=z(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=z(e,this.array),n=z(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=z(e,this.array),n=z(n,this.array),i=z(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=z(e,this.array),n=z(n,this.array),i=z(i,this.array),r=z(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==M&&(t.usage=this.usage),t}}class Ne extends Le{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class ze extends Le{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Oe extends Le{constructor(t,e,n){super(new Float32Array(t),e,n)}}let ke=0;const Fe=new kt,Be=new de,Ve=new lt,Ge=new dt,He=new dt,We=new lt;class je extends C{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:ke++}),this.uuid=P(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(function(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}(t)?ze:Ne)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new F).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(t),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return Fe.makeRotationFromQuaternion(t),this.applyMatrix4(Fe),this}rotateX(t){return Fe.makeRotationX(t),this.applyMatrix4(Fe),this}rotateY(t){return Fe.makeRotationY(t),this.applyMatrix4(Fe),this}rotateZ(t){return Fe.makeRotationZ(t),this.applyMatrix4(Fe),this}translate(t,e,n){return Fe.makeTranslation(t,e,n),this.applyMatrix4(Fe),this}scale(t,e,n){return Fe.makeScale(t,e,n),this.applyMatrix4(Fe),this}lookAt(t){return Be.lookAt(t),Be.updateMatrix(),this.applyMatrix4(Be.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ve).negate(),this.translate(Ve.x,Ve.y,Ve.z),this}setFromPoints(t){const e=[];for(let n=0,i=t.length;n<i;n++){const i=t[n];e.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new Oe(e,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new dt);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),void this.boundingBox.set(new lt(-1/0,-1/0,-1/0),new lt(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];Ge.setFromBufferAttribute(n),this.morphTargetsRelative?(We.addVectors(this.boundingBox.min,Ge.min),this.boundingBox.expandByPoint(We),We.addVectors(this.boundingBox.max,Ge.max),this.boundingBox.expandByPoint(We)):(this.boundingBox.expandByPoint(Ge.min),this.boundingBox.expandByPoint(Ge.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Ut);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),void this.boundingSphere.set(new lt,1/0);if(t){const n=this.boundingSphere.center;if(Ge.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];He.setFromBufferAttribute(n),this.morphTargetsRelative?(We.addVectors(Ge.min,He.min),Ge.expandByPoint(We),We.addVectors(Ge.max,He.max),Ge.expandByPoint(We)):(Ge.expandByPoint(He.min),Ge.expandByPoint(He.max))}Ge.getCenter(n);let i=0;for(let e=0,r=t.count;e<r;e++)We.fromBufferAttribute(t,e),i=Math.max(i,n.distanceToSquared(We));if(e)for(let r=0,a=e.length;r<a;r++){const a=e[r],o=this.morphTargetsRelative;for(let e=0,r=a.count;e<r;e++)We.fromBufferAttribute(a,e),o&&(Ve.fromBufferAttribute(t,e),We.add(Ve)),i=Math.max(i,n.distanceToSquared(We))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.position,i=e.normal,r=e.uv;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new Le(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),o=[],s=[];for(let t=0;t<n.count;t++)o[t]=new lt,s[t]=new lt;const l=new lt,c=new lt,h=new lt,d=new k,u=new k,f=new k,p=new lt,m=new lt;function g(t,e,i){l.fromBufferAttribute(n,t),c.fromBufferAttribute(n,e),h.fromBufferAttribute(n,i),d.fromBufferAttribute(r,t),u.fromBufferAttribute(r,e),f.fromBufferAttribute(r,i),c.sub(l),h.sub(l),u.sub(d),f.sub(d);const a=1/(u.x*f.y-f.x*u.y);isFinite(a)&&(p.copy(c).multiplyScalar(f.y).addScaledVector(h,-u.y).multiplyScalar(a),m.copy(h).multiplyScalar(u.x).addScaledVector(c,-f.x).multiplyScalar(a),o[t].add(p),o[e].add(p),o[i].add(p),s[t].add(m),s[e].add(m),s[i].add(m))}let v=this.groups;0===v.length&&(v=[{start:0,count:t.count}]);for(let e=0,n=v.length;e<n;++e){const n=v[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)g(t.getX(e+0),t.getX(e+1),t.getX(e+2))}const x=new lt,_=new lt,y=new lt,S=new lt;function M(t){y.fromBufferAttribute(i,t),S.copy(y);const e=o[t];x.copy(e),x.sub(y.multiplyScalar(y.dot(e))).normalize(),_.crossVectors(S,e);const n=_.dot(s[t])<0?-1:1;a.setXYZW(t,x.x,x.y,x.z,n)}for(let e=0,n=v.length;e<n;++e){const n=v[e],i=n.start;for(let e=i,r=i+n.count;e<r;e+=3)M(t.getX(e+0)),M(t.getX(e+1)),M(t.getX(e+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new Le(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const i=new lt,r=new lt,a=new lt,o=new lt,s=new lt,l=new lt,c=new lt,h=new lt;if(t)for(let d=0,u=t.count;d<u;d+=3){const u=t.getX(d+0),f=t.getX(d+1),p=t.getX(d+2);i.fromBufferAttribute(e,u),r.fromBufferAttribute(e,f),a.fromBufferAttribute(e,p),c.subVectors(a,r),h.subVectors(i,r),c.cross(h),o.fromBufferAttribute(n,u),s.fromBufferAttribute(n,f),l.fromBufferAttribute(n,p),o.add(c),s.add(c),l.add(c),n.setXYZ(u,o.x,o.y,o.z),n.setXYZ(f,s.x,s.y,s.z),n.setXYZ(p,l.x,l.y,l.z)}else for(let t=0,o=e.count;t<o;t+=3)i.fromBufferAttribute(e,t+0),r.fromBufferAttribute(e,t+1),a.fromBufferAttribute(e,t+2),c.subVectors(a,r),h.subVectors(i,r),c.cross(h),n.setXYZ(t+0,c.x,c.y,c.z),n.setXYZ(t+1,c.x,c.y,c.z),n.setXYZ(t+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)We.fromBufferAttribute(t,e),We.normalize(),t.setXYZ(e,We.x,We.y,We.z)}toNonIndexed(){function t(t,e){const n=t.array,i=t.itemSize,r=t.normalized,a=new n.constructor(e.length*i);let o=0,s=0;for(let r=0,l=e.length;r<l;r++){o=t.isInterleavedBufferAttribute?e[r]*t.data.stride+t.offset:e[r]*i;for(let t=0;t<i;t++)a[s++]=n[o++]}return new Le(a,i,r)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new je,n=this.index.array,i=this.attributes;for(const r in i){const a=t(i[r],n);e.setAttribute(r,a)}const r=this.morphAttributes;for(const i in r){const a=[],o=r[i];for(let e=0,i=o.length;e<i;e++){const i=t(o[e],n);a.push(i)}e.morphAttributes[i]=a}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let t=0,n=a.length;t<n;t++){const n=a[t];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const i=n[e];t.data.attributes[e]=i.toJSON(t.data)}const i={};let r=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],a=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];a.push(i.toJSON(t.data))}a.length>0&&(i[e]=a,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return null!==o&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const i=t.attributes;for(const t in i){const n=i[t];this.setAttribute(t,n.clone(e))}const r=t.morphAttributes;for(const t in r){const n=[],i=r[t];for(let t=0,r=i.length;t<r;t++)n.push(i[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let t=0,e=a.length;t<e;t++){const e=a[t];this.addGroup(e.start,e.count,e.materialIndex)}const o=t.boundingBox;null!==o&&(this.boundingBox=o.clone());const s=t.boundingSphere;return null!==s&&(this.boundingSphere=s.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Xe=new kt,qe=new Ot,Ye=new Ut,Ze=new lt,$e=new lt,Je=new lt,Qe=new lt,Ke=new lt,tn=new lt,en=new k,nn=new k,rn=new k,an=new lt,on=new lt,sn=new lt,ln=new lt,cn=new lt;class hn extends de{constructor(t=new je,e=new Pe){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const o=this.morphTargetInfluences;if(r&&o){tn.set(0,0,0);for(let n=0,i=r.length;n<i;n++){const i=o[n],s=r[n];0!==i&&(Ke.fromBufferAttribute(s,t),a?tn.addScaledVector(Ke,i):tn.addScaledVector(Ke.sub(e),i))}e.add(tn)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i){if(null===n.boundingSphere&&n.computeBoundingSphere(),Ye.copy(n.boundingSphere),Ye.applyMatrix4(r),qe.copy(t.ray).recast(t.near),!1===Ye.containsPoint(qe.origin)){if(null===qe.intersectSphere(Ye,Ze))return;if(qe.origin.distanceToSquared(Ze)>(t.far-t.near)**2)return}Xe.copy(r).invert(),qe.copy(t.ray).applyMatrix4(Xe),null!==n.boundingBox&&!1===qe.intersectsBox(n.boundingBox)||this._computeIntersections(t,e,qe)}}_computeIntersections(t,e,n){let i;const r=this.geometry,a=this.material,o=r.index,s=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,d=r.groups,u=r.drawRange;if(null!==o)if(Array.isArray(a))for(let r=0,s=d.length;r<s;r++){const s=d[r],f=a[s.materialIndex];for(let r=Math.max(s.start,u.start),a=Math.min(o.count,Math.min(s.start+s.count,u.start+u.count));r<a;r+=3){i=dn(this,f,t,n,l,c,h,o.getX(r),o.getX(r+1),o.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=s.materialIndex,e.push(i))}}else{for(let r=Math.max(0,u.start),s=Math.min(o.count,u.start+u.count);r<s;r+=3){i=dn(this,a,t,n,l,c,h,o.getX(r),o.getX(r+1),o.getX(r+2)),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}else if(void 0!==s)if(Array.isArray(a))for(let r=0,o=d.length;r<o;r++){const o=d[r],f=a[o.materialIndex];for(let r=Math.max(o.start,u.start),a=Math.min(s.count,Math.min(o.start+o.count,u.start+u.count));r<a;r+=3){i=dn(this,f,t,n,l,c,h,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),i.face.materialIndex=o.materialIndex,e.push(i))}}else{for(let r=Math.max(0,u.start),o=Math.min(s.count,u.start+u.count);r<o;r+=3){i=dn(this,a,t,n,l,c,h,r,r+1,r+2),i&&(i.faceIndex=Math.floor(r/3),e.push(i))}}}}function dn(t,i,r,a,o,s,l,c,h,d){t.getVertexPosition(c,$e),t.getVertexPosition(h,Je),t.getVertexPosition(d,Qe);const u=function(t,i,r,a,o,s,l,c){let h;if(h=i.side===n?a.intersectTriangle(l,s,o,!0,c):a.intersectTriangle(o,s,l,i.side===e,c),null===h)return null;cn.copy(c),cn.applyMatrix4(t.matrixWorld);const d=r.ray.origin.distanceTo(cn);return d<r.near||d>r.far?null:{distance:d,point:cn.clone(),object:t}}(t,i,r,a,$e,Je,Qe,ln);if(u){o&&(en.fromBufferAttribute(o,c),nn.fromBufferAttribute(o,h),rn.fromBufferAttribute(o,d),u.uv=Me.getInterpolation(ln,$e,Je,Qe,en,nn,rn,new k)),s&&(en.fromBufferAttribute(s,c),nn.fromBufferAttribute(s,h),rn.fromBufferAttribute(s,d),u.uv1=Me.getInterpolation(ln,$e,Je,Qe,en,nn,rn,new k)),l&&(an.fromBufferAttribute(l,c),on.fromBufferAttribute(l,h),sn.fromBufferAttribute(l,d),u.normal=Me.getInterpolation(ln,$e,Je,Qe,an,on,sn,new lt),u.normal.dot(a.direction)>0&&u.normal.multiplyScalar(-1));const t={a:c,b:h,c:d,normal:new lt,materialIndex:0};Me.getNormal($e,Je,Qe,t.normal),u.face=t}return u}function un(t){const e={};for(const n in t){e[n]={};for(const i in t[n]){const r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[n][i]=null):e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}}return e}const fn={clone:un,merge:function(t){const e={};for(let n=0;n<t.length;n++){const i=un(t[n]);for(const t in i)e[t]=i[t]}return e}};class pn extends Ee{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=un(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?e.uniforms[n]={type:"t",value:i.toJSON(t).uuid}:i&&i.isColor?e.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?e.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?e.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?e.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?e.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?e.uniforms[n]={type:"m4",value:i.toArray()}:e.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class mn extends de{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new kt,this.projectionMatrix=new kt,this.projectionMatrixInverse=new kt,this.coordinateSystem=w}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const gn=new lt,vn=new lt,xn=new F;class _n{constructor(t=new lt(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=gn.subVectors(n,e).cross(vn.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(gn),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||xn.getNormalMatrix(t),i=this.coplanarPoint(gn).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const yn=new Ut,Sn=new lt;class Mn{constructor(t=new _n,e=new _n,n=new _n,i=new _n,r=new _n,a=new _n){this.planes=[t,e,n,i,r,a]}set(t,e,n,i,r,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=2e3){const n=this.planes,i=t.elements,r=i[0],a=i[1],o=i[2],s=i[3],l=i[4],c=i[5],h=i[6],d=i[7],u=i[8],f=i[9],p=i[10],m=i[11],g=i[12],v=i[13],x=i[14],_=i[15];if(n[0].setComponents(s-r,d-l,m-u,_-g).normalize(),n[1].setComponents(s+r,d+l,m+u,_+g).normalize(),n[2].setComponents(s+a,d+c,m+f,_+v).normalize(),n[3].setComponents(s-a,d-c,m-f,_-v).normalize(),n[4].setComponents(s-o,d-h,m-p,_-x).normalize(),e===w)n[5].setComponents(s+o,d+h,m+p,_+x).normalize();else{if(e!==T)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);n[5].setComponents(o,h,p,x).normalize()}return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),yn.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),yn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(yn)}intersectsSprite(t){return yn.center.set(0,0,0),yn.radius=.7071067811865476,yn.applyMatrix4(t.matrixWorld),this.intersectsSphere(yn)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(n)<i)return!1}return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(Sn.x=i.normal.x>0?t.max.x:t.min.x,Sn.y=i.normal.y>0?t.max.y:t.min.y,Sn.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Sn)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}class bn extends je{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,a=e/2,o=Math.floor(n),s=Math.floor(i),l=o+1,c=s+1,h=t/o,d=e/s,u=[],f=[],p=[],m=[];for(let t=0;t<c;t++){const e=t*d-a;for(let n=0;n<l;n++){const i=n*h-r;f.push(i,-e,0),p.push(0,0,1),m.push(n/o),m.push(1-t/s)}}for(let t=0;t<s;t++)for(let e=0;e<o;e++){const n=e+l*t,i=e+l*(t+1),r=e+1+l*(t+1),a=e+1+l*t;u.push(n,i,a),u.push(i,r,a)}this.setIndex(u),this.setAttribute("position",new Oe(f,3)),this.setAttribute("normal",new Oe(p,3)),this.setAttribute("uv",new Oe(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new bn(t.width,t.height,t.widthSegments,t.heightSegments)}}const wn={alphahash_fragment:"#ifdef USE_ALPHAHASH\n\tif ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n\tconst float ALPHA_HASH_SCALE = 0.05;\n\tfloat hash2D( vec2 value ) {\n\t\treturn fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n\t}\n\tfloat hash3D( vec3 value ) {\n\t\treturn hash2D( vec2( hash2D( value.xy ), value.z ) );\n\t}\n\tfloat getAlphaHashThreshold( vec3 position ) {\n\t\tfloat maxDeriv = max(\n\t\t\tlength( dFdx( position.xyz ) ),\n\t\t\tlength( dFdy( position.xyz ) )\n\t\t);\n\t\tfloat pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n\t\tvec2 pixScales = vec2(\n\t\t\texp2( floor( log2( pixScale ) ) ),\n\t\t\texp2( ceil( log2( pixScale ) ) )\n\t\t);\n\t\tvec2 alpha = vec2(\n\t\t\thash3D( floor( pixScales.x * position.xyz ) ),\n\t\t\thash3D( floor( pixScales.y * position.xyz ) )\n\t\t);\n\t\tfloat lerpFactor = fract( log2( pixScale ) );\n\t\tfloat x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n\t\tfloat a = min( lerpFactor, 1.0 - lerpFactor );\n\t\tvec3 cases = vec3(\n\t\t\tx * x / ( 2.0 * a * ( 1.0 - a ) ),\n\t\t\t( x - 0.5 * a ) / ( 1.0 - a ),\n\t\t\t1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n\t\t);\n\t\tfloat threshold = ( x < ( 1.0 - a ) )\n\t\t\t? ( ( x < a ) ? cases.x : cases.y )\n\t\t\t: cases.z;\n\t\treturn clamp( threshold , 1.0e-6, 1.0 );\n\t}\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n\t#ifdef ALPHA_TO_COVERAGE\n\tdiffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\tif ( diffuseColor.a < alphaTest ) discard;\n\t#endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_CLEARCOAT ) \n\t\tclearcoatSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_SHEEN ) \n\t\tsheenSpecularIndirect *= ambientOcclusion;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n\t#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n\t#if ! defined( GL_ANGLE_multi_draw )\n\t#define gl_DrawID _gl_DrawID\n\tuniform int _gl_DrawID;\n\t#endif\n\tuniform highp sampler2D batchingTexture;\n\tuniform highp usampler2D batchingIdTexture;\n\tmat4 getBatchingMatrix( const in float i ) {\n\t\tint size = textureSize( batchingTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n\tfloat getIndirectIndex( const in int i ) {\n\t\tint size = textureSize( batchingIdTexture, 0 ).x;\n\t\tint x = i % size;\n\t\tint y = i / size;\n\t\treturn float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n\t}\n#endif\n#ifdef USE_BATCHING_COLOR\n\tuniform sampler2D batchingColorTexture;\n\tvec3 getBatchingColor( const in float i ) {\n\t\tint size = textureSize( batchingColorTexture, 0 ).x;\n\t\tint j = int( i );\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\treturn texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n\t}\n#endif",batching_vertex:"#ifdef USE_BATCHING\n\tmat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n\tvPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\treturn vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vBumpMapUv );\n\t\tvec2 dSTdy = dFdy( vBumpMapUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n\t\tvec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#ifdef ALPHA_TO_COVERAGE\n\t\tfloat distanceToPlane, distanceGradient;\n\t\tfloat clipOpacity = 1.0;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\tclipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\tif ( clipOpacity == 0.0 ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tfloat unionClipOpacity = 1.0;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tdistanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n\t\t\t\tdistanceGradient = fwidth( distanceToPlane ) / 2.0;\n\t\t\t\tunionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tclipOpacity *= 1.0 - unionClipOpacity;\n\t\t#endif\n\t\tdiffuseColor.a *= clipOpacity;\n\t\tif ( diffuseColor.a == 0.0 ) discard;\n\t#else\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\t\tbool clipped = true;\n\t\t\t#pragma unroll_loop_start\n\t\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\t\tplane = clippingPlanes[ i ];\n\t\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t\t}\n\t\t\t#pragma unroll_loop_end\n\t\t\tif ( clipped ) discard;\n\t\t#endif\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n\tvec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n\tvColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n\tmat3 bm = mat3( batchingMatrix );\n\ttransformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n\ttransformedNormal = bm * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = bm * transformedTangent;\n\t#endif\n#endif\n#ifdef USE_INSTANCING\n\tmat3 im = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n\ttransformedNormal = im * transformedNormal;\n\t#ifdef USE_TANGENT\n\t\ttransformedTangent = im * transformedTangent;\n\t#endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\ttransformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"\nconst mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(\n\tvec3( 0.8224621, 0.177538, 0.0 ),\n\tvec3( 0.0331941, 0.9668058, 0.0 ),\n\tvec3( 0.0170827, 0.0723974, 0.9105199 )\n);\nconst mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.2249401, - 0.2249404, 0.0 ),\n\tvec3( - 0.0420569, 1.0420571, 0.0 ),\n\tvec3( - 0.0196376, - 0.0786361, 1.0982735 )\n);\nvec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );\n}\nvec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {\n\treturn vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );\n}\nvec4 LinearTransferOETF( in vec4 value ) {\n\treturn value;\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn sRGBTransferOETF( value );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform mat3 envMapRotation;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n\tuniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif ( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometryPosition;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n\tmaterial.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tif( material.anisotropy == 0.0 ) {\n\t\tanisotropyV = vec2( 1.0, 0.0 );\n\t} else {\n\t\tanisotropyV /= material.anisotropy;\n\t\tmaterial.anisotropy = saturate( material.anisotropy );\n\t}\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\tfloat dispersion;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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 ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometryNormal;\n\t\tvec3 viewDir = geometryViewDir;\n\t\tvec3 position = geometryPosition;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n\tgeometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometryViewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometryPosition, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometryPosition, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#if defined( USE_LIGHT_PROBES )\n\t\tirradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometryNormal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tgl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\tvFragDepth = 1.0 + gl_Position.w;\n\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vMapUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n\tfloat morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\tfloat morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tmorphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n\t}\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_INSTANCING_MORPH\n\t\tuniform float morphTargetBaseInfluence;\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t#endif\n\tuniform sampler2DArray morphTargetsTexture;\n\tuniform ivec2 morphTargetsTextureSize;\n\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t}\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t}\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n\tmvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tfloat shadow = 1.0;\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\t\n\t\tfloat lightToPositionLength = length( lightToPosition );\n\t\tif ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {\n\t\t\tfloat dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\t\tdp += shadowBias;\n\t\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\t\tshadow = (\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t\t) * ( 1.0 / 9.0 );\n\t\t\t#else\n\t\t\t\tshadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t\t#endif\n\t\t}\n\t\treturn mix( 1.0, shadow, shadowIntensity );\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowIntensity;\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tint size = textureSize( boneTexture, 0 ).x;\n\t\tint j = int( i ) * 4;\n\t\tint x = j % size;\n\t\tint y = j / size;\n\t\tvec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n\t\tvec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n\t\tvec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n\t\tvec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n\t\treturn mat4( v1, v2, v3, v4 );\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n\tvec3( 1.6605, - 0.1246, - 0.0182 ),\n\tvec3( - 0.5876, 1.1329, - 0.1006 ),\n\tvec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n\tvec3( 0.6274, 0.0691, 0.0164 ),\n\tvec3( 0.3293, 0.9195, 0.0880 ),\n\tvec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n\tvec3 x2 = x * x;\n\tvec3 x4 = x2 * x2;\n\treturn + 15.5 * x4 * x2\n\t\t- 40.14 * x4 * x\n\t\t+ 31.96 * x4\n\t\t- 6.868 * x2 * x\n\t\t+ 0.4298 * x2\n\t\t+ 0.1191 * x\n\t\t- 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n\tconst mat3 AgXInsetMatrix = mat3(\n\t\tvec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n\t\tvec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n\t\tvec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n\t);\n\tconst mat3 AgXOutsetMatrix = mat3(\n\t\tvec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n\t\tvec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n\t\tvec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n\t);\n\tconst float AgxMinEv = - 12.47393;\tconst float AgxMaxEv = 4.026069;\n\tcolor *= toneMappingExposure;\n\tcolor = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n\tcolor = AgXInsetMatrix * color;\n\tcolor = max( color, 1e-10 );\tcolor = log2( color );\n\tcolor = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n\tcolor = clamp( color, 0.0, 1.0 );\n\tcolor = agxDefaultContrastApprox( color );\n\tcolor = AgXOutsetMatrix * color;\n\tcolor = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n\tcolor = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n\tcolor = clamp( color, 0.0, 1.0 );\n\treturn color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n\tconst float StartCompression = 0.8 - 0.04;\n\tconst float Desaturation = 0.15;\n\tcolor *= toneMappingExposure;\n\tfloat x = min( color.r, min( color.g, color.b ) );\n\tfloat offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n\tcolor -= offset;\n\tfloat peak = max( color.r, max( color.g, color.b ) );\n\tif ( peak < StartCompression ) return color;\n\tfloat d = 1. - StartCompression;\n\tfloat newPeak = 1. - d * d / ( peak + d - StartCompression );\n\tcolor *= newPeak / peak;\n\tfloat g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n\treturn mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec4 transmittedLight;\n\t\tvec3 transmittance;\n\t\t#ifdef USE_DISPERSION\n\t\t\tfloat halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n\t\t\tvec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n\t\t\tfor ( int i = 0; i < 3; i ++ ) {\n\t\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n\t\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\n\t\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\t\trefractionCoords += 1.0;\n\t\t\t\trefractionCoords /= 2.0;\n\t\t\n\t\t\t\tvec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n\t\t\t\ttransmittedLight[ i ] = transmissionSample[ i ];\n\t\t\t\ttransmittedLight.a += transmissionSample.a;\n\t\t\t\ttransmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n\t\t\t}\n\t\t\ttransmittedLight.a /= 3.0;\n\t\t\n\t\t#else\n\t\t\n\t\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\t\trefractionCoords += 1.0;\n\t\t\trefractionCoords /= 2.0;\n\t\t\ttransmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\t\ttransmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\t\n\t\t#endif\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_BATCHING\n\t\tworldPosition = batchingMatrix * worldPosition;\n\t#endif\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\ttexColor = 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 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",depth_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <logdepthbuf_fragment>\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <skinbase_vertex>\n\t#include <morphinstance_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <clipping_planes_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinbase_vertex>\n\t\t#include <skinnormal_vertex>\n\t\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_lambert_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n\tuniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include <transmission_fragment>\n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n\t#endif\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <normal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_toon_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include <color_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphcolor_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <batching_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphinstance_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\t#include <logdepthbuf_fragment>\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <alphahash_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <opaque_fragment>\n\t#include <tonemapping_fragment>\n\t#include <colorspace_fragment>\n\t#include <fog_fragment>\n}"};class Tn extends mn{constructor(t=-1,e=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,a=n+t,o=i+e,s=i-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=t*this.view.offsetX,a=r+t*this.view.width,o-=e*this.view.offsetY,s=o-e*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}class Cn extends it{constructor(t,e,n,i,r,a,s,c,h,d=1026){if(d!==u&&1027!==d)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&d===u&&(n=l),void 0===n&&1027===d&&(n=1020),super(null,i,r,a,s,c,d,n,h),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==s?s:o,this.minFilter=void 0!==c?c:o,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class An extends Ee{constructor(t){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(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class Dn extends Ee{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class Un extends de{constructor(){super(),this.isGroup=!0,this.type="Group"}}class En extends de{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Yt,this.environmentIntensity=1,this.environmentRotation=new Yt,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class Pn{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=M,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=P()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}get updateRange(){return H("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=P()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=P()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const In=new lt;class Rn{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)In.fromBufferAttribute(this,e),In.applyMatrix4(t),this.setXYZ(e,In.x,In.y,In.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)In.fromBufferAttribute(this,e),In.applyNormalMatrix(t),this.setXYZ(e,In.x,In.y,In.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)In.fromBufferAttribute(this,e),In.transformDirection(t),this.setXYZ(e,In.x,In.y,In.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=N(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=z(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=z(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=z(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=z(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=z(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=N(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=N(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=N(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=N(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=z(e,this.array),n=z(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=z(e,this.array),n=z(n,this.array),i=z(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=z(e,this.array),n=z(n,this.array),i=z(i,this.array),r=z(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new Le(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Rn(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ln extends Ee{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Ae(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let Nn;const zn=new lt,On=new lt,kn=new lt,Fn=new k,Bn=new k,Vn=new kt,Gn=new lt,Hn=new lt,Wn=new lt,jn=new k,Xn=new k,qn=new k;class Yn extends de{constructor(t=new Ln){if(super(),this.isSprite=!0,this.type="Sprite",void 0===Nn){Nn=new je;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),e=new Pn(t,5);Nn.setIndex([0,1,2,0,2,3]),Nn.setAttribute("position",new Rn(e,3,0,!1)),Nn.setAttribute("uv",new Rn(e,2,3,!1))}this.geometry=Nn,this.material=t,this.center=new k(.5,.5)}raycast(t,e){null===t.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),On.setFromMatrixScale(this.matrixWorld),Vn.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),kn.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&On.multiplyScalar(-kn.z);const n=this.material.rotation;let i,r;0!==n&&(r=Math.cos(n),i=Math.sin(n));const a=this.center;Zn(Gn.set(-.5,-.5,0),kn,a,On,i,r),Zn(Hn.set(.5,-.5,0),kn,a,On,i,r),Zn(Wn.set(.5,.5,0),kn,a,On,i,r),jn.set(0,0),Xn.set(1,0),qn.set(1,1);let o=t.ray.intersectTriangle(Gn,Hn,Wn,!1,zn);if(null===o&&(Zn(Hn.set(-.5,.5,0),kn,a,On,i,r),Xn.set(0,1),o=t.ray.intersectTriangle(Gn,Wn,Hn,!1,zn),null===o))return;const s=t.ray.origin.distanceTo(zn);s<t.near||s>t.far||e.push({distance:s,point:zn.clone(),uv:Me.getInterpolation(zn,Gn,Hn,Wn,jn,Xn,qn,new k),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function Zn(t,e,n,i,r,a){Fn.subVectors(t,n).addScalar(.5).multiply(i),void 0!==r?(Bn.x=a*Fn.x-r*Fn.y,Bn.y=r*Fn.x+a*Fn.y):Bn.copy(Fn),t.copy(e),t.x+=Bn.x,t.y+=Bn.y,t.applyMatrix4(Vn)}const $n=new lt,Jn=new rt,Qn=new rt,Kn=new lt,ti=new kt,ei=new lt,ni=new Ut,ii=new kt,ri=new Ot;class ai extends hn{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=i,this.bindMatrix=new kt,this.bindMatrixInverse=new kt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;null===this.boundingBox&&(this.boundingBox=new dt),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,ei),this.boundingBox.expandByPoint(ei)}computeBoundingSphere(){const t=this.geometry;null===this.boundingSphere&&(this.boundingSphere=new Ut),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let t=0;t<e.count;t++)this.getVertexPosition(t,ei),this.boundingSphere.expandByPoint(ei)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;void 0!==n&&(null===this.boundingSphere&&this.computeBoundingSphere(),ni.copy(this.boundingSphere),ni.applyMatrix4(i),!1!==t.ray.intersectsSphere(ni)&&(ii.copy(i).invert(),ri.copy(t.ray).applyMatrix4(ii),null!==this.boundingBox&&!1===ri.intersectsBox(this.boundingBox)||this._computeIntersections(t,e,ri)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new rt,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const i=1/t.manhattanLength();i!==1/0?t.multiplyScalar(i):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===i?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;Jn.fromBufferAttribute(i.attributes.skinIndex,t),Qn.fromBufferAttribute(i.attributes.skinWeight,t),$n.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let t=0;t<4;t++){const i=Qn.getComponent(t);if(0!==i){const r=Jn.getComponent(t);ti.multiplyMatrices(n.bones[r].matrixWorld,n.boneInverses[r]),e.addScaledVector(Kn.copy($n).applyMatrix4(ti),i)}}return e.applyMatrix4(this.bindMatrixInverse)}}class oi extends it{constructor(t=null,e=1,n=1,i,r,a,o,s,l=1003,c=1003,h,d){super(null,a,o,s,l,c,i,r,h,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class si extends Le{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const li=new kt,ci=new kt,hi=[],di=new dt,ui=new kt,fi=new hn,pi=new Ut;class mi extends hn{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new si(new Float32Array(16*n),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let t=0;t<n;t++)this.setMatrixAt(t,ui)}computeBoundingBox(){const t=this.geometry,e=this.count;null===this.boundingBox&&(this.boundingBox=new dt),null===t.boundingBox&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,li),di.copy(t.boundingBox).applyMatrix4(li),this.boundingBox.union(di)}computeBoundingSphere(){const t=this.geometry,e=this.count;null===this.boundingSphere&&(this.boundingSphere=new Ut),null===t.boundingSphere&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,li),pi.copy(t.boundingSphere).applyMatrix4(li),this.boundingSphere.union(pi)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),null!==t.morphTexture&&(this.morphTexture=t.morphTexture.clone()),null!==t.instanceColor&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){e.fromArray(this.instanceColor.array,3*t)}getMatrixAt(t,e){e.fromArray(this.instanceMatrix.array,16*t)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=t*(n.length+1)+1;for(let t=0;t<n.length;t++)n[t]=i[r+t]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(fi.geometry=this.geometry,fi.material=this.material,void 0!==fi.material&&(null===this.boundingSphere&&this.computeBoundingSphere(),pi.copy(this.boundingSphere),pi.applyMatrix4(n),!1!==t.ray.intersectsSphere(pi)))for(let r=0;r<i;r++){this.getMatrixAt(r,li),ci.multiplyMatrices(n,li),fi.matrixWorld=ci,fi.raycast(t,hi);for(let t=0,n=hi.length;t<n;t++){const n=hi[t];n.instanceId=r,n.object=this,e.push(n)}hi.length=0}}setColorAt(t,e){null===this.instanceColor&&(this.instanceColor=new si(new Float32Array(3*this.instanceMatrix.count),3)),e.toArray(this.instanceColor.array,3*t)}setMatrixAt(t,e){e.toArray(this.instanceMatrix.array,16*t)}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;null===this.morphTexture&&(this.morphTexture=new oi(new Float32Array(i*this.count),i,this.count,1028,c));const r=this.morphTexture.source.data.data;let a=0;for(let t=0;t<n.length;t++)a+=n[t];const o=this.geometry.morphTargetsRelative?1:1-a,s=i*t;r[s]=o,r.set(n,s+1)}updateMorphTargets(){}dispose(){return this.dispatchEvent({type:"dispose"}),null!==this.morphTexture&&(this.morphTexture.dispose(),this.morphTexture=null),this}}class gi extends Ee{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Ae(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const vi=new lt,xi=new lt,_i=new kt,yi=new Ot,Si=new Ut,Mi=new lt,bi=new lt;class wi extends de{constructor(t=new je,e=new gi){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,i=e.count;t<i;t++)vi.fromBufferAttribute(e,t-1),xi.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=vi.distanceTo(xi);t.setAttribute("lineDistance",new Oe(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Si.copy(n.boundingSphere),Si.applyMatrix4(i),Si.radius+=r,!1===t.ray.intersectsSphere(Si))return;_i.copy(i).invert(),yi.copy(t.ray).applyMatrix4(_i);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,l=this.isLineSegments?2:1,c=n.index,h=n.attributes.position;if(null!==c){const n=Math.max(0,a.start),i=Math.min(c.count,a.start+a.count);for(let r=n,a=i-1;r<a;r+=l){const n=c.getX(r),i=c.getX(r+1),a=Ti(this,t,yi,s,n,i);a&&e.push(a)}if(this.isLineLoop){const r=c.getX(i-1),a=c.getX(n),o=Ti(this,t,yi,s,r,a);o&&e.push(o)}}else{const n=Math.max(0,a.start),i=Math.min(h.count,a.start+a.count);for(let r=n,a=i-1;r<a;r+=l){const n=Ti(this,t,yi,s,r,r+1);n&&e.push(n)}if(this.isLineLoop){const r=Ti(this,t,yi,s,i-1,n);r&&e.push(r)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}function Ti(t,e,n,i,r,a){const o=t.geometry.attributes.position;vi.fromBufferAttribute(o,r),xi.fromBufferAttribute(o,a);if(n.distanceSqToSegment(vi,xi,Mi,bi)>i)return;Mi.applyMatrix4(t.matrixWorld);const s=e.ray.origin.distanceTo(Mi);return s<e.near||s>e.far?void 0:{distance:s,point:bi.clone().applyMatrix4(t.matrixWorld),index:r,face:null,faceIndex:null,object:t}}const Ci=new lt,Ai=new lt;class Di extends wi{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,i=e.count;t<i;t+=2)Ci.fromBufferAttribute(e,t),Ai.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+Ci.distanceTo(Ai);t.setAttribute("lineDistance",new Oe(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Ui extends Ee{constructor(t){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Ae(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 Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new k(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Yt,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Ei extends Ui{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new k(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return I(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Ae(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ae(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ae(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class Pi extends Ee{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new k(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class Ii extends Ee{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Ae(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Ae(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new k(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Yt,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}const Ri={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class Li{constructor(t,e,n){const i=this;let r,a=!1,o=0,s=0;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){s++,!1===a&&void 0!==i.onStart&&i.onStart(t,o,s),a=!0},this.itemEnd=function(t){o++,void 0!==i.onProgress&&i.onProgress(t,o,s),o===s&&(a=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return r?r(t):t},this.setURLModifier=function(t){return r=t,this},this.addHandler=function(t,e){return l.push(t,e),this},this.removeHandler=function(t){const e=l.indexOf(t);return-1!==e&&l.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=l.length;e<n;e+=2){const n=l[e],i=l[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return i}return null}}}const Ni=new Li;class zi{constructor(t){this.manager=void 0!==t?t:Ni,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise((function(i,r){n.load(t,i,e,r)}))}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}zi.DEFAULT_MATERIAL_NAME="__DEFAULT";class Oi extends zi{constructor(t){super(t)}load(t,e,n,i){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=Ri.get(t);if(void 0!==a)return r.manager.itemStart(t),setTimeout((function(){e&&e(a),r.manager.itemEnd(t)}),0),a;const o=V("img");function s(){c(),Ri.add(t,this),e&&e(this),r.manager.itemEnd(t)}function l(e){c(),i&&i(e),r.manager.itemError(t),r.manager.itemEnd(t)}function c(){o.removeEventListener("load",s,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",s,!1),o.addEventListener("error",l,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(t),o.src=t,o}}class ki extends zi{constructor(t){super(t)}load(t,e,n,i){const r=new it,a=new Oi(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,(function(t){r.image=t,r.needsUpdate=!0,void 0!==e&&e(r)}),n,i),r}}class Fi extends je{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){const t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class Bi{constructor(t){this.value=t}clone(){return new Bi(void 0===this.value.clone?this.value:this.value.clone())}}const Vi=new lt,Gi=new mn;class Hi extends Di{constructor(t){const e=new je,n=new gi({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],a={};function o(t,e){s(t),s(e)}function s(t){i.push(0,0,0),r.push(0,0,0),void 0===a[t]&&(a[t]=[]),a[t].push(i.length/3-1)}o("n1","n2"),o("n2","n4"),o("n4","n3"),o("n3","n1"),o("f1","f2"),o("f2","f4"),o("f4","f3"),o("f3","f1"),o("n1","f1"),o("n2","f2"),o("n3","f3"),o("n4","f4"),o("p","n1"),o("p","n2"),o("p","n3"),o("p","n4"),o("u1","u2"),o("u2","u3"),o("u3","u1"),o("c","t"),o("p","c"),o("cn1","cn2"),o("cn3","cn4"),o("cf1","cf2"),o("cf3","cf4"),e.setAttribute("position",new Oe(i,3)),e.setAttribute("color",new Oe(r,3)),super(e,n),this.type="CameraHelper",this.camera=t,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const l=new Ae(16755200),c=new Ae(16711680),h=new Ae(43775),d=new Ae(16777215),u=new Ae(3355443);this.setColors(l,c,h,d,u)}setColors(t,e,n,i,r){const a=this.geometry.getAttribute("color");a.setXYZ(0,t.r,t.g,t.b),a.setXYZ(1,t.r,t.g,t.b),a.setXYZ(2,t.r,t.g,t.b),a.setXYZ(3,t.r,t.g,t.b),a.setXYZ(4,t.r,t.g,t.b),a.setXYZ(5,t.r,t.g,t.b),a.setXYZ(6,t.r,t.g,t.b),a.setXYZ(7,t.r,t.g,t.b),a.setXYZ(8,t.r,t.g,t.b),a.setXYZ(9,t.r,t.g,t.b),a.setXYZ(10,t.r,t.g,t.b),a.setXYZ(11,t.r,t.g,t.b),a.setXYZ(12,t.r,t.g,t.b),a.setXYZ(13,t.r,t.g,t.b),a.setXYZ(14,t.r,t.g,t.b),a.setXYZ(15,t.r,t.g,t.b),a.setXYZ(16,t.r,t.g,t.b),a.setXYZ(17,t.r,t.g,t.b),a.setXYZ(18,t.r,t.g,t.b),a.setXYZ(19,t.r,t.g,t.b),a.setXYZ(20,t.r,t.g,t.b),a.setXYZ(21,t.r,t.g,t.b),a.setXYZ(22,t.r,t.g,t.b),a.setXYZ(23,t.r,t.g,t.b),a.setXYZ(24,e.r,e.g,e.b),a.setXYZ(25,e.r,e.g,e.b),a.setXYZ(26,e.r,e.g,e.b),a.setXYZ(27,e.r,e.g,e.b),a.setXYZ(28,e.r,e.g,e.b),a.setXYZ(29,e.r,e.g,e.b),a.setXYZ(30,e.r,e.g,e.b),a.setXYZ(31,e.r,e.g,e.b),a.setXYZ(32,n.r,n.g,n.b),a.setXYZ(33,n.r,n.g,n.b),a.setXYZ(34,n.r,n.g,n.b),a.setXYZ(35,n.r,n.g,n.b),a.setXYZ(36,n.r,n.g,n.b),a.setXYZ(37,n.r,n.g,n.b),a.setXYZ(38,i.r,i.g,i.b),a.setXYZ(39,i.r,i.g,i.b),a.setXYZ(40,r.r,r.g,r.b),a.setXYZ(41,r.r,r.g,r.b),a.setXYZ(42,r.r,r.g,r.b),a.setXYZ(43,r.r,r.g,r.b),a.setXYZ(44,r.r,r.g,r.b),a.setXYZ(45,r.r,r.g,r.b),a.setXYZ(46,r.r,r.g,r.b),a.setXYZ(47,r.r,r.g,r.b),a.setXYZ(48,r.r,r.g,r.b),a.setXYZ(49,r.r,r.g,r.b),a.needsUpdate=!0}update(){const t=this.geometry,e=this.pointMap;Gi.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Wi("c",e,t,Gi,0,0,-1),Wi("t",e,t,Gi,0,0,1),Wi("n1",e,t,Gi,-1,-1,-1),Wi("n2",e,t,Gi,1,-1,-1),Wi("n3",e,t,Gi,-1,1,-1),Wi("n4",e,t,Gi,1,1,-1),Wi("f1",e,t,Gi,-1,-1,1),Wi("f2",e,t,Gi,1,-1,1),Wi("f3",e,t,Gi,-1,1,1),Wi("f4",e,t,Gi,1,1,1),Wi("u1",e,t,Gi,.7,1.1,-1),Wi("u2",e,t,Gi,-.7,1.1,-1),Wi("u3",e,t,Gi,0,2,-1),Wi("cf1",e,t,Gi,-1,0,1),Wi("cf2",e,t,Gi,1,0,1),Wi("cf3",e,t,Gi,0,-1,1),Wi("cf4",e,t,Gi,0,1,1),Wi("cn1",e,t,Gi,-1,0,-1),Wi("cn2",e,t,Gi,1,0,-1),Wi("cn3",e,t,Gi,0,-1,-1),Wi("cn4",e,t,Gi,0,1,-1),t.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Wi(t,e,n,i,r,a,o){Vi.set(r,a,o).unproject(i);const s=e[t];if(void 0!==s){const t=n.getAttribute("position");for(let e=0,n=s.length;e<n;e++)t.setXYZ(s[e],Vi.x,Vi.y,Vi.z)}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=t);const ji=({focus:t=0,size:e=25,samples:n=10}={})=>{const i=wn.shadowmap_pars_fragment;return wn.shadowmap_pars_fragment=wn.shadowmap_pars_fragment.replace("#ifdef USE_SHADOWMAP",`#ifdef USE_SHADOWMAP\n\n #define PENUMBRA_FILTER_SIZE float(${e})\n #define RGB_NOISE_FUNCTION(uv) (randRGB(uv))\n vec3 randRGB(vec2 uv) {\n return vec3(\n fract(sin(dot(uv, vec2(12.75613, 38.12123))) * 13234.76575),\n fract(sin(dot(uv, vec2(19.45531, 58.46547))) * 43678.23431),\n fract(sin(dot(uv, vec2(23.67817, 78.23121))) * 93567.23423)\n );\n }\n \n vec3 lowPassRandRGB(vec2 uv) {\n // 3x3 convolution (average)\n // can be implemented as separable with an extra buffer for a total of 6 samples instead of 9\n vec3 result = vec3(0);\n result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, -1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, 0.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(-1.0, +1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, -1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, 0.0));\n result += RGB_NOISE_FUNCTION(uv + vec2( 0.0, +1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, -1.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, 0.0));\n result += RGB_NOISE_FUNCTION(uv + vec2(+1.0, +1.0));\n result *= 0.111111111; // 1.0 / 9.0\n return result;\n }\n vec3 highPassRandRGB(vec2 uv) {\n // by subtracting the low-pass signal from the original signal, we're being left with the high-pass signal\n // hp(x) = x - lp(x)\n return RGB_NOISE_FUNCTION(uv) - lowPassRandRGB(uv) + 0.5;\n }\n \n \n vec2 vogelDiskSample(int sampleIndex, int sampleCount, float angle) {\n const float goldenAngle = 2.399963f; // radians\n float r = sqrt(float(sampleIndex) + 0.5f) / sqrt(float(sampleCount));\n float theta = float(sampleIndex) * goldenAngle + angle;\n float sine = sin(theta);\n float cosine = cos(theta);\n return vec2(cosine, sine) * r;\n }\n float penumbraSize( const in float zReceiver, const in float zBlocker ) { // Parallel plane estimation\n return (zReceiver - zBlocker) / zBlocker;\n }\n float findBlocker(sampler2D shadowMap, vec2 uv, float compare, float angle) {\n float texelSize = 1.0 / float(textureSize(shadowMap, 0).x);\n float blockerDepthSum = float(${t});\n float blockers = 0.0;\n \n int j = 0;\n vec2 offset = vec2(0.);\n float depth = 0.;\n \n #pragma unroll_loop_start\n for(int i = 0; i < ${n}; i ++) {\n offset = (vogelDiskSample(j, ${n}, angle) * texelSize) * 2.0 * PENUMBRA_FILTER_SIZE;\n depth = unpackRGBAToDepth( texture2D( shadowMap, uv + offset));\n if (depth < compare) {\n blockerDepthSum += depth;\n blockers++;\n }\n j++;\n }\n #pragma unroll_loop_end\n \n if (blockers > 0.0) {\n return blockerDepthSum / blockers;\n }\n return -1.0;\n }\n \n float vogelFilter(sampler2D shadowMap, vec2 uv, float zReceiver, float filterRadius, float angle) {\n float texelSize = 1.0 / float(textureSize(shadowMap, 0).x);\n float shadow = 0.0f;\n int j = 0;\n vec2 vogelSample = vec2(0.0);\n vec2 offset = vec2(0.0);\n #pragma unroll_loop_start\n for (int i = 0; i < ${n}; i++) {\n vogelSample = vogelDiskSample(j, ${n}, angle) * texelSize;\n offset = vogelSample * (1.0 + filterRadius * float(${e}));\n shadow += step( zReceiver, unpackRGBAToDepth( texture2D( shadowMap, uv + offset ) ) );\n j++;\n }\n #pragma unroll_loop_end\n return shadow * 1.0 / ${n}.0;\n }\n \n float PCSS (sampler2D shadowMap, vec4 coords) {\n vec2 uv = coords.xy;\n float zReceiver = coords.z; // Assumed to be eye-space z in this code\n float angle = highPassRandRGB(gl_FragCoord.xy).r * PI2;\n float avgBlockerDepth = findBlocker(shadowMap, uv, zReceiver, angle);\n if (avgBlockerDepth == -1.0) {\n return 1.0;\n }\n float penumbraRatio = penumbraSize(zReceiver, avgBlockerDepth);\n return vogelFilter(shadowMap, uv, zReceiver, 1.25 * penumbraRatio, angle);\n }`).replace("#if defined( SHADOWMAP_TYPE_PCF )","\nreturn PCSS(shadowMap, shadowCoord);\n#if defined( SHADOWMAP_TYPE_PCF )"),(t,e,n)=>{wn.shadowmap_pars_fragment=i,function(t,e,n){e.traverse((e=>{e.material&&(Array.isArray(e.material)?e.material.forEach((e=>{t.properties.remove(e),e.dispose()})):(t.properties.remove(e.material),e.material.dispose()))})),t.info.programs.length=0,t.compile(e,n)}(t,e,n)}};function Xi(t,e,n,i){const r=Object.entries(t);class a extends pn{constructor(t){super({uniforms:r.reduce(((t,[e,n])=>({...t,...fn.clone({[e]:{value:n}})})),{}),vertexShader:e,fragmentShader:n});for(const[t]of r)Object.defineProperty(this,t,{get:()=>this.uniforms[t].value,set:e=>this.uniforms[t].value=e});Object.assign(this,t),null==i||i(this)}}return a.key=O.generateUUID(),a}const qi=new Tn(-1,1,1,-1,0,1);const Yi=new class extends je{constructor(){super(),this.setAttribute("position",new Oe([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new Oe([0,2,0,0,2,0],2))}};class Zi{constructor(t){this._mesh=new hn(Yi,t)}dispose(){this._mesh.geometry.dispose()}render(t){t.render(this._mesh,qi)}get material(){return this._mesh.material}set material(t){this._mesh.material=t}}function $i(t=1024,e=1024,n={samples:0,depth:!1}){var i=t,r=e,a=n,o=a.samples||0,l=a.depth,d=Object.assign({},a);delete d.samples,delete d.depth;var u=new ot(i,r,Object.assign({minFilter:s,magFilter:s,type:h},d));return l&&(u.depthTexture=new Cn(i,r,c)),u.samples=o,u}const Ji=t=>null==t?void 0:t.isVector3;function Qi(t=e){const n={value:new kt};return Object.assign(new Pi({side:t}),{viewMatrix:n,onBeforeCompile:t=>{t.uniforms.viewMatrix=n,t.fragmentShader="vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n }\n"+t.fragmentShader.replace("#include <normal_fragment_maps>","#include <normal_fragment_maps>\n normal = inverseTransformDirection( normal, viewMatrix );\n")}})}const Ki=Xi({causticsTexture:null,causticsTextureB:null,color:new Ae,lightProjMatrix:new kt,lightViewMatrix:new kt},"varying vec3 vWorldPosition; \n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vec4 worldPosition = modelMatrix * vec4(position, 1.);\n vWorldPosition = worldPosition.xyz;\n }",`varying vec3 vWorldPosition;\n uniform vec3 color;\n uniform sampler2D causticsTexture; \n uniform sampler2D causticsTextureB; \n uniform mat4 lightProjMatrix;\n uniform mat4 lightViewMatrix;\n void main() {\n // Apply caustics \n vec4 lightSpacePos = lightProjMatrix * lightViewMatrix * vec4(vWorldPosition, 1.0);\n lightSpacePos.xyz /= lightSpacePos.w;\n lightSpacePos.xyz = lightSpacePos.xyz * 0.5 + 0.5; \n vec3 front = texture2D(causticsTexture, lightSpacePos.xy).rgb;\n vec3 back = texture2D(causticsTextureB, lightSpacePos.xy).rgb;\n gl_FragColor = vec4((front + back) * color, 1.0);\n #include <tonemapping_fragment>\n #include <${parseInt(t.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>\n }`),tr=Xi({cameraMatrixWorld:new kt,cameraProjectionMatrixInv:new kt,normalTexture:null,depthTexture:null,lightDir:new lt(0,1,0),lightPlaneNormal:new lt(0,1,0),lightPlaneConstant:0,near:.1,far:100,modelMatrix:new kt,worldRadius:1/40,ior:1.1,bounces:0,resolution:1024,size:10,intensity:.5},"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }"," \n uniform mat4 cameraMatrixWorld;\n uniform mat4 cameraProjectionMatrixInv;\n uniform vec3 lightDir;\n uniform vec3 lightPlaneNormal;\n uniform float lightPlaneConstant;\n uniform float near;\n uniform float far;\n uniform float time;\n uniform float worldRadius;\n uniform float resolution;\n uniform float size;\n uniform float intensity;\n uniform float ior;\n precision highp isampler2D;\n precision highp usampler2D;\n uniform sampler2D normalTexture;\n uniform sampler2D depthTexture;\n uniform float bounces;\n varying vec2 vUv;\n vec3 WorldPosFromDepth(float depth, vec2 coord) {\n float z = depth * 2.0 - 1.0;\n vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);\n vec4 viewSpacePosition = cameraProjectionMatrixInv * clipSpacePosition;\n // Perspective division\n viewSpacePosition /= viewSpacePosition.w;\n vec4 worldSpacePosition = cameraMatrixWorld * viewSpacePosition;\n return worldSpacePosition.xyz;\n } \n float sdPlane( vec3 p, vec3 n, float h ) {\n // n must be normalized\n return dot(p,n) + h;\n }\n float planeIntersect( vec3 ro, vec3 rd, vec4 p ) {\n return -(dot(ro,p.xyz)+p.w)/dot(rd,p.xyz);\n }\n vec3 totalInternalReflection(vec3 ro, vec3 rd, vec3 pos, vec3 normal, float ior, out vec3 rayOrigin, out vec3 rayDirection) {\n rayOrigin = ro;\n rayDirection = rd;\n rayDirection = refract(rayDirection, normal, 1.0 / ior);\n rayOrigin = pos + rayDirection * 0.1;\n return rayDirection;\n }\n void main() {\n // Each sample consists of random offset in the x and y direction\n float caustic = 0.0;\n float causticTexelSize = (1.0 / resolution) * size * 2.0;\n float texelsNeeded = worldRadius / causticTexelSize;\n float sampleRadius = texelsNeeded / resolution;\n float sum = 0.0;\n if (texture2D(depthTexture, vUv).x == 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n vec2 offset1 = vec2(-0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset2 = vec2(-0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset3 = vec2(0.5, 0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 offset4 = vec2(0.5, -0.5);//vec2(rand() - 0.5, rand() - 0.5);\n vec2 uv1 = vUv + offset1 * sampleRadius;\n vec2 uv2 = vUv + offset2 * sampleRadius;\n vec2 uv3 = vUv + offset3 * sampleRadius;\n vec2 uv4 = vUv + offset4 * sampleRadius;\n vec3 normal1 = texture2D(normalTexture, uv1, -10.0).rgb * 2.0 - 1.0;\n vec3 normal2 = texture2D(normalTexture, uv2, -10.0).rgb * 2.0 - 1.0;\n vec3 normal3 = texture2D(normalTexture, uv3, -10.0).rgb * 2.0 - 1.0;\n vec3 normal4 = texture2D(normalTexture, uv4, -10.0).rgb * 2.0 - 1.0;\n float depth1 = texture2D(depthTexture, uv1, -10.0).x;\n float depth2 = texture2D(depthTexture, uv2, -10.0).x;\n float depth3 = texture2D(depthTexture, uv3, -10.0).x;\n float depth4 = texture2D(depthTexture, uv4, -10.0).x;\n // Sanity check the depths\n if (depth1 == 1.0 || depth2 == 1.0 || depth3 == 1.0 || depth4 == 1.0) {\n gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n vec3 pos1 = WorldPosFromDepth(depth1, uv1);\n vec3 pos2 = WorldPosFromDepth(depth2, uv2);\n vec3 pos3 = WorldPosFromDepth(depth3, uv3);\n vec3 pos4 = WorldPosFromDepth(depth4, uv4);\n vec3 originPos1 = WorldPosFromDepth(0.0, uv1);\n vec3 originPos2 = WorldPosFromDepth(0.0, uv2);\n vec3 originPos3 = WorldPosFromDepth(0.0, uv3);\n vec3 originPos4 = WorldPosFromDepth(0.0, uv4);\n vec3 endPos1, endPos2, endPos3, endPos4;\n vec3 endDir1, endDir2, endDir3, endDir4;\n totalInternalReflection(originPos1, lightDir, pos1, normal1, ior, endPos1, endDir1);\n totalInternalReflection(originPos2, lightDir, pos2, normal2, ior, endPos2, endDir2);\n totalInternalReflection(originPos3, lightDir, pos3, normal3, ior, endPos3, endDir3);\n totalInternalReflection(originPos4, lightDir, pos4, normal4, ior, endPos4, endDir4);\n float lightPosArea = length(cross(originPos2 - originPos1, originPos3 - originPos1)) + length(cross(originPos3 - originPos1, originPos4 - originPos1));\n float t1 = planeIntersect(endPos1, endDir1, vec4(lightPlaneNormal, lightPlaneConstant));\n float t2 = planeIntersect(endPos2, endDir2, vec4(lightPlaneNormal, lightPlaneConstant));\n float t3 = planeIntersect(endPos3, endDir3, vec4(lightPlaneNormal, lightPlaneConstant));\n float t4 = planeIntersect(endPos4, endDir4, vec4(lightPlaneNormal, lightPlaneConstant));\n vec3 finalPos1 = endPos1 + endDir1 * t1;\n vec3 finalPos2 = endPos2 + endDir2 * t2;\n vec3 finalPos3 = endPos3 + endDir3 * t3;\n vec3 finalPos4 = endPos4 + endDir4 * t4;\n float finalArea = length(cross(finalPos2 - finalPos1, finalPos3 - finalPos1)) + length(cross(finalPos3 - finalPos1, finalPos4 - finalPos1));\n caustic += intensity * (lightPosArea / finalArea);\n // Calculate the area of the triangle in light spaces\n gl_FragColor = vec4(vec3(max(caustic, 0.0)), 1.0);\n }"),er={depth:!0,minFilter:s,magFilter:s,type:1009},nr={minFilter:1008,magFilter:s,type:c,generateMipmaps:!0};function ir(t){const e=Qi(),i=Qi(n),r=new tr,a=new Zi(r);let o=0;const s=new lt,l=new Mn,c=new kt,h=new _n,d=new lt,u=new lt,f=new dt,p=new lt,m=[],g=[],v=[],x=[],_=new lt;for(let t=0;t<8;t++)m.push(new lt),g.push(new lt),v.push(new lt),x.push(new lt);return function(n){const{params:y,helper:S,camera:M,plane:b,normalTarget:w,normalTargetB:T,causticsTarget:C,causticsTargetB:A,scene:D,group:U}=t();if(y.frames===1/0||y.frames&&o++<y.frames){var E;Ji(y.lightSource)?d.copy(y.lightSource).normalize():y.lightSource&&d.copy(U.worldToLocal(y.lightSource.getWorldPosition(s)).normalize()),u.copy(d).multiplyScalar(-1),null==(E=D.parent)||E.matrixWorld.identity(),f.setFromObject(D,!0),m[0].set(f.min.x,f.min.y,f.min.z),m[1].set(f.min.x,f.min.y,f.max.z),m[2].set(f.min.x,f.max.y,f.min.z),m[3].set(f.min.x,f.max.y,f.max.z),m[4].set(f.max.x,f.min.y,f.min.z),m[5].set(f.max.x,f.min.y,f.max.z),m[6].set(f.max.x,f.max.y,f.min.z),m[7].set(f.max.x,f.max.y,f.max.z);for(let t=0;t<8;t++)g[t].copy(m[t]);f.getCenter(p),m.map((t=>t.sub(p)));const t=h.set(u,0);m.map(((e,n)=>t.projectPoint(e,v[n])));const o=v.reduce(((t,e)=>t.add(e)),s.set(0,0,0)).divideScalar(v.length),P=v.map((t=>t.distanceTo(o))).reduce(((t,e)=>Math.max(t,e))),I=m.map((t=>t.dot(d))).reduce(((t,e)=>Math.max(t,e)));M.position.copy(_.copy(d).multiplyScalar(I).add(p)),M.lookAt(D.localToWorld(p));const R=c.lookAt(M.position,p,s.set(0,1,0));if(M.left=-P,M.right=P,M.top=P,M.bottom=-P,y.near&&(M.near=y.near),y.far)M.far=y.far;else{const t=s.set(0,P,0).applyMatrix4(R),e=(M.position.y+t.y)/d.y;M.far=e}M.updateProjectionMatrix(),M.updateMatrixWorld();const L=g.map(((t,e)=>t.add(x[e].copy(d).multiplyScalar(-t.y/d.y)))),N=L.reduce(((t,e)=>t.add(e)),s.set(0,0,0)).divideScalar(L.length),z=2*L.map((t=>Math.hypot(t.x-N.x,t.z-N.z))).reduce(((t,e)=>Math.max(t,e)));b.scale.setScalar(z),b.position.copy(N),null!=S&&S.parent&&S.update(),i.viewMatrix.value=e.viewMatrix.value=M.matrixWorldInverse;const O=l.setFromProjectionMatrix(c.multiplyMatrices(M.projectionMatrix,M.matrixWorldInverse)).planes[4];r.cameraMatrixWorld=M.matrixWorld,r.cameraProjectionMatrixInv=M.projectionMatrixInverse,r.lightDir=u,r.lightPlaneNormal=O.normal,r.lightPlaneConstant=O.constant,r.near=M.near,r.far=M.far,y.resolution&&(r.resolution=y.resolution),r.size=P,y.intensity&&(r.intensity=y.intensity),y.worldRadius&&(r.worldRadius=y.worldRadius),D.visible=!0,n.setRenderTarget(w),n.clear(),D.overrideMaterial=e,n.render(D,M),n.setRenderTarget(T),n.clear(),y.backside&&(D.overrideMaterial=i,n.render(D,M)),D.overrideMaterial=null,y.ior&&(r.ior=y.ior),b.material.lightProjMatrix=M.projectionMatrix,b.material.lightViewMatrix=M.matrixWorldInverse,r.normalTexture=w.texture,r.depthTexture=w.depthTexture,n.setRenderTarget(C),n.clear(),a.render(n),y.backsideIOR&&(r.ior=y.backsideIOR),r.normalTexture=T.texture,r.depthTexture=T.depthTexture,n.setRenderTarget(A),n.clear(),y.backside&&a.render(n),n.setRenderTarget(null),y.causticsOnly&&(D.visible=!1)}}}const rr=(t,{frames:e=1,causticsOnly:n=!1,ior:i=1.1,backside:r=!1,backsideIOR:a=1.1,worldRadius:o=.3125,color:s=new Ae("white"),intensity:l=.05,resolution:c=2024,lightSource:h=new lt(1,1,1),near:d=.1,far:u=0}={})=>{const f={frames:e,ior:i,color:s,causticsOnly:n,backside:r,backsideIOR:a,worldRadius:o,intensity:l,resolution:c,lightSource:h,near:d,far:u},p=new Un;p.name="caustics_group";const m=new Tn,g=new En;g.name="caustics_scene";const v=t,x=new Hi(m);x.name="caustics_helper";const _=f.resolution,y=$i(_,_,er),S=$i(_,_,er),M=$i(_,_,nr),b=$i(_,_,nr),w=new hn(new bn(1,1),new Ki({transparent:!0,color:f.color,causticsTexture:M.texture,causticsTextureB:b.texture,blending:5,blendSrc:201,blendDst:204,depthWrite:!1}));w.name="caustics_plane",w.rotation.x=-Math.PI/2,w.renderOrder=2,p.add(g,w),p.updateWorldMatrix(!1,!0);const T=ir((()=>({params:f,scene:g,group:p,camera:m,plane:w,normalTarget:y,normalTargetB:S,causticsTarget:M,causticsTargetB:b,helper:x})));return{scene:g,group:p,helper:x,params:f,update:T.bind({},v),normalTarget:y,normalTargetB:S,causticsTarget:M,causticsTargetB:b}},ar=Xi({},"void main() { }","void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); discard; }");const or=Xi({color:new Ae(0),blend:2,alphaTest:.75,opacity:0,map:null},"varying vec2 vUv;\n void main() {\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(position, 1.);\n vUv = uv;\n }",`varying vec2 vUv;\n uniform sampler2D map;\n uniform vec3 color;\n uniform float opacity;\n uniform float alphaTest;\n uniform float blend;\n void main() {\n vec4 sampledDiffuseColor = texture2D(map, vUv);\n gl_FragColor = vec4(color * sampledDiffuseColor.r * blend, max(0.0, (1.0 - (sampledDiffuseColor.r + sampledDiffuseColor.g + sampledDiffuseColor.b) / alphaTest)) * opacity);\n #include <tonemapping_fragment>\n #include <${parseInt(t.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>\n }`);class sr{constructor(t,e,n=1024){this.renderer=t,this.res=n,this.scene=e,this.buffer1Active=!1,this.lights=[],this.meshes=[],this.object=null,this.clearColor=new Ae,this.clearAlpha=0;const i=/(Android|iPad|iPhone|iPod)/g.test(navigator.userAgent)?h:c;this.progressiveLightMap1=new ot(this.res,this.res,{type:i}),this.progressiveLightMap2=new ot(this.res,this.res,{type:i}),this.discardMat=new ar,this.targetMat=new Ii({fog:!1}),this.previousShadowMap={value:this.progressiveLightMap1.texture},this.averagingWindow={value:100},this.targetMat.onBeforeCompile=t=>{t.vertexShader="varying vec2 vUv;\n"+t.vertexShader.slice(0,-1)+"vUv = uv; gl_Position = vec4((uv - 0.5) * 2.0, 1.0, 1.0); }";const e=t.fragmentShader.indexOf("void main() {");t.fragmentShader="varying vec2 vUv;\n"+t.fragmentShader.slice(0,e)+"uniform sampler2D previousShadowMap;\n\tuniform float averagingWindow;\n"+t.fragmentShader.slice(e-1,-1)+"\nvec3 texelOld = texture2D(previousShadowMap, vUv).rgb;\n gl_FragColor.rgb = mix(texelOld, gl_FragColor.rgb, 1.0/ averagingWindow);\n }",t.uniforms.previousShadowMap=this.previousShadowMap,t.uniforms.averagingWindow=this.averagingWindow}}clear(){this.renderer.getClearColor(this.clearColor),this.clearAlpha=this.renderer.getClearAlpha(),this.renderer.setClearColor("black",1),this.renderer.setRenderTarget(this.progressiveLightMap1),this.renderer.clear(),this.renderer.setRenderTarget(this.progressiveLightMap2),this.renderer.clear(),this.renderer.setRenderTarget(null),this.renderer.setClearColor(this.clearColor,this.clearAlpha),this.lights=[],this.meshes=[],this.scene.traverse((t=>{!function(t){return!!t.geometry}(t)?function(t){return t.isLight}(t)&&this.lights.push({object:t,intensity:t.intensity}):this.meshes.push({object:t,material:t.material})}))}prepare(){this.lights.forEach((t=>t.object.intensity=0)),this.meshes.forEach((t=>t.object.material=this.discardMat))}finish(){this.lights.forEach((t=>t.object.intensity=t.intensity)),this.meshes.forEach((t=>t.object.material=t.material))}configure(t){this.object=t}update(t,e=100){if(!this.object)return;this.averagingWindow.value=e,this.object.material=this.targetMat;const n=this.buffer1Active?this.progressiveLightMap1:this.progressiveLightMap2,i=this.buffer1Active?this.progressiveLightMap2:this.progressiveLightMap1,r=this.scene.background;this.scene.background=null,this.renderer.setRenderTarget(n),this.previousShadowMap.value=i.texture,this.buffer1Active=!this.buffer1Active,this.renderer.render(this.scene,t),this.renderer.setRenderTarget(null),this.scene.background=r}}const lr=(t,e)=>{"updateRanges"in t?t.updateRanges[0]=e:t.updateRange=e},cr="https://rawcdn.githack.com/pmndrs/drei-assets/9225a9f1fbd449d9411125c2f419b843d0308c9f/cloud.png",hr=new kt,dr=new lt,ur=new st,fr=new lt,pr=new st,mr=new lt,gr=e=>class extends e{constructor(){super();const e=parseInt(t.replace(/\D+/g,""))>=154?"opaque_fragment":"output_fragment";this.onBeforeCompile=t=>{t.vertexShader="attribute float cloudOpacity;\n varying float vOpacity;\n "+t.vertexShader.replace("#include <fog_vertex>","#include <fog_vertex>\n vOpacity = cloudOpacity;\n "),t.fragmentShader="varying float vOpacity;\n "+t.fragmentShader.replace(`#include <${e}>`,`#include <${e}>\n gl_FragColor = vec4(outgoingLight, diffuseColor.a * vOpacity);\n `)}}};class vr extends Un{constructor({limit:t=200,range:e,material:n=Ii,texture:i,frustumCulled:r=!0}={}){super(),this.name="Clouds",this.ref=this;const a=new bn(1,1),o=new Float32Array(Array.from({length:t},(()=>1))),s=new Float32Array(Array.from({length:t},(()=>[1,1,1])).flat()),l=new si(o,1);l.setUsage(b),a.setAttribute("cloudOpacity",l);const c=new(gr(n));c.map=i,c.transparent=!0,c.depthWrite=!1,c.needsUpdate=!0,this.cloudMaterial=c,this.instance=new mi(a,c,t);const h=this.instance;h.matrixAutoUpdate=!1,h.frustumCulled=r,h.instanceColor=new si(s,3),h.instanceColor.setUsage(b),this.add(h);const d=[],u=()=>{const t=d.length;let e=0;for(let t=0;t<this.ref.children.length;t++){const n=this.ref.children[t];n.cloudStateArray&&(e+=n.cloudStateArray.length)}if(t===e)return d;d.length=0;for(let t=0;t<this.ref.children.length;t++){const e=this.ref.children[t];e.cloudStateArray&&d.push(...e.cloudStateArray)}return f(),d},f=()=>{const n=Math.min(t,void 0!==e?e:t,d.length);h.count=n,lr(h.instanceMatrix,{offset:0,count:16*n}),h.instanceColor&&lr(h.instanceColor,{offset:0,count:3*n}),lr(h.geometry.attributes.cloudOpacity,{offset:0,count:n})};let p,m=0,g=0;const v=new st,x=new lt(0,0,1),_=new lt;this.update=(t,e,n)=>{m=e,hr.copy(h.matrixWorld).invert(),t.matrixWorld.decompose(fr,pr,mr);const i=u();for(g=0;g<i.length;g++)p=i[g],p.ref.matrixWorld.decompose(dr,ur,mr),dr.add(_.copy(p.position).applyQuaternion(ur).multiply(mr)),ur.copy(pr).multiply(v.setFromAxisAngle(x,p.rotation+=n*p.rotationFactor)),mr.multiplyScalar(p.volume+(1+Math.sin(m*p.density*p.speed))/2*p.growth),p.matrix.compose(dr,ur,mr).premultiply(hr),p.dist=dr.distanceTo(fr);for(i.sort(((t,e)=>e.dist-t.dist)),g=0;g<i.length;g++)p=i[g],o[g]=p.opacity*(p.dist<p.fade-1?p.dist/p.fade:1),h.setMatrixAt(g,p.matrix),h.setColorAt(g,p.color);h.geometry.attributes.cloudOpacity.needsUpdate=!0,h.instanceMatrix.needsUpdate=!0,h.instanceColor&&(h.instanceColor.needsUpdate=!0)}}}let xr=0;class _r extends Un{constructor({opacity:t=1,speed:e=0,bounds:n=(new lt).fromArray([5,1,1]),segments:i=20,color:r=new Ae("#ffffff"),fade:a=10,volume:o=6,smallestVolume:s=.25,distribute:l=null,growth:c=4,concentrate:h="inside",seed:d=Math.random()}={}){super(),this.name="cloud_"+xr++,this.seed=d,this.segments=i,this.bounds=n,this.concentrate=h,this.volume=o,this.smallestVolume=s,this.distribute=l,this.growth=c,this.speed=e,this.fade=a,this.opacity=t,this.color=r,this.ref=this,this.cloudStateArray=[],this.updateCloud()}updateCloudStateArray(){if(this.cloudStateArray.length===this.segments)return;const{segments:t,uuid:e}=this;if(this.cloudStateArray.length>this.segments)this.cloudStateArray.splice(0,this.cloudStateArray.length-this.segments);else for(let n=this.cloudStateArray.length;n<t;n++)this.cloudStateArray.push({segments:t,bounds:new lt(1,1,1),position:new lt,uuid:e,index:n,ref:this,dist:0,matrix:new kt,volume:0,length:0,speed:0,growth:0,opacity:1,fade:0,density:0,rotation:n*(Math.PI/t),rotationFactor:0,color:new Ae})}updateCloud(){const{volume:t,color:e,speed:n,growth:i,opacity:r,fade:a,bounds:o,seed:s,cloudStateArray:l,distribute:c,segments:h,concentrate:d,smallestVolume:u}=this;this.updateCloudStateArray();let f=0;function p(){const t=1e4*Math.sin(s+f);return f++,t-Math.floor(t)}l.forEach(((s,l)=>{s.segments=h,s.volume=t,s.color=e,s.speed=n,s.growth=i,s.opacity=r,s.fade=a,s.bounds.copy(o),s.density=Math.max(.5,p()),s.rotationFactor=Math.max(.2,.5*p())*n;const f=null==c?void 0:c(s,l);var m;(f||h>1)&&s.position.copy(s.bounds).multiply(null!==(m=null==f?void 0:f.point)&&void 0!==m?m:{x:2*p()-1,y:2*p()-1,z:2*p()-1});const g=Math.abs(s.position.x),v=Math.abs(s.position.y),x=Math.abs(s.position.z),_=Math.max(g,v,x);s.length=1,g===_&&(s.length-=g/s.bounds.x),v===_&&(s.length-=v/s.bounds.y),x===_&&(s.length-=x/s.bounds.z),s.volume=(void 0!==(null==f?void 0:f.volume)?f.volume:Math.max(Math.max(0,u),"random"===d?p():"inside"===d?s.length:1-s.length))*t}))}}const yr=({startFrame:t,endFrame:e,fps:n,frameName:i,textureDataURL:a,textureImageURL:o,loop:s,numberOfFrames:l,autoPlay:c,animationNames:h,onStart:d,onEnd:u,onLoopEnd:f,onFrame:p,play:m,pause:g,flipX:v,alphaTest:x,asSprite:_})=>{let y={frames:[],meta:{version:"1.0",size:{w:1,h:1},scale:"1"}},S=!1,M=new it;const b=new Ln({toneMapped:!1,transparent:!0,map:M,alphaTest:null!=x?x:0}),w=new Pe({toneMapped:!1,side:2,map:M,transparent:!0,alphaTest:null!=x?x:0}),T=new Yn(b),C=new hn(new bn(1,1),w);let A=b,D=T;const U=new Un;U.add(D);let E=window.performance.now(),P=t||0,I=i||"";const R=1e3/(n||30),L=new lt(1,1,1),N=t=>{L.copy(t)},z=v?-1:1;let O=null==_||_;O=O,O?(A=b,D=T,U.add(T),U.remove(C)):(A=w,D=C,U.remove(T),U.add(C));const k=(t,e)=>{const n=e/t;return D.scale.set(1,n,1),D.scale},F=(t,e)=>{if(null===t){if(e&&l){const t=e.image.width,n=e.image.height,i=t/l,r=n;if(y={frames:[],meta:{version:"1.0",size:{w:t,h:n},scale:"1"}},parseInt(i.toString(),10)===i)for(let t=0;t<l;t++)y.frames.push({frame:{x:t*i,y:0,w:i,h:r},rotated:!1,trimmed:!1,spriteSourceSize:{x:0,y:0,w:i,h:r},sourceSize:{w:i,h:n}})}}else if(e){y=t,y.frames=Array.isArray(t.frames)?t.frames:B();const{w:n,h:i}=G(t.frames).sourceSize,r=k(n,i);N(r),A&&(A.map=e)}var n;e.premultiplyAlpha=!1,M=n=e,A&&(A.map=n),V()},B=()=>{const t={},e=y,n=h;if(n)for(let i=0;i<n.length;i++){t[n[i]]=[];for(const r in e.frames){const a=e.frames[r],o=a.frame,s=o.x,l=o.y,c=o.w,h=o.h,d=a.sourceSize.w,u=a.sourceSize.h;"string"==typeof r&&-1!==r.toLowerCase().indexOf(n[i].toLowerCase())&&t[n[i]].push({x:s,y:l,w:c,h:h,frame:o,sourceSize:{w:d,h:u}})}}return t},V=()=>{if(!y||!A.map)return;const{meta:{size:t},frames:e}=y,{w:n,h:a}=Array.isArray(e)?e[0].sourceSize:i&&e[i]?e[i][0].sourceSize:{w:0,h:0};A.map.wrapS=A.map.wrapT=r,A.map.center.set(0,0),A.map.repeat.set(1*z/(t.w/n),1/(t.h/a));const o=1/((t.h-1)/a);A.map.offset.x=0,A.map.offset.y=1-o,d&&d({currentFrameName:i,currentFrame:P})},G=t=>{if(Array.isArray(t))return t[0];if("object"==typeof t&&null!==t){return t[Object.keys(t)[0]][0]}return{w:0,h:0}};return{group:U,init:async()=>{if(a&&o)await async function(t,e,n){const i=new ki,r=fetch(t).then((t=>t.json())),a=new Promise((t=>{i.load(e,t)}));await Promise.all([r,a]).then((t=>{n(t[0],t[1])}))}(a,o,F);else if(o){const t=new ki,e=await t.loadAsync(o);F(null,e)}},update:()=>{var n,r;null!=(n=y)&&n.frames&&null!=(r=A)&&r.map&&(g||S||!c&&!m||((()=>{if(!y||!A.map)return;const n=window.performance.now(),r=n-E,{meta:{size:a},frames:o}=y,{w:l,h:c}=G(o).sourceSize,h=Array.isArray(o)?o:i?o[i]:[];let d=0,p=0;const m=e||h.length-1;if(P>m&&(P=s&&null!=t?t:0,s?null==f||f({currentFrameName:i,currentFrame:P}):(null==u||u({currentFrameName:i,currentFrame:P}),S=!0),!s))return;if(r<=R)return;E=n-r%R,k(l,c);const g=(a.w-1)/l,v=(a.h-1)/c,{frame:{x:x,y:_},sourceSize:{w:M,h:b}}=h[P],w=1/g,T=1/v;d=z>0?w*(x/M):w*(x/M)-A.map.repeat.x,p=Math.abs(1-T)-T*(_/b),A.map.offset.x=d,A.map.offset.y=p,P+=1})(),p&&p({currentFrameName:I,currentFrame:P})))},playAnimation:()=>{m=!0,g=!1},pauseAnimation:()=>{g=!0},setFrameName:t=>{I!==(i=t)&&i&&(P=0,I=i)}}};const Sr=Xi({screenspace:!1,color:new Ae("black"),opacity:1,thickness:.05,size:new k},"\n #include <common>\n #include <morphtarget_pars_vertex>\n #include <skinning_pars_vertex>\n uniform float thickness;\n uniform float screenspace;\n uniform vec2 size;\n void main() {\n #if defined (USE_SKINNING)\n\t #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n\t #include <morphtarget_vertex>\n\t #include <skinning_vertex>\n #include <project_vertex>\n vec4 tNormal = vec4(normal, 0.0);\n vec4 tPosition = vec4(transformed, 1.0);\n #ifdef USE_INSTANCING\n tNormal = instanceMatrix * tNormal;\n tPosition = instanceMatrix * tPosition;\n #endif\n if (screenspace == 0.0) {\n vec3 newPosition = tPosition.xyz + tNormal.xyz * thickness;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0); \n } else {\n vec4 clipPosition = projectionMatrix * modelViewMatrix * tPosition;\n vec4 clipNormal = projectionMatrix * modelViewMatrix * tNormal;\n vec2 offset = normalize(clipNormal.xy) * thickness / size * clipPosition.w * 2.0;\n clipPosition.xy += offset;\n gl_Position = clipPosition;\n }\n }",`\n uniform vec3 color;\n uniform float opacity;\n void main(){\n gl_FragColor = vec4(color, opacity);\n #include <tonemapping_fragment>\n #include <${parseInt(t.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>\n }`);function Mr({color:t=new Ae("black"),opacity:e=1,transparent:i=!1,screenspace:r=!1,toneMapped:a=!0,polygonOffset:o=!1,polygonOffsetFactor:s=0,renderOrder:l=0,thickness:c=.05,angle:h=Math.PI,gl:d}){const u=new Un;let f={color:t,opacity:e,transparent:i,screenspace:r,toneMapped:a,polygonOffset:o,polygonOffsetFactor:s,renderOrder:l,thickness:c,angle:h};function p(t){const e=u.parent;if(u.clear(),e&&e.geometry){let i;const r=new Sr({side:n});e.skeleton?(i=new ai,i.material=r,i.bind(e.skeleton,e.bindMatrix),u.add(i)):e.isInstancedMesh?(i=new mi(e.geometry,r,e.count),i.instanceMatrix=e.instanceMatrix,u.add(i)):(i=new hn,i.material=r,u.add(i)),i.geometry=t?function(t,e=Math.PI/3){const n=Math.cos(e),i=100*(1+1e-10),r=[new lt,new lt,new lt],a=new lt,o=new lt,s=new lt,l=new lt;function c(t){return`${~~(t.x*i)},${~~(t.y*i)},${~~(t.z*i)}`}const h=t.index?t.toNonIndexed():t,d=h.attributes.position,u={};for(let t=0,e=d.count/3;t<e;t++){const e=3*t,n=r[0].fromBufferAttribute(d,e+0),i=r[1].fromBufferAttribute(d,e+1),s=r[2].fromBufferAttribute(d,e+2);a.subVectors(s,i),o.subVectors(n,i);const l=(new lt).crossVectors(a,o).normalize();for(let t=0;t<3;t++){const e=c(r[t]);e in u||(u[e]=[]),u[e].push(l)}}const f=new Float32Array(3*d.count),p=new Le(f,3,!1);for(let t=0,e=d.count/3;t<e;t++){const e=3*t,i=r[0].fromBufferAttribute(d,e+0),h=r[1].fromBufferAttribute(d,e+1),f=r[2].fromBufferAttribute(d,e+2);a.subVectors(f,h),o.subVectors(i,h),s.crossVectors(a,o).normalize();for(let t=0;t<3;t++){const i=u[c(r[t])];l.set(0,0,0);for(let t=0,e=i.length;t<e;t++){const e=i[t];s.dot(e)>n&&l.add(e)}l.normalize(),p.setXYZ(e+t,l.x,l.y,l.z)}}return h.setAttribute("normal",p),h}(e.geometry,t):e.geometry}}function m(t){f={...f,...t};const e=u.children[0];if(e){const{transparent:t,thickness:n,color:i,opacity:r,screenspace:a,toneMapped:o,polygonOffset:s,polygonOffsetFactor:l,renderOrder:c}=f,h=new k;!d&&f.screenspace&&console.warn('Outlines: "screenspace" requires a WebGLRenderer instance to calculate the outline size'),d&&d.getSize(h),Object.assign(e.material,{transparent:t,thickness:n,color:i,opacity:r,size:h,screenspace:a,toneMapped:o,polygonOffset:s,polygonOffsetFactor:l}),void 0!==c&&(e.renderOrder=c)}}return{group:u,updateProps(t){var e;const n=null!==(e=t.angle)&&void 0!==e?e:f.angle;n!==f.angle&&p(n),m(t)},generate(){p(f.angle),m(f)}}}const br=({follow:t=!0,lockX:e=!1,lockY:n=!1,lockZ:i=!1}={})=>{const r=new Un,a={follow:t,lockX:e,lockY:n,lockZ:i};return{group:r,update:function(t){const{follow:e,lockX:n,lockY:i,lockZ:o}=a;if(!e)return;const s=r.rotation.clone();t.getWorldQuaternion(r.quaternion),n&&(r.rotation.x=s.x),i&&(r.rotation.y=s.y),o&&(r.rotation.z=s.z)},updateProps(t){Object.assign(a,t)}}};function wr(){var t=Object.create(null);function e(i,r){var a=i.id,o=i.name,s=i.dependencies;void 0===s&&(s=[]);var l=i.init;void 0===l&&(l=function(){});var c=i.getTransferables;if(void 0===c&&(c=null),!t[a])try{s=s.map((function(n){return n&&n.isWorkerModule&&(e(n,(function(t){if(t instanceof Error)throw t})),n=t[n.id].value),n})),l=n("<"+o+">.init",l),c&&(c=n("<"+o+">.getTransferables",c));var h=null;"function"==typeof l?h=l.apply(void 0,s):console.error("worker module init function failed to rehydrate"),t[a]={id:a,value:h,getTransferables:c},r(h)}catch(t){t&&t.noLog||console.error(t),r(t)}}function n(t,e){var n=void 0;self.troikaDefine=function(t){return n=t};var i=URL.createObjectURL(new Blob(["/** "+t.replace(/\*/g,"")+" **/\n\ntroikaDefine(\n"+e+"\n)"],{type:"application/javascript"}));try{importScripts(i)}catch(t){console.error(t)}return URL.revokeObjectURL(i),delete self.troikaDefine,n}self.addEventListener("message",(function(n){var i=n.data,r=i.messageId,a=i.action,o=i.data;try{"registerModule"===a&&e(o,(function(t){t instanceof Error?postMessage({messageId:r,success:!1,error:t.message}):postMessage({messageId:r,success:!0,result:{isCallable:"function"==typeof t}})})),"callModule"===a&&function(e,n){var i,r=e.id,a=e.args;t[r]&&"function"==typeof t[r].value||n(new Error("Worker module "+r+": not found or its 'init' did not return a function"));try{var o=(i=t[r]).value.apply(i,a);o&&"function"==typeof o.then?o.then(s,(function(t){return n(t instanceof Error?t:new Error(""+t))})):s(o)}catch(t){n(t)}function s(e){try{var i=t[r].getTransferables&&t[r].getTransferables(e);i&&Array.isArray(i)&&i.length||(i=void 0),n(e,i)}catch(t){console.error(t),n(t)}}}(o,(function(t,e){t instanceof Error?postMessage({messageId:r,success:!1,error:t.message}):postMessage({messageId:r,success:!0,result:t},e||void 0)}))}catch(t){postMessage({messageId:r,success:!1,error:t.stack})}}))}var Tr=function(){var t=!1;if("undefined"!=typeof window&&void 0!==window.document)try{new Worker(URL.createObjectURL(new Blob([""],{type:"application/javascript"}))).terminate(),t=!0}catch(t){"undefined"!=typeof process&&"test"===process.env.NODE_ENV||console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: ["+t.message+"]")}return Tr=function(){return t},t},Cr=0,Ar=0,Dr=!1,Ur=Object.create(null),Er=Object.create(null),Pr=Object.create(null);function Ir(t){if(!(t&&"function"==typeof t.init||Dr))throw new Error("requires `options.init` function");var e=t.dependencies,n=t.init,i=t.getTransferables,r=t.workerId;if(!Tr())return function(t){var e=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];return e._getInitResult().then((function(e){if("function"==typeof e)return e.apply(void 0,t);throw new Error("Worker module function was called but `init` did not return a callable function")}))};return e._getInitResult=function(){var n=t.dependencies,i=t.init;n=Array.isArray(n)?n.map((function(t){return t&&t._getInitResult?t._getInitResult():t})):[];var r=Promise.all(n).then((function(t){return i.apply(null,t)}));return e._getInitResult=function(){return r},r},e}(t);null==r&&(r="#default");var a="workerModule"+ ++Cr,o=t.name||a,s=null;function l(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];if(!s){s=Lr(r,"registerModule",l.workerModuleData);var n=function(){s=null,Er[r].delete(n)};(Er[r]||(Er[r]=new Set)).add(n)}return s.then((function(e){if(e.isCallable)return Lr(r,"callModule",{id:a,args:t});throw new Error("Worker module function was called but `init` did not return a callable function")}))}return e=e&&e.map((function(t){return"function"!=typeof t||t.workerModuleData||(Dr=!0,t=Ir({workerId:r,name:"<"+o+"> function dependency: "+t.name,init:"function(){return (\n"+Rr(t)+"\n)}"}),Dr=!1),t&&t.workerModuleData&&(t=t.workerModuleData),t})),l.workerModuleData={isWorkerModule:!0,id:a,name:o,dependencies:e,init:Rr(n),getTransferables:i&&Rr(i)},l}function Rr(t){var e=t.toString();return!/^function/.test(e)&&/^\w+\s*\(/.test(e)&&(e="function "+e),e}function Lr(t,e,n){return new Promise((function(i,r){var a=++Ar;Pr[a]=function(t){t.success?i(t.result):r(new Error("Error in worker "+e+" call: "+t.error))},function(t){var e=Ur[t];if(!e){var n=Rr(wr);(e=Ur[t]=new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: "+t.replace(/\*/g,"")+" **/\n\n;("+n+")()"],{type:"application/javascript"})))).onmessage=function(t){var e=t.data,n=e.messageId,i=Pr[n];if(!i)throw new Error("WorkerModule response with empty or unknown messageId");delete Pr[n],i(e)}}return e}(t).postMessage({messageId:a,action:e,data:n})}))}function Nr(){var t=function(t){function e(t,e,n,i,r,a,o,s,l,c){var h=1-l;c.x=h*h*h*t+3*h*h*l*n+3*h*l*l*r+l*l*l*o,c.y=h*h*h*e+3*h*h*l*i+3*h*l*l*a+l*l*l*s}function n(t,e){for(var n,i,r,a,o,s=/([MLQCZ])([^MLQCZ]*)/g;n=s.exec(t);){var l=n[2].replace(/^\s*|\s*$/g,"").split(/[,\s]+/).map((function(t){return parseFloat(t)}));switch(n[1]){case"M":a=i=l[0],o=r=l[1];break;case"L":l[0]===a&&l[1]===o||e("L",a,o,a=l[0],o=l[1]);break;case"Q":e("Q",a,o,a=l[2],o=l[3],l[0],l[1]);break;case"C":e("C",a,o,a=l[4],o=l[5],l[0],l[1],l[2],l[3]);break;case"Z":a===i&&o===r||e("L",a,o,i,r)}}}function i(t,i,r){void 0===r&&(r=16);var a={x:0,y:0};n(t,(function(t,n,o,s,l,c,h,d,u){switch(t){case"L":i(n,o,s,l);break;case"Q":for(var f=n,p=o,m=1;m<r;m++)_=o,y=h,S=l,w=void 0,w=1-(M=m/(r-1)),(b=a).x=w*w*n+2*w*M*c+M*M*s,b.y=w*w*_+2*w*M*y+M*M*S,i(f,p,a.x,a.y),f=a.x,p=a.y;break;case"C":for(var g=n,v=o,x=1;x<r;x++)e(n,o,c,h,d,u,s,l,x/(r-1),a),i(g,v,a.x,a.y),g=a.x,v=a.y}var _,y,S,M,b,w}))}var r="precision highp float;attribute vec2 aUV;varying vec2 vUV;void main(){vUV=aUV;gl_Position=vec4(mix(vec2(-1.0),vec2(1.0),aUV),0.0,1.0);}",a="precision highp float;uniform sampler2D tex;varying vec2 vUV;void main(){gl_FragColor=texture2D(tex,vUV);}",o=new WeakMap,s={premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1,depth:!1};function l(t,e){var n=t.getContext?t.getContext("webgl",s):t,i=o.get(n);if(!i){var r="undefined"!=typeof WebGL2RenderingContext&&n instanceof WebGL2RenderingContext,a={},l={},c={},h=-1,d=[];function u(t){var e=a[t];if(!e&&!(e=a[t]=n.getExtension(t)))throw new Error(t+" not supported");return e}function f(t,e){var i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}function p(){a={},l={},c={},h=-1,d.length=0}n.canvas.addEventListener("webglcontextlost",(function(t){p(),t.preventDefault()}),!1),o.set(n,i={gl:n,isWebGL2:r,getExtension:u,withProgram:function(t,e,i,a){if(!l[t]){var o={},s={},c=n.createProgram();n.attachShader(c,f(e,n.VERTEX_SHADER)),n.attachShader(c,f(i,n.FRAGMENT_SHADER)),n.linkProgram(c),l[t]={program:c,transaction:function(t){n.useProgram(c),t({setUniform:function(t,e){for(var i=[],r=arguments.length-2;r-- >0;)i[r]=arguments[r+2];var a=s[e]||(s[e]=n.getUniformLocation(c,e));n["uniform"+t].apply(n,[a].concat(i))},setAttribute:function(t,e,i,a,s){var l=o[t];l||(l=o[t]={buf:n.createBuffer(),loc:n.getAttribLocation(c,t),data:null}),n.bindBuffer(n.ARRAY_BUFFER,l.buf),n.vertexAttribPointer(l.loc,e,n.FLOAT,!1,0,0),n.enableVertexAttribArray(l.loc),r?n.vertexAttribDivisor(l.loc,a):u("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(l.loc,a),s!==l.data&&(n.bufferData(n.ARRAY_BUFFER,s,i),l.data=s)}})}}}l[t].transaction(a)},withTexture:function(t,e){h++;try{n.activeTexture(n.TEXTURE0+h);var i=c[t];i||(i=c[t]=n.createTexture(),n.bindTexture(n.TEXTURE_2D,i),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST)),n.bindTexture(n.TEXTURE_2D,i),e(i,h)}finally{h--}},withTextureFramebuffer:function(t,e,i){var r=n.createFramebuffer();d.push(r),n.bindFramebuffer(n.FRAMEBUFFER,r),n.activeTexture(n.TEXTURE0+e),n.bindTexture(n.TEXTURE_2D,t),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,t,0);try{i(r)}finally{n.deleteFramebuffer(r),n.bindFramebuffer(n.FRAMEBUFFER,d[--d.length-1]||null)}},handleContextLoss:p})}e(i)}function c(t,e,n,i,o,s,c,h){void 0===c&&(c=15),void 0===h&&(h=null),l(t,(function(t){var l=t.gl,d=t.withProgram;(0,t.withTexture)("copy",(function(t,u){l.texImage2D(l.TEXTURE_2D,0,l.RGBA,o,s,0,l.RGBA,l.UNSIGNED_BYTE,e),d("copy",r,a,(function(t){var e=t.setUniform;(0,t.setAttribute)("aUV",2,l.STATIC_DRAW,0,new Float32Array([0,0,2,0,0,2])),e("1i","image",u),l.bindFramebuffer(l.FRAMEBUFFER,h||null),l.disable(l.BLEND),l.colorMask(8&c,4&c,2&c,1&c),l.viewport(n,i,o,s),l.scissor(n,i,o,s),l.drawArrays(l.TRIANGLES,0,3)}))}))}))}var h=Object.freeze({__proto__:null,withWebGLContext:l,renderImageData:c,resizeWebGLCanvasWithoutClearing:function(t,e,n){var i=t.width,r=t.height;l(t,(function(a){var o=a.gl,s=new Uint8Array(i*r*4);o.readPixels(0,0,i,r,o.RGBA,o.UNSIGNED_BYTE,s),t.width=e,t.height=n,c(o,s,0,0,i,r)}))}});function d(t,e,n,r,a,o){void 0===o&&(o=1);var s=new Uint8Array(t*e),l=r[2]-r[0],c=r[3]-r[1],h=[];i(n,(function(t,e,n,i){h.push({x1:t,y1:e,x2:n,y2:i,minX:Math.min(t,n),minY:Math.min(e,i),maxX:Math.max(t,n),maxY:Math.max(e,i)})})),h.sort((function(t,e){return t.maxX-e.maxX}));for(var d=0;d<t;d++)for(var u=0;u<e;u++){var f=g(r[0]+l*(d+.5)/t,r[1]+c*(u+.5)/e),m=Math.pow(1-Math.abs(f)/a,o)/2;f<0&&(m=1-m),m=Math.max(0,Math.min(255,Math.round(255*m))),s[u*t+d]=m}return s;function g(t,e){for(var n=1/0,i=1/0,r=h.length;r--;){var a=h[r];if(a.maxX+i<=t)break;if(t+i>a.minX&&e-i<a.maxY&&e+i>a.minY){var o=p(t,e,a.x1,a.y1,a.x2,a.y2);o<n&&(n=o,i=Math.sqrt(n))}}return function(t,e){for(var n=0,i=h.length;i--;){var r=h[i];if(r.maxX<=t)break;r.y1>e!=r.y2>e&&t<(r.x2-r.x1)*(e-r.y1)/(r.y2-r.y1)+r.x1&&(n+=r.y1<r.y2?1:-1)}return 0!==n}(t,e)&&(i=-i),i}}function u(t,e,n,i,r,a,o,s,l,c){void 0===a&&(a=1),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),f(t,e,n,i,r,a,o,null,s,l,c)}function f(t,e,n,i,r,a,o,s,l,h,u){void 0===a&&(a=1),void 0===l&&(l=0),void 0===h&&(h=0),void 0===u&&(u=0);for(var f=d(t,e,n,i,r,a),p=new Uint8Array(4*f.length),m=0;m<f.length;m++)p[4*m+u]=f[m];c(o,p,l,h,t,e,1<<3-u,s)}function p(t,e,n,i,r,a){var o=r-n,s=a-i,l=o*o+s*s,c=l?Math.max(0,Math.min(1,((t-n)*o+(e-i)*s)/l)):0,h=t-(n+c*o),d=e-(i+c*s);return h*h+d*d}var m=Object.freeze({__proto__:null,generate:d,generateIntoCanvas:u,generateIntoFramebuffer:f}),g="precision highp float;uniform vec4 uGlyphBounds;attribute vec2 aUV;attribute vec4 aLineSegment;varying vec4 vLineSegment;varying vec2 vGlyphXY;void main(){vLineSegment=aLineSegment;vGlyphXY=mix(uGlyphBounds.xy,uGlyphBounds.zw,aUV);gl_Position=vec4(mix(vec2(-1.0),vec2(1.0),aUV),0.0,1.0);}",v="precision highp float;uniform vec4 uGlyphBounds;uniform float uMaxDistance;uniform float uExponent;varying vec4 vLineSegment;varying vec2 vGlyphXY;float absDistToSegment(vec2 point,vec2 lineA,vec2 lineB){vec2 lineDir=lineB-lineA;float lenSq=dot(lineDir,lineDir);float t=lenSq==0.0 ? 0.0 : clamp(dot(point-lineA,lineDir)/lenSq,0.0,1.0);vec2 linePt=lineA+t*lineDir;return distance(point,linePt);}void main(){vec4 seg=vLineSegment;vec2 p=vGlyphXY;float dist=absDistToSegment(p,seg.xy,seg.zw);float val=pow(1.0-clamp(dist/uMaxDistance,0.0,1.0),uExponent)*0.5;bool crossing=(seg.y>p.y!=seg.w>p.y)&&(p.x<(seg.z-seg.x)*(p.y-seg.y)/(seg.w-seg.y)+seg.x);bool crossingUp=crossing&&vLineSegment.y<vLineSegment.w;gl_FragColor=vec4(crossingUp ? 1.0/255.0 : 0.0,crossing&&!crossingUp ? 1.0/255.0 : 0.0,0.0,val);}",x="precision highp float;uniform sampler2D tex;varying vec2 vUV;void main(){vec4 color=texture2D(tex,vUV);bool inside=color.r!=color.g;float val=inside ? 1.0-color.a : color.a;gl_FragColor=vec4(val);}",_=new Float32Array([0,0,2,0,0,2]),y=null,S=!1,M={},b=new WeakMap;function w(t){if(!S&&!D(t))throw new Error("WebGL generation not supported")}function T(t,e,n,i,r,a,o){if(void 0===a&&(a=1),void 0===o&&(o=null),!o&&!(o=y)){var s="function"==typeof OffscreenCanvas?new OffscreenCanvas(1,1):"undefined"!=typeof document?document.createElement("canvas"):null;if(!s)throw new Error("OffscreenCanvas or DOM canvas not supported");o=y=s.getContext("webgl",{depth:!1})}w(o);var c=new Uint8Array(t*e*4);l(o,(function(o){var s=o.gl,l=o.withTexture,h=o.withTextureFramebuffer;l("readable",(function(o,l){s.texImage2D(s.TEXTURE_2D,0,s.RGBA,t,e,0,s.RGBA,s.UNSIGNED_BYTE,null),h(o,l,(function(o){A(t,e,n,i,r,a,s,o,0,0,0),s.readPixels(0,0,t,e,s.RGBA,s.UNSIGNED_BYTE,c)}))}))}));for(var h=new Uint8Array(t*e),d=0,u=0;d<c.length;d+=4)h[u++]=c[d];return h}function C(t,e,n,i,r,a,o,s,l,c){void 0===a&&(a=1),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),A(t,e,n,i,r,a,o,null,s,l,c)}function A(t,e,n,a,o,s,c,h,d,u,f){void 0===s&&(s=1),void 0===d&&(d=0),void 0===u&&(u=0),void 0===f&&(f=0),w(c);var p=[];i(n,(function(t,e,n,i){p.push(t,e,n,i)})),p=new Float32Array(p),l(c,(function(n){var i=n.gl,l=n.isWebGL2,c=n.getExtension,m=n.withProgram,y=n.withTexture,S=n.withTextureFramebuffer,M=n.handleContextLoss;if(y("rawDistances",(function(n,y){t===n._lastWidth&&e===n._lastHeight||i.texImage2D(i.TEXTURE_2D,0,i.RGBA,n._lastWidth=t,n._lastHeight=e,0,i.RGBA,i.UNSIGNED_BYTE,null),m("main",g,v,(function(r){var h=r.setAttribute,d=r.setUniform,u=!l&&c("ANGLE_instanced_arrays"),f=!l&&c("EXT_blend_minmax");h("aUV",2,i.STATIC_DRAW,0,_),h("aLineSegment",4,i.DYNAMIC_DRAW,1,p),d.apply(void 0,["4f","uGlyphBounds"].concat(a)),d("1f","uMaxDistance",o),d("1f","uExponent",s),S(n,y,(function(n){i.enable(i.BLEND),i.colorMask(!0,!0,!0,!0),i.viewport(0,0,t,e),i.scissor(0,0,t,e),i.blendFunc(i.ONE,i.ONE),i.blendEquationSeparate(i.FUNC_ADD,l?i.MAX:f.MAX_EXT),i.clear(i.COLOR_BUFFER_BIT),l?i.drawArraysInstanced(i.TRIANGLES,0,3,p.length/4):u.drawArraysInstancedANGLE(i.TRIANGLES,0,3,p.length/4)}))})),m("post",r,x,(function(n){n.setAttribute("aUV",2,i.STATIC_DRAW,0,_),n.setUniform("1i","tex",y),i.bindFramebuffer(i.FRAMEBUFFER,h),i.disable(i.BLEND),i.colorMask(0===f,1===f,2===f,3===f),i.viewport(d,u,t,e),i.scissor(d,u,t,e),i.drawArrays(i.TRIANGLES,0,3)}))})),i.isContextLost())throw M(),new Error("webgl context lost")}))}function D(t){var e=t&&t!==y?t.canvas||t:M,n=b.get(e);if(void 0===n){S=!0;var i=null;try{var r=[97,106,97,61,99,137,118,80,80,118,137,99,61,97,106,97],a=T(4,4,"M8,8L16,8L24,24L16,24Z",[0,0,32,32],24,1,t);(n=a&&r.length===a.length&&a.every((function(t,e){return t===r[e]})))||(i="bad trial run results",console.info(r,a))}catch(t){n=!1,i=t.message}i&&console.warn("WebGL SDF generation not supported:",i),S=!1,b.set(e,n)}return n}var U=Object.freeze({__proto__:null,generate:T,generateIntoCanvas:C,generateIntoFramebuffer:A,isSupported:D});return t.forEachPathCommand=n,t.generate=function(t,e,n,i,r,a){void 0===r&&(r=Math.max(i[2]-i[0],i[3]-i[1])/2),void 0===a&&(a=1);try{return T.apply(U,arguments)}catch(t){return console.info("WebGL SDF generation failed, falling back to JS",t),d.apply(m,arguments)}},t.generateIntoCanvas=function(t,e,n,i,r,a,o,s,l,c){void 0===r&&(r=Math.max(i[2]-i[0],i[3]-i[1])/2),void 0===a&&(a=1),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0);try{return C.apply(U,arguments)}catch(t){return console.info("WebGL SDF generation failed, falling back to JS",t),u.apply(m,arguments)}},t.javascript=m,t.pathToLineSegments=i,t.webgl=U,t.webglUtils=h,Object.defineProperty(t,"__esModule",{value:!0}),t}({});return t}const zr=/\bvoid\s+main\s*\(\s*\)\s*{/g;function Or(t){return t.replace(/^[ \t]*#include +<([\w\d./]+)>/gm,(function(t,e){let n=wn[e];return n?Or(n):t}))}const kr=[];for(let t=0;t<256;t++)kr[t]=(t<16?"0":"")+t.toString(16);const Fr=Object.assign||function(){let t=arguments[0];for(let e=1,n=arguments.length;e<n;e++){let n=arguments[e];if(n)for(let e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t},Br=Date.now(),Vr=new WeakMap,Gr=new Map;let Hr=1e10;function Wr(t,e){const n=function(t){const e=JSON.stringify(t,Xr);let n=Yr.get(e);null==n&&Yr.set(e,n=++qr);return n}(e);let i=Vr.get(t);if(i||Vr.set(t,i=Object.create(null)),i[n])return new i[n];const r=`_onBeforeCompile${n}`,a=function(i,a){t.onBeforeCompile.call(this,i,a);const o=this.customProgramCacheKey()+"|"+i.vertexShader+"|"+i.fragmentShader;let s=Gr[o];if(!s){const t=function(t,{vertexShader:e,fragmentShader:n},i,r){let{vertexDefs:a,vertexMainIntro:o,vertexMainOutro:s,vertexTransform:l,fragmentDefs:c,fragmentMainIntro:h,fragmentMainOutro:d,fragmentColorTransform:u,customRewriter:f,timeUniform:p}=i;a=a||"",o=o||"",s=s||"",c=c||"",h=h||"",d=d||"",(l||f)&&(e=Or(e));(u||f)&&(n=Or(n=n.replace(/^[ \t]*#include <((?:tonemapping|encodings|fog|premultiplied_alpha|dithering)_fragment)>/gm,"\n//!BEGIN_POST_CHUNK $1\n$&\n//!END_POST_CHUNK\n")));if(f){let t=f({vertexShader:e,fragmentShader:n});e=t.vertexShader,n=t.fragmentShader}if(u){let t=[];n=n.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm,(e=>(t.push(e),""))),d=`${u}\n${t.join("\n")}\n${d}`}if(p){const t=`\nuniform float ${p};\n`;a=t+a,c=t+c}l&&(a=`${a}\nvoid troikaVertexTransform${r}(inout vec3 position, inout vec3 normal, inout vec2 uv) {\n ${l}\n}\n`,o=`\ntroika_position_${r} = vec3(position);\ntroika_normal_${r} = vec3(normal);\ntroika_uv_${r} = vec2(uv);\ntroikaVertexTransform${r}(troika_position_${r}, troika_normal_${r}, troika_uv_${r});\n${o}\n`,e=(e=`vec3 troika_position_${r};\nvec3 troika_normal_${r};\nvec2 troika_uv_${r};\n${e}\n`).replace(/\b(position|normal|uv)\b/g,((t,e,n,i)=>/\battribute\s+vec[23]\s+$/.test(i.substr(0,n))?e:`troika_${e}_${r}`)),t.map&&t.map.channel>0||(e=e.replace(/\bMAP_UV\b/g,`troika_uv_${r}`)));return e=jr(e,r,a,o,s),n=jr(n,r,c,h,d),{vertexShader:e,fragmentShader:n}}(this,i,e,n);s=Gr[o]=t}i.vertexShader=s.vertexShader,i.fragmentShader=s.fragmentShader,Fr(i.uniforms,this.uniforms),e.timeUniform&&(i.uniforms[e.timeUniform]={get value(){return Date.now()-Br}}),this[r]&&this[r](i)},o=function(){return s(e.chained?t:t.clone())},s=function(i){const r=Object.create(i,l);return Object.defineProperty(r,"baseMaterial",{value:t}),Object.defineProperty(r,"id",{value:Hr++}),r.uuid=function(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(kr[255&t]+kr[t>>8&255]+kr[t>>16&255]+kr[t>>24&255]+"-"+kr[255&e]+kr[e>>8&255]+"-"+kr[e>>16&15|64]+kr[e>>24&255]+"-"+kr[63&n|128]+kr[n>>8&255]+"-"+kr[n>>16&255]+kr[n>>24&255]+kr[255&i]+kr[i>>8&255]+kr[i>>16&255]+kr[i>>24&255]).toUpperCase()}(),r.uniforms=Fr({},i.uniforms,e.uniforms),r.defines=Fr({},i.defines,e.defines),r.defines[`TROIKA_DERIVED_MATERIAL_${n}`]="",r.extensions=Fr({},i.extensions,e.extensions),r._listeners=void 0,r},l={constructor:{value:o},isDerivedMaterial:{value:!0},customProgramCacheKey:{writable:!0,configurable:!0,value:function(){return t.customProgramCacheKey()+"|"+n}},onBeforeCompile:{get:()=>a,set(t){this[r]=t}},copy:{writable:!0,configurable:!0,value:function(e){return t.copy.call(this,e),t.isShaderMaterial||t.isDerivedMaterial||(Fr(this.extensions,e.extensions),Fr(this.defines,e.defines),Fr(this.uniforms,fn.clone(e.uniforms))),this}},clone:{writable:!0,configurable:!0,value:function(){const e=new t.constructor;return s(e).copy(this)}},getDepthMaterial:{writable:!0,configurable:!0,value:function(){let n=this._depthMaterial;return n||(n=this._depthMaterial=Wr(t.isDerivedMaterial?t.getDepthMaterial():new An({depthPacking:p}),e),n.defines.IS_DEPTH_MATERIAL="",n.uniforms=this.uniforms),n}},getDistanceMaterial:{writable:!0,configurable:!0,value:function(){let n=this._distanceMaterial;return n||(n=this._distanceMaterial=Wr(t.isDerivedMaterial?t.getDistanceMaterial():new Dn,e),n.defines.IS_DISTANCE_MATERIAL="",n.uniforms=this.uniforms),n}},dispose:{writable:!0,configurable:!0,value(){const{_depthMaterial:e,_distanceMaterial:n}=this;e&&e.dispose(),n&&n.dispose(),t.dispose.call(this)}}};return i[n]=o,new o}function jr(t,e,n,i,r){return(i||r||n)&&(t=t.replace(zr,`\n${n}\nvoid troikaOrigMain${e}() {`),t+=`\nvoid main() {\n ${i}\n troikaOrigMain${e}();\n ${r}\n}`),t}function Xr(t,e){return"uniforms"===t?void 0:"function"==typeof e?e.toString():e}let qr=0;const Yr=new Map;const Zr=()=>(self.performance||Date).now(),$r=Nr();let Jr;const Qr=[],Kr=5;let ta=0;function ea(){const t=Zr();for(;Qr.length&&Zr()-t<Kr;)Qr.shift()();ta=Qr.length?setTimeout(ea,0):0}const na=(...t)=>new Promise(((e,n)=>{Qr.push((()=>{const i=Zr();try{$r.webgl.generateIntoCanvas(...t),e({timing:Zr()-i})}catch(t){n(t)}})),ta||(ta=setTimeout(ea,0))})),ia=4,ra=2e3,aa={};let oa=0;function sa(t,e,n,i,r,a,o,s,l,c){const h="TroikaTextSDFGenerator_JS_"+oa++%ia;let d=aa[h];return d||(d=aa[h]={workerModule:Ir({name:h,workerId:h,dependencies:[Nr,Zr],init(t,e){const n=t().javascript.generate;return function(...t){const i=e();return{textureData:n(...t),timing:e()-i}}},getTransferables:t=>[t.textureData.buffer]}),requests:0,idleTimer:null}),d.requests++,clearTimeout(d.idleTimer),d.workerModule(t,e,n,i,r,a).then((({textureData:n,timing:i})=>{const r=Zr(),a=new Uint8Array(4*n.length);for(let t=0;t<n.length;t++)a[4*t+c]=n[t];return $r.webglUtils.renderImageData(o,a,s,l,t,e,1<<3-c),i+=Zr()-r,0==--d.requests&&(d.idleTimer=setTimeout((()=>{!function(t){Er[t]&&Er[t].forEach((function(t){t()})),Ur[t]&&(Ur[t].terminate(),delete Ur[t])}(h)}),ra)),{timing:i}}))}const la=$r.webglUtils.resizeWebGLCanvasWithoutClearing; | |
/*! | |
Custom build of Typr.ts (https://github.com/fredli74/Typr.ts) for use in Troika text rendering. | |
Original MIT license applies: https://github.com/fredli74/Typr.ts/blob/master/LICENSE | |
*/const ca=Ir({name:"Typr Font Parser",dependencies:[function(){return"undefined"==typeof window&&(self.window=self),function(t){var e={parse:function(t){var n=e._bin,i=new Uint8Array(t);if("ttcf"==n.readASCII(i,0,4)){var r=4;n.readUshort(i,r),r+=2,n.readUshort(i,r),r+=2;var a=n.readUint(i,r);r+=4;for(var o=[],s=0;s<a;s++){var l=n.readUint(i,r);r+=4,o.push(e._readFont(i,l))}return o}return[e._readFont(i,0)]},_readFont:function(t,n){var i=e._bin,r=n;i.readFixed(t,n),n+=4;var a=i.readUshort(t,n);n+=2,i.readUshort(t,n),n+=2,i.readUshort(t,n),n+=2,i.readUshort(t,n),n+=2;for(var o=["cmap","head","hhea","maxp","hmtx","name","OS/2","post","loca","glyf","kern","CFF ","GPOS","GSUB","SVG "],s={_data:t,_offset:r},l={},c=0;c<a;c++){var h=i.readASCII(t,n,4);n+=4,i.readUint(t,n),n+=4;var d=i.readUint(t,n);n+=4;var u=i.readUint(t,n);n+=4,l[h]={offset:d,length:u}}for(c=0;c<o.length;c++){var f=o[c];l[f]&&(s[f.trim()]=e[f.trim()].parse(t,l[f].offset,l[f].length,s))}return s},_tabOffset:function(t,n,i){for(var r=e._bin,a=r.readUshort(t,i+4),o=i+12,s=0;s<a;s++){var l=r.readASCII(t,o,4);o+=4,r.readUint(t,o),o+=4;var c=r.readUint(t,o);if(o+=4,r.readUint(t,o),o+=4,l==n)return c}return 0}};e._bin={readFixed:function(t,e){return(t[e]<<8|t[e+1])+(t[e+2]<<8|t[e+3])/65540},readF2dot14:function(t,n){return e._bin.readShort(t,n)/16384},readInt:function(t,n){return e._bin._view(t).getInt32(n)},readInt8:function(t,n){return e._bin._view(t).getInt8(n)},readShort:function(t,n){return e._bin._view(t).getInt16(n)},readUshort:function(t,n){return e._bin._view(t).getUint16(n)},readUshorts:function(t,n,i){for(var r=[],a=0;a<i;a++)r.push(e._bin.readUshort(t,n+2*a));return r},readUint:function(t,n){return e._bin._view(t).getUint32(n)},readUint64:function(t,n){return 4294967296*e._bin.readUint(t,n)+e._bin.readUint(t,n+4)},readASCII:function(t,e,n){for(var i="",r=0;r<n;r++)i+=String.fromCharCode(t[e+r]);return i},readUnicode:function(t,e,n){for(var i="",r=0;r<n;r++){var a=t[e++]<<8|t[e++];i+=String.fromCharCode(a)}return i},_tdec:"undefined"!=typeof window&&window.TextDecoder?new window.TextDecoder:null,readUTF8:function(t,n,i){var r=e._bin._tdec;return r&&0==n&&i==t.length?r.decode(t):e._bin.readASCII(t,n,i)},readBytes:function(t,e,n){for(var i=[],r=0;r<n;r++)i.push(t[e+r]);return i},readASCIIArray:function(t,e,n){for(var i=[],r=0;r<n;r++)i.push(String.fromCharCode(t[e+r]));return i},_view:function(t){return t._dataView||(t._dataView=t.buffer?new DataView(t.buffer,t.byteOffset,t.byteLength):new DataView(new Uint8Array(t).buffer))}},e._lctf={},e._lctf.parse=function(t,n,i,r,a){var o=e._bin,s={},l=n;o.readFixed(t,n),n+=4;var c=o.readUshort(t,n);n+=2;var h=o.readUshort(t,n);n+=2;var d=o.readUshort(t,n);return n+=2,s.scriptList=e._lctf.readScriptList(t,l+c),s.featureList=e._lctf.readFeatureList(t,l+h),s.lookupList=e._lctf.readLookupList(t,l+d,a),s},e._lctf.readLookupList=function(t,n,i){var r=e._bin,a=n,o=[],s=r.readUshort(t,n);n+=2;for(var l=0;l<s;l++){var c=r.readUshort(t,n);n+=2;var h=e._lctf.readLookupTable(t,a+c,i);o.push(h)}return o},e._lctf.readLookupTable=function(t,n,i){var r=e._bin,a=n,o={tabs:[]};o.ltype=r.readUshort(t,n),n+=2,o.flag=r.readUshort(t,n),n+=2;var s=r.readUshort(t,n);n+=2;for(var l=o.ltype,c=0;c<s;c++){var h=r.readUshort(t,n);n+=2;var d=i(t,l,a+h,o);o.tabs.push(d)}return o},e._lctf.numOfOnes=function(t){for(var e=0,n=0;n<32;n++)0!=(t>>>n&1)&&e++;return e},e._lctf.readClassDef=function(t,n){var i=e._bin,r=[],a=i.readUshort(t,n);if(n+=2,1==a){var o=i.readUshort(t,n);n+=2;var s=i.readUshort(t,n);n+=2;for(var l=0;l<s;l++)r.push(o+l),r.push(o+l),r.push(i.readUshort(t,n)),n+=2}if(2==a){var c=i.readUshort(t,n);for(n+=2,l=0;l<c;l++)r.push(i.readUshort(t,n)),n+=2,r.push(i.readUshort(t,n)),n+=2,r.push(i.readUshort(t,n)),n+=2}return r},e._lctf.getInterval=function(t,e){for(var n=0;n<t.length;n+=3){var i=t[n],r=t[n+1];if(t[n+2],i<=e&&e<=r)return n}return-1},e._lctf.readCoverage=function(t,n){var i=e._bin,r={};r.fmt=i.readUshort(t,n),n+=2;var a=i.readUshort(t,n);return n+=2,1==r.fmt&&(r.tab=i.readUshorts(t,n,a)),2==r.fmt&&(r.tab=i.readUshorts(t,n,3*a)),r},e._lctf.coverageIndex=function(t,n){var i=t.tab;if(1==t.fmt)return i.indexOf(n);if(2==t.fmt){var r=e._lctf.getInterval(i,n);if(-1!=r)return i[r+2]+(n-i[r])}return-1},e._lctf.readFeatureList=function(t,n){var i=e._bin,r=n,a=[],o=i.readUshort(t,n);n+=2;for(var s=0;s<o;s++){var l=i.readASCII(t,n,4);n+=4;var c=i.readUshort(t,n);n+=2;var h=e._lctf.readFeatureTable(t,r+c);h.tag=l.trim(),a.push(h)}return a},e._lctf.readFeatureTable=function(t,n){var i=e._bin,r=n,a={},o=i.readUshort(t,n);n+=2,o>0&&(a.featureParams=r+o);var s=i.readUshort(t,n);n+=2,a.tab=[];for(var l=0;l<s;l++)a.tab.push(i.readUshort(t,n+2*l));return a},e._lctf.readScriptList=function(t,n){var i=e._bin,r=n,a={},o=i.readUshort(t,n);n+=2;for(var s=0;s<o;s++){var l=i.readASCII(t,n,4);n+=4;var c=i.readUshort(t,n);n+=2,a[l.trim()]=e._lctf.readScriptTable(t,r+c)}return a},e._lctf.readScriptTable=function(t,n){var i=e._bin,r=n,a={},o=i.readUshort(t,n);n+=2,a.default=e._lctf.readLangSysTable(t,r+o);var s=i.readUshort(t,n);n+=2;for(var l=0;l<s;l++){var c=i.readASCII(t,n,4);n+=4;var h=i.readUshort(t,n);n+=2,a[c.trim()]=e._lctf.readLangSysTable(t,r+h)}return a},e._lctf.readLangSysTable=function(t,n){var i=e._bin,r={};i.readUshort(t,n),n+=2,r.reqFeature=i.readUshort(t,n),n+=2;var a=i.readUshort(t,n);return n+=2,r.features=i.readUshorts(t,n,a),r},e.CFF={},e.CFF.parse=function(t,n,i){var r=e._bin;(t=new Uint8Array(t.buffer,n,i))[n=0],t[++n],t[++n],t[++n],n++;var a=[];n=e.CFF.readIndex(t,n,a);for(var o=[],s=0;s<a.length-1;s++)o.push(r.readASCII(t,n+a[s],a[s+1]-a[s]));n+=a[a.length-1];var l=[];n=e.CFF.readIndex(t,n,l);var c=[];for(s=0;s<l.length-1;s++)c.push(e.CFF.readDict(t,n+l[s],n+l[s+1]));n+=l[l.length-1];var h=c[0],d=[];n=e.CFF.readIndex(t,n,d);var u=[];for(s=0;s<d.length-1;s++)u.push(r.readASCII(t,n+d[s],d[s+1]-d[s]));if(n+=d[d.length-1],e.CFF.readSubrs(t,n,h),h.CharStrings){n=h.CharStrings,d=[],n=e.CFF.readIndex(t,n,d);var f=[];for(s=0;s<d.length-1;s++)f.push(r.readBytes(t,n+d[s],d[s+1]-d[s]));h.CharStrings=f}if(h.ROS){n=h.FDArray;var p=[];for(n=e.CFF.readIndex(t,n,p),h.FDArray=[],s=0;s<p.length-1;s++){var m=e.CFF.readDict(t,n+p[s],n+p[s+1]);e.CFF._readFDict(t,m,u),h.FDArray.push(m)}n+=p[p.length-1],n=h.FDSelect,h.FDSelect=[];var g=t[n];if(n++,3!=g)throw g;var v=r.readUshort(t,n);for(n+=2,s=0;s<v+1;s++)h.FDSelect.push(r.readUshort(t,n),t[n+2]),n+=3}return h.Encoding&&(h.Encoding=e.CFF.readEncoding(t,h.Encoding,h.CharStrings.length)),h.charset&&(h.charset=e.CFF.readCharset(t,h.charset,h.CharStrings.length)),e.CFF._readFDict(t,h,u),h},e.CFF._readFDict=function(t,n,i){var r;for(var a in n.Private&&(r=n.Private[1],n.Private=e.CFF.readDict(t,r,r+n.Private[0]),n.Private.Subrs&&e.CFF.readSubrs(t,r+n.Private.Subrs,n.Private)),n)-1!=["FamilyName","FontName","FullName","Notice","version","Copyright"].indexOf(a)&&(n[a]=i[n[a]-426+35])},e.CFF.readSubrs=function(t,n,i){var r=e._bin,a=[];n=e.CFF.readIndex(t,n,a);var o,s=a.length;o=s<1240?107:s<33900?1131:32768,i.Bias=o,i.Subrs=[];for(var l=0;l<a.length-1;l++)i.Subrs.push(r.readBytes(t,n+a[l],a[l+1]-a[l]))},e.CFF.tableSE=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,0,111,112,113,114,0,115,116,117,118,119,120,121,122,0,123,0,124,125,126,127,128,129,130,131,0,132,133,0,134,135,136,137,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,138,0,139,0,0,0,0,140,141,142,143,0,0,0,0,0,144,0,0,0,145,0,0,146,147,148,149,0,0,0,0],e.CFF.glyphByUnicode=function(t,e){for(var n=0;n<t.charset.length;n++)if(t.charset[n]==e)return n;return-1},e.CFF.glyphBySE=function(t,n){return n<0||n>255?-1:e.CFF.glyphByUnicode(t,e.CFF.tableSE[n])},e.CFF.readEncoding=function(t,n,i){e._bin;var r=[".notdef"],a=t[n];if(n++,0!=a)throw"error: unknown encoding format: "+a;var o=t[n];n++;for(var s=0;s<o;s++)r.push(t[n+s]);return r},e.CFF.readCharset=function(t,n,i){var r=e._bin,a=[".notdef"],o=t[n];if(n++,0==o)for(var s=0;s<i;s++){var l=r.readUshort(t,n);n+=2,a.push(l)}else{if(1!=o&&2!=o)throw"error: format: "+o;for(;a.length<i;){l=r.readUshort(t,n),n+=2;var c=0;for(1==o?(c=t[n],n++):(c=r.readUshort(t,n),n+=2),s=0;s<=c;s++)a.push(l),l++}}return a},e.CFF.readIndex=function(t,n,i){var r=e._bin,a=r.readUshort(t,n)+1,o=t[n+=2];if(n++,1==o)for(var s=0;s<a;s++)i.push(t[n+s]);else if(2==o)for(s=0;s<a;s++)i.push(r.readUshort(t,n+2*s));else if(3==o)for(s=0;s<a;s++)i.push(16777215&r.readUint(t,n+3*s-1));else if(1!=a)throw"unsupported offset size: "+o+", count: "+a;return(n+=a*o)-1},e.CFF.getCharString=function(t,n,i){var r=e._bin,a=t[n],o=t[n+1];t[n+2],t[n+3],t[n+4];var s=1,l=null,c=null;a<=20&&(l=a,s=1),12==a&&(l=100*a+o,s=2),21<=a&&a<=27&&(l=a,s=1),28==a&&(c=r.readShort(t,n+1),s=3),29<=a&&a<=31&&(l=a,s=1),32<=a&&a<=246&&(c=a-139,s=1),247<=a&&a<=250&&(c=256*(a-247)+o+108,s=2),251<=a&&a<=254&&(c=256*-(a-251)-o-108,s=2),255==a&&(c=r.readInt(t,n+1)/65535,s=5),i.val=null!=c?c:"o"+l,i.size=s},e.CFF.readCharString=function(t,n,i){for(var r=n+i,a=e._bin,o=[];n<r;){var s=t[n],l=t[n+1];t[n+2],t[n+3],t[n+4];var c=1,h=null,d=null;s<=20&&(h=s,c=1),12==s&&(h=100*s+l,c=2),19!=s&&20!=s||(h=s,c=2),21<=s&&s<=27&&(h=s,c=1),28==s&&(d=a.readShort(t,n+1),c=3),29<=s&&s<=31&&(h=s,c=1),32<=s&&s<=246&&(d=s-139,c=1),247<=s&&s<=250&&(d=256*(s-247)+l+108,c=2),251<=s&&s<=254&&(d=256*-(s-251)-l-108,c=2),255==s&&(d=a.readInt(t,n+1)/65535,c=5),o.push(null!=d?d:"o"+h),n+=c}return o},e.CFF.readDict=function(t,n,i){for(var r=e._bin,a={},o=[];n<i;){var s=t[n],l=t[n+1];t[n+2],t[n+3],t[n+4];var c=1,h=null,d=null;if(28==s&&(d=r.readShort(t,n+1),c=3),29==s&&(d=r.readInt(t,n+1),c=5),32<=s&&s<=246&&(d=s-139,c=1),247<=s&&s<=250&&(d=256*(s-247)+l+108,c=2),251<=s&&s<=254&&(d=256*-(s-251)-l-108,c=2),255==s)throw d=r.readInt(t,n+1)/65535,c=5,"unknown number";if(30==s){var u=[];for(c=1;;){var f=t[n+c];c++;var p=f>>4,m=15&f;if(15!=p&&u.push(p),15!=m&&u.push(m),15==m)break}for(var g="",v=[0,1,2,3,4,5,6,7,8,9,".","e","e-","reserved","-","endOfNumber"],x=0;x<u.length;x++)g+=v[u[x]];d=parseFloat(g)}s<=21&&(h=["version","Notice","FullName","FamilyName","Weight","FontBBox","BlueValues","OtherBlues","FamilyBlues","FamilyOtherBlues","StdHW","StdVW","escape","UniqueID","XUID","charset","Encoding","CharStrings","Private","Subrs","defaultWidthX","nominalWidthX"][s],c=1,12==s&&(h=["Copyright","isFixedPitch","ItalicAngle","UnderlinePosition","UnderlineThickness","PaintType","CharstringType","FontMatrix","StrokeWidth","BlueScale","BlueShift","BlueFuzz","StemSnapH","StemSnapV","ForceBold",0,0,"LanguageGroup","ExpansionFactor","initialRandomSeed","SyntheticBase","PostScript","BaseFontName","BaseFontBlend",0,0,0,0,0,0,"ROS","CIDFontVersion","CIDFontRevision","CIDFontType","CIDCount","UIDBase","FDArray","FDSelect","FontName"][l],c=2)),null!=h?(a[h]=1==o.length?o[0]:o,o=[]):o.push(d),n+=c}return a},e.cmap={},e.cmap.parse=function(t,n,i){t=new Uint8Array(t.buffer,n,i),n=0;var r=e._bin,a={};r.readUshort(t,n),n+=2;var o=r.readUshort(t,n);n+=2;var s=[];a.tables=[];for(var l=0;l<o;l++){var c=r.readUshort(t,n);n+=2;var h=r.readUshort(t,n);n+=2;var d=r.readUint(t,n);n+=4;var u="p"+c+"e"+h,f=s.indexOf(d);if(-1==f){var p;f=a.tables.length,s.push(d);var m=r.readUshort(t,d);0==m?p=e.cmap.parse0(t,d):4==m?p=e.cmap.parse4(t,d):6==m?p=e.cmap.parse6(t,d):12==m?p=e.cmap.parse12(t,d):console.debug("unknown format: "+m,c,h,d),a.tables.push(p)}if(null!=a[u])throw"multiple tables for one platform+encoding";a[u]=f}return a},e.cmap.parse0=function(t,n){var i=e._bin,r={};r.format=i.readUshort(t,n),n+=2;var a=i.readUshort(t,n);n+=2,i.readUshort(t,n),n+=2,r.map=[];for(var o=0;o<a-6;o++)r.map.push(t[n+o]);return r},e.cmap.parse4=function(t,n){var i=e._bin,r=n,a={};a.format=i.readUshort(t,n),n+=2;var o=i.readUshort(t,n);n+=2,i.readUshort(t,n),n+=2;var s=i.readUshort(t,n);n+=2;var l=s/2;a.searchRange=i.readUshort(t,n),n+=2,a.entrySelector=i.readUshort(t,n),n+=2,a.rangeShift=i.readUshort(t,n),n+=2,a.endCount=i.readUshorts(t,n,l),n+=2*l,n+=2,a.startCount=i.readUshorts(t,n,l),n+=2*l,a.idDelta=[];for(var c=0;c<l;c++)a.idDelta.push(i.readShort(t,n)),n+=2;for(a.idRangeOffset=i.readUshorts(t,n,l),n+=2*l,a.glyphIdArray=[];n<r+o;)a.glyphIdArray.push(i.readUshort(t,n)),n+=2;return a},e.cmap.parse6=function(t,n){var i=e._bin,r={};r.format=i.readUshort(t,n),n+=2,i.readUshort(t,n),n+=2,i.readUshort(t,n),n+=2,r.firstCode=i.readUshort(t,n),n+=2;var a=i.readUshort(t,n);n+=2,r.glyphIdArray=[];for(var o=0;o<a;o++)r.glyphIdArray.push(i.readUshort(t,n)),n+=2;return r},e.cmap.parse12=function(t,n){var i=e._bin,r={};r.format=i.readUshort(t,n),n+=2,n+=2,i.readUint(t,n),n+=4,i.readUint(t,n),n+=4;var a=i.readUint(t,n);n+=4,r.groups=[];for(var o=0;o<a;o++){var s=n+12*o,l=i.readUint(t,s+0),c=i.readUint(t,s+4),h=i.readUint(t,s+8);r.groups.push([l,c,h])}return r},e.glyf={},e.glyf.parse=function(t,e,n,i){for(var r=[],a=0;a<i.maxp.numGlyphs;a++)r.push(null);return r},e.glyf._parseGlyf=function(t,n){var i=e._bin,r=t._data,a=e._tabOffset(r,"glyf",t._offset)+t.loca[n];if(t.loca[n]==t.loca[n+1])return null;var o={};if(o.noc=i.readShort(r,a),a+=2,o.xMin=i.readShort(r,a),a+=2,o.yMin=i.readShort(r,a),a+=2,o.xMax=i.readShort(r,a),a+=2,o.yMax=i.readShort(r,a),a+=2,o.xMin>=o.xMax||o.yMin>=o.yMax)return null;if(o.noc>0){o.endPts=[];for(var s=0;s<o.noc;s++)o.endPts.push(i.readUshort(r,a)),a+=2;var l=i.readUshort(r,a);if(a+=2,r.length-a<l)return null;o.instructions=i.readBytes(r,a,l),a+=l;var c=o.endPts[o.noc-1]+1;for(o.flags=[],s=0;s<c;s++){var h=r[a];if(a++,o.flags.push(h),0!=(8&h)){var d=r[a];a++;for(var u=0;u<d;u++)o.flags.push(h),s++}}for(o.xs=[],s=0;s<c;s++){var f=0!=(2&o.flags[s]),p=0!=(16&o.flags[s]);f?(o.xs.push(p?r[a]:-r[a]),a++):p?o.xs.push(0):(o.xs.push(i.readShort(r,a)),a+=2)}for(o.ys=[],s=0;s<c;s++)f=0!=(4&o.flags[s]),p=0!=(32&o.flags[s]),f?(o.ys.push(p?r[a]:-r[a]),a++):p?o.ys.push(0):(o.ys.push(i.readShort(r,a)),a+=2);var m=0,g=0;for(s=0;s<c;s++)m+=o.xs[s],g+=o.ys[s],o.xs[s]=m,o.ys[s]=g}else{var v;o.parts=[];do{v=i.readUshort(r,a),a+=2;var x={m:{a:1,b:0,c:0,d:1,tx:0,ty:0},p1:-1,p2:-1};if(o.parts.push(x),x.glyphIndex=i.readUshort(r,a),a+=2,1&v){var _=i.readShort(r,a);a+=2;var y=i.readShort(r,a);a+=2}else _=i.readInt8(r,a),a++,y=i.readInt8(r,a),a++;2&v?(x.m.tx=_,x.m.ty=y):(x.p1=_,x.p2=y),8&v?(x.m.a=x.m.d=i.readF2dot14(r,a),a+=2):64&v?(x.m.a=i.readF2dot14(r,a),a+=2,x.m.d=i.readF2dot14(r,a),a+=2):128&v&&(x.m.a=i.readF2dot14(r,a),a+=2,x.m.b=i.readF2dot14(r,a),a+=2,x.m.c=i.readF2dot14(r,a),a+=2,x.m.d=i.readF2dot14(r,a),a+=2)}while(32&v);if(256&v){var S=i.readUshort(r,a);for(a+=2,o.instr=[],s=0;s<S;s++)o.instr.push(r[a]),a++}}return o},e.GPOS={},e.GPOS.parse=function(t,n,i,r){return e._lctf.parse(t,n,i,r,e.GPOS.subt)},e.GPOS.subt=function(t,n,i,r){var a=e._bin,o=i,s={};if(s.fmt=a.readUshort(t,i),i+=2,1==n||2==n||3==n||7==n||8==n&&s.fmt<=2){var l=a.readUshort(t,i);i+=2,s.coverage=e._lctf.readCoverage(t,l+o)}if(1==n&&1==s.fmt){var c=a.readUshort(t,i);i+=2;var h=e._lctf.numOfOnes(c);0!=c&&(s.pos=e.GPOS.readValueRecord(t,i,c))}else if(2==n&&s.fmt>=1&&s.fmt<=2){c=a.readUshort(t,i),i+=2;var d=a.readUshort(t,i);i+=2,h=e._lctf.numOfOnes(c);var u=e._lctf.numOfOnes(d);if(1==s.fmt){s.pairsets=[];var f=a.readUshort(t,i);i+=2;for(var p=0;p<f;p++){var m=o+a.readUshort(t,i);i+=2;var g=a.readUshort(t,m);m+=2;for(var v=[],x=0;x<g;x++){var _=a.readUshort(t,m);m+=2,0!=c&&(T=e.GPOS.readValueRecord(t,m,c),m+=2*h),0!=d&&(C=e.GPOS.readValueRecord(t,m,d),m+=2*u),v.push({gid2:_,val1:T,val2:C})}s.pairsets.push(v)}}if(2==s.fmt){var y=a.readUshort(t,i);i+=2;var S=a.readUshort(t,i);i+=2;var M=a.readUshort(t,i);i+=2;var b=a.readUshort(t,i);for(i+=2,s.classDef1=e._lctf.readClassDef(t,o+y),s.classDef2=e._lctf.readClassDef(t,o+S),s.matrix=[],p=0;p<M;p++){var w=[];for(x=0;x<b;x++){var T=null,C=null;0!=c&&(T=e.GPOS.readValueRecord(t,i,c),i+=2*h),0!=d&&(C=e.GPOS.readValueRecord(t,i,d),i+=2*u),w.push({val1:T,val2:C})}s.matrix.push(w)}}}else{if(9==n&&1==s.fmt){var A=a.readUshort(t,i);i+=2;var D=a.readUint(t,i);if(i+=4,9==r.ltype)r.ltype=A;else if(r.ltype!=A)throw"invalid extension substitution";return e.GPOS.subt(t,r.ltype,o+D)}console.debug("unsupported GPOS table LookupType",n,"format",s.fmt)}return s},e.GPOS.readValueRecord=function(t,n,i){var r=e._bin,a=[];return a.push(1&i?r.readShort(t,n):0),n+=1&i?2:0,a.push(2&i?r.readShort(t,n):0),n+=2&i?2:0,a.push(4&i?r.readShort(t,n):0),n+=4&i?2:0,a.push(8&i?r.readShort(t,n):0),n+=8&i?2:0,a},e.GSUB={},e.GSUB.parse=function(t,n,i,r){return e._lctf.parse(t,n,i,r,e.GSUB.subt)},e.GSUB.subt=function(t,n,i,r){var a=e._bin,o=i,s={};if(s.fmt=a.readUshort(t,i),i+=2,1!=n&&4!=n&&5!=n&&6!=n)return null;if(1==n||4==n||5==n&&s.fmt<=2||6==n&&s.fmt<=2){var l=a.readUshort(t,i);i+=2,s.coverage=e._lctf.readCoverage(t,o+l)}if(1==n&&s.fmt>=1&&s.fmt<=2){if(1==s.fmt)s.delta=a.readShort(t,i),i+=2;else if(2==s.fmt){var c=a.readUshort(t,i);i+=2,s.newg=a.readUshorts(t,i,c),i+=2*s.newg.length}}else if(4==n){s.vals=[],c=a.readUshort(t,i),i+=2;for(var h=0;h<c;h++){var d=a.readUshort(t,i);i+=2,s.vals.push(e.GSUB.readLigatureSet(t,o+d))}}else if(5==n&&2==s.fmt){if(2==s.fmt){var u=a.readUshort(t,i);i+=2,s.cDef=e._lctf.readClassDef(t,o+u),s.scset=[];var f=a.readUshort(t,i);for(i+=2,h=0;h<f;h++){var p=a.readUshort(t,i);i+=2,s.scset.push(0==p?null:e.GSUB.readSubClassSet(t,o+p))}}}else if(6==n&&3==s.fmt){if(3==s.fmt){for(h=0;h<3;h++){c=a.readUshort(t,i),i+=2;for(var m=[],g=0;g<c;g++)m.push(e._lctf.readCoverage(t,o+a.readUshort(t,i+2*g)));i+=2*c,0==h&&(s.backCvg=m),1==h&&(s.inptCvg=m),2==h&&(s.ahedCvg=m)}c=a.readUshort(t,i),i+=2,s.lookupRec=e.GSUB.readSubstLookupRecords(t,i,c)}}else{if(7==n&&1==s.fmt){var v=a.readUshort(t,i);i+=2;var x=a.readUint(t,i);if(i+=4,9==r.ltype)r.ltype=v;else if(r.ltype!=v)throw"invalid extension substitution";return e.GSUB.subt(t,r.ltype,o+x)}console.debug("unsupported GSUB table LookupType",n,"format",s.fmt)}return s},e.GSUB.readSubClassSet=function(t,n){var i=e._bin.readUshort,r=n,a=[],o=i(t,n);n+=2;for(var s=0;s<o;s++){var l=i(t,n);n+=2,a.push(e.GSUB.readSubClassRule(t,r+l))}return a},e.GSUB.readSubClassRule=function(t,n){var i=e._bin.readUshort,r={},a=i(t,n),o=i(t,n+=2);n+=2,r.input=[];for(var s=0;s<a-1;s++)r.input.push(i(t,n)),n+=2;return r.substLookupRecords=e.GSUB.readSubstLookupRecords(t,n,o),r},e.GSUB.readSubstLookupRecords=function(t,n,i){for(var r=e._bin.readUshort,a=[],o=0;o<i;o++)a.push(r(t,n),r(t,n+2)),n+=4;return a},e.GSUB.readChainSubClassSet=function(t,n){var i=e._bin,r=n,a=[],o=i.readUshort(t,n);n+=2;for(var s=0;s<o;s++){var l=i.readUshort(t,n);n+=2,a.push(e.GSUB.readChainSubClassRule(t,r+l))}return a},e.GSUB.readChainSubClassRule=function(t,n){for(var i=e._bin,r={},a=["backtrack","input","lookahead"],o=0;o<a.length;o++){var s=i.readUshort(t,n);n+=2,1==o&&s--,r[a[o]]=i.readUshorts(t,n,s),n+=2*r[a[o]].length}return s=i.readUshort(t,n),n+=2,r.subst=i.readUshorts(t,n,2*s),n+=2*r.subst.length,r},e.GSUB.readLigatureSet=function(t,n){var i=e._bin,r=n,a=[],o=i.readUshort(t,n);n+=2;for(var s=0;s<o;s++){var l=i.readUshort(t,n);n+=2,a.push(e.GSUB.readLigature(t,r+l))}return a},e.GSUB.readLigature=function(t,n){var i=e._bin,r={chain:[]};r.nglyph=i.readUshort(t,n),n+=2;var a=i.readUshort(t,n);n+=2;for(var o=0;o<a-1;o++)r.chain.push(i.readUshort(t,n)),n+=2;return r},e.head={},e.head.parse=function(t,n,i){var r=e._bin,a={};return r.readFixed(t,n),n+=4,a.fontRevision=r.readFixed(t,n),n+=4,r.readUint(t,n),n+=4,r.readUint(t,n),n+=4,a.flags=r.readUshort(t,n),n+=2,a.unitsPerEm=r.readUshort(t,n),n+=2,a.created=r.readUint64(t,n),n+=8,a.modified=r.readUint64(t,n),n+=8,a.xMin=r.readShort(t,n),n+=2,a.yMin=r.readShort(t,n),n+=2,a.xMax=r.readShort(t,n),n+=2,a.yMax=r.readShort(t,n),n+=2,a.macStyle=r.readUshort(t,n),n+=2,a.lowestRecPPEM=r.readUshort(t,n),n+=2,a.fontDirectionHint=r.readShort(t,n),n+=2,a.indexToLocFormat=r.readShort(t,n),n+=2,a.glyphDataFormat=r.readShort(t,n),n+=2,a},e.hhea={},e.hhea.parse=function(t,n,i){var r=e._bin,a={};return r.readFixed(t,n),n+=4,a.ascender=r.readShort(t,n),n+=2,a.descender=r.readShort(t,n),n+=2,a.lineGap=r.readShort(t,n),n+=2,a.advanceWidthMax=r.readUshort(t,n),n+=2,a.minLeftSideBearing=r.readShort(t,n),n+=2,a.minRightSideBearing=r.readShort(t,n),n+=2,a.xMaxExtent=r.readShort(t,n),n+=2,a.caretSlopeRise=r.readShort(t,n),n+=2,a.caretSlopeRun=r.readShort(t,n),n+=2,a.caretOffset=r.readShort(t,n),n+=2,n+=8,a.metricDataFormat=r.readShort(t,n),n+=2,a.numberOfHMetrics=r.readUshort(t,n),n+=2,a},e.hmtx={},e.hmtx.parse=function(t,n,i,r){for(var a=e._bin,o={aWidth:[],lsBearing:[]},s=0,l=0,c=0;c<r.maxp.numGlyphs;c++)c<r.hhea.numberOfHMetrics&&(s=a.readUshort(t,n),n+=2,l=a.readShort(t,n),n+=2),o.aWidth.push(s),o.lsBearing.push(l);return o},e.kern={},e.kern.parse=function(t,n,i,r){var a=e._bin,o=a.readUshort(t,n);if(n+=2,1==o)return e.kern.parseV1(t,n-2,i,r);var s=a.readUshort(t,n);n+=2;for(var l={glyph1:[],rval:[]},c=0;c<s;c++){n+=2,i=a.readUshort(t,n),n+=2;var h=a.readUshort(t,n);n+=2;var d=h>>>8;if(0!=(d&=15))throw"unknown kern table format: "+d;n=e.kern.readFormat0(t,n,l)}return l},e.kern.parseV1=function(t,n,i,r){var a=e._bin;a.readFixed(t,n),n+=4;var o=a.readUint(t,n);n+=4;for(var s={glyph1:[],rval:[]},l=0;l<o;l++){a.readUint(t,n),n+=4;var c=a.readUshort(t,n);n+=2,a.readUshort(t,n),n+=2;var h=c>>>8;if(0!=(h&=15))throw"unknown kern table format: "+h;n=e.kern.readFormat0(t,n,s)}return s},e.kern.readFormat0=function(t,n,i){var r=e._bin,a=-1,o=r.readUshort(t,n);n+=2,r.readUshort(t,n),n+=2,r.readUshort(t,n),n+=2,r.readUshort(t,n),n+=2;for(var s=0;s<o;s++){var l=r.readUshort(t,n);n+=2;var c=r.readUshort(t,n);n+=2;var h=r.readShort(t,n);n+=2,l!=a&&(i.glyph1.push(l),i.rval.push({glyph2:[],vals:[]}));var d=i.rval[i.rval.length-1];d.glyph2.push(c),d.vals.push(h),a=l}return n},e.loca={},e.loca.parse=function(t,n,i,r){var a=e._bin,o=[],s=r.head.indexToLocFormat,l=r.maxp.numGlyphs+1;if(0==s)for(var c=0;c<l;c++)o.push(a.readUshort(t,n+(c<<1))<<1);if(1==s)for(c=0;c<l;c++)o.push(a.readUint(t,n+(c<<2)));return o},e.maxp={},e.maxp.parse=function(t,n,i){var r=e._bin,a={},o=r.readUint(t,n);return n+=4,a.numGlyphs=r.readUshort(t,n),n+=2,65536==o&&(a.maxPoints=r.readUshort(t,n),n+=2,a.maxContours=r.readUshort(t,n),n+=2,a.maxCompositePoints=r.readUshort(t,n),n+=2,a.maxCompositeContours=r.readUshort(t,n),n+=2,a.maxZones=r.readUshort(t,n),n+=2,a.maxTwilightPoints=r.readUshort(t,n),n+=2,a.maxStorage=r.readUshort(t,n),n+=2,a.maxFunctionDefs=r.readUshort(t,n),n+=2,a.maxInstructionDefs=r.readUshort(t,n),n+=2,a.maxStackElements=r.readUshort(t,n),n+=2,a.maxSizeOfInstructions=r.readUshort(t,n),n+=2,a.maxComponentElements=r.readUshort(t,n),n+=2,a.maxComponentDepth=r.readUshort(t,n),n+=2),a},e.name={},e.name.parse=function(t,n,i){var r=e._bin,a={};r.readUshort(t,n),n+=2;var o=r.readUshort(t,n);n+=2,r.readUshort(t,n);for(var s,l=["copyright","fontFamily","fontSubfamily","ID","fullName","version","postScriptName","trademark","manufacturer","designer","description","urlVendor","urlDesigner","licence","licenceURL","---","typoFamilyName","typoSubfamilyName","compatibleFull","sampleText","postScriptCID","wwsFamilyName","wwsSubfamilyName","lightPalette","darkPalette"],c=n+=2,h=0;h<o;h++){var d=r.readUshort(t,n);n+=2;var u=r.readUshort(t,n);n+=2;var f=r.readUshort(t,n);n+=2;var p=r.readUshort(t,n);n+=2;var m=r.readUshort(t,n);n+=2;var g=r.readUshort(t,n);n+=2;var v,x=l[p],_=c+12*o+g;if(0==d)v=r.readUnicode(t,_,m/2);else if(3==d&&0==u)v=r.readUnicode(t,_,m/2);else if(0==u)v=r.readASCII(t,_,m);else if(1==u)v=r.readUnicode(t,_,m/2);else if(3==u)v=r.readUnicode(t,_,m/2);else{if(1!=d)throw"unknown encoding "+u+", platformID: "+d;v=r.readASCII(t,_,m),console.debug("reading unknown MAC encoding "+u+" as ASCII")}var y="p"+d+","+f.toString(16);null==a[y]&&(a[y]={}),a[y][void 0!==x?x:p]=v,a[y]._lang=f}for(var S in a)if(null!=a[S].postScriptName&&1033==a[S]._lang)return a[S];for(var S in a)if(null!=a[S].postScriptName&&0==a[S]._lang)return a[S];for(var S in a)if(null!=a[S].postScriptName&&3084==a[S]._lang)return a[S];for(var S in a)if(null!=a[S].postScriptName)return a[S];for(var S in a){s=S;break}return console.debug("returning name table with languageID "+a[s]._lang),a[s]},e["OS/2"]={},e["OS/2"].parse=function(t,n,i){var r=e._bin.readUshort(t,n);n+=2;var a={};if(0==r)e["OS/2"].version0(t,n,a);else if(1==r)e["OS/2"].version1(t,n,a);else if(2==r||3==r||4==r)e["OS/2"].version2(t,n,a);else{if(5!=r)throw"unknown OS/2 table version: "+r;e["OS/2"].version5(t,n,a)}return a},e["OS/2"].version0=function(t,n,i){var r=e._bin;return i.xAvgCharWidth=r.readShort(t,n),n+=2,i.usWeightClass=r.readUshort(t,n),n+=2,i.usWidthClass=r.readUshort(t,n),n+=2,i.fsType=r.readUshort(t,n),n+=2,i.ySubscriptXSize=r.readShort(t,n),n+=2,i.ySubscriptYSize=r.readShort(t,n),n+=2,i.ySubscriptXOffset=r.readShort(t,n),n+=2,i.ySubscriptYOffset=r.readShort(t,n),n+=2,i.ySuperscriptXSize=r.readShort(t,n),n+=2,i.ySuperscriptYSize=r.readShort(t,n),n+=2,i.ySuperscriptXOffset=r.readShort(t,n),n+=2,i.ySuperscriptYOffset=r.readShort(t,n),n+=2,i.yStrikeoutSize=r.readShort(t,n),n+=2,i.yStrikeoutPosition=r.readShort(t,n),n+=2,i.sFamilyClass=r.readShort(t,n),n+=2,i.panose=r.readBytes(t,n,10),n+=10,i.ulUnicodeRange1=r.readUint(t,n),n+=4,i.ulUnicodeRange2=r.readUint(t,n),n+=4,i.ulUnicodeRange3=r.readUint(t,n),n+=4,i.ulUnicodeRange4=r.readUint(t,n),n+=4,i.achVendID=[r.readInt8(t,n),r.readInt8(t,n+1),r.readInt8(t,n+2),r.readInt8(t,n+3)],n+=4,i.fsSelection=r.readUshort(t,n),n+=2,i.usFirstCharIndex=r.readUshort(t,n),n+=2,i.usLastCharIndex=r.readUshort(t,n),n+=2,i.sTypoAscender=r.readShort(t,n),n+=2,i.sTypoDescender=r.readShort(t,n),n+=2,i.sTypoLineGap=r.readShort(t,n),n+=2,i.usWinAscent=r.readUshort(t,n),n+=2,i.usWinDescent=r.readUshort(t,n),n+2},e["OS/2"].version1=function(t,n,i){var r=e._bin;return n=e["OS/2"].version0(t,n,i),i.ulCodePageRange1=r.readUint(t,n),n+=4,i.ulCodePageRange2=r.readUint(t,n),n+4},e["OS/2"].version2=function(t,n,i){var r=e._bin;return n=e["OS/2"].version1(t,n,i),i.sxHeight=r.readShort(t,n),n+=2,i.sCapHeight=r.readShort(t,n),n+=2,i.usDefault=r.readUshort(t,n),n+=2,i.usBreak=r.readUshort(t,n),n+=2,i.usMaxContext=r.readUshort(t,n),n+2},e["OS/2"].version5=function(t,n,i){var r=e._bin;return n=e["OS/2"].version2(t,n,i),i.usLowerOpticalPointSize=r.readUshort(t,n),n+=2,i.usUpperOpticalPointSize=r.readUshort(t,n),n+2},e.post={},e.post.parse=function(t,n,i){var r=e._bin,a={};return a.version=r.readFixed(t,n),n+=4,a.italicAngle=r.readFixed(t,n),n+=4,a.underlinePosition=r.readShort(t,n),n+=2,a.underlineThickness=r.readShort(t,n),n+=2,a},null==e&&(e={}),null==e.U&&(e.U={}),e.U.codeToGlyph=function(t,e){var n=t.cmap,i=-1;if(null!=n.p0e4?i=n.p0e4:null!=n.p3e1?i=n.p3e1:null!=n.p1e0?i=n.p1e0:null!=n.p0e3&&(i=n.p0e3),-1==i)throw"no familiar platform and encoding!";var r=n.tables[i];if(0==r.format)return e>=r.map.length?0:r.map[e];if(4==r.format){for(var a=-1,o=0;o<r.endCount.length;o++)if(e<=r.endCount[o]){a=o;break}return-1==a||r.startCount[a]>e?0:65535&(0!=r.idRangeOffset[a]?r.glyphIdArray[e-r.startCount[a]+(r.idRangeOffset[a]>>1)-(r.idRangeOffset.length-a)]:e+r.idDelta[a])}if(12==r.format){if(e>r.groups[r.groups.length-1][1])return 0;for(o=0;o<r.groups.length;o++){var s=r.groups[o];if(s[0]<=e&&e<=s[1])return s[2]+(e-s[0])}return 0}throw"unknown cmap table format "+r.format},e.U.glyphToPath=function(t,n){var i={cmds:[],crds:[]};if(t.SVG&&t.SVG.entries[n]){var r=t.SVG.entries[n];return null==r?i:("string"==typeof r&&(r=e.SVG.toPath(r),t.SVG.entries[n]=r),r)}if(t.CFF){var a={x:0,y:0,stack:[],nStems:0,haveWidth:!1,width:t.CFF.Private?t.CFF.Private.defaultWidthX:0,open:!1},o=t.CFF,s=t.CFF.Private;if(o.ROS){for(var l=0;o.FDSelect[l+2]<=n;)l+=2;s=o.FDArray[o.FDSelect[l+1]].Private}e.U._drawCFF(t.CFF.CharStrings[n],a,o,s,i)}else t.glyf&&e.U._drawGlyf(n,t,i);return i},e.U._drawGlyf=function(t,n,i){var r=n.glyf[t];null==r&&(r=n.glyf[t]=e.glyf._parseGlyf(n,t)),null!=r&&(r.noc>-1?e.U._simpleGlyph(r,i):e.U._compoGlyph(r,n,i))},e.U._simpleGlyph=function(t,n){for(var i=0;i<t.noc;i++){for(var r=0==i?0:t.endPts[i-1]+1,a=t.endPts[i],o=r;o<=a;o++){var s=o==r?a:o-1,l=o==a?r:o+1,c=1&t.flags[o],h=1&t.flags[s],d=1&t.flags[l],u=t.xs[o],f=t.ys[o];if(o==r)if(c){if(!h){e.U.P.moveTo(n,u,f);continue}e.U.P.moveTo(n,t.xs[s],t.ys[s])}else h?e.U.P.moveTo(n,t.xs[s],t.ys[s]):e.U.P.moveTo(n,(t.xs[s]+u)/2,(t.ys[s]+f)/2);c?h&&e.U.P.lineTo(n,u,f):d?e.U.P.qcurveTo(n,u,f,t.xs[l],t.ys[l]):e.U.P.qcurveTo(n,u,f,(u+t.xs[l])/2,(f+t.ys[l])/2)}e.U.P.closePath(n)}},e.U._compoGlyph=function(t,n,i){for(var r=0;r<t.parts.length;r++){var a={cmds:[],crds:[]},o=t.parts[r];e.U._drawGlyf(o.glyphIndex,n,a);for(var s=o.m,l=0;l<a.crds.length;l+=2){var c=a.crds[l],h=a.crds[l+1];i.crds.push(c*s.a+h*s.b+s.tx),i.crds.push(c*s.c+h*s.d+s.ty)}for(l=0;l<a.cmds.length;l++)i.cmds.push(a.cmds[l])}},e.U._getGlyphClass=function(t,n){var i=e._lctf.getInterval(n,t);return-1==i?0:n[i+2]},e.U.getPairAdjustment=function(t,n,i){var r=!1;if(t.GPOS)for(var a=t.GPOS,o=a.lookupList,s=a.featureList,l=[],c=0;c<s.length;c++){var h=s[c];if("kern"==h.tag){r=!0;for(var d=0;d<h.tab.length;d++)if(!l[h.tab[d]]){l[h.tab[d]]=!0;for(var u=o[h.tab[d]],f=0;f<u.tabs.length;f++)if(null!=u.tabs[f]){var p,m=u.tabs[f];if(!m.coverage||-1!=(p=e._lctf.coverageIndex(m.coverage,n)))if(1==u.ltype);else if(2==u.ltype){var g=null;if(1==m.fmt){var v=m.pairsets[p];for(c=0;c<v.length;c++)v[c].gid2==i&&(g=v[c])}else if(2==m.fmt){var x=e.U._getGlyphClass(n,m.classDef1),_=e.U._getGlyphClass(i,m.classDef2);g=m.matrix[x][_]}if(g){var y=0;return g.val1&&g.val1[2]&&(y+=g.val1[2]),g.val2&&g.val2[0]&&(y+=g.val2[0]),y}}}}}}if(t.kern&&!r){var S=t.kern.glyph1.indexOf(n);if(-1!=S){var M=t.kern.rval[S].glyph2.indexOf(i);if(-1!=M)return t.kern.rval[S].vals[M]}}return 0},e.U._applySubs=function(t,n,i,r){for(var a=t.length-n-1,o=0;o<i.tabs.length;o++)if(null!=i.tabs[o]){var s,l=i.tabs[o];if(!l.coverage||-1!=(s=e._lctf.coverageIndex(l.coverage,t[n])))if(1==i.ltype)t[n],1==l.fmt?t[n]=t[n]+l.delta:t[n]=l.newg[s];else if(4==i.ltype)for(var c=l.vals[s],h=0;h<c.length;h++){var d=c[h],u=d.chain.length;if(!(u>a)){for(var f=!0,p=0,m=0;m<u;m++){for(;-1==t[n+p+(1+m)];)p++;d.chain[m]!=t[n+p+(1+m)]&&(f=!1)}if(f){for(t[n]=d.nglyph,m=0;m<u+p;m++)t[n+m+1]=-1;break}}}else if(5==i.ltype&&2==l.fmt)for(var g=e._lctf.getInterval(l.cDef,t[n]),v=l.cDef[g+2],x=l.scset[v],_=0;_<x.length;_++){var y=x[_],S=y.input;if(!(S.length>a)){for(f=!0,m=0;m<S.length;m++){var M=e._lctf.getInterval(l.cDef,t[n+1+m]);if(-1==g&&l.cDef[M+2]!=S[m]){f=!1;break}}if(f){var b=y.substLookupRecords;for(h=0;h<b.length;h+=2)b[h],b[h+1]}}}else if(6==i.ltype&&3==l.fmt){if(!e.U._glsCovered(t,l.backCvg,n-l.backCvg.length))continue;if(!e.U._glsCovered(t,l.inptCvg,n))continue;if(!e.U._glsCovered(t,l.ahedCvg,n+l.inptCvg.length))continue;var w=l.lookupRec;for(_=0;_<w.length;_+=2){g=w[_];var T=r[w[_+1]];e.U._applySubs(t,n+g,T,r)}}}},e.U._glsCovered=function(t,n,i){for(var r=0;r<n.length;r++)if(-1==e._lctf.coverageIndex(n[r],t[i+r]))return!1;return!0},e.U.glyphsToPath=function(t,n,i){for(var r={cmds:[],crds:[]},a=0,o=0;o<n.length;o++){var s=n[o];if(-1!=s){for(var l=o<n.length-1&&-1!=n[o+1]?n[o+1]:0,c=e.U.glyphToPath(t,s),h=0;h<c.crds.length;h+=2)r.crds.push(c.crds[h]+a),r.crds.push(c.crds[h+1]);for(i&&r.cmds.push(i),h=0;h<c.cmds.length;h++)r.cmds.push(c.cmds[h]);i&&r.cmds.push("X"),a+=t.hmtx.aWidth[s],o<n.length-1&&(a+=e.U.getPairAdjustment(t,s,l))}}return r},e.U.P={},e.U.P.moveTo=function(t,e,n){t.cmds.push("M"),t.crds.push(e,n)},e.U.P.lineTo=function(t,e,n){t.cmds.push("L"),t.crds.push(e,n)},e.U.P.curveTo=function(t,e,n,i,r,a,o){t.cmds.push("C"),t.crds.push(e,n,i,r,a,o)},e.U.P.qcurveTo=function(t,e,n,i,r){t.cmds.push("Q"),t.crds.push(e,n,i,r)},e.U.P.closePath=function(t){t.cmds.push("Z")},e.U._drawCFF=function(t,n,i,r,a){for(var o=n.stack,s=n.nStems,l=n.haveWidth,c=n.width,h=n.open,d=0,u=n.x,f=n.y,p=0,m=0,g=0,v=0,x=0,_=0,y=0,S=0,M=0,b=0,w={val:0,size:0};d<t.length;){e.CFF.getCharString(t,d,w);var T=w.val;if(d+=w.size,"o1"==T||"o18"==T)o.length%2!=0&&!l&&(c=o.shift()+r.nominalWidthX),s+=o.length>>1,o.length=0,l=!0;else if("o3"==T||"o23"==T)o.length%2!=0&&!l&&(c=o.shift()+r.nominalWidthX),s+=o.length>>1,o.length=0,l=!0;else if("o4"==T)o.length>1&&!l&&(c=o.shift()+r.nominalWidthX,l=!0),h&&e.U.P.closePath(a),f+=o.pop(),e.U.P.moveTo(a,u,f),h=!0;else if("o5"==T)for(;o.length>0;)u+=o.shift(),f+=o.shift(),e.U.P.lineTo(a,u,f);else if("o6"==T||"o7"==T)for(var C=o.length,A="o6"==T,D=0;D<C;D++){var U=o.shift();A?u+=U:f+=U,A=!A,e.U.P.lineTo(a,u,f)}else if("o8"==T||"o24"==T){C=o.length;for(var E=0;E+6<=C;)p=u+o.shift(),m=f+o.shift(),g=p+o.shift(),v=m+o.shift(),u=g+o.shift(),f=v+o.shift(),e.U.P.curveTo(a,p,m,g,v,u,f),E+=6;"o24"==T&&(u+=o.shift(),f+=o.shift(),e.U.P.lineTo(a,u,f))}else{if("o11"==T)break;if("o1234"==T||"o1235"==T||"o1236"==T||"o1237"==T)"o1234"==T&&(m=f,g=(p=u+o.shift())+o.shift(),b=v=m+o.shift(),_=v,S=f,u=(y=(x=(M=g+o.shift())+o.shift())+o.shift())+o.shift(),e.U.P.curveTo(a,p,m,g,v,M,b),e.U.P.curveTo(a,x,_,y,S,u,f)),"o1235"==T&&(p=u+o.shift(),m=f+o.shift(),g=p+o.shift(),v=m+o.shift(),M=g+o.shift(),b=v+o.shift(),x=M+o.shift(),_=b+o.shift(),y=x+o.shift(),S=_+o.shift(),u=y+o.shift(),f=S+o.shift(),o.shift(),e.U.P.curveTo(a,p,m,g,v,M,b),e.U.P.curveTo(a,x,_,y,S,u,f)),"o1236"==T&&(p=u+o.shift(),m=f+o.shift(),g=p+o.shift(),b=v=m+o.shift(),_=v,y=(x=(M=g+o.shift())+o.shift())+o.shift(),S=_+o.shift(),u=y+o.shift(),e.U.P.curveTo(a,p,m,g,v,M,b),e.U.P.curveTo(a,x,_,y,S,u,f)),"o1237"==T&&(p=u+o.shift(),m=f+o.shift(),g=p+o.shift(),v=m+o.shift(),M=g+o.shift(),b=v+o.shift(),x=M+o.shift(),_=b+o.shift(),y=x+o.shift(),S=_+o.shift(),Math.abs(y-u)>Math.abs(S-f)?u=y+o.shift():f=S+o.shift(),e.U.P.curveTo(a,p,m,g,v,M,b),e.U.P.curveTo(a,x,_,y,S,u,f));else if("o14"==T){if(o.length>0&&!l&&(c=o.shift()+i.nominalWidthX,l=!0),4==o.length){var P=o.shift(),I=o.shift(),R=o.shift(),L=o.shift(),N=e.CFF.glyphBySE(i,R),z=e.CFF.glyphBySE(i,L);e.U._drawCFF(i.CharStrings[N],n,i,r,a),n.x=P,n.y=I,e.U._drawCFF(i.CharStrings[z],n,i,r,a)}h&&(e.U.P.closePath(a),h=!1)}else if("o19"==T||"o20"==T)o.length%2!=0&&!l&&(c=o.shift()+r.nominalWidthX),s+=o.length>>1,o.length=0,l=!0,d+=s+7>>3;else if("o21"==T)o.length>2&&!l&&(c=o.shift()+r.nominalWidthX,l=!0),f+=o.pop(),u+=o.pop(),h&&e.U.P.closePath(a),e.U.P.moveTo(a,u,f),h=!0;else if("o22"==T)o.length>1&&!l&&(c=o.shift()+r.nominalWidthX,l=!0),u+=o.pop(),h&&e.U.P.closePath(a),e.U.P.moveTo(a,u,f),h=!0;else if("o25"==T){for(;o.length>6;)u+=o.shift(),f+=o.shift(),e.U.P.lineTo(a,u,f);p=u+o.shift(),m=f+o.shift(),g=p+o.shift(),v=m+o.shift(),u=g+o.shift(),f=v+o.shift(),e.U.P.curveTo(a,p,m,g,v,u,f)}else if("o26"==T)for(o.length%2&&(u+=o.shift());o.length>0;)p=u,m=f+o.shift(),u=g=p+o.shift(),f=(v=m+o.shift())+o.shift(),e.U.P.curveTo(a,p,m,g,v,u,f);else if("o27"==T)for(o.length%2&&(f+=o.shift());o.length>0;)m=f,g=(p=u+o.shift())+o.shift(),v=m+o.shift(),u=g+o.shift(),f=v,e.U.P.curveTo(a,p,m,g,v,u,f);else if("o10"==T||"o29"==T){var O="o10"==T?r:i;if(0==o.length)console.debug("error: empty stack");else{var k=o.pop(),F=O.Subrs[k+O.Bias];n.x=u,n.y=f,n.nStems=s,n.haveWidth=l,n.width=c,n.open=h,e.U._drawCFF(F,n,i,r,a),u=n.x,f=n.y,s=n.nStems,l=n.haveWidth,c=n.width,h=n.open}}else if("o30"==T||"o31"==T){var B=o.length,V=(E=0,"o31"==T);for(E+=B-(C=-3&B);E<C;)V?(m=f,g=(p=u+o.shift())+o.shift(),f=(v=m+o.shift())+o.shift(),C-E==5?(u=g+o.shift(),E++):u=g,V=!1):(p=u,m=f+o.shift(),g=p+o.shift(),v=m+o.shift(),u=g+o.shift(),C-E==5?(f=v+o.shift(),E++):f=v,V=!0),e.U.P.curveTo(a,p,m,g,v,u,f),E+=4}else{if("o"==(T+"").charAt(0))throw console.debug("Unknown operation: "+T,t),T;o.push(T)}}}n.x=u,n.y=f,n.nStems=s,n.haveWidth=l,n.width=c,n.open=h};var n=e,i={Typr:n};return t.Typr=n,t.default=i,Object.defineProperty(t,"__esModule",{value:!0}),t}({}).Typr} | |
/*! | |
Custom bundle of woff2otf (https://github.com/arty-name/woff2otf) with fflate | |
(https://github.com/101arrowz/fflate) for use in Troika text rendering. | |
Original licenses apply: | |
- fflate: https://github.com/101arrowz/fflate/blob/master/LICENSE (MIT) | |
- woff2otf.js: https://github.com/arty-name/woff2otf/blob/master/woff2otf.js (Apache2) | |
*/,function(){return function(t){var e=Uint8Array,n=Uint16Array,i=Uint32Array,r=new e([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),a=new e([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),o=new e([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=function(t,e){for(var r=new n(31),a=0;a<31;++a)r[a]=e+=1<<t[a-1];var o=new i(r[30]);for(a=1;a<30;++a)for(var s=r[a];s<r[a+1];++s)o[s]=s-r[a]<<5|a;return[r,o]},l=s(r,2),c=l[0],h=l[1];c[28]=258,h[258]=28;for(var d=s(a,0)[0],u=new n(32768),f=0;f<32768;++f){var p=(43690&f)>>>1|(21845&f)<<1;p=(61680&(p=(52428&p)>>>2|(13107&p)<<2))>>>4|(3855&p)<<4,u[f]=((65280&p)>>>8|(255&p)<<8)>>>1}var m=function(t,e,i){for(var r=t.length,a=0,o=new n(e);a<r;++a)++o[t[a]-1];var s,l=new n(e);for(a=0;a<e;++a)l[a]=l[a-1]+o[a-1]<<1;if(i){s=new n(1<<e);var c=15-e;for(a=0;a<r;++a)if(t[a])for(var h=a<<4|t[a],d=e-t[a],f=l[t[a]-1]++<<d,p=f|(1<<d)-1;f<=p;++f)s[u[f]>>>c]=h}else for(s=new n(r),a=0;a<r;++a)t[a]&&(s[a]=u[l[t[a]-1]++]>>>15-t[a]);return s},g=new e(288);for(f=0;f<144;++f)g[f]=8;for(f=144;f<256;++f)g[f]=9;for(f=256;f<280;++f)g[f]=7;for(f=280;f<288;++f)g[f]=8;var v=new e(32);for(f=0;f<32;++f)v[f]=5;var x=m(g,9,1),_=m(v,5,1),y=function(t){for(var e=t[0],n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},S=function(t,e,n){var i=e/8|0;return(t[i]|t[i+1]<<8)>>(7&e)&n},M=function(t,e){var n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(7&e)},b=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],w=function(t,e,n){var i=new Error(e||b[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,w),!n)throw i;return i},T=function(t,s,l){var h=t.length;if(!h||l&&!l.l&&h<5)return s||new e(0);var u=!s||l,f=!l||l.i;l||(l={}),s||(s=new e(3*h));var p,g=function(t){var n=s.length;if(t>n){var i=new e(Math.max(2*n,t));i.set(s),s=i}},v=l.f||0,b=l.p||0,T=l.b||0,C=l.l,A=l.d,D=l.m,U=l.n,E=8*h;do{if(!C){l.f=v=S(t,b,1);var P=S(t,b+1,3);if(b+=3,!P){var I=t[(H=((p=b)/8|0)+(7&p&&1)+4)-4]|t[H-3]<<8,R=H+I;if(R>h){f&&w(0);break}u&&g(T+I),s.set(t.subarray(H,R),T),l.b=T+=I,l.p=b=8*R;continue}if(1==P)C=x,A=_,D=9,U=5;else if(2==P){var L=S(t,b,31)+257,N=S(t,b+10,15)+4,z=L+S(t,b+5,31)+1;b+=14;for(var O=new e(z),k=new e(19),F=0;F<N;++F)k[o[F]]=S(t,b+3*F,7);b+=3*N;var B=y(k),V=(1<<B)-1,G=m(k,B,1);for(F=0;F<z;){var H,W=G[S(t,b,V)];if(b+=15&W,(H=W>>>4)<16)O[F++]=H;else{var j=0,X=0;for(16==H?(X=3+S(t,b,3),b+=2,j=O[F-1]):17==H?(X=3+S(t,b,7),b+=3):18==H&&(X=11+S(t,b,127),b+=7);X--;)O[F++]=j}}var q=O.subarray(0,L),Y=O.subarray(L);D=y(q),U=y(Y),C=m(q,D,1),A=m(Y,U,1)}else w(1);if(b>E){f&&w(0);break}}u&&g(T+131072);for(var Z=(1<<D)-1,$=(1<<U)-1,J=b;;J=b){var Q=(j=C[M(t,b)&Z])>>>4;if((b+=15&j)>E){f&&w(0);break}if(j||w(2),Q<256)s[T++]=Q;else{if(256==Q){J=b,C=null;break}var K=Q-254;if(Q>264){var tt=r[F=Q-257];K=S(t,b,(1<<tt)-1)+c[F],b+=tt}var et=A[M(t,b)&$],nt=et>>>4;if(et||w(3),b+=15&et,Y=d[nt],nt>3&&(tt=a[nt],Y+=M(t,b)&(1<<tt)-1,b+=tt),b>E){f&&w(0);break}u&&g(T+131072);for(var it=T+K;T<it;T+=4)s[T]=s[T-Y],s[T+1]=s[T+1-Y],s[T+2]=s[T+2-Y],s[T+3]=s[T+3-Y];T=it}}l.l=C,l.p=J,l.b=T,C&&(v=1,l.m=D,l.d=A,l.n=U)}while(!v);return T==s.length?s:function(t,r,a){(null==r||r<0)&&(r=0),(null==a||a>t.length)&&(a=t.length);var o=new(t instanceof n?n:t instanceof i?i:e)(a-r);return o.set(t.subarray(r,a)),o}(s,0,T)},C=new e(0),A="undefined"!=typeof TextDecoder&&new TextDecoder;try{A.decode(C,{stream:!0})}catch(t){}return t.convert_streams=function(t){var e=new DataView(t),n=0;function i(){var t=e.getUint16(n);return n+=2,t}function r(){var t=e.getUint32(n);return n+=4,t}function a(t){v.setUint16(x,t),x+=2}function o(t){v.setUint32(x,t),x+=4}for(var s={signature:r(),flavor:r(),length:r(),numTables:i(),reserved:i(),totalSfntSize:r(),majorVersion:i(),minorVersion:i(),metaOffset:r(),metaLength:r(),metaOrigLength:r(),privOffset:r(),privLength:r()},l=0;Math.pow(2,l)<=s.numTables;)l++;l--;for(var c=16*Math.pow(2,l),h=16*s.numTables-c,d=12,u=[],f=0;f<s.numTables;f++)u.push({tag:r(),offset:r(),compLength:r(),origLength:r(),origChecksum:r()}),d+=16;var p,m=new Uint8Array(12+16*u.length+u.reduce((function(t,e){return t+e.origLength+4}),0)),g=m.buffer,v=new DataView(g),x=0;return o(s.flavor),a(s.numTables),a(c),a(l),a(h),u.forEach((function(t){o(t.tag),o(t.origChecksum),o(d),o(t.origLength),t.outOffset=d,(d+=t.origLength)%4!=0&&(d+=4-d%4)})),u.forEach((function(e){var n,i=t.slice(e.offset,e.offset+e.compLength);if(e.compLength!=e.origLength){var r=new Uint8Array(e.origLength);n=new Uint8Array(i,2),T(n,r)}else r=new Uint8Array(i);m.set(r,e.outOffset);var a=0;(d=e.outOffset+e.origLength)%4!=0&&(a=4-d%4),m.set(new Uint8Array(a).buffer,e.outOffset+e.origLength),p=d+a})),g.slice(0,p)},Object.defineProperty(t,"__esModule",{value:!0}),t}({}).convert_streams},function(t,e){const n={M:2,L:2,Q:4,C:6,Z:0},i={C:"18g,ca,368,1kz",D:"17k,6,2,2+4,5+c,2+6,2+1,10+1,9+f,j+11,2+1,a,2,2+1,15+2,3,j+2,6+3,2+8,2,2,2+1,w+a,4+e,3+3,2,3+2,3+5,23+w,2f+4,3,2+9,2,b,2+3,3,1k+9,6+1,3+1,2+2,2+d,30g,p+y,1,1+1g,f+x,2,sd2+1d,jf3+4,f+3,2+4,2+2,b+3,42,2,4+2,2+1,2,3,t+1,9f+w,2,el+2,2+g,d+2,2l,2+1,5,3+1,2+1,2,3,6,16wm+1v",R:"17m+3,2,2,6+3,m,15+2,2+2,h+h,13,3+8,2,2,3+1,2,p+1,x,5+4,5,a,2,2,3,u,c+2,g+1,5,2+1,4+1,5j,6+1,2,b,2+2,f,2+1,1s+2,2,3+1,7,1ez0,2,2+1,4+4,b,4,3,b,42,2+2,4,3,2+1,2,o+3,ae,ep,x,2o+2,3+1,3,5+1,6",L:"x9u,jff,a,fd,jv",T:"4t,gj+33,7o+4,1+1,7c+18,2,2+1,2+1,2,21+a,2,1b+k,h,2u+6,3+5,3+1,2+3,y,2,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,3,7,6+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+d,1,1+1,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,ek,3+1,r+4,1e+4,6+5,2p+c,1+3,1,1+2,1+b,2db+2,3y,2p+v,ff+3,30+1,n9x,1+2,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,5s,6y+2,ea,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+9,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2,2b+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,470+8,at4+4,1o+6,t5,1s+3,2a,f5l+1,2+3,43o+2,a+7,1+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,1,gzau,v+2n,3l+6n"},r=1,a=2,o=4,s=8,l=16,c=32;let h;function d(t){if(!h){const t={R:a,L:r,D:o,C:l,U:c,T:s};h=new Map;for(let e in i){let n=0;i[e].split(",").forEach((i=>{let[r,a]=i.split("+");r=parseInt(r,36),a=a?parseInt(a,36):0,h.set(n+=r,t[e]);for(let i=a;i--;)h.set(++n,t[e])}))}}return h.get(t)||c}const u=1,f=2,p=3,m=4,g=[null,"isol","init","fina","medi"];function v(t){const e=new Uint8Array(t.length);let n=c,i=u,h=-1;for(let g=0;g<t.length;g++){const v=t.codePointAt(g);let x=0|d(v),_=u;x&s||(n&(r|o|l)?x&(a|o|l)?(_=p,i!==u&&i!==p||e[h]++):x&(r|c)&&(i!==f&&i!==m||e[h]--):n&(a|c)&&(i!==f&&i!==m||e[h]--),i=e[g]=_,n=x,h=g,v>65535&&g++)}return e}function x(...t){for(let e=0;e<t.length;e++)if("number"==typeof t[e])return t[e]}function _(e){const i=Object.create(null),r=e["OS/2"],a=e.hhea,o=e.head.unitsPerEm,s=x(r&&r.sTypoAscender,a&&a.ascender,o),l={unitsPerEm:o,ascender:s,descender:x(r&&r.sTypoDescender,a&&a.descender,0),capHeight:x(r&&r.sCapHeight,s),xHeight:x(r&&r.sxHeight,s),lineGap:x(r&&r.sTypoLineGap,a&&a.lineGap),forEachGlyph(r,a,o,s){let c=0;const h=1/l.unitsPerEm*a,d=function(e,n){const i=[];for(let r=0;r<n.length;r++){const a=n.codePointAt(r);a>65535&&r++,i.push(t.U.codeToGlyph(e,a))}const r=e.GSUB;if(r){const{lookupList:e,featureList:a}=r;let o;const s=/^(rlig|liga|mset|isol|init|fina|medi|half|pres|blws)$/,l=[];a.forEach((r=>{if(s.test(r.tag))for(let a=0;a<r.tab.length;a++){if(l[r.tab[a]])continue;l[r.tab[a]]=!0;const s=e[r.tab[a]],c=/^(isol|init|fina|medi)$/.test(r.tag);c&&!o&&(o=v(n));for(let n=0;n<i.length;n++)o&&c&&g[o[n]]!==r.tag||t.U._applySubs(i,n,s,e)}}))}return i}(e,r);let u=0,f=-1;return d.forEach(((l,d)=>{if(-1!==l){let r=i[l];if(!r){const{cmds:a,crds:o}=t.U.glyphToPath(e,l);let s,c,h,d,u="",f=0;for(let t=0,e=a.length;t<e;t++){const e=n[a[t]];u+=a[t];for(let t=1;t<=e;t++)u+=(t>1?",":"")+o[f++]}if(o.length){s=c=1/0,h=d=-1/0;for(let t=0,e=o.length;t<e;t+=2){let e=o[t],n=o[t+1];e<s&&(s=e),n<c&&(c=n),e>h&&(h=e),n>d&&(d=n)}}else s=h=c=d=0;r=i[l]={index:l,advanceWidth:e.hmtx.aWidth[l],xMin:s,yMin:c,xMax:h,yMax:d,path:u,pathCommandCount:a.length}}-1!==f&&(c+=t.U.getPairAdjustment(e,f,l)*h),s.call(null,r,c,u),r.advanceWidth&&(c+=r.advanceWidth*h),o&&(c+=o*a),f=l}u+=r.codePointAt(u)>65535?2:1})),c}};return l}return function(n){const i=new Uint8Array(n,0,4),r=t._bin.readASCII(i,0,4);if("wOFF"===r)n=e(n);else if("wOF2"===r)throw new Error("woff2 fonts not supported");return _(t.parse(n)[0])}}],init:(t,e,n)=>n(t(),e())}),ha={defaultFontURL:"https://fonts.gstatic.com/s/roboto/v18/KFOmCnqEu92Fr1Mu4mxM.woff",sdfGlyphSize:64,sdfMargin:1/16,sdfExponent:9,textureWidth:2048},da=new Ae;function ua(){return(self.performance||Date).now()}const fa=Object.create(null);function pa(t,e){t=function(t,e){for(let n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}({},t);const n=ua();if(t.font=function(t){ga||(ga="undefined"==typeof document?{}:document.createElement("a"));return ga.href=t,ga.href}(t.font||ha.defaultFontURL),t.text=""+t.text,t.sdfGlyphSize=t.sdfGlyphSize||ha.sdfGlyphSize,null!=t.colorRanges){let e={};for(let n in t.colorRanges)if(t.colorRanges.hasOwnProperty(n)){let i=t.colorRanges[n];"number"!=typeof i&&(i=da.set(i).getHex()),e[n]=i}t.colorRanges=e}Object.freeze(t);const{textureWidth:i,sdfExponent:r}=ha,{sdfGlyphSize:a}=t,o=i/a*4;let l=fa[a];if(!l){const t=document.createElement("canvas");t.width=i,t.height=256*a/o,l=fa[a]={glyphCount:0,sdfGlyphSize:a,sdfCanvas:t,sdfTexture:new it(t,void 0,void 0,void 0,s,s),contextLost:!1,glyphsByFont:new Map},l.sdfTexture.generateMipmaps=!1,function(t){const e=t.sdfCanvas;e.addEventListener("webglcontextlost",(e=>{console.log("Context Lost",e),e.preventDefault(),t.contextLost=!0})),e.addEventListener("webglcontextrestored",(e=>{console.log("Context Restored",e),t.contextLost=!1;const n=[];t.glyphsByFont.forEach((e=>{e.forEach((e=>{n.push(ma(e,t,!0))}))})),Promise.all(n).then((()=>{va(t),t.sdfTexture.needsUpdate=!0}))}))}(l)}const{sdfTexture:c,sdfCanvas:h}=l;let d=l.glyphsByFont.get(t.font);d||l.glyphsByFont.set(t.font,d=new Map),_a(t).then((s=>{const{glyphIds:u,glyphPositions:f,fontSize:p,unitsPerEm:m,timings:g}=s,v=[],x=new Float32Array(4*u.length),_=p/m;let y=0,S=0;const M=ua();u.forEach(((t,e)=>{let n=d.get(t);if(!n){const{path:e,pathBounds:i}=s.glyphData[t],r=Math.max(i[2]-i[0],i[3]-i[1])/a*(ha.sdfMargin*a+.5),o=l.glyphCount++,c=[i[0]-r,i[1]-r,i[2]+r,i[3]+r];d.set(t,n={path:e,atlasIndex:o,sdfViewBox:c}),v.push(n)}const{sdfViewBox:i}=n,r=f[S++],o=f[S++];x[y++]=r+i[0]*_,x[y++]=o+i[1]*_,x[y++]=r+i[2]*_,x[y++]=o+i[3]*_,u[e]=n.atlasIndex})),g.quads=(g.quads||0)+(ua()-M);const b=ua();g.sdf={};const w=h.height,T=Math.ceil(l.glyphCount/o),C=Math.pow(2,Math.ceil(Math.log2(T*a)));C>w&&(console.info(`Increasing SDF texture size ${w}->${C}`),la(h,i,C),c.dispose()),Promise.all(v.map((e=>ma(e,l,t.gpuAccelerateSDF).then((({timing:t})=>{g.sdf[e.atlasIndex]=t}))))).then((()=>{v.length&&!l.contextLost&&(va(l),c.needsUpdate=!0),g.sdfTotal=ua()-b,g.total=ua()-n,e(Object.freeze({parameters:t,sdfTexture:c,sdfGlyphSize:a,sdfExponent:r,glyphBounds:x,glyphAtlasIndices:u,glyphColors:s.glyphColors,caretPositions:s.caretPositions,caretHeight:s.caretHeight,chunkedBounds:s.chunkedBounds,ascender:s.ascender,descender:s.descender,lineHeight:s.lineHeight,capHeight:s.capHeight,xHeight:s.xHeight,topBaseline:s.topBaseline,blockBounds:s.blockBounds,visibleBounds:s.visibleBounds,timings:s.timings}))}))})),Promise.resolve().then((()=>{var t;l.contextLost||(t=h)._warm||($r.webgl.isSupported(t),t._warm=!0)}))}function ma({path:t,atlasIndex:e,sdfViewBox:n},{sdfGlyphSize:i,sdfCanvas:r,contextLost:a},o){if(a)return Promise.resolve({timing:-1});const{textureWidth:s,sdfExponent:l}=ha,c=Math.max(n[2]-n[0],n[3]-n[1]),h=Math.floor(e/4);return function(t,e,n,i,r,a,o,s,l,c,h=!0){return h?na(t,e,n,i,r,a,o,s,l,c).then(null,(h=>(Jr||(console.warn("WebGL SDF generation failed, falling back to JS",h),Jr=!0),sa(t,e,n,i,r,a,o,s,l,c)))):sa(t,e,n,i,r,a,o,s,l,c)}(i,i,t,n,c,l,r,h%(s/i)*i,Math.floor(h/(s/i))*i,e%4,o)}let ga;function va(t){if("function"!=typeof createImageBitmap){console.info("Safari<15: applying SDF canvas workaround");const{sdfCanvas:e,sdfTexture:n}=t,{width:i,height:r}=e,a=t.sdfCanvas.getContext("webgl");let o=n.image.data;o&&o.length===i*r*4||(o=new Uint8Array(i*r*4),n.image={width:i,height:r,data:o},n.flipY=!1,n.isDataTexture=!0),a.readPixels(0,0,i,r,a.RGBA,a.UNSIGNED_BYTE,o)}}const xa=Ir({name:"Typesetter",dependencies:[ha,ca,function(t,e,n){const{defaultFontURL:i}=n,r=Object.create(null),a=1/0,o=/[\u00AD\u034F\u061C\u115F-\u1160\u17B4-\u17B5\u180B-\u180E\u200B-\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8]/,s="[^\\S\\u00A0]",l=new RegExp(`${s}|[\\-\\u007C\\u00AD\\u2010\\u2012-\\u2014\\u2027\\u2056\\u2E17\\u2E40]`);function c(e,n){e||(e=i);let a=r[e];a?a.pending?a.pending.push(n):n(a):(r[e]={pending:[n]},function(e,n){!function r(){const a=t=>{console.error(`Failure loading font ${e}${e===i?"":"; trying fallback"}`,t),e!==i&&(e=i,r())};try{const i=new XMLHttpRequest;i.open("get",e,!0),i.responseType="arraybuffer",i.onload=function(){if(i.status>=400)a(new Error(i.statusText));else if(i.status>0)try{const e=t(i.response);n(e)}catch(t){a(t)}},i.onerror=a,i.send()}catch(t){a(t)}}()}(e,(t=>{let n=r[e].pending;r[e]=t,n.forEach((e=>e(t)))})))}function h({text:t="",font:n=i,sdfGlyphSize:r=64,fontSize:h=1,letterSpacing:m=0,lineHeight:g="normal",maxWidth:v=a,direction:x,textAlign:_="left",textIndent:y=0,whiteSpace:S="normal",overflowWrap:M="normal",anchorX:b=0,anchorY:w=0,includeCaretPositions:T=!1,chunkedBoundsSize:C=8192,colorRanges:A=null},D,U=!1){const E=f(),P={fontLoad:0,typesetting:0};t.indexOf("\r")>-1&&(console.info("Typesetter: got text with \\r chars; normalizing to \\n"),t=t.replace(/\r\n/g,"\n").replace(/\r/g,"\n")),h=+h,m=+m,v=+v,g=g||"normal",y=+y,c(n,(n=>{const i=isFinite(v);let r=null,c=null,I=null,R=null,L=null,N=null,z=null,O=0,k=0,F="nowrap"!==S;const{ascender:B,descender:V,unitsPerEm:G,lineGap:H,capHeight:W,xHeight:j}=n;P.fontLoad=f()-E;const X=f(),q=h/G;"normal"===g&&(g=(B-V+H)/G);const Y=((g*=h)-(B-V)*q)/2,Z=-(B*q+Y),$=Math.min(g,(B-V)*q),J=(B+V)/2*q-$/2;let Q=y,K=new p;const tt=[K];n.forEachGlyph(t,h,m,((e,n,r)=>{const a=t.charAt(r),c=e.advanceWidth*q,d=K.count;let u;if("isEmpty"in e||(e.isWhitespace=!!a&&new RegExp(s).test(a),e.canBreakAfter=!!a&&l.test(a),e.isEmpty=e.xMin===e.xMax||e.yMin===e.yMax||o.test(a)),e.isWhitespace||e.isEmpty||k++,F&&i&&!e.isWhitespace&&n+c+Q>v&&d){if(K.glyphAt(d-1).glyphObj.canBreakAfter)u=new p,Q=-n;else for(let t=d;t--;){if(0===t&&"break-word"===M){u=new p,Q=-n;break}if(K.glyphAt(t).glyphObj.canBreakAfter){u=K.splitAt(t+1);const e=u.glyphAt(0).x;Q-=e;for(let t=u.count;t--;)u.glyphAt(t).x-=e;break}}u&&(K.isSoftWrapped=!0,K=u,tt.push(K),O=v)}let f=K.glyphAt(K.count);f.glyphObj=e,f.x=n+Q,f.width=c,f.charIndex=r,"\n"===a&&(K=new p,tt.push(K),Q=-(n+c+m*h)+y)})),tt.forEach((t=>{for(let e=t.count;e--;){let{glyphObj:n,x:i,width:r}=t.glyphAt(e);if(!n.isWhitespace)return t.width=i+r,void(t.width>O&&(O=t.width))}}));let et=0,nt=0;if(b&&("number"==typeof b?et=-b:"string"==typeof b&&(et=-O*("left"===b?0:"center"===b?.5:"right"===b?1:d(b)))),w)if("number"==typeof w)nt=-w;else if("string"==typeof w){let t=tt.length*g;nt="top"===w?0:"top-baseline"===w?-Z:"top-cap"===w?-Z-W*q:"top-ex"===w?-Z-j*q:"middle"===w?t/2:"bottom"===w?t:"bottom-baseline"===w?t-Y+V*q:d(w)*t}if(!U){const i=e.getEmbeddingLevels(t,x);r=new Uint16Array(k),c=new Float32Array(2*k),I={},N=[a,a,-a,-a],z=[];let o=Z;T&&(L=new Float32Array(3*t.length)),A&&(R=new Uint8Array(3*k));let s,l,h=0,d=-1,f=-1;if(tt.forEach(((p,m)=>{let{count:v,width:x}=p;if(v>0){let m=0;for(let t=v;t--&&p.glyphAt(t).glyphObj.isWhitespace;)m++;let g=0,y=0;if("center"===_)g=(O-x)/2;else if("right"===_)g=O-x;else if("justify"===_&&p.isSoftWrapped){let t=0;for(let e=v-m;e--;)p.glyphAt(e).glyphObj.isWhitespace&&t++;y=(O-x)/t}if(y||g){let t=0;for(let e=0;e<v;e++){let n=p.glyphAt(e);const i=n.glyphObj;n.x+=g+t,0!==y&&i.isWhitespace&&e<v-m&&(t+=y,n.width+=y)}}const S=e.getReorderSegments(t,i,p.glyphAt(0).charIndex,p.glyphAt(p.count-1).charIndex);for(let t=0;t<S.length;t++){const[e,n]=S[t];let i=1/0,r=-1/0;for(let t=0;t<v;t++)if(p.glyphAt(t).charIndex>=e){let e=t,a=t;for(;a<v;a++){let t=p.glyphAt(a);if(t.charIndex>n)break;a<v-m&&(i=Math.min(i,t.x),r=Math.max(r,t.x+t.width))}for(let t=e;t<a;t++){const e=p.glyphAt(t);e.x=r-(e.x+e.width-i)}break}}let M;const b=t=>M=t;for(let m=0;m<v;m++){let g=p.glyphAt(m);M=g.glyphObj;const v=M.index,x=1&i.levels[g.charIndex];if(x){const i=e.getMirroredCharacter(t[g.charIndex]);i&&n.forEachGlyph(i,0,0,b)}if(T){const{charIndex:t}=g,e=g.x+et,n=g.x+g.width+et;L[3*t]=x?n:e,L[3*t+1]=x?e:n,L[3*t+2]=o+J+nt;const i=t-d;i>1&&u(L,d,i),d=t}if(A){const{charIndex:t}=g;for(;t>f;)f++,A.hasOwnProperty(f)&&(l=A[f])}if(!M.isWhitespace&&!M.isEmpty){const t=h++;I[v]||(I[v]={path:M.path,pathBounds:[M.xMin,M.yMin,M.xMax,M.yMax]});const e=g.x+et,n=o+nt;c[2*t]=e,c[2*t+1]=n;const i=e+M.xMin*q,d=n+M.yMin*q,u=e+M.xMax*q,f=n+M.yMax*q;i<N[0]&&(N[0]=i),d<N[1]&&(N[1]=d),u>N[2]&&(N[2]=u),f>N[3]&&(N[3]=f),t%C==0&&(s={start:t,end:t,rect:[a,a,-a,-a]},z.push(s)),s.end++;const p=s.rect;if(i<p[0]&&(p[0]=i),d<p[1]&&(p[1]=d),u>p[2]&&(p[2]=u),f>p[3]&&(p[3]=f),r[t]=v,A){const e=3*t;R[e]=l>>16&255,R[e+1]=l>>8&255,R[e+2]=255&l}}}}o-=g})),L){const e=t.length-d;e>1&&u(L,d,e)}}P.typesetting=f()-X,D({glyphIds:r,glyphPositions:c,glyphData:I,caretPositions:L,caretHeight:$,glyphColors:R,chunkedBounds:z,fontSize:h,unitsPerEm:G,ascender:B*q,descender:V*q,capHeight:W*q,xHeight:j*q,lineHeight:g,topBaseline:Z,blockBounds:[et,nt-tt.length*g,et+O,nt],visibleBounds:N,timings:P})}))}function d(t){let e=t.match(/^([\d.]+)%$/),n=e?parseFloat(e[1]):NaN;return isNaN(n)?0:n/100}function u(t,e,n){const i=t[3*e],r=t[3*e+1],a=t[3*e+2],o=(r-i)/n;for(let r=0;r<n;r++){const n=3*(e+r);t[n]=i+o*r,t[n+1]=i+o*(r+1),t[n+2]=a}}function f(){return(self.performance||Date).now()}function p(){this.data=[]}const m=["glyphObj","x","width","charIndex"];return p.prototype={width:0,isSoftWrapped:!1,get count(){return Math.ceil(this.data.length/m.length)},glyphAt(t){let e=p.flyweight;return e.data=this.data,e.index=t,e},splitAt(t){let e=new p;return e.data=this.data.splice(t*m.length),e}},p.flyweight=m.reduce(((t,e,n,i)=>(Object.defineProperty(t,e,{get(){return this.data[this.index*m.length+n]},set(t){this.data[this.index*m.length+n]=t}}),t)),{data:null,index:0}),{typeset:h,measure:function(t,e){h(t,(t=>{const[n,i,r,a]=t.blockBounds;e({width:r-n,height:a-i})}),{metricsOnly:!0})},loadFont:c}},function(){return function(t){var e={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},n={},i={};n.L=1,i[1]="L",Object.keys(e).forEach((function(t,e){n[t]=1<<e+1,i[n[t]]=t})),Object.freeze(n);var r=n.LRI|n.RLI|n.FSI,a=n.L|n.R|n.AL,o=n.B|n.S|n.WS|n.ON|n.FSI|n.LRI|n.RLI|n.PDI,s=n.BN|n.RLE|n.LRE|n.RLO|n.LRO|n.PDF,l=n.S|n.WS|n.B|r|n.PDI|s,c=null;function h(t){return function(){if(!c){c=new Map;var t=function(t){if(e.hasOwnProperty(t)){var i=0;e[t].split(",").forEach((function(e){var r=e.split("+"),a=r[0],o=r[1];a=parseInt(a,36),o=o?parseInt(o,36):0,c.set(i+=a,n[t]);for(var s=0;s<o;s++)c.set(++i,n[t])}))}};for(var i in e)t(i)}}(),c.get(t.codePointAt(0))||n.L}var d,u,f,p={pairs:"14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",canonical:"6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"};function m(t,e){var n,i=0,r=new Map,a=e&&new Map;return t.split(",").forEach((function t(o){if(-1!==o.indexOf("+"))for(var s=+o;s--;)t(n);else{n=o;var l=o.split(">"),c=l[0],h=l[1];c=String.fromCodePoint(i+=parseInt(c,36)),h=String.fromCodePoint(i+=parseInt(h,36)),r.set(c,h),e&&a.set(h,c)}})),{map:r,reverseMap:a}}function g(){if(!d){var t=m(p.pairs,!0),e=t.map,n=t.reverseMap;d=e,u=n,f=m(p.canonical,!1).map}}function v(t){return g(),d.get(t)||null}function x(t){return g(),u.get(t)||null}function _(t){return g(),f.get(t)||null}var y=n.L,S=n.R,M=n.EN,b=n.ES,w=n.ET,T=n.AN,C=n.CS,A=n.B,D=n.S,U=n.ON,E=n.BN,P=n.NSM,I=n.AL,R=n.LRO,L=n.RLO,N=n.LRE,z=n.RLE,O=n.PDF,k=n.LRI,F=n.RLI,B=n.FSI,V=n.PDI;var G,H="14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1";function W(t){return function(){if(!G){var t=m(H,!0),e=t.map;t.reverseMap.forEach((function(t,n){e.set(n,t)})),G=e}}(),G.get(t)||null}function j(t,e,n,i){var r=t.length;n=Math.max(0,null==n?0:+n),i=Math.min(r-1,null==i?r-1:+i);var a=[];return e.paragraphs.forEach((function(r){var o=Math.max(n,r.start),s=Math.min(i,r.end);if(o<s){for(var c=e.levels.slice(o,s+1),d=s;d>=o&&h(t[d])&l;d--)c[d]=r.level;for(var u=r.level,f=1/0,p=0;p<c.length;p++){var m=c[p];m>u&&(u=m),m<f&&(f=1|m)}for(var g=u;g>=f;g--)for(var v=0;v<c.length;v++)if(c[v]>=g){for(var x=v;v+1<c.length&&c[v+1]>=g;)v++;v>x&&a.push([x+o,v+o])}}})),a}function X(t,e,n,i){for(var r=j(t,e,n,i),a=[],o=0;o<t.length;o++)a[o]=o;return r.forEach((function(t){for(var e=t[0],n=t[1],i=a.slice(e,n+1),r=i.length;r--;)a[n-r]=i[r]})),a}return t.closingToOpeningBracket=x,t.getBidiCharType=h,t.getBidiCharTypeName=function(t){return i[h(t)]},t.getCanonicalBracket=_,t.getEmbeddingLevels=function(t,e){for(var n=new Uint32Array(t.length),i=0;i<t.length;i++)n[i]=h(t[i]);var c=new Map;function d(t,e){var i=n[t];n[t]=e,c.set(i,c.get(i)-1),i&o&&c.set(o,c.get(o)-1),c.set(e,(c.get(e)||0)+1),e&o&&c.set(o,(c.get(o)||0)+1)}for(var u=new Uint8Array(t.length),f=new Map,p=[],m=null,g=0;g<t.length;g++)m||p.push(m={start:g,end:t.length-1,level:"rtl"===e?1:"ltr"===e?0:Ve(g,!1)}),n[g]&A&&(m.end=g,m=null);for(var G=z|N|L|R|r|V|O|A,H=function(t){return t+(1&t?1:2)},W=function(t){return t+(1&t?2:1)},j=0;j<p.length;j++){var X=[{_level:(m=p[j]).level,_override:0,_isolate:0}],q=void 0,Y=0,Z=0,$=0;c.clear();for(var J=m.start;J<=m.end;J++){var Q=n[J];if(q=X[X.length-1],c.set(Q,(c.get(Q)||0)+1),Q&o&&c.set(o,(c.get(o)||0)+1),Q&G)if(Q&(z|N)){u[J]=q._level;var K=(Q===z?W:H)(q._level);K<=125&&!Y&&!Z?X.push({_level:K,_override:0,_isolate:0}):Y||Z++}else if(Q&(L|R)){u[J]=q._level;var tt=(Q===L?W:H)(q._level);tt<=125&&!Y&&!Z?X.push({_level:tt,_override:Q&L?S:y,_isolate:0}):Y||Z++}else if(Q&r){Q&B&&(Q=1===Ve(J+1,!0)?F:k),u[J]=q._level,q._override&&d(J,q._override);var et=(Q===F?W:H)(q._level);et<=125&&0===Y&&0===Z?($++,X.push({_level:et,_override:0,_isolate:1,_isolInitIndex:J})):Y++}else if(Q&V){if(Y>0)Y--;else if($>0){for(Z=0;!X[X.length-1]._isolate;)X.pop();var nt=X[X.length-1]._isolInitIndex;null!=nt&&(f.set(nt,J),f.set(J,nt)),X.pop(),$--}q=X[X.length-1],u[J]=q._level,q._override&&d(J,q._override)}else Q&O?(0===Y&&(Z>0?Z--:!q._isolate&&X.length>1&&(X.pop(),q=X[X.length-1])),u[J]=q._level):Q&A&&(u[J]=m.level);else u[J]=q._level,q._override&&Q!==E&&d(J,q._override)}for(var it=[],rt=null,at=m.start;at<=m.end;at++){var ot=n[at];if(!(ot&s)){var st=u[at],lt=ot&r,ct=ot===V;rt&&st===rt._level?(rt._end=at,rt._endsWithIsolInit=lt):it.push(rt={_start:at,_end:at,_level:st,_startsWithPDI:ct,_endsWithIsolInit:lt})}}for(var ht=[],dt=0;dt<it.length;dt++){var ut=it[dt];if(!ut._startsWithPDI||ut._startsWithPDI&&!f.has(ut._start)){for(var ft=[rt=ut],pt=void 0;rt&&rt._endsWithIsolInit&&null!=(pt=f.get(rt._end));)for(var mt=dt+1;mt<it.length;mt++)if(it[mt]._start===pt){ft.push(rt=it[mt]);break}for(var gt=[],vt=0;vt<ft.length;vt++)for(var xt=ft[vt],_t=xt._start;_t<=xt._end;_t++)gt.push(_t);for(var yt=u[gt[0]],St=m.level,Mt=gt[0]-1;Mt>=0;Mt--)if(!(n[Mt]&s)){St=u[Mt];break}var bt=gt[gt.length-1],wt=u[bt],Tt=m.level;if(!(n[bt]&r))for(var Ct=bt+1;Ct<=m.end;Ct++)if(!(n[Ct]&s)){Tt=u[Ct];break}ht.push({_seqIndices:gt,_sosType:Math.max(St,yt)%2?S:y,_eosType:Math.max(Tt,wt)%2?S:y})}}for(var At=0;At<ht.length;At++){var Dt=ht[At],Ut=Dt._seqIndices,Et=Dt._sosType,Pt=Dt._eosType,It=1&u[Ut[0]]?S:y;if(c.get(P))for(var Rt=0;Rt<Ut.length;Rt++){var Lt=Ut[Rt];if(n[Lt]&P){for(var Nt=Et,zt=Rt-1;zt>=0;zt--)if(!(n[Ut[zt]]&s)){Nt=n[Ut[zt]];break}d(Lt,Nt&(r|V)?U:Nt)}}if(c.get(M))for(var Ot=0;Ot<Ut.length;Ot++){var kt=Ut[Ot];if(n[kt]&M)for(var Ft=Ot-1;Ft>=-1;Ft--){var Bt=-1===Ft?Et:n[Ut[Ft]];if(Bt&a){Bt===I&&d(kt,T);break}}}if(c.get(I))for(var Vt=0;Vt<Ut.length;Vt++){var Gt=Ut[Vt];n[Gt]&I&&d(Gt,S)}if(c.get(b)||c.get(C))for(var Ht=1;Ht<Ut.length-1;Ht++){var Wt=Ut[Ht];if(n[Wt]&(b|C)){for(var jt=0,Xt=0,qt=Ht-1;qt>=0&&(jt=n[Ut[qt]])&s;qt--);for(var Yt=Ht+1;Yt<Ut.length&&(Xt=n[Ut[Yt]])&s;Yt++);jt===Xt&&(n[Wt]===b?jt===M:jt&(M|T))&&d(Wt,jt)}}if(c.get(M))for(var Zt=0;Zt<Ut.length;Zt++){var $t=Ut[Zt];if(n[$t]&M){for(var Jt=Zt-1;Jt>=0&&n[Ut[Jt]]&(w|s);Jt--)d(Ut[Jt],M);for(Zt++;Zt<Ut.length&&n[Ut[Zt]]&(w|s|M);Zt++)n[Ut[Zt]]!==M&&d(Ut[Zt],M)}}if(c.get(w)||c.get(b)||c.get(C))for(var Qt=0;Qt<Ut.length;Qt++){var Kt=Ut[Qt];if(n[Kt]&(w|b|C)){d(Kt,U);for(var te=Qt-1;te>=0&&n[Ut[te]]&s;te--)d(Ut[te],U);for(var ee=Qt+1;ee<Ut.length&&n[Ut[ee]]&s;ee++)d(Ut[ee],U)}}if(c.get(M))for(var ne=0,ie=Et;ne<Ut.length;ne++){var re=Ut[ne],ae=n[re];ae&M?ie===y&&d(re,y):ae&a&&(ie=ae)}if(c.get(o)){for(var oe=S|M|T,se=oe|y,le=[],ce=[],he=0;he<Ut.length;he++)if(n[Ut[he]]&o){var de=t[Ut[he]],ue=void 0;if(null!==v(de)){if(!(ce.length<63))break;ce.push({char:de,seqIndex:he})}else if(null!==(ue=x(de)))for(var fe=ce.length-1;fe>=0;fe--){var pe=ce[fe].char;if(pe===ue||pe===x(_(de))||v(_(pe))===de){le.push([ce[fe].seqIndex,he]),ce.length=fe;break}}}le.sort((function(t,e){return t[0]-e[0]}));for(var me=0;me<le.length;me++){for(var ge=le[me],ve=ge[0],xe=ge[1],_e=!1,ye=0,Se=ve+1;Se<xe;Se++){var Me=Ut[Se];if(n[Me]&se){_e=!0;var be=n[Me]&oe?S:y;if(be===It){ye=be;break}}}if(_e&&!ye){ye=Et;for(var we=ve-1;we>=0;we--){var Te=Ut[we];if(n[Te]&se){var Ce=n[Te]&oe?S:y;ye=Ce!==It?Ce:It;break}}}if(ye){if(n[Ut[ve]]=n[Ut[xe]]=ye,ye!==It)for(var Ae=ve+1;Ae<Ut.length;Ae++)if(!(n[Ut[Ae]]&s)){h(t[Ut[Ae]])&P&&(n[Ut[Ae]]=ye);break}if(ye!==It)for(var De=xe+1;De<Ut.length;De++)if(!(n[Ut[De]]&s)){h(t[Ut[De]])&P&&(n[Ut[De]]=ye);break}}}for(var Ue=0;Ue<Ut.length;Ue++)if(n[Ut[Ue]]&o){for(var Ee=Ue,Pe=Ue,Ie=Et,Re=Ue-1;Re>=0;Re--){if(!(n[Ut[Re]]&s)){Ie=n[Ut[Re]]&oe?S:y;break}Ee=Re}for(var Le=Pt,Ne=Ue+1;Ne<Ut.length;Ne++){if(!(n[Ut[Ne]]&(o|s))){Le=n[Ut[Ne]]&oe?S:y;break}Pe=Ne}for(var ze=Ee;ze<=Pe;ze++)n[Ut[ze]]=Ie===Le?Ie:It;Ue=Pe}}}for(var Oe=m.start;Oe<=m.end;Oe++){var ke=u[Oe],Fe=n[Oe];if(1&ke?Fe&(y|M|T)&&u[Oe]++:Fe&S?u[Oe]++:Fe&(T|M)&&(u[Oe]+=2),Fe&s&&(u[Oe]=0===Oe?m.level:u[Oe-1]),Oe===m.end||h(t[Oe])&(D|A))for(var Be=Oe;Be>=0&&h(t[Be])&l;Be--)u[Be]=m.level}}return{levels:u,paragraphs:p};function Ve(e,i){for(var a=e;a<t.length;a++){var o=n[a];if(o&(S|I))return 1;if(o&(A|y)||i&&o===V)return 0;if(o&r){var s=Ge(a);a=-1===s?t.length:s}}return 0}function Ge(e){for(var i=1,a=e+1;a<t.length;a++){var o=n[a];if(o&A)break;if(o&V){if(0==--i)return a}else o&r&&i++}return-1}},t.getMirroredCharacter=W,t.getMirroredCharactersMap=function(t,e,n,i){var r=t.length;n=Math.max(0,null==n?0:+n),i=Math.min(r-1,null==i?r-1:+i);for(var a=new Map,o=n;o<=i;o++)if(1&e[o]){var s=W(t[o]);null!==s&&a.set(o,s)}return a},t.getReorderSegments=j,t.getReorderedIndices=X,t.getReorderedString=function(t,e,n,i){var r=X(t,e,n,i),a=[].concat(t);return r.forEach((function(n,i){a[i]=(1&e.levels[n]?W(t[n]):null)||t[n]})),a.join("")},t.openingToClosingBracket=v,Object.defineProperty(t,"__esModule",{value:!0}),t}({})}],init(t,e,n,i){const{defaultFontURL:r}=t;return n(e,i(),{defaultFontURL:r})}}),_a=Ir({name:"Typesetter",dependencies:[xa],init:t=>function(e){return new Promise((n=>{t.typeset(e,n)}))},getTransferables(t){const e=[t.glyphPositions.buffer,t.glyphIds.buffer];return t.caretPositions&&e.push(t.caretPositions.buffer),t.glyphColors&&e.push(t.glyphColors.buffer),e}}),ya={};const Sa="aTroikaGlyphIndex";class Ma extends Fi{constructor(){super(),this.detail=1,this.curveRadius=0,this.groups=[{start:0,count:1/0,materialIndex:0},{start:0,count:1/0,materialIndex:1}],this.boundingSphere=new Ut,this.boundingBox=new dt}computeBoundingSphere(){}computeBoundingBox(){}setSide(t){const e=this.getIndex().count;this.setDrawRange(t===n?e/2:0,2===t?e:e/2)}set detail(t){if(t!==this._detail){this._detail=t,("number"!=typeof t||t<1)&&(t=1);let e=function(t){let e=ya[t];if(!e){const n=new bn(1,1,t,t),i=n.clone(),r=n.attributes,a=i.attributes,o=new je,s=r.uv.count;for(let t=0;t<s;t++)a.position.array[3*t]*=-1,a.normal.array[3*t+2]*=-1;["position","normal","uv"].forEach((t=>{o.setAttribute(t,new Oe([...r[t].array,...a[t].array],r[t].itemSize))})),o.setIndex([...n.index.array,...i.index.array.map((t=>t+s))]),o.translate(.5,.5,0),e=ya[t]=o}return e}(t);["position","normal","uv"].forEach((t=>{this.attributes[t]=e.attributes[t].clone()})),this.setIndex(e.getIndex().clone())}}get detail(){return this._detail}set curveRadius(t){t!==this._curveRadius&&(this._curveRadius=t,this._updateBounds())}get curveRadius(){return this._curveRadius}updateGlyphs(t,e,n,i,r){ba(this,"aTroikaGlyphBounds",t,4),ba(this,Sa,e,1),ba(this,"aTroikaGlyphColor",r,3),this._blockBounds=n,this._chunkedBounds=i,this.instanceCount=e.length,this._updateBounds()}_updateBounds(){const t=this._blockBounds;if(t){const{curveRadius:e,boundingBox:n}=this;if(e){const{PI:i,floor:r,min:a,max:o,sin:s,cos:l}=Math,c=i/2,h=2*i,d=Math.abs(e),u=t[0]/d,f=t[2]/d,p=r((u+c)/h)!==r((f+c)/h)?-d:a(s(u)*d,s(f)*d),m=r((u-c)/h)!==r((f-c)/h)?d:o(s(u)*d,s(f)*d),g=r((u+i)/h)!==r((f+i)/h)?2*d:o(d-l(u)*d,d-l(f)*d);n.min.set(p,t[1],e<0?-g:0),n.max.set(m,t[3],e<0?0:g)}else n.min.set(t[0],t[1],0),n.max.set(t[2],t[3],0);n.getBoundingSphere(this.boundingSphere)}}applyClipRect(t){let e=this.getAttribute(Sa).count,n=this._chunkedBounds;if(n)for(let i=n.length;i--;){e=n[i].end;let r=n[i].rect;if(r[1]<t.w&&r[3]>t.y&&r[0]<t.z&&r[2]>t.x)break}this.instanceCount=e}}function ba(t,e,n,i){const r=t.getAttribute(e);n?r&&r.array.length===n.length?(r.array.set(n),r.needsUpdate=!0):(t.setAttribute(e,new si(n,i)),delete t._maxInstanceCount,t.dispose()):r&&t.deleteAttribute(e)}const wa="\nuniform vec2 uTroikaSDFTextureSize;\nuniform float uTroikaSDFGlyphSize;\nuniform vec4 uTroikaTotalBounds;\nuniform vec4 uTroikaClipRect;\nuniform mat3 uTroikaOrient;\nuniform bool uTroikaUseGlyphColors;\nuniform float uTroikaDistanceOffset;\nuniform float uTroikaBlurRadius;\nuniform vec2 uTroikaPositionOffset;\nuniform float uTroikaCurveRadius;\nattribute vec4 aTroikaGlyphBounds;\nattribute float aTroikaGlyphIndex;\nattribute vec3 aTroikaGlyphColor;\nvarying vec2 vTroikaGlyphUV;\nvarying vec4 vTroikaTextureUVBounds;\nvarying float vTroikaTextureChannel;\nvarying vec3 vTroikaGlyphColor;\nvarying vec2 vTroikaGlyphDimensions;\n",Ta="\nvec4 bounds = aTroikaGlyphBounds;\nbounds.xz += uTroikaPositionOffset.x;\nbounds.yw -= uTroikaPositionOffset.y;\n\nvec4 outlineBounds = vec4(\n bounds.xy - uTroikaDistanceOffset - uTroikaBlurRadius,\n bounds.zw + uTroikaDistanceOffset + uTroikaBlurRadius\n);\nvec4 clippedBounds = vec4(\n clamp(outlineBounds.xy, uTroikaClipRect.xy, uTroikaClipRect.zw),\n clamp(outlineBounds.zw, uTroikaClipRect.xy, uTroikaClipRect.zw)\n);\n\nvec2 clippedXY = (mix(clippedBounds.xy, clippedBounds.zw, position.xy) - bounds.xy) / (bounds.zw - bounds.xy);\n\nposition.xy = mix(bounds.xy, bounds.zw, clippedXY);\n\nuv = (position.xy - uTroikaTotalBounds.xy) / (uTroikaTotalBounds.zw - uTroikaTotalBounds.xy);\n\nfloat rad = uTroikaCurveRadius;\nif (rad != 0.0) {\n float angle = position.x / rad;\n position.xz = vec2(sin(angle) * rad, rad - cos(angle) * rad);\n normal.xz = vec2(sin(angle), cos(angle));\n}\n \nposition = uTroikaOrient * position;\nnormal = uTroikaOrient * normal;\n\nvTroikaGlyphUV = clippedXY.xy;\nvTroikaGlyphDimensions = vec2(bounds[2] - bounds[0], bounds[3] - bounds[1]);\n\n\nfloat txCols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize;\nvec2 txUvPerSquare = uTroikaSDFGlyphSize / uTroikaSDFTextureSize;\nvec2 txStartUV = txUvPerSquare * vec2(\n mod(floor(aTroikaGlyphIndex / 4.0), txCols),\n floor(floor(aTroikaGlyphIndex / 4.0) / txCols)\n);\nvTroikaTextureUVBounds = vec4(txStartUV, vec2(txStartUV) + txUvPerSquare);\nvTroikaTextureChannel = mod(aTroikaGlyphIndex, 4.0);\n",Ca="\nuniform sampler2D uTroikaSDFTexture;\nuniform vec2 uTroikaSDFTextureSize;\nuniform float uTroikaSDFGlyphSize;\nuniform float uTroikaSDFExponent;\nuniform float uTroikaDistanceOffset;\nuniform float uTroikaFillOpacity;\nuniform float uTroikaOutlineOpacity;\nuniform float uTroikaBlurRadius;\nuniform vec3 uTroikaStrokeColor;\nuniform float uTroikaStrokeWidth;\nuniform float uTroikaStrokeOpacity;\nuniform bool uTroikaSDFDebug;\nvarying vec2 vTroikaGlyphUV;\nvarying vec4 vTroikaTextureUVBounds;\nvarying float vTroikaTextureChannel;\nvarying vec2 vTroikaGlyphDimensions;\n\nfloat troikaSdfValueToSignedDistance(float alpha) {\n // Inverse of exponential encoding in webgl-sdf-generator\n \n float maxDimension = max(vTroikaGlyphDimensions.x, vTroikaGlyphDimensions.y);\n float absDist = (1.0 - pow(2.0 * (alpha > 0.5 ? 1.0 - alpha : alpha), 1.0 / uTroikaSDFExponent)) * maxDimension;\n float signedDist = absDist * (alpha > 0.5 ? -1.0 : 1.0);\n return signedDist;\n}\n\nfloat troikaGlyphUvToSdfValue(vec2 glyphUV) {\n vec2 textureUV = mix(vTroikaTextureUVBounds.xy, vTroikaTextureUVBounds.zw, glyphUV);\n vec4 rgba = texture2D(uTroikaSDFTexture, textureUV);\n float ch = floor(vTroikaTextureChannel + 0.5); //NOTE: can't use round() in WebGL1\n return ch == 0.0 ? rgba.r : ch == 1.0 ? rgba.g : ch == 2.0 ? rgba.b : rgba.a;\n}\n\nfloat troikaGlyphUvToDistance(vec2 uv) {\n return troikaSdfValueToSignedDistance(troikaGlyphUvToSdfValue(uv));\n}\n\nfloat troikaGetAADist() {\n \n #if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300\n return length(fwidth(vTroikaGlyphUV * vTroikaGlyphDimensions)) * 0.5;\n #else\n return vTroikaGlyphDimensions.x / 64.0;\n #endif\n}\n\nfloat troikaGetFragDistValue() {\n vec2 clampedGlyphUV = clamp(vTroikaGlyphUV, 0.5 / uTroikaSDFGlyphSize, 1.0 - 0.5 / uTroikaSDFGlyphSize);\n float distance = troikaGlyphUvToDistance(clampedGlyphUV);\n \n // Extrapolate distance when outside bounds:\n distance += clampedGlyphUV == vTroikaGlyphUV ? 0.0 : \n length((vTroikaGlyphUV - clampedGlyphUV) * vTroikaGlyphDimensions);\n\n \n\n return distance;\n}\n\nfloat troikaGetEdgeAlpha(float distance, float distanceOffset, float aaDist) {\n #if defined(IS_DEPTH_MATERIAL) || defined(IS_DISTANCE_MATERIAL)\n float alpha = step(-distanceOffset, -distance);\n #else\n\n float alpha = smoothstep(\n distanceOffset + aaDist,\n distanceOffset - aaDist,\n distance\n );\n #endif\n\n return alpha;\n}\n",Aa="\nfloat aaDist = troikaGetAADist();\nfloat fragDistance = troikaGetFragDistValue();\nfloat edgeAlpha = uTroikaSDFDebug ?\n troikaGlyphUvToSdfValue(vTroikaGlyphUV) :\n troikaGetEdgeAlpha(fragDistance, uTroikaDistanceOffset, max(aaDist, uTroikaBlurRadius));\n\n#if !defined(IS_DEPTH_MATERIAL) && !defined(IS_DISTANCE_MATERIAL)\nvec4 fillRGBA = gl_FragColor;\nfillRGBA.a *= uTroikaFillOpacity;\nvec4 strokeRGBA = uTroikaStrokeWidth == 0.0 ? fillRGBA : vec4(uTroikaStrokeColor, uTroikaStrokeOpacity);\nif (fillRGBA.a == 0.0) fillRGBA.rgb = strokeRGBA.rgb;\ngl_FragColor = mix(fillRGBA, strokeRGBA, smoothstep(\n -uTroikaStrokeWidth - aaDist,\n -uTroikaStrokeWidth + aaDist,\n fragDistance\n));\ngl_FragColor.a *= edgeAlpha;\n#endif\n\nif (edgeAlpha == 0.0) {\n discard;\n}\n";const Da=new Pe({color:16777215,side:2,transparent:!0}),Ua=8421504,Ea=new kt,Pa=new lt,Ia=new lt,Ra=[],La=new lt,Na="+x+y";function za(t){return Array.isArray(t)?t[0]:t}let Oa=()=>{const t=new hn(new bn(1,1),Da);return Oa=()=>t,t},ka=()=>{const t=new hn(new bn(1,1,32,1),Da);return ka=()=>t,t};const Fa={type:"syncstart"},Ba={type:"synccomplete"},Va=["font","fontSize","letterSpacing","lineHeight","maxWidth","overflowWrap","text","direction","textAlign","textIndent","whiteSpace","anchorX","anchorY","colorRanges","sdfGlyphSize"],Ga=Va.concat("material","color","depthOffset","clipRect","curveRadius","orientation","glyphGeometryDetail");class Ha extends hn{constructor(){super(new Ma,null),this.text="",this.anchorX=0,this.anchorY=0,this.curveRadius=0,this.direction="auto",this.font=null,this.fontSize=.1,this.letterSpacing=0,this.lineHeight="normal",this.maxWidth=1/0,this.overflowWrap="normal",this.textAlign="left",this.textIndent=0,this.whiteSpace="normal",this.material=null,this.color=null,this.colorRanges=null,this.outlineWidth=0,this.outlineColor=0,this.outlineOpacity=1,this.outlineBlur=0,this.outlineOffsetX=0,this.outlineOffsetY=0,this.strokeWidth=0,this.strokeColor=Ua,this.strokeOpacity=1,this.fillOpacity=1,this.depthOffset=0,this.clipRect=null,this.orientation=Na,this.glyphGeometryDetail=1,this.sdfGlyphSize=null,this.gpuAccelerateSDF=!0,this.debugSDF=!1}sync(t){this._needsSync&&(this._needsSync=!1,this._isSyncing?(this._queuedSyncs||(this._queuedSyncs=[])).push(t):(this._isSyncing=!0,this.dispatchEvent(Fa),pa({text:this.text,font:this.font,fontSize:this.fontSize||.1,letterSpacing:this.letterSpacing||0,lineHeight:this.lineHeight||"normal",maxWidth:this.maxWidth,direction:this.direction||"auto",textAlign:this.textAlign,textIndent:this.textIndent,whiteSpace:this.whiteSpace,overflowWrap:this.overflowWrap,anchorX:this.anchorX,anchorY:this.anchorY,colorRanges:this.colorRanges,includeCaretPositions:!0,sdfGlyphSize:this.sdfGlyphSize,gpuAccelerateSDF:this.gpuAccelerateSDF},(e=>{this._isSyncing=!1,this._textRenderInfo=e,this.geometry.updateGlyphs(e.glyphBounds,e.glyphAtlasIndices,e.blockBounds,e.chunkedBounds,e.glyphColors);const n=this._queuedSyncs;n&&(this._queuedSyncs=null,this._needsSync=!0,this.sync((()=>{n.forEach((t=>t&&t()))}))),this.dispatchEvent(Ba),t&&t()}))))}onBeforeRender(t,n,i,r,a,o){this.sync(),a.isTroikaTextMaterial&&this._prepareForRender(a),a._hadOwnSide=a.hasOwnProperty("side"),this.geometry.setSide(a._actualSide=a.side),a.side=e}onAfterRender(t,e,n,i,r,a){r._hadOwnSide?r.side=r._actualSide:delete r.side}dispose(){this.geometry.dispose()}get textRenderInfo(){return this._textRenderInfo||null}get material(){let t=this._derivedMaterial;const e=this._baseMaterial||this._defaultMaterial||(this._defaultMaterial=Da.clone());if(t&&t.baseMaterial===e||(t=this._derivedMaterial=function(t){const e=Wr(t,{chained:!0,extensions:{derivatives:!0},uniforms:{uTroikaSDFTexture:{value:null},uTroikaSDFTextureSize:{value:new k},uTroikaSDFGlyphSize:{value:0},uTroikaSDFExponent:{value:0},uTroikaTotalBounds:{value:new rt(0,0,0,0)},uTroikaClipRect:{value:new rt(0,0,0,0)},uTroikaDistanceOffset:{value:0},uTroikaOutlineOpacity:{value:0},uTroikaFillOpacity:{value:1},uTroikaPositionOffset:{value:new k},uTroikaCurveRadius:{value:0},uTroikaBlurRadius:{value:0},uTroikaStrokeWidth:{value:0},uTroikaStrokeColor:{value:new Ae},uTroikaStrokeOpacity:{value:1},uTroikaOrient:{value:new F},uTroikaUseGlyphColors:{value:!0},uTroikaSDFDebug:{value:!1}},vertexDefs:wa,vertexTransform:Ta,fragmentDefs:Ca,fragmentColorTransform:Aa,customRewriter({vertexShader:t,fragmentShader:e}){let n=/\buniform\s+vec3\s+diffuse\b/;return n.test(e)&&(e=e.replace(n,"varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g,"vTroikaGlyphColor"),n.test(t)||(t=t.replace(zr,"uniform vec3 diffuse;\n$&\nvTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;\n"))),{vertexShader:t,fragmentShader:e}}});return e.transparent=!0,Object.defineProperties(e,{isTroikaTextMaterial:{value:!0},shadowSide:{get(){return this.side},set(){}}}),e}(e),e.addEventListener("dispose",(function n(){e.removeEventListener("dispose",n),t.dispose()}))),this.outlineWidth||this.outlineBlur||this.outlineOffsetX||this.outlineOffsetY){let e=t._outlineMtl;return e||(e=t._outlineMtl=Object.create(t,{id:{value:t.id+.1}}),e.isTextOutlineMaterial=!0,e.depthWrite=!1,e.map=null,t.addEventListener("dispose",(function n(){t.removeEventListener("dispose",n),e.dispose()}))),[e,t]}return t}set material(t){t&&t.isTroikaTextMaterial?(this._derivedMaterial=t,this._baseMaterial=t.baseMaterial):this._baseMaterial=t}get glyphGeometryDetail(){return this.geometry.detail}set glyphGeometryDetail(t){this.geometry.detail=t}get curveRadius(){return this.geometry.curveRadius}set curveRadius(t){this.geometry.curveRadius=t}get customDepthMaterial(){return za(this.material).getDepthMaterial()}get customDistanceMaterial(){return za(this.material).getDistanceMaterial()}_prepareForRender(t){const e=t.isTextOutlineMaterial,n=t.uniforms,i=this.textRenderInfo;if(i){const{sdfTexture:t,blockBounds:r}=i;n.uTroikaSDFTexture.value=t,n.uTroikaSDFTextureSize.value.set(t.image.width,t.image.height),n.uTroikaSDFGlyphSize.value=i.sdfGlyphSize,n.uTroikaSDFExponent.value=i.sdfExponent,n.uTroikaTotalBounds.value.fromArray(r),n.uTroikaUseGlyphColors.value=!e&&!!i.glyphColors;let a,o,s,l=0,c=0,h=0,d=0,u=0;if(e){let{outlineWidth:t,outlineOffsetX:e,outlineOffsetY:n,outlineBlur:i,outlineOpacity:r}=this;l=this._parsePercent(t)||0,c=Math.max(0,this._parsePercent(i)||0),a=r,d=this._parsePercent(e)||0,u=this._parsePercent(n)||0}else h=Math.max(0,this._parsePercent(this.strokeWidth)||0),h&&(s=this.strokeColor,n.uTroikaStrokeColor.value.set(null==s?Ua:s),o=this.strokeOpacity,null==o&&(o=1)),a=this.fillOpacity;n.uTroikaDistanceOffset.value=l,n.uTroikaPositionOffset.value.set(d,u),n.uTroikaBlurRadius.value=c,n.uTroikaStrokeWidth.value=h,n.uTroikaStrokeOpacity.value=o,n.uTroikaFillOpacity.value=null==a?1:a,n.uTroikaCurveRadius.value=this.curveRadius||0;let f=this.clipRect;if(f&&Array.isArray(f)&&4===f.length)n.uTroikaClipRect.value.fromArray(f);else{const t=100*(this.fontSize||.1);n.uTroikaClipRect.value.set(r[0]-t,r[1]-t,r[2]+t,r[3]+t)}this.geometry.applyClipRect(n.uTroikaClipRect.value)}n.uTroikaSDFDebug.value=!!this.debugSDF,t.polygonOffset=!!this.depthOffset,t.polygonOffsetFactor=t.polygonOffsetUnits=this.depthOffset||0;const r=e?this.outlineColor||0:this.color;if(null==r)delete t.color;else{const e=t.hasOwnProperty("color")?t.color:t.color=new Ae;r===e._input&&"object"!=typeof r||e.set(e._input=r)}let a=this.orientation||Na;if(a!==t._orientation){let e=n.uTroikaOrient.value;a=a.replace(/[^-+xyz]/g,"");let i=a!==Na&&a.match(/^([-+])([xyz])([-+])([xyz])$/);if(i){let[,t,n,r,a]=i;Pa.set(0,0,0)[n]="-"===t?1:-1,Ia.set(0,0,0)[a]="-"===r?-1:1,Ea.lookAt(La,Pa.cross(Ia),Ia),e.setFromMatrix4(Ea)}else e.identity();t._orientation=a}}_parsePercent(t){if("string"==typeof t){let e=t.match(/^(-?[\d.]+)%$/),n=e?parseFloat(e[1]):NaN;t=(isNaN(n)?0:n/100)*this.fontSize}return t}localPositionToTextCoords(t,e=new k){e.copy(t);const n=this.curveRadius;return n&&(e.x=Math.atan2(t.x,Math.abs(n)-Math.abs(t.z))*Math.abs(n)),e}worldPositionToTextCoords(t,e=new k){return Pa.copy(t),this.localPositionToTextCoords(this.worldToLocal(Pa),e)}raycast(t,e){const{textRenderInfo:n,curveRadius:i}=this;if(n){const r=n.blockBounds,a=i?ka():Oa(),o=a.geometry,{position:s,uv:l}=o.attributes;for(let t=0;t<l.count;t++){let e=r[0]+l.getX(t)*(r[2]-r[0]);const n=r[1]+l.getY(t)*(r[3]-r[1]);let a=0;i&&(a=i-Math.cos(e/i)*i,e=Math.sin(e/i)*i),s.setXYZ(t,e,n,a)}o.boundingSphere=this.geometry.boundingSphere,o.boundingBox=this.geometry.boundingBox,a.matrixWorld=this.matrixWorld,a.material.side=this.material.side,Ra.length=0,a.raycast(t,Ra);for(let t=0;t<Ra.length;t++)Ra[t].object=this,e.push(Ra[t])}}copy(t){const e=this.geometry;return super.copy(t),this.geometry=e,Ga.forEach((e=>{this[e]=t[e]})),this}clone(){return(new this.constructor).copy(this)}}Va.forEach((t=>{const e="_private_"+t;Object.defineProperty(Ha.prototype,t,{get(){return this[e]},set(t){t!==this[e]&&(this[e]=t,this._needsSync=!0)}})}));const Wa=["onSync","onPreloadEnd","characters"];function ja(t){return Object.keys(t).reduce(((e,n)=>(-1===Wa.indexOf(n)&&(e[n]=t[n]),e)),{})}const Xa=({sdfGlyphSize:t=64,anchorX:e="center",anchorY:n="middle",fontSize:i=1,...r})=>{const a={sdfGlyphSize:t,anchorX:e,anchorY:n,fontSize:i,...r},o=new Ha;return Object.assign(o,ja(a)),a.font&&a.characters&&function({font:t,characters:e,sdfGlyphSize:n},i){pa({font:t,sdfGlyphSize:n,text:Array.isArray(e)?e.join("\n"):""+e},i)}({font:a.font,characters:a.characters},(()=>{a.onPreloadEnd&&a.onPreloadEnd()})),{mesh:o,updateProps(t){Object.assign(o,ja(t)),o.sync((()=>{a.onSync&&a.onSync(o)}))},dispose(){o.dispose()}}},qa=Xi({alphaTest:0,viewport:new k(1980,1080),focal:1e3,centerAndScaleTexture:null,covAndColorTexture:null},"\n precision highp sampler2D;\n precision highp usampler2D;\n out vec4 vColor;\n out vec3 vPosition;\n uniform vec2 resolution;\n uniform vec2 viewport;\n uniform float focal;\n attribute uint splatIndex;\n uniform sampler2D centerAndScaleTexture;\n uniform usampler2D covAndColorTexture; \n\n vec2 unpackInt16(in uint value) {\n int v = int(value);\n int v0 = v >> 16;\n int v1 = (v & 0xFFFF);\n if((v & 0x8000) != 0)\n v1 |= 0xFFFF0000;\n return vec2(float(v1), float(v0));\n }\n\n void main () {\n ivec2 texSize = textureSize(centerAndScaleTexture, 0);\n ivec2 texPos = ivec2(splatIndex%uint(texSize.x), splatIndex/uint(texSize.x));\n vec4 centerAndScaleData = texelFetch(centerAndScaleTexture, texPos, 0);\n vec4 center = vec4(centerAndScaleData.xyz, 1);\n vec4 camspace = modelViewMatrix * center;\n vec4 pos2d = projectionMatrix * camspace;\n\n float bounds = 1.2 * pos2d.w;\n if (pos2d.z < -pos2d.w || pos2d.x < -bounds || pos2d.x > bounds\n || pos2d.y < -bounds || pos2d.y > bounds) {\n gl_Position = vec4(0.0, 0.0, 2.0, 1.0);\n return;\n }\n\n uvec4 covAndColorData = texelFetch(covAndColorTexture, texPos, 0);\n vec2 cov3D_M11_M12 = unpackInt16(covAndColorData.x) * centerAndScaleData.w;\n vec2 cov3D_M13_M22 = unpackInt16(covAndColorData.y) * centerAndScaleData.w;\n vec2 cov3D_M23_M33 = unpackInt16(covAndColorData.z) * centerAndScaleData.w;\n mat3 Vrk = mat3(\n cov3D_M11_M12.x, cov3D_M11_M12.y, cov3D_M13_M22.x,\n cov3D_M11_M12.y, cov3D_M13_M22.y, cov3D_M23_M33.x,\n cov3D_M13_M22.x, cov3D_M23_M33.x, cov3D_M23_M33.y\n );\n\n mat3 J = mat3(\n focal / camspace.z, 0., -(focal * camspace.x) / (camspace.z * camspace.z),\n 0., focal / camspace.z, -(focal * camspace.y) / (camspace.z * camspace.z),\n 0., 0., 0.\n );\n\n mat3 W = transpose(mat3(modelViewMatrix));\n mat3 T = W * J;\n mat3 cov = transpose(T) * Vrk * T;\n vec2 vCenter = vec2(pos2d) / pos2d.w;\n float diagonal1 = cov[0][0] + 0.3;\n float offDiagonal = cov[0][1];\n float diagonal2 = cov[1][1] + 0.3;\n float mid = 0.5 * (diagonal1 + diagonal2);\n float radius = length(vec2((diagonal1 - diagonal2) / 2.0, offDiagonal));\n float lambda1 = mid + radius;\n float lambda2 = max(mid - radius, 0.1);\n vec2 diagonalVector = normalize(vec2(offDiagonal, lambda1 - diagonal1));\n vec2 v1 = min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector;\n vec2 v2 = min(sqrt(2.0 * lambda2), 1024.0) * vec2(diagonalVector.y, -diagonalVector.x);\n uint colorUint = covAndColorData.w;\n vColor = vec4(\n float(colorUint & uint(0xFF)) / 255.0,\n float((colorUint >> uint(8)) & uint(0xFF)) / 255.0,\n float((colorUint >> uint(16)) & uint(0xFF)) / 255.0,\n float(colorUint >> uint(24)) / 255.0\n );\n vPosition = position;\n\n gl_Position = vec4(\n vCenter \n + position.x * v2 / viewport * 2.0 \n + position.y * v1 / viewport * 2.0, pos2d.z / pos2d.w, 1.0);\n }\n ",`\n #include <alphatest_pars_fragment>\n #include <alphahash_pars_fragment>\n in vec4 vColor;\n in vec3 vPosition;\n void main () {\n float A = -dot(vPosition.xy, vPosition.xy);\n if (A < -4.0) discard;\n float B = exp(A) * vColor.a;\n vec4 diffuseColor = vec4(vColor.rgb, B);\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n gl_FragColor = diffuseColor;\n #include <tonemapping_fragment>\n #include <${parseInt(t.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n `);function Ya(t){let e=null,n=0;t.onmessage=i=>{if("push"==i.data.method){0===n&&(e=new Float32Array(i.data.length));const t=new Float32Array(i.data.matrices);e.set(t,n),n+=t.length}else if("sort"==i.data.method&&null!==e){const n=function(t,n=!1){const i=e.length/16;let r=-1/0,a=1/0;const o=new Float32Array(i),s=new Int32Array(o.buffer),l=new Int32Array(i);let c=0;for(let s=0;s<i;s++){const i=t[0]*e[16*s+12]+t[1]*e[16*s+13]+t[2]*e[16*s+14]+t[3];(n||i<0&&e[16*s+15]>-1e-4*i)&&(o[c]=i,l[c]=s,c++,i>r&&(r=i),i<a&&(a=i))}const h=65535/(r-a),d=new Uint32Array(65536);for(let t=0;t<c;t++)s[t]=(o[t]-a)*h|0,d[s[t]]++;const u=new Uint32Array(65536);for(let t=1;t<65536;t++)u[t]=u[t-1]+d[t-1];const f=new Uint32Array(c);for(let t=0;t<c;t++)f[u[s[t]]++]=l[t];return f}(new Float32Array(i.data.view),i.data.hashed);t.postMessage({indices:n,key:i.data.key},[n.buffer])}}}class Za extends zi{constructor(t,e=25e3){super(),this.gl=t,this.chunkSize=e}async loadAsync(t,e,n){return new Promise((i=>this.load(t,i,e,n)))}load(t,e,n,i){const r={gl:this.gl,url:this.manager.resolveURL(t),worker:new Worker(URL.createObjectURL(new Blob(["(",Ya.toString(),")(self)"],{type:"application/javascript"}))),manager:this.manager,update:(t,e,n)=>function(t,e,n,i){if(t.updateMatrixWorld(),e.gl.getCurrentViewport(n.viewport),n.material.viewport.x=n.viewport.z,n.material.viewport.y=n.viewport.w,n.material.focal=n.viewport.w/2*Math.abs(t.projectionMatrix.elements[5]),n.ready){if(i&&n.sorted)return;n.ready=!1;const t=new Float32Array([n.modelViewMatrix.elements[2],-n.modelViewMatrix.elements[6],n.modelViewMatrix.elements[10],n.modelViewMatrix.elements[14]]);e.worker.postMessage({method:"sort",src:e.url,key:n.uuid,view:t.buffer,hashed:i},[t.buffer]),i&&e.loaded&&(n.sorted=!0)}}(e,r,t,n),connect:t=>function(t,e){t.loading||async function(t){t.loading=!0;let e=0,n=0;const i=[];let r=0;const a=0!==t.totalDownloadBytes;for(;;)try{const{value:o,done:s}=await t.stream.read();if(s)break;if(e+=o.length,null!=t.totalDownloadBytes){const n=e/t.totalDownloadBytes*100;if(t.onProgress&&n-r>1){const i=new ProgressEvent("progress",{lengthComputable:a,loaded:e,total:t.totalDownloadBytes});t.onProgress(i),r=n}}i.push(o);const l=e-n;if(null!=t.totalDownloadBytes&&l>t.rowLength*t.chunkSize){const e=Math.floor(l/t.rowLength),r=new Uint8Array(l);let o=0;for(const t of i)r.set(t,o),o+=t.length;if(i.length=0,l>e*t.rowLength){const n=new Uint8Array(l-e*t.rowLength);n.set(r.subarray(l-n.length,l),0),i.push(n)}const s=new Uint8Array(e*t.rowLength);s.set(r.subarray(0,s.byteLength),0);const c=$a(t,s.buffer,e);if(t.worker.postMessage({method:"push",src:t.url,length:16*t.numVertices,matrices:c.buffer},[c.buffer]),n+=e*t.rowLength,t.onProgress){const e=new ProgressEvent("progress",{lengthComputable:a,loaded:t.totalDownloadBytes,total:t.totalDownloadBytes});t.onProgress(e)}}}catch(t){console.error(t);break}if(e-n>0){const e=new Uint8Array(i.reduce(((t,e)=>t+e.length),0));let n=0;for(const t of i)e.set(t,n),n+=t.length;const r=Math.floor(e.byteLength/t.rowLength),a=$a(t,e.buffer,r);t.worker.postMessage({method:"push",src:t.url,length:16*r,matrices:a.buffer},[a.buffer])}t.loaded=!0,t.manager.itemEnd(t.url)}(t);e.ready=!1,e.pm=new kt,e.vm1=new kt,e.vm2=new kt,e.viewport=new rt;const n=new Uint32Array(t.bufferTextureWidth*t.bufferTextureHeight),i=new si(n,1,!1);i.setUsage(b);const r=e.geometry=new Fi,a=new Float32Array(18),o=new Le(a,3);function s(t){if(e&&t.data.key===e.uuid){const n=new Uint32Array(t.data.indices);r.attributes.splatIndex.set(n),r.attributes.splatIndex.needsUpdate=!0,r.instanceCount=n.length,e.ready=!0}}async function l(){for(;;){const e=t.gl.properties.get(t.centerAndScaleTexture),n=t.gl.properties.get(t.covAndColorTexture);if(null!=e&&e.__webglTexture&&null!=n&&n.__webglTexture&&t.loadedVertexCount>0)break;await new Promise((t=>setTimeout(t,10)))}e.ready=!0}return r.setAttribute("position",o),o.setXYZ(2,-2,2,0),o.setXYZ(1,2,2,0),o.setXYZ(0,-2,-2,0),o.setXYZ(5,-2,-2,0),o.setXYZ(4,2,2,0),o.setXYZ(3,2,-2,0),o.needsUpdate=!0,r.setAttribute("splatIndex",i),r.instanceCount=1,t.worker.addEventListener("message",s),l(),()=>t.worker.removeEventListener("message",s)}(r,t),loading:!1,loaded:!1,loadedVertexCount:0,chunkSize:this.chunkSize,totalDownloadBytes:0,numVertices:0,rowLength:32,maxVertexes:0,bufferTextureWidth:0,bufferTextureHeight:0,stream:null,centerAndScaleData:null,covAndColorData:null,covAndColorTexture:null,centerAndScaleTexture:null,onProgress:n};(async function(t){t.manager.itemStart(t.url);const e=await fetch(t.url);if(null===e.body)throw"Failed to fetch file";const n=e.headers.get("Content-Length"),i=n?parseInt(n):void 0;if(null==i)throw"Failed to get content length";t.stream=e.body.getReader(),t.totalDownloadBytes=i,t.numVertices=Math.floor(t.totalDownloadBytes/t.rowLength);const r=t.gl.getContext(),a=r.getParameter(r.MAX_TEXTURE_SIZE);t.maxVertexes=a*a,t.numVertices>t.maxVertexes&&(t.numVertices=t.maxVertexes);return t.bufferTextureWidth=a,t.bufferTextureHeight=Math.floor((t.numVertices-1)/a)+1,t.centerAndScaleData=new Float32Array(t.bufferTextureWidth*t.bufferTextureHeight*4),t.covAndColorData=new Uint32Array(t.bufferTextureWidth*t.bufferTextureHeight*4),t.centerAndScaleTexture=new oi(t.centerAndScaleData,t.bufferTextureWidth,t.bufferTextureHeight,d,c),t.centerAndScaleTexture.needsUpdate=!0,t.covAndColorTexture=new oi(t.covAndColorData,t.bufferTextureWidth,t.bufferTextureHeight,f,l),t.covAndColorTexture.internalFormat="RGBA32UI",t.covAndColorTexture.needsUpdate=!0,t})(r).then(e).catch((t=>{null==i||i(t),r.manager.itemError(r.url)}))}}function $a(t,e,n){const i=t.gl.getContext();if(t.loadedVertexCount+n>t.maxVertexes&&(n=t.maxVertexes-t.loadedVertexCount),n<=0)throw"Failed to parse file";const r=new Uint8Array(e),a=new Float32Array(e),o=new Float32Array(16*n),s=new Uint8Array(t.covAndColorData.buffer),l=new Int16Array(t.covAndColorData.buffer);for(let e=0;e<n;e++){const n=new st(-(r[32*e+28+1]-128)/128,(r[32*e+28+2]-128)/128,(r[32*e+28+3]-128)/128,-(r[32*e+28+0]-128)/128);n.invert();const i=new lt(a[8*e+0],a[8*e+1],-a[8*e+2]),c=new lt(a[8*e+3+0],a[8*e+3+1],a[8*e+3+2]),h=new kt;h.makeRotationFromQuaternion(n),h.transpose(),h.scale(c);const d=h.clone();h.transpose(),h.premultiply(d),h.setPosition(i);const u=[0,1,2,5,6,10];let f=0;for(let t=0;t<u.length;t++)Math.abs(h.elements[u[t]])>f&&(f=Math.abs(h.elements[u[t]]));let p=4*t.loadedVertexCount+4*e;t.centerAndScaleData[p+0]=i.x,t.centerAndScaleData[p+1]=-i.y,t.centerAndScaleData[p+2]=i.z,t.centerAndScaleData[p+3]=f/32767,p=8*t.loadedVertexCount+4*e*2;for(let t=0;t<u.length;t++)l[p+t]=32767*h.elements[u[t]]/f;p=16*t.loadedVertexCount+4*(4*e+3);const m=new Ae(r[32*e+24+0]/255,r[32*e+24+1]/255,r[32*e+24+2]/255);m.convertSRGBToLinear(),s[p+0]=255*m.r,s[p+1]=255*m.g,s[p+2]=255*m.b,s[p+3]=r[32*e+24+3],h.elements[15]=Math.max(c.x,c.y,c.z)*r[32*e+24+3]/255;for(let t=0;t<16;t++)o[16*e+t]=h.elements[t]}for(;n>0;){let e=0,r=0;const a=t.loadedVertexCount%t.bufferTextureWidth,o=Math.floor(t.loadedVertexCount/t.bufferTextureWidth);t.loadedVertexCount%t.bufferTextureWidth!=0?(e=Math.min(t.bufferTextureWidth,a+n)-a,r=1):Math.floor(n/t.bufferTextureWidth)>0?(e=t.bufferTextureWidth,r=Math.floor(n/t.bufferTextureWidth)):(e=n%t.bufferTextureWidth,r=1);const s=t.gl.properties.get(t.centerAndScaleTexture);i.bindTexture(i.TEXTURE_2D,s.__webglTexture),i.texSubImage2D(i.TEXTURE_2D,0,a,o,e,r,i.RGBA,i.FLOAT,t.centerAndScaleData,4*t.loadedVertexCount);const l=t.gl.properties.get(t.covAndColorTexture);i.bindTexture(i.TEXTURE_2D,l.__webglTexture),i.texSubImage2D(i.TEXTURE_2D,0,a,o,e,r,i.RGBA_INTEGER,i.UNSIGNED_INT,t.covAndColorData,4*t.loadedVertexCount),t.gl.resetState(),t.loadedVertexCount+=e*r,n-=e*r}return o}class Ja extends hn{constructor(t,e,{toneMapped:n=!1,alphaTest:i=0,alphaHash:r=!1}={}){super(),this.frustumCulled=!1,this.onBeforeRender=()=>t.update(this,e,r),this.material=new qa,Object.assign(this.material,{transparent:!r,depthTest:!0,alphaTest:r?0:i,centerAndScaleTexture:t.centerAndScaleTexture,covAndColorTexture:t.covAndColorTexture,depthWrite:!!r||i>0,blending:r?1:5,blendSrcAlpha:201,alphaHash:!!r,toneMapped:n}),t.connect(this)}}const Qa=Xi({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,cellThickness:.5,sectionThickness:1,cellColor:new Ae,sectionColor:new Ae,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new lt,worldPlanePosition:new lt},"\n varying vec3 localPosition;\n varying vec4 worldPosition;\n \n uniform vec3 worldCamProjPosition;\n uniform vec3 worldPlanePosition;\n uniform float fadeDistance;\n uniform bool infiniteGrid;\n uniform bool followCamera;\n \n void main() {\n localPosition = position.xzy;\n if (infiniteGrid) localPosition *= 1.0 + fadeDistance;\n \n worldPosition = modelMatrix * vec4(localPosition, 1.0);\n if (followCamera) {\n worldPosition.xyz += (worldCamProjPosition - worldPlanePosition);\n localPosition = (inverse(modelMatrix) * worldPosition).xyz;\n }\n \n gl_Position = projectionMatrix * viewMatrix * worldPosition;\n }\n ",`\n varying vec3 localPosition;\n varying vec4 worldPosition;\n \n uniform vec3 worldCamProjPosition;\n uniform float cellSize;\n uniform float sectionSize;\n uniform vec3 cellColor;\n uniform vec3 sectionColor;\n uniform float fadeDistance;\n uniform float fadeStrength;\n uniform float cellThickness;\n uniform float sectionThickness;\n \n float getGrid(float size, float thickness) {\n vec2 r = localPosition.xz / size;\n vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);\n float line = min(grid.x, grid.y) + 1.0 - thickness;\n return 1.0 - min(line, 1.0);\n }\n \n void main() {\n float g1 = getGrid(cellSize, cellThickness);\n float g2 = getGrid(sectionSize, sectionThickness);\n \n float dist = distance(worldCamProjPosition, worldPosition.xyz);\n float d = 1.0 - min(dist / fadeDistance, 1.0);\n vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2));\n \n gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength));\n gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);\n if (gl_FragColor.a <= 0.0) discard;\n \n #include <tonemapping_fragment>\n #include <${parseInt(t.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>\n }\n `),Ka=({args:t=[1,1],cellColor:e=new Ae("#000000"),sectionColor:i=new Ae("#2080ff"),cellSize:r=.5,sectionSize:a=1,followCamera:o=!1,infiniteGrid:s=!1,fadeDistance:l=100,fadeStrength:c=1,cellThickness:h=.5,sectionThickness:d=1,side:u=n}={})=>{const f=new Qa({transparent:!0,side:u,...{cellSize:r,sectionSize:a,cellColor:e,sectionColor:i,cellThickness:h,sectionThickness:d},...{fadeDistance:l,fadeStrength:c,infiniteGrid:s,followCamera:o}}),p=new bn(t[0],t[1]),m=new hn(p,f);m.frustumCulled=!1;const g=new _n,v=new lt(0,1,0),x=new lt(0,0,0);return{mesh:m,update:t=>{if(!m.parent)return;g.setFromNormalAndCoplanarPoint(v,x).applyMatrix4(m.matrixWorld);const e=m.material,n=e.uniforms.worldCamProjPosition,i=e.uniforms.worldPlanePosition;g.projectPoint(t.position,n.value),i.value.set(0,0,0).applyMatrix4(m.matrixWorld)}}};class to extends Ei{constructor({samples:t=6,transmissionSampler:e=!1,chromaticAberration:n=.05,transmission:i=0,_transmission:r=1,transmissionMap:a=null,roughness:o=0,thickness:s=0,thicknessMap:l=null,attenuationDistance:c=1/0,attenuationColor:h=new Ae("white"),anisotropicBlur:d=.1,time:u=0,distortion:f=0,distortionScale:p=.5,temporalDistortion:m=0,buffer:g=null}={}){super(),this.uniforms={chromaticAberration:{value:n},transmission:{value:i},_transmission:{value:r},transmissionMap:{value:a},roughness:{value:o},thickness:{value:s},thicknessMap:{value:l},attenuationDistance:{value:c},attenuationColor:{value:h},anisotropicBlur:{value:d},time:{value:u},distortion:{value:f},distortionScale:{value:p},temporalDistortion:{value:m},buffer:{value:g}},this.onBeforeCompile=n=>{n.uniforms={...n.uniforms,...this.uniforms},e?n.defines.USE_SAMPLER="":n.defines.USE_TRANSMISSION="",n.fragmentShader="\n uniform float chromaticAberration; \n uniform float anisotropicBlur; \n uniform float time;\n uniform float distortion;\n uniform float distortionScale;\n uniform float temporalDistortion;\n uniform sampler2D buffer;\n\n vec3 random3(vec3 c) {\n float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));\n vec3 r;\n r.z = fract(512.0*j);\n j *= .125;\n r.x = fract(512.0*j);\n j *= .125;\n r.y = fract(512.0*j);\n return r-0.5;\n }\n\n uint hash( uint x ) {\n x += ( x << 10u );\n x ^= ( x >> 6u );\n x += ( x << 3u );\n x ^= ( x >> 11u );\n x += ( x << 15u );\n return x;\n }\n\n // Compound versions of the hashing algorithm I whipped together.\n uint hash( uvec2 v ) { return hash( v.x ^ hash(v.y) ); }\n uint hash( uvec3 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ); }\n uint hash( uvec4 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ^ hash(v.w) ); }\n\n // Construct a float with half-open range [0:1] using low 23 bits.\n // All zeroes yields 0.0, all ones yields the next smallest representable value below 1.0.\n float floatConstruct( uint m ) {\n const uint ieeeMantissa = 0x007FFFFFu; // binary32 mantissa bitmask\n const uint ieeeOne = 0x3F800000u; // 1.0 in IEEE binary32\n m &= ieeeMantissa; // Keep only mantissa bits (fractional part)\n m |= ieeeOne; // Add fractional part to 1.0\n float f = uintBitsToFloat( m ); // Range [1:2]\n return f - 1.0; // Range [0:1]\n }\n\n // Pseudo-random value in half-open range [0:1].\n float randomBase( float x ) { return floatConstruct(hash(floatBitsToUint(x))); }\n float randomBase( vec2 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n float randomBase( vec3 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n float randomBase( vec4 v ) { return floatConstruct(hash(floatBitsToUint(v))); }\n float rand(float seed) {\n float result = randomBase(vec3(gl_FragCoord.xy, seed));\n return result;\n }\n\n const float F3 = 0.3333333;\n const float G3 = 0.1666667;\n\n float snoise(vec3 p) {\n vec3 s = floor(p + dot(p, vec3(F3)));\n vec3 x = p - s + dot(s, vec3(G3));\n vec3 e = step(vec3(0.0), x - x.yzx);\n vec3 i1 = e*(1.0 - e.zxy);\n vec3 i2 = 1.0 - e.zxy*(1.0 - e);\n vec3 x1 = x - i1 + G3;\n vec3 x2 = x - i2 + 2.0*G3;\n vec3 x3 = x - 1.0 + 3.0*G3;\n vec4 w, d;\n w.x = dot(x, x);\n w.y = dot(x1, x1);\n w.z = dot(x2, x2);\n w.w = dot(x3, x3);\n w = max(0.6 - w, 0.0);\n d.x = dot(random3(s), x);\n d.y = dot(random3(s + i1), x1);\n d.z = dot(random3(s + i2), x2);\n d.w = dot(random3(s + 1.0), x3);\n w *= w;\n w *= w;\n d *= w;\n return dot(d, vec4(52.0));\n }\n\n float snoiseFractal(vec3 m) {\n return 0.5333333* snoise(m)\n +0.2666667* snoise(2.0*m)\n +0.1333333* snoise(4.0*m)\n +0.0666667* snoise(8.0*m);\n }\n"+n.fragmentShader,n.fragmentShader=n.fragmentShader.replace("#include <transmission_pars_fragment>","\n #ifdef USE_TRANSMISSION\n // Transmission code is based on glTF-Sampler-Viewer\n // https://github.com/KhronosGroup/glTF-Sample-Viewer\n uniform float _transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n // Direction of refracted light.\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n // Compute rotation-independant scaling of the model matrix.\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n // The thickness is specified in local space.\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and\n // an IOR of 1.5 results in the default amount of microfacet refraction.\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); \n #ifdef USE_SAMPLER\n #ifdef texture2DLodEXT\n return texture2DLodEXT(transmissionSamplerMap, fragCoord.xy, framebufferLod);\n #else\n return texture2D(transmissionSamplerMap, fragCoord.xy, framebufferLod);\n #endif\n #else\n return texture2D(buffer, fragCoord.xy);\n #endif\n }\n vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n // Attenuation distance is +∞, i.e. the transmitted color is not attenuated at all.\n return radiance;\n } else {\n // Compute light attenuation using Beer's law.\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); // Beer's law\n return transmittance * radiance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n // Project refracted vector on the framebuffer, while mapping to normalized device coordinates.\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n // Sample framebuffer to get pixel the refracted ray hits.\n vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n // Get the specular component.\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n }\n #endif\n"),n.fragmentShader=n.fragmentShader.replace("#include <transmission_fragment>",` \n // Improve the refraction to use the world pos\n material.transmission = _transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vUv ).g;\n #endif\n \n vec3 pos = vWorldPosition;\n float runningSeed = 0.0;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = inverseTransformDirection( normal, viewMatrix );\n vec3 transmission = vec3(0.0);\n float transmissionR, transmissionB, transmissionG;\n float randomCoords = rand(runningSeed++);\n float thickness_smear = thickness * max(pow(roughnessFactor, 0.33), anisotropicBlur);\n vec3 distortionNormal = vec3(0.0);\n vec3 temporalOffset = vec3(time, -time, -time) * temporalDistortion;\n if (distortion > 0.0) {\n distortionNormal = distortion * vec3(snoiseFractal(vec3((pos * distortionScale + temporalOffset))), snoiseFractal(vec3(pos.zxy * distortionScale - temporalOffset)), snoiseFractal(vec3(pos.yxz * distortionScale + temporalOffset)));\n }\n for (float i = 0.0; i < ${t}.0; i ++) {\n vec3 sampleNorm = normalize(n + roughnessFactor * roughnessFactor * 2.0 * normalize(vec3(rand(runningSeed++) - 0.5, rand(runningSeed++) - 0.5, rand(runningSeed++) - 0.5)) * pow(rand(runningSeed++), 0.33) + distortionNormal);\n transmissionR = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness + thickness_smear * (i + randomCoords) / float(${t}),\n material.attenuationColor, material.attenuationDistance\n ).r;\n transmissionG = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + chromaticAberration * (i + randomCoords) / float(${t})) , material.thickness + thickness_smear * (i + randomCoords) / float(${t}),\n material.attenuationColor, material.attenuationDistance\n ).g;\n transmissionB = getIBLVolumeRefraction(\n sampleNorm, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.ior * (1.0 + 2.0 * chromaticAberration * (i + randomCoords) / float(${t})), material.thickness + thickness_smear * (i + randomCoords) / float(${t}),\n material.attenuationColor, material.attenuationDistance\n ).b;\n transmission.r += transmissionR;\n transmission.g += transmissionG;\n transmission.b += transmissionB;\n }\n transmission /= ${t}.0;\n totalDiffuse = mix( totalDiffuse, transmission.rgb, material.transmission );\n`)},Object.keys(this.uniforms).forEach((t=>Object.defineProperty(this,t,{get:()=>this.uniforms[t].value,set:e=>this.uniforms[t].value=e})))}}const eo=Xi({depth:null,opacity:1,attenuation:2.5,anglePower:12,spotPosition:new lt(0,0,0),lightColor:new Ae("white"),cameraNear:0,cameraFar:1,resolution:new k(0,0),transparent:!0,depthWrite:!1},"\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n varying float vViewZ;\n varying float vIntensity;\n uniform vec3 spotPosition;\n uniform float attenuation;\n\n void main() {\n // compute intensity\n vNormal = normalize( normalMatrix * normal );\n vec4 worldPosition\t= modelMatrix * vec4( position, 1.0 );\n vWorldPosition = worldPosition.xyz;\n vec4 viewPosition = viewMatrix * worldPosition;\n vViewZ = viewPosition.z;\n float intensity\t= distance(worldPosition.xyz, spotPosition) / attenuation;\n intensity\t= 1.0 - clamp(intensity, 0.0, 1.0);\n vIntensity = intensity;\n // set gl_Position\n gl_Position\t= projectionMatrix * viewPosition;\n\n }",`\n #include <packing>\n\n varying vec3 vNormal;\n varying vec3 vWorldPosition;\n uniform vec3 lightColor;\n uniform vec3 spotPosition;\n uniform float attenuation;\n uniform float anglePower;\n uniform sampler2D depth;\n uniform vec2 resolution;\n uniform float cameraNear;\n uniform float cameraFar;\n varying float vViewZ;\n varying float vIntensity;\n uniform float opacity;\n\n float readDepth( sampler2D depthSampler, vec2 coord ) {\n float fragCoordZ = texture2D( depthSampler, coord ).x;\n float viewZ = perspectiveDepthToViewZ(fragCoordZ, cameraNear, cameraFar);\n return viewZ;\n }\n\n void main() {\n float d = 1.0;\n bool isSoft = resolution[0] > 0.0 && resolution[1] > 0.0;\n if (isSoft) {\n vec2 sUv = gl_FragCoord.xy / resolution;\n d = readDepth(depth, sUv);\n }\n float intensity = vIntensity;\n vec3 normal\t= vec3(vNormal.x, vNormal.y, abs(vNormal.z));\n float angleIntensity\t= pow( dot(normal, vec3(0.0, 0.0, 1.0)), anglePower );\n intensity\t*= angleIntensity;\n // fades when z is close to sampled depth, meaning the cone is intersecting existing geometry\n if (isSoft) {\n intensity\t*= smoothstep(0., 1., vViewZ - d);\n }\n gl_FragColor = vec4(lightColor, intensity * opacity);\n\n #include <tonemapping_fragment>\n #include <${parseInt(t.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>\n }`);class no extends pn{constructor(e=new k){super({uniforms:{inputBuffer:new Bi(null),depthBuffer:new Bi(null),resolution:new Bi(new k),texelSize:new Bi(new k),halfTexelSize:new Bi(new k),kernel:new Bi(0),scale:new Bi(1),cameraNear:new Bi(0),cameraFar:new Bi(1),minDepthThreshold:new Bi(0),maxDepthThreshold:new Bi(1),depthScale:new Bi(0),depthToBlurRatioBias:new Bi(.25)},fragmentShader:`#include <common>\n #include <dithering_pars_fragment> \n uniform sampler2D inputBuffer;\n uniform sampler2D depthBuffer;\n uniform float cameraNear;\n uniform float cameraFar;\n uniform float minDepthThreshold;\n uniform float maxDepthThreshold;\n uniform float depthScale;\n uniform float depthToBlurRatioBias;\n varying vec2 vUv;\n varying vec2 vUv0;\n varying vec2 vUv1;\n varying vec2 vUv2;\n varying vec2 vUv3;\n\n void main() {\n float depthFactor = 0.0;\n \n #ifdef USE_DEPTH\n vec4 depth = texture2D(depthBuffer, vUv);\n depthFactor = smoothstep(minDepthThreshold, maxDepthThreshold, 1.0-(depth.r * depth.a));\n depthFactor *= depthScale;\n depthFactor = max(0.0, min(1.0, depthFactor + 0.25));\n #endif\n \n vec4 sum = texture2D(inputBuffer, mix(vUv0, vUv, depthFactor));\n sum += texture2D(inputBuffer, mix(vUv1, vUv, depthFactor));\n sum += texture2D(inputBuffer, mix(vUv2, vUv, depthFactor));\n sum += texture2D(inputBuffer, mix(vUv3, vUv, depthFactor));\n gl_FragColor = sum * 0.25 ;\n\n #include <dithering_fragment>\n #include <tonemapping_fragment>\n #include <${parseInt(t.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>\n }`,vertexShader:"uniform vec2 texelSize;\n uniform vec2 halfTexelSize;\n uniform float kernel;\n uniform float scale;\n varying vec2 vUv;\n varying vec2 vUv0;\n varying vec2 vUv1;\n varying vec2 vUv2;\n varying vec2 vUv3;\n\n void main() {\n vec2 uv = position.xy * 0.5 + 0.5;\n vUv = uv;\n\n vec2 dUv = (texelSize * vec2(kernel) + halfTexelSize) * scale;\n vUv0 = vec2(uv.x - dUv.x, uv.y + dUv.y);\n vUv1 = vec2(uv.x + dUv.x, uv.y + dUv.y);\n vUv2 = vec2(uv.x + dUv.x, uv.y - dUv.y);\n vUv3 = vec2(uv.x - dUv.x, uv.y - dUv.y);\n\n gl_Position = vec4(position.xy, 1.0, 1.0);\n }",blending:0,depthWrite:!1,depthTest:!1}),this.toneMapped=!1,this.setTexelSize(e.x,e.y),this.kernel=new Float32Array([0,1,2,2,3])}setTexelSize(t,e){this.uniforms.texelSize.value.set(t,e),this.uniforms.halfTexelSize.value.set(t,e).multiplyScalar(.5)}setResolution(t){this.uniforms.resolution.value.copy(t)}}class io{constructor({gl:t,resolution:e,width:n=500,height:i=500,minDepthThreshold:r=0,maxDepthThreshold:a=1,depthScale:o=0,depthToBlurRatioBias:l=.25}){this.renderToScreen=!1,this.renderTargetA=new ot(e,e,{minFilter:s,magFilter:s,stencilBuffer:!1,depthBuffer:!1,type:h}),this.renderTargetB=this.renderTargetA.clone(),this.convolutionMaterial=new no,this.convolutionMaterial.setTexelSize(1/n,1/i),this.convolutionMaterial.setResolution(new k(n,i)),this.scene=new En,this.camera=new mn,this.convolutionMaterial.uniforms.minDepthThreshold.value=r,this.convolutionMaterial.uniforms.maxDepthThreshold.value=a,this.convolutionMaterial.uniforms.depthScale.value=o,this.convolutionMaterial.uniforms.depthToBlurRatioBias.value=l,this.convolutionMaterial.defines.USE_DEPTH=o>0;const c=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),d=new Float32Array([0,0,2,0,0,2]),u=new je;u.setAttribute("position",new Le(c,3)),u.setAttribute("uv",new Le(d,2)),this.screen=new hn(u,this.convolutionMaterial),this.screen.frustumCulled=!1,this.scene.add(this.screen)}render(t,e,n){const i=this.scene,r=this.camera,a=this.renderTargetA,o=this.renderTargetB,s=this.convolutionMaterial,l=s.uniforms;l.depthBuffer.value=e.depthTexture;const c=s.kernel;let h,d,u,f=e;for(d=0,u=c.length-1;d<u;++d)h=0==(1&d)?a:o,l.kernel.value=c[d],l.inputBuffer.value=f.texture,t.setRenderTarget(h),t.render(i,r),f=h;l.kernel.value=c[d],l.inputBuffer.value=f.texture,t.setRenderTarget(this.renderToScreen?null:n),t.render(i,r)}}class ro extends Ui{constructor(t={}){super(),this._tDepth={value:null},this._distortionMap={value:null},this._tDiffuse={value:null},this._tDiffuseBlur={value:null},this._textureMatrix={value:null},this._hasBlur={value:!1},this._mirror={value:0},this._mixBlur={value:0},this._blurStrength={value:.5},this._minDepthThreshold={value:.9},this._maxDepthThreshold={value:1},this._depthScale={value:0},this._depthToBlurRatioBias={value:.25},this._distortion={value:1},this._mixContrast={value:1},this._tDepth={value:null},this._distortionMap={value:null},this._tDiffuse={value:null},this._tDiffuseBlur={value:null},this._textureMatrix={value:null},this._hasBlur={value:!1},this._mirror={value:0},this._mixBlur={value:0},this._blurStrength={value:.5},this._minDepthThreshold={value:.9},this._maxDepthThreshold={value:1},this._depthScale={value:0},this._depthToBlurRatioBias={value:.25},this._distortion={value:1},this._mixContrast={value:1},this.setValues(t)}onBeforeCompile(t){var e;null!=(e=t.defines)&&e.USE_UV||(t.defines.USE_UV=""),t.uniforms.hasBlur=this._hasBlur,t.uniforms.tDiffuse=this._tDiffuse,t.uniforms.tDepth=this._tDepth,t.uniforms.distortionMap=this._distortionMap,t.uniforms.tDiffuseBlur=this._tDiffuseBlur,t.uniforms.textureMatrix=this._textureMatrix,t.uniforms.mirror=this._mirror,t.uniforms.mixBlur=this._mixBlur,t.uniforms.mixStrength=this._blurStrength,t.uniforms.minDepthThreshold=this._minDepthThreshold,t.uniforms.maxDepthThreshold=this._maxDepthThreshold,t.uniforms.depthScale=this._depthScale,t.uniforms.depthToBlurRatioBias=this._depthToBlurRatioBias,t.uniforms.distortion=this._distortion,t.uniforms.mixContrast=this._mixContrast,t.vertexShader=`\n uniform mat4 textureMatrix;\n varying vec4 my_vUv;\n ${t.vertexShader}`,t.vertexShader=t.vertexShader.replace("#include <project_vertex>","#include <project_vertex>\n my_vUv = textureMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );"),t.fragmentShader=`\n uniform sampler2D tDiffuse;\n uniform sampler2D tDiffuseBlur;\n uniform sampler2D tDepth;\n uniform sampler2D distortionMap;\n uniform float distortion;\n uniform float cameraNear;\n\t\t\t uniform float cameraFar;\n uniform bool hasBlur;\n uniform float mixBlur;\n uniform float mirror;\n uniform float mixStrength;\n uniform float minDepthThreshold;\n uniform float maxDepthThreshold;\n uniform float mixContrast;\n uniform float depthScale;\n uniform float depthToBlurRatioBias;\n varying vec4 my_vUv;\n ${t.fragmentShader}`,t.fragmentShader=t.fragmentShader.replace("#include <emissivemap_fragment>","#include <emissivemap_fragment>\n\n float distortionFactor = 0.0;\n #ifdef USE_DISTORTION\n distortionFactor = texture2D(distortionMap, vUv).r * distortion;\n #endif\n\n vec4 new_vUv = my_vUv;\n new_vUv.x += distortionFactor;\n new_vUv.y += distortionFactor;\n\n vec4 base = texture2DProj(tDiffuse, new_vUv);\n vec4 blur = texture2DProj(tDiffuseBlur, new_vUv);\n\n vec4 merge = base;\n\n #ifdef USE_NORMALMAP\n vec2 normal_uv = vec2(0.0);\n vec4 normalColor = texture2D(normalMap, vUv * normalScale);\n vec3 my_normal = normalize( vec3( normalColor.r * 2.0 - 1.0, normalColor.b, normalColor.g * 2.0 - 1.0 ) );\n vec3 coord = new_vUv.xyz / new_vUv.w;\n normal_uv = coord.xy + coord.z * my_normal.xz * 0.05;\n vec4 base_normal = texture2D(tDiffuse, normal_uv);\n vec4 blur_normal = texture2D(tDiffuseBlur, normal_uv);\n merge = base_normal;\n blur = blur_normal;\n #endif\n\n float depthFactor = 0.0001;\n float blurFactor = 0.0;\n\n #ifdef USE_DEPTH\n vec4 depth = texture2DProj(tDepth, new_vUv);\n depthFactor = smoothstep(minDepthThreshold, maxDepthThreshold, 1.0-(depth.r * depth.a));\n depthFactor *= depthScale;\n depthFactor = max(0.0001, min(1.0, depthFactor));\n\n #ifdef USE_BLUR\n blur = blur * min(1.0, depthFactor + depthToBlurRatioBias);\n merge = merge * min(1.0, depthFactor + 0.5);\n #else\n merge = merge * depthFactor;\n #endif\n\n #endif\n\n float reflectorRoughnessFactor = roughness;\n #ifdef USE_ROUGHNESSMAP\n vec4 reflectorTexelRoughness = texture2D( roughnessMap, vUv );\n reflectorRoughnessFactor *= reflectorTexelRoughness.g;\n #endif\n\n #ifdef USE_BLUR\n blurFactor = min(1.0, mixBlur * reflectorRoughnessFactor);\n merge = mix(merge, blur, blurFactor);\n #endif\n\n vec4 newMerge = vec4(0.0, 0.0, 0.0, 1.0);\n newMerge.r = (merge.r - 0.5) * mixContrast + 0.5;\n newMerge.g = (merge.g - 0.5) * mixContrast + 0.5;\n newMerge.b = (merge.b - 0.5) * mixContrast + 0.5;\n\n diffuseColor.rgb = diffuseColor.rgb * ((1.0 - min(1.0, mirror)) + newMerge.rgb * mixStrength);\n ")}get tDiffuse(){return this._tDiffuse.value}set tDiffuse(t){this._tDiffuse.value=t}get tDepth(){return this._tDepth.value}set tDepth(t){this._tDepth.value=t}get distortionMap(){return this._distortionMap.value}set distortionMap(t){this._distortionMap.value=t}get tDiffuseBlur(){return this._tDiffuseBlur.value}set tDiffuseBlur(t){this._tDiffuseBlur.value=t}get textureMatrix(){return this._textureMatrix.value}set textureMatrix(t){this._textureMatrix.value=t}get hasBlur(){return this._hasBlur.value}set hasBlur(t){this._hasBlur.value=t}get mirror(){return this._mirror.value}set mirror(t){this._mirror.value=t}get mixBlur(){return this._mixBlur.value}set mixBlur(t){this._mixBlur.value=t}get mixStrength(){return this._blurStrength.value}set mixStrength(t){this._blurStrength.value=t}get minDepthThreshold(){return this._minDepthThreshold.value}set minDepthThreshold(t){this._minDepthThreshold.value=t}get maxDepthThreshold(){return this._maxDepthThreshold.value}set maxDepthThreshold(t){this._maxDepthThreshold.value=t}get depthScale(){return this._depthScale.value}set depthScale(t){this._depthScale.value=t}get depthToBlurRatioBias(){return this._depthToBlurRatioBias.value}set depthToBlurRatioBias(t){this._depthToBlurRatioBias.value=t}get distortion(){return this._distortion.value}set distortion(t){this._distortion.value=t}get mixContrast(){return this._mixContrast.value}set mixContrast(t){this._mixContrast.value=t}}class ao extends Ei{constructor({time:t=0,distort:e=.4,radius:n=1,...i}={}){super(i),this.setValues(i),this._time={value:t},this._distort={value:e},this._radius={value:n}}onBeforeCompile(t){t.uniforms.time=this._time,t.uniforms.radius=this._radius,t.uniforms.distort=this._distort,t.vertexShader=`\n uniform float time;\n uniform float radius;\n uniform float distort;\n #define GLSLIFY 1\nvec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec4 permute(vec4 x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float snoise(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}\n ${t.vertexShader}\n `,t.vertexShader=t.vertexShader.replace("#include <begin_vertex>","\n float updateTime = time / 50.0;\n float noise = snoise(vec3(position / 2.0 + updateTime * 5.0));\n vec3 transformed = vec3(position * (noise * pow(distort, 2.0) + radius));\n ")}get time(){return this._time.value}set time(t){this._time.value=t}get distort(){return this._distort.value}set distort(t){this._distort.value=t}get radius(){return this._radius.value}set radius(t){this._radius.value=t}}class oo extends Ui{constructor({time:t=0,factor:e=1,...n}={}){super(n),this.setValues(n),this._time={value:t},this._factor={value:e}}onBeforeCompile(t){t.uniforms.time=this._time,t.uniforms.factor=this._factor,t.vertexShader=`\n uniform float time;\n uniform float factor;\n ${t.vertexShader}\n `,t.vertexShader=t.vertexShader.replace("#include <begin_vertex>","float theta = sin( time + position.y ) / 2.0 * factor;\n float c = cos( theta );\n float s = sin( theta );\n mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );\n vec3 transformed = vec3( position ) * m;\n vNormal = vNormal * m;")}get time(){return this._time.value}set time(t){this._time.value=t}get factor(){return this._factor.value}set factor(t){this._factor.value=t}}export{br as Billboard,io as BlurPass,cr as CLOUD_URL,rr as Caustics,tr as CausticsMaterial,Ki as CausticsProjectionMaterial,_r as Cloud,vr as Clouds,no as ConvolutionMaterial,Ka as Grid,ar as MeshDiscardMaterial,ao as MeshDistortMaterial,ro as MeshReflectorMaterial,to as MeshTransmissionMaterial,oo as MeshWobbleMaterial,Mr as Outlines,sr as ProgressiveLightMap,or as SoftShadowMaterial,Ja as Splat,Za as SplatLoader,eo as SpotLightMaterial,yr as SpriteAnimator,Xa as Text,ir as createCausticsUpdate,ji as pcss,Xi as shaderMaterial,$i as useFBO}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment