react-globe.gl 2.24.0 → 2.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version 2.24.
|
|
1
|
+
// Version 2.24.1 react-globe.gl - https://github.com/vasturiano/react-globe.gl
|
|
2
2
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Globe=t(e.React)}(this,(function(e){"use strict";function t(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],A=!0,l=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;A=!1}else for(;!(A=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);A=!0);}catch(e){l=!0,i=e}finally{try{if(!A&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||i(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||i(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s=o((function(e){return[...e].reduce(((e,[t,n])=>(e[t]=n,e)),{})}));function A(e){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},A(e)}function l(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],A=!0,l=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;A=!1}else for(;!(A=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);A=!0);}catch(e){l=!0,i=e}finally{try{if(!A&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||u(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||u(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){if(e){if("string"==typeof e)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(e,t):void 0}}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function f(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.useEffect,r=e.useRef(),i=e.useRef(!1),a=e.useRef(!1),o=l(e.useState(0),2);o[0];var s=o[1];i.current&&(a.current=!0),n((function(){return i.current||(r.current=t(),i.current=!0),s((function(e){return e+1})),function(){a.current&&r.current&&r.current()}}),[])}const d="151",p={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},m=0,g=1,v=2,y=3,b=1,x=2,_=3,w=0,M=1,S=2,E=0,T=1,C=100,P=0,L=1,D=2,R=0,q=1,O=2,I=3,k=4,B=5,U=301,N=302,z=306,F=1e3,G=1001,j=1002,H=1003,V=1005,W=1006,Q=1008,X=1009,Y=1014,Z=1015,J=1016,K=1020,$=1023,ee=1026,te=1027,ne=33776,re=33777,ie=33778,ae=33779,oe=36492,se=3e3,Ae=3001,le=0,ce="srgb",ue="srgb-linear",he="display-p3",fe=7680,de=35044,pe="300 es",me=1035;class ge{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,r=n.length;t<r;t++)n[t].call(this,e);e.target=null}}}const ve=["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 ye=1234567;const be=Math.PI/180,xe=180/Math.PI;function _e(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(ve[255&e]+ve[e>>8&255]+ve[e>>16&255]+ve[e>>24&255]+"-"+ve[255&t]+ve[t>>8&255]+"-"+ve[t>>16&15|64]+ve[t>>24&255]+"-"+ve[63&n|128]+ve[n>>8&255]+"-"+ve[n>>16&255]+ve[n>>24&255]+ve[255&r]+ve[r>>8&255]+ve[r>>16&255]+ve[r>>24&255]).toLowerCase()}function we(e,t,n){return Math.max(t,Math.min(n,e))}function Me(e,t){return(e%t+t)%t}function Se(e,t,n){return(1-n)*e+n*t}function Ee(e){return 0==(e&e-1)&&0!==e}function Te(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Ce(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function Pe(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const Le={DEG2RAD:be,RAD2DEG:xe,generateUUID:_e,clamp:we,euclideanModulo:Me,mapLinear:function(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:Se,damp:function(e,t,n,r){return Se(e,t,1-Math.exp(-n*r))},pingpong:function(e,t=1){return t-Math.abs(Me(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(ye=e);let t=ye+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*be},radToDeg:function(e){return e*xe},isPowerOfTwo:Ee,ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:Te,setQuaternionFromProperEuler:function(e,t,n,r,i){const a=Math.cos,o=Math.sin,s=a(n/2),A=o(n/2),l=a((t+r)/2),c=o((t+r)/2),u=a((t-r)/2),h=o((t-r)/2),f=a((r-t)/2),d=o((r-t)/2);switch(i){case"XYX":e.set(s*c,A*u,A*h,s*l);break;case"YZY":e.set(A*h,s*c,A*u,s*l);break;case"ZXZ":e.set(A*u,A*h,s*c,s*l);break;case"XZX":e.set(s*c,A*d,A*f,s*l);break;case"YXY":e.set(A*f,s*c,A*d,s*l);break;case"ZYZ":e.set(A*d,A*f,s*c,s*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}},normalize:Pe,denormalize:Ce};class De{constructor(e=0,t=0){De.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(we(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Re{constructor(){Re.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(e,t,n,r,i,a,o,s,A){const l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=A,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],A=n[1],l=n[4],c=n[7],u=n[2],h=n[5],f=n[8],d=r[0],p=r[3],m=r[6],g=r[1],v=r[4],y=r[7],b=r[2],x=r[5],_=r[8];return i[0]=a*d+o*g+s*b,i[3]=a*p+o*v+s*x,i[6]=a*m+o*y+s*_,i[1]=A*d+l*g+c*b,i[4]=A*p+l*v+c*x,i[7]=A*m+l*y+c*_,i[2]=u*d+h*g+f*b,i[5]=u*p+h*v+f*x,i[8]=u*m+h*y+f*_,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],A=e[7],l=e[8];return t*a*l-t*o*A-n*i*l+n*o*s+r*i*A-r*a*s}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],A=e[7],l=e[8],c=l*a-o*A,u=o*s-l*i,h=A*i-a*s,f=t*c+n*u+r*h;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);const d=1/f;return e[0]=c*d,e[1]=(r*A-l*n)*d,e[2]=(o*n-r*a)*d,e[3]=u*d,e[4]=(l*t-r*s)*d,e[5]=(r*i-o*t)*d,e[6]=h*d,e[7]=(n*s-A*t)*d,e[8]=(a*t-n*i)*d,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){const s=Math.cos(i),A=Math.sin(i);return this.set(n*s,n*A,-n*(s*a+A*o)+a+e,-r*A,r*s,-r*(-A*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(qe.makeScale(e,t)),this}rotate(e){return this.premultiply(qe.makeRotation(-e)),this}translate(e,t){return this.premultiply(qe.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const qe=new Re;function Oe(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function Ie(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ke(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Be(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const Ue=(new Re).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),Ne=(new Re).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);const ze={[ue]:e=>e,[ce]:e=>e.convertSRGBToLinear(),[he]:function(e){return e.convertSRGBToLinear().applyMatrix3(Ne)}},Fe={[ue]:e=>e,[ce]:e=>e.convertLinearToSRGB(),[he]:function(e){return e.applyMatrix3(Ue).convertLinearToSRGB()}},Ge={enabled:!1,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return ue},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;const r=ze[t],i=Fe[n];if(void 0===r||void 0===i)throw new Error(`Unsupported color space conversion, "${t}" to "${n}".`);return i(r(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}};let je;class He{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===je&&(je=Ie("canvas")),je.width=e.width,je.height=e.height;const n=je.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=je}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=Ie("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e<i.length;e++)i[e]=255*ke(i[e]/255);return n.putImageData(r,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*ke(t[e]/255)):t[e]=ke(t[e]);return{data:t,width:e.width,height:e.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}class Ve{constructor(e=null){this.isSource=!0,this.uuid=_e(),this.data=e,this.version=0}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(null!==r){let e;if(Array.isArray(r)){e=[];for(let t=0,n=r.length;t<n;t++)r[t].isDataTexture?e.push(We(r[t].image)):e.push(We(r[t]))}else e=We(r);n.url=e}return t||(e.images[this.uuid]=n),n}}function We(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?He.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Qe=0;class Xe extends ge{constructor(e=Xe.DEFAULT_IMAGE,t=Xe.DEFAULT_MAPPING,n=1001,r=1001,i=1006,a=Q,o=$,s=X,A=Xe.DEFAULT_ANISOTROPY,l=se){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Qe++}),this.uuid=_e(),this.name="",this.source=new Ve(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=i,this.minFilter=a,this.anisotropy=A,this.format=o,this.internalFormat=null,this.type=s,this.offset=new De(0,0),this.repeat=new De(1,1),this.center=new De(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Re,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=l,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e=null){this.source.data=e}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(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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,encoding:this.encoding,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),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case F:e.x=e.x-Math.floor(e.x);break;case G:e.x=e.x<0?0:1;break;case j:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case F:e.y=e.y-Math.floor(e.y);break;case G:e.y=e.y<0?0:1;break;case j:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}}Xe.DEFAULT_IMAGE=null,Xe.DEFAULT_MAPPING=300,Xe.DEFAULT_ANISOTROPY=1;class Ye{constructor(e=0,t=0,n=0,r=1){Ye.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i;const a=.01,o=.1,s=e.elements,A=s[0],l=s[4],c=s[8],u=s[1],h=s[5],f=s[9],d=s[2],p=s[6],m=s[10];if(Math.abs(l-u)<a&&Math.abs(c-d)<a&&Math.abs(f-p)<a){if(Math.abs(l+u)<o&&Math.abs(c+d)<o&&Math.abs(f+p)<o&&Math.abs(A+h+m-3)<o)return this.set(1,0,0,0),this;t=Math.PI;const e=(A+1)/2,s=(h+1)/2,g=(m+1)/2,v=(l+u)/4,y=(c+d)/4,b=(f+p)/4;return e>s&&e>g?e<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(e),r=v/n,i=y/n):s>g?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=b/r):g<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(g),n=y/i,r=b/i),this.set(n,r,i,t),this}let g=Math.sqrt((p-f)*(p-f)+(c-d)*(c-d)+(u-l)*(u-l));return Math.abs(g)<.001&&(g=1),this.x=(p-f)/g,this.y=(c-d)/g,this.z=(u-l)/g,this.w=Math.acos((A+h+m-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Ze extends ge{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new Ye(0,0,e,t),this.scissorTest=!1,this.viewport=new Ye(0,0,e,t);const r={width:e,height:t,depth:1};this.texture=new Xe(r,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:W,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null,this.samples=void 0!==n.samples?n.samples:0}setSize(e,t,n=1){this.width===e&&this.height===t&&this.depth===n||(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new Ve(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Je extends Xe{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=H,this.minFilter=H,this.wrapR=G,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ke extends Xe{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=H,this.minFilter=H,this.wrapR=G,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class $e{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,i,a,o){let s=n[r+0],A=n[r+1],l=n[r+2],c=n[r+3];const u=i[a+0],h=i[a+1],f=i[a+2],d=i[a+3];if(0===o)return e[t+0]=s,e[t+1]=A,e[t+2]=l,void(e[t+3]=c);if(1===o)return e[t+0]=u,e[t+1]=h,e[t+2]=f,void(e[t+3]=d);if(c!==d||s!==u||A!==h||l!==f){let e=1-o;const t=s*u+A*h+l*f+c*d,n=t>=0?1:-1,r=1-t*t;if(r>Number.EPSILON){const i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}const i=o*n;if(s=s*e+u*i,A=A*e+h*i,l=l*e+f*i,c=c*e+d*i,e===1-o){const e=1/Math.sqrt(s*s+A*A+l*l+c*c);s*=e,A*=e,l*=e,c*=e}}e[t]=s,e[t+1]=A,e[t+2]=l,e[t+3]=c}static multiplyQuaternionsFlat(e,t,n,r,i,a){const o=n[r],s=n[r+1],A=n[r+2],l=n[r+3],c=i[a],u=i[a+1],h=i[a+2],f=i[a+3];return e[t]=o*f+l*c+s*h-A*u,e[t+1]=s*f+l*u+A*c-o*h,e[t+2]=A*f+l*h+o*u-s*c,e[t+3]=l*f-o*c-s*u-A*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,A=o(n/2),l=o(r/2),c=o(i/2),u=s(n/2),h=s(r/2),f=s(i/2);switch(a){case"XYZ":this._x=u*l*c+A*h*f,this._y=A*h*c-u*l*f,this._z=A*l*f+u*h*c,this._w=A*l*c-u*h*f;break;case"YXZ":this._x=u*l*c+A*h*f,this._y=A*h*c-u*l*f,this._z=A*l*f-u*h*c,this._w=A*l*c+u*h*f;break;case"ZXY":this._x=u*l*c-A*h*f,this._y=A*h*c+u*l*f,this._z=A*l*f+u*h*c,this._w=A*l*c-u*h*f;break;case"ZYX":this._x=u*l*c-A*h*f,this._y=A*h*c+u*l*f,this._z=A*l*f-u*h*c,this._w=A*l*c+u*h*f;break;case"YZX":this._x=u*l*c+A*h*f,this._y=A*h*c+u*l*f,this._z=A*l*f-u*h*c,this._w=A*l*c-u*h*f;break;case"XZY":this._x=u*l*c-A*h*f,this._y=A*h*c-u*l*f,this._z=A*l*f+u*h*c,this._w=A*l*c+u*h*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],A=t[2],l=t[6],c=t[10],u=n+o+c;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-A)*e,this._z=(a-r)*e}else if(n>o&&n>c){const e=2*Math.sqrt(1+n-o-c);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+A)/e}else if(o>c){const e=2*Math.sqrt(1+o-n-c);this._w=(i-A)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{const e=2*Math.sqrt(1+c-n-o);this._w=(a-r)/e,this._x=(i+A)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(we(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,A=t._z,l=t._w;return this._x=n*l+a*o+r*A-i*s,this._y=r*l+a*s+i*o-n*A,this._z=i*l+a*A+n*s-r*o,this._w=a*l-n*o-r*s-i*A,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,r=this._y,i=this._z,a=this._w;let o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;const s=1-o*o;if(s<=Number.EPSILON){const e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this._onChangeCallback(),this}const A=Math.sqrt(s),l=Math.atan2(A,o),c=Math.sin((1-t)*l)/A,u=Math.sin(t*l)/A;return this._w=a*c+this._w*u,this._x=n*c+this._x*u,this._y=r*c+this._y*u,this._z=i*c+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),r=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(t*Math.cos(r),n*Math.sin(i),n*Math.cos(i),t*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class et{constructor(e=0,t=0,n=0){et.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(nt.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(nt.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,A=s*t+a*r-o*n,l=s*n+o*t-i*r,c=s*r+i*n-a*t,u=-i*t-a*n-o*r;return this.x=A*s+u*-i+l*-o-c*-a,this.y=l*s+u*-a+c*-i-A*-o,this.z=c*s+u*-o+A*-a-l*-i,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return tt.copy(this).projectOnVector(e),this.sub(tt)}reflect(e){return this.sub(tt.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(we(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const tt=new et,nt=new $e;class rt{constructor(e=new et(1/0,1/0,1/0),t=new et(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(at.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(at.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=at.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){if(e.updateWorldMatrix(!1,!1),void 0!==e.boundingBox)null===e.boundingBox&&e.computeBoundingBox(),ot.copy(e.boundingBox),ot.applyMatrix4(e.matrixWorld),this.union(ot);else{const n=e.geometry;if(void 0!==n)if(t&&void 0!==n.attributes&&void 0!==n.attributes.position){const t=n.attributes.position;for(let n=0,r=t.count;n<r;n++)at.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),this.expandByPoint(at)}else null===n.boundingBox&&n.computeBoundingBox(),ot.copy(n.boundingBox),ot.applyMatrix4(e.matrixWorld),this.union(ot)}const n=e.children;for(let e=0,r=n.length;e<r;e++)this.expandByObject(n[e],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,at),at.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ft),dt.subVectors(this.max,ft),st.subVectors(e.a,ft),At.subVectors(e.b,ft),lt.subVectors(e.c,ft),ct.subVectors(At,st),ut.subVectors(lt,At),ht.subVectors(st,lt);let t=[0,-ct.z,ct.y,0,-ut.z,ut.y,0,-ht.z,ht.y,ct.z,0,-ct.x,ut.z,0,-ut.x,ht.z,0,-ht.x,-ct.y,ct.x,0,-ut.y,ut.x,0,-ht.y,ht.x,0];return!!gt(t,st,At,lt,dt)&&(t=[1,0,0,0,1,0,0,0,1],!!gt(t,st,At,lt,dt)&&(pt.crossVectors(ct,ut),t=[pt.x,pt.y,pt.z],gt(t,st,At,lt,dt)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,at).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(at).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(it[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),it[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),it[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),it[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),it[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),it[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),it[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),it[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(it)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const it=[new et,new et,new et,new et,new et,new et,new et,new et],at=new et,ot=new rt,st=new et,At=new et,lt=new et,ct=new et,ut=new et,ht=new et,ft=new et,dt=new et,pt=new et,mt=new et;function gt(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){mt.fromArray(e,a);const o=i.x*Math.abs(mt.x)+i.y*Math.abs(mt.y)+i.z*Math.abs(mt.z),s=t.dot(mt),A=n.dot(mt),l=r.dot(mt);if(Math.max(-Math.max(s,A,l),Math.min(s,A,l))>o)return!1}return!0}const vt=new rt,yt=new et,bt=new et;class xt{constructor(e=new et,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):vt.setFromPoints(e).getCenter(n);let r=0;for(let t=0,i=e.length;t<i;t++)r=Math.max(r,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;yt.subVectors(e,this.center);const t=yt.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(yt,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(bt.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(yt.copy(e.center).add(bt)),this.expandByPoint(yt.copy(e.center).sub(bt))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const _t=new et,wt=new et,Mt=new et,St=new et,Et=new et,Tt=new et,Ct=new et;class Pt{constructor(e=new et,t=new et(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,_t)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=_t.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(_t.copy(this.origin).addScaledVector(this.direction,t),_t.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){wt.copy(e).add(t).multiplyScalar(.5),Mt.copy(t).sub(e).normalize(),St.copy(this.origin).sub(wt);const i=.5*e.distanceTo(t),a=-this.direction.dot(Mt),o=St.dot(this.direction),s=-St.dot(Mt),A=St.lengthSq(),l=Math.abs(1-a*a);let c,u,h,f;if(l>0)if(c=a*s-o,u=a*o-s,f=i*l,c>=0)if(u>=-f)if(u<=f){const e=1/l;c*=e,u*=e,h=c*(c+a*u+2*o)+u*(a*c+u+2*s)+A}else u=i,c=Math.max(0,-(a*u+o)),h=-c*c+u*(u+2*s)+A;else u=-i,c=Math.max(0,-(a*u+o)),h=-c*c+u*(u+2*s)+A;else u<=-f?(c=Math.max(0,-(-a*i+o)),u=c>0?-i:Math.min(Math.max(-i,-s),i),h=-c*c+u*(u+2*s)+A):u<=f?(c=0,u=Math.min(Math.max(-i,-s),i),h=u*(u+2*s)+A):(c=Math.max(0,-(a*i+o)),u=c>0?i:Math.min(Math.max(-i,-s),i),h=-c*c+u*(u+2*s)+A);else u=a>0?-i:i,c=Math.max(0,-(a*u+o)),h=-c*c+u*(u+2*s)+A;return n&&n.copy(this.origin).addScaledVector(this.direction,c),r&&r.copy(wt).addScaledVector(Mt,u),h}intersectSphere(e,t){_t.subVectors(e.center,this.origin);const n=_t.dot(this.direction),r=_t.dot(_t)-n*n,i=e.radius*e.radius;if(r>i)return null;const a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s;const A=1/this.direction.x,l=1/this.direction.y,c=1/this.direction.z,u=this.origin;return A>=0?(n=(e.min.x-u.x)*A,r=(e.max.x-u.x)*A):(n=(e.max.x-u.x)*A,r=(e.min.x-u.x)*A),l>=0?(i=(e.min.y-u.y)*l,a=(e.max.y-u.y)*l):(i=(e.max.y-u.y)*l,a=(e.min.y-u.y)*l),n>a||i>r?null:((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),c>=0?(o=(e.min.z-u.z)*c,s=(e.max.z-u.z)*c):(o=(e.max.z-u.z)*c,s=(e.min.z-u.z)*c),n>s||o>r?null:((o>n||n!=n)&&(n=o),(s<r||r!=r)&&(r=s),r<0?null:this.at(n>=0?n:r,t)))}intersectsBox(e){return null!==this.intersectBox(e,_t)}intersectTriangle(e,t,n,r,i){Et.subVectors(t,e),Tt.subVectors(n,e),Ct.crossVectors(Et,Tt);let a,o=this.direction.dot(Ct);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}St.subVectors(this.origin,e);const s=a*this.direction.dot(Tt.crossVectors(St,Tt));if(s<0)return null;const A=a*this.direction.dot(Et.cross(St));if(A<0)return null;if(s+A>o)return null;const l=-a*St.dot(Ct);return l<0?null:this.at(l/o,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class Lt{constructor(){Lt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(e,t,n,r,i,a,o,s,A,l,c,u,h,f,d,p){const m=this.elements;return m[0]=e,m[4]=t,m[8]=n,m[12]=r,m[1]=i,m[5]=a,m[9]=o,m[13]=s,m[2]=A,m[6]=l,m[10]=c,m[14]=u,m[3]=h,m[7]=f,m[11]=d,m[15]=p,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 Lt).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,r=1/Dt.setFromMatrixColumn(e,0).length(),i=1/Dt.setFromMatrixColumn(e,1).length(),a=1/Dt.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),A=Math.sin(r),l=Math.cos(i),c=Math.sin(i);if("XYZ"===e.order){const e=a*l,n=a*c,r=o*l,i=o*c;t[0]=s*l,t[4]=-s*c,t[8]=A,t[1]=n+r*A,t[5]=e-i*A,t[9]=-o*s,t[2]=i-e*A,t[6]=r+n*A,t[10]=a*s}else if("YXZ"===e.order){const e=s*l,n=s*c,r=A*l,i=A*c;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*A,t[1]=a*c,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if("ZXY"===e.order){const e=s*l,n=s*c,r=A*l,i=A*c;t[0]=e-i*o,t[4]=-a*c,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*A,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){const e=a*l,n=a*c,r=o*l,i=o*c;t[0]=s*l,t[4]=r*A-n,t[8]=e*A+i,t[1]=s*c,t[5]=i*A+e,t[9]=n*A-r,t[2]=-A,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){const e=a*s,n=a*A,r=o*s,i=o*A;t[0]=s*l,t[4]=i-e*c,t[8]=r*c+n,t[1]=c,t[5]=a*l,t[9]=-o*l,t[2]=-A*l,t[6]=n*c+r,t[10]=e-i*c}else if("XZY"===e.order){const e=a*s,n=a*A,r=o*s,i=o*A;t[0]=s*l,t[4]=-c,t[8]=A*l,t[1]=e*c+i,t[5]=a*l,t[9]=n*c-r,t[2]=r*c-n,t[6]=o*l,t[10]=i*c+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(qt,e,Ot)}lookAt(e,t,n){const r=this.elements;return Bt.subVectors(e,t),0===Bt.lengthSq()&&(Bt.z=1),Bt.normalize(),It.crossVectors(n,Bt),0===It.lengthSq()&&(1===Math.abs(n.z)?Bt.x+=1e-4:Bt.z+=1e-4,Bt.normalize(),It.crossVectors(n,Bt)),It.normalize(),kt.crossVectors(Bt,It),r[0]=It.x,r[4]=kt.x,r[8]=Bt.x,r[1]=It.y,r[5]=kt.y,r[9]=Bt.y,r[2]=It.z,r[6]=kt.z,r[10]=Bt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],A=n[12],l=n[1],c=n[5],u=n[9],h=n[13],f=n[2],d=n[6],p=n[10],m=n[14],g=n[3],v=n[7],y=n[11],b=n[15],x=r[0],_=r[4],w=r[8],M=r[12],S=r[1],E=r[5],T=r[9],C=r[13],P=r[2],L=r[6],D=r[10],R=r[14],q=r[3],O=r[7],I=r[11],k=r[15];return i[0]=a*x+o*S+s*P+A*q,i[4]=a*_+o*E+s*L+A*O,i[8]=a*w+o*T+s*D+A*I,i[12]=a*M+o*C+s*R+A*k,i[1]=l*x+c*S+u*P+h*q,i[5]=l*_+c*E+u*L+h*O,i[9]=l*w+c*T+u*D+h*I,i[13]=l*M+c*C+u*R+h*k,i[2]=f*x+d*S+p*P+m*q,i[6]=f*_+d*E+p*L+m*O,i[10]=f*w+d*T+p*D+m*I,i[14]=f*M+d*C+p*R+m*k,i[3]=g*x+v*S+y*P+b*q,i[7]=g*_+v*E+y*L+b*O,i[11]=g*w+v*T+y*D+b*I,i[15]=g*M+v*C+y*R+b*k,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],A=e[13],l=e[2],c=e[6],u=e[10],h=e[14];return e[3]*(+i*s*c-r*A*c-i*o*u+n*A*u+r*o*h-n*s*h)+e[7]*(+t*s*h-t*A*u+i*a*u-r*a*h+r*A*l-i*s*l)+e[11]*(+t*A*c-t*o*h-i*a*c+n*a*h+i*o*l-n*A*l)+e[15]*(-r*o*l-t*s*c+t*o*u+r*a*c-n*a*u+n*s*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],A=e[7],l=e[8],c=e[9],u=e[10],h=e[11],f=e[12],d=e[13],p=e[14],m=e[15],g=c*p*A-d*u*A+d*s*h-o*p*h-c*s*m+o*u*m,v=f*u*A-l*p*A-f*s*h+a*p*h+l*s*m-a*u*m,y=l*d*A-f*c*A+f*o*h-a*d*h-l*o*m+a*c*m,b=f*c*s-l*d*s-f*o*u+a*d*u+l*o*p-a*c*p,x=t*g+n*v+r*y+i*b;if(0===x)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const _=1/x;return e[0]=g*_,e[1]=(d*u*i-c*p*i-d*r*h+n*p*h+c*r*m-n*u*m)*_,e[2]=(o*p*i-d*s*i+d*r*A-n*p*A-o*r*m+n*s*m)*_,e[3]=(c*s*i-o*u*i-c*r*A+n*u*A+o*r*h-n*s*h)*_,e[4]=v*_,e[5]=(l*p*i-f*u*i+f*r*h-t*p*h-l*r*m+t*u*m)*_,e[6]=(f*s*i-a*p*i-f*r*A+t*p*A+a*r*m-t*s*m)*_,e[7]=(a*u*i-l*s*i+l*r*A-t*u*A-a*r*h+t*s*h)*_,e[8]=y*_,e[9]=(f*c*i-l*d*i-f*n*h+t*d*h+l*n*m-t*c*m)*_,e[10]=(a*d*i-f*o*i+f*n*A-t*d*A-a*n*m+t*o*m)*_,e[11]=(l*o*i-a*c*i-l*n*A+t*c*A+a*n*h-t*o*h)*_,e[12]=b*_,e[13]=(l*d*r-f*c*r+f*n*u-t*d*u-l*n*p+t*c*p)*_,e[14]=(f*o*r-a*d*r-f*n*s+t*d*s+a*n*p-t*o*p)*_,e[15]=(a*c*r-l*o*r+l*n*s-t*c*s-a*n*u+t*o*u)*_,this}scale(e){const t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,A=i*a,l=i*o;return this.set(A*a+n,A*o-r*s,A*s+r*o,0,A*o+r*s,l*o+n,l*s-r*a,0,A*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,A=i+i,l=a+a,c=o+o,u=i*A,h=i*l,f=i*c,d=a*l,p=a*c,m=o*c,g=s*A,v=s*l,y=s*c,b=n.x,x=n.y,_=n.z;return r[0]=(1-(d+m))*b,r[1]=(h+y)*b,r[2]=(f-v)*b,r[3]=0,r[4]=(h-y)*x,r[5]=(1-(u+m))*x,r[6]=(p+g)*x,r[7]=0,r[8]=(f+v)*_,r[9]=(p-g)*_,r[10]=(1-(u+d))*_,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;let i=Dt.set(r[0],r[1],r[2]).length();const a=Dt.set(r[4],r[5],r[6]).length(),o=Dt.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],Rt.copy(this);const s=1/i,A=1/a,l=1/o;return Rt.elements[0]*=s,Rt.elements[1]*=s,Rt.elements[2]*=s,Rt.elements[4]*=A,Rt.elements[5]*=A,Rt.elements[6]*=A,Rt.elements[8]*=l,Rt.elements[9]*=l,Rt.elements[10]*=l,t.setFromRotationMatrix(Rt),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a){const o=this.elements,s=2*i/(t-e),A=2*i/(n-r),l=(t+e)/(t-e),c=(n+r)/(n-r),u=-(a+i)/(a-i),h=-2*a*i/(a-i);return o[0]=s,o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=A,o[9]=c,o[13]=0,o[2]=0,o[6]=0,o[10]=u,o[14]=h,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,r,i,a){const o=this.elements,s=1/(t-e),A=1/(n-r),l=1/(a-i),c=(t+e)*s,u=(n+r)*A,h=(a+i)*l;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-c,o[1]=0,o[5]=2*A,o[9]=0,o[13]=-u,o[2]=0,o[6]=0,o[10]=-2*l,o[14]=-h,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Dt=new et,Rt=new Lt,qt=new et(0,0,0),Ot=new et(1,1,1),It=new et,kt=new et,Bt=new et,Ut=new Lt,Nt=new $e;class zt{constructor(e=0,t=0,n=0,r=zt.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],A=r[5],l=r[9],c=r[2],u=r[6],h=r[10];switch(t){case"XYZ":this._y=Math.asin(we(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,h),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(u,A),this._z=0);break;case"YXZ":this._x=Math.asin(-we(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,h),this._z=Math.atan2(s,A)):(this._y=Math.atan2(-c,i),this._z=0);break;case"ZXY":this._x=Math.asin(we(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,h),this._z=Math.atan2(-a,A)):(this._y=0,this._z=Math.atan2(s,i));break;case"ZYX":this._y=Math.asin(-we(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,h),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,A));break;case"YZX":this._z=Math.asin(we(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,A),this._y=Math.atan2(-c,i)):(this._x=0,this._y=Math.atan2(o,h));break;case"XZY":this._z=Math.asin(-we(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(u,A),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,h),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ut.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ut,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Nt.setFromEuler(this),this.setFromQuaternion(Nt,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}zt.DEFAULT_ORDER="XYZ";class Ft{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return 0!=(this.mask&e.mask)}isEnabled(e){return 0!=(this.mask&(1<<e|0))}}let Gt=0;const jt=new et,Ht=new $e,Vt=new Lt,Wt=new et,Qt=new et,Xt=new et,Yt=new $e,Zt=new et(1,0,0),Jt=new et(0,1,0),Kt=new et(0,0,1),$t={type:"added"},en={type:"removed"};class tn extends ge{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Gt++}),this.uuid=_e(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=tn.DEFAULT_UP.clone();const e=new et,t=new zt,n=new $e,r=new et(1,1,1);t._onChange((function(){n.setFromEuler(t,!1)})),n._onChange((function(){t.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Lt},normalMatrix:{value:new Re}}),this.matrix=new Lt,this.matrixWorld=new Lt,this.matrixAutoUpdate=tn.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=tn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.layers=new Ft,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Ht.setFromAxisAngle(e,t),this.quaternion.multiply(Ht),this}rotateOnWorldAxis(e,t){return Ht.setFromAxisAngle(e,t),this.quaternion.premultiply(Ht),this}rotateX(e){return this.rotateOnAxis(Zt,e)}rotateY(e){return this.rotateOnAxis(Jt,e)}rotateZ(e){return this.rotateOnAxis(Kt,e)}translateOnAxis(e,t){return jt.copy(e).applyQuaternion(this.quaternion),this.position.add(jt.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Zt,e)}translateY(e){return this.translateOnAxis(Jt,e)}translateZ(e){return this.translateOnAxis(Kt,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Vt.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Wt.copy(e):Wt.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Qt.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Vt.lookAt(Qt,Wt,this.up):Vt.lookAt(Wt,Qt,this.up),this.quaternion.setFromRotationMatrix(Vt),r&&(Vt.extractRotation(r.matrixWorld),Ht.setFromRotationMatrix(Vt),this.quaternion.premultiply(Ht.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent($t)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(en)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(en)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),Vt.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),Vt.multiply(e.parent.matrixWorld)),e.applyMatrix4(Vt),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const r=this.children[n].getObjectByProperty(e,t);if(void 0!==r)return r}}getObjectsByProperty(e,t){let n=[];this[e]===t&&n.push(this);for(let r=0,i=this.children.length;r<i;r++){const i=this.children[r].getObjectsByProperty(e,t);i.length>0&&(n=n.concat(i))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qt,e,Xt),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Qt,Yt,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++){const r=t[n];!0!==r.matrixWorldAutoUpdate&&!0!==e||r.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(!0===e&&null!==n&&!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,n=e.length;t<n;t++){const n=e[t];!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const r={};function i(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),!0===this.castShadow&&(r.castShadow=!0),!0===this.receiveShadow&&(r.receiveShadow=!0),!1===this.visible&&(r.visible=!1),!1===this.frustumCulled&&(r.frustumCulled=!1),0!==this.renderOrder&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(r.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t<r;t++){const r=n[t];i(e.shapes,r)}else i(e.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(i(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,r=this.material.length;n<r;n++)t.push(i(e.materials,this.material[n]));r.material=t}else r.material=i(e.materials,this.material);if(this.children.length>0){r.children=[];for(let t=0;t<this.children.length;t++)r.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let t=0;t<this.animations.length;t++){const n=this.animations[t];r.animations.push(i(e.animations,n))}}if(t){const t=a(e.geometries),r=a(e.materials),i=a(e.textures),o=a(e.images),s=a(e.shapes),A=a(e.skeletons),l=a(e.animations),c=a(e.nodes);t.length>0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),A.length>0&&(n.skeletons=A),l.length>0&&(n.animations=l),c.length>0&&(n.nodes=c)}return n.object=r,n;function a(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const n=e.children[t];this.add(n.clone())}return this}}tn.DEFAULT_UP=new et(0,1,0),tn.DEFAULT_MATRIX_AUTO_UPDATE=!0,tn.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const nn=new et,rn=new et,an=new et,on=new et,sn=new et,An=new et,ln=new et,cn=new et,un=new et,hn=new et;let fn=!1;class dn{constructor(e=new et,t=new et,n=new et){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),nn.subVectors(e,t),r.cross(nn);const i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){nn.subVectors(r,t),rn.subVectors(n,t),an.subVectors(e,t);const a=nn.dot(nn),o=nn.dot(rn),s=nn.dot(an),A=rn.dot(rn),l=rn.dot(an),c=a*A-o*o;if(0===c)return i.set(-2,-1,-1);const u=1/c,h=(A*s-o*l)*u,f=(a*l-o*s)*u;return i.set(1-h-f,f,h)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,on),on.x>=0&&on.y>=0&&on.x+on.y<=1}static getUV(e,t,n,r,i,a,o,s){return!1===fn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),fn=!0),this.getInterpolation(e,t,n,r,i,a,o,s)}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,on),s.setScalar(0),s.addScaledVector(i,on.x),s.addScaledVector(a,on.y),s.addScaledVector(o,on.z),s}static isFrontFacing(e,t,n,r){return nn.subVectors(n,t),rn.subVectors(e,t),nn.cross(rn).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return nn.subVectors(this.c,this.b),rn.subVectors(this.a,this.b),.5*nn.cross(rn).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return dn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return dn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,r,i){return!1===fn&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),fn=!0),dn.getInterpolation(e,this.a,this.b,this.c,t,n,r,i)}getInterpolation(e,t,n,r,i){return dn.getInterpolation(e,this.a,this.b,this.c,t,n,r,i)}containsPoint(e){return dn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return dn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,i=this.c;let a,o;sn.subVectors(r,n),An.subVectors(i,n),cn.subVectors(e,n);const s=sn.dot(cn),A=An.dot(cn);if(s<=0&&A<=0)return t.copy(n);un.subVectors(e,r);const l=sn.dot(un),c=An.dot(un);if(l>=0&&c<=l)return t.copy(r);const u=s*c-l*A;if(u<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(sn,a);hn.subVectors(e,i);const h=sn.dot(hn),f=An.dot(hn);if(f>=0&&h<=f)return t.copy(i);const d=h*A-s*f;if(d<=0&&A>=0&&f<=0)return o=A/(A-f),t.copy(n).addScaledVector(An,o);const p=l*f-h*c;if(p<=0&&c-l>=0&&h-f>=0)return ln.subVectors(i,r),o=(c-l)/(c-l+(h-f)),t.copy(r).addScaledVector(ln,o);const m=1/(p+d+u);return a=d*m,o=u*m,t.copy(n).addScaledVector(sn,a).addScaledVector(An,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let pn=0;class mn extends ge{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:pn++}),this.uuid=_e(),this.name="",this.type="Material",this.blending=T,this.side=w,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=C,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=fe,this.stencilZFail=fe,this.stencilZPass=fe,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(e){const t=[];for(const n in e){const r=e[n];delete r.metadata,t.push(r)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==T&&(n.blending=this.blending),this.side!==w&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(n.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}const gn={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},vn={h:0,s:0,l:0},yn={h:0,s:0,l:0};function bn(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}let xn=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=ce){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Ge.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=Ge.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ge.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=Ge.workingColorSpace){if(e=Me(e,1),t=we(t,0,1),n=we(n,0,1),0===t)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=bn(i,r,e+1/3),this.g=bn(i,r,e),this.b=bn(i,r,e-1/3)}return Ge.toWorkingColorSpace(this,r),this}setStyle(e,t=ce){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i;const a=r[1],o=r[2];switch(a){case"rgb":case"rgba":if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(i[1],10))/255,this.g=Math.min(255,parseInt(i[2],10))/255,this.b=Math.min(255,parseInt(i[3],10))/255,Ge.toWorkingColorSpace(this,t),n(i[4]),this;if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(i[1],10))/100,this.g=Math.min(100,parseInt(i[2],10))/100,this.b=Math.min(100,parseInt(i[3],10))/100,Ge.toWorkingColorSpace(this,t),n(i[4]),this;break;case"hsl":case"hsla":if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const e=parseFloat(i[1])/360,r=parseFloat(i[2])/100,a=parseFloat(i[3])/100;return n(i[4]),this.setHSL(e,r,a,t)}break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=r[1],i=n.length;if(3===i)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===i)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=ce){const n=gn[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ke(e.r),this.g=ke(e.g),this.b=ke(e.b),this}copyLinearToSRGB(e){return this.r=Be(e.r),this.g=Be(e.g),this.b=Be(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=ce){return Ge.fromWorkingColorSpace(_n.copy(this),e),we(255*_n.r,0,255)<<16^we(255*_n.g,0,255)<<8^we(255*_n.b,0,255)<<0}getHexString(e=ce){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ge.workingColorSpace){Ge.fromWorkingColorSpace(_n.copy(this),t);const n=_n.r,r=_n.g,i=_n.b,a=Math.max(n,r,i),o=Math.min(n,r,i);let s,A;const l=(o+a)/2;if(o===a)s=0,A=0;else{const e=a-o;switch(A=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r<i?6:0);break;case r:s=(i-n)/e+2;break;case i:s=(n-r)/e+4}s/=6}return e.h=s,e.s=A,e.l=l,e}getRGB(e,t=Ge.workingColorSpace){return Ge.fromWorkingColorSpace(_n.copy(this),t),e.r=_n.r,e.g=_n.g,e.b=_n.b,e}getStyle(e=ce){Ge.fromWorkingColorSpace(_n.copy(this),e);const t=_n.r,n=_n.g,r=_n.b;return e!==ce?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${255*t|0},${255*n|0},${255*r|0})`}offsetHSL(e,t,n){return this.getHSL(vn),vn.h+=e,vn.s+=t,vn.l+=n,this.setHSL(vn.h,vn.s,vn.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(vn),e.getHSL(yn);const n=Se(vn.h,yn.h,t),r=Se(vn.s,yn.s,t),i=Se(vn.l,yn.l,t);return this.setHSL(n,r,i),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,i=e.elements;return this.r=i[0]*t+i[3]*n+i[6]*r,this.g=i[1]*t+i[4]*n+i[7]*r,this.b=i[2]*t+i[5]*n+i[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const _n=new xn;xn.NAMES=gn;class wn extends mn{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new xn(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.combine=P,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Mn=new et,Sn=new De;class En{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=de,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)Sn.fromBufferAttribute(this,t),Sn.applyMatrix3(e),this.setXY(t,Sn.x,Sn.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)Mn.fromBufferAttribute(this,t),Mn.applyMatrix3(e),this.setXYZ(t,Mn.x,Mn.y,Mn.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Mn.fromBufferAttribute(this,t),Mn.applyMatrix4(e),this.setXYZ(t,Mn.x,Mn.y,Mn.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Mn.fromBufferAttribute(this,t),Mn.applyNormalMatrix(e),this.setXYZ(t,Mn.x,Mn.y,Mn.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Mn.fromBufferAttribute(this,t),Mn.transformDirection(e),this.setXYZ(t,Mn.x,Mn.y,Mn.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Ce(t,this.array)),t}setX(e,t){return this.normalized&&(t=Pe(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Ce(t,this.array)),t}setY(e,t){return this.normalized&&(t=Pe(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=Ce(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Pe(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=Ce(t,this.array)),t}setW(e,t){return this.normalized&&(t=Pe(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Pe(t,this.array),n=Pe(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Pe(t,this.array),n=Pe(n,this.array),r=Pe(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e*=this.itemSize,this.normalized&&(t=Pe(t,this.array),n=Pe(n,this.array),r=Pe(r,this.array),i=Pe(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==de&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}copyColorsArray(){console.error("THREE.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("THREE.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("THREE.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("THREE.BufferAttribute: copyVector4sArray() was removed in r144.")}}class Tn extends En{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Cn extends En{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Pn extends En{constructor(e,t,n){super(new Float32Array(e),t,n)}}let Ln=0;const Dn=new Lt,Rn=new tn,qn=new et,On=new rt,In=new rt,kn=new et;class Bn extends ge{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ln++}),this.uuid=_e(),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(e){return Array.isArray(e)?this.index=new(Oe(e)?Cn:Tn)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new Re).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(e),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return Dn.makeRotationFromQuaternion(e),this.applyMatrix4(Dn),this}rotateX(e){return Dn.makeRotationX(e),this.applyMatrix4(Dn),this}rotateY(e){return Dn.makeRotationY(e),this.applyMatrix4(Dn),this}rotateZ(e){return Dn.makeRotationZ(e),this.applyMatrix4(Dn),this}translate(e,t,n){return Dn.makeTranslation(e,t,n),this.applyMatrix4(Dn),this}scale(e,t,n){return Dn.makeScale(e,t,n),this.applyMatrix4(Dn),this}lookAt(e){return Rn.lookAt(e),Rn.updateMatrix(),this.applyMatrix4(Rn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(qn).negate(),this.translate(qn.x,qn.y,qn.z),this}setFromPoints(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];t.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new Pn(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new rt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new et(-1/0,-1/0,-1/0),new et(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];On.setFromBufferAttribute(n),this.morphTargetsRelative?(kn.addVectors(this.boundingBox.min,On.min),this.boundingBox.expandByPoint(kn),kn.addVectors(this.boundingBox.max,On.max),this.boundingBox.expandByPoint(kn)):(this.boundingBox.expandByPoint(On.min),this.boundingBox.expandByPoint(On.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 xt);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new et,1/0);if(e){const n=this.boundingSphere.center;if(On.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];In.setFromBufferAttribute(n),this.morphTargetsRelative?(kn.addVectors(On.min,In.min),On.expandByPoint(kn),kn.addVectors(On.max,In.max),On.expandByPoint(kn)):(On.expandByPoint(In.min),On.expandByPoint(In.max))}On.getCenter(n);let r=0;for(let t=0,i=e.count;t<i;t++)kn.fromBufferAttribute(e,t),r=Math.max(r,n.distanceToSquared(kn));if(t)for(let i=0,a=t.length;i<a;i++){const a=t[i],o=this.morphTargetsRelative;for(let t=0,i=a.count;t<i;t++)kn.fromBufferAttribute(a,t),o&&(qn.fromBufferAttribute(e,t),kn.add(qn)),r=Math.max(r,n.distanceToSquared(kn))}this.boundingSphere.radius=Math.sqrt(r),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 e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.array,r=t.position.array,i=t.normal.array,a=t.uv.array,o=r.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new En(new Float32Array(4*o),4));const s=this.getAttribute("tangent").array,A=[],l=[];for(let e=0;e<o;e++)A[e]=new et,l[e]=new et;const c=new et,u=new et,h=new et,f=new De,d=new De,p=new De,m=new et,g=new et;function v(e,t,n){c.fromArray(r,3*e),u.fromArray(r,3*t),h.fromArray(r,3*n),f.fromArray(a,2*e),d.fromArray(a,2*t),p.fromArray(a,2*n),u.sub(c),h.sub(c),d.sub(f),p.sub(f);const i=1/(d.x*p.y-p.x*d.y);isFinite(i)&&(m.copy(u).multiplyScalar(p.y).addScaledVector(h,-d.y).multiplyScalar(i),g.copy(h).multiplyScalar(d.x).addScaledVector(u,-p.x).multiplyScalar(i),A[e].add(m),A[t].add(m),A[n].add(m),l[e].add(g),l[t].add(g),l[n].add(g))}let y=this.groups;0===y.length&&(y=[{start:0,count:n.length}]);for(let e=0,t=y.length;e<t;++e){const t=y[e],r=t.start;for(let e=r,i=r+t.count;e<i;e+=3)v(n[e+0],n[e+1],n[e+2])}const b=new et,x=new et,_=new et,w=new et;function M(e){_.fromArray(i,3*e),w.copy(_);const t=A[e];b.copy(t),b.sub(_.multiplyScalar(_.dot(t))).normalize(),x.crossVectors(w,t);const n=x.dot(l[e])<0?-1:1;s[4*e]=b.x,s[4*e+1]=b.y,s[4*e+2]=b.z,s[4*e+3]=n}for(let e=0,t=y.length;e<t;++e){const t=y[e],r=t.start;for(let e=r,i=r+t.count;e<i;e+=3)M(n[e+0]),M(n[e+1]),M(n[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new En(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const r=new et,i=new et,a=new et,o=new et,s=new et,A=new et,l=new et,c=new et;if(e)for(let u=0,h=e.count;u<h;u+=3){const h=e.getX(u+0),f=e.getX(u+1),d=e.getX(u+2);r.fromBufferAttribute(t,h),i.fromBufferAttribute(t,f),a.fromBufferAttribute(t,d),l.subVectors(a,i),c.subVectors(r,i),l.cross(c),o.fromBufferAttribute(n,h),s.fromBufferAttribute(n,f),A.fromBufferAttribute(n,d),o.add(l),s.add(l),A.add(l),n.setXYZ(h,o.x,o.y,o.z),n.setXYZ(f,s.x,s.y,s.z),n.setXYZ(d,A.x,A.y,A.z)}else for(let e=0,o=t.count;e<o;e+=3)r.fromBufferAttribute(t,e+0),i.fromBufferAttribute(t,e+1),a.fromBufferAttribute(t,e+2),l.subVectors(a,i),c.subVectors(r,i),l.cross(c),n.setXYZ(e+0,l.x,l.y,l.z),n.setXYZ(e+1,l.x,l.y,l.z),n.setXYZ(e+2,l.x,l.y,l.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(){return console.error("THREE.BufferGeometry.merge() has been removed. Use THREE.BufferGeometryUtils.mergeGeometries() instead."),this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)kn.fromBufferAttribute(e,t),kn.normalize(),e.setXYZ(t,kn.x,kn.y,kn.z)}toNonIndexed(){function e(e,t){const n=e.array,r=e.itemSize,i=e.normalized,a=new n.constructor(t.length*r);let o=0,s=0;for(let i=0,A=t.length;i<A;i++){o=e.isInterleavedBufferAttribute?t[i]*e.data.stride+e.offset:t[i]*r;for(let e=0;e<r;e++)a[s++]=n[o++]}return new En(a,r,i)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Bn,n=this.index.array,r=this.attributes;for(const i in r){const a=e(r[i],n);t.setAttribute(i,a)}const i=this.morphAttributes;for(const r in i){const a=[],o=i[r];for(let t=0,r=o.length;t<r;t++){const r=e(o[t],n);a.push(r)}t.morphAttributes[r]=a}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let e=0,n=a.length;e<n;e++){const n=a[e];t.addGroup(n.start,n.count,n.materialIndex)}return t}toJSON(){const e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const r=n[t];e.data.attributes[t]=r.toJSON(e.data)}const r={};let i=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t<r;t++){const r=n[t];a.push(r.toJSON(e.data))}a.length>0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const r=e.attributes;for(const e in r){const n=r[e];this.setAttribute(e,n.clone(t))}const i=e.morphAttributes;for(const e in i){const n=[],r=i[e];for(let e=0,i=r.length;e<i;e++)n.push(r[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let e=0,t=a.length;e<t;e++){const t=a[e];this.addGroup(t.start,t.count,t.materialIndex)}const o=e.boundingBox;null!==o&&(this.boundingBox=o.clone());const s=e.boundingSphere;return null!==s&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Un=new Lt,Nn=new Pt,zn=new xt,Fn=new et,Gn=new et,jn=new et,Hn=new et,Vn=new et,Wn=new et,Qn=new De,Xn=new De,Yn=new De,Zn=new et,Jn=new et,Kn=new et,$n=new et,er=new et;class tr extends tn{constructor(e=new Bn,t=new wn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,i=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const o=this.morphTargetInfluences;if(i&&o){Wn.set(0,0,0);for(let n=0,r=i.length;n<r;n++){const r=o[n],s=i[n];0!==r&&(Vn.fromBufferAttribute(s,e),a?Wn.addScaledVector(Vn,r):Wn.addScaledVector(Vn.sub(t),r))}t.add(Wn)}return this.isSkinnedMesh&&this.applyBoneTransform(e,t),t}raycast(e,t){const n=this.geometry,r=this.material,i=this.matrixWorld;if(void 0===r)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),zn.copy(n.boundingSphere),zn.applyMatrix4(i),Nn.copy(e.ray).recast(e.near),!1===zn.containsPoint(Nn.origin)){if(null===Nn.intersectSphere(zn,Fn))return;if(Nn.origin.distanceToSquared(Fn)>(e.far-e.near)**2)return}if(Un.copy(i).invert(),Nn.copy(e.ray).applyMatrix4(Un),null!==n.boundingBox&&!1===Nn.intersectsBox(n.boundingBox))return;let a;const o=n.index,s=n.attributes.position,A=n.attributes.uv,l=n.attributes.uv2,c=n.attributes.normal,u=n.groups,h=n.drawRange;if(null!==o)if(Array.isArray(r))for(let n=0,i=u.length;n<i;n++){const i=u[n],s=r[i.materialIndex];for(let n=Math.max(i.start,h.start),r=Math.min(o.count,Math.min(i.start+i.count,h.start+h.count));n<r;n+=3){const r=o.getX(n),u=o.getX(n+1),h=o.getX(n+2);a=nr(this,s,e,Nn,A,l,c,r,u,h),a&&(a.faceIndex=Math.floor(n/3),a.face.materialIndex=i.materialIndex,t.push(a))}}else{for(let n=Math.max(0,h.start),i=Math.min(o.count,h.start+h.count);n<i;n+=3){const i=o.getX(n),s=o.getX(n+1),u=o.getX(n+2);a=nr(this,r,e,Nn,A,l,c,i,s,u),a&&(a.faceIndex=Math.floor(n/3),t.push(a))}}else if(void 0!==s)if(Array.isArray(r))for(let n=0,i=u.length;n<i;n++){const i=u[n],o=r[i.materialIndex];for(let n=Math.max(i.start,h.start),r=Math.min(s.count,Math.min(i.start+i.count,h.start+h.count));n<r;n+=3){a=nr(this,o,e,Nn,A,l,c,n,n+1,n+2),a&&(a.faceIndex=Math.floor(n/3),a.face.materialIndex=i.materialIndex,t.push(a))}}else{for(let n=Math.max(0,h.start),i=Math.min(s.count,h.start+h.count);n<i;n+=3){a=nr(this,r,e,Nn,A,l,c,n,n+1,n+2),a&&(a.faceIndex=Math.floor(n/3),t.push(a))}}}}function nr(e,t,n,r,i,a,o,s,A,l){e.getVertexPosition(s,Gn),e.getVertexPosition(A,jn),e.getVertexPosition(l,Hn);const c=function(e,t,n,r,i,a,o,s){let A;if(A=t.side===M?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,t.side===w,s),null===A)return null;er.copy(s),er.applyMatrix4(e.matrixWorld);const l=n.ray.origin.distanceTo(er);return l<n.near||l>n.far?null:{distance:l,point:er.clone(),object:e}}(e,t,n,r,Gn,jn,Hn,$n);if(c){i&&(Qn.fromBufferAttribute(i,s),Xn.fromBufferAttribute(i,A),Yn.fromBufferAttribute(i,l),c.uv=dn.getInterpolation($n,Gn,jn,Hn,Qn,Xn,Yn,new De)),a&&(Qn.fromBufferAttribute(a,s),Xn.fromBufferAttribute(a,A),Yn.fromBufferAttribute(a,l),c.uv2=dn.getInterpolation($n,Gn,jn,Hn,Qn,Xn,Yn,new De)),o&&(Zn.fromBufferAttribute(o,s),Jn.fromBufferAttribute(o,A),Kn.fromBufferAttribute(o,l),c.normal=dn.getInterpolation($n,Gn,jn,Hn,Zn,Jn,Kn,new et),c.normal.dot(r.direction)>0&&c.normal.multiplyScalar(-1));const e={a:s,b:A,c:l,normal:new et,materialIndex:0};dn.getNormal(Gn,jn,Hn,e.normal),c.face=e}return c}class rr extends Bn{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};const o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);const s=[],A=[],l=[],c=[];let u=0,h=0;function f(e,t,n,r,i,a,f,d,p,m,g){const v=a/p,y=f/m,b=a/2,x=f/2,_=d/2,w=p+1,M=m+1;let S=0,E=0;const T=new et;for(let a=0;a<M;a++){const o=a*y-x;for(let s=0;s<w;s++){const u=s*v-b;T[e]=u*r,T[t]=o*i,T[n]=_,A.push(T.x,T.y,T.z),T[e]=0,T[t]=0,T[n]=d>0?1:-1,l.push(T.x,T.y,T.z),c.push(s/p),c.push(1-a/m),S+=1}}for(let e=0;e<m;e++)for(let t=0;t<p;t++){const n=u+t+w*e,r=u+t+w*(e+1),i=u+(t+1)+w*(e+1),a=u+(t+1)+w*e;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(h,E,g),h+=E,u+=S}f("z","y","x",-1,-1,n,t,e,a,i,0),f("z","y","x",1,-1,n,t,-e,a,i,1),f("x","z","y",1,1,e,n,t,r,a,2),f("x","z","y",1,-1,e,n,-t,r,a,3),f("x","y","z",1,-1,e,t,n,r,i,4),f("x","y","z",-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute("position",new Pn(A,3)),this.setAttribute("normal",new Pn(l,3)),this.setAttribute("uv",new Pn(c,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ir(e){const t={};for(const n in e){t[n]={};for(const r in e[n]){const i=e[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(console.warn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[n][r]=null):t[n][r]=i.clone():Array.isArray(i)?t[n][r]=i.slice():t[n][r]=i}}return t}function ar(e){const t={};for(let n=0;n<e.length;n++){const r=ir(e[n]);for(const e in r)t[e]=r[e]}return t}function or(e){return null===e.getRenderTarget()&&e.outputEncoding===Ae?ce:ue}const sr={clone:ir,merge:ar};class Ar extends mn{constructor(e){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={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ir(e.uniforms),this.uniformsGroups=function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const n in this.uniforms){const r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:"t",value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:"m4",value:r.toArray()}:t.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class lr extends tn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Lt,this.projectionMatrix=new Lt,this.projectionMatrixInverse=new Lt}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class cr extends lr{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*xe*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*be*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*xe*Math.atan(Math.tan(.5*be*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*be*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r;const a=this.view;if(null!==this.view&&this.view.enabled){const e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}const o=this.filmOffset;0!==o&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const ur=-90;class hr extends tn{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n;const r=new cr(ur,1,e,t);r.layers=this.layers,r.up.set(0,1,0),r.lookAt(1,0,0),this.add(r);const i=new cr(ur,1,e,t);i.layers=this.layers,i.up.set(0,1,0),i.lookAt(-1,0,0),this.add(i);const a=new cr(ur,1,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(0,1,0),this.add(a);const o=new cr(ur,1,e,t);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(0,-1,0),this.add(o);const s=new cr(ur,1,e,t);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(0,0,1),this.add(s);const A=new cr(ur,1,e,t);A.layers=this.layers,A.up.set(0,1,0),A.lookAt(0,0,-1),this.add(A)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[r,i,a,o,s,A]=this.children,l=e.getRenderTarget(),c=e.toneMapping,u=e.xr.enabled;e.toneMapping=R,e.xr.enabled=!1;const h=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,r),e.setRenderTarget(n,1),e.render(t,i),e.setRenderTarget(n,2),e.render(t,a),e.setRenderTarget(n,3),e.render(t,o),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=h,e.setRenderTarget(n,5),e.render(t,A),e.setRenderTarget(l),e.toneMapping=c,e.xr.enabled=u,n.texture.needsPMREMUpdate=!0}}class fr extends Xe{constructor(e,t,n,r,i,a,o,s,A,l){super(e=void 0!==e?e:[],t=void 0!==t?t:U,n,r,i,a,o,s,A,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class dr extends Ze{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new fr(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:W}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t\t#include <project_vertex>\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include <common>\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},r=new rr(5,5,5),i=new Ar({name:"CubemapFromEquirect",uniforms:ir(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:M,blending:E});i.uniforms.tEquirect.value=t;const a=new tr(r,i),o=t.minFilter;t.minFilter===Q&&(t.minFilter=W);return new hr(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){const i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}}const pr=new et,mr=new et,gr=new Re;class vr{constructor(e=new et(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=pr.subVectors(n,t).cross(mr.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(pr),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||gr.getNormalMatrix(e),r=this.coplanarPoint(pr).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const yr=new xt,br=new et;class xr{constructor(e=new vr,t=new vr,n=new vr,r=new vr,i=new vr,a=new vr){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],A=n[5],l=n[6],c=n[7],u=n[8],h=n[9],f=n[10],d=n[11],p=n[12],m=n[13],g=n[14],v=n[15];return t[0].setComponents(o-r,c-s,d-u,v-p).normalize(),t[1].setComponents(o+r,c+s,d+u,v+p).normalize(),t[2].setComponents(o+i,c+A,d+h,v+m).normalize(),t[3].setComponents(o-i,c-A,d-h,v-m).normalize(),t[4].setComponents(o-a,c-l,d-f,v-g).normalize(),t[5].setComponents(o+a,c+l,d+f,v+g).normalize(),this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),yr.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),yr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(yr)}intersectsSprite(e){return yr.center.set(0,0,0),yr.radius=.7071067811865476,yr.applyMatrix4(e.matrixWorld),this.intersectsSphere(yr)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)<r)return!1}return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(br.x=r.normal.x>0?e.max.x:e.min.x,br.y=r.normal.y>0?e.max.y:e.min.y,br.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(br)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function _r(){let e=null,t=!1,n=null,r=null;function i(t,a){n(t,a),r=e.requestAnimationFrame(i)}return{start:function(){!0!==t&&null!==n&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function wr(e,t){const n=t.isWebGL2,r=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=r.get(t);n&&(e.deleteBuffer(n.buffer),r.delete(t))},update:function(t,i){if(t.isGLBufferAttribute){const e=r.get(t);return void((!e||e.version<t.version)&&r.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const a=r.get(t);void 0===a?r.set(t,function(t,r){const i=t.array,a=t.usage,o=e.createBuffer();let s;if(e.bindBuffer(r,o),e.bufferData(r,i,a),t.onUploadCallback(),i instanceof Float32Array)s=5126;else if(i instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!n)throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");s=5131}else s=5123;else if(i instanceof Int16Array)s=5122;else if(i instanceof Uint32Array)s=5125;else if(i instanceof Int32Array)s=5124;else if(i instanceof Int8Array)s=5120;else if(i instanceof Uint8Array)s=5121;else{if(!(i instanceof Uint8ClampedArray))throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+i);s=5121}return{buffer:o,type:s,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version}}(t,i)):a.version<t.version&&(!function(t,r,i){const a=r.array,o=r.updateRange;e.bindBuffer(i,t),-1===o.count?e.bufferSubData(i,0,a):(n?e.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a,o.offset,o.count):e.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a.subarray(o.offset,o.offset+o.count)),o.count=-1),r.onUploadCallback()}(a.buffer,t,i),a.version=t.version)}}}class Mr extends Bn{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const i=e/2,a=t/2,o=Math.floor(n),s=Math.floor(r),A=o+1,l=s+1,c=e/o,u=t/s,h=[],f=[],d=[],p=[];for(let e=0;e<l;e++){const t=e*u-a;for(let n=0;n<A;n++){const r=n*c-i;f.push(r,-t,0),d.push(0,0,1),p.push(n/o),p.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<o;t++){const n=t+A*e,r=t+A*(e+1),i=t+1+A*(e+1),a=t+1+A*e;h.push(n,r,a),h.push(r,i,a)}this.setIndex(h),this.setAttribute("position",new Pn(f,3)),this.setAttribute("normal",new Pn(d,3)),this.setAttribute("uv",new Pn(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Mr(e.width,e.height,e.widthSegments,e.heightSegments)}}const Sr={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\tif ( diffuseColor.a < alphaTest ) discard;\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_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\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",begin_vertex:"vec3 transformed = vec3( position );",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\t return 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 R21 = R12;\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 = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = 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#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\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};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat 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_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\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_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, 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",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || 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:"#if defined( USE_ENVMAP )\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec = 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, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\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_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",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 GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, 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;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\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_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",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_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};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = 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_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\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\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 GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, 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:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\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, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\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, geometry, 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.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, 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( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 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#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",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\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\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = 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#ifdef USE_NORMALMAP_TANGENTSPACE\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, vNormalMapUv );\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 geometryNormal = 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 ) )\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 = geometryNormal;\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",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\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_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 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 shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\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 shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#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 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 shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#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.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, 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.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\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\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 toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\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 transmission = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmission.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmission.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, vec2 fullSize, 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\t\n\t\tvec2 lodFudge = pow( 1.95, lod ) / fullSize;\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\tvec2 fullSize = vec2( textureSize( sampler, 0 ) );\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), fullSize, floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), fullSize, 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 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( 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 ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#ifdef USE_UV\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_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:"#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_UV2\n\tattribute vec2 uv2;\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_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:"#ifdef USE_UV\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_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_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 <encodings_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;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, 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 <encodings_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 <encodings_fragment>\n}",depth_vert:"#include <common>\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 <skinbase_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 <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\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 <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 <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 <skinbase_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 <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_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 <encodings_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 <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\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\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 <morphcolor_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 <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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\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 <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 <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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 <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 <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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <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 <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 <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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 <morphcolor_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 <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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\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 <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 <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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 <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#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\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 ), opacity );\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 <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 <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}",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 <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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <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 <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 <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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 <morphcolor_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_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\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 <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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <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 <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 + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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 <morphcolor_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 <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\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <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 <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 <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_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 <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 <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\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 <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 <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 <encodings_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 <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\t#include <output_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}"},Er={common:{diffuse:{value:new xn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Re},alphaMap:{value:null},alphaMapTransform:{value:new Re},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Re}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Re}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Re}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Re},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Re},normalScale:{value:new De(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Re},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Re}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Re}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Re}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new xn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new Re}},sprite:{diffuse:{value:new xn(16777215)},opacity:{value:1},center:{value:new De(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Re},alphaMap:{value:null},alphaTest:{value:0}}},Tr={basic:{uniforms:ar([Er.common,Er.specularmap,Er.envmap,Er.aomap,Er.lightmap,Er.fog]),vertexShader:Sr.meshbasic_vert,fragmentShader:Sr.meshbasic_frag},lambert:{uniforms:ar([Er.common,Er.specularmap,Er.envmap,Er.aomap,Er.lightmap,Er.emissivemap,Er.bumpmap,Er.normalmap,Er.displacementmap,Er.fog,Er.lights,{emissive:{value:new xn(0)}}]),vertexShader:Sr.meshlambert_vert,fragmentShader:Sr.meshlambert_frag},phong:{uniforms:ar([Er.common,Er.specularmap,Er.envmap,Er.aomap,Er.lightmap,Er.emissivemap,Er.bumpmap,Er.normalmap,Er.displacementmap,Er.fog,Er.lights,{emissive:{value:new xn(0)},specular:{value:new xn(1118481)},shininess:{value:30}}]),vertexShader:Sr.meshphong_vert,fragmentShader:Sr.meshphong_frag},standard:{uniforms:ar([Er.common,Er.envmap,Er.aomap,Er.lightmap,Er.emissivemap,Er.bumpmap,Er.normalmap,Er.displacementmap,Er.roughnessmap,Er.metalnessmap,Er.fog,Er.lights,{emissive:{value:new xn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Sr.meshphysical_vert,fragmentShader:Sr.meshphysical_frag},toon:{uniforms:ar([Er.common,Er.aomap,Er.lightmap,Er.emissivemap,Er.bumpmap,Er.normalmap,Er.displacementmap,Er.gradientmap,Er.fog,Er.lights,{emissive:{value:new xn(0)}}]),vertexShader:Sr.meshtoon_vert,fragmentShader:Sr.meshtoon_frag},matcap:{uniforms:ar([Er.common,Er.bumpmap,Er.normalmap,Er.displacementmap,Er.fog,{matcap:{value:null}}]),vertexShader:Sr.meshmatcap_vert,fragmentShader:Sr.meshmatcap_frag},points:{uniforms:ar([Er.points,Er.fog]),vertexShader:Sr.points_vert,fragmentShader:Sr.points_frag},dashed:{uniforms:ar([Er.common,Er.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Sr.linedashed_vert,fragmentShader:Sr.linedashed_frag},depth:{uniforms:ar([Er.common,Er.displacementmap]),vertexShader:Sr.depth_vert,fragmentShader:Sr.depth_frag},normal:{uniforms:ar([Er.common,Er.bumpmap,Er.normalmap,Er.displacementmap,{opacity:{value:1}}]),vertexShader:Sr.meshnormal_vert,fragmentShader:Sr.meshnormal_frag},sprite:{uniforms:ar([Er.sprite,Er.fog]),vertexShader:Sr.sprite_vert,fragmentShader:Sr.sprite_frag},background:{uniforms:{uvTransform:{value:new Re},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Sr.background_vert,fragmentShader:Sr.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:Sr.backgroundCube_vert,fragmentShader:Sr.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Sr.cube_vert,fragmentShader:Sr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Sr.equirect_vert,fragmentShader:Sr.equirect_frag},distanceRGBA:{uniforms:ar([Er.common,Er.displacementmap,{referencePosition:{value:new et},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Sr.distanceRGBA_vert,fragmentShader:Sr.distanceRGBA_frag},shadow:{uniforms:ar([Er.lights,Er.fog,{color:{value:new xn(0)},opacity:{value:1}}]),vertexShader:Sr.shadow_vert,fragmentShader:Sr.shadow_frag}};Tr.physical={uniforms:ar([Tr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Re},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Re},clearcoatNormalScale:{value:new De(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Re},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Re},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Re},sheen:{value:0},sheenColor:{value:new xn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Re},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Re},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Re},transmissionSamplerSize:{value:new De},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Re},attenuationDistance:{value:0},attenuationColor:{value:new xn(0)},specularColor:{value:new xn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Re},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Re}}]),vertexShader:Sr.meshphysical_vert,fragmentShader:Sr.meshphysical_frag};const Cr={r:0,b:0,g:0};function Pr(e,t,n,r,i,a,o){const s=new xn(0);let A,l,c=!0===a?0:1,u=null,h=0,f=null;function d(t,n){t.getRGB(Cr,or(e)),r.buffers.color.setClear(Cr.r,Cr.g,Cr.b,n,o)}return{getClearColor:function(){return s},setClearColor:function(e,t=1){s.set(e),c=t,d(s,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,d(s,c)},render:function(r,a){let o=!1,p=!0===a.isScene?a.background:null;if(p&&p.isTexture){p=(a.backgroundBlurriness>0?n:t).get(p)}const m=e.xr,g=m.getSession&&m.getSession();g&&"additive"===g.environmentBlendMode&&(p=null),null===p?d(s,c):p&&p.isColor&&(d(p,1),o=!0),(e.autoClear||o)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),p&&(p.isCubeTexture||p.mapping===z)?(void 0===l&&(l=new tr(new rr(1,1,1),new Ar({name:"BackgroundCubeMaterial",uniforms:ir(Tr.backgroundCube.uniforms),vertexShader:Tr.backgroundCube.vertexShader,fragmentShader:Tr.backgroundCube.fragmentShader,side:M,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=p,l.material.uniforms.flipEnvMap.value=p.isCubeTexture&&!1===p.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=a.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=a.backgroundIntensity,l.material.toneMapped=p.encoding!==Ae,u===p&&h===p.version&&f===e.toneMapping||(l.material.needsUpdate=!0,u=p,h=p.version,f=e.toneMapping),l.layers.enableAll(),r.unshift(l,l.geometry,l.material,0,0,null)):p&&p.isTexture&&(void 0===A&&(A=new tr(new Mr(2,2),new Ar({name:"BackgroundMaterial",uniforms:ir(Tr.background.uniforms),vertexShader:Tr.background.vertexShader,fragmentShader:Tr.background.fragmentShader,side:w,depthTest:!1,depthWrite:!1,fog:!1})),A.geometry.deleteAttribute("normal"),Object.defineProperty(A.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(A)),A.material.uniforms.t2D.value=p,A.material.uniforms.backgroundIntensity.value=a.backgroundIntensity,A.material.toneMapped=p.encoding!==Ae,!0===p.matrixAutoUpdate&&p.updateMatrix(),A.material.uniforms.uvTransform.value.copy(p.matrix),u===p&&h===p.version&&f===e.toneMapping||(A.material.needsUpdate=!0,u=p,h=p.version,f=e.toneMapping),A.layers.enableAll(),r.unshift(A,A.geometry,A.material,0,0,null))}}}function Lr(e,t,n,r){const i=e.getParameter(34921),a=r.isWebGL2?null:t.get("OES_vertex_array_object"),o=r.isWebGL2||null!==a,s={},A=f(null);let l=A,c=!1;function u(t){return r.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function h(t){return r.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function f(e){const t=[],n=[],r=[];for(let e=0;e<i;e++)t[e]=0,n[e]=0,r[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:r,object:e,attributes:{},index:null}}function d(){const e=l.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function p(e){m(e,0)}function m(n,i){const a=l.newAttributes,o=l.enabledAttributes,s=l.attributeDivisors;if(a[n]=1,0===o[n]&&(e.enableVertexAttribArray(n),o[n]=1),s[n]!==i){(r.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,i),s[n]=i}}function g(){const t=l.newAttributes,n=l.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==t[r]&&(e.disableVertexAttribArray(r),n[r]=0)}function v(t,n,i,a,o,s){!0!==r.isWebGL2||5124!==i&&5125!==i?e.vertexAttribPointer(t,n,i,a,o,s):e.vertexAttribIPointer(t,n,i,o,s)}function y(){b(),c=!0,l!==A&&(l=A,u(l.object))}function b(){A.geometry=null,A.program=null,A.wireframe=!1}return{setup:function(i,A,h,y,b){let x=!1;if(o){const t=function(t,n,i){const o=!0===i.wireframe;let A=s[t.id];void 0===A&&(A={},s[t.id]=A);let l=A[n.id];void 0===l&&(l={},A[n.id]=l);let c=l[o];void 0===c&&(c=f(r.isWebGL2?e.createVertexArray():a.createVertexArrayOES()),l[o]=c);return c}(y,h,A);l!==t&&(l=t,u(l.object)),x=function(e,t,n,r){const i=l.attributes,a=t.attributes;let o=0;const s=n.getAttributes();for(const t in s){if(s[t].location>=0){const n=i[t];let r=a[t];if(void 0===r&&("instanceMatrix"===t&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(r=e.instanceColor)),void 0===n)return!0;if(n.attribute!==r)return!0;if(r&&n.data!==r.data)return!0;o++}}return l.attributesNum!==o||l.index!==r}(i,y,h,b),x&&function(e,t,n,r){const i={},a=t.attributes;let o=0;const s=n.getAttributes();for(const t in s){if(s[t].location>=0){let n=a[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,o++}}l.attributes=i,l.attributesNum=o,l.index=r}(i,y,h,b)}else{const e=!0===A.wireframe;l.geometry===y.id&&l.program===h.id&&l.wireframe===e||(l.geometry=y.id,l.program=h.id,l.wireframe=e,x=!0)}null!==b&&n.update(b,34963),(x||c)&&(c=!1,function(i,a,o,s){if(!1===r.isWebGL2&&(i.isInstancedMesh||s.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;d();const A=s.attributes,l=o.getAttributes(),c=a.defaultAttributeValues;for(const t in l){const r=l[t];if(r.location>=0){let a=A[t];if(void 0===a&&("instanceMatrix"===t&&i.instanceMatrix&&(a=i.instanceMatrix),"instanceColor"===t&&i.instanceColor&&(a=i.instanceColor)),void 0!==a){const t=a.normalized,o=a.itemSize,A=n.get(a);if(void 0===A)continue;const l=A.buffer,c=A.type,u=A.bytesPerElement;if(a.isInterleavedBufferAttribute){const n=a.data,A=n.stride,h=a.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e<r.locationSize;e++)m(r.location+e,n.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let e=0;e<r.locationSize;e++)p(r.location+e);e.bindBuffer(34962,l);for(let e=0;e<r.locationSize;e++)v(r.location+e,o/r.locationSize,c,t,A*u,(h+o/r.locationSize*e)*u)}else{if(a.isInstancedBufferAttribute){for(let e=0;e<r.locationSize;e++)m(r.location+e,a.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=a.meshPerAttribute*a.count)}else for(let e=0;e<r.locationSize;e++)p(r.location+e);e.bindBuffer(34962,l);for(let e=0;e<r.locationSize;e++)v(r.location+e,o/r.locationSize,c,t,o*u,o/r.locationSize*e*u)}}else if(void 0!==c){const n=c[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(r.location,n);break;case 3:e.vertexAttrib3fv(r.location,n);break;case 4:e.vertexAttrib4fv(r.location,n);break;default:e.vertexAttrib1fv(r.location,n)}}}}g()}(i,A,h,y),null!==b&&e.bindBuffer(34963,n.get(b).buffer))},reset:y,resetDefaultState:b,dispose:function(){y();for(const e in s){const t=s[e];for(const e in t){const n=t[e];for(const e in n)h(n[e].object),delete n[e];delete t[e]}delete s[e]}},releaseStatesOfGeometry:function(e){if(void 0===s[e.id])return;const t=s[e.id];for(const e in t){const n=t[e];for(const e in n)h(n[e].object),delete n[e];delete t[e]}delete s[e.id]},releaseStatesOfProgram:function(e){for(const t in s){const n=s[t];if(void 0===n[e.id])continue;const r=n[e.id];for(const e in r)h(r[e].object),delete r[e];delete n[e.id]}},initAttributes:d,enableAttribute:p,disableUnusedAttributes:g}}function Dr(e,t,n,r){const i=r.isWebGL2;let a;this.setMode=function(e){a=e},this.render=function(t,r){e.drawArrays(a,t,r),n.update(r,a,1)},this.renderInstances=function(r,o,s){if(0===s)return;let A,l;if(i)A=e,l="drawArraysInstanced";else if(A=t.get("ANGLE_instanced_arrays"),l="drawArraysInstancedANGLE",null===A)return void console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");A[l](a,r,o,s),n.update(o,a,s)}}function Rr(e,t,n){let r;function i(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const a="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let o=void 0!==n.precision?n.precision:"highp";const s=i(o);s!==o&&(console.warn("THREE.WebGLRenderer:",o,"not supported, using",s,"instead."),o=s);const A=a||t.has("WEBGL_draw_buffers"),l=!0===n.logarithmicDepthBuffer,c=e.getParameter(34930),u=e.getParameter(35660),h=e.getParameter(3379),f=e.getParameter(34076),d=e.getParameter(34921),p=e.getParameter(36347),m=e.getParameter(36348),g=e.getParameter(36349),v=u>0,y=a||t.has("OES_texture_float");return{isWebGL2:a,drawBuffers:A,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:l,maxTextures:c,maxVertexTextures:u,maxTextureSize:h,maxCubemapSize:f,maxAttributes:d,maxVertexUniforms:p,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:y,floatVertexTextures:v&&y,maxSamples:a?e.getParameter(36183):0}}function qr(e){const t=this;let n=null,r=0,i=!1,a=!1;const o=new vr,s=new Re,A={value:null,needsUpdate:!1};function l(e,n,r,i){const a=null!==e?e.length:0;let l=null;if(0!==a){if(l=A.value,!0!==i||null===l){const t=r+4*a,i=n.matrixWorldInverse;s.getNormalMatrix(i),(null===l||l.length<t)&&(l=new Float32Array(t));for(let t=0,n=r;t!==a;++t,n+=4)o.copy(e[t]).applyMatrix4(i,s),o.normal.toArray(l,n),l[n+3]=o.constant}A.value=l,A.needsUpdate=!0}return t.numPlanes=a,t.numIntersection=0,l}this.uniform=A,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){const n=0!==e.length||t||0!==r||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,l(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=l(e,t,0)},this.setState=function(o,s,c){const u=o.clippingPlanes,h=o.clipIntersection,f=o.clipShadows,d=e.get(o);if(!i||null===u||0===u.length||a&&!f)a?l(null):function(){A.value!==n&&(A.value=n,A.needsUpdate=r>0);t.numPlanes=r,t.numIntersection=0}();else{const e=a?0:r,t=4*e;let i=d.clippingState||null;A.value=i,i=l(u,s,t,c);for(let e=0;e!==t;++e)i[e]=n[e];d.clippingState=i,this.numIntersection=h?this.numPlanes:0,this.numPlanes+=e}}}function Or(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=U:304===t&&(e.mapping=N),e}function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture&&!1===i.isRenderTargetTexture){const a=i.mapping;if(303===a||304===a){if(t.has(i)){return n(t.get(i).texture,i.mapping)}{const a=i.image;if(a&&a.height>0){const o=new dr(a.height/2);return o.fromEquirectangularTexture(e,i),t.set(i,o),i.addEventListener("dispose",r),n(o.texture,i.mapping)}return null}}}return i},dispose:function(){t=new WeakMap}}}class Ir extends lr{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,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=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let i=n-e,a=n+e,o=r+t,s=r-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const kr=4,Br=[.125,.215,.35,.446,.526,.582],Ur=20,Nr=new Ir,zr=new xn;let Fr=null;const Gr=(1+Math.sqrt(5))/2,jr=1/Gr,Hr=[new et(1,1,1),new et(-1,1,1),new et(1,1,-1),new et(-1,1,-1),new et(0,Gr,jr),new et(0,Gr,-jr),new et(jr,0,Gr),new et(-jr,0,Gr),new et(Gr,jr,0),new et(-Gr,jr,0)];class Vr{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){Fr=this._renderer.getRenderTarget(),this._setSize(256);const i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Yr(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Xr(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(Fr),e.scissorTest=!1,Qr(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===U||e.mapping===N?this._setSize(0===e.image.length?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Fr=this._renderer.getRenderTarget();const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:W,minFilter:W,generateMipmaps:!1,type:J,format:$,encoding:se,depthBuffer:!1},r=Wr(e,t,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=Wr(e,t,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(e){const t=[],n=[],r=[];let i=e;const a=e-kr+1+Br.length;for(let o=0;o<a;o++){const a=Math.pow(2,i);n.push(a);let s=1/a;o>e-kr?s=Br[o-e+kr-1]:0===o&&(s=0),r.push(s);const A=1/(a-2),l=-A,c=1+A,u=[l,l,c,l,c,c,l,l,c,c,l,c],h=6,f=6,d=3,p=2,m=1,g=new Float32Array(d*f*h),v=new Float32Array(p*f*h),y=new Float32Array(m*f*h);for(let e=0;e<h;e++){const t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];g.set(r,d*f*e),v.set(u,p*f*e);const i=[e,e,e,e,e,e];y.set(i,m*f*e)}const b=new Bn;b.setAttribute("position",new En(g,d)),b.setAttribute("uv",new En(v,p)),b.setAttribute("faceIndex",new En(y,m)),t.push(b),i>kr&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}(r)),this._blurMaterial=function(e,t,n){const r=new Float32Array(Ur),i=new et(0,1,0),a=new Ar({name:"SphericalGaussianBlur",defines:{n:Ur,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Zr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include <cube_uv_reflection_fragment>\n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:E,depthTest:!1,depthWrite:!1});return a}(r,e,t)}return r}_compileMaterial(e){const t=new tr(this._lodPlanes[0],e);this._renderer.compile(t,Nr)}_sceneToCubeUV(e,t,n,r){const i=new cr(90,1,t,n),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],s=this._renderer,A=s.autoClear,l=s.toneMapping;s.getClearColor(zr),s.toneMapping=R,s.autoClear=!1;const c=new wn({name:"PMREM.Background",side:M,depthWrite:!1,depthTest:!1}),u=new tr(new rr,c);let h=!1;const f=e.background;f?f.isColor&&(c.color.copy(f),e.background=null,h=!0):(c.color.copy(zr),h=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(i.up.set(0,a[t],0),i.lookAt(o[t],0,0)):1===n?(i.up.set(0,0,a[t]),i.lookAt(0,o[t],0)):(i.up.set(0,a[t],0),i.lookAt(0,0,o[t]));const A=this._cubeSize;Qr(r,n*A,t>2?A:0,A,A),s.setRenderTarget(r),h&&s.render(u,i),s.render(e,i)}u.geometry.dispose(),u.material.dispose(),s.toneMapping=l,s.autoClear=A,e.background=f}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===U||e.mapping===N;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=Yr()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Xr());const i=r?this._cubemapMaterial:this._equirectMaterial,a=new tr(this._lodPlanes[0],i);i.uniforms.envMap.value=e;const o=this._cubeSize;Qr(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,Nr)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t<this._lodPlanes.length;t++){const n=Math.sqrt(this._sigmas[t]*this._sigmas[t]-this._sigmas[t-1]*this._sigmas[t-1]),r=Hr[(t-1)%Hr.length];this._blur(e,t-1,t,n,r)}t.autoClear=n}_blur(e,t,n,r,i){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",i),this._halfBlur(a,e,n,n,r,"longitudinal",i)}_halfBlur(e,t,n,r,i,a,o){const s=this._renderer,A=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");const l=new tr(this._lodPlanes[r],A),c=A.uniforms,u=this._sizeLods[n]-1,h=isFinite(i)?Math.PI/(2*u):2*Math.PI/(2*Ur-1),f=i/h,d=isFinite(i)?1+Math.floor(3*f):Ur;d>Ur&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${d} samples when the maximum is set to ${Ur}`);const p=[];let m=0;for(let e=0;e<Ur;++e){const t=e/f,n=Math.exp(-t*t/2);p.push(n),0===e?m+=n:e<d&&(m+=2*n)}for(let e=0;e<p.length;e++)p[e]=p[e]/m;c.envMap.value=e.texture,c.samples.value=d,c.weights.value=p,c.latitudinal.value="latitudinal"===a,o&&(c.poleAxis.value=o);const{_lodMax:g}=this;c.dTheta.value=h,c.mipInt.value=g-n;const v=this._sizeLods[r];Qr(t,3*v*(r>g-kr?r-g+kr:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,Nr)}}function Wr(e,t,n){const r=new Ze(e,t,n);return r.texture.mapping=z,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Qr(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function Xr(){return new Ar({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Zr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include <common>\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:E,depthTest:!1,depthWrite:!1})}function Yr(){return new Ar({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Zr(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:E,depthTest:!1,depthWrite:!1})}function Zr(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Jr(e){let t=new WeakMap,n=null;function r(e){const n=e.target;n.removeEventListener("dispose",r);const i=t.get(n);void 0!==i&&(t.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture){const a=i.mapping,o=303===a||304===a,s=a===U||a===N;if(o||s){if(i.isRenderTargetTexture&&!0===i.needsPMREMUpdate){i.needsPMREMUpdate=!1;let r=t.get(i);return null===n&&(n=new Vr(e)),r=o?n.fromEquirectangular(i,r):n.fromCubemap(i,r),t.set(i,r),r.texture}if(t.has(i))return t.get(i).texture;{const a=i.image;if(o&&a&&a.height>0||s&&a&&function(e){let t=0;const n=6;for(let r=0;r<n;r++)void 0!==e[r]&&t++;return t===n}(a)){null===n&&(n=new Vr(e));const a=o?n.fromEquirectangular(i):n.fromCubemap(i);return t.set(i,a),i.addEventListener("dispose",r),a.texture}return null}}}return i},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Kr(e){const t={};function n(n){if(void 0!==t[n])return t[n];let r;switch(n){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function $r(e,t,n,r){const i={},a=new WeakMap;function o(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",o),delete i[s.id];const A=a.get(s);A&&(t.remove(A),a.delete(s)),r.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],r=e.index,i=e.attributes.position;let o=0;if(null!==r){const e=r.array;o=r.version;for(let t=0,r=e.length;t<r;t+=3){const r=e[t+0],i=e[t+1],a=e[t+2];n.push(r,i,i,a,a,r)}}else{const e=i.array;o=i.version;for(let t=0,r=e.length/3-1;t<r;t+=3){const e=t+0,r=t+1,i=t+2;n.push(e,r,r,i,i,e)}}const s=new(Oe(n)?Cn:Tn)(n,1);s.version=o;const A=a.get(e);A&&t.remove(A),a.set(e,s)}return{get:function(e,t){return!0===i[t.id]||(t.addEventListener("dispose",o),i[t.id]=!0,n.memory.geometries++),t},update:function(e){const n=e.attributes;for(const e in n)t.update(n[e],34962);const r=e.morphAttributes;for(const e in r){const n=r[e];for(let e=0,r=n.length;e<r;e++)t.update(n[e],34962)}},getWireframeAttribute:function(e){const t=a.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return a.get(e)}}}function ei(e,t,n,r){const i=r.isWebGL2;let a,o,s;this.setMode=function(e){a=e},this.setIndex=function(e){o=e.type,s=e.bytesPerElement},this.render=function(t,r){e.drawElements(a,r,o,t*s),n.update(r,a,1)},this.renderInstances=function(r,A,l){if(0===l)return;let c,u;if(i)c=e,u="drawElementsInstanced";else if(c=t.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===c)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");c[u](a,A,o,r*s,l),n.update(A,a,l)}}function ti(e){const t={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:t,programs:null,autoReset:!0,reset:function(){t.frame++,t.calls=0,t.triangles=0,t.points=0,t.lines=0},update:function(e,n,r){switch(t.calls++,n){case 4:t.triangles+=r*(e/3);break;case 1:t.lines+=r*(e/2);break;case 3:t.lines+=r*(e-1);break;case 2:t.lines+=r*e;break;case 0:t.points+=r*e;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function ni(e,t){return e[0]-t[0]}function ri(e,t){return Math.abs(t[1])-Math.abs(e[1])}function ii(e,t,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new Ye,s=[];for(let e=0;e<8;e++)s[e]=[e,0];return{update:function(A,l,c){const u=A.morphTargetInfluences;if(!0===t.isWebGL2){const h=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,f=void 0!==h?h.length:0;let d=a.get(l);if(void 0===d||d.count!==f){void 0!==d&&d.texture.dispose();const g=void 0!==l.morphAttributes.position,v=void 0!==l.morphAttributes.normal,y=void 0!==l.morphAttributes.color,b=l.morphAttributes.position||[],x=l.morphAttributes.normal||[],_=l.morphAttributes.color||[];let w=0;!0===g&&(w=1),!0===v&&(w=2),!0===y&&(w=3);let M=l.attributes.position.count*w,S=1;M>t.maxTextureSize&&(S=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);const E=new Float32Array(M*S*4*f),T=new Je(E,M,S,f);T.type=Z,T.needsUpdate=!0;const C=4*w;for(let L=0;L<f;L++){const D=b[L],R=x[L],q=_[L],O=M*S*4*L;for(let I=0;I<D.count;I++){const k=I*C;!0===g&&(o.fromBufferAttribute(D,I),E[O+k+0]=o.x,E[O+k+1]=o.y,E[O+k+2]=o.z,E[O+k+3]=0),!0===v&&(o.fromBufferAttribute(R,I),E[O+k+4]=o.x,E[O+k+5]=o.y,E[O+k+6]=o.z,E[O+k+7]=0),!0===y&&(o.fromBufferAttribute(q,I),E[O+k+8]=o.x,E[O+k+9]=o.y,E[O+k+10]=o.z,E[O+k+11]=4===q.itemSize?o.w:1)}}function P(){T.dispose(),a.delete(l),l.removeEventListener("dispose",P)}d={count:f,texture:T,size:new De(M,S)},a.set(l,d),l.addEventListener("dispose",P)}let p=0;for(let B=0;B<u.length;B++)p+=u[B];const m=l.morphTargetsRelative?1:1-p;c.getUniforms().setValue(e,"morphTargetBaseInfluence",m),c.getUniforms().setValue(e,"morphTargetInfluences",u),c.getUniforms().setValue(e,"morphTargetsTexture",d.texture,n),c.getUniforms().setValue(e,"morphTargetsTextureSize",d.size)}else{const U=void 0===u?0:u.length;let N=r[l.id];if(void 0===N||N.length!==U){N=[];for(let H=0;H<U;H++)N[H]=[H,0];r[l.id]=N}for(let V=0;V<U;V++){const W=N[V];W[0]=V,W[1]=u[V]}N.sort(ri);for(let Q=0;Q<8;Q++)Q<U&&N[Q][1]?(s[Q][0]=N[Q][0],s[Q][1]=N[Q][1]):(s[Q][0]=Number.MAX_SAFE_INTEGER,s[Q][1]=0);s.sort(ni);const z=l.morphAttributes.position,F=l.morphAttributes.normal;let G=0;for(let X=0;X<8;X++){const Y=s[X],J=Y[0],K=Y[1];J!==Number.MAX_SAFE_INTEGER&&K?(z&&l.getAttribute("morphTarget"+X)!==z[J]&&l.setAttribute("morphTarget"+X,z[J]),F&&l.getAttribute("morphNormal"+X)!==F[J]&&l.setAttribute("morphNormal"+X,F[J]),i[X]=K,G+=K):(z&&!0===l.hasAttribute("morphTarget"+X)&&l.deleteAttribute("morphTarget"+X),F&&!0===l.hasAttribute("morphNormal"+X)&&l.deleteAttribute("morphNormal"+X),i[X]=0)}const j=l.morphTargetsRelative?1:1-G;c.getUniforms().setValue(e,"morphTargetBaseInfluence",j),c.getUniforms().setValue(e,"morphTargetInfluences",i)}}}}function ai(e,t,n,r){let i=new WeakMap;function a(e){const t=e.target;t.removeEventListener("dispose",a),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(e){const o=r.render.frame,s=e.geometry,A=t.get(e,s);return i.get(A)!==o&&(t.update(A),i.set(A,o)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",a)&&e.addEventListener("dispose",a),n.update(e.instanceMatrix,34962),null!==e.instanceColor&&n.update(e.instanceColor,34962)),A},dispose:function(){i=new WeakMap}}}const oi=new Xe,si=new Je,Ai=new Ke,li=new fr,ci=[],ui=[],hi=new Float32Array(16),fi=new Float32Array(9),di=new Float32Array(4);function pi(e,t,n){const r=e[0];if(r<=0||r>0)return e;const i=t*n;let a=ci[i];if(void 0===a&&(a=new Float32Array(i),ci[i]=a),0!==t){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function mi(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function gi(e,t){for(let n=0,r=t.length;n<r;n++)e[n]=t[n]}function vi(e,t){let n=ui[t];void 0===n&&(n=new Int32Array(t),ui[t]=n);for(let r=0;r!==t;++r)n[r]=e.allocateTextureUnit();return n}function yi(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function bi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(mi(n,t))return;e.uniform2fv(this.addr,t),gi(n,t)}}function xi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(mi(n,t))return;e.uniform3fv(this.addr,t),gi(n,t)}}function _i(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(mi(n,t))return;e.uniform4fv(this.addr,t),gi(n,t)}}function wi(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(mi(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),gi(n,t)}else{if(mi(n,r))return;di.set(r),e.uniformMatrix2fv(this.addr,!1,di),gi(n,r)}}function Mi(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(mi(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),gi(n,t)}else{if(mi(n,r))return;fi.set(r),e.uniformMatrix3fv(this.addr,!1,fi),gi(n,r)}}function Si(e,t){const n=this.cache,r=t.elements;if(void 0===r){if(mi(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),gi(n,t)}else{if(mi(n,r))return;hi.set(r),e.uniformMatrix4fv(this.addr,!1,hi),gi(n,r)}}function Ei(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Ti(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(mi(n,t))return;e.uniform2iv(this.addr,t),gi(n,t)}}function Ci(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(mi(n,t))return;e.uniform3iv(this.addr,t),gi(n,t)}}function Pi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(mi(n,t))return;e.uniform4iv(this.addr,t),gi(n,t)}}function Li(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function Di(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(mi(n,t))return;e.uniform2uiv(this.addr,t),gi(n,t)}}function Ri(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(mi(n,t))return;e.uniform3uiv(this.addr,t),gi(n,t)}}function qi(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(mi(n,t))return;e.uniform4uiv(this.addr,t),gi(n,t)}}function Oi(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2D(t||oi,i)}function Ii(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(t||Ai,i)}function ki(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(t||li,i)}function Bi(e,t,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(e.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(t||si,i)}function Ui(e,t){e.uniform1fv(this.addr,t)}function Ni(e,t){const n=pi(t,this.size,2);e.uniform2fv(this.addr,n)}function zi(e,t){const n=pi(t,this.size,3);e.uniform3fv(this.addr,n)}function Fi(e,t){const n=pi(t,this.size,4);e.uniform4fv(this.addr,n)}function Gi(e,t){const n=pi(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function ji(e,t){const n=pi(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function Hi(e,t){const n=pi(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Vi(e,t){e.uniform1iv(this.addr,t)}function Wi(e,t){e.uniform2iv(this.addr,t)}function Qi(e,t){e.uniform3iv(this.addr,t)}function Xi(e,t){e.uniform4iv(this.addr,t)}function Yi(e,t){e.uniform1uiv(this.addr,t)}function Zi(e,t){e.uniform2uiv(this.addr,t)}function Ji(e,t){e.uniform3uiv(this.addr,t)}function Ki(e,t){e.uniform4uiv(this.addr,t)}function $i(e,t,n){const r=this.cache,i=t.length,a=vi(n,i);mi(r,a)||(e.uniform1iv(this.addr,a),gi(r,a));for(let e=0;e!==i;++e)n.setTexture2D(t[e]||oi,a[e])}function ea(e,t,n){const r=this.cache,i=t.length,a=vi(n,i);mi(r,a)||(e.uniform1iv(this.addr,a),gi(r,a));for(let e=0;e!==i;++e)n.setTexture3D(t[e]||Ai,a[e])}function ta(e,t,n){const r=this.cache,i=t.length,a=vi(n,i);mi(r,a)||(e.uniform1iv(this.addr,a),gi(r,a));for(let e=0;e!==i;++e)n.setTextureCube(t[e]||li,a[e])}function na(e,t,n){const r=this.cache,i=t.length,a=vi(n,i);mi(r,a)||(e.uniform1iv(this.addr,a),gi(r,a));for(let e=0;e!==i;++e)n.setTexture2DArray(t[e]||si,a[e])}class ra{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=function(e){switch(e){case 5126:return yi;case 35664:return bi;case 35665:return xi;case 35666:return _i;case 35674:return wi;case 35675:return Mi;case 35676:return Si;case 5124:case 35670:return Ei;case 35667:case 35671:return Ti;case 35668:case 35672:return Ci;case 35669:case 35673:return Pi;case 5125:return Li;case 36294:return Di;case 36295:return Ri;case 36296:return qi;case 35678:case 36198:case 36298:case 36306:case 35682:return Oi;case 35679:case 36299:case 36307:return Ii;case 35680:case 36300:case 36308:case 36293:return ki;case 36289:case 36303:case 36311:case 36292:return Bi}}(t.type)}}class ia{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Ui;case 35664:return Ni;case 35665:return zi;case 35666:return Fi;case 35674:return Gi;case 35675:return ji;case 35676:return Hi;case 5124:case 35670:return Vi;case 35667:case 35671:return Wi;case 35668:case 35672:return Qi;case 35669:case 35673:return Xi;case 5125:return Yi;case 36294:return Zi;case 36295:return Ji;case 36296:return Ki;case 35678:case 36198:case 36298:case 36306:case 35682:return $i;case 35679:case 36299:case 36307:return ea;case 35680:case 36300:case 36308:case 36293:return ta;case 36289:case 36303:case 36311:case 36292:return na}}(t.type)}}class aa{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let i=0,a=r.length;i!==a;++i){const a=r[i];a.setValue(e,t[a.id],n)}}}const oa=/(\w+)(\])?(\[|\.)?/g;function sa(e,t){e.seq.push(t),e.map[t.id]=t}function Aa(e,t,n){const r=e.name,i=r.length;for(oa.lastIndex=0;;){const a=oa.exec(r),o=oa.lastIndex;let s=a[1];const A="]"===a[2],l=a[3];if(A&&(s|=0),void 0===l||"["===l&&o+2===i){sa(n,void 0===l?new ra(s,e,t):new ia(s,e,t));break}{let e=n.map[s];void 0===e&&(e=new aa(s),sa(n,e)),n=e}}}class la{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,35718);for(let r=0;r<n;++r){const n=e.getActiveUniform(t,r);Aa(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,r){const i=this.map[t];void 0!==i&&i.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];void 0!==r&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let i=0,a=t.length;i!==a;++i){const a=t[i],o=n[a.id];!1!==o.needsUpdate&&a.setValue(e,o.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,i=e.length;r!==i;++r){const i=e[r];i.id in t&&n.push(i)}return n}}function ca(e,t,n){const r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),r}let ua=0;function ha(e,t,n){const r=e.getShaderParameter(t,35713),i=e.getShaderInfoLog(t).trim();if(r&&""===i)return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const r=parseInt(a[1]);return n.toUpperCase()+"\n\n"+i+"\n\n"+function(e,t){const n=e.split("\n"),r=[],i=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=i;e<a;e++){const i=e+1;r.push(`${i===t?">":" "} ${i}: ${n[e]}`)}return r.join("\n")}(e.getShaderSource(t),r)}return i}function fa(e,t){const n=function(e){switch(e){case se:return["Linear","( value )"];case Ae:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function da(e,t){let n;switch(t){case q:n="Linear";break;case O:n="Reinhard";break;case I:n="OptimizedCineon";break;case k:n="ACESFilmic";break;case B:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function pa(e){return""!==e}function ma(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function ga(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const va=/^[ \t]*#include +<([\w\d./]+)>/gm;function ya(e){return e.replace(va,ba)}function ba(e,t){const n=Sr[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return ya(n)}const xa=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function _a(e){return e.replace(xa,wa)}function wa(e,t,n,r){let i="";for(let e=parseInt(t);e<parseInt(n);e++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+e+" ]").replace(/UNROLLED_LOOP_INDEX/g,e);return i}function Ma(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Sa(e,t,n,r){const i=e.getContext(),a=n.defines;let o=n.vertexShader,s=n.fragmentShader;const A=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===b?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===x?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===_&&(t="SHADOWMAP_TYPE_VSM"),t}(n),l=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case U:case N:t="ENVMAP_TYPE_CUBE";break;case z:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),c=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===N&&(t="ENVMAP_MODE_REFRACTION");return t}(n),u=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case P:t="ENVMAP_BLENDING_MULTIPLY";break;case L:t="ENVMAP_BLENDING_MIX";break;case D:t="ENVMAP_BLENDING_ADD"}return t}(n),h=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,r=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}(n),f=n.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.normalMapTangentSpace||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(pa).join("\n")}(n),d=function(e){const t=[];for(const n in e){const r=e[n];!1!==r&&t.push("#define "+n+" "+r)}return t.join("\n")}(a),p=i.createProgram();let m,g,v=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(m=[d].filter(pa).join("\n"),m.length>0&&(m+="\n"),g=[f,d].filter(pa).join("\n"),g.length>0&&(g+="\n")):(m=[Ma(n),"#define SHADER_NAME "+n.shaderName,d,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs2?"#define USE_UV2":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+A:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(pa).join("\n"),g=[f,Ma(n),"#define SHADER_NAME "+n.shaderName,d,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+l:"",n.envMap?"#define "+c:"",n.envMap?"#define "+u:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs2?"#define USE_UV2":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+A:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==R?"#define TONE_MAPPING":"",n.toneMapping!==R?Sr.tonemapping_pars_fragment:"",n.toneMapping!==R?da("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Sr.encodings_pars_fragment,fa("linearToOutputTexel",n.outputEncoding),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(pa).join("\n")),o=ya(o),o=ma(o,n),o=ga(o,n),s=ya(s),s=ma(s,n),s=ga(s,n),o=_a(o),s=_a(s),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(v="#version 300 es\n",m=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+m,g=["#define varying in",n.glslVersion===pe?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===pe?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+g);const y=v+g+s,w=ca(i,35633,v+m+o),M=ca(i,35632,y);if(i.attachShader(p,w),i.attachShader(p,M),void 0!==n.index0AttributeName?i.bindAttribLocation(p,0,n.index0AttributeName):!0===n.morphTargets&&i.bindAttribLocation(p,0,"position"),i.linkProgram(p),e.debug.checkShaderErrors){const t=i.getProgramInfoLog(p).trim(),n=i.getShaderInfoLog(w).trim(),r=i.getShaderInfoLog(M).trim();let a=!0,o=!0;if(!1===i.getProgramParameter(p,35714))if(a=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(i,p,w,M);else{const e=ha(i,w,"vertex"),n=ha(i,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(p,35715)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==n&&""!==r||(o=!1);o&&(this.diagnostics={runnable:a,programLog:t,vertexShader:{log:n,prefix:m},fragmentShader:{log:r,prefix:g}})}let S,E;return i.deleteShader(w),i.deleteShader(M),this.getUniforms=function(){return void 0===S&&(S=new la(i,p)),S},this.getAttributes=function(){return void 0===E&&(E=function(e,t){const n={},r=e.getProgramParameter(t,35721);for(let i=0;i<r;i++){const r=e.getActiveAttrib(t,i),a=r.name;let o=1;35674===r.type&&(o=2),35675===r.type&&(o=3),35676===r.type&&(o=4),n[a]={type:r.type,location:e.getAttribLocation(t,a),locationSize:o}}return n}(i,p)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(p),this.program=void 0},this.name=n.shaderName,this.id=ua++,this.cacheKey=t,this.usedTimes=1,this.program=p,this.vertexShader=w,this.fragmentShader=M,this}let Ea=0;class Ta{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return!1===a.has(r)&&(a.add(r),r.usedTimes++),!1===a.has(i)&&(a.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new Ca(e),t.set(e,n)),n}}class Ca{constructor(e){this.id=Ea++,this.code=e,this.usedTimes=0}}function Pa(e,t,n,r,i,a,o){const s=new Ft,A=new Ta,l=[],c=i.isWebGL2,u=i.logarithmicDepthBuffer,h=i.vertexTextures;let f=i.precision;const d={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(e){return 1===e?"uv2":"uv"}return{getParameters:function(a,s,l,m,g){const v=m.fog,y=g.geometry,b=a.isMeshStandardMaterial?m.environment:null,x=(a.isMeshStandardMaterial?n:t).get(a.envMap||b),_=x&&x.mapping===z?x.image.height:null,w=d[a.type];null!==a.precision&&(f=i.getMaxPrecision(a.precision),f!==a.precision&&console.warn("THREE.WebGLProgram.getParameters:",a.precision,"not supported, using",f,"instead."));const E=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,C=void 0!==E?E.length:0;let P,L,D,q,O=0;if(void 0!==y.morphAttributes.position&&(O=1),void 0!==y.morphAttributes.normal&&(O=2),void 0!==y.morphAttributes.color&&(O=3),w){const e=Tr[w];P=e.vertexShader,L=e.fragmentShader}else P=a.vertexShader,L=a.fragmentShader,A.update(a),D=A.getVertexShaderID(a),q=A.getFragmentShaderID(a);const I=e.getRenderTarget(),k=!0===g.isInstancedMesh,B=!!a.map,U=!!a.matcap,N=!!x,F=!!a.aoMap,G=!!a.lightMap,j=!!a.bumpMap,H=!!a.normalMap,V=!!a.displacementMap,W=!!a.emissiveMap,Q=!!a.metalnessMap,X=!!a.roughnessMap,Y=a.clearcoat>0,Z=a.iridescence>0,J=a.sheen>0,K=a.transmission>0,$=Y&&!!a.clearcoatMap,ee=Y&&!!a.clearcoatNormalMap,te=Y&&!!a.clearcoatRoughnessMap,ne=Z&&!!a.iridescenceMap,re=Z&&!!a.iridescenceThicknessMap,ie=J&&!!a.sheenColorMap,ae=J&&!!a.sheenRoughnessMap,oe=!!a.specularMap,ce=!!a.specularColorMap,ue=!!a.specularIntensityMap,he=K&&!!a.transmissionMap,fe=K&&!!a.thicknessMap,de=!!a.gradientMap,pe=!!a.alphaMap,me=a.alphaTest>0,ge=!!a.extensions,ve=!!y.attributes.uv2;return{isWebGL2:c,shaderID:w,shaderName:a.type,vertexShader:P,fragmentShader:L,defines:a.defines,customVertexShaderID:D,customFragmentShaderID:q,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,instancing:k,instancingColor:k&&null!==g.instanceColor,supportsVertexTextures:h,outputEncoding:null===I?e.outputEncoding:!0===I.isXRRenderTarget?I.texture.encoding:se,map:B,matcap:U,envMap:N,envMapMode:N&&x.mapping,envMapCubeUVHeight:_,aoMap:F,lightMap:G,bumpMap:j,normalMap:H,displacementMap:h&&V,emissiveMap:W,normalMapObjectSpace:H&&1===a.normalMapType,normalMapTangentSpace:H&&a.normalMapType===le,decodeVideoTexture:B&&!0===a.map.isVideoTexture&&a.map.encoding===Ae,metalnessMap:Q,roughnessMap:X,clearcoat:Y,clearcoatMap:$,clearcoatNormalMap:ee,clearcoatRoughnessMap:te,iridescence:Z,iridescenceMap:ne,iridescenceThicknessMap:re,sheen:J,sheenColorMap:ie,sheenRoughnessMap:ae,specularMap:oe,specularColorMap:ce,specularIntensityMap:ue,transmission:K,transmissionMap:he,thicknessMap:fe,gradientMap:de,opaque:!1===a.transparent&&a.blending===T,alphaMap:pe,alphaTest:me,combine:a.combine,mapUv:B&&p(a.map.channel),aoMapUv:F&&p(a.aoMap.channel),lightMapUv:G&&p(a.lightMap.channel),bumpMapUv:j&&p(a.bumpMap.channel),normalMapUv:H&&p(a.normalMap.channel),displacementMapUv:V&&p(a.displacementMap.channel),emissiveMapUv:W&&p(a.emissiveMap.channel),metalnessMapUv:Q&&p(a.metalnessMap.channel),roughnessMapUv:X&&p(a.roughnessMap.channel),clearcoatMapUv:$&&p(a.clearcoatMap.channel),clearcoatNormalMapUv:ee&&p(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:te&&p(a.clearcoatRoughnessMap.channel),iridescenceMapUv:ne&&p(a.iridescenceMap.channel),iridescenceThicknessMapUv:re&&p(a.iridescenceThicknessMap.channel),sheenColorMapUv:ie&&p(a.sheenColorMap.channel),sheenRoughnessMapUv:ae&&p(a.sheenRoughnessMap.channel),specularMapUv:oe&&p(a.specularMap.channel),specularColorMapUv:ce&&p(a.specularColorMap.channel),specularIntensityMapUv:ue&&p(a.specularIntensityMap.channel),transmissionMapUv:he&&p(a.transmissionMap.channel),thicknessMapUv:fe&&p(a.thicknessMap.channel),alphaMapUv:pe&&p(a.alphaMap.channel),vertexTangents:H&&!!y.attributes.tangent,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,vertexUvs2:ve,pointsUvs:!0===g.isPoints&&!!y.attributes.uv&&(B||pe),fog:!!v,useFog:!0===a.fog,fogExp2:v&&v.isFogExp2,flatShading:!0===a.flatShading,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:C,morphTextureStride:O,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:a.toneMapped?e.toneMapping:R,useLegacyLights:e.useLegacyLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===S,flipSided:a.side===M,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:ge&&!0===a.extensions.derivatives,extensionFragDepth:ge&&!0===a.extensions.fragDepth,extensionDrawBuffers:ge&&!0===a.extensions.drawBuffers,extensionShaderTextureLOD:ge&&!0===a.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||r.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){s.disableAll(),t.isWebGL2&&s.enable(0);t.supportsVertexTextures&&s.enable(1);t.instancing&&s.enable(2);t.instancingColor&&s.enable(3);t.matcap&&s.enable(4);t.envMap&&s.enable(5);t.normalMapObjectSpace&&s.enable(6);t.normalMapTangentSpace&&s.enable(7);t.clearcoat&&s.enable(8);t.iridescence&&s.enable(9);t.alphaTest&&s.enable(10);t.vertexColors&&s.enable(11);t.vertexAlphas&&s.enable(12);t.vertexUvs2&&s.enable(13);t.vertexTangents&&s.enable(14);e.push(s.mask),s.disableAll(),t.fog&&s.enable(0);t.useFog&&s.enable(1);t.flatShading&&s.enable(2);t.logarithmicDepthBuffer&&s.enable(3);t.skinning&&s.enable(4);t.morphTargets&&s.enable(5);t.morphNormals&&s.enable(6);t.morphColors&&s.enable(7);t.premultipliedAlpha&&s.enable(8);t.shadowMapEnabled&&s.enable(9);t.useLegacyLights&&s.enable(10);t.doubleSided&&s.enable(11);t.flipSided&&s.enable(12);t.useDepthPacking&&s.enable(13);t.dithering&&s.enable(14);t.transmission&&s.enable(15);t.sheen&&s.enable(16);t.decodeVideoTexture&&s.enable(17);t.opaque&&s.enable(18);t.pointsUvs&&s.enable(19);e.push(s.mask)}(n,t),n.push(e.outputEncoding)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=d[e.type];let n;if(t){const e=Tr[t];n=sr.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let r;for(let e=0,t=l.length;e<t;e++){const t=l[e];if(t.cacheKey===n){r=t,++r.usedTimes;break}}return void 0===r&&(r=new Sa(e,n,t,a),l.push(r)),r},releaseProgram:function(e){if(0==--e.usedTimes){const t=l.indexOf(e);l[t]=l[l.length-1],l.pop(),e.destroy()}},releaseShaderCache:function(e){A.remove(e)},programs:l,dispose:function(){A.dispose()}}}function La(){let e=new WeakMap;return{get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,r){e.get(t)[n]=r},dispose:function(){e=new WeakMap}}}function Da(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Ra(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function qa(){const e=[];let t=0;const n=[],r=[],i=[];function a(n,r,i,a,o,s){let A=e[t];return void 0===A?(A={id:n.id,object:n,geometry:r,material:i,groupOrder:a,renderOrder:n.renderOrder,z:o,group:s},e[t]=A):(A.id=n.id,A.object=n,A.geometry=r,A.material=i,A.groupOrder=a,A.renderOrder=n.renderOrder,A.z=o,A.group=s),t++,A}return{opaque:n,transmissive:r,transparent:i,init:function(){t=0,n.length=0,r.length=0,i.length=0},push:function(e,t,o,s,A,l){const c=a(e,t,o,s,A,l);o.transmission>0?r.push(c):!0===o.transparent?i.push(c):n.push(c)},unshift:function(e,t,o,s,A,l){const c=a(e,t,o,s,A,l);o.transmission>0?r.unshift(c):!0===o.transparent?i.unshift(c):n.unshift(c)},finish:function(){for(let n=t,r=e.length;n<r;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||Da),r.length>1&&r.sort(t||Ra),i.length>1&&i.sort(t||Ra)}}}function Oa(){let e=new WeakMap;return{get:function(t,n){const r=e.get(t);let i;return void 0===r?(i=new qa,e.set(t,[i])):n>=r.length?(i=new qa,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function Ia(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new et,color:new xn};break;case"SpotLight":n={position:new et,direction:new et,color:new xn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new et,color:new xn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new et,skyColor:new xn,groundColor:new xn};break;case"RectAreaLight":n={color:new xn,position:new et,halfWidth:new et,halfHeight:new et}}return e[t.id]=n,n}}}let ka=0;function Ba(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Ua(e,t){const n=new Ia,r=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new De,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0};for(let e=0;e<9;e++)i.probe.push(new et);const a=new et,o=new Lt,s=new Lt;return{setup:function(a,o){let s=0,A=0,l=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let c=0,u=0,h=0,f=0,d=0,p=0,m=0,g=0,v=0,y=0;a.sort(Ba);const b=!0===o?Math.PI:1;for(let e=0,t=a.length;e<t;e++){const t=a[e],o=t.color,x=t.intensity,_=t.distance,w=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)s+=o.r*x*b,A+=o.g*x*b,l+=o.b*x*b;else if(t.isLightProbe)for(let e=0;e<9;e++)i.probe[e].addScaledVector(t.sh.coefficients[e],x);else if(t.isDirectionalLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*b),t.castShadow){const e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,i.directionalShadow[c]=n,i.directionalShadowMap[c]=w,i.directionalShadowMatrix[c]=t.shadow.matrix,p++}i.directional[c]=e,c++}else if(t.isSpotLight){const e=n.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(o).multiplyScalar(x*b),e.distance=_,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,i.spot[h]=e;const a=t.shadow;if(t.map&&(i.spotLightMap[v]=t.map,v++,a.updateMatrices(t),t.castShadow&&y++),i.spotLightMatrix[h]=a.matrix,t.castShadow){const e=r.get(t);e.shadowBias=a.bias,e.shadowNormalBias=a.normalBias,e.shadowRadius=a.radius,e.shadowMapSize=a.mapSize,i.spotShadow[h]=e,i.spotShadowMap[h]=w,g++}h++}else if(t.isRectAreaLight){const e=n.get(t);e.color.copy(o).multiplyScalar(x),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),i.rectArea[f]=e,f++}else if(t.isPointLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*b),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,n=r.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,n.shadowCameraNear=e.camera.near,n.shadowCameraFar=e.camera.far,i.pointShadow[u]=n,i.pointShadowMap[u]=w,i.pointShadowMatrix[u]=t.shadow.matrix,m++}i.point[u]=e,u++}else if(t.isHemisphereLight){const e=n.get(t);e.skyColor.copy(t.color).multiplyScalar(x*b),e.groundColor.copy(t.groundColor).multiplyScalar(x*b),i.hemi[d]=e,d++}}f>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=Er.LTC_FLOAT_1,i.rectAreaLTC2=Er.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=Er.LTC_HALF_1,i.rectAreaLTC2=Er.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=s,i.ambient[1]=A,i.ambient[2]=l;const x=i.hash;x.directionalLength===c&&x.pointLength===u&&x.spotLength===h&&x.rectAreaLength===f&&x.hemiLength===d&&x.numDirectionalShadows===p&&x.numPointShadows===m&&x.numSpotShadows===g&&x.numSpotMaps===v||(i.directional.length=c,i.spot.length=h,i.rectArea.length=f,i.point.length=u,i.hemi.length=d,i.directionalShadow.length=p,i.directionalShadowMap.length=p,i.pointShadow.length=m,i.pointShadowMap.length=m,i.spotShadow.length=g,i.spotShadowMap.length=g,i.directionalShadowMatrix.length=p,i.pointShadowMatrix.length=m,i.spotLightMatrix.length=g+v-y,i.spotLightMap.length=v,i.numSpotLightShadowsWithMaps=y,x.directionalLength=c,x.pointLength=u,x.spotLength=h,x.rectAreaLength=f,x.hemiLength=d,x.numDirectionalShadows=p,x.numPointShadows=m,x.numSpotShadows=g,x.numSpotMaps=v,i.version=ka++)},setupView:function(e,t){let n=0,r=0,A=0,l=0,c=0;const u=t.matrixWorldInverse;for(let t=0,h=e.length;t<h;t++){const h=e[t];if(h.isDirectionalLight){const e=i.directional[n];e.direction.setFromMatrixPosition(h.matrixWorld),a.setFromMatrixPosition(h.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),n++}else if(h.isSpotLight){const e=i.spot[A];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(u),e.direction.setFromMatrixPosition(h.matrixWorld),a.setFromMatrixPosition(h.target.matrixWorld),e.direction.sub(a),e.direction.transformDirection(u),A++}else if(h.isRectAreaLight){const e=i.rectArea[l];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(u),s.identity(),o.copy(h.matrixWorld),o.premultiply(u),s.extractRotation(o),e.halfWidth.set(.5*h.width,0,0),e.halfHeight.set(0,.5*h.height,0),e.halfWidth.applyMatrix4(s),e.halfHeight.applyMatrix4(s),l++}else if(h.isPointLight){const e=i.point[r];e.position.setFromMatrixPosition(h.matrixWorld),e.position.applyMatrix4(u),r++}else if(h.isHemisphereLight){const e=i.hemi[c];e.direction.setFromMatrixPosition(h.matrixWorld),e.direction.transformDirection(u),c++}}},state:i}}function Na(e,t){const n=new Ua(e,t),r=[],i=[];return{init:function(){r.length=0,i.length=0},state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:function(e){n.setup(r,e)},setupLightsView:function(e){n.setupView(r,e)},pushLight:function(e){r.push(e)},pushShadow:function(e){i.push(e)}}}function za(e,t){let n=new WeakMap;return{get:function(r,i=0){const a=n.get(r);let o;return void 0===a?(o=new Na(e,t),n.set(r,[o])):i>=a.length?(o=new Na(e,t),a.push(o)):o=a[i],o},dispose:function(){n=new WeakMap}}}class Fa extends mn{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ga extends mn{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function ja(e,t,n){let r=new xr;const i=new De,a=new De,o=new Ye,s=new Fa({depthPacking:3201}),A=new Ga,l={},c=n.maxTextureSize,u={[w]:M,[M]:w,[S]:S},h=new Ar({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new De},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const d=new Bn;d.setAttribute("position",new En(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const p=new tr(d,h),m=this;function g(n,r){const a=t.update(p);h.defines.VSM_SAMPLES!==n.blurSamples&&(h.defines.VSM_SAMPLES=n.blurSamples,f.defines.VSM_SAMPLES=n.blurSamples,h.needsUpdate=!0,f.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Ze(i.x,i.y)),h.uniforms.shadow_pass.value=n.map.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,a,h,p,null),f.uniforms.shadow_pass.value=n.mapPass.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,a,f,p,null)}function v(t,n,r,i){let a=null;const o=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==o)a=o;else if(a=!0===r.isPointLight?A:s,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=a.uuid,t=n.uuid;let r=l[e];void 0===r&&(r={},l[e]=r);let i=r[t];void 0===i&&(i=a.clone(),r[t]=i),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,a.side=i===_?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===r.isPointLight&&!0===a.isMeshDistanceMaterial){e.properties.get(a).light=r}return a}function y(n,i,a,o,s){if(!1===n.visible)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===_)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const r=t.update(n),i=n.material;if(Array.isArray(i)){const t=r.groups;for(let A=0,l=t.length;A<l;A++){const l=t[A],c=i[l.materialIndex];if(c&&c.visible){const t=v(n,c,o,s);e.renderBufferDirect(a,null,r,t,n,l)}}}else if(i.visible){const t=v(n,i,o,s);e.renderBufferDirect(a,null,r,t,n,null)}}const A=n.children;for(let e=0,t=A.length;e<t;e++)y(A[e],i,a,o,s)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=b,this.render=function(t,n,s){if(!1===m.enabled)return;if(!1===m.autoUpdate&&!1===m.needsUpdate)return;if(0===t.length)return;const A=e.getRenderTarget(),l=e.getActiveCubeFace(),u=e.getActiveMipmapLevel(),h=e.state;h.setBlending(E),h.buffers.color.setClear(1,1,1,1),h.buffers.depth.setTest(!0),h.setScissorTest(!1);for(let A=0,l=t.length;A<l;A++){const l=t[A],u=l.shadow;if(void 0===u){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===u.autoUpdate&&!1===u.needsUpdate)continue;i.copy(u.mapSize);const f=u.getFrameExtents();if(i.multiply(f),a.copy(u.mapSize),(i.x>c||i.y>c)&&(i.x>c&&(a.x=Math.floor(c/f.x),i.x=a.x*f.x,u.mapSize.x=a.x),i.y>c&&(a.y=Math.floor(c/f.y),i.y=a.y*f.y,u.mapSize.y=a.y)),null===u.map){const e=this.type!==_?{minFilter:H,magFilter:H}:{};u.map=new Ze(i.x,i.y,e),u.map.texture.name=l.name+".shadowMap",u.camera.updateProjectionMatrix()}e.setRenderTarget(u.map),e.clear();const d=u.getViewportCount();for(let e=0;e<d;e++){const t=u.getViewport(e);o.set(a.x*t.x,a.y*t.y,a.x*t.z,a.y*t.w),h.viewport(o),u.updateMatrices(l,e),r=u.getFrustum(),y(n,s,u.camera,l,this.type)}!0!==u.isPointLightShadow&&this.type===_&&g(u,s),u.needsUpdate=!1}m.needsUpdate=!1,e.setRenderTarget(A,l,u)}}function Ha(e,t,n){const r=n.isWebGL2;const i=new function(){let t=!1;const n=new Ye;let r=null;const i=new Ye(0,0,0,0);return{setMask:function(n){r===n||t||(e.colorMask(n,n,n,n),r=n)},setLocked:function(e){t=e},setClear:function(t,r,a,o,s){!0===s&&(t*=o,r*=o,a*=o),n.set(t,r,a,o),!1===i.equals(n)&&(e.clearColor(t,r,a,o),i.copy(n))},reset:function(){t=!1,r=null,i.set(-1,0,0,0)}}},a=new function(){let t=!1,n=null,r=null,i=null;return{setTest:function(e){e?V(2929):W(2929)},setMask:function(r){n===r||t||(e.depthMask(r),n=r)},setFunc:function(t){if(r!==t){switch(t){case 0:e.depthFunc(512);break;case 1:e.depthFunc(519);break;case 2:e.depthFunc(513);break;case 3:default:e.depthFunc(515);break;case 4:e.depthFunc(514);break;case 5:e.depthFunc(518);break;case 6:e.depthFunc(516);break;case 7:e.depthFunc(517)}r=t}},setLocked:function(e){t=e},setClear:function(t){i!==t&&(e.clearDepth(t),i=t)},reset:function(){t=!1,n=null,r=null,i=null}}},o=new function(){let t=!1,n=null,r=null,i=null,a=null,o=null,s=null,A=null,l=null;return{setTest:function(e){t||(e?V(2960):W(2960))},setMask:function(r){n===r||t||(e.stencilMask(r),n=r)},setFunc:function(t,n,o){r===t&&i===n&&a===o||(e.stencilFunc(t,n,o),r=t,i=n,a=o)},setOp:function(t,n,r){o===t&&s===n&&A===r||(e.stencilOp(t,n,r),o=t,s=n,A=r)},setLocked:function(e){t=e},setClear:function(t){l!==t&&(e.clearStencil(t),l=t)},reset:function(){t=!1,n=null,r=null,i=null,a=null,o=null,s=null,A=null,l=null}}},s=new WeakMap,A=new WeakMap;let l={},c={},u=new WeakMap,h=[],f=null,d=!1,p=null,m=null,g=null,v=null,y=null,b=null,x=null,_=!1,w=null,P=null,L=null,D=null,R=null;const q=e.getParameter(35661);let O=!1,I=0;const k=e.getParameter(7938);-1!==k.indexOf("WebGL")?(I=parseFloat(/^WebGL (\d)/.exec(k)[1]),O=I>=1):-1!==k.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(k)[1]),O=I>=2);let B=null,U={};const N=e.getParameter(3088),z=e.getParameter(2978),F=(new Ye).fromArray(N),G=(new Ye).fromArray(z);function j(t,n,r){const i=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;t<r;t++)e.texImage2D(n+t,0,6408,1,1,0,6408,5121,i);return a}const H={};function V(t){!0!==l[t]&&(e.enable(t),l[t]=!0)}function W(t){!1!==l[t]&&(e.disable(t),l[t]=!1)}H[3553]=j(3553,3553,1),H[34067]=j(34067,34069,6),i.setClear(0,0,0,1),a.setClear(1),o.setClear(0),V(2929),a.setFunc(3),Z(!1),J(1),V(2884),Y(E);const Q={[C]:32774,101:32778,102:32779};if(r)Q[103]=32775,Q[104]=32776;else{const e=t.get("EXT_blend_minmax");null!==e&&(Q[103]=e.MIN_EXT,Q[104]=e.MAX_EXT)}const X={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function Y(t,n,r,i,a,o,s,A){if(t!==E){if(!1===d&&(V(3042),d=!0),5===t)a=a||n,o=o||r,s=s||i,n===m&&a===y||(e.blendEquationSeparate(Q[n],Q[a]),m=n,y=a),r===g&&i===v&&o===b&&s===x||(e.blendFuncSeparate(X[r],X[i],X[o],X[s]),g=r,v=i,b=o,x=s),p=t,_=!1;else if(t!==p||A!==_){if(m===C&&y===C||(e.blendEquation(32774),m=C,y=C),A)switch(t){case T:e.blendFuncSeparate(1,771,1,771);break;case 2:e.blendFunc(1,1);break;case 3:e.blendFuncSeparate(0,769,0,1);break;case 4:e.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}else switch(t){case T:e.blendFuncSeparate(770,771,1,771);break;case 2:e.blendFunc(770,1);break;case 3:e.blendFuncSeparate(0,769,0,1);break;case 4:e.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",t)}g=null,v=null,b=null,x=null,p=t,_=A}}else!0===d&&(W(3042),d=!1)}function Z(t){w!==t&&(t?e.frontFace(2304):e.frontFace(2305),w=t)}function J(t){0!==t?(V(2884),t!==P&&(1===t?e.cullFace(1029):2===t?e.cullFace(1028):e.cullFace(1032))):W(2884),P=t}function K(t,n,r){t?(V(32823),D===n&&R===r||(e.polygonOffset(n,r),D=n,R=r)):W(32823)}return{buffers:{color:i,depth:a,stencil:o},enable:V,disable:W,bindFramebuffer:function(t,n){return c[t]!==n&&(e.bindFramebuffer(t,n),c[t]=n,r&&(36009===t&&(c[36160]=n),36160===t&&(c[36009]=n)),!0)},drawBuffers:function(r,i){let a=h,o=!1;if(r)if(a=u.get(i),void 0===a&&(a=[],u.set(i,a)),r.isWebGLMultipleRenderTargets){const e=r.texture;if(a.length!==e.length||36064!==a[0]){for(let t=0,n=e.length;t<n;t++)a[t]=36064+t;a.length=e.length,o=!0}}else 36064!==a[0]&&(a[0]=36064,o=!0);else 1029!==a[0]&&(a[0]=1029,o=!0);o&&(n.isWebGL2?e.drawBuffers(a):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(a))},useProgram:function(t){return f!==t&&(e.useProgram(t),f=t,!0)},setBlending:Y,setMaterial:function(e,t){e.side===S?W(2884):V(2884);let n=e.side===M;t&&(n=!n),Z(n),e.blending===T&&!1===e.transparent?Y(E):Y(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),a.setFunc(e.depthFunc),a.setTest(e.depthTest),a.setMask(e.depthWrite),i.setMask(e.colorWrite);const r=e.stencilWrite;o.setTest(r),r&&(o.setMask(e.stencilWriteMask),o.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),o.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),K(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?V(32926):W(32926)},setFlipSided:Z,setCullFace:J,setLineWidth:function(t){t!==L&&(O&&e.lineWidth(t),L=t)},setPolygonOffset:K,setScissorTest:function(e){e?V(3089):W(3089)},activeTexture:function(t){void 0===t&&(t=33984+q-1),B!==t&&(e.activeTexture(t),B=t)},bindTexture:function(t,n,r){void 0===r&&(r=null===B?33984+q-1:B);let i=U[r];void 0===i&&(i={type:void 0,texture:void 0},U[r]=i),i.type===t&&i.texture===n||(B!==r&&(e.activeTexture(r),B=r),e.bindTexture(t,n||H[t]),i.type=t,i.texture=n)},unbindTexture:function(){const t=U[B];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},updateUBOMapping:function(t,n){let r=A.get(n);void 0===r&&(r=new WeakMap,A.set(n,r));let i=r.get(t);void 0===i&&(i=e.getUniformBlockIndex(n,t.name),r.set(t,i))},uniformBlockBinding:function(t,n){const r=A.get(n).get(t);s.get(n)!==r&&(e.uniformBlockBinding(n,r,t.__bindingPointIndex),s.set(n,r))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){console.error("THREE.WebGLState:",e)}},scissor:function(t){!1===F.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),F.copy(t))},viewport:function(t){!1===G.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),G.copy(t))},reset:function(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),!0===r&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),l={},B=null,U={},c={},u=new WeakMap,h=[],f=null,d=!1,p=null,m=null,g=null,v=null,y=null,b=null,x=null,_=!1,w=null,P=null,L=null,D=null,R=null,F.set(0,0,e.canvas.width,e.canvas.height),G.set(0,0,e.canvas.width,e.canvas.height),i.reset(),a.reset(),o.reset()}}}function Va(e,t,n,r,i,a,o){const s=i.isWebGL2,A=i.maxTextures,l=i.maxCubemapSize,c=i.maxTextureSize,u=i.maxSamples,h=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,f="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),d=new WeakMap;let p;const m=new WeakMap;let g=!1;try{g="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function v(e,t){return g?new OffscreenCanvas(e,t):Ie("canvas")}function y(e,t,n,r){let i=1;if((e.width>r||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const r=t?Te:Math.floor,a=r(i*e.width),o=r(i*e.height);void 0===p&&(p=v(a,o));const s=n?v(a,o):p;s.width=a,s.height=o;return s.getContext("2d").drawImage(e,0,0,a,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+a+"x"+o+")."),s}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function b(e){return Ee(e.width)&&Ee(e.height)}function x(e,t){return e.generateMipmaps&&t&&e.minFilter!==H&&e.minFilter!==W}function _(t){e.generateMipmap(t)}function w(n,r,i,a,o=!1){if(!1===s)return r;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let A=r;return 6403===r&&(5126===i&&(A=33326),5131===i&&(A=33325),5121===i&&(A=33321)),33319===r&&(5126===i&&(A=33328),5131===i&&(A=33327),5121===i&&(A=33323)),6408===r&&(5126===i&&(A=34836),5131===i&&(A=34842),5121===i&&(A=a===Ae&&!1===o?35907:32856),32819===i&&(A=32854),32820===i&&(A=32855)),33325!==A&&33326!==A&&33327!==A&&33328!==A&&34842!==A&&34836!==A||t.get("EXT_color_buffer_float"),A}function M(e,t,n){return!0===x(e,n)||e.isFramebufferTexture&&e.minFilter!==H&&e.minFilter!==W?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function S(e){return e===H||1004===e||e===V?9728:9729}function E(e){const t=e.target;t.removeEventListener("dispose",E),function(e){const t=r.get(e);if(void 0===t.__webglInit)return;const n=e.source,i=m.get(n);if(i){const r=i[t.__cacheKey];r.usedTimes--,0===r.usedTimes&&C(e),0===Object.keys(i).length&&m.delete(n)}r.remove(e)}(t),t.isVideoTexture&&d.delete(t)}function T(t){const n=t.target;n.removeEventListener("dispose",T),function(t){const n=t.texture,i=r.get(t),a=r.get(n);void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),o.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(i.__webglFramebuffer[t]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&e.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let t=0;t<i.__webglColorRenderbuffer.length;t++)i.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(i.__webglColorRenderbuffer[t]);i.__webglDepthRenderbuffer&&e.deleteRenderbuffer(i.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let t=0,i=n.length;t<i;t++){const i=r.get(n[t]);i.__webglTexture&&(e.deleteTexture(i.__webglTexture),o.memory.textures--),r.remove(n[t])}r.remove(n),r.remove(t)}(n)}function C(t){const n=r.get(t);e.deleteTexture(n.__webglTexture);const i=t.source;delete m.get(i)[n.__cacheKey],o.memory.textures--}let P=0;function L(e,t){const i=r.get(e);if(e.isVideoTexture&&function(e){const t=o.render.frame;d.get(e)!==t&&(d.set(e,t),e.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&i.__version!==e.version){const n=e.image;if(null===n)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==n.complete)return void I(i,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(3553,i.__webglTexture,33984+t)}const D={[F]:10497,[G]:33071,[j]:33648},R={[H]:9728,1004:9984,[V]:9986,[W]:9729,1007:9985,[Q]:9987};function q(n,a,o){if(o?(e.texParameteri(n,10242,D[a.wrapS]),e.texParameteri(n,10243,D[a.wrapT]),32879!==n&&35866!==n||e.texParameteri(n,32882,D[a.wrapR]),e.texParameteri(n,10240,R[a.magFilter]),e.texParameteri(n,10241,R[a.minFilter])):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),32879!==n&&35866!==n||e.texParameteri(n,32882,33071),a.wrapS===G&&a.wrapT===G||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,10240,S(a.magFilter)),e.texParameteri(n,10241,S(a.minFilter)),a.minFilter!==H&&a.minFilter!==W&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){const o=t.get("EXT_texture_filter_anisotropic");if(a.magFilter===H)return;if(a.minFilter!==V&&a.minFilter!==Q)return;if(a.type===Z&&!1===t.has("OES_texture_float_linear"))return;if(!1===s&&a.type===J&&!1===t.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function O(t,n){let r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",E));const i=n.source;let a=m.get(i);void 0===a&&(a={},m.set(i,a));const s=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.encoding),t.join()}(n);if(s!==t.__cacheKey){void 0===a[s]&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;const i=a[t.__cacheKey];void 0!==i&&(a[t.__cacheKey].usedTimes--,0===i.usedTimes&&C(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function I(t,i,o){let A=3553;(i.isDataArrayTexture||i.isCompressedArrayTexture)&&(A=35866),i.isData3DTexture&&(A=32879);const l=O(t,i),u=i.source;n.bindTexture(A,t.__webglTexture,33984+o);const h=r.get(u);if(u.version!==h.__version||!0===l){n.activeTexture(33984+o),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const t=function(e){return!s&&(e.wrapS!==G||e.wrapT!==G||e.minFilter!==H&&e.minFilter!==W)}(i)&&!1===b(i.image);let r=y(i.image,t,!1,c);r=ne(i,r);const f=b(r)||s,d=a.convert(i.format,i.encoding);let p,m=a.convert(i.type),g=w(i.internalFormat,d,m,i.encoding,i.isVideoTexture);q(A,i,f);const v=i.mipmaps,S=s&&!0!==i.isVideoTexture,E=void 0===h.__version||!0===l,T=M(i,r,f);if(i.isDepthTexture)g=6402,s?g=i.type===Z?36012:i.type===Y?33190:i.type===K?35056:33189:i.type===Z&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),i.format===ee&&6402===g&&1012!==i.type&&i.type!==Y&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=Y,m=a.convert(i.type)),i.format===te&&6402===g&&(g=34041,i.type!==K&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=K,m=a.convert(i.type))),E&&(S?n.texStorage2D(3553,1,g,r.width,r.height):n.texImage2D(3553,0,g,r.width,r.height,0,d,m,null));else if(i.isDataTexture)if(v.length>0&&f){S&&E&&n.texStorage2D(3553,T,g,v[0].width,v[0].height);for(let e=0,t=v.length;e<t;e++)p=v[e],S?n.texSubImage2D(3553,e,0,0,p.width,p.height,d,m,p.data):n.texImage2D(3553,e,g,p.width,p.height,0,d,m,p.data);i.generateMipmaps=!1}else S?(E&&n.texStorage2D(3553,T,g,r.width,r.height),n.texSubImage2D(3553,0,0,0,r.width,r.height,d,m,r.data)):n.texImage2D(3553,0,g,r.width,r.height,0,d,m,r.data);else if(i.isCompressedTexture)if(i.isCompressedArrayTexture){S&&E&&n.texStorage3D(35866,T,g,v[0].width,v[0].height,r.depth);for(let e=0,t=v.length;e<t;e++)p=v[e],i.format!==$?null!==d?S?n.compressedTexSubImage3D(35866,e,0,0,0,p.width,p.height,r.depth,d,p.data,0,0):n.compressedTexImage3D(35866,e,g,p.width,p.height,r.depth,0,p.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):S?n.texSubImage3D(35866,e,0,0,0,p.width,p.height,r.depth,d,m,p.data):n.texImage3D(35866,e,g,p.width,p.height,r.depth,0,d,m,p.data)}else{S&&E&&n.texStorage2D(3553,T,g,v[0].width,v[0].height);for(let e=0,t=v.length;e<t;e++)p=v[e],i.format!==$?null!==d?S?n.compressedTexSubImage2D(3553,e,0,0,p.width,p.height,d,p.data):n.compressedTexImage2D(3553,e,g,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):S?n.texSubImage2D(3553,e,0,0,p.width,p.height,d,m,p.data):n.texImage2D(3553,e,g,p.width,p.height,0,d,m,p.data)}else if(i.isDataArrayTexture)S?(E&&n.texStorage3D(35866,T,g,r.width,r.height,r.depth),n.texSubImage3D(35866,0,0,0,0,r.width,r.height,r.depth,d,m,r.data)):n.texImage3D(35866,0,g,r.width,r.height,r.depth,0,d,m,r.data);else if(i.isData3DTexture)S?(E&&n.texStorage3D(32879,T,g,r.width,r.height,r.depth),n.texSubImage3D(32879,0,0,0,0,r.width,r.height,r.depth,d,m,r.data)):n.texImage3D(32879,0,g,r.width,r.height,r.depth,0,d,m,r.data);else if(i.isFramebufferTexture){if(E)if(S)n.texStorage2D(3553,T,g,r.width,r.height);else{let e=r.width,t=r.height;for(let r=0;r<T;r++)n.texImage2D(3553,r,g,e,t,0,d,m,null),e>>=1,t>>=1}}else if(v.length>0&&f){S&&E&&n.texStorage2D(3553,T,g,v[0].width,v[0].height);for(let e=0,t=v.length;e<t;e++)p=v[e],S?n.texSubImage2D(3553,e,0,0,d,m,p):n.texImage2D(3553,e,g,d,m,p);i.generateMipmaps=!1}else S?(E&&n.texStorage2D(3553,T,g,r.width,r.height),n.texSubImage2D(3553,0,0,0,d,m,r)):n.texImage2D(3553,0,g,d,m,r);x(i,f)&&_(A),h.__version=u.version,i.onUpdate&&i.onUpdate(i)}t.__version=i.version}function k(t,i,o,s,A){const l=a.convert(o.format,o.encoding),c=a.convert(o.type),u=w(o.internalFormat,l,c,o.encoding);r.get(i).__hasExternalTextures||(32879===A||35866===A?n.texImage3D(A,0,u,i.width,i.height,i.depth,0,l,c,null):n.texImage2D(A,0,u,i.width,i.height,0,l,c,null)),n.bindFramebuffer(36160,t),z(i)?h.framebufferTexture2DMultisampleEXT(36160,s,A,r.get(o).__webglTexture,0,N(i)):(3553===A||A>=34069&&A<=34074)&&e.framebufferTexture2D(36160,s,A,r.get(o).__webglTexture,0),n.bindFramebuffer(36160,null)}function B(t,n,r){if(e.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){let i=33189;if(r||z(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===Z?i=36012:t.type===Y&&(i=33190));const r=N(n);z(n)?h.renderbufferStorageMultisampleEXT(36161,r,i,n.width,n.height):e.renderbufferStorageMultisample(36161,r,i,n.width,n.height)}else e.renderbufferStorage(36161,i,n.width,n.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(n.depthBuffer&&n.stencilBuffer){const i=N(n);r&&!1===z(n)?e.renderbufferStorageMultisample(36161,i,35056,n.width,n.height):z(n)?h.renderbufferStorageMultisampleEXT(36161,i,35056,n.width,n.height):e.renderbufferStorage(36161,34041,n.width,n.height),e.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let i=0;i<t.length;i++){const o=t[i],s=a.convert(o.format,o.encoding),A=a.convert(o.type),l=w(o.internalFormat,s,A,o.encoding),c=N(n);r&&!1===z(n)?e.renderbufferStorageMultisample(36161,c,l,n.width,n.height):z(n)?h.renderbufferStorageMultisampleEXT(36161,c,l,n.width,n.height):e.renderbufferStorage(36161,l,n.width,n.height)}}e.bindRenderbuffer(36161,null)}function U(t){const i=r.get(t),a=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!i.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,i){if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,t),!i.depthTexture||!i.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");r.get(i.depthTexture).__webglTexture&&i.depthTexture.image.width===i.width&&i.depthTexture.image.height===i.height||(i.depthTexture.image.width=i.width,i.depthTexture.image.height=i.height,i.depthTexture.needsUpdate=!0),L(i.depthTexture,0);const a=r.get(i.depthTexture).__webglTexture,o=N(i);if(i.depthTexture.format===ee)z(i)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,a,0,o):e.framebufferTexture2D(36160,36096,3553,a,0);else{if(i.depthTexture.format!==te)throw new Error("Unknown depthTexture format");z(i)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,a,0,o):e.framebufferTexture2D(36160,33306,3553,a,0)}}(i.__webglFramebuffer,t)}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)n.bindFramebuffer(36160,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]=e.createRenderbuffer(),B(i.__webglDepthbuffer[r],t,!1)}else n.bindFramebuffer(36160,i.__webglFramebuffer),i.__webglDepthbuffer=e.createRenderbuffer(),B(i.__webglDepthbuffer,t,!1);n.bindFramebuffer(36160,null)}function N(e){return Math.min(u,e.samples)}function z(e){const n=r.get(e);return s&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function ne(e,n){const r=e.encoding,i=e.format,a=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===me||r!==se&&(r===Ae?!1===s?!0===t.has("EXT_sRGB")&&i===$?(e.format=me,e.minFilter=W,e.generateMipmaps=!1):n=He.sRGBToLinear(n):i===$&&a===X||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",r)),n}this.allocateTextureUnit=function(){const e=P;return e>=A&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+A),P+=1,e},this.resetTextureUnits=function(){P=0},this.setTexture2D=L,this.setTexture2DArray=function(e,t){const i=r.get(e);e.version>0&&i.__version!==e.version?I(i,e,t):n.bindTexture(35866,i.__webglTexture,33984+t)},this.setTexture3D=function(e,t){const i=r.get(e);e.version>0&&i.__version!==e.version?I(i,e,t):n.bindTexture(32879,i.__webglTexture,33984+t)},this.setTextureCube=function(t,i){const o=r.get(t);t.version>0&&o.__version!==t.version?function(t,i,o){if(6!==i.image.length)return;const A=O(t,i),c=i.source;n.bindTexture(34067,t.__webglTexture,33984+o);const u=r.get(c);if(c.version!==u.__version||!0===A){n.activeTexture(33984+o),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const t=i.isCompressedTexture||i.image[0].isCompressedTexture,r=i.image[0]&&i.image[0].isDataTexture,h=[];for(let e=0;e<6;e++)h[e]=t||r?r?i.image[e].image:i.image[e]:y(i.image[e],!1,!0,l),h[e]=ne(i,h[e]);const f=h[0],d=b(f)||s,p=a.convert(i.format,i.encoding),m=a.convert(i.type),g=w(i.internalFormat,p,m,i.encoding),v=s&&!0!==i.isVideoTexture,S=void 0===u.__version||!0===A;let E,T=M(i,f,d);if(q(34067,i,d),t){v&&S&&n.texStorage2D(34067,T,g,f.width,f.height);for(let e=0;e<6;e++){E=h[e].mipmaps;for(let t=0;t<E.length;t++){const r=E[t];i.format!==$?null!==p?v?n.compressedTexSubImage2D(34069+e,t,0,0,r.width,r.height,p,r.data):n.compressedTexImage2D(34069+e,t,g,r.width,r.height,0,r.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):v?n.texSubImage2D(34069+e,t,0,0,r.width,r.height,p,m,r.data):n.texImage2D(34069+e,t,g,r.width,r.height,0,p,m,r.data)}}}else{E=i.mipmaps,v&&S&&(E.length>0&&T++,n.texStorage2D(34067,T,g,h[0].width,h[0].height));for(let e=0;e<6;e++)if(r){v?n.texSubImage2D(34069+e,0,0,0,h[e].width,h[e].height,p,m,h[e].data):n.texImage2D(34069+e,0,g,h[e].width,h[e].height,0,p,m,h[e].data);for(let t=0;t<E.length;t++){const r=E[t].image[e].image;v?n.texSubImage2D(34069+e,t+1,0,0,r.width,r.height,p,m,r.data):n.texImage2D(34069+e,t+1,g,r.width,r.height,0,p,m,r.data)}}else{v?n.texSubImage2D(34069+e,0,0,0,p,m,h[e]):n.texImage2D(34069+e,0,g,p,m,h[e]);for(let t=0;t<E.length;t++){const r=E[t];v?n.texSubImage2D(34069+e,t+1,0,0,p,m,r.image[e]):n.texImage2D(34069+e,t+1,g,p,m,r.image[e])}}}x(i,d)&&_(34067),u.__version=c.version,i.onUpdate&&i.onUpdate(i)}t.__version=i.version}(o,t,i):n.bindTexture(34067,o.__webglTexture,33984+i)},this.rebindTextures=function(e,t,n){const i=r.get(e);void 0!==t&&k(i.__webglFramebuffer,e,e.texture,36064,3553),void 0!==n&&U(e)},this.setupRenderTarget=function(t){const A=t.texture,l=r.get(t),c=r.get(A);t.addEventListener("dispose",T),!0!==t.isWebGLMultipleRenderTargets&&(void 0===c.__webglTexture&&(c.__webglTexture=e.createTexture()),c.__version=A.version,o.memory.textures++);const u=!0===t.isWebGLCubeRenderTarget,h=!0===t.isWebGLMultipleRenderTargets,f=b(t)||s;if(u){l.__webglFramebuffer=[];for(let t=0;t<6;t++)l.__webglFramebuffer[t]=e.createFramebuffer()}else{if(l.__webglFramebuffer=e.createFramebuffer(),h)if(i.drawBuffers){const n=t.texture;for(let t=0,i=n.length;t<i;t++){const i=r.get(n[t]);void 0===i.__webglTexture&&(i.__webglTexture=e.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(s&&t.samples>0&&!1===z(t)){const r=h?A:[A];l.__webglMultisampledFramebuffer=e.createFramebuffer(),l.__webglColorRenderbuffer=[],n.bindFramebuffer(36160,l.__webglMultisampledFramebuffer);for(let n=0;n<r.length;n++){const i=r[n];l.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(36161,l.__webglColorRenderbuffer[n]);const o=a.convert(i.format,i.encoding),s=a.convert(i.type),A=w(i.internalFormat,o,s,i.encoding,!0===t.isXRRenderTarget),c=N(t);e.renderbufferStorageMultisample(36161,c,A,t.width,t.height),e.framebufferRenderbuffer(36160,36064+n,36161,l.__webglColorRenderbuffer[n])}e.bindRenderbuffer(36161,null),t.depthBuffer&&(l.__webglDepthRenderbuffer=e.createRenderbuffer(),B(l.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(36160,null)}}if(u){n.bindTexture(34067,c.__webglTexture),q(34067,A,f);for(let e=0;e<6;e++)k(l.__webglFramebuffer[e],t,A,36064,34069+e);x(A,f)&&_(34067),n.unbindTexture()}else if(h){const e=t.texture;for(let i=0,a=e.length;i<a;i++){const a=e[i],o=r.get(a);n.bindTexture(3553,o.__webglTexture),q(3553,a,f),k(l.__webglFramebuffer,t,a,36064+i,3553),x(a,f)&&_(3553)}n.unbindTexture()}else{let e=3553;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(s?e=t.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(e,c.__webglTexture),q(e,A,f),k(l.__webglFramebuffer,t,A,36064,e),x(A,f)&&_(e),n.unbindTexture()}t.depthBuffer&&U(t)},this.updateRenderTargetMipmap=function(e){const t=b(e)||s,i=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let a=0,o=i.length;a<o;a++){const o=i[a];if(x(o,t)){const t=e.isWebGLCubeRenderTarget?34067:3553,i=r.get(o).__webglTexture;n.bindTexture(t,i),_(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(s&&t.samples>0&&!1===z(t)){const i=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,o=t.height;let s=16384;const A=[],l=t.stencilBuffer?33306:36096,c=r.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;t<i.length;t++)n.bindFramebuffer(36160,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+t,36161,null),n.bindFramebuffer(36160,c.__webglFramebuffer),e.framebufferTexture2D(36009,36064+t,3553,null,0);n.bindFramebuffer(36008,c.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,c.__webglFramebuffer);for(let n=0;n<i.length;n++){A.push(36064+n),t.depthBuffer&&A.push(l);const h=void 0!==c.__ignoreDepthValues&&c.__ignoreDepthValues;if(!1===h&&(t.depthBuffer&&(s|=256),t.stencilBuffer&&(s|=1024)),u&&e.framebufferRenderbuffer(36008,36064,36161,c.__webglColorRenderbuffer[n]),!0===h&&(e.invalidateFramebuffer(36008,[l]),e.invalidateFramebuffer(36009,[l])),u){const t=r.get(i[n]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,t,0)}e.blitFramebuffer(0,0,a,o,0,0,a,o,s,9728),f&&e.invalidateFramebuffer(36008,A)}if(n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,null),u)for(let t=0;t<i.length;t++){n.bindFramebuffer(36160,c.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+t,36161,c.__webglColorRenderbuffer[t]);const a=r.get(i[t]).__webglTexture;n.bindFramebuffer(36160,c.__webglFramebuffer),e.framebufferTexture2D(36009,36064+t,3553,a,0)}n.bindFramebuffer(36009,c.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=U,this.setupFrameBufferTexture=k,this.useMultisampledRTT=z}function Wa(e,t,n){const r=n.isWebGL2;return{convert:function(n,i=null){let a;if(n===X)return 5121;if(1017===n)return 32819;if(1018===n)return 32820;if(1010===n)return 5120;if(1011===n)return 5122;if(1012===n)return 5123;if(1013===n)return 5124;if(n===Y)return 5125;if(n===Z)return 5126;if(n===J)return r?5131:(a=t.get("OES_texture_half_float"),null!==a?a.HALF_FLOAT_OES:null);if(1021===n)return 6406;if(n===$)return 6408;if(1024===n)return 6409;if(1025===n)return 6410;if(n===ee)return 6402;if(n===te)return 34041;if(n===me)return a=t.get("EXT_sRGB"),null!==a?a.SRGB_ALPHA_EXT:null;if(1028===n)return 6403;if(1029===n)return 36244;if(1030===n)return 33319;if(1031===n)return 33320;if(1033===n)return 36249;if(n===ne||n===re||n===ie||n===ae)if(i===Ae){if(a=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===a)return null;if(n===ne)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===re)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===ie)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===ae)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(a=t.get("WEBGL_compressed_texture_s3tc"),null===a)return null;if(n===ne)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===re)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===ie)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ae)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===n||35841===n||35842===n||35843===n){if(a=t.get("WEBGL_compressed_texture_pvrtc"),null===a)return null;if(35840===n)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===n)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===n)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===n)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===n)return a=t.get("WEBGL_compressed_texture_etc1"),null!==a?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(37492===n||37496===n){if(a=t.get("WEBGL_compressed_texture_etc"),null===a)return null;if(37492===n)return i===Ae?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(37496===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}if(37808===n||37809===n||37810===n||37811===n||37812===n||37813===n||37814===n||37815===n||37816===n||37817===n||37818===n||37819===n||37820===n||37821===n){if(a=t.get("WEBGL_compressed_texture_astc"),null===a)return null;if(37808===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===n)return i===Ae?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===oe){if(a=t.get("EXT_texture_compression_bptc"),null===a)return null;if(n===oe)return i===Ae?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}if(36283===n||36284===n||36285===n||36286===n){if(a=t.get("EXT_texture_compression_rgtc"),null===a)return null;if(n===oe)return a.COMPRESSED_RED_RGTC1_EXT;if(36284===n)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(36285===n)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(36286===n)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}return n===K?r?34042:(a=t.get("WEBGL_depth_texture"),null!==a?a.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[n]?e[n]:null}}}class Qa extends cr{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}let Xa=class extends tn{constructor(){super(),this.isGroup=!0,this.type="Group"}};const Ya={type:"move"};class Za{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new Xa,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new Xa,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new et,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new et),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new Xa,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new et,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new et),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null;const o=this._targetRay,s=this._grip,A=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(A&&e.hand){a=!0;for(const r of e.hand.values()){const e=t.getJointPose(r,n),i=this._getHandJoint(A,r);null!==e&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.jointRadius=e.radius),i.visible=null!==e}const r=A.joints["index-finger-tip"],i=A.joints["thumb-tip"],o=r.position.distanceTo(i.position),s=.02,l=.005;A.inputState.pinching&&o>s+l?(A.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!A.inputState.pinching&&o<=s-l&&(A.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));null!==o&&(r=t.getPose(e.targetRaySpace,n),null===r&&null!==i&&(r=i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Ya)))}return null!==o&&(o.visible=null!==r),null!==s&&(s.visible=null!==i),null!==A&&(A.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new Xa;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Ja extends Xe{constructor(e,t,n,r,i,a,o,s,A,l){if((l=void 0!==l?l:ee)!==ee&&l!==te)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&l===ee&&(n=Y),void 0===n&&l===te&&(n=K),super(null,r,i,a,o,s,l,n,A),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==o?o:H,this.minFilter=void 0!==s?s:H,this.flipY=!1,this.generateMipmaps=!1}}class Ka extends ge{constructor(e,t){super();const n=this;let r=null,i=1,a=null,o="local-floor",s=1,A=null,l=null,c=null,u=null,h=null,f=null;const d=t.getContextAttributes();let p=null,m=null;const g=[],v=[],y=new Set,b=new Map,x=new cr;x.layers.enable(1),x.viewport=new Ye;const _=new cr;_.layers.enable(2),_.viewport=new Ye;const w=[x,_],M=new Qa;M.layers.enable(1),M.layers.enable(2);let S=null,E=null;function T(e){const t=v.indexOf(e.inputSource);if(-1===t)return;const n=g[t];void 0!==n&&n.dispatchEvent({type:e.type,data:e.inputSource})}function C(){r.removeEventListener("select",T),r.removeEventListener("selectstart",T),r.removeEventListener("selectend",T),r.removeEventListener("squeeze",T),r.removeEventListener("squeezestart",T),r.removeEventListener("squeezeend",T),r.removeEventListener("end",C),r.removeEventListener("inputsourceschange",P);for(let e=0;e<g.length;e++){const t=v[e];null!==t&&(v[e]=null,g[e].disconnect(t))}S=null,E=null,e.setRenderTarget(p),h=null,u=null,c=null,r=null,m=null,O.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function P(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],r=v.indexOf(n);r>=0&&(v[r]=null,g[r].disconnect(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let r=v.indexOf(n);if(-1===r){for(let e=0;e<g.length;e++){if(e>=v.length){v.push(n),r=e;break}if(null===v[e]){v[e]=n,r=e;break}}if(-1===r)break}const i=g[r];i&&i.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=g[e];return void 0===t&&(t=new Za,g[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=g[e];return void 0===t&&(t=new Za,g[e]=t),t.getGripSpace()},this.getHand=function(e){let t=g[e];return void 0===t&&(t=new Za,g[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){i=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){o=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return A||a},this.setReferenceSpace=function(e){A=e},this.getBaseLayer=function(){return null!==u?u:h},this.getBinding=function(){return c},this.getFrame=function(){return f},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,null!==r){if(p=e.getRenderTarget(),r.addEventListener("select",T),r.addEventListener("selectstart",T),r.addEventListener("selectend",T),r.addEventListener("squeeze",T),r.addEventListener("squeezestart",T),r.addEventListener("squeezeend",T),r.addEventListener("end",C),r.addEventListener("inputsourceschange",P),!0!==d.xrCompatible&&await t.makeXRCompatible(),void 0===r.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==r.renderState.layers||d.antialias,alpha:d.alpha,depth:d.depth,stencil:d.stencil,framebufferScaleFactor:i};h=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:h}),m=new Ze(h.framebufferWidth,h.framebufferHeight,{format:$,type:X,encoding:e.outputEncoding,stencilBuffer:d.stencil})}else{let n=null,a=null,o=null;d.depth&&(o=d.stencil?35056:33190,n=d.stencil?te:ee,a=d.stencil?K:Y);const s={colorFormat:32856,depthFormat:o,scaleFactor:i};c=new XRWebGLBinding(r,t),u=c.createProjectionLayer(s),r.updateRenderState({layers:[u]}),m=new Ze(u.textureWidth,u.textureHeight,{format:$,type:X,depthTexture:new Ja(u.textureWidth,u.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:d.stencil,encoding:e.outputEncoding,samples:d.antialias?4:0});e.properties.get(m).__ignoreDepthValues=u.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(s),A=null,a=await r.requestReferenceSpace(o),O.setContext(r),O.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const L=new et,D=new et;function R(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===r)return;M.near=_.near=x.near=e.near,M.far=_.far=x.far=e.far,S===M.near&&E===M.far||(r.updateRenderState({depthNear:M.near,depthFar:M.far}),S=M.near,E=M.far);const t=e.parent,n=M.cameras;R(M,t);for(let e=0;e<n.length;e++)R(n[e],t);2===n.length?function(e,t,n){L.setFromMatrixPosition(t.matrixWorld),D.setFromMatrixPosition(n.matrixWorld);const r=L.distanceTo(D),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),A=(i[9]+1)/i[5],l=(i[9]-1)/i[5],c=(i[8]-1)/i[0],u=(a[8]+1)/a[0],h=o*c,f=o*u,d=r/(-c+u),p=d*-c;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(p),e.translateZ(d),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const m=o+d,g=s+d,v=h-p,y=f+(r-p),b=A*s/g*m,x=l*s/g*m;e.projectionMatrix.makePerspective(v,y,b,x,m,g),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}(M,x,_):M.projectionMatrix.copy(x.projectionMatrix),function(e,t,n){null===n?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld));e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0);const r=e.children;for(let e=0,t=r.length;e<t;e++)r[e].updateMatrixWorld(!0);e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=2*xe*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}(e,M,t)},this.getCamera=function(){return M},this.getFoveation=function(){if(null!==u||null!==h)return s},this.setFoveation=function(e){s=e,null!==u&&(u.fixedFoveation=e),null!==h&&void 0!==h.fixedFoveation&&(h.fixedFoveation=e)},this.getPlanes=function(){return y};let q=null;const O=new _r;O.setAnimationLoop((function(t,r){if(l=r.getViewerPose(A||a),f=r,null!==l){const t=l.views;null!==h&&(e.setRenderTargetFramebuffer(m,h.framebuffer),e.setRenderTarget(m));let n=!1;t.length!==M.cameras.length&&(M.cameras.length=0,n=!0);for(let r=0;r<t.length;r++){const i=t[r];let a=null;if(null!==h)a=h.getViewport(i);else{const t=c.getViewSubImage(u,i);a=t.viewport,0===r&&(e.setRenderTargetTextures(m,t.colorTexture,u.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(m))}let o=w[r];void 0===o&&(o=new cr,o.layers.enable(r),o.viewport=new Ye,w[r]=o),o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(i.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),0===r&&(M.matrix.copy(o.matrix),M.matrix.decompose(M.position,M.quaternion,M.scale)),!0===n&&M.cameras.push(o)}}for(let e=0;e<g.length;e++){const t=v[e],n=g[e];null!==t&&void 0!==n&&n.update(t,r,A||a)}if(q&&q(t,r),r.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:r.detectedPlanes});let e=null;for(const t of y)r.detectedPlanes.has(t)||(null===e&&(e=[]),e.push(t));if(null!==e)for(const t of e)y.delete(t),b.delete(t),n.dispatchEvent({type:"planeremoved",data:t});for(const e of r.detectedPlanes)if(y.has(e)){const t=b.get(e);e.lastChangedTime>t&&(b.set(e,e.lastChangedTime),n.dispatchEvent({type:"planechanged",data:e}))}else y.add(e),b.set(e,r.lastChangedTime),n.dispatchEvent({type:"planeadded",data:e})}f=null})),this.setAnimationLoop=function(e){q=e},this.dispose=function(){}}}function $a(e,t){function n(e,t){!0===e.matrixAutoUpdate&&e.updateMatrix(),t.value.copy(e.matrix)}function r(r,i){r.opacity.value=i.opacity,i.color&&r.diffuse.value.copy(i.color),i.emissive&&r.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(r.map.value=i.map,n(i.map,r.mapTransform)),i.alphaMap&&(r.alphaMap.value=i.alphaMap,n(i.alphaMap,r.alphaMapTransform)),i.bumpMap&&(r.bumpMap.value=i.bumpMap,n(i.bumpMap,r.bumpMapTransform),r.bumpScale.value=i.bumpScale,i.side===M&&(r.bumpScale.value*=-1)),i.normalMap&&(r.normalMap.value=i.normalMap,n(i.normalMap,r.normalMapTransform),r.normalScale.value.copy(i.normalScale),i.side===M&&r.normalScale.value.negate()),i.displacementMap&&(r.displacementMap.value=i.displacementMap,n(i.displacementMap,r.displacementMapTransform),r.displacementScale.value=i.displacementScale,r.displacementBias.value=i.displacementBias),i.emissiveMap&&(r.emissiveMap.value=i.emissiveMap,n(i.emissiveMap,r.emissiveMapTransform)),i.specularMap&&(r.specularMap.value=i.specularMap,n(i.specularMap,r.specularMapTransform)),i.alphaTest>0&&(r.alphaTest.value=i.alphaTest);const a=t.get(i).envMap;if(a&&(r.envMap.value=a,r.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,r.reflectivity.value=i.reflectivity,r.ior.value=i.ior,r.refractionRatio.value=i.refractionRatio),i.lightMap){r.lightMap.value=i.lightMap;const t=!0===e.useLegacyLights?Math.PI:1;r.lightMapIntensity.value=i.lightMapIntensity*t,n(i.lightMap,r.lightMapTransform)}i.aoMap&&(r.aoMap.value=i.aoMap,r.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,r.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,or(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,i,a,o,s){i.isMeshBasicMaterial||i.isMeshLambertMaterial?r(e,i):i.isMeshToonMaterial?(r(e,i),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,i)):i.isMeshPhongMaterial?(r(e,i),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,i)):i.isMeshStandardMaterial?(r(e,i),function(e,r){e.metalness.value=r.metalness,r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap,n(r.metalnessMap,e.metalnessMapTransform));e.roughness.value=r.roughness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap,n(r.roughnessMap,e.roughnessMapTransform));const i=t.get(r).envMap;i&&(e.envMapIntensity.value=r.envMapIntensity)}(e,i),i.isMeshPhysicalMaterial&&function(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===M&&e.clearcoatNormalScale.value.negate()));t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,i,s)):i.isMeshMatcapMaterial?(r(e,i),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,i)):i.isMeshDepthMaterial?r(e,i):i.isMeshDistanceMaterial?(r(e,i),function(e,n){const r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}(e,i)):i.isMeshNormalMaterial?r(e,i):i.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,i)):i.isPointsMaterial?function(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=.5*i,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i,a,o):i.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isShaderMaterial&&(i.uniformsNeedUpdate=!1)}}}function eo(e,t,n,r){let i={},a={},o=[];const s=n.isWebGL2?e.getParameter(35375):0;function A(e,t,n){const r=e.value;if(void 0===n[t]){if("number"==typeof r)n[t]=r;else{const e=Array.isArray(r)?r:[r],i=[];for(let t=0;t<e.length;t++)i.push(e[t].clone());n[t]=i}return!0}if("number"==typeof r){if(n[t]!==r)return n[t]=r,!0}else{const e=Array.isArray(n[t])?n[t]:[n[t]],i=Array.isArray(r)?r:[r];for(let t=0;t<e.length;t++){const n=e[t];if(!1===n.equals(i[t]))return n.copy(i[t]),!0}}return!1}function l(e){const t={boundary:0,storage:0};return"number"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",e),t}function c(t){const n=t.target;n.removeEventListener("dispose",c);const r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}return{bind:function(e,t){const n=t.program;r.uniformBlockBinding(e,n)},update:function(n,u){let h=i[n.id];void 0===h&&(!function(e){const t=e.uniforms;let n=0;const r=16;let i=0;for(let e=0,a=t.length;e<a;e++){const a=t[e],o={boundary:0,storage:0},s=Array.isArray(a.value)?a.value:[a.value];for(let e=0,t=s.length;e<t;e++){const t=l(s[e]);o.boundary+=t.boundary,o.storage+=t.storage}if(a.__data=new Float32Array(o.storage/Float32Array.BYTES_PER_ELEMENT),a.__offset=n,e>0){i=n%r;0!==i&&r-i-o.boundary<0&&(n+=r-i,a.__offset=n)}n+=o.storage}i=n%r,i>0&&(n+=r-i);e.__size=n,e.__cache={}}(n),h=function(t){const n=function(){for(let e=0;e<s;e++)if(-1===o.indexOf(e))return o.push(e),e;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(35345,r),e.bufferData(35345,i,a),e.bindBuffer(35345,null),e.bindBufferBase(35345,n,r),r}(n),i[n.id]=h,n.addEventListener("dispose",c));const f=u.program;r.updateUBOMapping(n,f);const d=t.render.frame;a[n.id]!==d&&(!function(t){const n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(35345,n);for(let t=0,n=r.length;t<n;t++){const n=r[t];if(!0===A(n,t,a)){const t=n.__offset,r=Array.isArray(n.value)?n.value:[n.value];let i=0;for(let a=0;a<r.length;a++){const o=r[a],s=l(o);"number"==typeof o?(n.__data[0]=o,e.bufferSubData(35345,t+i,n.__data)):o.isMatrix3?(n.__data[0]=o.elements[0],n.__data[1]=o.elements[1],n.__data[2]=o.elements[2],n.__data[3]=o.elements[0],n.__data[4]=o.elements[3],n.__data[5]=o.elements[4],n.__data[6]=o.elements[5],n.__data[7]=o.elements[0],n.__data[8]=o.elements[6],n.__data[9]=o.elements[7],n.__data[10]=o.elements[8],n.__data[11]=o.elements[0]):(o.toArray(n.__data,i),i+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,t,n.__data)}}e.bindBuffer(35345,null)}(n),a[n.id]=d)},dispose:function(){for(const t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}}}function to(){const e=Ie("canvas");return e.style.display="block",e}class no{constructor(e={}){const{canvas:t=to(),context:n=null,depth:r=!0,stencil:i=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:A=!1,powerPreference:l="default",failIfMajorPerformanceCaveat:c=!1}=e;let u;this.isWebGLRenderer=!0,u=null!==n?n.getContextAttributes().alpha:a;let h=null,f=null;const p=[],m=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=se,this.useLegacyLights=!0,this.toneMapping=R,this.toneMappingExposure=1;const g=this;let v=!1,y=0,b=0,x=null,_=-1,E=null;const T=new Ye,C=new Ye;let P=null,L=t.width,D=t.height,q=1,O=null,I=null;const k=new Ye(0,0,L,D),B=new Ye(0,0,L,D);let U=!1;const N=new xr;let z=!1,F=!1,G=null;const j=new Lt,H=new et,V={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function W(){return null===x?q:1}let Y,K,ee,te,ne,re,ie,ae,oe,Ae,le,ce,ue,he,fe,de,pe,me,ge,ve,ye,be,xe,_e,we=n;function Me(e,n){for(let r=0;r<e.length;r++){const i=e[r],a=t.getContext(i,n);if(null!==a)return a}return null}try{const e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:A,powerPreference:l,failIfMajorPerformanceCaveat:c};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${d}`),t.addEventListener("webglcontextlost",Te,!1),t.addEventListener("webglcontextrestored",Ce,!1),t.addEventListener("webglcontextcreationerror",Pe,!1),null===we){const t=["webgl2","webgl","experimental-webgl"];if(!0===g.isWebGL1Renderer&&t.shift(),we=Me(t,e),null===we)throw Me(t)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===we.getShaderPrecisionFormat&&(we.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("THREE.WebGLRenderer: "+e.message),e}function Se(){Y=new Kr(we),K=new Rr(we,Y,e),Y.init(K),be=new Wa(we,Y,K),ee=new Ha(we,Y,K),te=new ti,ne=new La,re=new Va(we,Y,ee,ne,K,be,te),ie=new Or(g),ae=new Jr(g),oe=new wr(we,K),xe=new Lr(we,Y,oe,K),Ae=new $r(we,oe,te,xe),le=new ai(we,Ae,oe,te),ge=new ii(we,K,re),de=new qr(ne),ce=new Pa(g,ie,ae,Y,K,xe,de),ue=new $a(g,ne),he=new Oa,fe=new za(Y,K),me=new Pr(g,ie,ae,ee,le,u,s),pe=new ja(g,le,K),_e=new eo(we,te,K,ee),ve=new Dr(we,Y,te,K),ye=new ei(we,Y,te,K),te.programs=ce.programs,g.capabilities=K,g.extensions=Y,g.properties=ne,g.renderLists=he,g.shadowMap=pe,g.state=ee,g.info=te}Se();const Ee=new Ka(g,we);function Te(e){e.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),v=!0}function Ce(){console.log("THREE.WebGLRenderer: Context Restored."),v=!1;const e=te.autoReset,t=pe.enabled,n=pe.autoUpdate,r=pe.needsUpdate,i=pe.type;Se(),te.autoReset=e,pe.enabled=t,pe.autoUpdate=n,pe.needsUpdate=r,pe.type=i}function Pe(e){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Le(e){const t=e.target;t.removeEventListener("dispose",Le),function(e){(function(e){const t=ne.get(e).programs;void 0!==t&&(t.forEach((function(e){ce.releaseProgram(e)})),e.isShaderMaterial&&ce.releaseShaderCache(e))})(e),ne.remove(e)}(t)}this.xr=Ee,this.getContext=function(){return we},this.getContextAttributes=function(){return we.getContextAttributes()},this.forceContextLoss=function(){const e=Y.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=Y.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return q},this.setPixelRatio=function(e){void 0!==e&&(q=e,this.setSize(L,D,!1))},this.getSize=function(e){return e.set(L,D)},this.setSize=function(e,n,r=!0){Ee.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(L=e,D=n,t.width=Math.floor(e*q),t.height=Math.floor(n*q),!0===r&&(t.style.width=e+"px",t.style.height=n+"px"),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(L*q,D*q).floor()},this.setDrawingBufferSize=function(e,n,r){L=e,D=n,q=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(T)},this.getViewport=function(e){return e.copy(k)},this.setViewport=function(e,t,n,r){e.isVector4?k.set(e.x,e.y,e.z,e.w):k.set(e,t,n,r),ee.viewport(T.copy(k).multiplyScalar(q).floor())},this.getScissor=function(e){return e.copy(B)},this.setScissor=function(e,t,n,r){e.isVector4?B.set(e.x,e.y,e.z,e.w):B.set(e,t,n,r),ee.scissor(C.copy(B).multiplyScalar(q).floor())},this.getScissorTest=function(){return U},this.setScissorTest=function(e){ee.setScissorTest(U=e)},this.setOpaqueSort=function(e){O=e},this.setTransparentSort=function(e){I=e},this.getClearColor=function(e){return e.copy(me.getClearColor())},this.setClearColor=function(){me.setClearColor.apply(me,arguments)},this.getClearAlpha=function(){return me.getClearAlpha()},this.setClearAlpha=function(){me.setClearAlpha.apply(me,arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;e&&(r|=16384),t&&(r|=256),n&&(r|=1024),we.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",Te,!1),t.removeEventListener("webglcontextrestored",Ce,!1),t.removeEventListener("webglcontextcreationerror",Pe,!1),he.dispose(),fe.dispose(),ne.dispose(),ie.dispose(),ae.dispose(),le.dispose(),xe.dispose(),_e.dispose(),ce.dispose(),Ee.dispose(),Ee.removeEventListener("sessionstart",Re),Ee.removeEventListener("sessionend",qe),G&&(G.dispose(),G=null),Oe.stop()},this.renderBufferDirect=function(e,t,n,r,i,a){null===t&&(t=V);const o=i.isMesh&&i.matrixWorld.determinant()<0,s=function(e,t,n,r,i){!0!==t.isScene&&(t=V);re.resetTextureUnits();const a=t.fog,o=r.isMeshStandardMaterial?t.environment:null,s=null===x?g.outputEncoding:!0===x.isXRRenderTarget?x.texture.encoding:se,A=(r.isMeshStandardMaterial?ae:ie).get(r.envMap||o),l=!0===r.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,c=!!r.normalMap&&!!n.attributes.tangent,u=!!n.morphAttributes.position,h=!!n.morphAttributes.normal,d=!!n.morphAttributes.color,p=r.toneMapped?g.toneMapping:R,m=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==m?m.length:0,y=ne.get(r),b=f.state.lights;if(!0===z&&(!0===F||e!==E)){const t=e===E&&r.id===_;de.setState(r,e,t)}let w=!1;r.version===y.__version?y.needsLights&&y.lightsStateVersion!==b.state.version||y.outputEncoding!==s||i.isInstancedMesh&&!1===y.instancing?w=!0:i.isInstancedMesh||!0!==y.instancing?i.isSkinnedMesh&&!1===y.skinning?w=!0:i.isSkinnedMesh||!0!==y.skinning?y.envMap!==A||!0===r.fog&&y.fog!==a?w=!0:void 0===y.numClippingPlanes||y.numClippingPlanes===de.numPlanes&&y.numIntersection===de.numIntersection?(y.vertexAlphas!==l||y.vertexTangents!==c||y.morphTargets!==u||y.morphNormals!==h||y.morphColors!==d||y.toneMapping!==p||!0===K.isWebGL2&&y.morphTargetsCount!==v)&&(w=!0):w=!0:w=!0:w=!0:(w=!0,y.__version=r.version);let M=y.currentProgram;!0===w&&(M=Ne(r,t,i));let S=!1,T=!1,C=!1;const P=M.getUniforms(),L=y.uniforms;ee.useProgram(M.program)&&(S=!0,T=!0,C=!0);r.id!==_&&(_=r.id,T=!0);if(S||E!==e){if(P.setValue(we,"projectionMatrix",e.projectionMatrix),K.logarithmicDepthBuffer&&P.setValue(we,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),E!==e&&(E=e,T=!0,C=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshStandardMaterial||r.envMap){const t=P.map.cameraPosition;void 0!==t&&t.setValue(we,H.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&P.setValue(we,"isOrthographic",!0===e.isOrthographicCamera),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isShadowMaterial||i.isSkinnedMesh)&&P.setValue(we,"viewMatrix",e.matrixWorldInverse)}if(i.isSkinnedMesh){P.setOptional(we,i,"bindMatrix"),P.setOptional(we,i,"bindMatrixInverse");const e=i.skeleton;e&&(K.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),P.setValue(we,"boneTexture",e.boneTexture,re),P.setValue(we,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const O=n.morphAttributes;(void 0!==O.position||void 0!==O.normal||void 0!==O.color&&!0===K.isWebGL2)&&ge.update(i,n,M);(T||y.receiveShadow!==i.receiveShadow)&&(y.receiveShadow=i.receiveShadow,P.setValue(we,"receiveShadow",i.receiveShadow));r.isMeshGouraudMaterial&&null!==r.envMap&&(L.envMap.value=A,L.flipEnvMap.value=A.isCubeTexture&&!1===A.isRenderTargetTexture?-1:1);T&&(P.setValue(we,"toneMappingExposure",g.toneMappingExposure),y.needsLights&&(k=C,(I=L).ambientLightColor.needsUpdate=k,I.lightProbe.needsUpdate=k,I.directionalLights.needsUpdate=k,I.directionalLightShadows.needsUpdate=k,I.pointLights.needsUpdate=k,I.pointLightShadows.needsUpdate=k,I.spotLights.needsUpdate=k,I.spotLightShadows.needsUpdate=k,I.rectAreaLights.needsUpdate=k,I.hemisphereLights.needsUpdate=k),a&&!0===r.fog&&ue.refreshFogUniforms(L,a),ue.refreshMaterialUniforms(L,r,q,D,G),la.upload(we,y.uniformsList,L,re));var I,k;r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(la.upload(we,y.uniformsList,L,re),r.uniformsNeedUpdate=!1);r.isSpriteMaterial&&P.setValue(we,"center",i.center);if(P.setValue(we,"modelViewMatrix",i.modelViewMatrix),P.setValue(we,"normalMatrix",i.normalMatrix),P.setValue(we,"modelMatrix",i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){const e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++)if(K.isWebGL2){const n=e[t];_e.update(n,M),_e.bind(n,M)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return M}(e,t,n,r,i);ee.setMaterial(r,o);let A=n.index,l=1;!0===r.wireframe&&(A=Ae.getWireframeAttribute(n),l=2);const c=n.drawRange,u=n.attributes.position;let h=c.start*l,d=(c.start+c.count)*l;null!==a&&(h=Math.max(h,a.start*l),d=Math.min(d,(a.start+a.count)*l)),null!==A?(h=Math.max(h,0),d=Math.min(d,A.count)):null!=u&&(h=Math.max(h,0),d=Math.min(d,u.count));const p=d-h;if(p<0||p===1/0)return;let m;xe.setup(i,r,s,n,A);let v=ve;if(null!==A&&(m=oe.get(A),v=ye,v.setIndex(m)),i.isMesh)!0===r.wireframe?(ee.setLineWidth(r.wireframeLinewidth*W()),v.setMode(1)):v.setMode(4);else if(i.isLine){let e=r.linewidth;void 0===e&&(e=1),ee.setLineWidth(e*W()),i.isLineSegments?v.setMode(1):i.isLineLoop?v.setMode(2):v.setMode(3)}else i.isPoints?v.setMode(0):i.isSprite&&v.setMode(4);if(i.isInstancedMesh)v.renderInstances(h,p,i.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);v.renderInstances(h,p,t)}else v.render(h,p)},this.compile=function(e,t){function n(e,t,n){!0===e.transparent&&e.side===S&&!1===e.forceSinglePass?(e.side=M,e.needsUpdate=!0,Ne(e,t,n),e.side=w,e.needsUpdate=!0,Ne(e,t,n),e.side=S):Ne(e,t,n)}f=fe.get(e),f.init(),m.push(f),e.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&(f.pushLight(e),e.castShadow&&f.pushShadow(e))})),f.setupLights(g.useLegacyLights),e.traverse((function(t){const r=t.material;if(r)if(Array.isArray(r))for(let i=0;i<r.length;i++){n(r[i],e,t)}else n(r,e,t)})),m.pop(),f=null};let De=null;function Re(){Oe.stop()}function qe(){Oe.start()}const Oe=new _r;function Ie(e,t,n,r){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)f.pushLight(e),e.castShadow&&f.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||N.intersectsSprite(e)){r&&H.setFromMatrixPosition(e.matrixWorld).applyMatrix4(j);const t=le.update(e),i=e.material;i.visible&&h.push(e,t,i,n,H.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.frame!==te.render.frame&&(e.skeleton.update(),e.skeleton.frame=te.render.frame),!e.frustumCulled||N.intersectsObject(e))){r&&H.setFromMatrixPosition(e.matrixWorld).applyMatrix4(j);const t=le.update(e),i=e.material;if(Array.isArray(i)){const r=t.groups;for(let a=0,o=r.length;a<o;a++){const o=r[a],s=i[o.materialIndex];s&&s.visible&&h.push(e,t,s,n,H.z,o)}}else i.visible&&h.push(e,t,i,n,H.z,null)}const i=e.children;for(let e=0,a=i.length;e<a;e++)Ie(i[e],t,n,r)}function ke(e,t,n,r){const i=e.opaque,a=e.transmissive,s=e.transparent;f.setupLightsView(n),!0===z&&de.setGlobalState(g.clippingPlanes,n),a.length>0&&function(e,t,n,r){if(null===G){const e=K.isWebGL2;G=new Ze(1024,1024,{generateMipmaps:!0,type:Y.has("EXT_color_buffer_half_float")?J:X,minFilter:Q,samples:e&&!0===o?4:0})}const i=g.getRenderTarget();g.setRenderTarget(G),g.clear();const a=g.toneMapping;g.toneMapping=R,Be(e,n,r),re.updateMultisampleRenderTarget(G),re.updateRenderTargetMipmap(G);let s=!1;for(let e=0,i=t.length;e<i;e++){const i=t[e],a=i.object,o=i.geometry,A=i.material,l=i.group;if(A.side===S&&a.layers.test(r.layers)){const e=A.side;A.side=M,A.needsUpdate=!0,Ue(a,n,r,o,A,l),A.side=e,A.needsUpdate=!0,s=!0}}!0===s&&(re.updateMultisampleRenderTarget(G),re.updateRenderTargetMipmap(G));g.setRenderTarget(i),g.toneMapping=a}(i,a,t,n),r&&ee.viewport(T.copy(r)),i.length>0&&Be(i,t,n),a.length>0&&Be(a,t,n),s.length>0&&Be(s,t,n),ee.buffers.depth.setTest(!0),ee.buffers.depth.setMask(!0),ee.buffers.color.setMask(!0),ee.setPolygonOffset(!1)}function Be(e,t,n){const r=!0===t.isScene?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){const a=e[i],o=a.object,s=a.geometry,A=null===r?a.material:r,l=a.group;o.layers.test(n.layers)&&Ue(o,t,n,s,A,l)}}function Ue(e,t,n,r,i,a){e.onBeforeRender(g,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(g,t,n,r,e,a),!0===i.transparent&&i.side===S&&!1===i.forceSinglePass?(i.side=M,i.needsUpdate=!0,g.renderBufferDirect(n,t,r,i,e,a),i.side=w,i.needsUpdate=!0,g.renderBufferDirect(n,t,r,i,e,a),i.side=S):g.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(g,t,n,r,i,a)}function Ne(e,t,n){!0!==t.isScene&&(t=V);const r=ne.get(e),i=f.state.lights,a=f.state.shadowsArray,o=i.state.version,s=ce.getParameters(e,i.state,a,t,n),A=ce.getProgramCacheKey(s);let l=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?ae:ie).get(e.envMap||r.environment),void 0===l&&(e.addEventListener("dispose",Le),l=new Map,r.programs=l);let c=l.get(A);if(void 0!==c){if(r.currentProgram===c&&r.lightsStateVersion===o)return ze(e,s),c}else s.uniforms=ce.getUniforms(e),e.onBuild(n,s,g),e.onBeforeCompile(s,g),c=ce.acquireProgram(s,A),l.set(A,c),r.uniforms=s.uniforms;const u=r.uniforms;(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||(u.clippingPlanes=de.uniform),ze(e,s),r.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights}(e),r.lightsStateVersion=o,r.needsLights&&(u.ambientLightColor.value=i.state.ambient,u.lightProbe.value=i.state.probe,u.directionalLights.value=i.state.directional,u.directionalLightShadows.value=i.state.directionalShadow,u.spotLights.value=i.state.spot,u.spotLightShadows.value=i.state.spotShadow,u.rectAreaLights.value=i.state.rectArea,u.ltc_1.value=i.state.rectAreaLTC1,u.ltc_2.value=i.state.rectAreaLTC2,u.pointLights.value=i.state.point,u.pointLightShadows.value=i.state.pointShadow,u.hemisphereLights.value=i.state.hemi,u.directionalShadowMap.value=i.state.directionalShadowMap,u.directionalShadowMatrix.value=i.state.directionalShadowMatrix,u.spotShadowMap.value=i.state.spotShadowMap,u.spotLightMatrix.value=i.state.spotLightMatrix,u.spotLightMap.value=i.state.spotLightMap,u.pointShadowMap.value=i.state.pointShadowMap,u.pointShadowMatrix.value=i.state.pointShadowMatrix);const h=c.getUniforms(),d=la.seqWithValue(h.seq,u);return r.currentProgram=c,r.uniformsList=d,c}function ze(e,t){const n=ne.get(e);n.outputEncoding=t.outputEncoding,n.instancing=t.instancing,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}Oe.setAnimationLoop((function(e){De&&De(e)})),"undefined"!=typeof self&&Oe.setContext(self),this.setAnimationLoop=function(e){De=e,Ee.setAnimationLoop(e),null===e?Oe.stop():Oe.start()},Ee.addEventListener("sessionstart",Re),Ee.addEventListener("sessionend",qe),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===v)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Ee.enabled&&!0===Ee.isPresenting&&(!0===Ee.cameraAutoUpdate&&Ee.updateCamera(t),t=Ee.getCamera()),!0===e.isScene&&e.onBeforeRender(g,e,t,x),f=fe.get(e,m.length),f.init(),m.push(f),j.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),N.setFromProjectionMatrix(j),F=this.localClippingEnabled,z=de.init(this.clippingPlanes,F),h=he.get(e,p.length),h.init(),p.push(h),Ie(e,t,0,g.sortObjects),h.finish(),!0===g.sortObjects&&h.sort(O,I),!0===z&&de.beginShadows();const n=f.state.shadowsArray;if(pe.render(n,e,t),!0===z&&de.endShadows(),!0===this.info.autoReset&&this.info.reset(),me.render(h,e),f.setupLights(g.useLegacyLights),t.isArrayCamera){const n=t.cameras;for(let t=0,r=n.length;t<r;t++){const r=n[t];ke(h,e,r,r.viewport)}}else ke(h,e,t);null!==x&&(re.updateMultisampleRenderTarget(x),re.updateRenderTargetMipmap(x)),!0===e.isScene&&e.onAfterRender(g,e,t),xe.resetDefaultState(),_=-1,E=null,m.pop(),f=m.length>0?m[m.length-1]:null,p.pop(),h=p.length>0?p[p.length-1]:null},this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(e,t,n){ne.get(e.texture).__webglTexture=t,ne.get(e.depthTexture).__webglTexture=n;const r=ne.get(e);r.__hasExternalTextures=!0,r.__hasExternalTextures&&(r.__autoAllocateDepthBuffer=void 0===n,r.__autoAllocateDepthBuffer||!0===Y.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),r.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=ne.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){x=e,y=t,b=n;let r=!0,i=null,a=!1,o=!1;if(e){const n=ne.get(e);void 0!==n.__useDefaultFramebuffer?(ee.bindFramebuffer(36160,null),r=!1):void 0===n.__webglFramebuffer?re.setupRenderTarget(e):n.__hasExternalTextures&&re.rebindTextures(e,ne.get(e.texture).__webglTexture,ne.get(e.depthTexture).__webglTexture);const s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(o=!0);const A=ne.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=A[t],a=!0):i=K.isWebGL2&&e.samples>0&&!1===re.useMultisampledRTT(e)?ne.get(e).__webglMultisampledFramebuffer:A,T.copy(e.viewport),C.copy(e.scissor),P=e.scissorTest}else T.copy(k).multiplyScalar(q).floor(),C.copy(B).multiplyScalar(q).floor(),P=U;if(ee.bindFramebuffer(36160,i)&&K.drawBuffers&&r&&ee.drawBuffers(e,i),ee.viewport(T),ee.scissor(C),ee.setScissorTest(P),a){const r=ne.get(e.texture);we.framebufferTexture2D(36160,36064,34069+t,r.__webglTexture,n)}else if(o){const r=ne.get(e.texture),i=t||0;we.framebufferTextureLayer(36160,36064,r.__webglTexture,n||0,i)}_=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=ne.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){ee.bindFramebuffer(36160,s);try{const o=e.texture,s=o.format,A=o.type;if(s!==$&&be.convert(s)!==we.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const l=A===J&&(Y.has("EXT_color_buffer_half_float")||K.isWebGL2&&Y.has("EXT_color_buffer_float"));if(!(A===X||be.convert(A)===we.getParameter(35738)||A===Z&&(K.isWebGL2||Y.has("OES_texture_float")||Y.has("WEBGL_color_buffer_float"))||l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&we.readPixels(t,n,r,i,be.convert(s),be.convert(A),a)}finally{const e=null!==x?ne.get(x).__webglFramebuffer:null;ee.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const r=Math.pow(2,-n),i=Math.floor(t.image.width*r),a=Math.floor(t.image.height*r);re.setTexture2D(t,0),we.copyTexSubImage2D(3553,n,0,0,e.x,e.y,i,a),ee.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){const i=t.image.width,a=t.image.height,o=be.convert(n.format),s=be.convert(n.type);re.setTexture2D(n,0),we.pixelStorei(37440,n.flipY),we.pixelStorei(37441,n.premultiplyAlpha),we.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?we.texSubImage2D(3553,r,e.x,e.y,i,a,o,s,t.image.data):t.isCompressedTexture?we.compressedTexSubImage2D(3553,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):we.texSubImage2D(3553,r,e.x,e.y,o,s,t.image),0===r&&n.generateMipmaps&&we.generateMipmap(3553),ee.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,r,i=0){if(g.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const a=e.max.x-e.min.x+1,o=e.max.y-e.min.y+1,s=e.max.z-e.min.z+1,A=be.convert(r.format),l=be.convert(r.type);let c;if(r.isData3DTexture)re.setTexture3D(r,0),c=32879;else{if(!r.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");re.setTexture2DArray(r,0),c=35866}we.pixelStorei(37440,r.flipY),we.pixelStorei(37441,r.premultiplyAlpha),we.pixelStorei(3317,r.unpackAlignment);const u=we.getParameter(3314),h=we.getParameter(32878),f=we.getParameter(3316),d=we.getParameter(3315),p=we.getParameter(32877),m=n.isCompressedTexture?n.mipmaps[0]:n.image;we.pixelStorei(3314,m.width),we.pixelStorei(32878,m.height),we.pixelStorei(3316,e.min.x),we.pixelStorei(3315,e.min.y),we.pixelStorei(32877,e.min.z),n.isDataTexture||n.isData3DTexture?we.texSubImage3D(c,i,t.x,t.y,t.z,a,o,s,A,l,m.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),we.compressedTexSubImage3D(c,i,t.x,t.y,t.z,a,o,s,A,m.data)):we.texSubImage3D(c,i,t.x,t.y,t.z,a,o,s,A,l,m),we.pixelStorei(3314,u),we.pixelStorei(32878,h),we.pixelStorei(3316,f),we.pixelStorei(3315,d),we.pixelStorei(32877,p),0===i&&r.generateMipmaps&&we.generateMipmap(c),ee.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?re.setTextureCube(e,0):e.isData3DTexture?re.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?re.setTexture2DArray(e,0):re.setTexture2D(e,0),ee.unbindTexture()},this.resetState=function(){y=0,b=0,x=null,ee.reset(),xe.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}}(class extends no{}).prototype.isWebGL1Renderer=!0;class ro{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=de,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=_e()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r<i;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=_e()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=_e()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.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 io=new et;class ao{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)io.fromBufferAttribute(this,t),io.applyMatrix4(e),this.setXYZ(t,io.x,io.y,io.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)io.fromBufferAttribute(this,t),io.applyNormalMatrix(e),this.setXYZ(t,io.x,io.y,io.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)io.fromBufferAttribute(this,t),io.transformDirection(e),this.setXYZ(t,io.x,io.y,io.z);return this}setX(e,t){return this.normalized&&(t=Pe(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Pe(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Pe(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Pe(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=Ce(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Ce(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Ce(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Ce(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pe(t,this.array),n=Pe(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pe(t,this.array),n=Pe(n,this.array),r=Pe(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=Pe(t,this.array),n=Pe(n,this.array),r=Pe(r,this.array),i=Pe(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=i,this}clone(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new En(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ao(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class oo extends En{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}class so extends mn{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new xn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Ao=new et,lo=new et,co=new Lt,uo=new Pt,ho=new xt;class fo extends tn{constructor(e=new Bn,t=new so){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,r=t.count;e<r;e++)Ao.fromBufferAttribute(t,e-1),lo.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Ao.distanceTo(lo);e.setAttribute("lineDistance",new Pn(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,i=e.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),ho.copy(n.boundingSphere),ho.applyMatrix4(r),ho.radius+=i,!1===e.ray.intersectsSphere(ho))return;co.copy(r).invert(),uo.copy(e.ray).applyMatrix4(co);const o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,A=new et,l=new et,c=new et,u=new et,h=this.isLineSegments?2:1,f=n.index,d=n.attributes.position;if(null!==f){for(let n=Math.max(0,a.start),r=Math.min(f.count,a.start+a.count)-1;n<r;n+=h){const r=f.getX(n),i=f.getX(n+1);A.fromBufferAttribute(d,r),l.fromBufferAttribute(d,i);if(uo.distanceSqToSegment(A,l,u,c)>s)continue;u.applyMatrix4(this.matrixWorld);const a=e.ray.origin.distanceTo(u);a<e.near||a>e.far||t.push({distance:a,point:c.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,a.start),r=Math.min(d.count,a.start+a.count)-1;n<r;n+=h){A.fromBufferAttribute(d,n),l.fromBufferAttribute(d,n+1);if(uo.distanceSqToSegment(A,l,u,c)>s)continue;u.applyMatrix4(this.matrixWorld);const r=e.ray.origin.distanceTo(u);r<e.near||r>e.far||t.push({distance:r,point:c.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}const po=new et,mo=new et;class go extends fo{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,r=t.count;e<r;e+=2)po.fromBufferAttribute(t,e),mo.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+po.distanceTo(mo);e.setAttribute("lineDistance",new Pn(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class vo{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),i=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),i+=n.distanceTo(r),t.push(i),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let r=0;const i=n.length;let a;a=t||e*n[i-1];let o,s=0,A=i-1;for(;s<=A;)if(r=Math.floor(s+(A-s)/2),o=n[r]-a,o<0)s=r+1;else{if(!(o>0)){A=r;break}A=r-1}if(r=A,n[r]===a)return r/(i-1);const l=n[r];return(r+(a-l)/(n[r+1]-l))/(i-1)}getTangent(e,t){const n=1e-4;let r=e-n,i=e+n;r<0&&(r=0),i>1&&(i=1);const a=this.getPoint(r),o=this.getPoint(i),s=t||(a.isVector2?new De:new et);return s.copy(o).sub(a).normalize(),s}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new et,r=[],i=[],a=[],o=new et,s=new Lt;for(let t=0;t<=e;t++){const n=t/e;r[t]=this.getTangentAt(n,new et)}i[0]=new et,a[0]=new et;let A=Number.MAX_VALUE;const l=Math.abs(r[0].x),c=Math.abs(r[0].y),u=Math.abs(r[0].z);l<=A&&(A=l,n.set(1,0,0)),c<=A&&(A=c,n.set(0,1,0)),u<=A&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(let t=1;t<=e;t++){if(i[t]=i[t-1].clone(),a[t]=a[t-1].clone(),o.crossVectors(r[t-1],r[t]),o.length()>Number.EPSILON){o.normalize();const e=Math.acos(we(r[t-1].dot(r[t]),-1,1));i[t].applyMatrix4(s.makeRotationAxis(o,e))}a[t].crossVectors(r[t],i[t])}if(!0===t){let t=Math.acos(we(i[0].dot(i[e]),-1,1));t/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(t=-t);for(let n=1;n<=e;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],t*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class yo extends vo{constructor(e=0,t=0,n=1,r=1,i=0,a=2*Math.PI,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(e,t){const n=t||new De,r=2*Math.PI;let i=this.aEndAngle-this.aStartAngle;const a=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=r;for(;i>r;)i-=r;i<Number.EPSILON&&(i=a?0:r),!0!==this.aClockwise||a||(i===r?i=-r:i-=r);const o=this.aStartAngle+e*i;let s=this.aX+this.xRadius*Math.cos(o),A=this.aY+this.yRadius*Math.sin(o);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,r=A-this.aY;s=n*e-r*t+this.aX,A=n*t+r*e+this.aY}return n.set(s,A)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}function bo(){let e=0,t=0,n=0,r=0;function i(i,a,o,s){e=i,t=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(e,t,n,r,a){i(t,n,a*(n-e),a*(r-t))},initNonuniformCatmullRom:function(e,t,n,r,a,o,s){let A=(t-e)/a-(n-e)/(a+o)+(n-t)/o,l=(n-t)/o-(r-t)/(o+s)+(r-n)/s;A*=o,l*=o,i(t,n,A,l)},calc:function(i){const a=i*i;return e+t*i+n*a+r*(a*i)}}}const xo=new et,_o=new bo,wo=new bo,Mo=new bo;function So(e,t,n,r,i){const a=.5*(r-t),o=.5*(i-n),s=e*e;return(2*n-2*r+a+o)*(e*s)+(-3*n+3*r-2*a-o)*s+a*e+n}function Eo(e,t,n,r){return function(e,t){const n=1-e;return n*n*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,n)+function(e,t){return e*e*t}(e,r)}function To(e,t,n,r,i){return function(e,t){const n=1-e;return n*n*n*t}(e,t)+function(e,t){const n=1-e;return 3*n*n*e*t}(e,n)+function(e,t){return 3*(1-e)*e*e*t}(e,r)+function(e,t){return e*e*e*t}(e,i)}class Co extends vo{constructor(e=new De,t=new De,n=new De,r=new De){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new De){const n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(To(e,r.x,i.x,a.x,o.x),To(e,r.y,i.y,a.y,o.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Po extends vo{constructor(e=new et,t=new et,n=new et,r=new et){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new et){const n=t,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(To(e,r.x,i.x,a.x,o.x),To(e,r.y,i.y,a.y,o.y),To(e,r.z,i.z,a.z,o.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Lo extends vo{constructor(e=new De,t=new De){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new De){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new De){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Do extends vo{constructor(e=new De,t=new De,n=new De){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new De){const n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Eo(e,r.x,i.x,a.x),Eo(e,r.y,i.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Ro extends vo{constructor(e=new et,t=new et,n=new et){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new et){const n=t,r=this.v0,i=this.v1,a=this.v2;return n.set(Eo(e,r.x,i.x,a.x),Eo(e,r.y,i.y,a.y),Eo(e,r.z,i.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class qo extends vo{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new De){const n=t,r=this.points,i=(r.length-1)*e,a=Math.floor(i),o=i-a,s=r[0===a?a:a-1],A=r[a],l=r[a>r.length-2?r.length-1:a+1],c=r[a>r.length-3?r.length-1:a+2];return n.set(So(o,s.x,A.x,l.x,c.x),So(o,s.y,A.y,l.y,c.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new De).fromArray(n))}return this}}var Oo=Object.freeze({__proto__:null,ArcCurve:class extends yo{constructor(e,t,n,r,i,a){super(e,t,n,n,r,i,a),this.isArcCurve=!0,this.type="ArcCurve"}},CatmullRomCurve3:class extends vo{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new et){const n=t,r=this.points,i=r.length,a=(i-(this.closed?0:1))*e;let o,s,A=Math.floor(a),l=a-A;this.closed?A+=A>0?0:(Math.floor(Math.abs(A)/i)+1)*i:0===l&&A===i-1&&(A=i-2,l=1),this.closed||A>0?o=r[(A-1)%i]:(xo.subVectors(r[0],r[1]).add(r[0]),o=xo);const c=r[A%i],u=r[(A+1)%i];if(this.closed||A+2<i?s=r[(A+2)%i]:(xo.subVectors(r[i-1],r[i-2]).add(r[i-1]),s=xo),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(o.distanceToSquared(c),e),n=Math.pow(c.distanceToSquared(u),e),r=Math.pow(u.distanceToSquared(s),e);n<1e-4&&(n=1),t<1e-4&&(t=n),r<1e-4&&(r=n),_o.initNonuniformCatmullRom(o.x,c.x,u.x,s.x,t,n,r),wo.initNonuniformCatmullRom(o.y,c.y,u.y,s.y,t,n,r),Mo.initNonuniformCatmullRom(o.z,c.z,u.z,s.z,t,n,r)}else"catmullrom"===this.curveType&&(_o.initCatmullRom(o.x,c.x,u.x,s.x,this.tension),wo.initCatmullRom(o.y,c.y,u.y,s.y,this.tension),Mo.initCatmullRom(o.z,c.z,u.z,s.z,this.tension));return n.set(_o.calc(l),wo.calc(l),Mo.calc(l)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new et).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}},CubicBezierCurve:Co,CubicBezierCurve3:Po,EllipseCurve:yo,LineCurve:Lo,LineCurve3:class extends vo{constructor(e=new et,t=new et){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new et){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new et){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}},QuadraticBezierCurve:Do,QuadraticBezierCurve3:Ro,SplineCurve:qo});class Io extends vo{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new Lo(t,e))}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let i=0;for(;i<r.length;){if(r[i]>=n){const e=r[i]-n,a=this.curves[i],o=a.getLength(),s=0===o?0:1-e/o;return a.getPointAt(s,t)}i++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let r=0,i=this.curves;r<i.length;r++){const a=i[r],o=a.isEllipseCurve?2*e:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,s=a.getPoints(o);for(let e=0;e<s.length;e++){const r=s[e];n&&n.equals(r)||(t.push(r),n=r)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push((new Oo[n.type]).fromJSON(n))}return this}}let ko=class extends Io{constructor(e){super(),this.type="Path",this.currentPoint=new De,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new Lo(this.currentPoint.clone(),new De(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const i=new Do(this.currentPoint.clone(),new De(e,t),new De(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,i,a){const o=new Co(this.currentPoint.clone(),new De(e,t),new De(n,r),new De(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new qo(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,i,a){const o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+o,t+s,n,r,i,a),this}absarc(e,t,n,r,i,a){return this.absellipse(e,t,n,n,r,i,a),this}ellipse(e,t,n,r,i,a,o,s){const A=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(e+A,t+l,n,r,i,a,o,s),this}absellipse(e,t,n,r,i,a,o,s){const A=new yo(e,t,n,r,i,a,o,s);if(this.curves.length>0){const e=A.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(A);const l=A.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class Bo extends Bn{constructor(e=1,t=32,n=0,r=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const i=[],a=[],o=[],s=[],A=new et,l=new De;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let i=0,c=3;i<=t;i++,c+=3){const u=n+i/t*r;A.x=e*Math.cos(u),A.y=e*Math.sin(u),a.push(A.x,A.y,A.z),o.push(0,0,1),l.x=(a[c]/e+1)/2,l.y=(a[c+1]/e+1)/2,s.push(l.x,l.y)}for(let e=1;e<=t;e++)i.push(e,e+1,0);this.setIndex(i),this.setAttribute("position",new Pn(a,3)),this.setAttribute("normal",new Pn(o,3)),this.setAttribute("uv",new Pn(s,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Bo(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Uo extends Bn{constructor(e=1,t=1,n=1,r=32,i=1,a=!1,o=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:i,openEnded:a,thetaStart:o,thetaLength:s};const A=this;r=Math.floor(r),i=Math.floor(i);const l=[],c=[],u=[],h=[];let f=0;const d=[],p=n/2;let m=0;function g(n){const i=f,a=new De,d=new et;let g=0;const v=!0===n?e:t,y=!0===n?1:-1;for(let e=1;e<=r;e++)c.push(0,p*y,0),u.push(0,y,0),h.push(.5,.5),f++;const b=f;for(let e=0;e<=r;e++){const t=e/r*s+o,n=Math.cos(t),i=Math.sin(t);d.x=v*i,d.y=p*y,d.z=v*n,c.push(d.x,d.y,d.z),u.push(0,y,0),a.x=.5*n+.5,a.y=.5*i*y+.5,h.push(a.x,a.y),f++}for(let e=0;e<r;e++){const t=i+e,r=b+e;!0===n?l.push(r,r+1,t):l.push(r+1,r,t),g+=3}A.addGroup(m,g,!0===n?1:2),m+=g}!function(){const a=new et,g=new et;let v=0;const y=(t-e)/n;for(let A=0;A<=i;A++){const l=[],m=A/i,v=m*(t-e)+e;for(let e=0;e<=r;e++){const t=e/r,i=t*s+o,A=Math.sin(i),d=Math.cos(i);g.x=v*A,g.y=-m*n+p,g.z=v*d,c.push(g.x,g.y,g.z),a.set(A,y,d).normalize(),u.push(a.x,a.y,a.z),h.push(t,1-m),l.push(f++)}d.push(l)}for(let e=0;e<r;e++)for(let t=0;t<i;t++){const n=d[t][e],r=d[t+1][e],i=d[t+1][e+1],a=d[t][e+1];l.push(n,r,a),l.push(r,i,a),v+=6}A.addGroup(m,v,0),m+=v}(),!1===a&&(e>0&&g(!0),t>0&&g(!1)),this.setIndex(l),this.setAttribute("position",new Pn(c,3)),this.setAttribute("normal",new Pn(u,3)),this.setAttribute("uv",new Pn(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Uo(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class No extends ko{constructor(e){super(e),this.uuid=_e(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push((new ko).fromJSON(n))}return this}}const zo=function(e,t,n=2){const r=t&&t.length,i=r?t[0]*n:e.length;let a=Fo(e,0,i,n,!0);const o=[];if(!a||a.next===a.prev)return o;let s,A,l,c,u,h,f;if(r&&(a=function(e,t,n,r){const i=[];let a,o,s,A,l;for(a=0,o=t.length;a<o;a++)s=t[a]*r,A=a<o-1?t[a+1]*r:e.length,l=Fo(e,s,A,r,!1),l===l.next&&(l.steiner=!0),i.push(Ko(l));for(i.sort(Xo),a=0;a<i.length;a++)n=Yo(i[a],n);return n}(e,t,a,n)),e.length>80*n){s=l=e[0],A=c=e[1];for(let t=n;t<i;t+=n)u=e[t],h=e[t+1],u<s&&(s=u),h<A&&(A=h),u>l&&(l=u),h>c&&(c=h);f=Math.max(l-s,c-A),f=0!==f?32767/f:0}return jo(a,o,n,s,A,f,0),o};function Fo(e,t,n,r,i){let a,o;if(i===function(e,t,n,r){let i=0;for(let a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}(e,t,n,r)>0)for(a=t;a<n;a+=r)o=As(a,e[a],e[a+1],o);else for(a=n-r;a>=t;a-=r)o=As(a,e[a],e[a+1],o);return o&&ns(o,o.next)&&(ls(o),o=o.next),o}function Go(e,t){if(!e)return e;t||(t=e);let n,r=e;do{if(n=!1,r.steiner||!ns(r,r.next)&&0!==ts(r.prev,r,r.next))r=r.next;else{if(ls(r),r=t=r.prev,r===r.next)break;n=!0}}while(n||r!==t);return t}function jo(e,t,n,r,i,a,o){if(!e)return;!o&&a&&function(e,t,n,r){let i=e;do{0===i.z&&(i.z=Jo(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){let t,n,r,i,a,o,s,A,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t<l&&(s++,r=r.nextZ,r);t++);for(A=l;s>0||A>0&&r;)0!==s&&(0===A||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,A--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1)}(i)}(e,r,i,a);let s,A,l=e;for(;e.prev!==e.next;)if(s=e.prev,A=e.next,a?Vo(e,r,i,a):Ho(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(A.i/n|0),ls(e),e=A.next,l=A.next;else if((e=A)===l){o?1===o?jo(e=Wo(Go(e),t,n),t,n,r,i,a,2):2===o&&Qo(e,t,n,r,i,a):jo(Go(e),t,n,r,i,a,1);break}}function Ho(e){const t=e.prev,n=e,r=e.next;if(ts(t,n,r)>=0)return!1;const i=t.x,a=n.x,o=r.x,s=t.y,A=n.y,l=r.y,c=i<a?i<o?i:o:a<o?a:o,u=s<A?s<l?s:l:A<l?A:l,h=i>a?i>o?i:o:a>o?a:o,f=s>A?s>l?s:l:A>l?A:l;let d=r.next;for(;d!==t;){if(d.x>=c&&d.x<=h&&d.y>=u&&d.y<=f&&$o(i,s,a,A,o,l,d.x,d.y)&&ts(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function Vo(e,t,n,r){const i=e.prev,a=e,o=e.next;if(ts(i,a,o)>=0)return!1;const s=i.x,A=a.x,l=o.x,c=i.y,u=a.y,h=o.y,f=s<A?s<l?s:l:A<l?A:l,d=c<u?c<h?c:h:u<h?u:h,p=s>A?s>l?s:l:A>l?A:l,m=c>u?c>h?c:h:u>h?u:h,g=Jo(f,d,t,n,r),v=Jo(p,m,t,n,r);let y=e.prevZ,b=e.nextZ;for(;y&&y.z>=g&&b&&b.z<=v;){if(y.x>=f&&y.x<=p&&y.y>=d&&y.y<=m&&y!==i&&y!==o&&$o(s,c,A,u,l,h,y.x,y.y)&&ts(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,b.x>=f&&b.x<=p&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&$o(s,c,A,u,l,h,b.x,b.y)&&ts(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;y&&y.z>=g;){if(y.x>=f&&y.x<=p&&y.y>=d&&y.y<=m&&y!==i&&y!==o&&$o(s,c,A,u,l,h,y.x,y.y)&&ts(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=p&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&$o(s,c,A,u,l,h,b.x,b.y)&&ts(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function Wo(e,t,n){let r=e;do{const i=r.prev,a=r.next.next;!ns(i,a)&&rs(i,r,r.next,a)&&os(i,a)&&os(a,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(a.i/n|0),ls(r),ls(r.next),r=e=a),r=r.next}while(r!==e);return Go(r)}function Qo(e,t,n,r,i,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&es(o,e)){let s=ss(o,e);return o=Go(o,o.next),s=Go(s,s.next),jo(o,t,n,r,i,a,0),void jo(s,t,n,r,i,a,0)}e=e.next}o=o.next}while(o!==e)}function Xo(e,t){return e.x-t.x}function Yo(e,t){const n=function(e,t){let n,r=t,i=-1/0;const a=e.x,o=e.y;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){const e=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(e<=a&&e>i&&(i=e,n=r.x<r.next.x?r:r.next,e===a))return n}r=r.next}while(r!==t);if(!n)return null;const s=n,A=n.x,l=n.y;let c,u=1/0;r=n;do{a>=r.x&&r.x>=A&&a!==r.x&&$o(o<l?a:i,o,A,l,o<l?i:a,o,r.x,r.y)&&(c=Math.abs(o-r.y)/(a-r.x),os(r,e)&&(c<u||c===u&&(r.x>n.x||r.x===n.x&&Zo(n,r)))&&(n=r,u=c)),r=r.next}while(r!==s);return n}(e,t);if(!n)return t;const r=ss(n,e);return Go(r,r.next),Go(n,n.next)}function Zo(e,t){return ts(e.prev,e,t.prev)<0&&ts(t.next,e,e.next)<0}function Jo(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Ko(e){let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function $o(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function es(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&rs(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(os(e,t)&&os(t,e)&&function(e,t){let n=e,r=!1;const i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(ts(e.prev,e,t.prev)||ts(e,t.prev,t))||ns(e,t)&&ts(e.prev,e,e.next)>0&&ts(t.prev,t,t.next)>0)}function ts(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function ns(e,t){return e.x===t.x&&e.y===t.y}function rs(e,t,n,r){const i=as(ts(e,t,n)),a=as(ts(e,t,r)),o=as(ts(n,r,e)),s=as(ts(n,r,t));return i!==a&&o!==s||(!(0!==i||!is(e,n,t))||(!(0!==a||!is(e,r,t))||(!(0!==o||!is(n,e,r))||!(0!==s||!is(n,t,r)))))}function is(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function as(e){return e>0?1:e<0?-1:0}function os(e,t){return ts(e.prev,e,e.next)<0?ts(e,t,e.next)>=0&&ts(e,e.prev,t)>=0:ts(e,t,e.prev)<0||ts(e,e.next,t)<0}function ss(e,t){const n=new cs(e.i,e.x,e.y),r=new cs(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function As(e,t,n,r){const i=new cs(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function ls(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function cs(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class us{static area(e){const t=e.length;let n=0;for(let r=t-1,i=0;i<t;r=i++)n+=e[r].x*e[i].y-e[i].x*e[r].y;return.5*n}static isClockWise(e){return us.area(e)<0}static triangulateShape(e,t){const n=[],r=[],i=[];hs(e),fs(n,e);let a=e.length;t.forEach(hs);for(let e=0;e<t.length;e++)r.push(a),a+=t[e].length,fs(n,t[e]);const o=zo(n,r);for(let e=0;e<o.length;e+=3)i.push(o.slice(e,e+3));return i}}function hs(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function fs(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class ds extends Bn{constructor(e=new No([new De(.5,.5),new De(-.5,.5),new De(-.5,-.5),new De(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],i=[];for(let t=0,n=e.length;t<n;t++){a(e[t])}function a(e){const a=[],o=void 0!==t.curveSegments?t.curveSegments:12,s=void 0!==t.steps?t.steps:1,A=void 0!==t.depth?t.depth:1;let l=void 0===t.bevelEnabled||t.bevelEnabled,c=void 0!==t.bevelThickness?t.bevelThickness:.2,u=void 0!==t.bevelSize?t.bevelSize:c-.1,h=void 0!==t.bevelOffset?t.bevelOffset:0,f=void 0!==t.bevelSegments?t.bevelSegments:3;const d=t.extrudePath,p=void 0!==t.UVGenerator?t.UVGenerator:ps;let m,g,v,y,b,x=!1;d&&(m=d.getSpacedPoints(s),x=!0,l=!1,g=d.computeFrenetFrames(s,!1),v=new et,y=new et,b=new et),l||(f=0,c=0,u=0,h=0);const _=e.extractPoints(o);let w=_.shape;const M=_.holes;if(!us.isClockWise(w)){w=w.reverse();for(let e=0,t=M.length;e<t;e++){const t=M[e];us.isClockWise(t)&&(M[e]=t.reverse())}}const S=us.triangulateShape(w,M),E=w;for(let e=0,t=M.length;e<t;e++){const t=M[e];w=w.concat(t)}function T(e,t,n){return t||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().addScaledVector(t,n)}const C=w.length,P=S.length;function L(e,t,n){let r,i,a;const o=e.x-t.x,s=e.y-t.y,A=n.x-e.x,l=n.y-e.y,c=o*o+s*s,u=o*l-s*A;if(Math.abs(u)>Number.EPSILON){const u=Math.sqrt(c),h=Math.sqrt(A*A+l*l),f=t.x-s/u,d=t.y+o/u,p=((n.x-l/h-f)*l-(n.y+A/h-d)*A)/(o*l-s*A);r=f+o*p-e.x,i=d+s*p-e.y;const m=r*r+i*i;if(m<=2)return new De(r,i);a=Math.sqrt(m/2)}else{let e=!1;o>Number.EPSILON?A>Number.EPSILON&&(e=!0):o<-Number.EPSILON?A<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(l)&&(e=!0),e?(r=-s,i=o,a=Math.sqrt(c)):(r=o,i=s,a=Math.sqrt(c/2))}return new De(r/a,i/a)}const D=[];for(let e=0,t=E.length,n=t-1,r=e+1;e<t;e++,n++,r++)n===t&&(n=0),r===t&&(r=0),D[e]=L(E[e],E[n],E[r]);const R=[];let q,O=D.concat();for(let e=0,t=M.length;e<t;e++){const t=M[e];q=[];for(let e=0,n=t.length,r=n-1,i=e+1;e<n;e++,r++,i++)r===n&&(r=0),i===n&&(i=0),q[e]=L(t[e],t[r],t[i]);R.push(q),O=O.concat(q)}for(let e=0;e<f;e++){const t=e/f,n=c*Math.cos(t*Math.PI/2),r=u*Math.sin(t*Math.PI/2)+h;for(let e=0,t=E.length;e<t;e++){const t=T(E[e],D[e],r);B(t.x,t.y,-n)}for(let e=0,t=M.length;e<t;e++){const t=M[e];q=R[e];for(let e=0,i=t.length;e<i;e++){const i=T(t[e],q[e],r);B(i.x,i.y,-n)}}}const I=u+h;for(let e=0;e<C;e++){const t=l?T(w[e],O[e],I):w[e];x?(y.copy(g.normals[0]).multiplyScalar(t.x),v.copy(g.binormals[0]).multiplyScalar(t.y),b.copy(m[0]).add(y).add(v),B(b.x,b.y,b.z)):B(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<C;t++){const n=l?T(w[t],O[t],I):w[t];x?(y.copy(g.normals[e]).multiplyScalar(n.x),v.copy(g.binormals[e]).multiplyScalar(n.y),b.copy(m[e]).add(y).add(v),B(b.x,b.y,b.z)):B(n.x,n.y,A/s*e)}for(let e=f-1;e>=0;e--){const t=e/f,n=c*Math.cos(t*Math.PI/2),r=u*Math.sin(t*Math.PI/2)+h;for(let e=0,t=E.length;e<t;e++){const t=T(E[e],D[e],r);B(t.x,t.y,A+n)}for(let e=0,t=M.length;e<t;e++){const t=M[e];q=R[e];for(let e=0,i=t.length;e<i;e++){const i=T(t[e],q[e],r);x?B(i.x,i.y+m[s-1].y,m[s-1].x+n):B(i.x,i.y,A+n)}}}function k(e,t){let n=e.length;for(;--n>=0;){const r=n;let i=n-1;i<0&&(i=e.length-1);for(let e=0,n=s+2*f;e<n;e++){const n=C*e,a=C*(e+1);N(t+r+n,t+i+n,t+i+a,t+r+a)}}}function B(e,t,n){a.push(e),a.push(t),a.push(n)}function U(e,t,i){z(e),z(t),z(i);const a=r.length/3,o=p.generateTopUV(n,r,a-3,a-2,a-1);F(o[0]),F(o[1]),F(o[2])}function N(e,t,i,a){z(e),z(t),z(a),z(t),z(i),z(a);const o=r.length/3,s=p.generateSideWallUV(n,r,o-6,o-3,o-2,o-1);F(s[0]),F(s[1]),F(s[3]),F(s[1]),F(s[2]),F(s[3])}function z(e){r.push(a[3*e+0]),r.push(a[3*e+1]),r.push(a[3*e+2])}function F(e){i.push(e.x),i.push(e.y)}!function(){const e=r.length/3;if(l){let e=0,t=C*e;for(let e=0;e<P;e++){const n=S[e];U(n[2]+t,n[1]+t,n[0]+t)}e=s+2*f,t=C*e;for(let e=0;e<P;e++){const n=S[e];U(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<P;e++){const t=S[e];U(t[2],t[1],t[0])}for(let e=0;e<P;e++){const t=S[e];U(t[0]+C*s,t[1]+C*s,t[2]+C*s)}}n.addGroup(e,r.length/3-e,0)}(),function(){const e=r.length/3;let t=0;k(E,t),t+=E.length;for(let e=0,n=M.length;e<n;e++){const n=M[e];k(n,t),t+=n.length}n.addGroup(e,r.length/3-e,1)}()}this.setAttribute("position",new Pn(r,3)),this.setAttribute("uv",new Pn(i,2)),this.computeVertexNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return function(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,r=e.length;t<r;t++){const r=e[t];n.shapes.push(r.uuid)}else n.shapes.push(e.uuid);n.options=Object.assign({},t),void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const n=[];for(let r=0,i=e.shapes.length;r<i;r++){const i=t[e.shapes[r]];n.push(i)}const r=e.options.extrudePath;return void 0!==r&&(e.options.extrudePath=(new Oo[r.type]).fromJSON(r)),new ds(n,e.options)}}const ps={generateTopUV:function(e,t,n,r,i){const a=t[3*n],o=t[3*n+1],s=t[3*r],A=t[3*r+1],l=t[3*i],c=t[3*i+1];return[new De(a,o),new De(s,A),new De(l,c)]},generateSideWallUV:function(e,t,n,r,i,a){const o=t[3*n],s=t[3*n+1],A=t[3*n+2],l=t[3*r],c=t[3*r+1],u=t[3*r+2],h=t[3*i],f=t[3*i+1],d=t[3*i+2],p=t[3*a],m=t[3*a+1],g=t[3*a+2];return Math.abs(s-c)<Math.abs(o-l)?[new De(o,1-A),new De(l,1-u),new De(h,1-d),new De(p,1-g)]:[new De(s,1-A),new De(c,1-u),new De(f,1-d),new De(m,1-g)]}};class ms extends Bn{constructor(e=1,t=32,n=16,r=0,i=2*Math.PI,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const s=Math.min(a+o,Math.PI);let A=0;const l=[],c=new et,u=new et,h=[],f=[],d=[],p=[];for(let h=0;h<=n;h++){const m=[],g=h/n;let v=0;0===h&&0===a?v=.5/t:h===n&&s===Math.PI&&(v=-.5/t);for(let n=0;n<=t;n++){const s=n/t;c.x=-e*Math.cos(r+s*i)*Math.sin(a+g*o),c.y=e*Math.cos(a+g*o),c.z=e*Math.sin(r+s*i)*Math.sin(a+g*o),f.push(c.x,c.y,c.z),u.copy(c).normalize(),d.push(u.x,u.y,u.z),p.push(s+v,1-g),m.push(A++)}l.push(m)}for(let e=0;e<n;e++)for(let r=0;r<t;r++){const t=l[e][r+1],i=l[e][r],o=l[e+1][r],A=l[e+1][r+1];(0!==e||a>0)&&h.push(t,i,A),(e!==n-1||s<Math.PI)&&h.push(i,o,A)}this.setIndex(h),this.setAttribute("position",new Pn(f,3)),this.setAttribute("normal",new Pn(d,3)),this.setAttribute("uv",new Pn(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ms(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class gs extends Bn{constructor(e=new Ro(new et(-1,-1,0),new et(-1,1,0),new et(1,1,0)),t=64,n=1,r=8,i=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:i};const a=e.computeFrenetFrames(t,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new et,s=new et,A=new De;let l=new et;const c=[],u=[],h=[],f=[];function d(i){l=e.getPointAt(i/t,l);const A=a.normals[i],h=a.binormals[i];for(let e=0;e<=r;e++){const t=e/r*Math.PI*2,i=Math.sin(t),a=-Math.cos(t);s.x=a*A.x+i*h.x,s.y=a*A.y+i*h.y,s.z=a*A.z+i*h.z,s.normalize(),u.push(s.x,s.y,s.z),o.x=l.x+n*s.x,o.y=l.y+n*s.y,o.z=l.z+n*s.z,c.push(o.x,o.y,o.z)}}!function(){for(let e=0;e<t;e++)d(e);d(!1===i?t:0),function(){for(let e=0;e<=t;e++)for(let n=0;n<=r;n++)A.x=e/t,A.y=n/r,h.push(A.x,A.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=r;t++){const n=(r+1)*(e-1)+(t-1),i=(r+1)*e+(t-1),a=(r+1)*e+t,o=(r+1)*(e-1)+t;f.push(n,i,o),f.push(i,a,o)}}()}(),this.setIndex(f),this.setAttribute("position",new Pn(c,3)),this.setAttribute("normal",new Pn(u,3)),this.setAttribute("uv",new Pn(h,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new gs((new Oo[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}function vs(e,t,n){const r=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,i=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return!0!==n.has(r)&&!0!==n.has(i)&&(n.add(r),n.add(i),!0)}class ys extends mn{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=le,this.normalScale=new De(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=P,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}const bs={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class xs{constructor(e,t,n){const r=this;let i,a=!1,o=0,s=0;const A=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){s++,!1===a&&void 0!==r.onStart&&r.onStart(e,o,s),a=!0},this.itemEnd=function(e){o++,void 0!==r.onProgress&&r.onProgress(e,o,s),o===s&&(a=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(e){void 0!==r.onError&&r.onError(e)},this.resolveURL=function(e){return i?i(e):e},this.setURLModifier=function(e){return i=e,this},this.addHandler=function(e,t){return A.push(e,t),this},this.removeHandler=function(e){const t=A.indexOf(e);return-1!==t&&A.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=A.length;t<n;t+=2){const n=A[t],r=A[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return r}return null}}}const _s=new xs;class ws{constructor(e){this.manager=void 0!==e?e:_s,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise((function(r,i){n.load(e,r,t,i)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}class Ms extends ws{constructor(e){super(e)}load(e,t,n,r){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const i=this,a=bs.get(e);if(void 0!==a)return i.manager.itemStart(e),setTimeout((function(){t&&t(a),i.manager.itemEnd(e)}),0),a;const o=Ie("img");function s(){l(),bs.add(e,this),t&&t(this),i.manager.itemEnd(e)}function A(t){l(),r&&r(t),i.manager.itemError(e),i.manager.itemEnd(e)}function l(){o.removeEventListener("load",s,!1),o.removeEventListener("error",A,!1)}return o.addEventListener("load",s,!1),o.addEventListener("error",A,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(e),o.src=e,o}}class Ss extends ws{constructor(e){super(e)}load(e,t,n,r){const i=new Xe,a=new Ms(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,(function(e){i.image=e,i.needsUpdate=!0,void 0!==t&&t(i)}),n,r),i}}class Es extends tn{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xn(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}const Ts=new Lt,Cs=new et,Ps=new et;class Ls{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new De(512,512),this.map=null,this.mapPass=null,this.matrix=new Lt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new xr,this._frameExtents=new De(1,1),this._viewportCount=1,this._viewports=[new Ye(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Cs.setFromMatrixPosition(e.matrixWorld),t.position.copy(Cs),Ps.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ps),t.updateMatrixWorld(),Ts.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ts),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ts)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Ds extends Ls{constructor(){super(new Ir(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Rs{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=qs(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=qs();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function qs(){return("undefined"==typeof performance?Date:performance).now()}class Os extends ro{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}function Is(e,t){return e.distance-t.distance}function ks(e,t,n,r){if(e.layers.test(t.layers)&&e.raycast(t,n),!0===r){const r=e.children;for(let e=0,i=r.length;e<i;e++)ks(r[e],t,n,!0)}}class Bs{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(we(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}const Us=new et,Ns=new et;class zs{constructor(){this.type="ShapePath",this.color=new xn,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new ko,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,i,a){return this.currentPath.bezierCurveTo(e,t,n,r,i,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const n=t.length;let r=!1;for(let i=n-1,a=0;a<n;i=a++){let n=t[i],o=t[a],s=o.x-n.x,A=o.y-n.y;if(Math.abs(A)>Number.EPSILON){if(A<0&&(n=t[a],s=-s,o=t[i],A=-A),e.y<n.y||e.y>o.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=A*(e.x-n.x)-s*(e.y-n.y);if(0===t)return!0;if(t<0)continue;r=!r}}else{if(e.y!==n.y)continue;if(o.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=o.x)return!0}}return r}const n=us.isClockWise,r=this.subPaths;if(0===r.length)return[];let i,a,o;const s=[];if(1===r.length)return a=r[0],o=new No,o.curves=a.curves,s.push(o),s;let A=!n(r[0].getPoints());A=e?!A:A;const l=[],c=[];let u,h,f=[],d=0;c[d]=void 0,f[d]=[];for(let t=0,o=r.length;t<o;t++)a=r[t],u=a.getPoints(),i=n(u),i=e?!i:i,i?(!A&&c[d]&&d++,c[d]={s:new No,p:u},c[d].s.curves=a.curves,A&&d++,f[d]=[]):f[d].push({h:a,p:u[0]});if(!c[0])return function(e){const t=[];for(let n=0,r=e.length;n<r;n++){const r=e[n],i=new No;i.curves=r.curves,t.push(i)}return t}(r);if(c.length>1){let e=!1,n=0;for(let e=0,t=c.length;e<t;e++)l[e]=[];for(let r=0,i=c.length;r<i;r++){const i=f[r];for(let a=0;a<i.length;a++){const o=i[a];let s=!0;for(let i=0;i<c.length;i++)t(o.p,c[i].p)&&(r!==i&&n++,s?(s=!1,l[i].push(o)):e=!0);s&&l[r].push(o)}}n>0&&!1===e&&(f=l)}for(let e=0,t=c.length;e<t;e++){o=c[e].s,s.push(o),h=f[e];for(let e=0,t=h.length;e<t;e++)o.holes.push(h[e].h)}return s}}"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:d}})),"undefined"!=typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=d);const Fs=new et,Gs=new Lt,js=new Lt,Hs=new et,Vs=new et;var Ws="object"==typeof global&&global&&global.Object===Object&&global,Qs="object"==typeof self&&self&&self.Object===Object&&self,Xs=Ws||Qs||Function("return this")(),Ys=Xs.Symbol,Zs=Object.prototype,Js=Zs.hasOwnProperty,Ks=Zs.toString,$s=Ys?Ys.toStringTag:void 0;var eA=Object.prototype.toString;var tA="[object Null]",nA="[object Undefined]",rA=Ys?Ys.toStringTag:void 0;function iA(e){return null==e?void 0===e?nA:tA:rA&&rA in Object(e)?function(e){var t=Js.call(e,$s),n=e[$s];try{e[$s]=void 0;var r=!0}catch(e){}var i=Ks.call(e);return r&&(t?e[$s]=n:delete e[$s]),i}(e):function(e){return eA.call(e)}(e)}var aA="[object Symbol]";var oA=/\s/;var sA=/^\s+/;function AA(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&oA.test(e.charAt(t)););return t}(e)+1).replace(sA,""):e}function lA(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var cA=NaN,uA=/^[-+]0x[0-9a-f]+$/i,hA=/^0b[01]+$/i,fA=/^0o[0-7]+$/i,dA=parseInt;function pA(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&iA(e)==aA}(e))return cA;if(lA(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=lA(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=AA(e);var n=hA.test(e);return n||fA.test(e)?dA(e.slice(2),n?2:8):uA.test(e)?cA:+e}var mA=function(){return Xs.Date.now()},gA="Expected a function",vA=Math.max,yA=Math.min;function bA(e,t,n){var r,i,a,o,s,A,l=0,c=!1,u=!1,h=!0;if("function"!=typeof e)throw new TypeError(gA);function f(t){var n=r,a=i;return r=i=void 0,l=t,o=e.apply(a,n)}function d(e){var n=e-A;return void 0===A||n>=t||n<0||u&&e-l>=a}function p(){var e=mA();if(d(e))return m(e);s=setTimeout(p,function(e){var n=t-(e-A);return u?yA(n,a-(e-l)):n}(e))}function m(e){return s=void 0,h&&r?f(e):(r=i=void 0,o)}function g(){var e=mA(),n=d(e);if(r=arguments,i=this,A=e,n){if(void 0===s)return function(e){return l=e,s=setTimeout(p,t),c?f(e):o}(A);if(u)return clearTimeout(s),s=setTimeout(p,t),f(A)}return void 0===s&&(s=setTimeout(p,t)),o}return t=pA(t)||0,lA(n)&&(c=!!n.leading,a=(u="maxWait"in n)?vA(pA(n.maxWait)||0,t):a,h="trailing"in n?!!n.trailing:h),g.cancel=function(){void 0!==s&&clearTimeout(s),l=0,r=A=i=s=void 0},g.flush=function(){return void 0===s?o:m(mA())},g}function xA(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(i=r.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(i,"string"))?a:String(a)),r)}var i,a}function _A(e,t,n){return t&&xA(e.prototype,t),n&&xA(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function wA(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],A=!0,l=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;A=!1}else for(;!(A=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);A=!0);}catch(e){l=!0,i=e}finally{try{if(!A&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return MA(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return MA(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function MA(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var SA=_A((function e(t,n){var r=n.default,i=void 0===r?null:r,a=n.triggerUpdate,o=void 0===a||a,s=n.onChange,A=void 0===s?function(e,t){}:s;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name=t,this.defaultVal=i,this.triggerUpdate=o,this.onChange=A}));function EA(e){var t=e.stateInit,n=void 0===t?function(){return{}}:t,r=e.props,i=void 0===r?{}:r,a=e.methods,o=void 0===a?{}:a,s=e.aliases,A=void 0===s?{}:s,l=e.init,c=void 0===l?function(){}:l,u=e.update,h=void 0===u?function(){}:u,f=Object.keys(i).map((function(e){return new SA(e,i[e])}));return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},n instanceof Function?n(e):n,{initialised:!1}),r={};function i(t){return a(t,e),s(),i}var a=function(e,n){c.call(i,e,t,n),t.initialised=!0},s=bA((function(){t.initialised&&(h.call(i,t,r),r={})}),1);return f.forEach((function(e){i[e.name]=function(e){var n=e.name,a=e.triggerUpdate,o=void 0!==a&&a,A=e.onChange,l=void 0===A?function(e,t){}:A,c=e.defaultVal,u=void 0===c?null:c;return function(e){var a=t[n];if(!arguments.length)return a;var A=void 0===e?u:e;return t[n]=A,l.call(i,A,t,a),!r.hasOwnProperty(n)&&(r[n]=a),o&&s(),i}}(e)})),Object.keys(o).forEach((function(e){i[e]=function(){for(var n,r=arguments.length,a=new Array(r),s=0;s<r;s++)a[s]=arguments[s];return(n=o[e]).call.apply(n,[i,t].concat(a))}})),Object.entries(A).forEach((function(e){var t=wA(e,2),n=t[0],r=t[1];return i[n]=i[r]})),i.resetProps=function(){return f.forEach((function(e){i[e.name](e.defaultVal)})),i},i.resetProps(),t._rerender=s,i}}var TA,CA=Object.freeze({Linear:Object.freeze({None:function(e){return e},In:function(e){return this.None(e)},Out:function(e){return this.None(e)},InOut:function(e){return this.None(e)}}),Quadratic:Object.freeze({In:function(e){return e*e},Out:function(e){return e*(2-e)},InOut:function(e){return(e*=2)<1?.5*e*e:-.5*(--e*(e-2)-1)}}),Cubic:Object.freeze({In:function(e){return e*e*e},Out:function(e){return--e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e:.5*((e-=2)*e*e+2)}}),Quartic:Object.freeze({In:function(e){return e*e*e*e},Out:function(e){return 1- --e*e*e*e},InOut:function(e){return(e*=2)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2)}}),Quintic:Object.freeze({In:function(e){return e*e*e*e*e},Out:function(e){return--e*e*e*e*e+1},InOut:function(e){return(e*=2)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2)}}),Sinusoidal:Object.freeze({In:function(e){return 1-Math.sin((1-e)*Math.PI/2)},Out:function(e){return Math.sin(e*Math.PI/2)},InOut:function(e){return.5*(1-Math.sin(Math.PI*(.5-e)))}}),Exponential:Object.freeze({In:function(e){return 0===e?0:Math.pow(1024,e-1)},Out:function(e){return 1===e?1:1-Math.pow(2,-10*e)},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?.5*Math.pow(1024,e-1):.5*(2-Math.pow(2,-10*(e-1)))}}),Circular:Object.freeze({In:function(e){return 1-Math.sqrt(1-e*e)},Out:function(e){return Math.sqrt(1- --e*e)},InOut:function(e){return(e*=2)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1)}}),Elastic:Object.freeze({In:function(e){return 0===e?0:1===e?1:-Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)},Out:function(e){return 0===e?0:1===e?1:Math.pow(2,-10*e)*Math.sin(5*(e-.1)*Math.PI)+1},InOut:function(e){return 0===e?0:1===e?1:(e*=2)<1?-.5*Math.pow(2,10*(e-1))*Math.sin(5*(e-1.1)*Math.PI):.5*Math.pow(2,-10*(e-1))*Math.sin(5*(e-1.1)*Math.PI)+1}}),Back:Object.freeze({In:function(e){var t=1.70158;return 1===e?1:e*e*((t+1)*e-t)},Out:function(e){var t=1.70158;return 0===e?0:--e*e*((t+1)*e+t)+1},InOut:function(e){var t=2.5949095;return(e*=2)<1?e*e*((t+1)*e-t)*.5:.5*((e-=2)*e*((t+1)*e+t)+2)}}),Bounce:Object.freeze({In:function(e){return 1-CA.Bounce.Out(1-e)},Out:function(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},InOut:function(e){return e<.5?.5*CA.Bounce.In(2*e):.5*CA.Bounce.Out(2*e-1)+.5}}),generatePow:function(e){return void 0===e&&(e=4),e=(e=e<Number.EPSILON?Number.EPSILON:e)>1e4?1e4:e,{In:function(t){return Math.pow(t,e)},Out:function(t){return 1-Math.pow(1-t,e)},InOut:function(t){return t<.5?Math.pow(2*t,e)/2:(1-Math.pow(2-2*t,e))/2+.5}}}}),PA="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var e=process.hrtime();return 1e3*e[0]+e[1]/1e6}:"undefined"!=typeof self&&void 0!==self.performance&&void 0!==self.performance.now?self.performance.now.bind(self.performance):void 0!==Date.now?Date.now:function(){return(new Date).getTime()},LA=function(){function e(){this._tweens={},this._tweensAddedDuringUpdate={}}return e.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map((function(t){return e._tweens[t]}))},e.prototype.removeAll=function(){this._tweens={}},e.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},e.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},e.prototype.update=function(e,t){void 0===e&&(e=PA()),void 0===t&&(t=!1);var n=Object.keys(this._tweens);if(0===n.length)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<n.length;r++){var i=this._tweens[n[r]],a=!t;i&&!1===i.update(e,a)&&!t&&delete this._tweens[n[r]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},e}(),DA={Linear:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),a=DA.Utils.Linear;return t<0?a(e[0],e[1],r):t>1?a(e[n],e[n-1],n-r):a(e[i],e[i+1>n?n:i+1],r-i)},Bezier:function(e,t){for(var n=0,r=e.length-1,i=Math.pow,a=DA.Utils.Bernstein,o=0;o<=r;o++)n+=i(1-t,r-o)*i(t,o)*e[o]*a(r,o);return n},CatmullRom:function(e,t){var n=e.length-1,r=n*t,i=Math.floor(r),a=DA.Utils.CatmullRom;return e[0]===e[n]?(t<0&&(i=Math.floor(r=n*(1+t))),a(e[(i-1+n)%n],e[i],e[(i+1)%n],e[(i+2)%n],r-i)):t<0?e[0]-(a(e[0],e[0],e[1],e[1],-r)-e[0]):t>1?e[n]-(a(e[n],e[n],e[n-1],e[n-1],r-n)-e[n]):a(e[i?i-1:0],e[i],e[n<i+1?n:i+1],e[n<i+2?n:i+2],r-i)},Utils:{Linear:function(e,t,n){return(t-e)*n+e},Bernstein:function(e,t){var n=DA.Utils.Factorial;return n(e)/n(t)/n(e-t)},Factorial:(TA=[1],function(e){var t=1;if(TA[e])return TA[e];for(var n=e;n>1;n--)t*=n;return TA[e]=t,t}),CatmullRom:function(e,t,n,r,i){var a=.5*(n-e),o=.5*(r-t),s=i*i;return(2*t-2*n+a+o)*(i*s)+(-3*t+3*n-2*a-o)*s+a*i+t}}},RA=function(){function e(){}return e.nextId=function(){return e._nextId++},e._nextId=0,e}(),qA=new LA,OA=function(){function e(e,t){void 0===t&&(t=qA),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=CA.Linear.None,this._interpolationFunction=DA.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=RA.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return e.prototype.getId=function(){return this._id},e.prototype.isPlaying=function(){return this._isPlaying},e.prototype.isPaused=function(){return this._isPaused},e.prototype.to=function(e,t){return this._valuesEnd=Object.create(e),void 0!==t&&(this._duration=t),this},e.prototype.duration=function(e){return void 0===e&&(e=1e3),this._duration=e,this},e.prototype.start=function(e,t){if(void 0===e&&(e=PA()),void 0===t&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var n in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t),this},e.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},e.prototype._setupProperties=function(e,t,n,r,i){for(var a in n){var o=e[a],s=Array.isArray(o),A=s?"array":typeof o,l=!s&&Array.isArray(n[a]);if("undefined"!==A&&"function"!==A){if(l){var c=n[a];if(0===c.length)continue;c=c.map(this._handleRelativeValue.bind(this,o)),void 0===t[a]&&(n[a]=[o].concat(c))}if("object"!==A&&!s||!o||l)(void 0===t[a]||i)&&(t[a]=o),s||(t[a]*=1),r[a]=l?n[a].slice().reverse():t[a]||0;else{for(var u in t[a]=s?[]:{},o)t[a][u]=o[u];r[a]=s?[]:{},this._setupProperties(o,t[a],n[a],r[a],i)}}}},e.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},e.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},e.prototype.pause=function(e){return void 0===e&&(e=PA()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this)),this},e.prototype.resume=function(e){return void 0===e&&(e=PA()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},e.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},e.prototype.group=function(e){return void 0===e&&(e=qA),this._group=e,this},e.prototype.delay=function(e){return void 0===e&&(e=0),this._delayTime=e,this},e.prototype.repeat=function(e){return void 0===e&&(e=0),this._initialRepeat=e,this._repeat=e,this},e.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},e.prototype.yoyo=function(e){return void 0===e&&(e=!1),this._yoyo=e,this},e.prototype.easing=function(e){return void 0===e&&(e=CA.Linear.None),this._easingFunction=e,this},e.prototype.interpolation=function(e){return void 0===e&&(e=DA.Linear),this._interpolationFunction=e,this},e.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},e.prototype.onStart=function(e){return this._onStartCallback=e,this},e.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},e.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},e.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},e.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},e.prototype.onStop=function(e){return this._onStopCallback=e,this},e.prototype.update=function(e,t){if(void 0===e&&(e=PA()),void 0===t&&(t=!0),this._isPaused)return!0;var n,r,i=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>i)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),!1===this._onEveryStartCallbackFired&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0),r=(e-this._startTime)/this._duration,r=0===this._duration||r>1?1:r;var a=this._easingFunction(r);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,a),this._onUpdateCallback&&this._onUpdateCallback(this._object,r),1===r){if(this._repeat>0){for(n in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[n]||(this._valuesStartRepeat[n]=this._valuesStartRepeat[n]+parseFloat(this._valuesEnd[n])),this._yoyo&&this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=e+this._repeatDelayTime:this._startTime=e+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var o=0,s=this._chainedTweens.length;o<s;o++)this._chainedTweens[o].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},e.prototype._updateProperties=function(e,t,n,r){for(var i in n)if(void 0!==t[i]){var a=t[i]||0,o=n[i],s=Array.isArray(e[i]),A=Array.isArray(o);!s&&A?e[i]=this._interpolationFunction(o,r):"object"==typeof o&&o?this._updateProperties(e[i],a,o,r):"number"==typeof(o=this._handleRelativeValue(a,o))&&(e[i]=a+(o-a)*r)}},e.prototype._handleRelativeValue=function(e,t){return"string"!=typeof t?t:"+"===t.charAt(0)||"-"===t.charAt(0)?e+parseFloat(t):parseFloat(t)},e.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];this._valuesStartRepeat[e]="string"==typeof n?this._valuesStartRepeat[e]+parseFloat(n):this._valuesEnd[e],this._valuesEnd[e]=t},e}(),IA=RA.nextId,kA=qA,BA=kA.getAll.bind(kA),UA=kA.removeAll.bind(kA),NA=kA.add.bind(kA),zA=kA.remove.bind(kA),FA=kA.update.bind(kA),GA={Easing:CA,Group:LA,Interpolation:DA,now:PA,Sequence:RA,nextId:IA,Tween:OA,VERSION:"19.0.0",getAll:BA,removeAll:UA,add:NA,remove:zA,update:FA},jA={exports:{}};function HA(e,t,n){n=n||2;var r,i,a,o,s,A,l,c=t&&t.length,u=c?t[0]*n:e.length,h=VA(e,0,u,n,!0),f=[];if(!h||h.next===h.prev)return f;if(c&&(h=function(e,t,n,r){var i,a,o,s=[];for(i=0,a=t.length;i<a;i++)(o=VA(e,t[i]*r,i<a-1?t[i+1]*r:e.length,r,!1))===o.next&&(o.steiner=!0),s.push(nl(o));for(s.sort(KA),i=0;i<s.length;i++)n=$A(s[i],n);return n}(e,t,h,n)),e.length>80*n){r=a=e[0],i=o=e[1];for(var d=n;d<u;d+=n)(s=e[d])<r&&(r=s),(A=e[d+1])<i&&(i=A),s>a&&(a=s),A>o&&(o=A);l=0!==(l=Math.max(a-r,o-i))?32767/l:0}return QA(h,f,n,r,i,l,0),f}function VA(e,t,n,r,i){var a,o;if(i===pl(e,t,n,r)>0)for(a=t;a<n;a+=r)o=hl(a,e[a],e[a+1],o);else for(a=n-r;a>=t;a-=r)o=hl(a,e[a],e[a+1],o);return o&&ol(o,o.next)&&(fl(o),o=o.next),o}function WA(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!ol(r,r.next)&&0!==al(r.prev,r,r.next))r=r.next;else{if(fl(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function QA(e,t,n,r,i,a,o){if(e){!o&&a&&function(e,t,n,r){var i=e;do{0===i.z&&(i.z=tl(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,a,o,s,A,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t<l&&(s++,r=r.nextZ);t++);for(A=l;s>0||A>0&&r;)0!==s&&(0===A||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,A--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1)}(i)}(e,r,i,a);for(var s,A,l=e;e.prev!==e.next;)if(s=e.prev,A=e.next,a?YA(e,r,i,a):XA(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(A.i/n|0),fl(e),e=A.next,l=A.next;else if((e=A)===l){o?1===o?QA(e=ZA(WA(e),t,n),t,n,r,i,a,2):2===o&&JA(e,t,n,r,i,a):QA(WA(e),t,n,r,i,a,1);break}}}function XA(e){var t=e.prev,n=e,r=e.next;if(al(t,n,r)>=0)return!1;for(var i=t.x,a=n.x,o=r.x,s=t.y,A=n.y,l=r.y,c=i<a?i<o?i:o:a<o?a:o,u=s<A?s<l?s:l:A<l?A:l,h=i>a?i>o?i:o:a>o?a:o,f=s>A?s>l?s:l:A>l?A:l,d=r.next;d!==t;){if(d.x>=c&&d.x<=h&&d.y>=u&&d.y<=f&&rl(i,s,a,A,o,l,d.x,d.y)&&al(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function YA(e,t,n,r){var i=e.prev,a=e,o=e.next;if(al(i,a,o)>=0)return!1;for(var s=i.x,A=a.x,l=o.x,c=i.y,u=a.y,h=o.y,f=s<A?s<l?s:l:A<l?A:l,d=c<u?c<h?c:h:u<h?u:h,p=s>A?s>l?s:l:A>l?A:l,m=c>u?c>h?c:h:u>h?u:h,g=tl(f,d,t,n,r),v=tl(p,m,t,n,r),y=e.prevZ,b=e.nextZ;y&&y.z>=g&&b&&b.z<=v;){if(y.x>=f&&y.x<=p&&y.y>=d&&y.y<=m&&y!==i&&y!==o&&rl(s,c,A,u,l,h,y.x,y.y)&&al(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,b.x>=f&&b.x<=p&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&rl(s,c,A,u,l,h,b.x,b.y)&&al(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;y&&y.z>=g;){if(y.x>=f&&y.x<=p&&y.y>=d&&y.y<=m&&y!==i&&y!==o&&rl(s,c,A,u,l,h,y.x,y.y)&&al(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;b&&b.z<=v;){if(b.x>=f&&b.x<=p&&b.y>=d&&b.y<=m&&b!==i&&b!==o&&rl(s,c,A,u,l,h,b.x,b.y)&&al(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function ZA(e,t,n){var r=e;do{var i=r.prev,a=r.next.next;!ol(i,a)&&sl(i,r,r.next,a)&&cl(i,a)&&cl(a,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(a.i/n|0),fl(r),fl(r.next),r=e=a),r=r.next}while(r!==e);return WA(r)}function JA(e,t,n,r,i,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&il(o,s)){var A=ul(o,s);return o=WA(o,o.next),A=WA(A,A.next),QA(o,t,n,r,i,a,0),void QA(A,t,n,r,i,a,0)}s=s.next}o=o.next}while(o!==e)}function KA(e,t){return e.x-t.x}function $A(e,t){var n=function(e,t){var n,r=t,i=e.x,a=e.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>o&&(o=s,n=r.x<r.next.x?r:r.next,s===i))return n}r=r.next}while(r!==t);if(!n)return null;var A,l=n,c=n.x,u=n.y,h=1/0;r=n;do{i>=r.x&&r.x>=c&&i!==r.x&&rl(a<u?i:o,a,c,u,a<u?o:i,a,r.x,r.y)&&(A=Math.abs(a-r.y)/(i-r.x),cl(r,e)&&(A<h||A===h&&(r.x>n.x||r.x===n.x&&el(n,r)))&&(n=r,h=A)),r=r.next}while(r!==l);return n}(e,t);if(!n)return t;var r=ul(n,e);return WA(r,r.next),WA(n,n.next)}function el(e,t){return al(e.prev,e,t.prev)<0&&al(t.next,e,e.next)<0}function tl(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function nl(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function rl(e,t,n,r,i,a,o,s){return(i-o)*(t-s)>=(e-o)*(a-s)&&(e-o)*(r-s)>=(n-o)*(t-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function il(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&sl(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(cl(e,t)&&cl(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(al(e.prev,e,t.prev)||al(e,t.prev,t))||ol(e,t)&&al(e.prev,e,e.next)>0&&al(t.prev,t,t.next)>0)}function al(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function ol(e,t){return e.x===t.x&&e.y===t.y}function sl(e,t,n,r){var i=ll(al(e,t,n)),a=ll(al(e,t,r)),o=ll(al(n,r,e)),s=ll(al(n,r,t));return i!==a&&o!==s||(!(0!==i||!Al(e,n,t))||(!(0!==a||!Al(e,r,t))||(!(0!==o||!Al(n,e,r))||!(0!==s||!Al(n,t,r)))))}function Al(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function ll(e){return e>0?1:e<0?-1:0}function cl(e,t){return al(e.prev,e,e.next)<0?al(e,t,e.next)>=0&&al(e,e.prev,t)>=0:al(e,t,e.prev)<0||al(e,e.next,t)<0}function ul(e,t){var n=new dl(e.i,e.x,e.y),r=new dl(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function hl(e,t,n,r){var i=new dl(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function fl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function dl(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function pl(e,t,n,r){for(var i=0,a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}jA.exports=HA,jA.exports.default=HA,HA.deviation=function(e,t,n,r){var i=t&&t.length,a=i?t[0]*n:e.length,o=Math.abs(pl(e,0,a,n));if(i)for(var s=0,A=t.length;s<A;s++){var l=t[s]*n,c=s<A-1?t[s+1]*n:e.length;o-=Math.abs(pl(e,l,c,n))}var u=0;for(s=0;s<r.length;s+=3){var h=r[s]*n,f=r[s+1]*n,d=r[s+2]*n;u+=Math.abs((e[h]-e[d])*(e[f+1]-e[h+1])-(e[h]-e[f])*(e[d+1]-e[h+1]))}return 0===o&&0===u?0:Math.abs((u-o)/o)},HA.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,i=0;i<e.length;i++){for(var a=0;a<e[i].length;a++)for(var o=0;o<t;o++)n.vertices.push(e[i][a][o]);i>0&&(r+=e[i-1].length,n.holes.push(r))}return n};var ml=o(jA.exports);function gl(e,t){return null==e||null==t?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function vl(e,t){return null==e||null==t?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function yl(e){let t,n,r;function i(e,r,i=0,a=e.length){if(i<a){if(0!==t(r,r))return a;do{const t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}return 2!==e.length?(t=gl,n=(t,n)=>gl(e(t),n),r=(t,n)=>e(t)-n):(t=e===gl||e===vl?e:bl,n=e,r=e),{left:i,center:function(e,t,n=0,a=e.length){const o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o},right:function(e,r,i=0,a=e.length){if(i<a){if(0!==t(r,r))return a;do{const t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}}}function bl(){return 0}const xl=yl(gl).right;yl((function(e){return null===e?NaN:+e})).center;var _l=xl;function wl(e,t){let n,r;if(void 0===t)for(const t of e)null!=t&&(void 0===n?t>=t&&(n=r=t):(n>t&&(n=t),r<t&&(r=t)));else{let i=-1;for(let a of e)null!=(a=t(a,++i,e))&&(void 0===n?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)))}return[n,r]}class Ml{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){const t=this._partials;let n=0;for(let r=0;r<this._n&&r<32;r++){const i=t[r],a=e+i,o=Math.abs(e)<Math.abs(i)?e-(a-i):i-(a-e);o&&(t[n++]=o),e=a}return t[n]=e,this._n=n+1,this}valueOf(){const e=this._partials;let t,n,r,i=this._n,a=0;if(i>0){for(a=e[--i];i>0&&(t=a,n=e[--i],a=t+n,r=n-(a-t),!r););i>0&&(r<0&&e[i-1]<0||r>0&&e[i-1]>0)&&(n=2*r,t=a+n,n==t-a&&(a=t))}return a}}const Sl=Math.sqrt(50),El=Math.sqrt(10),Tl=Math.sqrt(2);function Cl(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=Sl?10:a>=El?5:a>=Tl?2:1;let s,A,l;return i<0?(l=Math.pow(10,-i)/o,s=Math.round(e*l),A=Math.round(t*l),s/l<e&&++s,A/l>t&&--A,l=-l):(l=Math.pow(10,i)*o,s=Math.round(e/l),A=Math.round(t/l),s*l<e&&++s,A*l>t&&--A),A<s&&.5<=n&&n<2?Cl(e,t,2*n):[s,A,l]}function Pl(e,t,n){return Cl(e=+e,t=+t,n=+n)[2]}function Ll(e){return Array.from(function*(e){for(const t of e)yield*t}(e))}function Dl(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((t-e)/n)),a=new Array(i);++r<i;)a[r]=e+r*n;return a}var Rl=1e-6,ql=1e-12,Ol=Math.PI,Il=Ol/2,kl=Ol/4,Bl=2*Ol,Ul=180/Ol,Nl=Ol/180,zl=Math.abs,Fl=Math.atan,Gl=Math.atan2,jl=Math.cos,Hl=Math.ceil,Vl=Math.hypot,Wl=Math.sin,Ql=Math.sign||function(e){return e>0?1:e<0?-1:0},Xl=Math.sqrt;function Yl(e){return e>1?Il:e<-1?-Il:Math.asin(e)}function Zl(e){return(e=Wl(e/2))*e}function Jl(){}function Kl(e,t){e&&ec.hasOwnProperty(e.type)&&ec[e.type](e,t)}var $l={Feature:function(e,t){Kl(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r<i;)Kl(n[r].geometry,t)}},ec={Sphere:function(e,t){t.sphere()},Point:function(e,t){e=e.coordinates,t.point(e[0],e[1],e[2])},MultiPoint:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)e=n[r],t.point(e[0],e[1],e[2])},LineString:function(e,t){tc(e.coordinates,t,0)},MultiLineString:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)tc(n[r],t,0)},Polygon:function(e,t){nc(e.coordinates,t)},MultiPolygon:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)nc(n[r],t)},GeometryCollection:function(e,t){for(var n=e.geometries,r=-1,i=n.length;++r<i;)Kl(n[r],t)}};function tc(e,t,n){var r,i=-1,a=e.length-n;for(t.lineStart();++i<a;)r=e[i],t.point(r[0],r[1],r[2]);t.lineEnd()}function nc(e,t){var n=-1,r=e.length;for(t.polygonStart();++n<r;)tc(e[n],t,1);t.polygonEnd()}function rc(e,t){e&&$l.hasOwnProperty(e.type)?$l[e.type](e,t):Kl(e,t)}var ic,ac,oc,sc,Ac,lc,cc,uc,hc,fc,dc,pc,mc,gc,vc,yc,bc=new Ml,xc=new Ml,_c={point:Jl,lineStart:Jl,lineEnd:Jl,polygonStart:function(){bc=new Ml,_c.lineStart=wc,_c.lineEnd=Mc},polygonEnd:function(){var e=+bc;xc.add(e<0?Bl+e:e),this.lineStart=this.lineEnd=this.point=Jl},sphere:function(){xc.add(Bl)}};function wc(){_c.point=Sc}function Mc(){Ec(ic,ac)}function Sc(e,t){_c.point=Ec,ic=e,ac=t,oc=e*=Nl,sc=jl(t=(t*=Nl)/2+kl),Ac=Wl(t)}function Ec(e,t){var n=(e*=Nl)-oc,r=n>=0?1:-1,i=r*n,a=jl(t=(t*=Nl)/2+kl),o=Wl(t),s=Ac*o,A=sc*a+s*jl(i),l=s*r*Wl(i);bc.add(Gl(l,A)),oc=e,sc=a,Ac=o}function Tc(e){return[Gl(e[1],e[0]),Yl(e[2])]}function Cc(e){var t=e[0],n=e[1],r=jl(n);return[r*jl(t),r*Wl(t),Wl(n)]}function Pc(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Lc(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function Dc(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function Rc(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function qc(e){var t=Xl(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var Oc,Ic,kc,Bc,Uc,Nc,zc,Fc,Gc,jc,Hc,Vc,Wc,Qc,Xc,Yc,Zc={point:Jc,lineStart:$c,lineEnd:eu,polygonStart:function(){Zc.point=tu,Zc.lineStart=nu,Zc.lineEnd=ru,gc=new Ml,_c.polygonStart()},polygonEnd:function(){_c.polygonEnd(),Zc.point=Jc,Zc.lineStart=$c,Zc.lineEnd=eu,bc<0?(lc=-(uc=180),cc=-(hc=90)):gc>Rl?hc=90:gc<-Rl&&(cc=-90),yc[0]=lc,yc[1]=uc},sphere:function(){lc=-(uc=180),cc=-(hc=90)}};function Jc(e,t){vc.push(yc=[lc=e,uc=e]),t<cc&&(cc=t),t>hc&&(hc=t)}function Kc(e,t){var n=Cc([e*Nl,t*Nl]);if(mc){var r=Lc(mc,n),i=Lc([r[1],-r[0],0],r);qc(i),i=Tc(i);var a,o=e-fc,s=o>0?1:-1,A=i[0]*Ul*s,l=zl(o)>180;l^(s*fc<A&&A<s*e)?(a=i[1]*Ul)>hc&&(hc=a):l^(s*fc<(A=(A+360)%360-180)&&A<s*e)?(a=-i[1]*Ul)<cc&&(cc=a):(t<cc&&(cc=t),t>hc&&(hc=t)),l?e<fc?iu(lc,e)>iu(lc,uc)&&(uc=e):iu(e,uc)>iu(lc,uc)&&(lc=e):uc>=lc?(e<lc&&(lc=e),e>uc&&(uc=e)):e>fc?iu(lc,e)>iu(lc,uc)&&(uc=e):iu(e,uc)>iu(lc,uc)&&(lc=e)}else vc.push(yc=[lc=e,uc=e]);t<cc&&(cc=t),t>hc&&(hc=t),mc=n,fc=e}function $c(){Zc.point=Kc}function eu(){yc[0]=lc,yc[1]=uc,Zc.point=Jc,mc=null}function tu(e,t){if(mc){var n=e-fc;gc.add(zl(n)>180?n+(n>0?360:-360):n)}else dc=e,pc=t;_c.point(e,t),Kc(e,t)}function nu(){_c.lineStart()}function ru(){tu(dc,pc),_c.lineEnd(),zl(gc)>Rl&&(lc=-(uc=180)),yc[0]=lc,yc[1]=uc,mc=null}function iu(e,t){return(t-=e)<0?t+360:t}function au(e,t){return e[0]-t[0]}function ou(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:t<e[0]||e[1]<t}function su(e){var t,n,r,i,a,o,s;if(hc=uc=-(lc=cc=1/0),vc=[],rc(e,Zc),n=vc.length){for(vc.sort(au),t=1,a=[r=vc[0]];t<n;++t)ou(r,(i=vc[t])[0])||ou(r,i[1])?(iu(r[0],i[1])>iu(r[0],r[1])&&(r[1]=i[1]),iu(i[0],r[1])>iu(r[0],r[1])&&(r[0]=i[0])):a.push(r=i);for(o=-1/0,t=0,r=a[n=a.length-1];t<=n;r=i,++t)i=a[t],(s=iu(r[1],i[0]))>o&&(o=s,lc=i[0],uc=r[1])}return vc=yc=null,lc===1/0||cc===1/0?[[NaN,NaN],[NaN,NaN]]:[[lc,cc],[uc,hc]]}var Au={sphere:Jl,point:lu,lineStart:uu,lineEnd:du,polygonStart:function(){Au.lineStart=pu,Au.lineEnd=mu},polygonEnd:function(){Au.lineStart=uu,Au.lineEnd=du}};function lu(e,t){e*=Nl;var n=jl(t*=Nl);cu(n*jl(e),n*Wl(e),Wl(t))}function cu(e,t,n){++Oc,kc+=(e-kc)/Oc,Bc+=(t-Bc)/Oc,Uc+=(n-Uc)/Oc}function uu(){Au.point=hu}function hu(e,t){e*=Nl;var n=jl(t*=Nl);Qc=n*jl(e),Xc=n*Wl(e),Yc=Wl(t),Au.point=fu,cu(Qc,Xc,Yc)}function fu(e,t){e*=Nl;var n=jl(t*=Nl),r=n*jl(e),i=n*Wl(e),a=Wl(t),o=Gl(Xl((o=Xc*a-Yc*i)*o+(o=Yc*r-Qc*a)*o+(o=Qc*i-Xc*r)*o),Qc*r+Xc*i+Yc*a);Ic+=o,Nc+=o*(Qc+(Qc=r)),zc+=o*(Xc+(Xc=i)),Fc+=o*(Yc+(Yc=a)),cu(Qc,Xc,Yc)}function du(){Au.point=lu}function pu(){Au.point=gu}function mu(){vu(Vc,Wc),Au.point=lu}function gu(e,t){Vc=e,Wc=t,e*=Nl,t*=Nl,Au.point=vu;var n=jl(t);Qc=n*jl(e),Xc=n*Wl(e),Yc=Wl(t),cu(Qc,Xc,Yc)}function vu(e,t){e*=Nl;var n=jl(t*=Nl),r=n*jl(e),i=n*Wl(e),a=Wl(t),o=Xc*a-Yc*i,s=Yc*r-Qc*a,A=Qc*i-Xc*r,l=Vl(o,s,A),c=Yl(l),u=l&&-c/l;Gc.add(u*o),jc.add(u*s),Hc.add(u*A),Ic+=c,Nc+=c*(Qc+(Qc=r)),zc+=c*(Xc+(Xc=i)),Fc+=c*(Yc+(Yc=a)),cu(Qc,Xc,Yc)}function yu(e){Oc=Ic=kc=Bc=Uc=Nc=zc=Fc=0,Gc=new Ml,jc=new Ml,Hc=new Ml,rc(e,Au);var t=+Gc,n=+jc,r=+Hc,i=Vl(t,n,r);return i<ql&&(t=Nc,n=zc,r=Fc,Ic<Rl&&(t=kc,n=Bc,r=Uc),(i=Vl(t,n,r))<ql)?[NaN,NaN]:[Gl(n,t)*Ul,Yl(r/i)*Ul]}function bu(e,t){function n(n,r){return n=e(n,r),t(n[0],n[1])}return e.invert&&t.invert&&(n.invert=function(n,r){return(n=t.invert(n,r))&&e.invert(n[0],n[1])}),n}function xu(e,t){return zl(e)>Ol&&(e-=Math.round(e/Bl)*Bl),[e,t]}function _u(e,t,n){return(e%=Bl)?t||n?bu(Mu(e),Su(t,n)):Mu(e):t||n?Su(t,n):xu}function wu(e){return function(t,n){return zl(t+=e)>Ol&&(t-=Math.round(t/Bl)*Bl),[t,n]}}function Mu(e){var t=wu(e);return t.invert=wu(-e),t}function Su(e,t){var n=jl(e),r=Wl(e),i=jl(t),a=Wl(t);function o(e,t){var o=jl(t),s=jl(e)*o,A=Wl(e)*o,l=Wl(t),c=l*n+s*r;return[Gl(A*i-c*a,s*n-l*r),Yl(c*i+A*a)]}return o.invert=function(e,t){var o=jl(t),s=jl(e)*o,A=Wl(e)*o,l=Wl(t),c=l*i-A*a;return[Gl(A*i+l*a,s*n+c*r),Yl(c*n-s*r)]},o}function Eu(e,t){(t=Cc(t))[0]-=e,qc(t);var n,r=(n=-t[1])>1?0:n<-1?Ol:Math.acos(n);return((-t[2]<0?-r:r)+Bl-Rl)%Bl}function Tu(){var e,t=[];return{point:function(t,n,r){e.push([t,n,r])},lineStart:function(){t.push(e=[])},lineEnd:Jl,rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))},result:function(){var n=t;return t=[],e=null,n}}}function Cu(e,t){return zl(e[0]-t[0])<Rl&&zl(e[1]-t[1])<Rl}function Pu(e,t,n,r){this.x=e,this.z=t,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function Lu(e,t,n,r,i){var a,o,s=[],A=[];if(e.forEach((function(e){if(!((t=e.length-1)<=0)){var t,n,r=e[0],o=e[t];if(Cu(r,o)){if(!r[2]&&!o[2]){for(i.lineStart(),a=0;a<t;++a)i.point((r=e[a])[0],r[1]);return void i.lineEnd()}o[0]+=2*Rl}s.push(n=new Pu(r,e,null,!0)),A.push(n.o=new Pu(r,null,n,!1)),s.push(n=new Pu(o,e,null,!1)),A.push(n.o=new Pu(o,null,n,!0))}})),s.length){for(A.sort(t),Du(s),Du(A),a=0,o=A.length;a<o;++a)A[a].e=n=!n;for(var l,c,u=s[0];;){for(var h=u,f=!0;h.v;)if((h=h.n)===u)return;l=h.z,i.lineStart();do{if(h.v=h.o.v=!0,h.e){if(f)for(a=0,o=l.length;a<o;++a)i.point((c=l[a])[0],c[1]);else r(h.x,h.n.x,1,i);h=h.n}else{if(f)for(l=h.p.z,a=l.length-1;a>=0;--a)i.point((c=l[a])[0],c[1]);else r(h.x,h.p.x,-1,i);h=h.p}l=(h=h.o).z,f=!f}while(!h.v);i.lineEnd()}}}function Du(e){if(t=e.length){for(var t,n,r=0,i=e[0];++r<t;)i.n=n=e[r],n.p=i,i=n;i.n=n=e[0],n.p=i}}function Ru(e){return zl(e[0])<=Ol?e[0]:Ql(e[0])*((zl(e[0])+Ol)%Bl-Ol)}function qu(e,t){var n=Ru(t),r=t[1],i=Wl(r),a=[Wl(n),-jl(n),0],o=0,s=0,A=new Ml;1===i?r=Il+Rl:-1===i&&(r=-Il-Rl);for(var l=0,c=e.length;l<c;++l)if(h=(u=e[l]).length)for(var u,h,f=u[h-1],d=Ru(f),p=f[1]/2+kl,m=Wl(p),g=jl(p),v=0;v<h;++v,d=b,m=_,g=w,f=y){var y=u[v],b=Ru(y),x=y[1]/2+kl,_=Wl(x),w=jl(x),M=b-d,S=M>=0?1:-1,E=S*M,T=E>Ol,C=m*_;if(A.add(Gl(C*S*Wl(E),g*w+C*jl(E))),o+=T?M+S*Bl:M,T^d>=n^b>=n){var P=Lc(Cc(f),Cc(y));qc(P);var L=Lc(a,P);qc(L);var D=(T^M>=0?-1:1)*Yl(L[2]);(r>D||r===D&&(P[0]||P[1]))&&(s+=T^M>=0?1:-1)}}return(o<-Rl||o<Rl&&A<-ql)^1&s}function Ou(e,t,n,r){return function(i){var a,o,s,A=t(i),l=Tu(),c=t(l),u=!1,h={point:f,lineStart:p,lineEnd:m,polygonStart:function(){h.point=g,h.lineStart=v,h.lineEnd=y,o=[],a=[]},polygonEnd:function(){h.point=f,h.lineStart=p,h.lineEnd=m,o=Ll(o);var e=qu(a,r);o.length?(u||(i.polygonStart(),u=!0),Lu(o,ku,e,n,i)):e&&(u||(i.polygonStart(),u=!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),u&&(i.polygonEnd(),u=!1),o=a=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function f(t,n){e(t,n)&&i.point(t,n)}function d(e,t){A.point(e,t)}function p(){h.point=d,A.lineStart()}function m(){h.point=f,A.lineEnd()}function g(e,t){s.push([e,t]),c.point(e,t)}function v(){c.lineStart(),s=[]}function y(){g(s[0][0],s[0][1]),c.lineEnd();var e,t,n,r,A=c.clean(),h=l.result(),f=h.length;if(s.pop(),a.push(s),s=null,f)if(1&A){if((t=(n=h[0]).length-1)>0){for(u||(i.polygonStart(),u=!0),i.lineStart(),e=0;e<t;++e)i.point((r=n[e])[0],r[1]);i.lineEnd()}}else f>1&&2&A&&h.push(h.pop().concat(h.shift())),o.push(h.filter(Iu))}return h}}function Iu(e){return e.length>1}function ku(e,t){return((e=e.x)[0]<0?e[1]-Il-Rl:Il-e[1])-((t=t.x)[0]<0?t[1]-Il-Rl:Il-t[1])}xu.invert=xu;var Bu=Ou((function(){return!0}),(function(e){var t,n=NaN,r=NaN,i=NaN;return{lineStart:function(){e.lineStart(),t=1},point:function(a,o){var s=a>0?Ol:-Ol,A=zl(a-n);zl(A-Ol)<Rl?(e.point(n,r=(r+o)/2>0?Il:-Il),e.point(i,r),e.lineEnd(),e.lineStart(),e.point(s,r),e.point(a,r),t=0):i!==s&&A>=Ol&&(zl(n-i)<Rl&&(n-=i*Rl),zl(a-s)<Rl&&(a-=s*Rl),r=function(e,t,n,r){var i,a,o=Wl(e-n);return zl(o)>Rl?Fl((Wl(t)*(a=jl(r))*Wl(n)-Wl(r)*(i=jl(t))*Wl(e))/(i*a*o)):(t+r)/2}(n,r,a,o),e.point(i,r),e.lineEnd(),e.lineStart(),e.point(s,r),t=0),e.point(n=a,r=o),i=s},lineEnd:function(){e.lineEnd(),n=r=NaN},clean:function(){return 2-t}}}),(function(e,t,n,r){var i;if(null==e)i=n*Il,r.point(-Ol,i),r.point(0,i),r.point(Ol,i),r.point(Ol,0),r.point(Ol,-i),r.point(0,-i),r.point(-Ol,-i),r.point(-Ol,0),r.point(-Ol,i);else if(zl(e[0]-t[0])>Rl){var a=e[0]<t[0]?Ol:-Ol;i=n*a/2,r.point(-a,i),r.point(0,i),r.point(a,i)}else r.point(t[0],t[1])}),[-Ol,-Il]);function Uu(e){var t=jl(e),n=6*Nl,r=t>0,i=zl(t)>Rl;function a(e,n){return jl(e)*jl(n)>t}function o(e,n,r){var i=[1,0,0],a=Lc(Cc(e),Cc(n)),o=Pc(a,a),s=a[0],A=o-s*s;if(!A)return!r&&e;var l=t*o/A,c=-t*s/A,u=Lc(i,a),h=Rc(i,l);Dc(h,Rc(a,c));var f=u,d=Pc(h,f),p=Pc(f,f),m=d*d-p*(Pc(h,h)-1);if(!(m<0)){var g=Xl(m),v=Rc(f,(-d-g)/p);if(Dc(v,h),v=Tc(v),!r)return v;var y,b=e[0],x=n[0],_=e[1],w=n[1];x<b&&(y=b,b=x,x=y);var M=x-b,S=zl(M-Ol)<Rl;if(!S&&w<_&&(y=_,_=w,w=y),S||M<Rl?S?_+w>0^v[1]<(zl(v[0]-b)<Rl?_:w):_<=v[1]&&v[1]<=w:M>Ol^(b<=v[0]&&v[0]<=x)){var E=Rc(f,(-d+g)/p);return Dc(E,h),[v,Tc(E)]}}}function s(t,n){var i=r?e:Ol-e,a=0;return t<-i?a|=1:t>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}return Ou(a,(function(e){var t,n,A,l,c;return{lineStart:function(){l=A=!1,c=1},point:function(u,h){var f,d=[u,h],p=a(u,h),m=r?p?0:s(u,h):p?s(u+(u<0?Ol:-Ol),h):0;if(!t&&(l=A=p)&&e.lineStart(),p!==A&&(!(f=o(t,d))||Cu(t,f)||Cu(d,f))&&(d[2]=1),p!==A)c=0,p?(e.lineStart(),f=o(d,t),e.point(f[0],f[1])):(f=o(t,d),e.point(f[0],f[1],2),e.lineEnd()),t=f;else if(i&&t&&r^p){var g;m&n||!(g=o(d,t,!0))||(c=0,r?(e.lineStart(),e.point(g[0][0],g[0][1]),e.point(g[1][0],g[1][1]),e.lineEnd()):(e.point(g[1][0],g[1][1]),e.lineEnd(),e.lineStart(),e.point(g[0][0],g[0][1],3)))}!p||t&&Cu(t,d)||e.point(d[0],d[1]),t=d,A=p,n=m},lineEnd:function(){A&&e.lineEnd(),t=null},clean:function(){return c|(l&&A)<<1}}}),(function(t,r,i,a){!function(e,t,n,r,i,a){if(n){var o=jl(t),s=Wl(t),A=r*n;null==i?(i=t+r*Bl,a=t-A/2):(i=Eu(o,i),a=Eu(o,a),(r>0?i<a:i>a)&&(i+=r*Bl));for(var l,c=i;r>0?c>a:c<a;c-=A)l=Tc([o,-s*jl(c),-s*Wl(c)]),e.point(l[0],l[1])}}(a,e,n,i,t,r)}),r?[0,-e]:[-Ol,e-Ol])}var Nu,zu,Fu,Gu,ju=1e9,Hu=-ju;function Vu(e,t,n,r){function i(i,a){return e<=i&&i<=n&&t<=a&&a<=r}function a(i,a,s,l){var c=0,u=0;if(null==i||(c=o(i,s))!==(u=o(a,s))||A(i,a)<0^s>0)do{l.point(0===c||3===c?e:n,c>1?r:t)}while((c=(c+s+4)%4)!==u);else l.point(a[0],a[1])}function o(r,i){return zl(r[0]-e)<Rl?i>0?0:3:zl(r[0]-n)<Rl?i>0?2:1:zl(r[1]-t)<Rl?i>0?1:0:i>0?3:2}function s(e,t){return A(e.x,t.x)}function A(e,t){var n=o(e,1),r=o(t,1);return n!==r?n-r:0===n?t[1]-e[1]:1===n?e[0]-t[0]:2===n?e[1]-t[1]:t[0]-e[0]}return function(o){var A,l,c,u,h,f,d,p,m,g,v,y=o,b=Tu(),x={point:_,lineStart:function(){x.point=w,l&&l.push(c=[]);g=!0,m=!1,d=p=NaN},lineEnd:function(){A&&(w(u,h),f&&m&&b.rejoin(),A.push(b.result()));x.point=_,m&&y.lineEnd()},polygonStart:function(){y=b,A=[],l=[],v=!0},polygonEnd:function(){var t=function(){for(var t=0,n=0,i=l.length;n<i;++n)for(var a,o,s=l[n],A=1,c=s.length,u=s[0],h=u[0],f=u[1];A<c;++A)a=h,o=f,h=(u=s[A])[0],f=u[1],o<=r?f>r&&(h-a)*(r-o)>(f-o)*(e-a)&&++t:f<=r&&(h-a)*(r-o)<(f-o)*(e-a)&&--t;return t}(),n=v&&t,i=(A=Ll(A)).length;(n||i)&&(o.polygonStart(),n&&(o.lineStart(),a(null,null,1,o),o.lineEnd()),i&&Lu(A,s,t,a,o),o.polygonEnd());y=o,A=l=c=null}};function _(e,t){i(e,t)&&y.point(e,t)}function w(a,o){var s=i(a,o);if(l&&c.push([a,o]),g)u=a,h=o,f=s,g=!1,s&&(y.lineStart(),y.point(a,o));else if(s&&m)y.point(a,o);else{var A=[d=Math.max(Hu,Math.min(ju,d)),p=Math.max(Hu,Math.min(ju,p))],b=[a=Math.max(Hu,Math.min(ju,a)),o=Math.max(Hu,Math.min(ju,o))];!function(e,t,n,r,i,a){var o,s=e[0],A=e[1],l=0,c=1,u=t[0]-s,h=t[1]-A;if(o=n-s,u||!(o>0)){if(o/=u,u<0){if(o<l)return;o<c&&(c=o)}else if(u>0){if(o>c)return;o>l&&(l=o)}if(o=i-s,u||!(o<0)){if(o/=u,u<0){if(o>c)return;o>l&&(l=o)}else if(u>0){if(o<l)return;o<c&&(c=o)}if(o=r-A,h||!(o>0)){if(o/=h,h<0){if(o<l)return;o<c&&(c=o)}else if(h>0){if(o>c)return;o>l&&(l=o)}if(o=a-A,h||!(o<0)){if(o/=h,h<0){if(o>c)return;o>l&&(l=o)}else if(h>0){if(o<l)return;o<c&&(c=o)}return l>0&&(e[0]=s+l*u,e[1]=A+l*h),c<1&&(t[0]=s+c*u,t[1]=A+c*h),!0}}}}}(A,b,e,t,n,r)?s&&(y.lineStart(),y.point(a,o),v=!1):(m||(y.lineStart(),y.point(A[0],A[1])),y.point(b[0],b[1]),s||y.lineEnd(),v=!1)}d=a,p=o,m=s}return x}}var Wu={sphere:Jl,point:Jl,lineStart:function(){Wu.point=Xu,Wu.lineEnd=Qu},lineEnd:Jl,polygonStart:Jl,polygonEnd:Jl};function Qu(){Wu.point=Wu.lineEnd=Jl}function Xu(e,t){zu=e*=Nl,Fu=Wl(t*=Nl),Gu=jl(t),Wu.point=Yu}function Yu(e,t){e*=Nl;var n=Wl(t*=Nl),r=jl(t),i=zl(e-zu),a=jl(i),o=r*Wl(i),s=Gu*n-Fu*r*a,A=Fu*n+Gu*r*a;Nu.add(Gl(Xl(o*o+s*s),A)),zu=e,Fu=n,Gu=r}var Zu=[null,null],Ju={type:"LineString",coordinates:Zu};function Ku(e,t){return Zu[0]=e,Zu[1]=t,function(e){return Nu=new Ml,rc(e,Wu),+Nu}(Ju)}var $u={Feature:function(e,t){return th(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r<i;)if(th(n[r].geometry,t))return!0;return!1}},eh={Sphere:function(){return!0},Point:function(e,t){return nh(e.coordinates,t)},MultiPoint:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)if(nh(n[r],t))return!0;return!1},LineString:function(e,t){return rh(e.coordinates,t)},MultiLineString:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)if(rh(n[r],t))return!0;return!1},Polygon:function(e,t){return ih(e.coordinates,t)},MultiPolygon:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)if(ih(n[r],t))return!0;return!1},GeometryCollection:function(e,t){for(var n=e.geometries,r=-1,i=n.length;++r<i;)if(th(n[r],t))return!0;return!1}};function th(e,t){return!(!e||!eh.hasOwnProperty(e.type))&&eh[e.type](e,t)}function nh(e,t){return 0===Ku(e,t)}function rh(e,t){for(var n,r,i,a=0,o=e.length;a<o;a++){if(0===(r=Ku(e[a],t)))return!0;if(a>0&&(i=Ku(e[a],e[a-1]))>0&&n<=i&&r<=i&&(n+r-i)*(1-Math.pow((n-r)/i,2))<ql*i)return!0;n=r}return!1}function ih(e,t){return!!qu(e.map(ah),oh(t))}function ah(e){return(e=e.map(oh)).pop(),e}function oh(e){return[e[0]*Nl,e[1]*Nl]}function sh(e,t,n){var r=Dl(e,t-Rl,n).concat(t);return function(e){return r.map((function(t){return[e,t]}))}}function Ah(e,t,n){var r=Dl(e,t-Rl,n).concat(t);return function(e){return r.map((function(t){return[t,e]}))}}function lh(){return function(){var e,t,n,r,i,a,o,s,A,l,c,u,h=10,f=h,d=90,p=360,m=2.5;function g(){return{type:"MultiLineString",coordinates:v()}}function v(){return Dl(Hl(r/d)*d,n,d).map(c).concat(Dl(Hl(s/p)*p,o,p).map(u)).concat(Dl(Hl(t/h)*h,e,h).filter((function(e){return zl(e%d)>Rl})).map(A)).concat(Dl(Hl(a/f)*f,i,f).filter((function(e){return zl(e%p)>Rl})).map(l))}return g.lines=function(){return v().map((function(e){return{type:"LineString",coordinates:e}}))},g.outline=function(){return{type:"Polygon",coordinates:[c(r).concat(u(o).slice(1),c(n).reverse().slice(1),u(s).reverse().slice(1))]}},g.extent=function(e){return arguments.length?g.extentMajor(e).extentMinor(e):g.extentMinor()},g.extentMajor=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],s=+e[0][1],o=+e[1][1],r>n&&(e=r,r=n,n=e),s>o&&(e=s,s=o,o=e),g.precision(m)):[[r,s],[n,o]]},g.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],a=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),a>i&&(n=a,a=i,i=n),g.precision(m)):[[t,a],[e,i]]},g.step=function(e){return arguments.length?g.stepMajor(e).stepMinor(e):g.stepMinor()},g.stepMajor=function(e){return arguments.length?(d=+e[0],p=+e[1],g):[d,p]},g.stepMinor=function(e){return arguments.length?(h=+e[0],f=+e[1],g):[h,f]},g.precision=function(h){return arguments.length?(m=+h,A=sh(a,i,90),l=Ah(t,e,m),c=sh(s,o,90),u=Ah(r,n,m),g):m},g.extentMajor([[-180,-90+Rl],[180,90-Rl]]).extentMinor([[-180,-80-Rl],[180,80+Rl]])}()()}function ch(e,t){var n=e[0]*Nl,r=e[1]*Nl,i=t[0]*Nl,a=t[1]*Nl,o=jl(r),s=Wl(r),A=jl(a),l=Wl(a),c=o*jl(n),u=o*Wl(n),h=A*jl(i),f=A*Wl(i),d=2*Yl(Xl(Zl(a-r)+o*A*Zl(i-n))),p=Wl(d),m=d?function(e){var t=Wl(e*=d)/p,n=Wl(d-e)/p,r=n*c+t*h,i=n*u+t*f,a=n*s+t*l;return[Gl(i,r)*Ul,Gl(a,Xl(r*r+i*i))*Ul]}:function(){return[n*Ul,r*Ul]};return m.distance=d,m}var uh=e=>e,hh=1/0,fh=hh,dh=-hh,ph=dh;var mh={point:function(e,t){e<hh&&(hh=e);e>dh&&(dh=e);t<fh&&(fh=t);t>ph&&(ph=t)},lineStart:Jl,lineEnd:Jl,polygonStart:Jl,polygonEnd:Jl,result:function(){var e=[[hh,fh],[dh,ph]];return dh=ph=-(fh=hh=1/0),e}};function gh(e){return function(t){var n=new vh;for(var r in e)n[r]=e[r];return n.stream=t,n}}function vh(){}function yh(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),null!=r&&e.clipExtent(null),rc(n,e.stream(mh)),t(mh.result()),null!=r&&e.clipExtent(r),e}function bh(e,t,n){return yh(e,(function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+t[0][0]+(r-a*(n[1][0]+n[0][0]))/2,s=+t[0][1]+(i-a*(n[1][1]+n[0][1]))/2;e.scale(150*a).translate([o,s])}),n)}vh.prototype={constructor:vh,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var xh=16,_h=jl(30*Nl);function wh(e,t){return+t?function(e,t){function n(r,i,a,o,s,A,l,c,u,h,f,d,p,m){var g=l-r,v=c-i,y=g*g+v*v;if(y>4*t&&p--){var b=o+h,x=s+f,_=A+d,w=Xl(b*b+x*x+_*_),M=Yl(_/=w),S=zl(zl(_)-1)<Rl||zl(a-u)<Rl?(a+u)/2:Gl(x,b),E=e(S,M),T=E[0],C=E[1],P=T-r,L=C-i,D=v*P-g*L;(D*D/y>t||zl((g*P+v*L)/y-.5)>.3||o*h+s*f+A*d<_h)&&(n(r,i,a,o,s,A,T,C,S,b/=w,x/=w,_,p,m),m.point(T,C),n(T,C,S,b,x,_,l,c,u,h,f,d,p,m))}}return function(t){var r,i,a,o,s,A,l,c,u,h,f,d,p={point:m,lineStart:g,lineEnd:y,polygonStart:function(){t.polygonStart(),p.lineStart=b},polygonEnd:function(){t.polygonEnd(),p.lineStart=g}};function m(n,r){n=e(n,r),t.point(n[0],n[1])}function g(){c=NaN,p.point=v,t.lineStart()}function v(r,i){var a=Cc([r,i]),o=e(r,i);n(c,u,l,h,f,d,c=o[0],u=o[1],l=r,h=a[0],f=a[1],d=a[2],xh,t),t.point(c,u)}function y(){p.point=m,t.lineEnd()}function b(){g(),p.point=x,p.lineEnd=_}function x(e,t){v(r=e,t),i=c,a=u,o=h,s=f,A=d,p.point=v}function _(){n(c,u,l,h,f,d,i,a,r,o,s,A,xh,t),p.lineEnd=y,y()}return p}}(e,t):function(e){return gh({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}(e)}var Mh=gh({point:function(e,t){this.stream.point(e*Nl,t*Nl)}});function Sh(e,t,n,r,i,a){if(!a)return function(e,t,n,r,i){function a(a,o){return[t+e*(a*=r),n-e*(o*=i)]}return a.invert=function(a,o){return[(a-t)/e*r,(n-o)/e*i]},a}(e,t,n,r,i);var o=jl(a),s=Wl(a),A=o*e,l=s*e,c=o/e,u=s/e,h=(s*n-o*t)/e,f=(s*t+o*n)/e;function d(e,a){return[A*(e*=r)-l*(a*=i)+t,n-l*e-A*a]}return d.invert=function(e,t){return[r*(c*e-u*t+h),i*(f-u*e-c*t)]},d}function Eh(e){return function(e){var t,n,r,i,a,o,s,A,l,c,u=150,h=480,f=250,d=0,p=0,m=0,g=0,v=0,y=0,b=1,x=1,_=null,w=Bu,M=null,S=uh,E=.5;function T(e){return A(e[0]*Nl,e[1]*Nl)}function C(e){return(e=A.invert(e[0],e[1]))&&[e[0]*Ul,e[1]*Ul]}function P(){var e=Sh(u,0,0,b,x,y).apply(null,t(d,p)),r=Sh(u,h-e[0],f-e[1],b,x,y);return n=_u(m,g,v),s=bu(t,r),A=bu(n,s),o=wh(s,E),L()}function L(){return l=c=null,T}return T.stream=function(e){return l&&c===e?l:l=Mh(function(e){return gh({point:function(t,n){var r=e(t,n);return this.stream.point(r[0],r[1])}})}(n)(w(o(S(c=e)))))},T.preclip=function(e){return arguments.length?(w=e,_=void 0,L()):w},T.postclip=function(e){return arguments.length?(S=e,M=r=i=a=null,L()):S},T.clipAngle=function(e){return arguments.length?(w=+e?Uu(_=e*Nl):(_=null,Bu),L()):_*Ul},T.clipExtent=function(e){return arguments.length?(S=null==e?(M=r=i=a=null,uh):Vu(M=+e[0][0],r=+e[0][1],i=+e[1][0],a=+e[1][1]),L()):null==M?null:[[M,r],[i,a]]},T.scale=function(e){return arguments.length?(u=+e,P()):u},T.translate=function(e){return arguments.length?(h=+e[0],f=+e[1],P()):[h,f]},T.center=function(e){return arguments.length?(d=e[0]%360*Nl,p=e[1]%360*Nl,P()):[d*Ul,p*Ul]},T.rotate=function(e){return arguments.length?(m=e[0]%360*Nl,g=e[1]%360*Nl,v=e.length>2?e[2]%360*Nl:0,P()):[m*Ul,g*Ul,v*Ul]},T.angle=function(e){return arguments.length?(y=e%360*Nl,P()):y*Ul},T.reflectX=function(e){return arguments.length?(b=e?-1:1,P()):b<0},T.reflectY=function(e){return arguments.length?(x=e?-1:1,P()):x<0},T.precision=function(e){return arguments.length?(o=wh(s,E=e*e),L()):Xl(E)},T.fitExtent=function(e,t){return bh(T,e,t)},T.fitSize=function(e,t){return function(e,t,n){return bh(e,[[0,0],t],n)}(T,e,t)},T.fitWidth=function(e,t){return function(e,t,n){return yh(e,(function(n){var r=+t,i=r/(n[1][0]-n[0][0]),a=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];e.scale(150*i).translate([a,o])}),n)}(T,e,t)},T.fitHeight=function(e,t){return function(e,t,n){return yh(e,(function(n){var r=+t,i=r/(n[1][1]-n[0][1]),a=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([a,o])}),n)}(T,e,t)},function(){return t=e.apply(this,arguments),T.invert=t.invert&&C,P()}}((function(){return e}))()}function Th(e,t){var n=jl(t),r=1+jl(e)*n;return[n*Wl(e)/r,Wl(t)/r]}function Ch(){return Eh(Th).scale(250).clipAngle(142)}function Ph(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,(i=r.key,a=void 0,"symbol"==typeof(a=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(i,"string"))?a:String(a)),r)}var i,a}function Lh(e){return Lh=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Lh(e)}function Dh(e,t){return Dh=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Dh(e,t)}function Rh(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function qh(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=Lh(e);if(t){var i=Lh(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Rh(this,n)}}function Oh(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,a,o,s=[],A=!0,l=!1;try{if(a=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;A=!1}else for(;!(A=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);A=!0);}catch(e){l=!0,i=e}finally{try{if(!A&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}(e,t)||Ih(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ih(e,t){if(e){if("string"==typeof e)return kh(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?kh(e,t):void 0}}function kh(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}Th.invert=function(e){return function(t,n){var r=Xl(t*t+n*n),i=e(r),a=Wl(i),o=jl(i);return[Gl(t*a,r*o),Yl(r&&n*a/r)]}}((function(e){return 2*Fl(e)}));var Bh=function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=[],n=null;return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((function(r){if(n){var i=180*Ku(r,n)/Math.PI;if(i>e)for(var a=ch(n,r),o=1/Math.ceil(i/e),s=o;s<1;)t.push(a(s)),s+=o}t.push(n=r)})),t},Uh="undefined"!=typeof window&&window.THREE?window.THREE:{BufferGeometry:Bn,Float32BufferAttribute:Pn},Nh=(new Uh.BufferGeometry).setAttribute?"setAttribute":"addAttribute",zh=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Dh(e,t)}(a,e);var t,n,r,i=qh(a);function a(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=i.call(this)).type="GeoJsonGeometry",t.parameters={geoJson:e,radius:n,resolution:r};var o=({Point:c,MultiPoint:function(e,t){var n={vertices:[],indices:[]};return e.map((function(e){return c(e,t)})).forEach((function(e){var t=Oh(e,1)[0];Fh(n,t)})),[n]},LineString:u,MultiLineString:function(e,t){var n={vertices:[],indices:[]};return e.map((function(e){return u(e,t)})).forEach((function(e){var t=Oh(e,1)[0];Fh(n,t)})),[n]},Polygon:h,MultiPolygon:function(e,t){var n={vertices:[],indices:[]},r={vertices:[],indices:[]};e.map((function(e){return h(e,t)})).forEach((function(e){var t=Oh(e,2),i=t[0],a=t[1];Fh(n,i),a&&Fh(r,a)}));var i=[n];return r.vertices.length&&i.push(r),i}}[e.type]||function(){return[]})(e.coordinates,n),s=[],A=[],l=0;function c(e,t){return[{vertices:jh(e[1],e[0],t),indices:[]}]}function u(e,t){for(var n=Bh(e,r).map((function(e){var n=Oh(e,2),r=n[0];return jh(n[1],r,t)})),i=ml.flatten([n]).vertices,a=Math.round(i.length/3),o=[],s=1;s<a;s++)o.push(s-1,s);return[{vertices:i,indices:o}]}function h(e,t){for(var n=e.map((function(e){return Bh(e,r).map((function(e){var n=Oh(e,2),r=n[0];return jh(n[1],r,t)}))})),i=ml.flatten(n),a=i.vertices,o=i.holes,s=o[0]||1/0,A=a.slice(0,3*s),l=a.slice(3*s),c=new Set(o),u=Math.round(a.length/3),h=[],f=[],d=1;d<u;d++)c.has(d)||(d<s?h.push(d-1,d):f.push(d-1-s,d-s));var p=[{indices:h,vertices:A}];return o.length&&p.push({indices:f,vertices:l}),p}return o.forEach((function(e){var n=s.length;Fh({indices:s,vertices:A},e),t.addGroup(n,s.length-n,l++)})),s.length&&t.setIndex(s),A.length&&t[Nh]("position",new Uh.Float32BufferAttribute(A,3)),t}return t=a,n&&Ph(t.prototype,n),r&&Ph(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(Uh.BufferGeometry);function Fh(e,t){var n=Math.round(e.vertices.length/3);Gh(e.vertices,t.vertices),Gh(e.indices,t.indices.map((function(e){return e+n})))}function Gh(e,t){var n,r=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=Ih(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}(t);try{for(r.s();!(n=r.n()).done;){var i=n.value;e.push(i)}}catch(e){r.e(e)}finally{r.f()}}function jh(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180;return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}function Hh(e,t=!1){const n=null!==e[0].index,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,A=new Bn;let l=0;for(let c=0;c<e.length;++c){const u=e[c];let h=0;if(n!==(null!==u.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in u.attributes){if(!r.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===a[e]&&(a[e]=[]),a[e].push(u.attributes[e]),h++}if(h!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(s!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in u.morphAttributes){if(!i.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;void 0===o[e]&&(o[e]=[]),o[e].push(u.morphAttributes[e])}if(t){let e;if(n)e=u.index.count;else{if(void 0===u.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;e=u.attributes.position.count}A.addGroup(l,e,c),l+=e}}if(n){let t=0;const n=[];for(let r=0;r<e.length;++r){const i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}A.setIndex(n)}for(const e in a){const t=Vh(a[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" attribute."),null;A.setAttribute(e,t)}for(const e in o){const t=o[e][0].length;if(0===t)break;A.morphAttributes=A.morphAttributes||{},A.morphAttributes[e]=[];for(let n=0;n<t;++n){const t=[];for(let r=0;r<o[e].length;++r)t.push(o[e][r][n]);const r=Vh(t);if(!r)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" morphAttribute."),null;A.morphAttributes[e].push(r)}}return A}function Vh(e){let t,n,r,i=0;for(let a=0;a<e.length;++a){const o=e[a];if(o.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(void 0===t&&(t=o.array.constructor),t!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=o.itemSize),n!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===r&&(r=o.normalized),r!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=o.array.length}const a=new t(i);let o=0;for(let t=0;t<e.length;++t)a.set(e[t].array,o),o+=e[t].array.length;return new En(a,n,r)}function Wh(e){const t=e.data.array.constructor,n=e.count,r=e.itemSize,i=e.normalized,a=new t(n*r);let o;o=e.isInstancedInterleavedBufferAttribute?new oo(a,r,i,e.meshPerAttribute):new En(a,r,i);for(let t=0;t<n;t++)o.setX(t,e.getX(t)),r>=2&&o.setY(t,e.getY(t)),r>=3&&o.setZ(t,e.getZ(t)),r>=4&&o.setW(t,e.getW(t));return o}var Qh=Object.freeze({__proto__:null,computeMikkTSpaceTangents:function(e,t,n=!0){if(!t||!t.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!e.hasAttribute("position")||!e.hasAttribute("normal")||!e.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function r(e){if(e.normalized||e.isInterleavedBufferAttribute){const t=new Float32Array(e.getCount()*e.itemSize);for(let n=0,r=0;n<e.getCount();n++)t[r++]=e.getX(n),t[r++]=e.getY(n),e.itemSize>2&&(t[r++]=e.getZ(n));return t}return e.array instanceof Float32Array?e.array:new Float32Array(e.array)}const i=e.index?e.toNonIndexed():e,a=t.generateTangents(r(i.attributes.position),r(i.attributes.normal),r(i.attributes.uv));if(n)for(let e=3;e<a.length;e+=4)a[e]*=-1;return i.setAttribute("tangent",new En(a,4)),e!==i&&e.copy(i),e},computeMorphedAttributes:function(e){const t=new et,n=new et,r=new et,i=new et,a=new et,o=new et,s=new et,A=new et,l=new et;function c(e,c,u,h,f,d,p,m){t.fromBufferAttribute(c,f),n.fromBufferAttribute(c,d),r.fromBufferAttribute(c,p);const g=e.morphTargetInfluences;if(u&&g){s.set(0,0,0),A.set(0,0,0),l.set(0,0,0);for(let e=0,c=u.length;e<c;e++){const c=g[e],m=u[e];0!==c&&(i.fromBufferAttribute(m,f),a.fromBufferAttribute(m,d),o.fromBufferAttribute(m,p),h?(s.addScaledVector(i,c),A.addScaledVector(a,c),l.addScaledVector(o,c)):(s.addScaledVector(i.sub(t),c),A.addScaledVector(a.sub(n),c),l.addScaledVector(o.sub(r),c)))}t.add(s),n.add(A),r.add(l)}e.isSkinnedMesh&&(e.applyBoneTransform(f,t),e.applyBoneTransform(d,n),e.applyBoneTransform(p,r)),m[3*f+0]=t.x,m[3*f+1]=t.y,m[3*f+2]=t.z,m[3*d+0]=n.x,m[3*d+1]=n.y,m[3*d+2]=n.z,m[3*p+0]=r.x,m[3*p+1]=r.y,m[3*p+2]=r.z}const u=e.geometry,h=e.material;let f,d,p;const m=u.index,g=u.attributes.position,v=u.morphAttributes.position,y=u.morphTargetsRelative,b=u.attributes.normal,x=u.morphAttributes.position,_=u.groups,w=u.drawRange;let M,S,E,T,C,P,L;const D=new Float32Array(g.count*g.itemSize),R=new Float32Array(b.count*b.itemSize);if(null!==m)if(Array.isArray(h))for(M=0,E=_.length;M<E;M++)for(C=_[M],P=Math.max(C.start,w.start),L=Math.min(C.start+C.count,w.start+w.count),S=P,T=L;S<T;S+=3)f=m.getX(S),d=m.getX(S+1),p=m.getX(S+2),c(e,g,v,y,f,d,p,D),c(e,b,x,y,f,d,p,R);else for(P=Math.max(0,w.start),L=Math.min(m.count,w.start+w.count),M=P,E=L;M<E;M+=3)f=m.getX(M),d=m.getX(M+1),p=m.getX(M+2),c(e,g,v,y,f,d,p,D),c(e,b,x,y,f,d,p,R);else if(Array.isArray(h))for(M=0,E=_.length;M<E;M++)for(C=_[M],P=Math.max(C.start,w.start),L=Math.min(C.start+C.count,w.start+w.count),S=P,T=L;S<T;S+=3)f=S,d=S+1,p=S+2,c(e,g,v,y,f,d,p,D),c(e,b,x,y,f,d,p,R);else for(P=Math.max(0,w.start),L=Math.min(g.count,w.start+w.count),M=P,E=L;M<E;M+=3)f=M,d=M+1,p=M+2,c(e,g,v,y,f,d,p,D),c(e,b,x,y,f,d,p,R);return{positionAttribute:g,normalAttribute:b,morphedPositionAttribute:new Pn(D,3),morphedNormalAttribute:new Pn(R,3)}},deepCloneAttribute:function(e){return e.isInstancedInterleavedBufferAttribute||e.isInterleavedBufferAttribute?Wh(e):e.isInstancedBufferAttribute?(new oo).copy(e):(new En).copy(e)},deinterleaveAttribute:Wh,deinterleaveGeometry:function(e){const t=e.attributes,n=e.morphTargets,r=new Map;for(const e in t){const n=t[e];n.isInterleavedBufferAttribute&&(r.has(n)||r.set(n,Wh(n)),t[e]=r.get(n))}for(const e in n){const t=n[e];t.isInterleavedBufferAttribute&&(r.has(t)||r.set(t,Wh(t)),n[e]=r.get(t))}},estimateBytesUsed:function(e){let t=0;for(const n in e.attributes){const r=e.getAttribute(n);t+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}const n=e.getIndex();return t+=n?n.count*n.itemSize*n.array.BYTES_PER_ELEMENT:0,t},interleaveAttributes:function(e){let t,n=0,r=0;for(let i=0,a=e.length;i<a;++i){const a=e[i];if(void 0===t&&(t=a.array.constructor),t!==a.array.constructor)return console.error("AttributeBuffers of different types cannot be interleaved"),null;n+=a.array.length,r+=a.itemSize}const i=new ro(new t(n),r);let a=0;const o=[],s=["getX","getY","getZ","getW"],A=["setX","setY","setZ","setW"];for(let t=0,n=e.length;t<n;t++){const n=e[t],r=n.itemSize,l=n.count,c=new ao(i,r,a,n.normalized);o.push(c),a+=r;for(let e=0;e<l;e++)for(let t=0;t<r;t++)c[A[t]](e,n[s[t]](e))}return o},mergeAttributes:Vh,mergeBufferAttributes:function(e){return console.warn("THREE.BufferGeometryUtils: mergeBufferAttributes() has been renamed to mergeAttributes()."),Vh(e)},mergeBufferGeometries:function(e,t=!1){return console.warn("THREE.BufferGeometryUtils: mergeBufferGeometries() has been renamed to mergeGeometries()."),Hh(e,t)},mergeGeometries:Hh,mergeGroups:function(e){if(0===e.groups.length)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),e;let t=e.groups;if(t=t.sort(((e,t)=>e.materialIndex!==t.materialIndex?e.materialIndex-t.materialIndex:e.start-t.start)),null===e.getIndex()){const t=e.getAttribute("position"),n=[];for(let e=0;e<t.count;e+=3)n.push(e,e+1,e+2);e.setIndex(n)}const n=e.getIndex(),r=[];for(let e=0;e<t.length;e++){const i=t[e],a=i.start,o=a+i.count;for(let e=a;e<o;e++)r.push(n.getX(e))}e.dispose(),e.setIndex(r);let i=0;for(let e=0;e<t.length;e++){const n=t[e];n.start=i,i+=n.count}let a=t[0];e.groups=[a];for(let n=1;n<t.length;n++){const r=t[n];a.materialIndex===r.materialIndex?a.count+=r.count:(a=r,e.groups.push(a))}return e},mergeVertices:function(e,t=1e-4){t=Math.max(t,Number.EPSILON);const n={},r=e.getIndex(),i=e.getAttribute("position"),a=r?r.count:i.count;let o=0;const s=Object.keys(e.attributes),A={},l={},c=[],u=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let t=0,n=s.length;t<n;t++){const n=s[t],r=e.attributes[n];A[n]=new En(new r.array.constructor(r.count*r.itemSize),r.itemSize,r.normalized);const i=e.morphAttributes[n];i&&(l[n]=new En(new i.array.constructor(i.count*i.itemSize),i.itemSize,i.normalized))}const f=Math.log10(1/t),d=Math.pow(10,f);for(let t=0;t<a;t++){const i=r?r.getX(t):t;let a="";for(let t=0,n=s.length;t<n;t++){const n=s[t],r=e.getAttribute(n),o=r.itemSize;for(let e=0;e<o;e++)a+=~~(r[u[e]](i)*d)+","}if(a in n)c.push(n[a]);else{for(let t=0,n=s.length;t<n;t++){const n=s[t],r=e.getAttribute(n),a=e.morphAttributes[n],c=r.itemSize,f=A[n],d=l[n];for(let e=0;e<c;e++){const t=u[e],n=h[e];if(f[n](o,r[t](i)),a)for(let e=0,r=a.length;e<r;e++)d[e][n](o,a[e][t](i))}}n[a]=o,c.push(o),o++}}const p=e.clone();for(const t in e.attributes){const e=A[t];if(p.setAttribute(t,new En(e.array.slice(0,o*e.itemSize),e.itemSize,e.normalized)),t in l)for(let e=0;e<l[t].length;e++){const n=l[t][e];p.morphAttributes[t][e]=new En(n.array.slice(0,o*n.itemSize),n.itemSize,n.normalized)}}return p.setIndex(c),p},toCreasedNormals:function(e,t=Math.PI/3){const n=Math.cos(t),r=100*(1+1e-10),i=[new et,new et,new et],a=new et,o=new et,s=new et,A=new et;function l(e){return`${~~(e.x*r)},${~~(e.y*r)},${~~(e.z*r)}`}const c=e.toNonIndexed(),u=c.attributes.position,h={};for(let e=0,t=u.count/3;e<t;e++){const t=3*e,n=i[0].fromBufferAttribute(u,t+0),r=i[1].fromBufferAttribute(u,t+1),s=i[2].fromBufferAttribute(u,t+2);a.subVectors(s,r),o.subVectors(n,r);const A=(new et).crossVectors(a,o).normalize();for(let e=0;e<3;e++){const t=l(i[e]);t in h||(h[t]=[]),h[t].push(A)}}const f=new Float32Array(3*u.count),d=new En(f,3,!1);for(let e=0,t=u.count/3;e<t;e++){const t=3*e,r=i[0].fromBufferAttribute(u,t+0),c=i[1].fromBufferAttribute(u,t+1),f=i[2].fromBufferAttribute(u,t+2);a.subVectors(f,c),o.subVectors(r,c),s.crossVectors(a,o).normalize();for(let e=0;e<3;e++){const r=h[l(i[e])];A.set(0,0,0);for(let e=0,t=r.length;e<t;e++){const t=r[e];s.dot(t)>n&&A.add(t)}A.normalize(),d.setXYZ(t+e,A.x,A.y,A.z)}}return c.setAttribute("normal",d),c},toTrianglesDrawMode:function(e,t){if(0===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,i=[];if(2===t)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=e.clone();return a.setIndex(i),a.clearGroups(),a}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}}),Xh=function(e){return e instanceof Function?e:"string"==typeof e?function(t){return t[e]}:function(t){return e}};function Yh(e){return Yh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Yh(e)}var Zh=/^\s+/,Jh=/\s+$/;function Kh(e,t){if(t=t||{},(e=e||"")instanceof Kh)return e;if(!(this instanceof Kh))return new Kh(e,t);var n=function(e){var t={r:0,g:0,b:0},n=1,r=null,i=null,a=null,o=!1,s=!1;"string"==typeof e&&(e=function(e){e=e.replace(Zh,"").replace(Jh,"").toLowerCase();var t,n=!1;if(mf[e])e=mf[e],n=!0;else if("transparent"==e)return{r:0,g:0,b:0,a:0,format:"name"};if(t=Pf.rgb.exec(e))return{r:t[1],g:t[2],b:t[3]};if(t=Pf.rgba.exec(e))return{r:t[1],g:t[2],b:t[3],a:t[4]};if(t=Pf.hsl.exec(e))return{h:t[1],s:t[2],l:t[3]};if(t=Pf.hsla.exec(e))return{h:t[1],s:t[2],l:t[3],a:t[4]};if(t=Pf.hsv.exec(e))return{h:t[1],s:t[2],v:t[3]};if(t=Pf.hsva.exec(e))return{h:t[1],s:t[2],v:t[3],a:t[4]};if(t=Pf.hex8.exec(e))return{r:xf(t[1]),g:xf(t[2]),b:xf(t[3]),a:Sf(t[4]),format:n?"name":"hex8"};if(t=Pf.hex6.exec(e))return{r:xf(t[1]),g:xf(t[2]),b:xf(t[3]),format:n?"name":"hex"};if(t=Pf.hex4.exec(e))return{r:xf(t[1]+""+t[1]),g:xf(t[2]+""+t[2]),b:xf(t[3]+""+t[3]),a:Sf(t[4]+""+t[4]),format:n?"name":"hex8"};if(t=Pf.hex3.exec(e))return{r:xf(t[1]+""+t[1]),g:xf(t[2]+""+t[2]),b:xf(t[3]+""+t[3]),format:n?"name":"hex"};return!1}(e));"object"==Yh(e)&&(Lf(e.r)&&Lf(e.g)&&Lf(e.b)?(A=e.r,l=e.g,c=e.b,t={r:255*yf(A,255),g:255*yf(l,255),b:255*yf(c,255)},o=!0,s="%"===String(e.r).substr(-1)?"prgb":"rgb"):Lf(e.h)&&Lf(e.s)&&Lf(e.v)?(r=wf(e.s),i=wf(e.v),t=function(e,t,n){e=6*yf(e,360),t=yf(t,100),n=yf(n,100);var r=Math.floor(e),i=e-r,a=n*(1-t),o=n*(1-i*t),s=n*(1-(1-i)*t),A=r%6,l=[n,o,a,a,s,n][A],c=[s,n,n,o,a,a][A],u=[a,a,s,n,n,o][A];return{r:255*l,g:255*c,b:255*u}}(e.h,r,i),o=!0,s="hsv"):Lf(e.h)&&Lf(e.s)&&Lf(e.l)&&(r=wf(e.s),a=wf(e.l),t=function(e,t,n){var r,i,a;function o(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e}if(e=yf(e,360),t=yf(t,100),n=yf(n,100),0===t)r=i=a=n;else{var s=n<.5?n*(1+t):n+t-n*t,A=2*n-s;r=o(A,s,e+1/3),i=o(A,s,e),a=o(A,s,e-1/3)}return{r:255*r,g:255*i,b:255*a}}(e.h,r,a),o=!0,s="hsl"),e.hasOwnProperty("a")&&(n=e.a));var A,l,c;return n=vf(n),{ok:o,format:e.format||s,r:Math.min(255,Math.max(t.r,0)),g:Math.min(255,Math.max(t.g,0)),b:Math.min(255,Math.max(t.b,0)),a:n}}(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=Math.round(100*this._a)/100,this._format=t.format||n.format,this._gradientType=t.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=n.ok}function $h(e,t,n){e=yf(e,255),t=yf(t,255),n=yf(n,255);var r,i,a=Math.max(e,t,n),o=Math.min(e,t,n),s=(a+o)/2;if(a==o)r=i=0;else{var A=a-o;switch(i=s>.5?A/(2-a-o):A/(a+o),a){case e:r=(t-n)/A+(t<n?6:0);break;case t:r=(n-e)/A+2;break;case n:r=(e-t)/A+4}r/=6}return{h:r,s:i,l:s}}function ef(e,t,n){e=yf(e,255),t=yf(t,255),n=yf(n,255);var r,i,a=Math.max(e,t,n),o=Math.min(e,t,n),s=a,A=a-o;if(i=0===a?0:A/a,a==o)r=0;else{switch(a){case e:r=(t-n)/A+(t<n?6:0);break;case t:r=(n-e)/A+2;break;case n:r=(e-t)/A+4}r/=6}return{h:r,s:i,v:s}}function tf(e,t,n,r){var i=[_f(Math.round(e).toString(16)),_f(Math.round(t).toString(16)),_f(Math.round(n).toString(16))];return r&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function nf(e,t,n,r){return[_f(Mf(r)),_f(Math.round(e).toString(16)),_f(Math.round(t).toString(16)),_f(Math.round(n).toString(16))].join("")}function rf(e,t){t=0===t?0:t||10;var n=Kh(e).toHsl();return n.s-=t/100,n.s=bf(n.s),Kh(n)}function af(e,t){t=0===t?0:t||10;var n=Kh(e).toHsl();return n.s+=t/100,n.s=bf(n.s),Kh(n)}function of(e){return Kh(e).desaturate(100)}function sf(e,t){t=0===t?0:t||10;var n=Kh(e).toHsl();return n.l+=t/100,n.l=bf(n.l),Kh(n)}function Af(e,t){t=0===t?0:t||10;var n=Kh(e).toRgb();return n.r=Math.max(0,Math.min(255,n.r-Math.round(-t/100*255))),n.g=Math.max(0,Math.min(255,n.g-Math.round(-t/100*255))),n.b=Math.max(0,Math.min(255,n.b-Math.round(-t/100*255))),Kh(n)}function lf(e,t){t=0===t?0:t||10;var n=Kh(e).toHsl();return n.l-=t/100,n.l=bf(n.l),Kh(n)}function cf(e,t){var n=Kh(e).toHsl(),r=(n.h+t)%360;return n.h=r<0?360+r:r,Kh(n)}function uf(e){var t=Kh(e).toHsl();return t.h=(t.h+180)%360,Kh(t)}function hf(e,t){if(isNaN(t)||t<=0)throw new Error("Argument to polyad must be a positive number");for(var n=Kh(e).toHsl(),r=[Kh(e)],i=360/t,a=1;a<t;a++)r.push(Kh({h:(n.h+a*i)%360,s:n.s,l:n.l}));return r}function ff(e){var t=Kh(e).toHsl(),n=t.h;return[Kh(e),Kh({h:(n+72)%360,s:t.s,l:t.l}),Kh({h:(n+216)%360,s:t.s,l:t.l})]}function df(e,t,n){t=t||6,n=n||30;var r=Kh(e).toHsl(),i=360/n,a=[Kh(e)];for(r.h=(r.h-(i*t>>1)+720)%360;--t;)r.h=(r.h+i)%360,a.push(Kh(r));return a}function pf(e,t){t=t||6;for(var n=Kh(e).toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/t;t--;)o.push(Kh({h:r,s:i,v:a})),a=(a+s)%1;return o}Kh.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(299*e.r+587*e.g+114*e.b)/1e3},getLuminance:function(){var e,t,n,r=this.toRgb();return e=r.r/255,t=r.g/255,n=r.b/255,.2126*(e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4))+.7152*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.0722*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))},setAlpha:function(e){return this._a=vf(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=ef(this._r,this._g,this._b);return{h:360*e.h,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=ef(this._r,this._g,this._b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.v);return 1==this._a?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=$h(this._r,this._g,this._b);return{h:360*e.h,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=$h(this._r,this._g,this._b),t=Math.round(360*e.h),n=Math.round(100*e.s),r=Math.round(100*e.l);return 1==this._a?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return tf(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return function(e,t,n,r,i){var a=[_f(Math.round(e).toString(16)),_f(Math.round(t).toString(16)),_f(Math.round(n).toString(16)),_f(Mf(r))];if(i&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1))return a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0);return a.join("")}(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(100*yf(this._r,255))+"%",g:Math.round(100*yf(this._g,255))+"%",b:Math.round(100*yf(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+Math.round(100*yf(this._r,255))+"%, "+Math.round(100*yf(this._g,255))+"%, "+Math.round(100*yf(this._b,255))+"%)":"rgba("+Math.round(100*yf(this._r,255))+"%, "+Math.round(100*yf(this._g,255))+"%, "+Math.round(100*yf(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(gf[tf(this._r,this._g,this._b,!0)]||!1)},toFilter:function(e){var t="#"+nf(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var i=Kh(e);n="#"+nf(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0;return t||!r||"hex"!==e&&"hex6"!==e&&"hex3"!==e&&"hex4"!==e&&"hex8"!==e&&"name"!==e?("rgb"===e&&(n=this.toRgbString()),"prgb"===e&&(n=this.toPercentageRgbString()),"hex"!==e&&"hex6"!==e||(n=this.toHexString()),"hex3"===e&&(n=this.toHexString(!0)),"hex4"===e&&(n=this.toHex8String(!0)),"hex8"===e&&(n=this.toHex8String()),"name"===e&&(n=this.toName()),"hsl"===e&&(n=this.toHslString()),"hsv"===e&&(n=this.toHsvString()),n||this.toHexString()):"name"===e&&0===this._a?this.toName():this.toRgbString()},clone:function(){return Kh(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(sf,arguments)},brighten:function(){return this._applyModification(Af,arguments)},darken:function(){return this._applyModification(lf,arguments)},desaturate:function(){return this._applyModification(rf,arguments)},saturate:function(){return this._applyModification(af,arguments)},greyscale:function(){return this._applyModification(of,arguments)},spin:function(){return this._applyModification(cf,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(df,arguments)},complement:function(){return this._applyCombination(uf,arguments)},monochromatic:function(){return this._applyCombination(pf,arguments)},splitcomplement:function(){return this._applyCombination(ff,arguments)},triad:function(){return this._applyCombination(hf,[3])},tetrad:function(){return this._applyCombination(hf,[4])}},Kh.fromRatio=function(e,t){if("object"==Yh(e)){var n={};for(var r in e)e.hasOwnProperty(r)&&(n[r]="a"===r?e[r]:wf(e[r]));e=n}return Kh(e,t)},Kh.equals=function(e,t){return!(!e||!t)&&Kh(e).toRgbString()==Kh(t).toRgbString()},Kh.random=function(){return Kh.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})},Kh.mix=function(e,t,n){n=0===n?0:n||50;var r=Kh(e).toRgb(),i=Kh(t).toRgb(),a=n/100;return Kh({r:(i.r-r.r)*a+r.r,g:(i.g-r.g)*a+r.g,b:(i.b-r.b)*a+r.b,a:(i.a-r.a)*a+r.a})},
|
|
3
3
|
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
|
|
4
4
|
// Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
|