react-globe.gl 2.22.6 → 2.22.8
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.22.
|
|
1
|
+
// Version 2.22.8 react-globe.gl - https://github.com/vasturiano/react-globe.gl
|
|
2
2
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).Globe=e(t.React)}(this,(function(t){"use strict";function e(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=t&&("undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"]);if(null==n)return;var r,i,a=[],o=!0,s=!1;try{for(n=n.call(t);!(o=(r=n.next()).done)&&(a.push(r.value),!e||a.length!==e);o=!0);}catch(t){s=!0,i=t}finally{try{o||null==n.return||n.return()}finally{if(s)throw i}}return a}(t,e)||r(t,e)||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 n(t){return function(t){if(Array.isArray(t))return i(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||r(t)||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 r(t,e){if(t){if("string"==typeof t)return i(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var a=function(t,r){var i=new Set(r);return Object.assign.apply(Object,[{}].concat(n(Object.entries(t).filter((function(t){var n=e(t,1)[0];return!i.has(n)})).map((function(t){var n=e(t,2);return function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}({},n[0],n[1])})))))};"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var s=function(t){return[...t].reduce(((t,[e,n])=>(t[e]=n,t)),{})};function A(t){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},A(t)}function l(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var r,i,a=[],o=!0,s=!1;try{for(n=n.call(t);!(o=(r=n.next()).done)&&(a.push(r.value),!e||a.length!==e);o=!0);}catch(t){s=!0,i=t}finally{try{o||null==n.return||n.return()}finally{if(s)throw i}}return a}(t,e)||c(t,e)||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 u(t){return function(t){if(Array.isArray(t))return h(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||c(t)||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 c(t,e){if(t){if("string"==typeof t)return h(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(t,e):void 0}}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function f(e,n){var r=t.useRef();t.useEffect((function(){clearTimeout(r.current);var t=e();if(t)return function(){return r.current=setTimeout(t)}}),n)}const d="146",p={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},m=0,g=1,v=2,x=3,y=100,b=301,_=302,w=306,M=1e3,S=1001,E=1002,T=1003,C=1006,P=1008,D=1009,L=1014,q=1015,R=1016,O=1020,I=1023,k=1026,B=1027,N=33776,z=33777,U=33778,F=33779,G=3e3,j=3001,H="srgb",V="srgb-linear",W=7680,Q=35044,X="300 es",Y=1035;class Z{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[t]&&(n[t]=[]),-1===n[t].indexOf(e)&&n[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(void 0!==n){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);for(let e=0,r=n.length;e<r;e++)n[e].call(this,t);t.target=null}}}const J=["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 K=1234567;const $=Math.PI/180,tt=180/Math.PI;function et(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return(J[255&t]+J[t>>8&255]+J[t>>16&255]+J[t>>24&255]+"-"+J[255&e]+J[e>>8&255]+"-"+J[e>>16&15|64]+J[e>>24&255]+"-"+J[63&n|128]+J[n>>8&255]+"-"+J[n>>16&255]+J[n>>24&255]+J[255&r]+J[r>>8&255]+J[r>>16&255]+J[r>>24&255]).toLowerCase()}function nt(t,e,n){return Math.max(e,Math.min(n,t))}function rt(t,e){return(t%e+e)%e}function it(t,e,n){return(1-n)*t+n*e}function at(t){return 0==(t&t-1)&&0!==t}function ot(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function st(t,e){switch(e.constructor){case Float32Array:return t;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}function At(t,e){switch(e.constructor){case Float32Array:return t;case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}}var lt=Object.freeze({__proto__:null,DEG2RAD:$,RAD2DEG:tt,generateUUID:et,clamp:nt,euclideanModulo:rt,mapLinear:function(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)},inverseLerp:function(t,e,n){return t!==e?(n-t)/(e-t):0},lerp:it,damp:function(t,e,n,r){return it(t,e,1-Math.exp(-n*r))},pingpong:function(t,e=1){return e-Math.abs(rt(t,2*e)-e)},smoothstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*(3-2*t)},smootherstep:function(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(K=t);let e=K+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function(t){return t*$},radToDeg:function(t){return t*tt},isPowerOfTwo:at,ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:ot,setQuaternionFromProperEuler:function(t,e,n,r,i){const a=Math.cos,o=Math.sin,s=a(n/2),A=o(n/2),l=a((e+r)/2),u=o((e+r)/2),c=a((e-r)/2),h=o((e-r)/2),f=a((r-e)/2),d=o((r-e)/2);switch(i){case"XYX":t.set(s*u,A*c,A*h,s*l);break;case"YZY":t.set(A*h,s*u,A*c,s*l);break;case"ZXZ":t.set(A*c,A*h,s*u,s*l);break;case"XZX":t.set(s*u,A*d,A*f,s*l);break;case"YXY":t.set(A*f,s*u,A*d,s*l);break;case"ZYZ":t.set(A*d,A*f,s*u,s*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}},normalize:At,denormalize:st});class ut{constructor(t=0,e=0){ut.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),r=Math.sin(e),i=this.x-t.x,a=this.y-t.y;return this.x=i*n-a*r+t.x,this.y=i*r+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ct{constructor(){ct.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}set(t,e,n,r,i,a,o,s,A){const l=this.elements;return l[0]=t,l[1]=r,l[2]=o,l[3]=e,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(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,a=n[0],o=n[3],s=n[6],A=n[1],l=n[4],u=n[7],c=n[2],h=n[5],f=n[8],d=r[0],p=r[3],m=r[6],g=r[1],v=r[4],x=r[7],y=r[2],b=r[5],_=r[8];return i[0]=a*d+o*g+s*y,i[3]=a*p+o*v+s*b,i[6]=a*m+o*x+s*_,i[1]=A*d+l*g+u*y,i[4]=A*p+l*v+u*b,i[7]=A*m+l*x+u*_,i[2]=c*d+h*g+f*y,i[5]=c*p+h*v+f*b,i[8]=c*m+h*x+f*_,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],A=t[7],l=t[8];return e*a*l-e*o*A-n*i*l+n*o*s+r*i*A-r*a*s}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],A=t[7],l=t[8],u=l*a-o*A,c=o*s-l*i,h=A*i-a*s,f=e*u+n*c+r*h;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);const d=1/f;return t[0]=u*d,t[1]=(r*A-l*n)*d,t[2]=(o*n-r*a)*d,t[3]=c*d,t[4]=(l*e-r*s)*d,t[5]=(r*i-o*e)*d,t[6]=h*d,t[7]=(n*s-A*e)*d,t[8]=(a*e-n*i)*d,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,r,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+t,-r*A,r*s,-r*(-A*a+s*o)+o+e,0,0,1),this}scale(t,e){const n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=e,n[4]*=e,n[7]*=e,this}rotate(t){const e=Math.cos(t),n=Math.sin(t),r=this.elements,i=r[0],a=r[3],o=r[6],s=r[1],A=r[4],l=r[7];return r[0]=e*i+n*s,r[3]=e*a+n*A,r[6]=e*o+n*l,r[1]=-n*i+e*s,r[4]=-n*a+e*A,r[7]=-n*o+e*l,this}translate(t,e){const n=this.elements;return n[0]+=t*n[2],n[3]+=t*n[5],n[6]+=t*n[8],n[1]+=e*n[2],n[4]+=e*n[5],n[7]+=e*n[8],this}equals(t){const e=this.elements,n=t.elements;for(let t=0;t<9;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}function ht(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function ft(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function dt(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function pt(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}const mt={[H]:{[V]:dt},[V]:{[H]:pt}},gt={legacyMode:!0,get workingColorSpace(){return V},set workingColorSpace(t){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(t,e,n){if(this.legacyMode||e===n||!e||!n)return t;if(mt[e]&&void 0!==mt[e][n]){const r=mt[e][n];return t.r=r(t.r),t.g=r(t.g),t.b=r(t.b),t}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},toWorkingColorSpace:function(t,e){return this.convert(t,e,this.workingColorSpace)}},vt={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},xt={r:0,g:0,b:0},yt={h:0,s:0,l:0},bt={h:0,s:0,l:0};function _t(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+6*(e-t)*(2/3-n):t}function wt(t,e){return e.r=t.r,e.g=t.g,e.b=t.b,e}let Mt,St=class{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,void 0===e&&void 0===n?this.set(t):this.setRGB(t,e,n)}set(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e="srgb"){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,gt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,r="srgb-linear"){return this.r=t,this.g=e,this.b=n,gt.toWorkingColorSpace(this,r),this}setHSL(t,e,n,r="srgb-linear"){if(t=rt(t,1),e=nt(e,0,1),n=nt(n,0,1),0===e)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,i=2*n-r;this.r=_t(i,r,t+1/3),this.g=_t(i,r,t),this.b=_t(i,r,t-1/3)}return gt.toWorkingColorSpace(this,r),this}setStyle(t,e="srgb"){function n(e){void 0!==e&&parseFloat(e)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let r;if(r=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const i=r[1],a=r[2];switch(i){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(t[1],10))/255,this.g=Math.min(255,parseInt(t[2],10))/255,this.b=Math.min(255,parseInt(t[3],10))/255,gt.toWorkingColorSpace(this,e),n(t[4]),this;if(t=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(t[1],10))/100,this.g=Math.min(100,parseInt(t[2],10))/100,this.b=Math.min(100,parseInt(t[3],10))/100,gt.toWorkingColorSpace(this,e),n(t[4]),this;break;case"hsl":case"hsla":if(t=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)){const r=parseFloat(t[1])/360,i=parseFloat(t[2])/100,a=parseFloat(t[3])/100;return n(t[4]),this.setHSL(r,i,a,e)}}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=r[1],n=t.length;if(3===n)return this.r=parseInt(t.charAt(0)+t.charAt(0),16)/255,this.g=parseInt(t.charAt(1)+t.charAt(1),16)/255,this.b=parseInt(t.charAt(2)+t.charAt(2),16)/255,gt.toWorkingColorSpace(this,e),this;if(6===n)return this.r=parseInt(t.charAt(0)+t.charAt(1),16)/255,this.g=parseInt(t.charAt(2)+t.charAt(3),16)/255,this.b=parseInt(t.charAt(4)+t.charAt(5),16)/255,gt.toWorkingColorSpace(this,e),this}return t&&t.length>0?this.setColorName(t,e):this}setColorName(t,e="srgb"){const n=vt[t.toLowerCase()];return void 0!==n?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=dt(t.r),this.g=dt(t.g),this.b=dt(t.b),this}copyLinearToSRGB(t){return this.r=pt(t.r),this.g=pt(t.g),this.b=pt(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t="srgb"){return gt.fromWorkingColorSpace(wt(this,xt),t),nt(255*xt.r,0,255)<<16^nt(255*xt.g,0,255)<<8^nt(255*xt.b,0,255)<<0}getHexString(t="srgb"){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e="srgb-linear"){gt.fromWorkingColorSpace(wt(this,xt),e);const n=xt.r,r=xt.g,i=xt.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 t=a-o;switch(A=l<=.5?t/(a+o):t/(2-a-o),a){case n:s=(r-i)/t+(r<i?6:0);break;case r:s=(i-n)/t+2;break;case i:s=(n-r)/t+4}s/=6}return t.h=s,t.s=A,t.l=l,t}getRGB(t,e="srgb-linear"){return gt.fromWorkingColorSpace(wt(this,xt),e),t.r=xt.r,t.g=xt.g,t.b=xt.b,t}getStyle(t="srgb"){return gt.fromWorkingColorSpace(wt(this,xt),t),t!==H?`color(${t} ${xt.r} ${xt.g} ${xt.b})`:`rgb(${255*xt.r|0},${255*xt.g|0},${255*xt.b|0})`}offsetHSL(t,e,n){return this.getHSL(yt),yt.h+=t,yt.s+=e,yt.l+=n,this.setHSL(yt.h,yt.s,yt.l),this}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(yt),t.getHSL(bt);const n=it(yt.h,bt.h,e),r=it(yt.s,bt.s,e),i=it(yt.l,bt.l,e);return this.setHSL(n,r,i),this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};St.NAMES=vt;class Et{static getDataURL(t){if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{void 0===Mt&&(Mt=ft("canvas")),Mt.width=t.width,Mt.height=t.height;const n=Mt.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Mt}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const e=ft("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const r=n.getImageData(0,0,t.width,t.height),i=r.data;for(let t=0;t<i.length;t++)i[t]=255*dt(i[t]/255);return n.putImageData(r,0,0),e}if(t.data){const e=t.data.slice(0);for(let t=0;t<e.length;t++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[t]=Math.floor(255*dt(e[t]/255)):e[t]=dt(e[t]);return{data:e,width:t.width,height:t.height}}return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}class Tt{constructor(t=null){this.isSource=!0,this.uuid=et(),this.data=t,this.version=0}set needsUpdate(t){!0===t&&this.version++}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(null!==r){let t;if(Array.isArray(r)){t=[];for(let e=0,n=r.length;e<n;e++)r[e].isDataTexture?t.push(Ct(r[e].image)):t.push(Ct(r[e]))}else t=Ct(r);n.url=t}return e||(t.images[this.uuid]=n),n}}function Ct(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?Et.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let Pt=0;class Dt extends Z{constructor(t=Dt.DEFAULT_IMAGE,e=Dt.DEFAULT_MAPPING,n=1001,r=1001,i=1006,a=1008,o=1023,s=1009,A=1,l=3e3){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Pt++}),this.uuid=et(),this.name="",this.source=new Tt(t),this.mipmaps=[],this.mapping=e,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 ut(0,0),this.repeat=new ut(1,1),this.center=new ut(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ct,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(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.encoding=t.encoding,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case M:t.x=t.x-Math.floor(t.x);break;case S:t.x=t.x<0?0:1;break;case E:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case M:t.y=t.y-Math.floor(t.y);break;case S:t.y=t.y<0?0:1;break;case E:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}}Dt.DEFAULT_IMAGE=null,Dt.DEFAULT_MAPPING=300;class Lt{constructor(t=0,e=0,n=0,r=1){Lt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,r){return this.x=t,this.y=e,this.z=n,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*e+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*e+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*e+a[7]*n+a[11]*r+a[15]*i,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,r,i;const a=.01,o=.1,s=t.elements,A=s[0],l=s[4],u=s[8],c=s[1],h=s[5],f=s[9],d=s[2],p=s[6],m=s[10];if(Math.abs(l-c)<a&&Math.abs(u-d)<a&&Math.abs(f-p)<a){if(Math.abs(l+c)<o&&Math.abs(u+d)<o&&Math.abs(f+p)<o&&Math.abs(A+h+m-3)<o)return this.set(1,0,0,0),this;e=Math.PI;const t=(A+1)/2,s=(h+1)/2,g=(m+1)/2,v=(l+c)/4,x=(u+d)/4,y=(f+p)/4;return t>s&&t>g?t<a?(n=0,r=.707106781,i=.707106781):(n=Math.sqrt(t),r=v/n,i=x/n):s>g?s<a?(n=.707106781,r=0,i=.707106781):(r=Math.sqrt(s),n=v/r,i=y/r):g<a?(n=.707106781,r=.707106781,i=0):(i=Math.sqrt(g),n=x/i,r=y/i),this.set(n,r,i,e),this}let g=Math.sqrt((p-f)*(p-f)+(u-d)*(u-d)+(c-l)*(c-l));return Math.abs(g)<.001&&(g=1),this.x=(p-f)/g,this.y=(u-d)/g,this.z=(c-l)/g,this.w=Math.acos((A+h+m-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=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(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class qt extends Z{constructor(t=1,e=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new Lt(0,0,t,e),this.scissorTest=!1,this.viewport=new Lt(0,0,t,e);const r={width:t,height:e,depth:1};this.texture=new Dt(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:C,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(t,e,n=1){this.width===t&&this.height===e&&this.depth===n||(this.width=t,this.height=e,this.depth=n,this.texture.image.width=t,this.texture.image.height=e,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return(new this.constructor).copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.texture.isRenderTargetTexture=!0;const e=Object.assign({},t.texture.image);return this.texture.source=new Tt(e),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,null!==t.depthTexture&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Rt extends Dt{constructor(t=null,e=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=T,this.minFilter=T,this.wrapR=S,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Ot extends Dt{constructor(t=null,e=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:r},this.magFilter=T,this.minFilter=T,this.wrapR=S,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class It{constructor(t=0,e=0,n=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=r}static slerpFlat(t,e,n,r,i,a,o){let s=n[r+0],A=n[r+1],l=n[r+2],u=n[r+3];const c=i[a+0],h=i[a+1],f=i[a+2],d=i[a+3];if(0===o)return t[e+0]=s,t[e+1]=A,t[e+2]=l,void(t[e+3]=u);if(1===o)return t[e+0]=c,t[e+1]=h,t[e+2]=f,void(t[e+3]=d);if(u!==d||s!==c||A!==h||l!==f){let t=1-o;const e=s*c+A*h+l*f+u*d,n=e>=0?1:-1,r=1-e*e;if(r>Number.EPSILON){const i=Math.sqrt(r),a=Math.atan2(i,e*n);t=Math.sin(t*a)/i,o=Math.sin(o*a)/i}const i=o*n;if(s=s*t+c*i,A=A*t+h*i,l=l*t+f*i,u=u*t+d*i,t===1-o){const t=1/Math.sqrt(s*s+A*A+l*l+u*u);s*=t,A*=t,l*=t,u*=t}}t[e]=s,t[e+1]=A,t[e+2]=l,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,r,i,a){const o=n[r],s=n[r+1],A=n[r+2],l=n[r+3],u=i[a],c=i[a+1],h=i[a+2],f=i[a+3];return t[e]=o*f+l*u+s*h-A*c,t[e+1]=s*f+l*c+A*u-o*h,t[e+2]=A*f+l*h+o*c-s*u,t[e+3]=l*f-o*u-s*c-A*h,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,r){return this._x=t,this._y=e,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){const n=t._x,r=t._y,i=t._z,a=t._order,o=Math.cos,s=Math.sin,A=o(n/2),l=o(r/2),u=o(i/2),c=s(n/2),h=s(r/2),f=s(i/2);switch(a){case"XYZ":this._x=c*l*u+A*h*f,this._y=A*h*u-c*l*f,this._z=A*l*f+c*h*u,this._w=A*l*u-c*h*f;break;case"YXZ":this._x=c*l*u+A*h*f,this._y=A*h*u-c*l*f,this._z=A*l*f-c*h*u,this._w=A*l*u+c*h*f;break;case"ZXY":this._x=c*l*u-A*h*f,this._y=A*h*u+c*l*f,this._z=A*l*f+c*h*u,this._w=A*l*u-c*h*f;break;case"ZYX":this._x=c*l*u-A*h*f,this._y=A*h*u+c*l*f,this._z=A*l*f-c*h*u,this._w=A*l*u+c*h*f;break;case"YZX":this._x=c*l*u+A*h*f,this._y=A*h*u+c*l*f,this._z=A*l*f-c*h*u,this._w=A*l*u-c*h*f;break;case"XZY":this._x=c*l*u-A*h*f,this._y=A*h*u-c*l*f,this._z=A*l*f+c*h*u,this._w=A*l*u+c*h*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],r=e[4],i=e[8],a=e[1],o=e[5],s=e[9],A=e[2],l=e[6],u=e[10],c=n+o+u;if(c>0){const t=.5/Math.sqrt(c+1);this._w=.25/t,this._x=(l-s)*t,this._y=(i-A)*t,this._z=(a-r)*t}else if(n>o&&n>u){const t=2*Math.sqrt(1+n-o-u);this._w=(l-s)/t,this._x=.25*t,this._y=(r+a)/t,this._z=(i+A)/t}else if(o>u){const t=2*Math.sqrt(1+o-n-u);this._w=(i-A)/t,this._x=(r+a)/t,this._y=.25*t,this._z=(s+l)/t}else{const t=2*Math.sqrt(1+u-n-o);this._w=(a-r)/t,this._x=(i+A)/t,this._y=(s+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(nt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(0===n)return this;const r=Math.min(1,e/n);return this.slerp(t,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(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,r=t._y,i=t._z,a=t._w,o=e._x,s=e._y,A=e._z,l=e._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(t,e){if(0===e)return this;if(1===e)return this.copy(t);const n=this._x,r=this._y,i=this._z,a=this._w;let o=a*t._w+n*t._x+r*t._y+i*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;const s=1-o*o;if(s<=Number.EPSILON){const t=1-e;return this._w=t*a+e*this._w,this._x=t*n+e*this._x,this._y=t*r+e*this._y,this._z=t*i+e*this._z,this.normalize(),this._onChangeCallback(),this}const A=Math.sqrt(s),l=Math.atan2(A,o),u=Math.sin((1-e)*l)/A,c=Math.sin(e*l)/A;return this._w=a*u+this._w*c,this._x=n*u+this._x*c,this._y=r*u+this._y*c,this._z=i*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=Math.random(),e=Math.sqrt(1-t),n=Math.sqrt(t),r=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(e*Math.cos(r),n*Math.sin(i),n*Math.cos(i),e*Math.sin(r))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class kt{constructor(t=0,e=0,n=0){kt.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return void 0===n&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Nt.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Nt.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6]*r,this.y=i[1]*e+i[4]*n+i[7]*r,this.z=i[2]*e+i[5]*n+i[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,r=this.z,i=t.elements,a=1/(i[3]*e+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*e+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*e+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*e+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,r=this.z,i=t.x,a=t.y,o=t.z,s=t.w,A=s*e+a*r-o*n,l=s*n+o*e-i*r,u=s*r+i*n-a*e,c=-i*e-a*n-o*r;return this.x=A*s+c*-i+l*-o-u*-a,this.y=l*s+c*-a+u*-i-A*-o,this.z=u*s+c*-o+A*-a-l*-i,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,r=this.z,i=t.elements;return this.x=i[0]*e+i[4]*n+i[8]*r,this.y=i[1]*e+i[5]*n+i[9]*r,this.z=i[2]*e+i[6]*n+i[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,r=t.y,i=t.z,a=e.x,o=e.y,s=e.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Bt.copy(this).projectOnVector(t),this.sub(Bt)}reflect(t){return this.sub(Bt.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(nt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return e*e+n*n+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const r=Math.sin(e)*t;return this.x=r*Math.sin(n),this.y=Math.cos(e)*t,this.z=r*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=2*(Math.random()-.5),e=Math.random()*Math.PI*2,n=Math.sqrt(1-t**2);return this.x=n*Math.cos(e),this.y=n*Math.sin(e),this.z=t,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Bt=new kt,Nt=new It;class zt{constructor(t=new kt(1/0,1/0,1/0),e=new kt(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){let e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(let s=0,A=t.length;s<A;s+=3){const A=t[s],l=t[s+1],u=t[s+2];A<e&&(e=A),l<n&&(n=l),u<r&&(r=u),A>i&&(i=A),l>a&&(a=l),u>o&&(o=u)}return this.min.set(e,n,r),this.max.set(i,a,o),this}setFromBufferAttribute(t){let e=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0;for(let s=0,A=t.count;s<A;s++){const A=t.getX(s),l=t.getY(s),u=t.getZ(s);A<e&&(e=A),l<n&&(n=l),u<r&&(r=u),A>i&&(i=A),l>a&&(a=l),u>o&&(o=u)}return this.min.set(e,n,r),this.max.set(i,a,o),this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Ft.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return(new this.constructor).copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(void 0!==n)if(e&&null!=n.attributes&&void 0!==n.attributes.position){const e=n.attributes.position;for(let n=0,r=e.count;n<r;n++)Ft.fromBufferAttribute(e,n).applyMatrix4(t.matrixWorld),this.expandByPoint(Ft)}else null===n.boundingBox&&n.computeBoundingBox(),Gt.copy(n.boundingBox),Gt.applyMatrix4(t.matrixWorld),this.union(Gt);const r=t.children;for(let t=0,n=r.length;t<n;t++)this.expandByObject(r[t],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Ft),Ft.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Yt),Zt.subVectors(this.max,Yt),jt.subVectors(t.a,Yt),Ht.subVectors(t.b,Yt),Vt.subVectors(t.c,Yt),Wt.subVectors(Ht,jt),Qt.subVectors(Vt,Ht),Xt.subVectors(jt,Vt);let e=[0,-Wt.z,Wt.y,0,-Qt.z,Qt.y,0,-Xt.z,Xt.y,Wt.z,0,-Wt.x,Qt.z,0,-Qt.x,Xt.z,0,-Xt.x,-Wt.y,Wt.x,0,-Qt.y,Qt.x,0,-Xt.y,Xt.x,0];return!!$t(e,jt,Ht,Vt,Zt)&&(e=[1,0,0,0,1,0,0,0,1],!!$t(e,jt,Ht,Vt,Zt)&&(Jt.crossVectors(Wt,Qt),e=[Jt.x,Jt.y,Jt.z],$t(e,jt,Ht,Vt,Zt)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Ft.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=.5*this.getSize(Ft).length(),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(Ut[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ut[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ut[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ut[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ut[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ut[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ut[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ut[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ut)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Ut=[new kt,new kt,new kt,new kt,new kt,new kt,new kt,new kt],Ft=new kt,Gt=new zt,jt=new kt,Ht=new kt,Vt=new kt,Wt=new kt,Qt=new kt,Xt=new kt,Yt=new kt,Zt=new kt,Jt=new kt,Kt=new kt;function $t(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){Kt.fromArray(t,a);const o=i.x*Math.abs(Kt.x)+i.y*Math.abs(Kt.y)+i.z*Math.abs(Kt.z),s=e.dot(Kt),A=n.dot(Kt),l=r.dot(Kt);if(Math.max(-Math.max(s,A,l),Math.min(s,A,l))>o)return!1}return!0}const te=new zt,ee=new kt,ne=new kt;class re{constructor(t=new kt,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;void 0!==e?n.copy(e):te.setFromPoints(t).getCenter(n);let r=0;for(let e=0,i=t.length;e<i;e++)r=Math.max(r,n.distanceToSquared(t[e]));return this.radius=Math.sqrt(r),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;ee.subVectors(t,this.center);const e=ee.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),n=.5*(t-this.radius);this.center.addScaledVector(ee,n/t),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(ne.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ee.copy(t.center).add(ne)),this.expandByPoint(ee.copy(t.center).sub(ne))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const ie=new kt,ae=new kt,oe=new kt,se=new kt,Ae=new kt,le=new kt,ue=new kt;class ce{constructor(t=new kt,e=new kt(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.direction).multiplyScalar(t).add(this.origin)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,ie)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=ie.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(ie.copy(this.direction).multiplyScalar(e).add(this.origin),ie.distanceToSquared(t))}distanceSqToSegment(t,e,n,r){ae.copy(t).add(e).multiplyScalar(.5),oe.copy(e).sub(t).normalize(),se.copy(this.origin).sub(ae);const i=.5*t.distanceTo(e),a=-this.direction.dot(oe),o=se.dot(this.direction),s=-se.dot(oe),A=se.lengthSq(),l=Math.abs(1-a*a);let u,c,h,f;if(l>0)if(u=a*s-o,c=a*o-s,f=i*l,u>=0)if(c>=-f)if(c<=f){const t=1/l;u*=t,c*=t,h=u*(u+a*c+2*o)+c*(a*u+c+2*s)+A}else c=i,u=Math.max(0,-(a*c+o)),h=-u*u+c*(c+2*s)+A;else c=-i,u=Math.max(0,-(a*c+o)),h=-u*u+c*(c+2*s)+A;else c<=-f?(u=Math.max(0,-(-a*i+o)),c=u>0?-i:Math.min(Math.max(-i,-s),i),h=-u*u+c*(c+2*s)+A):c<=f?(u=0,c=Math.min(Math.max(-i,-s),i),h=c*(c+2*s)+A):(u=Math.max(0,-(a*i+o)),c=u>0?i:Math.min(Math.max(-i,-s),i),h=-u*u+c*(c+2*s)+A);else c=a>0?-i:i,u=Math.max(0,-(a*c+o)),h=-u*u+c*(c+2*s)+A;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),r&&r.copy(oe).multiplyScalar(c).add(ae),h}intersectSphere(t,e){ie.subVectors(t.center,this.origin);const n=ie.dot(this.direction),r=ie.dot(ie)-n*n,i=t.radius*t.radius;if(r>i)return null;const a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return null===n?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);if(0===e)return!0;return t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,r,i,a,o,s;const A=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,c=this.origin;return A>=0?(n=(t.min.x-c.x)*A,r=(t.max.x-c.x)*A):(n=(t.max.x-c.x)*A,r=(t.min.x-c.x)*A),l>=0?(i=(t.min.y-c.y)*l,a=(t.max.y-c.y)*l):(i=(t.max.y-c.y)*l,a=(t.min.y-c.y)*l),n>a||i>r?null:((i>n||isNaN(n))&&(n=i),(a<r||isNaN(r))&&(r=a),u>=0?(o=(t.min.z-c.z)*u,s=(t.max.z-c.z)*u):(o=(t.max.z-c.z)*u,s=(t.min.z-c.z)*u),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,e)))}intersectsBox(t){return null!==this.intersectBox(t,ie)}intersectTriangle(t,e,n,r,i){Ae.subVectors(e,t),le.subVectors(n,t),ue.crossVectors(Ae,le);let a,o=this.direction.dot(ue);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}se.subVectors(this.origin,t);const s=a*this.direction.dot(le.crossVectors(se,le));if(s<0)return null;const A=a*this.direction.dot(Ae.cross(se));if(A<0)return null;if(s+A>o)return null;const l=-a*se.dot(ue);return l<0?null:this.at(l/o,i)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class he{constructor(){he.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}set(t,e,n,r,i,a,o,s,A,l,u,c,h,f,d,p){const m=this.elements;return m[0]=t,m[4]=e,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]=u,m[14]=c,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 he).fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,r=1/fe.setFromMatrixColumn(t,0).length(),i=1/fe.setFromMatrixColumn(t,1).length(),a=1/fe.setFromMatrixColumn(t,2).length();return e[0]=n[0]*r,e[1]=n[1]*r,e[2]=n[2]*r,e[3]=0,e[4]=n[4]*i,e[5]=n[5]*i,e[6]=n[6]*i,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,r=t.y,i=t.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),A=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if("XYZ"===t.order){const t=a*l,n=a*u,r=o*l,i=o*u;e[0]=s*l,e[4]=-s*u,e[8]=A,e[1]=n+r*A,e[5]=t-i*A,e[9]=-o*s,e[2]=i-t*A,e[6]=r+n*A,e[10]=a*s}else if("YXZ"===t.order){const t=s*l,n=s*u,r=A*l,i=A*u;e[0]=t+i*o,e[4]=r*o-n,e[8]=a*A,e[1]=a*u,e[5]=a*l,e[9]=-o,e[2]=n*o-r,e[6]=i+t*o,e[10]=a*s}else if("ZXY"===t.order){const t=s*l,n=s*u,r=A*l,i=A*u;e[0]=t-i*o,e[4]=-a*u,e[8]=r+n*o,e[1]=n+r*o,e[5]=a*l,e[9]=i-t*o,e[2]=-a*A,e[6]=o,e[10]=a*s}else if("ZYX"===t.order){const t=a*l,n=a*u,r=o*l,i=o*u;e[0]=s*l,e[4]=r*A-n,e[8]=t*A+i,e[1]=s*u,e[5]=i*A+t,e[9]=n*A-r,e[2]=-A,e[6]=o*s,e[10]=a*s}else if("YZX"===t.order){const t=a*s,n=a*A,r=o*s,i=o*A;e[0]=s*l,e[4]=i-t*u,e[8]=r*u+n,e[1]=u,e[5]=a*l,e[9]=-o*l,e[2]=-A*l,e[6]=n*u+r,e[10]=t-i*u}else if("XZY"===t.order){const t=a*s,n=a*A,r=o*s,i=o*A;e[0]=s*l,e[4]=-u,e[8]=A*l,e[1]=t*u+i,e[5]=a*l,e[9]=n*u-r,e[2]=r*u-n,e[6]=o*l,e[10]=i*u+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(pe,t,me)}lookAt(t,e,n){const r=this.elements;return xe.subVectors(t,e),0===xe.lengthSq()&&(xe.z=1),xe.normalize(),ge.crossVectors(n,xe),0===ge.lengthSq()&&(1===Math.abs(n.z)?xe.x+=1e-4:xe.z+=1e-4,xe.normalize(),ge.crossVectors(n,xe)),ge.normalize(),ve.crossVectors(xe,ge),r[0]=ge.x,r[4]=ve.x,r[8]=xe.x,r[1]=ge.y,r[5]=ve.y,r[9]=xe.y,r[2]=ge.z,r[6]=ve.z,r[10]=xe.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,i=this.elements,a=n[0],o=n[4],s=n[8],A=n[12],l=n[1],u=n[5],c=n[9],h=n[13],f=n[2],d=n[6],p=n[10],m=n[14],g=n[3],v=n[7],x=n[11],y=n[15],b=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],D=r[6],L=r[10],q=r[14],R=r[3],O=r[7],I=r[11],k=r[15];return i[0]=a*b+o*S+s*P+A*R,i[4]=a*_+o*E+s*D+A*O,i[8]=a*w+o*T+s*L+A*I,i[12]=a*M+o*C+s*q+A*k,i[1]=l*b+u*S+c*P+h*R,i[5]=l*_+u*E+c*D+h*O,i[9]=l*w+u*T+c*L+h*I,i[13]=l*M+u*C+c*q+h*k,i[2]=f*b+d*S+p*P+m*R,i[6]=f*_+d*E+p*D+m*O,i[10]=f*w+d*T+p*L+m*I,i[14]=f*M+d*C+p*q+m*k,i[3]=g*b+v*S+x*P+y*R,i[7]=g*_+v*E+x*D+y*O,i[11]=g*w+v*T+x*L+y*I,i[15]=g*M+v*C+x*q+y*k,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],r=t[8],i=t[12],a=t[1],o=t[5],s=t[9],A=t[13],l=t[2],u=t[6],c=t[10],h=t[14];return t[3]*(+i*s*u-r*A*u-i*o*c+n*A*c+r*o*h-n*s*h)+t[7]*(+e*s*h-e*A*c+i*a*c-r*a*h+r*A*l-i*s*l)+t[11]*(+e*A*u-e*o*h-i*a*u+n*a*h+i*o*l-n*A*l)+t[15]*(-r*o*l-e*s*u+e*o*c+r*a*u-n*a*c+n*s*l)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],A=t[7],l=t[8],u=t[9],c=t[10],h=t[11],f=t[12],d=t[13],p=t[14],m=t[15],g=u*p*A-d*c*A+d*s*h-o*p*h-u*s*m+o*c*m,v=f*c*A-l*p*A-f*s*h+a*p*h+l*s*m-a*c*m,x=l*d*A-f*u*A+f*o*h-a*d*h-l*o*m+a*u*m,y=f*u*s-l*d*s-f*o*c+a*d*c+l*o*p-a*u*p,b=e*g+n*v+r*x+i*y;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const _=1/b;return t[0]=g*_,t[1]=(d*c*i-u*p*i-d*r*h+n*p*h+u*r*m-n*c*m)*_,t[2]=(o*p*i-d*s*i+d*r*A-n*p*A-o*r*m+n*s*m)*_,t[3]=(u*s*i-o*c*i-u*r*A+n*c*A+o*r*h-n*s*h)*_,t[4]=v*_,t[5]=(l*p*i-f*c*i+f*r*h-e*p*h-l*r*m+e*c*m)*_,t[6]=(f*s*i-a*p*i-f*r*A+e*p*A+a*r*m-e*s*m)*_,t[7]=(a*c*i-l*s*i+l*r*A-e*c*A-a*r*h+e*s*h)*_,t[8]=x*_,t[9]=(f*u*i-l*d*i-f*n*h+e*d*h+l*n*m-e*u*m)*_,t[10]=(a*d*i-f*o*i+f*n*A-e*d*A-a*n*m+e*o*m)*_,t[11]=(l*o*i-a*u*i-l*n*A+e*u*A+a*n*h-e*o*h)*_,t[12]=y*_,t[13]=(l*d*r-f*u*r+f*n*c-e*d*c-l*n*p+e*u*p)*_,t[14]=(f*o*r-a*d*r-f*n*s+e*d*s+a*n*p-e*o*p)*_,t[15]=(a*u*r-l*o*r+l*n*s-e*u*s-a*n*c+e*o*c)*_,this}scale(t){const e=this.elements,n=t.x,r=t.y,i=t.z;return e[0]*=n,e[4]*=r,e[8]*=i,e[1]*=n,e[5]*=r,e[9]*=i,e[2]*=n,e[6]*=r,e[10]*=i,e[3]*=n,e[7]*=r,e[11]*=i,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,r))}makeTranslation(t,e,n){return this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),r=Math.sin(e),i=1-n,a=t.x,o=t.y,s=t.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(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,r,i,a){return this.set(1,n,i,0,t,1,a,0,e,r,1,0,0,0,0,1),this}compose(t,e,n){const r=this.elements,i=e._x,a=e._y,o=e._z,s=e._w,A=i+i,l=a+a,u=o+o,c=i*A,h=i*l,f=i*u,d=a*l,p=a*u,m=o*u,g=s*A,v=s*l,x=s*u,y=n.x,b=n.y,_=n.z;return r[0]=(1-(d+m))*y,r[1]=(h+x)*y,r[2]=(f-v)*y,r[3]=0,r[4]=(h-x)*b,r[5]=(1-(c+m))*b,r[6]=(p+g)*b,r[7]=0,r[8]=(f+v)*_,r[9]=(p-g)*_,r[10]=(1-(c+d))*_,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,n){const r=this.elements;let i=fe.set(r[0],r[1],r[2]).length();const a=fe.set(r[4],r[5],r[6]).length(),o=fe.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),t.x=r[12],t.y=r[13],t.z=r[14],de.copy(this);const s=1/i,A=1/a,l=1/o;return de.elements[0]*=s,de.elements[1]*=s,de.elements[2]*=s,de.elements[4]*=A,de.elements[5]*=A,de.elements[6]*=A,de.elements[8]*=l,de.elements[9]*=l,de.elements[10]*=l,e.setFromRotationMatrix(de),n.x=i,n.y=a,n.z=o,this}makePerspective(t,e,n,r,i,a){const o=this.elements,s=2*i/(e-t),A=2*i/(n-r),l=(e+t)/(e-t),u=(n+r)/(n-r),c=-(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]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=c,o[14]=h,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,n,r,i,a){const o=this.elements,s=1/(e-t),A=1/(n-r),l=1/(a-i),u=(e+t)*s,c=(n+r)*A,h=(a+i)*l;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*A,o[9]=0,o[13]=-c,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(t){const e=this.elements,n=t.elements;for(let t=0;t<16;t++)if(e[t]!==n[t])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const fe=new kt,de=new he,pe=new kt(0,0,0),me=new kt(1,1,1),ge=new kt,ve=new kt,xe=new kt,ye=new he,be=new It;class _e{constructor(t=0,e=0,n=0,r=_e.DefaultOrder){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,r=this._order){return this._x=t,this._y=e,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const r=t.elements,i=r[0],a=r[4],o=r[8],s=r[1],A=r[5],l=r[9],u=r[2],c=r[6],h=r[10];switch(e){case"XYZ":this._y=Math.asin(nt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,h),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(c,A),this._z=0);break;case"YXZ":this._x=Math.asin(-nt(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,h),this._z=Math.atan2(s,A)):(this._y=Math.atan2(-u,i),this._z=0);break;case"ZXY":this._x=Math.asin(nt(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(-u,h),this._z=Math.atan2(-a,A)):(this._y=0,this._z=Math.atan2(s,i));break;case"ZYX":this._y=Math.asin(-nt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(c,h),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,A));break;case"YZX":this._z=Math.asin(nt(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,A),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,h));break;case"XZY":this._z=Math.asin(-nt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(c,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: "+e)}return this._order=e,!0===n&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return ye.makeRotationFromQuaternion(t),this.setFromRotationMatrix(ye,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return be.setFromEuler(this),this.setFromQuaternion(be,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}_e.DefaultOrder="XYZ",_e.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class we{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return 0!=(this.mask&t.mask)}isEnabled(t){return 0!=(this.mask&(1<<t|0))}}let Me=0;const Se=new kt,Ee=new It,Te=new he,Ce=new kt,Pe=new kt,De=new kt,Le=new It,qe=new kt(1,0,0),Re=new kt(0,1,0),Oe=new kt(0,0,1),Ie={type:"added"},ke={type:"removed"};class Be extends Z{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Me++}),this.uuid=et(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Be.DefaultUp.clone();const t=new kt,e=new _e,n=new It,r=new kt(1,1,1);e._onChange((function(){n.setFromEuler(e,!1)})),n._onChange((function(){e.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new he},normalMatrix:{value:new ct}}),this.matrix=new he,this.matrixWorld=new he,this.matrixAutoUpdate=Be.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=Be.DefaultMatrixWorldAutoUpdate,this.layers=new we,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Ee.setFromAxisAngle(t,e),this.quaternion.multiply(Ee),this}rotateOnWorldAxis(t,e){return Ee.setFromAxisAngle(t,e),this.quaternion.premultiply(Ee),this}rotateX(t){return this.rotateOnAxis(qe,t)}rotateY(t){return this.rotateOnAxis(Re,t)}rotateZ(t){return this.rotateOnAxis(Oe,t)}translateOnAxis(t,e){return Se.copy(t).applyQuaternion(this.quaternion),this.position.add(Se.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(qe,t)}translateY(t){return this.translateOnAxis(Re,t)}translateZ(t){return this.translateOnAxis(Oe,t)}localToWorld(t){return t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return t.applyMatrix4(Te.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?Ce.copy(t):Ce.set(t,e,n);const r=this.parent;this.updateWorldMatrix(!0,!1),Pe.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Te.lookAt(Pe,Ce,this.up):Te.lookAt(Ce,Pe,this.up),this.quaternion.setFromRotationMatrix(Te),r&&(Te.extractRotation(r.matrixWorld),Ee.setFromRotationMatrix(Te),this.quaternion.premultiply(Ee.invert()))}add(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t),t.dispatchEvent(Ie)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.remove(arguments[t]);return this}const e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(ke)),this}removeFromParent(){const t=this.parent;return null!==t&&t.remove(this),this}clear(){for(let t=0;t<this.children.length;t++){const e=this.children[t];e.parent=null,e.dispatchEvent(ke)}return this.children.length=0,this}attach(t){return this.updateWorldMatrix(!0,!1),Te.copy(this.matrixWorld).invert(),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),Te.multiply(t.parent.matrixWorld)),t.applyMatrix4(Te),this.add(t),t.updateWorldMatrix(!1,!0),this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,r=this.children.length;n<r;n++){const r=this.children[n].getObjectByProperty(t,e);if(void 0!==r)return r}}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Pe,t,De),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Pe,Le,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverse(t)}traverseVisible(t){if(!1===this.visible)return;t(this);const e=this.children;for(let n=0,r=e.length;n<r;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;null!==e&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,r=e.length;n<r;n++){const r=e[n];!0!==r.matrixWorldAutoUpdate&&!0!==t||r.updateMatrixWorld(t)}}updateWorldMatrix(t,e){const n=this.parent;if(!0===t&&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===e){const t=this.children;for(let e=0,n=t.length;e<n;e++){const n=t[e];!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!1,!0)}}}toJSON(t){const e=void 0===t||"string"==typeof t,n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const r={};function i(e,n){return void 0===e[n.uuid]&&(e[n.uuid]=n.toJSON(t)),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),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.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(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(r.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(t.geometries,this.geometry);const e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){const n=e.shapes;if(Array.isArray(n))for(let e=0,r=n.length;e<r;e++){const r=n[e];i(t.shapes,r)}else i(t.shapes,n)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(i(t.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const e=[];for(let n=0,r=this.material.length;n<r;n++)e.push(i(t.materials,this.material[n]));r.material=e}else r.material=i(t.materials,this.material);if(this.children.length>0){r.children=[];for(let e=0;e<this.children.length;e++)r.children.push(this.children[e].toJSON(t).object)}if(this.animations.length>0){r.animations=[];for(let e=0;e<this.animations.length;e++){const n=this.animations[e];r.animations.push(i(t.animations,n))}}if(e){const e=a(t.geometries),r=a(t.materials),i=a(t.textures),o=a(t.images),s=a(t.shapes),A=a(t.skeletons),l=a(t.animations),u=a(t.nodes);e.length>0&&(n.geometries=e),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),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(t){const e=[];for(const n in t){const r=t[n];delete r.metadata,e.push(r)}return e}}clone(t){return(new this.constructor).copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e<t.children.length;e++){const n=t.children[e];this.add(n.clone())}return this}}Be.DefaultUp=new kt(0,1,0),Be.DefaultMatrixAutoUpdate=!0,Be.DefaultMatrixWorldAutoUpdate=!0;const Ne=new kt,ze=new kt,Ue=new kt,Fe=new kt,Ge=new kt,je=new kt,He=new kt,Ve=new kt,We=new kt,Qe=new kt;class Xe{constructor(t=new kt,e=new kt,n=new kt){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,r){r.subVectors(n,e),Ne.subVectors(t,e),r.cross(Ne);const i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(t,e,n,r,i){Ne.subVectors(r,e),ze.subVectors(n,e),Ue.subVectors(t,e);const a=Ne.dot(Ne),o=Ne.dot(ze),s=Ne.dot(Ue),A=ze.dot(ze),l=ze.dot(Ue),u=a*A-o*o;if(0===u)return i.set(-2,-1,-1);const c=1/u,h=(A*s-o*l)*c,f=(a*l-o*s)*c;return i.set(1-h-f,f,h)}static containsPoint(t,e,n,r){return this.getBarycoord(t,e,n,r,Fe),Fe.x>=0&&Fe.y>=0&&Fe.x+Fe.y<=1}static getUV(t,e,n,r,i,a,o,s){return this.getBarycoord(t,e,n,r,Fe),s.set(0,0),s.addScaledVector(i,Fe.x),s.addScaledVector(a,Fe.y),s.addScaledVector(o,Fe.z),s}static isFrontFacing(t,e,n,r){return Ne.subVectors(n,e),ze.subVectors(t,e),Ne.cross(ze).dot(r)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,r){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[r]),this}setFromAttributeAndIndices(t,e,n,r){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,r),this}clone(){return(new this.constructor).copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Ne.subVectors(this.c,this.b),ze.subVectors(this.a,this.b),.5*Ne.cross(ze).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Xe.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Xe.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,n,r,i){return Xe.getUV(t,this.a,this.b,this.c,e,n,r,i)}containsPoint(t){return Xe.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Xe.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,r=this.b,i=this.c;let a,o;Ge.subVectors(r,n),je.subVectors(i,n),Ve.subVectors(t,n);const s=Ge.dot(Ve),A=je.dot(Ve);if(s<=0&&A<=0)return e.copy(n);We.subVectors(t,r);const l=Ge.dot(We),u=je.dot(We);if(l>=0&&u<=l)return e.copy(r);const c=s*u-l*A;if(c<=0&&s>=0&&l<=0)return a=s/(s-l),e.copy(n).addScaledVector(Ge,a);Qe.subVectors(t,i);const h=Ge.dot(Qe),f=je.dot(Qe);if(f>=0&&h<=f)return e.copy(i);const d=h*A-s*f;if(d<=0&&A>=0&&f<=0)return o=A/(A-f),e.copy(n).addScaledVector(je,o);const p=l*f-h*u;if(p<=0&&u-l>=0&&h-f>=0)return He.subVectors(i,r),o=(u-l)/(u-l+(h-f)),e.copy(r).addScaledVector(He,o);const m=1/(p+d+c);return a=d*m,o=c*m,e.copy(n).addScaledVector(Ge,a).addScaledVector(je,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let Ye=0;class Ze extends Z{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ye++}),this.uuid=et(),this.name="",this.type="Material",this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=y,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=W,this.stencilZFail=W,this.stencilZPass=W,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(const e in t){const n=t[e];if(void 0===n){console.warn("THREE.Material: '"+e+"' parameter is undefined.");continue}const r=this[e];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[e]=n:console.warn("THREE."+this.type+": '"+e+"' is not a property of this material.")}}toJSON(t){const e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function r(t){const e=[];for(const n in t){const r=t[n];delete r.metadata,e.push(r)}return e}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(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).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(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).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(t).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).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),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(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.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),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),e){const e=r(t.textures),i=r(t.images);e.length>0&&(n.textures=e),i.length>0&&(n.images=i)}return n}clone(){return(new this.constructor).copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(null!==e){const t=e.length;n=new Array(t);for(let r=0;r!==t;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}class Je extends Ze{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new St(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=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Ke=new kt,$e=new ut;class tn{constructor(t,e,n){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=!0===n,this.usage=Q,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let r=0,i=this.itemSize;r<i;r++)this.array[t+r]=e.array[n+r];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(2===this.itemSize)for(let e=0,n=this.count;e<n;e++)$e.fromBufferAttribute(this,e),$e.applyMatrix3(t),this.setXY(e,$e.x,$e.y);else if(3===this.itemSize)for(let e=0,n=this.count;e<n;e++)Ke.fromBufferAttribute(this,e),Ke.applyMatrix3(t),this.setXYZ(e,Ke.x,Ke.y,Ke.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Ke.fromBufferAttribute(this,e),Ke.applyMatrix4(t),this.setXYZ(e,Ke.x,Ke.y,Ke.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ke.fromBufferAttribute(this,e),Ke.applyNormalMatrix(t),this.setXYZ(e,Ke.x,Ke.y,Ke.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ke.fromBufferAttribute(this,e),Ke.transformDirection(t),this.setXYZ(e,Ke.x,Ke.y,Ke.z);return this}set(t,e=0){return this.array.set(t,e),this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=st(e,this.array)),e}setX(t,e){return this.normalized&&(e=At(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=st(e,this.array)),e}setY(t,e){return this.normalized&&(e=At(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=st(e,this.array)),e}setZ(t,e){return this.normalized&&(e=At(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=st(e,this.array)),e}setW(t,e){return this.normalized&&(e=At(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=At(e,this.array),n=At(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,r){return t*=this.itemSize,this.normalized&&(e=At(e,this.array),n=At(n,this.array),r=At(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this}setXYZW(t,e,n,r,i){return t*=this.itemSize,this.normalized&&(e=At(e,this.array),n=At(n,this.array),r=At(r,this.array),i=At(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=r,this.array[t+3]=i,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(t.name=this.name),this.usage!==Q&&(t.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(t.updateRange=this.updateRange),t}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 en extends tn{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class nn extends tn{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class rn extends tn{constructor(t,e,n){super(new Float32Array(t),e,n)}}let an=0;const on=new he,sn=new Be,An=new kt,ln=new zt,un=new zt,cn=new kt;class hn extends Z{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:an++}),this.uuid=et(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(ht(t)?nn:en)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return void 0!==this.attributes[t]}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;void 0!==e&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const e=(new ct).getNormalMatrix(t);n.applyNormalMatrix(e),n.needsUpdate=!0}const r=this.attributes.tangent;return void 0!==r&&(r.transformDirection(t),r.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return on.makeRotationFromQuaternion(t),this.applyMatrix4(on),this}rotateX(t){return on.makeRotationX(t),this.applyMatrix4(on),this}rotateY(t){return on.makeRotationY(t),this.applyMatrix4(on),this}rotateZ(t){return on.makeRotationZ(t),this.applyMatrix4(on),this}translate(t,e,n){return on.makeTranslation(t,e,n),this.applyMatrix4(on),this}scale(t,e,n){return on.makeScale(t,e,n),this.applyMatrix4(on),this}lookAt(t){return sn.lookAt(t),sn.updateMatrix(),this.applyMatrix4(sn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(An).negate(),this.translate(An.x,An.y,An.z),this}setFromPoints(t){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n];e.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new rn(e,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new zt);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new kt(-1/0,-1/0,-1/0),new kt(1/0,1/0,1/0));if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];ln.setFromBufferAttribute(n),this.morphTargetsRelative?(cn.addVectors(this.boundingBox.min,ln.min),this.boundingBox.expandByPoint(cn),cn.addVectors(this.boundingBox.max,ln.max),this.boundingBox.expandByPoint(cn)):(this.boundingBox.expandByPoint(ln.min),this.boundingBox.expandByPoint(ln.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 re);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute)return console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new kt,1/0);if(t){const n=this.boundingSphere.center;if(ln.setFromBufferAttribute(t),e)for(let t=0,n=e.length;t<n;t++){const n=e[t];un.setFromBufferAttribute(n),this.morphTargetsRelative?(cn.addVectors(ln.min,un.min),ln.expandByPoint(cn),cn.addVectors(ln.max,un.max),ln.expandByPoint(cn)):(ln.expandByPoint(un.min),ln.expandByPoint(un.max))}ln.getCenter(n);let r=0;for(let e=0,i=t.count;e<i;e++)cn.fromBufferAttribute(t,e),r=Math.max(r,n.distanceToSquared(cn));if(e)for(let i=0,a=e.length;i<a;i++){const a=e[i],o=this.morphTargetsRelative;for(let e=0,i=a.count;e<i;e++)cn.fromBufferAttribute(a,e),o&&(An.fromBufferAttribute(t,e),cn.add(An)),r=Math.max(r,n.distanceToSquared(cn))}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 t=this.index,e=this.attributes;if(null===t||void 0===e.position||void 0===e.normal||void 0===e.uv)return void console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=t.array,r=e.position.array,i=e.normal.array,a=e.uv.array,o=r.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new tn(new Float32Array(4*o),4));const s=this.getAttribute("tangent").array,A=[],l=[];for(let t=0;t<o;t++)A[t]=new kt,l[t]=new kt;const u=new kt,c=new kt,h=new kt,f=new ut,d=new ut,p=new ut,m=new kt,g=new kt;function v(t,e,n){u.fromArray(r,3*t),c.fromArray(r,3*e),h.fromArray(r,3*n),f.fromArray(a,2*t),d.fromArray(a,2*e),p.fromArray(a,2*n),c.sub(u),h.sub(u),d.sub(f),p.sub(f);const i=1/(d.x*p.y-p.x*d.y);isFinite(i)&&(m.copy(c).multiplyScalar(p.y).addScaledVector(h,-d.y).multiplyScalar(i),g.copy(h).multiplyScalar(d.x).addScaledVector(c,-p.x).multiplyScalar(i),A[t].add(m),A[e].add(m),A[n].add(m),l[t].add(g),l[e].add(g),l[n].add(g))}let x=this.groups;0===x.length&&(x=[{start:0,count:n.length}]);for(let t=0,e=x.length;t<e;++t){const e=x[t],r=e.start;for(let t=r,i=r+e.count;t<i;t+=3)v(n[t+0],n[t+1],n[t+2])}const y=new kt,b=new kt,_=new kt,w=new kt;function M(t){_.fromArray(i,3*t),w.copy(_);const e=A[t];y.copy(e),y.sub(_.multiplyScalar(_.dot(e))).normalize(),b.crossVectors(w,e);const n=b.dot(l[t])<0?-1:1;s[4*t]=y.x,s[4*t+1]=y.y,s[4*t+2]=y.z,s[4*t+3]=n}for(let t=0,e=x.length;t<e;++t){const e=x[t],r=e.start;for(let t=r,i=r+e.count;t<i;t+=3)M(n[t+0]),M(n[t+1]),M(n[t+2])}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(void 0!==e){let n=this.getAttribute("normal");if(void 0===n)n=new tn(new Float32Array(3*e.count),3),this.setAttribute("normal",n);else for(let t=0,e=n.count;t<e;t++)n.setXYZ(t,0,0,0);const r=new kt,i=new kt,a=new kt,o=new kt,s=new kt,A=new kt,l=new kt,u=new kt;if(t)for(let c=0,h=t.count;c<h;c+=3){const h=t.getX(c+0),f=t.getX(c+1),d=t.getX(c+2);r.fromBufferAttribute(e,h),i.fromBufferAttribute(e,f),a.fromBufferAttribute(e,d),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),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 t=0,o=e.count;t<o;t+=3)r.fromBufferAttribute(e,t+0),i.fromBufferAttribute(e,t+1),a.fromBufferAttribute(e,t+2),l.subVectors(a,i),u.subVectors(r,i),l.cross(u),n.setXYZ(t+0,l.x,l.y,l.z),n.setXYZ(t+1,l.x,l.y,l.z),n.setXYZ(t+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.mergeBufferGeometries() instead."),this}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)cn.fromBufferAttribute(t,e),cn.normalize(),t.setXYZ(e,cn.x,cn.y,cn.z)}toNonIndexed(){function t(t,e){const n=t.array,r=t.itemSize,i=t.normalized,a=new n.constructor(e.length*r);let o=0,s=0;for(let i=0,A=e.length;i<A;i++){o=t.isInterleavedBufferAttribute?e[i]*t.data.stride+t.offset:e[i]*r;for(let t=0;t<r;t++)a[s++]=n[o++]}return new tn(a,r,i)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new hn,n=this.index.array,r=this.attributes;for(const i in r){const a=t(r[i],n);e.setAttribute(i,a)}const i=this.morphAttributes;for(const r in i){const a=[],o=i[r];for(let e=0,r=o.length;e<r;e++){const r=t(o[e],n);a.push(r)}e.morphAttributes[r]=a}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let t=0,n=a.length;t<n;t++){const n=a[t];e.addGroup(n.start,n.count,n.materialIndex)}return e}toJSON(){const t={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,""!==this.name&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}t.data={attributes:{}};const e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const e in n){const r=n[e];t.data.attributes[e]=r.toJSON(t.data)}const r={};let i=!1;for(const e in this.morphAttributes){const n=this.morphAttributes[e],a=[];for(let e=0,r=n.length;e<r;e++){const r=n[e];a.push(r.toJSON(t.data))}a.length>0&&(r[e]=a,i=!0)}i&&(t.data.morphAttributes=r,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return null!==o&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return(new this.constructor).copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;null!==n&&this.setIndex(n.clone(e));const r=t.attributes;for(const t in r){const n=r[t];this.setAttribute(t,n.clone(e))}const i=t.morphAttributes;for(const t in i){const n=[],r=i[t];for(let t=0,i=r.length;t<i;t++)n.push(r[t].clone(e));this.morphAttributes[t]=n}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let t=0,e=a.length;t<e;t++){const e=a[t];this.addGroup(e.start,e.count,e.materialIndex)}const o=t.boundingBox;null!==o&&(this.boundingBox=o.clone());const s=t.boundingSphere;return null!==s&&(this.boundingSphere=s.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,void 0!==t.parameters&&(this.parameters=Object.assign({},t.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}const fn=new he,dn=new ce,pn=new re,mn=new kt,gn=new kt,vn=new kt,xn=new kt,yn=new kt,bn=new kt,_n=new kt,wn=new kt,Mn=new kt,Sn=new ut,En=new ut,Tn=new ut,Cn=new kt,Pn=new kt;class Dn extends Be{constructor(t=new hn,e=new Je){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=t.material,this.geometry=t.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}raycast(t,e){const n=this.geometry,r=this.material,i=this.matrixWorld;if(void 0===r)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),pn.copy(n.boundingSphere),pn.applyMatrix4(i),!1===t.ray.intersectsSphere(pn))return;if(fn.copy(i).invert(),dn.copy(t.ray).applyMatrix4(fn),null!==n.boundingBox&&!1===dn.intersectsBox(n.boundingBox))return;let a;const o=n.index,s=n.attributes.position,A=n.morphAttributes.position,l=n.morphTargetsRelative,u=n.attributes.uv,c=n.attributes.uv2,h=n.groups,f=n.drawRange;if(null!==o)if(Array.isArray(r))for(let n=0,i=h.length;n<i;n++){const i=h[n],d=r[i.materialIndex];for(let n=Math.max(i.start,f.start),r=Math.min(o.count,Math.min(i.start+i.count,f.start+f.count));n<r;n+=3){const r=o.getX(n),h=o.getX(n+1),f=o.getX(n+2);a=Ln(this,d,t,dn,s,A,l,u,c,r,h,f),a&&(a.faceIndex=Math.floor(n/3),a.face.materialIndex=i.materialIndex,e.push(a))}}else{for(let n=Math.max(0,f.start),i=Math.min(o.count,f.start+f.count);n<i;n+=3){const i=o.getX(n),h=o.getX(n+1),f=o.getX(n+2);a=Ln(this,r,t,dn,s,A,l,u,c,i,h,f),a&&(a.faceIndex=Math.floor(n/3),e.push(a))}}else if(void 0!==s)if(Array.isArray(r))for(let n=0,i=h.length;n<i;n++){const i=h[n],o=r[i.materialIndex];for(let n=Math.max(i.start,f.start),r=Math.min(s.count,Math.min(i.start+i.count,f.start+f.count));n<r;n+=3){a=Ln(this,o,t,dn,s,A,l,u,c,n,n+1,n+2),a&&(a.faceIndex=Math.floor(n/3),a.face.materialIndex=i.materialIndex,e.push(a))}}else{for(let n=Math.max(0,f.start),i=Math.min(s.count,f.start+f.count);n<i;n+=3){a=Ln(this,r,t,dn,s,A,l,u,c,n,n+1,n+2),a&&(a.faceIndex=Math.floor(n/3),e.push(a))}}}}function Ln(t,e,n,r,i,a,o,s,A,l,u,c){mn.fromBufferAttribute(i,l),gn.fromBufferAttribute(i,u),vn.fromBufferAttribute(i,c);const h=t.morphTargetInfluences;if(a&&h){_n.set(0,0,0),wn.set(0,0,0),Mn.set(0,0,0);for(let t=0,e=a.length;t<e;t++){const e=h[t],n=a[t];0!==e&&(xn.fromBufferAttribute(n,l),yn.fromBufferAttribute(n,u),bn.fromBufferAttribute(n,c),o?(_n.addScaledVector(xn,e),wn.addScaledVector(yn,e),Mn.addScaledVector(bn,e)):(_n.addScaledVector(xn.sub(mn),e),wn.addScaledVector(yn.sub(gn),e),Mn.addScaledVector(bn.sub(vn),e)))}mn.add(_n),gn.add(wn),vn.add(Mn)}t.isSkinnedMesh&&(t.boneTransform(l,mn),t.boneTransform(u,gn),t.boneTransform(c,vn));const f=function(t,e,n,r,i,a,o,s){let A;if(A=1===e.side?r.intersectTriangle(o,a,i,!0,s):r.intersectTriangle(i,a,o,2!==e.side,s),null===A)return null;Pn.copy(s),Pn.applyMatrix4(t.matrixWorld);const l=n.ray.origin.distanceTo(Pn);return l<n.near||l>n.far?null:{distance:l,point:Pn.clone(),object:t}}(t,e,n,r,mn,gn,vn,Cn);if(f){s&&(Sn.fromBufferAttribute(s,l),En.fromBufferAttribute(s,u),Tn.fromBufferAttribute(s,c),f.uv=Xe.getUV(Cn,mn,gn,vn,Sn,En,Tn,new ut)),A&&(Sn.fromBufferAttribute(A,l),En.fromBufferAttribute(A,u),Tn.fromBufferAttribute(A,c),f.uv2=Xe.getUV(Cn,mn,gn,vn,Sn,En,Tn,new ut));const t={a:l,b:u,c:c,normal:new kt,materialIndex:0};Xe.getNormal(mn,gn,vn,t.normal),f.face=t}return f}class qn extends hn{constructor(t=1,e=1,n=1,r=1,i=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,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=[],u=[];let c=0,h=0;function f(t,e,n,r,i,a,f,d,p,m,g){const v=a/p,x=f/m,y=a/2,b=f/2,_=d/2,w=p+1,M=m+1;let S=0,E=0;const T=new kt;for(let a=0;a<M;a++){const o=a*x-b;for(let s=0;s<w;s++){const c=s*v-y;T[t]=c*r,T[e]=o*i,T[n]=_,A.push(T.x,T.y,T.z),T[t]=0,T[e]=0,T[n]=d>0?1:-1,l.push(T.x,T.y,T.z),u.push(s/p),u.push(1-a/m),S+=1}}for(let t=0;t<m;t++)for(let e=0;e<p;e++){const n=c+e+w*t,r=c+e+w*(t+1),i=c+(e+1)+w*(t+1),a=c+(e+1)+w*t;s.push(n,r,a),s.push(r,i,a),E+=6}o.addGroup(h,E,g),h+=E,c+=S}f("z","y","x",-1,-1,n,e,t,a,i,0),f("z","y","x",1,-1,n,e,-t,a,i,1),f("x","z","y",1,1,t,n,e,r,a,2),f("x","z","y",1,-1,t,n,-e,r,a,3),f("x","y","z",1,-1,t,e,n,r,i,4),f("x","y","z",-1,-1,t,e,-n,r,i,5),this.setIndex(s),this.setAttribute("position",new rn(A,3)),this.setAttribute("normal",new rn(l,3)),this.setAttribute("uv",new rn(u,2))}static fromJSON(t){return new qn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}function Rn(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?e[n][r]=i.clone():Array.isArray(i)?e[n][r]=i.slice():e[n][r]=i}}return e}function On(t){const e={};for(let n=0;n<t.length;n++){const r=Rn(t[n]);for(const t in r)e[t]=r[t]}return e}const In={clone:Rn,merge:On};class kn extends Ze{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.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!==t&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Rn(t.uniforms),this.uniformsGroups=function(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const n in this.uniforms){const r=this.uniforms[n].value;r&&r.isTexture?e.uniforms[n]={type:"t",value:r.toJSON(t).uuid}:r&&r.isColor?e.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?e.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?e.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?e.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?e.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?e.uniforms[n]={type:"m4",value:r.toArray()}:e.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const n={};for(const t in this.extensions)!0===this.extensions[t]&&(n[t]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class Bn extends Be{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new he,this.projectionMatrix=new he,this.projectionMatrixInverse=new he}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(-e[8],-e[9],-e[10]).normalize()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class Nn extends Bn{constructor(t=50,e=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=2*tt*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*$*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*tt*Math.atan(Math.tan(.5*$*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(t,e,n,r,i,a){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(.5*$*this.fov)/this.zoom,n=2*e,r=this.aspect*n,i=-.5*r;const a=this.view;if(null!==this.view&&this.view.enabled){const t=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/t,e-=a.offsetY*n/o,r*=a.width/t,n*=a.height/o}const o=this.filmOffset;0!==o&&(i+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,e,e-n,t,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const zn=90;class Un extends Be{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n;const r=new Nn(zn,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new kt(1,0,0)),this.add(r);const i=new Nn(zn,1,t,e);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new kt(-1,0,0)),this.add(i);const a=new Nn(zn,1,t,e);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(new kt(0,1,0)),this.add(a);const o=new Nn(zn,1,t,e);o.layers=this.layers,o.up.set(0,0,-1),o.lookAt(new kt(0,-1,0)),this.add(o);const s=new Nn(zn,1,t,e);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new kt(0,0,1)),this.add(s);const A=new Nn(zn,1,t,e);A.layers=this.layers,A.up.set(0,-1,0),A.lookAt(new kt(0,0,-1)),this.add(A)}update(t,e){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[r,i,a,o,s,A]=this.children,l=t.getRenderTarget(),u=t.toneMapping,c=t.xr.enabled;t.toneMapping=0,t.xr.enabled=!1;const h=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0),t.render(e,r),t.setRenderTarget(n,1),t.render(e,i),t.setRenderTarget(n,2),t.render(e,a),t.setRenderTarget(n,3),t.render(e,o),t.setRenderTarget(n,4),t.render(e,s),n.texture.generateMipmaps=h,t.setRenderTarget(n,5),t.render(e,A),t.setRenderTarget(l),t.toneMapping=u,t.xr.enabled=c,n.texture.needsPMREMUpdate=!0}}class Fn extends Dt{constructor(t,e,n,r,i,a,o,s,A,l){super(t=void 0!==t?t:[],e=void 0!==e?e:b,n,r,i,a,o,s,A,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Gn extends qt{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},r=[n,n,n,n,n,n];this.texture=new Fn(r,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:C}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include <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 qn(5,5,5),i=new kn({name:"CubemapFromEquirect",uniforms:Rn(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=e;const a=new Dn(r,i),o=e.minFilter;e.minFilter===P&&(e.minFilter=C);return new Un(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,r){const i=t.getRenderTarget();for(let i=0;i<6;i++)t.setRenderTarget(this,i),t.clear(e,n,r);t.setRenderTarget(i)}}const jn=new kt,Hn=new kt,Vn=new ct;class Wn{constructor(t=new kt(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,r){return this.normal.set(t,e,n),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const r=jn.subVectors(n,e).cross(Hn.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)}intersectLine(t,e){const n=t.delta(jn),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const i=-(t.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:e.copy(n).multiplyScalar(i).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Vn.getNormalMatrix(t),r=this.coplanarPoint(jn).applyMatrix4(t),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const Qn=new re,Xn=new kt;class Yn{constructor(t=new Wn,e=new Wn,n=new Wn,r=new Wn,i=new Wn,a=new Wn){this.planes=[t,e,n,r,i,a]}set(t,e,n,r,i,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t){const e=this.planes,n=t.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],A=n[5],l=n[6],u=n[7],c=n[8],h=n[9],f=n[10],d=n[11],p=n[12],m=n[13],g=n[14],v=n[15];return e[0].setComponents(o-r,u-s,d-c,v-p).normalize(),e[1].setComponents(o+r,u+s,d+c,v+p).normalize(),e[2].setComponents(o+i,u+A,d+h,v+m).normalize(),e[3].setComponents(o-i,u-A,d-h,v-m).normalize(),e[4].setComponents(o-a,u-l,d-f,v-g).normalize(),e[5].setComponents(o+a,u+l,d+f,v+g).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),Qn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(Qn)}intersectsSprite(t){return Qn.center.set(0,0,0),Qn.radius=.7071067811865476,Qn.applyMatrix4(t.matrixWorld),this.intersectsSphere(Qn)}intersectsSphere(t){const e=this.planes,n=t.center,r=-t.radius;for(let t=0;t<6;t++){if(e[t].distanceToPoint(n)<r)return!1}return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const r=e[n];if(Xn.x=r.normal.x>0?t.max.x:t.min.x,Xn.y=r.normal.y>0?t.max.y:t.min.y,Xn.z=r.normal.z>0?t.max.z:t.min.z,r.distanceToPoint(Xn)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function Zn(){let t=null,e=!1,n=null,r=null;function i(e,a){n(e,a),r=t.requestAnimationFrame(i)}return{start:function(){!0!==e&&null!==n&&(r=t.requestAnimationFrame(i),e=!0)},stop:function(){t.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(t){n=t},setContext:function(e){t=e}}}function Jn(t,e){const n=e.isWebGL2,r=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),r.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const n=r.get(e);n&&(t.deleteBuffer(n.buffer),r.delete(e))},update:function(e,i){if(e.isGLBufferAttribute){const t=r.get(e);return void((!t||t.version<e.version)&&r.set(e,{buffer:e.buffer,type:e.type,bytesPerElement:e.elementSize,version:e.version}))}e.isInterleavedBufferAttribute&&(e=e.data);const a=r.get(e);void 0===a?r.set(e,function(e,r){const i=e.array,a=e.usage,o=t.createBuffer();let s;if(t.bindBuffer(r,o),t.bufferData(r,i,a),e.onUploadCallback(),i instanceof Float32Array)s=5126;else if(i instanceof Uint16Array)if(e.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:e.version}}(e,i)):a.version<e.version&&(!function(e,r,i){const a=r.array,o=r.updateRange;t.bindBuffer(i,e),-1===o.count?t.bufferSubData(i,0,a):(n?t.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a,o.offset,o.count):t.bufferSubData(i,o.offset*a.BYTES_PER_ELEMENT,a.subarray(o.offset,o.offset+o.count)),o.count=-1)}(a.buffer,e,i),a.version=e.version)}}}class Kn extends hn{constructor(t=1,e=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:r};const i=t/2,a=e/2,o=Math.floor(n),s=Math.floor(r),A=o+1,l=s+1,u=t/o,c=e/s,h=[],f=[],d=[],p=[];for(let t=0;t<l;t++){const e=t*c-a;for(let n=0;n<A;n++){const r=n*u-i;f.push(r,-e,0),d.push(0,0,1),p.push(n/o),p.push(1-t/s)}}for(let t=0;t<s;t++)for(let e=0;e<o;e++){const n=e+A*t,r=e+A*(t+1),i=e+1+A*(t+1),a=e+1+A*t;h.push(n,r,a),h.push(r,i,a)}this.setIndex(h),this.setAttribute("position",new rn(f,3)),this.setAttribute("normal",new rn(d,3)),this.setAttribute("uv",new rn(p,2))}static fromJSON(t){return new Kn(t.width,t.height,t.widthSegments,t.heightSegments)}}const $n={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).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, vUv2 ).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:"vec3 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}\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}\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float 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\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( V * D );\n}\n#ifdef USE_IRIDESCENCE\n\tvec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {\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 = mix( F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence );\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\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}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",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( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = 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}",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\tvec2 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, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\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, vUv2 );\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\n#define Material_LightProbeLOD( material )\t(0)",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( 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, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).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_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_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 );\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( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );\n\t#else\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\t#endif\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 *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\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 *= all( bvec2( 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 *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = 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, vUv );\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\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\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_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",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 = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",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 linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform 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\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying 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_SPOT_LIGHT_COORDS > 0 )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_COORDS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_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\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, 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, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\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, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, 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\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 framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef texture2DLodEXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( 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:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || 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;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tgl_FragColor = vec4( mix( pow( gl_FragColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), gl_FragColor.rgb * 0.0773993808, vec3( lessThanEqual( gl_FragColor.rgb, vec3( 0.04045 ) ) ) ), gl_FragColor.w );\n\t#endif\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;\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\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 <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 <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 <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 <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 <uv2_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 <uv2_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 <uv2_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, vUv2 );\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 <uv2_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 <uv2_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 <uv2_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( TANGENTSPACE_NORMALMAP )\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( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include <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 <uv2_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 <uv2_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 <uv2_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 <uv2_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 <uv2_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 SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_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_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_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 <bsdfs>\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 <uv2_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 <uv2_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 <uv2_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>\nvoid main() {\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 <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 <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 <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\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}"},tr={common:{diffuse:{value:new St(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new ct},uv2Transform:{value:new ct},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new ut(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new St(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 St(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new ct}},sprite:{diffuse:{value:new St(16777215)},opacity:{value:1},center:{value:new ut(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new ct}}},er={basic:{uniforms:On([tr.common,tr.specularmap,tr.envmap,tr.aomap,tr.lightmap,tr.fog]),vertexShader:$n.meshbasic_vert,fragmentShader:$n.meshbasic_frag},lambert:{uniforms:On([tr.common,tr.specularmap,tr.envmap,tr.aomap,tr.lightmap,tr.emissivemap,tr.bumpmap,tr.normalmap,tr.displacementmap,tr.fog,tr.lights,{emissive:{value:new St(0)}}]),vertexShader:$n.meshlambert_vert,fragmentShader:$n.meshlambert_frag},phong:{uniforms:On([tr.common,tr.specularmap,tr.envmap,tr.aomap,tr.lightmap,tr.emissivemap,tr.bumpmap,tr.normalmap,tr.displacementmap,tr.fog,tr.lights,{emissive:{value:new St(0)},specular:{value:new St(1118481)},shininess:{value:30}}]),vertexShader:$n.meshphong_vert,fragmentShader:$n.meshphong_frag},standard:{uniforms:On([tr.common,tr.envmap,tr.aomap,tr.lightmap,tr.emissivemap,tr.bumpmap,tr.normalmap,tr.displacementmap,tr.roughnessmap,tr.metalnessmap,tr.fog,tr.lights,{emissive:{value:new St(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$n.meshphysical_vert,fragmentShader:$n.meshphysical_frag},toon:{uniforms:On([tr.common,tr.aomap,tr.lightmap,tr.emissivemap,tr.bumpmap,tr.normalmap,tr.displacementmap,tr.gradientmap,tr.fog,tr.lights,{emissive:{value:new St(0)}}]),vertexShader:$n.meshtoon_vert,fragmentShader:$n.meshtoon_frag},matcap:{uniforms:On([tr.common,tr.bumpmap,tr.normalmap,tr.displacementmap,tr.fog,{matcap:{value:null}}]),vertexShader:$n.meshmatcap_vert,fragmentShader:$n.meshmatcap_frag},points:{uniforms:On([tr.points,tr.fog]),vertexShader:$n.points_vert,fragmentShader:$n.points_frag},dashed:{uniforms:On([tr.common,tr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$n.linedashed_vert,fragmentShader:$n.linedashed_frag},depth:{uniforms:On([tr.common,tr.displacementmap]),vertexShader:$n.depth_vert,fragmentShader:$n.depth_frag},normal:{uniforms:On([tr.common,tr.bumpmap,tr.normalmap,tr.displacementmap,{opacity:{value:1}}]),vertexShader:$n.meshnormal_vert,fragmentShader:$n.meshnormal_frag},sprite:{uniforms:On([tr.sprite,tr.fog]),vertexShader:$n.sprite_vert,fragmentShader:$n.sprite_frag},background:{uniforms:{uvTransform:{value:new ct},t2D:{value:null}},vertexShader:$n.background_vert,fragmentShader:$n.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0}},vertexShader:$n.backgroundCube_vert,fragmentShader:$n.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$n.cube_vert,fragmentShader:$n.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$n.equirect_vert,fragmentShader:$n.equirect_frag},distanceRGBA:{uniforms:On([tr.common,tr.displacementmap,{referencePosition:{value:new kt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$n.distanceRGBA_vert,fragmentShader:$n.distanceRGBA_frag},shadow:{uniforms:On([tr.lights,tr.fog,{color:{value:new St(0)},opacity:{value:1}}]),vertexShader:$n.shadow_vert,fragmentShader:$n.shadow_frag}};function nr(t,e,n,r,i,a,o){const s=new St(0);let A,l,u=!0===a?0:1,c=null,h=0,f=null;function d(t,e){r.buffers.color.setClear(t.r,t.g,t.b,e,o)}return{getClearColor:function(){return s},setClearColor:function(t,e=1){s.set(t),u=e,d(s,u)},getClearAlpha:function(){return u},setClearAlpha:function(t){u=t,d(s,u)},render:function(r,a){let o=!1,p=!0===a.isScene?a.background:null;if(p&&p.isTexture){p=(a.backgroundBlurriness>0?n:e).get(p)}const m=t.xr,g=m.getSession&&m.getSession();g&&"additive"===g.environmentBlendMode&&(p=null),null===p?d(s,u):p&&p.isColor&&(d(p,1),o=!0),(t.autoClear||o)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),p&&(p.isCubeTexture||p.mapping===w)?(void 0===l&&(l=new Dn(new qn(1,1,1),new kn({name:"BackgroundCubeMaterial",uniforms:Rn(er.backgroundCube.uniforms),vertexShader:er.backgroundCube.vertexShader,fragmentShader:er.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(t,e,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,c===p&&h===p.version&&f===t.toneMapping||(l.material.needsUpdate=!0,c=p,h=p.version,f=t.toneMapping),l.layers.enableAll(),r.unshift(l,l.geometry,l.material,0,0,null)):p&&p.isTexture&&(void 0===A&&(A=new Dn(new Kn(2,2),new kn({name:"BackgroundMaterial",uniforms:Rn(er.background.uniforms),vertexShader:er.background.vertexShader,fragmentShader:er.background.fragmentShader,side:0,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,!0===p.matrixAutoUpdate&&p.updateMatrix(),A.material.uniforms.uvTransform.value.copy(p.matrix),c===p&&h===p.version&&f===t.toneMapping||(A.material.needsUpdate=!0,c=p,h=p.version,f=t.toneMapping),A.layers.enableAll(),r.unshift(A,A.geometry,A.material,0,0,null))}}}function rr(t,e,n,r){const i=t.getParameter(34921),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||null!==a,s={},A=f(null);let l=A,u=!1;function c(e){return r.isWebGL2?t.bindVertexArray(e):a.bindVertexArrayOES(e)}function h(e){return r.isWebGL2?t.deleteVertexArray(e):a.deleteVertexArrayOES(e)}function f(t){const e=[],n=[],r=[];for(let t=0;t<i;t++)e[t]=0,n[t]=0,r[t]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:e,enabledAttributes:n,attributeDivisors:r,object:t,attributes:{},index:null}}function d(){const t=l.newAttributes;for(let e=0,n=t.length;e<n;e++)t[e]=0}function p(t){m(t,0)}function m(n,i){const a=l.newAttributes,o=l.enabledAttributes,s=l.attributeDivisors;if(a[n]=1,0===o[n]&&(t.enableVertexAttribArray(n),o[n]=1),s[n]!==i){(r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,i),s[n]=i}}function g(){const e=l.newAttributes,n=l.enabledAttributes;for(let r=0,i=n.length;r<i;r++)n[r]!==e[r]&&(t.disableVertexAttribArray(r),n[r]=0)}function v(e,n,i,a,o,s){!0!==r.isWebGL2||5124!==i&&5125!==i?t.vertexAttribPointer(e,n,i,a,o,s):t.vertexAttribIPointer(e,n,i,o,s)}function x(){y(),u=!0,l!==A&&(l=A,c(l.object))}function y(){A.geometry=null,A.program=null,A.wireframe=!1}return{setup:function(i,A,h,x,y){let b=!1;if(o){const e=function(e,n,i){const o=!0===i.wireframe;let A=s[e.id];void 0===A&&(A={},s[e.id]=A);let l=A[n.id];void 0===l&&(l={},A[n.id]=l);let u=l[o];void 0===u&&(u=f(r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()),l[o]=u);return u}(x,h,A);l!==e&&(l=e,c(l.object)),b=function(t,e,n,r){const i=l.attributes,a=e.attributes;let o=0;const s=n.getAttributes();for(const e in s){if(s[e].location>=0){const n=i[e];let r=a[e];if(void 0===r&&("instanceMatrix"===e&&t.instanceMatrix&&(r=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(r=t.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,x,h,y),b&&function(t,e,n,r){const i={},a=e.attributes;let o=0;const s=n.getAttributes();for(const e in s){if(s[e].location>=0){let n=a[e];void 0===n&&("instanceMatrix"===e&&t.instanceMatrix&&(n=t.instanceMatrix),"instanceColor"===e&&t.instanceColor&&(n=t.instanceColor));const r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[e]=r,o++}}l.attributes=i,l.attributesNum=o,l.index=r}(i,x,h,y)}else{const t=!0===A.wireframe;l.geometry===x.id&&l.program===h.id&&l.wireframe===t||(l.geometry=x.id,l.program=h.id,l.wireframe=t,b=!0)}null!==y&&n.update(y,34963),(b||u)&&(u=!1,function(i,a,o,s){if(!1===r.isWebGL2&&(i.isInstancedMesh||s.isInstancedBufferGeometry)&&null===e.get("ANGLE_instanced_arrays"))return;d();const A=s.attributes,l=o.getAttributes(),u=a.defaultAttributeValues;for(const e in l){const r=l[e];if(r.location>=0){let a=A[e];if(void 0===a&&("instanceMatrix"===e&&i.instanceMatrix&&(a=i.instanceMatrix),"instanceColor"===e&&i.instanceColor&&(a=i.instanceColor)),void 0!==a){const e=a.normalized,o=a.itemSize,A=n.get(a);if(void 0===A)continue;const l=A.buffer,u=A.type,c=A.bytesPerElement;if(a.isInterleavedBufferAttribute){const n=a.data,A=n.stride,h=a.offset;if(n.isInstancedInterleavedBuffer){for(let t=0;t<r.locationSize;t++)m(r.location+t,n.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let t=0;t<r.locationSize;t++)p(r.location+t);t.bindBuffer(34962,l);for(let t=0;t<r.locationSize;t++)v(r.location+t,o/r.locationSize,u,e,A*c,(h+o/r.locationSize*t)*c)}else{if(a.isInstancedBufferAttribute){for(let t=0;t<r.locationSize;t++)m(r.location+t,a.meshPerAttribute);!0!==i.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=a.meshPerAttribute*a.count)}else for(let t=0;t<r.locationSize;t++)p(r.location+t);t.bindBuffer(34962,l);for(let t=0;t<r.locationSize;t++)v(r.location+t,o/r.locationSize,u,e,o*c,o/r.locationSize*t*c)}}else if(void 0!==u){const n=u[e];if(void 0!==n)switch(n.length){case 2:t.vertexAttrib2fv(r.location,n);break;case 3:t.vertexAttrib3fv(r.location,n);break;case 4:t.vertexAttrib4fv(r.location,n);break;default:t.vertexAttrib1fv(r.location,n)}}}}g()}(i,A,h,x),null!==y&&t.bindBuffer(34963,n.get(y).buffer))},reset:x,resetDefaultState:y,dispose:function(){x();for(const t in s){const e=s[t];for(const t in e){const n=e[t];for(const t in n)h(n[t].object),delete n[t];delete e[t]}delete s[t]}},releaseStatesOfGeometry:function(t){if(void 0===s[t.id])return;const e=s[t.id];for(const t in e){const n=e[t];for(const t in n)h(n[t].object),delete n[t];delete e[t]}delete s[t.id]},releaseStatesOfProgram:function(t){for(const e in s){const n=s[e];if(void 0===n[t.id])continue;const r=n[t.id];for(const t in r)h(r[t].object),delete r[t];delete n[t.id]}},initAttributes:d,enableAttribute:p,disableUnusedAttributes:g}}function ir(t,e,n,r){const i=r.isWebGL2;let a;this.setMode=function(t){a=t},this.render=function(e,r){t.drawArrays(a,e,r),n.update(r,a,1)},this.renderInstances=function(r,o,s){if(0===s)return;let A,l;if(i)A=t,l="drawArraysInstanced";else if(A=e.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 ar(t,e,n){let r;function i(e){if("highp"===e){if(t.getShaderPrecisionFormat(35633,36338).precision>0&&t.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";e="mediump"}return"mediump"===e&&t.getShaderPrecisionFormat(35633,36337).precision>0&&t.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const a="undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&t instanceof WebGL2ComputeRenderingContext;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||e.has("WEBGL_draw_buffers"),l=!0===n.logarithmicDepthBuffer,u=t.getParameter(34930),c=t.getParameter(35660),h=t.getParameter(3379),f=t.getParameter(34076),d=t.getParameter(34921),p=t.getParameter(36347),m=t.getParameter(36348),g=t.getParameter(36349),v=c>0,x=a||e.has("OES_texture_float");return{isWebGL2:a,drawBuffers:A,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===e.has("EXT_texture_filter_anisotropic")){const n=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:i,precision:o,logarithmicDepthBuffer:l,maxTextures:u,maxVertexTextures:c,maxTextureSize:h,maxCubemapSize:f,maxAttributes:d,maxVertexUniforms:p,maxVaryings:m,maxFragmentUniforms:g,vertexTextures:v,floatFragmentTextures:x,floatVertexTextures:v&&x,maxSamples:a?t.getParameter(36183):0}}function or(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new Wn,s=new ct,A={value:null,needsUpdate:!1};function l(){A.value!==n&&(A.value=n,A.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function u(t,n,r,i){const a=null!==t?t.length:0;let l=null;if(0!==a){if(l=A.value,!0!==i||null===l){const e=r+4*a,i=n.matrixWorldInverse;s.getNormalMatrix(i),(null===l||l.length<e)&&(l=new Float32Array(e));for(let e=0,n=r;e!==a;++e,n+=4)o.copy(t[e]).applyMatrix4(i,s),o.normal.toArray(l,n),l[n+3]=o.constant}A.value=l,A.needsUpdate=!0}return e.numPlanes=a,e.numIntersection=0,l}this.uniform=A,this.numPlanes=0,this.numIntersection=0,this.init=function(t,e,a){const o=0!==t.length||e||0!==r||i;return i=e,n=u(t,a,0),r=t.length,o},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1,l()},this.setState=function(e,o,s){const c=e.clippingPlanes,h=e.clipIntersection,f=e.clipShadows,d=t.get(e);if(!i||null===c||0===c.length||a&&!f)a?u(null):l();else{const t=a?0:r,e=4*t;let i=d.clippingState||null;A.value=i,i=u(c,o,e,s);for(let t=0;t!==e;++t)i[t]=n[t];d.clippingState=i,this.numIntersection=h?this.numPlanes:0,this.numPlanes+=t}}}function sr(t){let e=new WeakMap;function n(t,e){return 303===e?t.mapping=b:304===e&&(t.mapping=_),t}function r(t){const n=t.target;n.removeEventListener("dispose",r);const i=e.get(n);void 0!==i&&(e.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(e.has(i)){return n(e.get(i).texture,i.mapping)}{const a=i.image;if(a&&a.height>0){const o=new Gn(a.height/2);return o.fromEquirectangularTexture(t,i),e.set(i,o),i.addEventListener("dispose",r),n(o.texture,i.mapping)}return null}}}return i},dispose:function(){e=new WeakMap}}}er.physical={uniforms:On([er.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new ut(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new St(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new ut},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new St(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new St(1,1,1)},specularColorMap:{value:null}}]),vertexShader:$n.meshphysical_vert,fragmentShader:$n.meshphysical_frag};class Ar extends Bn{constructor(t=-1,e=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=null===t.view?null:Object.assign({},t.view),this}setViewOffset(t,e,n,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=t,this.view.fullHeight=e,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 t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let i=n-t,a=n+t,o=r+e,s=r-e;if(null!==this.view&&this.view.enabled){const t=(this.right-this.left)/this.view.fullWidth/this.zoom,e=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=t*this.view.offsetX,a=i+t*this.view.width,o-=e*this.view.offsetY,s=o-e*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,null!==this.view&&(e.object.view=Object.assign({},this.view)),e}}const lr=[.125,.215,.35,.446,.526,.582],ur=20,cr=new Ar,hr=new St;let fr=null;const dr=(1+Math.sqrt(5))/2,pr=1/dr,mr=[new kt(1,1,1),new kt(-1,1,1),new kt(1,1,-1),new kt(-1,1,-1),new kt(0,dr,pr),new kt(0,dr,-pr),new kt(pr,0,dr),new kt(-pr,0,dr),new kt(dr,pr,0),new kt(-dr,pr,0)];class gr{constructor(t){this._renderer=t,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(t,e=0,n=.1,r=100){fr=this._renderer.getRenderTarget(),this._setSize(256);const i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(t,n,r,i),e>0&&this._blur(i,0,0,e),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=br(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=yr(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodPlanes.length;t++)this._lodPlanes[t].dispose()}_cleanup(t){this._renderer.setRenderTarget(fr),t.scissorTest=!1,xr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===b||t.mapping===_?this._setSize(0===t.image.length?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),fr=this._renderer.getRenderTarget();const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:C,minFilter:C,generateMipmaps:!1,type:R,format:I,encoding:G,depthBuffer:!1},r=vr(t,e,n);if(null===this._pingPongRenderTarget||this._pingPongRenderTarget.width!==t){null!==this._pingPongRenderTarget&&this._dispose(),this._pingPongRenderTarget=vr(t,e,n);const{_lodMax:r}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=function(t){const e=[],n=[],r=[];let i=t;const a=t-4+1+lr.length;for(let o=0;o<a;o++){const a=Math.pow(2,i);n.push(a);let s=1/a;o>t-4?s=lr[o-t+4-1]:0===o&&(s=0),r.push(s);const A=1/(a-2),l=-A,u=1+A,c=[l,l,u,l,u,u,l,l,u,u,l,u],h=6,f=6,d=3,p=2,m=1,g=new Float32Array(d*f*h),v=new Float32Array(p*f*h),x=new Float32Array(m*f*h);for(let t=0;t<h;t++){const e=t%3*2/3-1,n=t>2?0:-1,r=[e,n,0,e+2/3,n,0,e+2/3,n+1,0,e,n,0,e+2/3,n+1,0,e,n+1,0];g.set(r,d*f*t),v.set(c,p*f*t);const i=[t,t,t,t,t,t];x.set(i,m*f*t)}const y=new hn;y.setAttribute("position",new tn(g,d)),y.setAttribute("uv",new tn(v,p)),y.setAttribute("faceIndex",new tn(x,m)),e.push(y),i>4&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}(r)),this._blurMaterial=function(t,e,n){const r=new Float32Array(ur),i=new kt(0,1,0);return new kn({name:"SphericalGaussianBlur",defines:{n:ur,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${t}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:_r(),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:0,depthTest:!1,depthWrite:!1})}(r,t,e)}return r}_compileMaterial(t){const e=new Dn(this._lodPlanes[0],t);this._renderer.compile(e,cr)}_sceneToCubeUV(t,e,n,r){const i=new Nn(90,1,e,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(hr),s.toneMapping=0,s.autoClear=!1;const u=new Je({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1}),c=new Dn(new qn,u);let h=!1;const f=t.background;f?f.isColor&&(u.color.copy(f),t.background=null,h=!0):(u.color.copy(hr),h=!0);for(let e=0;e<6;e++){const n=e%3;0===n?(i.up.set(0,a[e],0),i.lookAt(o[e],0,0)):1===n?(i.up.set(0,0,a[e]),i.lookAt(0,o[e],0)):(i.up.set(0,a[e],0),i.lookAt(0,0,o[e]));const A=this._cubeSize;xr(r,n*A,e>2?A:0,A,A),s.setRenderTarget(r),h&&s.render(c,i),s.render(t,i)}c.geometry.dispose(),c.material.dispose(),s.toneMapping=l,s.autoClear=A,t.background=f}_textureToCubeUV(t,e){const n=this._renderer,r=t.mapping===b||t.mapping===_;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=br()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===t.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=yr());const i=r?this._cubemapMaterial:this._equirectMaterial,a=new Dn(this._lodPlanes[0],i);i.uniforms.envMap.value=t;const o=this._cubeSize;xr(e,0,0,3*o,2*o),n.setRenderTarget(e),n.render(a,cr)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;for(let e=1;e<this._lodPlanes.length;e++){const n=Math.sqrt(this._sigmas[e]*this._sigmas[e]-this._sigmas[e-1]*this._sigmas[e-1]),r=mr[(e-1)%mr.length];this._blur(t,e-1,e,n,r)}e.autoClear=n}_blur(t,e,n,r,i){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,r,"latitudinal",i),this._halfBlur(a,t,n,n,r,"longitudinal",i)}_halfBlur(t,e,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 Dn(this._lodPlanes[r],A),u=A.uniforms,c=this._sizeLods[n]-1,h=isFinite(i)?Math.PI/(2*c):2*Math.PI/39,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 20`);const p=[];let m=0;for(let t=0;t<ur;++t){const e=t/f,n=Math.exp(-e*e/2);p.push(n),0===t?m+=n:t<d&&(m+=2*n)}for(let t=0;t<p.length;t++)p[t]=p[t]/m;u.envMap.value=t.texture,u.samples.value=d,u.weights.value=p,u.latitudinal.value="latitudinal"===a,o&&(u.poleAxis.value=o);const{_lodMax:g}=this;u.dTheta.value=h,u.mipInt.value=g-n;const v=this._sizeLods[r];xr(e,3*v*(r>g-4?r-g+4:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(e),s.render(l,cr)}}function vr(t,e,n){const r=new qt(t,e,n);return r.texture.mapping=w,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function xr(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function yr(){return new kn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:_r(),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:0,depthTest:!1,depthWrite:!1})}function br(){return new kn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:_r(),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:0,depthTest:!1,depthWrite:!1})}function _r(){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 wr(t){let e=new WeakMap,n=null;function r(t){const n=t.target;n.removeEventListener("dispose",r);const i=e.get(n);void 0!==i&&(e.delete(n),i.dispose())}return{get:function(i){if(i&&i.isTexture){const a=i.mapping,o=303===a||304===a,s=a===b||a===_;if(o||s){if(i.isRenderTargetTexture&&!0===i.needsPMREMUpdate){i.needsPMREMUpdate=!1;let r=e.get(i);return null===n&&(n=new gr(t)),r=o?n.fromEquirectangular(i,r):n.fromCubemap(i,r),e.set(i,r),r.texture}if(e.has(i))return e.get(i).texture;{const a=i.image;if(o&&a&&a.height>0||s&&a&&function(t){let e=0;const n=6;for(let r=0;r<n;r++)void 0!==t[r]&&e++;return e===n}(a)){null===n&&(n=new gr(t));const a=o?n.fromEquirectangular(i):n.fromCubemap(i);return e.set(i,a),i.addEventListener("dispose",r),a.texture}return null}}}return i},dispose:function(){e=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function Mr(t){const e={};function n(n){if(void 0!==e[n])return e[n];let r;switch(n){case"WEBGL_depth_texture":r=t.getExtension("WEBGL_depth_texture")||t.getExtension("MOZ_WEBGL_depth_texture")||t.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=t.getExtension("WEBGL_compressed_texture_s3tc")||t.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=t.getExtension(n)}return e[n]=r,r}return{has:function(t){return null!==n(t)},init:function(t){t.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(t){const e=n(t);return null===e&&console.warn("THREE.WebGLRenderer: "+t+" extension not supported."),e}}}function Sr(t,e,n,r){const i={},a=new WeakMap;function o(t){const s=t.target;null!==s.index&&e.remove(s.index);for(const t in s.attributes)e.remove(s.attributes[t]);s.removeEventListener("dispose",o),delete i[s.id];const A=a.get(s);A&&(e.remove(A),a.delete(s)),r.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(t){const n=[],r=t.index,i=t.attributes.position;let o=0;if(null!==r){const t=r.array;o=r.version;for(let e=0,r=t.length;e<r;e+=3){const r=t[e+0],i=t[e+1],a=t[e+2];n.push(r,i,i,a,a,r)}}else{const t=i.array;o=i.version;for(let e=0,r=t.length/3-1;e<r;e+=3){const t=e+0,r=e+1,i=e+2;n.push(t,r,r,i,i,t)}}const s=new(ht(n)?nn:en)(n,1);s.version=o;const A=a.get(t);A&&e.remove(A),a.set(t,s)}return{get:function(t,e){return!0===i[e.id]||(e.addEventListener("dispose",o),i[e.id]=!0,n.memory.geometries++),e},update:function(t){const n=t.attributes;for(const t in n)e.update(n[t],34962);const r=t.morphAttributes;for(const t in r){const n=r[t];for(let t=0,r=n.length;t<r;t++)e.update(n[t],34962)}},getWireframeAttribute:function(t){const e=a.get(t);if(e){const n=t.index;null!==n&&e.version<n.version&&s(t)}else s(t);return a.get(t)}}}function Er(t,e,n,r){const i=r.isWebGL2;let a,o,s;this.setMode=function(t){a=t},this.setIndex=function(t){o=t.type,s=t.bytesPerElement},this.render=function(e,r){t.drawElements(a,r,o,e*s),n.update(r,a,1)},this.renderInstances=function(r,A,l){if(0===l)return;let u,c;if(i)u=t,c="drawElementsInstanced";else if(u=e.get("ANGLE_instanced_arrays"),c="drawElementsInstancedANGLE",null===u)return void console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");u[c](a,A,o,r*s,l),n.update(A,a,l)}}function Tr(t){const e={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:e,programs:null,autoReset:!0,reset:function(){e.frame++,e.calls=0,e.triangles=0,e.points=0,e.lines=0},update:function(t,n,r){switch(e.calls++,n){case 4:e.triangles+=r*(t/3);break;case 1:e.lines+=r*(t/2);break;case 3:e.lines+=r*(t-1);break;case 2:e.lines+=r*t;break;case 0:e.points+=r*t;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",n)}}}}function Cr(t,e){return t[0]-e[0]}function Pr(t,e){return Math.abs(e[1])-Math.abs(t[1])}function Dr(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new Lt,s=[];for(let t=0;t<8;t++)s[t]=[t,0];return{update:function(A,l,u,c){const h=A.morphTargetInfluences;if(!0===e.isWebGL2){const f=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,d=void 0!==f?f.length:0;let p=a.get(l);if(void 0===p||p.count!==d){void 0!==p&&p.texture.dispose();const v=void 0!==l.morphAttributes.position,x=void 0!==l.morphAttributes.normal,y=void 0!==l.morphAttributes.color,b=l.morphAttributes.position||[],_=l.morphAttributes.normal||[],w=l.morphAttributes.color||[];let M=0;!0===v&&(M=1),!0===x&&(M=2),!0===y&&(M=3);let S=l.attributes.position.count*M,E=1;S>e.maxTextureSize&&(E=Math.ceil(S/e.maxTextureSize),S=e.maxTextureSize);const T=new Float32Array(S*E*4*d),C=new Rt(T,S,E,d);C.type=q,C.needsUpdate=!0;const P=4*M;for(let L=0;L<d;L++){const R=b[L],O=_[L],I=w[L],k=S*E*4*L;for(let B=0;B<R.count;B++){const N=B*P;!0===v&&(o.fromBufferAttribute(R,B),T[k+N+0]=o.x,T[k+N+1]=o.y,T[k+N+2]=o.z,T[k+N+3]=0),!0===x&&(o.fromBufferAttribute(O,B),T[k+N+4]=o.x,T[k+N+5]=o.y,T[k+N+6]=o.z,T[k+N+7]=0),!0===y&&(o.fromBufferAttribute(I,B),T[k+N+8]=o.x,T[k+N+9]=o.y,T[k+N+10]=o.z,T[k+N+11]=4===I.itemSize?o.w:1)}}function D(){C.dispose(),a.delete(l),l.removeEventListener("dispose",D)}p={count:d,texture:C,size:new ut(S,E)},a.set(l,p),l.addEventListener("dispose",D)}let m=0;for(let z=0;z<h.length;z++)m+=h[z];const g=l.morphTargetsRelative?1:1-m;c.getUniforms().setValue(t,"morphTargetBaseInfluence",g),c.getUniforms().setValue(t,"morphTargetInfluences",h),c.getUniforms().setValue(t,"morphTargetsTexture",p.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",p.size)}else{const U=void 0===h?0:h.length;let F=r[l.id];if(void 0===F||F.length!==U){F=[];for(let W=0;W<U;W++)F[W]=[W,0];r[l.id]=F}for(let Q=0;Q<U;Q++){const X=F[Q];X[0]=Q,X[1]=h[Q]}F.sort(Pr);for(let Y=0;Y<8;Y++)Y<U&&F[Y][1]?(s[Y][0]=F[Y][0],s[Y][1]=F[Y][1]):(s[Y][0]=Number.MAX_SAFE_INTEGER,s[Y][1]=0);s.sort(Cr);const G=l.morphAttributes.position,j=l.morphAttributes.normal;let H=0;for(let Z=0;Z<8;Z++){const J=s[Z],K=J[0],$=J[1];K!==Number.MAX_SAFE_INTEGER&&$?(G&&l.getAttribute("morphTarget"+Z)!==G[K]&&l.setAttribute("morphTarget"+Z,G[K]),j&&l.getAttribute("morphNormal"+Z)!==j[K]&&l.setAttribute("morphNormal"+Z,j[K]),i[Z]=$,H+=$):(G&&!0===l.hasAttribute("morphTarget"+Z)&&l.deleteAttribute("morphTarget"+Z),j&&!0===l.hasAttribute("morphNormal"+Z)&&l.deleteAttribute("morphNormal"+Z),i[Z]=0)}const V=l.morphTargetsRelative?1:1-H;c.getUniforms().setValue(t,"morphTargetBaseInfluence",V),c.getUniforms().setValue(t,"morphTargetInfluences",i)}}}}function Lr(t,e,n,r){let i=new WeakMap;function a(t){const e=t.target;e.removeEventListener("dispose",a),n.remove(e.instanceMatrix),null!==e.instanceColor&&n.remove(e.instanceColor)}return{update:function(t){const o=r.render.frame,s=t.geometry,A=e.get(t,s);return i.get(A)!==o&&(e.update(A),i.set(A,o)),t.isInstancedMesh&&(!1===t.hasEventListener("dispose",a)&&t.addEventListener("dispose",a),n.update(t.instanceMatrix,34962),null!==t.instanceColor&&n.update(t.instanceColor,34962)),A},dispose:function(){i=new WeakMap}}}const qr=new Dt,Rr=new Rt,Or=new Ot,Ir=new Fn,kr=[],Br=[],Nr=new Float32Array(16),zr=new Float32Array(9),Ur=new Float32Array(4);function Fr(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=kr[i];if(void 0===a&&(a=new Float32Array(i),kr[i]=a),0!==e){r.toArray(a,0);for(let r=1,i=0;r!==e;++r)i+=n,t[r].toArray(a,i)}return a}function Gr(t,e){if(t.length!==e.length)return!1;for(let n=0,r=t.length;n<r;n++)if(t[n]!==e[n])return!1;return!0}function jr(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function Hr(t,e){let n=Br[e];void 0===n&&(n=new Int32Array(e),Br[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function Vr(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Wr(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Gr(n,e))return;t.uniform2fv(this.addr,e),jr(n,e)}}function Qr(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(void 0!==e.r)n[0]===e.r&&n[1]===e.g&&n[2]===e.b||(t.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Gr(n,e))return;t.uniform3fv(this.addr,e),jr(n,e)}}function Xr(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Gr(n,e))return;t.uniform4fv(this.addr,e),jr(n,e)}}function Yr(t,e){const n=this.cache,r=e.elements;if(void 0===r){if(Gr(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),jr(n,e)}else{if(Gr(n,r))return;Ur.set(r),t.uniformMatrix2fv(this.addr,!1,Ur),jr(n,r)}}function Zr(t,e){const n=this.cache,r=e.elements;if(void 0===r){if(Gr(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),jr(n,e)}else{if(Gr(n,r))return;zr.set(r),t.uniformMatrix3fv(this.addr,!1,zr),jr(n,r)}}function Jr(t,e){const n=this.cache,r=e.elements;if(void 0===r){if(Gr(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),jr(n,e)}else{if(Gr(n,r))return;Nr.set(r),t.uniformMatrix4fv(this.addr,!1,Nr),jr(n,r)}}function Kr(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function $r(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2i(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Gr(n,e))return;t.uniform2iv(this.addr,e),jr(n,e)}}function ti(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3i(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Gr(n,e))return;t.uniform3iv(this.addr,e),jr(n,e)}}function ei(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4i(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Gr(n,e))return;t.uniform4iv(this.addr,e),jr(n,e)}}function ni(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function ri(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y||(t.uniform2ui(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Gr(n,e))return;t.uniform2uiv(this.addr,e),jr(n,e)}}function ii(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z||(t.uniform3ui(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else{if(Gr(n,e))return;t.uniform3uiv(this.addr,e),jr(n,e)}}function ai(t,e){const n=this.cache;if(void 0!==e.x)n[0]===e.x&&n[1]===e.y&&n[2]===e.z&&n[3]===e.w||(t.uniform4ui(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Gr(n,e))return;t.uniform4uiv(this.addr,e),jr(n,e)}}function oi(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2D(e||qr,i)}function si(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||Or,i)}function Ai(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||Ir,i)}function li(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||Rr,i)}function ui(t,e){t.uniform1fv(this.addr,e)}function ci(t,e){const n=Fr(e,this.size,2);t.uniform2fv(this.addr,n)}function hi(t,e){const n=Fr(e,this.size,3);t.uniform3fv(this.addr,n)}function fi(t,e){const n=Fr(e,this.size,4);t.uniform4fv(this.addr,n)}function di(t,e){const n=Fr(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function pi(t,e){const n=Fr(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function mi(t,e){const n=Fr(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function gi(t,e){t.uniform1iv(this.addr,e)}function vi(t,e){t.uniform2iv(this.addr,e)}function xi(t,e){t.uniform3iv(this.addr,e)}function yi(t,e){t.uniform4iv(this.addr,e)}function bi(t,e){t.uniform1uiv(this.addr,e)}function _i(t,e){t.uniform2uiv(this.addr,e)}function wi(t,e){t.uniform3uiv(this.addr,e)}function Mi(t,e){t.uniform4uiv(this.addr,e)}function Si(t,e,n){const r=this.cache,i=e.length,a=Hr(n,i);Gr(r,a)||(t.uniform1iv(this.addr,a),jr(r,a));for(let t=0;t!==i;++t)n.setTexture2D(e[t]||qr,a[t])}function Ei(t,e,n){const r=this.cache,i=e.length,a=Hr(n,i);Gr(r,a)||(t.uniform1iv(this.addr,a),jr(r,a));for(let t=0;t!==i;++t)n.setTexture3D(e[t]||Or,a[t])}function Ti(t,e,n){const r=this.cache,i=e.length,a=Hr(n,i);Gr(r,a)||(t.uniform1iv(this.addr,a),jr(r,a));for(let t=0;t!==i;++t)n.setTextureCube(e[t]||Ir,a[t])}function Ci(t,e,n){const r=this.cache,i=e.length,a=Hr(n,i);Gr(r,a)||(t.uniform1iv(this.addr,a),jr(r,a));for(let t=0;t!==i;++t)n.setTexture2DArray(e[t]||Rr,a[t])}class Pi{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.setValue=function(t){switch(t){case 5126:return Vr;case 35664:return Wr;case 35665:return Qr;case 35666:return Xr;case 35674:return Yr;case 35675:return Zr;case 35676:return Jr;case 5124:case 35670:return Kr;case 35667:case 35671:return $r;case 35668:case 35672:return ti;case 35669:case 35673:return ei;case 5125:return ni;case 36294:return ri;case 36295:return ii;case 36296:return ai;case 35678:case 36198:case 36298:case 36306:case 35682:return oi;case 35679:case 36299:case 36307:return si;case 35680:case 36300:case 36308:case 36293:return Ai;case 36289:case 36303:case 36311:case 36292:return li}}(e.type)}}class Di{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.size=e.size,this.setValue=function(t){switch(t){case 5126:return ui;case 35664:return ci;case 35665:return hi;case 35666:return fi;case 35674:return di;case 35675:return pi;case 35676:return mi;case 5124:case 35670:return gi;case 35667:case 35671:return vi;case 35668:case 35672:return xi;case 35669:case 35673:return yi;case 5125:return bi;case 36294:return _i;case 36295:return wi;case 36296:return Mi;case 35678:case 36198:case 36298:case 36306:case 35682:return Si;case 35679:case 36299:case 36307:return Ei;case 35680:case 36300:case 36308:case 36293:return Ti;case 36289:case 36303:case 36311:case 36292:return Ci}}(e.type)}}class Li{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const r=this.seq;for(let i=0,a=r.length;i!==a;++i){const a=r[i];a.setValue(t,e[a.id],n)}}}const qi=/(\w+)(\])?(\[|\.)?/g;function Ri(t,e){t.seq.push(e),t.map[e.id]=e}function Oi(t,e,n){const r=t.name,i=r.length;for(qi.lastIndex=0;;){const a=qi.exec(r),o=qi.lastIndex;let s=a[1];const A="]"===a[2],l=a[3];if(A&&(s|=0),void 0===l||"["===l&&o+2===i){Ri(n,void 0===l?new Pi(s,t,e):new Di(s,t,e));break}{let t=n.map[s];void 0===t&&(t=new Li(s),Ri(n,t)),n=t}}}class Ii{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,35718);for(let r=0;r<n;++r){const n=t.getActiveUniform(e,r);Oi(n,t.getUniformLocation(e,n.name),this)}}setValue(t,e,n,r){const i=this.map[e];void 0!==i&&i.setValue(t,n,r)}setOptional(t,e,n){const r=e[n];void 0!==r&&this.setValue(t,n,r)}static upload(t,e,n,r){for(let i=0,a=e.length;i!==a;++i){const a=e[i],o=n[a.id];!1!==o.needsUpdate&&a.setValue(t,o.value,r)}}static seqWithValue(t,e){const n=[];for(let r=0,i=t.length;r!==i;++r){const i=t[r];i.id in e&&n.push(i)}return n}}function ki(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}let Bi=0;function Ni(t,e,n){const r=t.getShaderParameter(e,35713),i=t.getShaderInfoLog(e).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(t,e){const n=t.split("\n"),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let t=i;t<a;t++){const i=t+1;r.push(`${i===e?">":" "} ${i}: ${n[t]}`)}return r.join("\n")}(t.getShaderSource(e),r)}return i}function zi(t,e){const n=function(t){switch(t){case G:return["Linear","( value )"];case j:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",t),["Linear","( value )"]}}(e);return"vec4 "+t+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function Ui(t,e){let n;switch(e){case 1:n="Linear";break;case 2:n="Reinhard";break;case 3:n="OptimizedCineon";break;case 4:n="ACESFilmic";break;case 5:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Fi(t){return""!==t}function Gi(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function ji(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Hi=/^[ \t]*#include +<([\w\d./]+)>/gm;function Vi(t){return t.replace(Hi,Wi)}function Wi(t,e){const n=$n[e];if(void 0===n)throw new Error("Can not resolve #include <"+e+">");return Vi(n)}const Qi=/#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 Xi(t){return t.replace(Qi,Yi)}function Yi(t,e,n,r){let i="";for(let t=parseInt(e);t<parseInt(n);t++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+t+" ]").replace(/UNROLLED_LOOP_INDEX/g,t);return i}function Zi(t){let e="precision "+t.precision+" float;\nprecision "+t.precision+" int;";return"highp"===t.precision?e+="\n#define HIGH_PRECISION":"mediump"===t.precision?e+="\n#define MEDIUM_PRECISION":"lowp"===t.precision&&(e+="\n#define LOW_PRECISION"),e}function Ji(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,s=n.fragmentShader;const A=function(t){let e="SHADOWMAP_TYPE_BASIC";return 1===t.shadowMapType?e="SHADOWMAP_TYPE_PCF":2===t.shadowMapType?e="SHADOWMAP_TYPE_PCF_SOFT":3===t.shadowMapType&&(e="SHADOWMAP_TYPE_VSM"),e}(n),l=function(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case b:case _:e="ENVMAP_TYPE_CUBE";break;case w:e="ENVMAP_TYPE_CUBE_UV"}return e}(n),u=function(t){let e="ENVMAP_MODE_REFLECTION";t.envMap&&t.envMapMode===_&&(e="ENVMAP_MODE_REFRACTION");return e}(n),c=function(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case 0:e="ENVMAP_BLENDING_MULTIPLY";break;case 1:e="ENVMAP_BLENDING_MIX";break;case 2:e="ENVMAP_BLENDING_ADD"}return e}(n),h=function(t){const e=t.envMapCubeUVHeight;if(null===e)return null;const n=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:r,maxMip:n}}(n),f=n.isWebGL2?"":function(t){return[t.extensionDerivatives||t.envMapCubeUVHeight||t.bumpMap||t.tangentSpaceNormalMap||t.clearcoatNormalMap||t.flatShading||"physical"===t.shaderID?"#extension GL_OES_standard_derivatives : enable":"",(t.extensionFragDepth||t.logarithmicDepthBuffer)&&t.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",t.extensionDrawBuffers&&t.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(t.extensionShaderTextureLOD||t.envMap||t.transmission)&&t.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Fi).join("\n")}(n),d=function(t){const e=[];for(const n in t){const r=t[n];!1!==r&&e.push("#define "+n+" "+r)}return e.join("\n")}(a),p=i.createProgram();let m,g,v=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(m=[d].filter(Fi).join("\n"),m.length>0&&(m+="\n"),g=[f,d].filter(Fi).join("\n"),g.length>0&&(g+="\n")):(m=[Zi(n),"#define SHADER_NAME "+n.shaderName,d,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"",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 "+u:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.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(Fi).join("\n"),g=[f,Zi(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 "+u:"",n.envMap?"#define "+c:"",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.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+A:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?$n.tonemapping_pars_fragment:"",0!==n.toneMapping?Ui("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",$n.encodings_pars_fragment,zi("linearToOutputTexel",n.outputEncoding),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(Fi).join("\n")),o=Vi(o),o=Gi(o,n),o=ji(o,n),s=Vi(s),s=Gi(s,n),s=ji(s,n),o=Xi(o),s=Xi(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===X?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===X?"":"#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 x=v+g+s,y=ki(i,35633,v+m+o),M=ki(i,35632,x);if(i.attachShader(p,y),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),t.debug.checkShaderErrors){const t=i.getProgramInfoLog(p).trim(),e=i.getShaderInfoLog(y).trim(),n=i.getShaderInfoLog(M).trim();let r=!0,a=!0;if(!1===i.getProgramParameter(p,35714)){r=!1;const e=Ni(i,y,"vertex"),n=Ni(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):""!==e&&""!==n||(a=!1);a&&(this.diagnostics={runnable:r,programLog:t,vertexShader:{log:e,prefix:m},fragmentShader:{log:n,prefix:g}})}let S,E;return i.deleteShader(y),i.deleteShader(M),this.getUniforms=function(){return void 0===S&&(S=new Ii(i,p)),S},this.getAttributes=function(){return void 0===E&&(E=function(t,e){const n={},r=t.getProgramParameter(e,35721);for(let i=0;i<r;i++){const r=t.getActiveAttrib(e,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:t.getAttribLocation(e,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=Bi++,this.cacheKey=e,this.usedTimes=1,this.program=p,this.vertexShader=y,this.fragmentShader=M,this}let Ki=0;class $i{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,r=this._getShaderStage(e),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return!1===a.has(r)&&(a.add(r),r.usedTimes++),!1===a.has(i)&&(a.add(i),i.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const t of e)t.usedTimes--,0===t.usedTimes&&this.shaderCache.delete(t.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return void 0===n&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return void 0===n&&(n=new ta(t),e.set(t,n)),n}}class ta{constructor(t){this.id=Ki++,this.code=t,this.usedTimes=0}}function ea(t,e,n,r,i,a,o){const s=new we,A=new $i,l=[],u=i.isWebGL2,c=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"};return{getParameters:function(a,s,l,p,m){const g=p.fog,v=m.geometry,x=a.isMeshStandardMaterial?p.environment:null,y=(a.isMeshStandardMaterial?n:e).get(a.envMap||x),b=y&&y.mapping===w?y.image.height:null,_=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 M=v.morphAttributes.position||v.morphAttributes.normal||v.morphAttributes.color,S=void 0!==M?M.length:0;let E,T,C,P,D=0;if(void 0!==v.morphAttributes.position&&(D=1),void 0!==v.morphAttributes.normal&&(D=2),void 0!==v.morphAttributes.color&&(D=3),_){const t=er[_];E=t.vertexShader,T=t.fragmentShader}else E=a.vertexShader,T=a.fragmentShader,A.update(a),C=A.getVertexShaderID(a),P=A.getFragmentShaderID(a);const L=t.getRenderTarget(),q=a.alphaTest>0,R=a.clearcoat>0,O=a.iridescence>0;return{isWebGL2:u,shaderID:_,shaderName:a.type,vertexShader:E,fragmentShader:T,defines:a.defines,customVertexShaderID:C,customFragmentShaderID:P,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,instancing:!0===m.isInstancedMesh,instancingColor:!0===m.isInstancedMesh&&null!==m.instanceColor,supportsVertexTextures:h,outputEncoding:null===L?t.outputEncoding:!0===L.isXRRenderTarget?L.texture.encoding:G,map:!!a.map,matcap:!!a.matcap,envMap:!!y,envMapMode:y&&y.mapping,envMapCubeUVHeight:b,lightMap:!!a.lightMap,aoMap:!!a.aoMap,emissiveMap:!!a.emissiveMap,bumpMap:!!a.bumpMap,normalMap:!!a.normalMap,objectSpaceNormalMap:1===a.normalMapType,tangentSpaceNormalMap:0===a.normalMapType,decodeVideoTexture:!!a.map&&!0===a.map.isVideoTexture&&a.map.encoding===j,clearcoat:R,clearcoatMap:R&&!!a.clearcoatMap,clearcoatRoughnessMap:R&&!!a.clearcoatRoughnessMap,clearcoatNormalMap:R&&!!a.clearcoatNormalMap,iridescence:O,iridescenceMap:O&&!!a.iridescenceMap,iridescenceThicknessMap:O&&!!a.iridescenceThicknessMap,displacementMap:!!a.displacementMap,roughnessMap:!!a.roughnessMap,metalnessMap:!!a.metalnessMap,specularMap:!!a.specularMap,specularIntensityMap:!!a.specularIntensityMap,specularColorMap:!!a.specularColorMap,opaque:!1===a.transparent&&1===a.blending,alphaMap:!!a.alphaMap,alphaTest:q,gradientMap:!!a.gradientMap,sheen:a.sheen>0,sheenColorMap:!!a.sheenColorMap,sheenRoughnessMap:!!a.sheenRoughnessMap,transmission:a.transmission>0,transmissionMap:!!a.transmissionMap,thicknessMap:!!a.thicknessMap,combine:a.combine,vertexTangents:!!a.normalMap&&!!v.attributes.tangent,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!v.attributes.color&&4===v.attributes.color.itemSize,vertexUvs:!!(a.map||a.bumpMap||a.normalMap||a.specularMap||a.alphaMap||a.emissiveMap||a.roughnessMap||a.metalnessMap||a.clearcoatMap||a.clearcoatRoughnessMap||a.clearcoatNormalMap||a.iridescenceMap||a.iridescenceThicknessMap||a.displacementMap||a.transmissionMap||a.thicknessMap||a.specularIntensityMap||a.specularColorMap||a.sheenColorMap||a.sheenRoughnessMap),uvsVertexOnly:!(a.map||a.bumpMap||a.normalMap||a.specularMap||a.alphaMap||a.emissiveMap||a.roughnessMap||a.metalnessMap||a.clearcoatNormalMap||a.iridescenceMap||a.iridescenceThicknessMap||a.transmission>0||a.transmissionMap||a.thicknessMap||a.specularIntensityMap||a.specularColorMap||a.sheen>0||a.sheenColorMap||a.sheenRoughnessMap||!a.displacementMap),fog:!!g,useFog:!0===a.fog,fogExp2:g&&g.isFogExp2,flatShading:!!a.flatShading,sizeAttenuation:a.sizeAttenuation,logarithmicDepthBuffer:c,skinning:!0===m.isSkinnedMesh,morphTargets:void 0!==v.morphAttributes.position,morphNormals:void 0!==v.morphAttributes.normal,morphColors:void 0!==v.morphAttributes.color,morphTargetsCount:S,morphTextureStride:D,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:t.shadowMap.enabled&&l.length>0,shadowMapType:t.shadowMap.type,toneMapping:a.toneMapped?t.toneMapping:0,physicallyCorrectLights:t.physicallyCorrectLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:!!a.depthPacking,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:a.extensions&&a.extensions.derivatives,extensionFragDepth:a.extensions&&a.extensions.fragDepth,extensionDrawBuffers:a.extensions&&a.extensions.drawBuffers,extensionShaderTextureLOD:a.extensions&&a.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||r.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function(e){const n=[];if(e.shaderID?n.push(e.shaderID):(n.push(e.customVertexShaderID),n.push(e.customFragmentShaderID)),void 0!==e.defines)for(const t in e.defines)n.push(t),n.push(e.defines[t]);return!1===e.isRawShaderMaterial&&(!function(t,e){t.push(e.precision),t.push(e.outputEncoding),t.push(e.envMapMode),t.push(e.envMapCubeUVHeight),t.push(e.combine),t.push(e.vertexUvs),t.push(e.fogExp2),t.push(e.sizeAttenuation),t.push(e.morphTargetsCount),t.push(e.morphAttributeCount),t.push(e.numDirLights),t.push(e.numPointLights),t.push(e.numSpotLights),t.push(e.numSpotLightMaps),t.push(e.numHemiLights),t.push(e.numRectAreaLights),t.push(e.numDirLightShadows),t.push(e.numPointLightShadows),t.push(e.numSpotLightShadows),t.push(e.numSpotLightShadowsWithMaps),t.push(e.shadowMapType),t.push(e.toneMapping),t.push(e.numClippingPlanes),t.push(e.numClipIntersection),t.push(e.depthPacking)}(n,e),function(t,e){s.disableAll(),e.isWebGL2&&s.enable(0);e.supportsVertexTextures&&s.enable(1);e.instancing&&s.enable(2);e.instancingColor&&s.enable(3);e.map&&s.enable(4);e.matcap&&s.enable(5);e.envMap&&s.enable(6);e.lightMap&&s.enable(7);e.aoMap&&s.enable(8);e.emissiveMap&&s.enable(9);e.bumpMap&&s.enable(10);e.normalMap&&s.enable(11);e.objectSpaceNormalMap&&s.enable(12);e.tangentSpaceNormalMap&&s.enable(13);e.clearcoat&&s.enable(14);e.clearcoatMap&&s.enable(15);e.clearcoatRoughnessMap&&s.enable(16);e.clearcoatNormalMap&&s.enable(17);e.iridescence&&s.enable(18);e.iridescenceMap&&s.enable(19);e.iridescenceThicknessMap&&s.enable(20);e.displacementMap&&s.enable(21);e.specularMap&&s.enable(22);e.roughnessMap&&s.enable(23);e.metalnessMap&&s.enable(24);e.gradientMap&&s.enable(25);e.alphaMap&&s.enable(26);e.alphaTest&&s.enable(27);e.vertexColors&&s.enable(28);e.vertexAlphas&&s.enable(29);e.vertexUvs&&s.enable(30);e.vertexTangents&&s.enable(31);e.uvsVertexOnly&&s.enable(32);t.push(s.mask),s.disableAll(),e.fog&&s.enable(0);e.useFog&&s.enable(1);e.flatShading&&s.enable(2);e.logarithmicDepthBuffer&&s.enable(3);e.skinning&&s.enable(4);e.morphTargets&&s.enable(5);e.morphNormals&&s.enable(6);e.morphColors&&s.enable(7);e.premultipliedAlpha&&s.enable(8);e.shadowMapEnabled&&s.enable(9);e.physicallyCorrectLights&&s.enable(10);e.doubleSided&&s.enable(11);e.flipSided&&s.enable(12);e.useDepthPacking&&s.enable(13);e.dithering&&s.enable(14);e.specularIntensityMap&&s.enable(15);e.specularColorMap&&s.enable(16);e.transmission&&s.enable(17);e.transmissionMap&&s.enable(18);e.thicknessMap&&s.enable(19);e.sheen&&s.enable(20);e.sheenColorMap&&s.enable(21);e.sheenRoughnessMap&&s.enable(22);e.decodeVideoTexture&&s.enable(23);e.opaque&&s.enable(24);t.push(s.mask)}(n,e),n.push(t.outputEncoding)),n.push(e.customProgramCacheKey),n.join()},getUniforms:function(t){const e=d[t.type];let n;if(e){const t=er[e];n=In.clone(t.uniforms)}else n=t.uniforms;return n},acquireProgram:function(e,n){let r;for(let t=0,e=l.length;t<e;t++){const e=l[t];if(e.cacheKey===n){r=e,++r.usedTimes;break}}return void 0===r&&(r=new Ji(t,n,e,a),l.push(r)),r},releaseProgram:function(t){if(0==--t.usedTimes){const e=l.indexOf(t);l[e]=l[l.length-1],l.pop(),t.destroy()}},releaseShaderCache:function(t){A.remove(t)},programs:l,dispose:function(){A.dispose()}}}function na(){let t=new WeakMap;return{get:function(e){let n=t.get(e);return void 0===n&&(n={},t.set(e,n)),n},remove:function(e){t.delete(e)},update:function(e,n,r){t.get(e)[n]=r},dispose:function(){t=new WeakMap}}}function ra(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.material.id!==e.material.id?t.material.id-e.material.id:t.z!==e.z?t.z-e.z:t.id-e.id}function ia(t,e){return t.groupOrder!==e.groupOrder?t.groupOrder-e.groupOrder:t.renderOrder!==e.renderOrder?t.renderOrder-e.renderOrder:t.z!==e.z?e.z-t.z:t.id-e.id}function aa(){const t=[];let e=0;const n=[],r=[],i=[];function a(n,r,i,a,o,s){let A=t[e];return void 0===A?(A={id:n.id,object:n,geometry:r,material:i,groupOrder:a,renderOrder:n.renderOrder,z:o,group:s},t[e]=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),e++,A}return{opaque:n,transmissive:r,transparent:i,init:function(){e=0,n.length=0,r.length=0,i.length=0},push:function(t,e,o,s,A,l){const u=a(t,e,o,s,A,l);o.transmission>0?r.push(u):!0===o.transparent?i.push(u):n.push(u)},unshift:function(t,e,o,s,A,l){const u=a(t,e,o,s,A,l);o.transmission>0?r.unshift(u):!0===o.transparent?i.unshift(u):n.unshift(u)},finish:function(){for(let n=e,r=t.length;n<r;n++){const e=t[n];if(null===e.id)break;e.id=null,e.object=null,e.geometry=null,e.material=null,e.group=null}},sort:function(t,e){n.length>1&&n.sort(t||ra),r.length>1&&r.sort(e||ia),i.length>1&&i.sort(e||ia)}}}function oa(){let t=new WeakMap;return{get:function(e,n){const r=t.get(e);let i;return void 0===r?(i=new aa,t.set(e,[i])):n>=r.length?(i=new aa,r.push(i)):i=r[n],i},dispose:function(){t=new WeakMap}}}function sa(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new kt,color:new St};break;case"SpotLight":n={position:new kt,direction:new kt,color:new St,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new kt,color:new St,distance:0,decay:0};break;case"HemisphereLight":n={direction:new kt,skyColor:new St,groundColor:new St};break;case"RectAreaLight":n={color:new St,position:new kt,halfWidth:new kt,halfHeight:new kt}}return t[e.id]=n,n}}}let Aa=0;function la(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function ua(t,e){const n=new sa,r=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let n;switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ut};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ut,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}}(),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 t=0;t<9;t++)i.probe.push(new kt);const a=new kt,o=new he,s=new he;return{setup:function(a,o){let s=0,A=0,l=0;for(let t=0;t<9;t++)i.probe[t].set(0,0,0);let u=0,c=0,h=0,f=0,d=0,p=0,m=0,g=0,v=0,x=0;a.sort(la);const y=!0!==o?Math.PI:1;for(let t=0,e=a.length;t<e;t++){const e=a[t],o=e.color,b=e.intensity,_=e.distance,w=e.shadow&&e.shadow.map?e.shadow.map.texture:null;if(e.isAmbientLight)s+=o.r*b*y,A+=o.g*b*y,l+=o.b*b*y;else if(e.isLightProbe)for(let t=0;t<9;t++)i.probe[t].addScaledVector(e.sh.coefficients[t],b);else if(e.isDirectionalLight){const t=n.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*y),e.castShadow){const t=e.shadow,n=r.get(e);n.shadowBias=t.bias,n.shadowNormalBias=t.normalBias,n.shadowRadius=t.radius,n.shadowMapSize=t.mapSize,i.directionalShadow[u]=n,i.directionalShadowMap[u]=w,i.directionalShadowMatrix[u]=e.shadow.matrix,p++}i.directional[u]=t,u++}else if(e.isSpotLight){const t=n.get(e);t.position.setFromMatrixPosition(e.matrixWorld),t.color.copy(o).multiplyScalar(b*y),t.distance=_,t.coneCos=Math.cos(e.angle),t.penumbraCos=Math.cos(e.angle*(1-e.penumbra)),t.decay=e.decay,i.spot[h]=t;const a=e.shadow;if(e.map&&(i.spotLightMap[v]=e.map,v++,a.updateMatrices(e),e.castShadow&&x++),i.spotLightMatrix[h]=a.matrix,e.castShadow){const t=r.get(e);t.shadowBias=a.bias,t.shadowNormalBias=a.normalBias,t.shadowRadius=a.radius,t.shadowMapSize=a.mapSize,i.spotShadow[h]=t,i.spotShadowMap[h]=w,g++}h++}else if(e.isRectAreaLight){const t=n.get(e);t.color.copy(o).multiplyScalar(b),t.halfWidth.set(.5*e.width,0,0),t.halfHeight.set(0,.5*e.height,0),i.rectArea[f]=t,f++}else if(e.isPointLight){const t=n.get(e);if(t.color.copy(e.color).multiplyScalar(e.intensity*y),t.distance=e.distance,t.decay=e.decay,e.castShadow){const t=e.shadow,n=r.get(e);n.shadowBias=t.bias,n.shadowNormalBias=t.normalBias,n.shadowRadius=t.radius,n.shadowMapSize=t.mapSize,n.shadowCameraNear=t.camera.near,n.shadowCameraFar=t.camera.far,i.pointShadow[c]=n,i.pointShadowMap[c]=w,i.pointShadowMatrix[c]=e.shadow.matrix,m++}i.point[c]=t,c++}else if(e.isHemisphereLight){const t=n.get(e);t.skyColor.copy(e.color).multiplyScalar(b*y),t.groundColor.copy(e.groundColor).multiplyScalar(b*y),i.hemi[d]=t,d++}}f>0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(i.rectAreaLTC1=tr.LTC_FLOAT_1,i.rectAreaLTC2=tr.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=tr.LTC_HALF_1,i.rectAreaLTC2=tr.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 b=i.hash;b.directionalLength===u&&b.pointLength===c&&b.spotLength===h&&b.rectAreaLength===f&&b.hemiLength===d&&b.numDirectionalShadows===p&&b.numPointShadows===m&&b.numSpotShadows===g&&b.numSpotMaps===v||(i.directional.length=u,i.spot.length=h,i.rectArea.length=f,i.point.length=c,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-x,i.spotLightMap.length=v,i.numSpotLightShadowsWithMaps=x,b.directionalLength=u,b.pointLength=c,b.spotLength=h,b.rectAreaLength=f,b.hemiLength=d,b.numDirectionalShadows=p,b.numPointShadows=m,b.numSpotShadows=g,b.numSpotMaps=v,i.version=Aa++)},setupView:function(t,e){let n=0,r=0,A=0,l=0,u=0;const c=e.matrixWorldInverse;for(let e=0,h=t.length;e<h;e++){const h=t[e];if(h.isDirectionalLight){const t=i.directional[n];t.direction.setFromMatrixPosition(h.matrixWorld),a.setFromMatrixPosition(h.target.matrixWorld),t.direction.sub(a),t.direction.transformDirection(c),n++}else if(h.isSpotLight){const t=i.spot[A];t.position.setFromMatrixPosition(h.matrixWorld),t.position.applyMatrix4(c),t.direction.setFromMatrixPosition(h.matrixWorld),a.setFromMatrixPosition(h.target.matrixWorld),t.direction.sub(a),t.direction.transformDirection(c),A++}else if(h.isRectAreaLight){const t=i.rectArea[l];t.position.setFromMatrixPosition(h.matrixWorld),t.position.applyMatrix4(c),s.identity(),o.copy(h.matrixWorld),o.premultiply(c),s.extractRotation(o),t.halfWidth.set(.5*h.width,0,0),t.halfHeight.set(0,.5*h.height,0),t.halfWidth.applyMatrix4(s),t.halfHeight.applyMatrix4(s),l++}else if(h.isPointLight){const t=i.point[r];t.position.setFromMatrixPosition(h.matrixWorld),t.position.applyMatrix4(c),r++}else if(h.isHemisphereLight){const t=i.hemi[u];t.direction.setFromMatrixPosition(h.matrixWorld),t.direction.transformDirection(c),u++}}},state:i}}function ca(t,e){const n=new ua(t,e),r=[],i=[];return{init:function(){r.length=0,i.length=0},state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:function(t){n.setup(r,t)},setupLightsView:function(t){n.setupView(r,t)},pushLight:function(t){r.push(t)},pushShadow:function(t){i.push(t)}}}function ha(t,e){let n=new WeakMap;return{get:function(r,i=0){const a=n.get(r);let o;return void 0===a?(o=new ca(t,e),n.set(r,[o])):i>=a.length?(o=new ca(t,e),a.push(o)):o=a[i],o},dispose:function(){n=new WeakMap}}}class fa extends Ze{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class da extends Ze{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new kt,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function pa(t,e,n){let r=new Yn;const i=new ut,a=new ut,o=new Lt,s=new fa({depthPacking:3201}),A=new da,l={},u=n.maxTextureSize,c={0:1,1:0,2:2},h=new kn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ut},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <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 hn;d.setAttribute("position",new tn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const p=new Dn(d,h),m=this;function g(n,r){const a=e.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 qt(i.x,i.y)),h.uniforms.shadow_pass.value=n.map.texture,h.uniforms.resolution.value=n.mapSize,h.uniforms.radius.value=n.radius,t.setRenderTarget(n.mapPass),t.clear(),t.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,t.setRenderTarget(n.map),t.clear(),t.renderBufferDirect(r,null,a,f,p,null)}function v(e,n,r,i,a,o){let u=null;const h=!0===r.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(u=void 0!==h?h:!0===r.isPointLight?A:s,t.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const t=u.uuid,e=n.uuid;let r=l[t];void 0===r&&(r={},l[t]=r);let i=r[e];void 0===i&&(i=u.clone(),r[e]=i),u=i}return u.visible=n.visible,u.wireframe=n.wireframe,u.side=3===o?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:c[n.side],u.alphaMap=n.alphaMap,u.alphaTest=n.alphaTest,u.clipShadows=n.clipShadows,u.clippingPlanes=n.clippingPlanes,u.clipIntersection=n.clipIntersection,u.displacementMap=n.displacementMap,u.displacementScale=n.displacementScale,u.displacementBias=n.displacementBias,u.wireframeLinewidth=n.wireframeLinewidth,u.linewidth=n.linewidth,!0===r.isPointLight&&!0===u.isMeshDistanceMaterial&&(u.referencePosition.setFromMatrixPosition(r.matrixWorld),u.nearDistance=i,u.farDistance=a),u}function x(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&&3===s)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);const r=e.update(n),i=n.material;if(Array.isArray(i)){const e=r.groups;for(let A=0,l=e.length;A<l;A++){const l=e[A],u=i[l.materialIndex];if(u&&u.visible){const e=v(n,u,o,a.near,a.far,s);t.renderBufferDirect(a,null,r,e,n,l)}}}else if(i.visible){const e=v(n,i,o,a.near,a.far,s);t.renderBufferDirect(a,null,r,e,n,null)}}const A=n.children;for(let t=0,e=A.length;t<e;t++)x(A[t],i,a,o,s)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.render=function(e,n,s){if(!1===m.enabled)return;if(!1===m.autoUpdate&&!1===m.needsUpdate)return;if(0===e.length)return;const A=t.getRenderTarget(),l=t.getActiveCubeFace(),c=t.getActiveMipmapLevel(),h=t.state;h.setBlending(0),h.buffers.color.setClear(1,1,1,1),h.buffers.depth.setTest(!0),h.setScissorTest(!1);for(let A=0,l=e.length;A<l;A++){const l=e[A],c=l.shadow;if(void 0===c){console.warn("THREE.WebGLShadowMap:",l,"has no shadow.");continue}if(!1===c.autoUpdate&&!1===c.needsUpdate)continue;i.copy(c.mapSize);const f=c.getFrameExtents();if(i.multiply(f),a.copy(c.mapSize),(i.x>u||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/f.x),i.x=a.x*f.x,c.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/f.y),i.y=a.y*f.y,c.mapSize.y=a.y)),null===c.map){const t=3!==this.type?{minFilter:T,magFilter:T}:{};c.map=new qt(i.x,i.y,t),c.map.texture.name=l.name+".shadowMap",c.camera.updateProjectionMatrix()}t.setRenderTarget(c.map),t.clear();const d=c.getViewportCount();for(let t=0;t<d;t++){const e=c.getViewport(t);o.set(a.x*e.x,a.y*e.y,a.x*e.z,a.y*e.w),h.viewport(o),c.updateMatrices(l,t),r=c.getFrustum(),x(n,s,c.camera,l,this.type)}!0!==c.isPointLightShadow&&3===this.type&&g(c,s),c.needsUpdate=!1}m.needsUpdate=!1,t.setRenderTarget(A,l,c)}}function ma(t,e,n){const r=n.isWebGL2;const i=new function(){let e=!1;const n=new Lt;let r=null;const i=new Lt(0,0,0,0);return{setMask:function(n){r===n||e||(t.colorMask(n,n,n,n),r=n)},setLocked:function(t){e=t},setClear:function(e,r,a,o,s){!0===s&&(e*=o,r*=o,a*=o),n.set(e,r,a,o),!1===i.equals(n)&&(t.clearColor(e,r,a,o),i.copy(n))},reset:function(){e=!1,r=null,i.set(-1,0,0,0)}}},a=new function(){let e=!1,n=null,r=null,i=null;return{setTest:function(t){t?F(2929):G(2929)},setMask:function(r){n===r||e||(t.depthMask(r),n=r)},setFunc:function(e){if(r!==e){switch(e){case 0:t.depthFunc(512);break;case 1:t.depthFunc(519);break;case 2:t.depthFunc(513);break;case 3:default:t.depthFunc(515);break;case 4:t.depthFunc(514);break;case 5:t.depthFunc(518);break;case 6:t.depthFunc(516);break;case 7:t.depthFunc(517)}r=e}},setLocked:function(t){e=t},setClear:function(e){i!==e&&(t.clearDepth(e),i=e)},reset:function(){e=!1,n=null,r=null,i=null}}},o=new function(){let e=!1,n=null,r=null,i=null,a=null,o=null,s=null,A=null,l=null;return{setTest:function(t){e||(t?F(2960):G(2960))},setMask:function(r){n===r||e||(t.stencilMask(r),n=r)},setFunc:function(e,n,o){r===e&&i===n&&a===o||(t.stencilFunc(e,n,o),r=e,i=n,a=o)},setOp:function(e,n,r){o===e&&s===n&&A===r||(t.stencilOp(e,n,r),o=e,s=n,A=r)},setLocked:function(t){e=t},setClear:function(e){l!==e&&(t.clearStencil(e),l=e)},reset:function(){e=!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={},u={},c=new WeakMap,h=[],f=null,d=!1,p=null,m=null,g=null,v=null,x=null,b=null,_=null,w=!1,M=null,S=null,E=null,T=null,C=null;const P=t.getParameter(35661);let D=!1,L=0;const q=t.getParameter(7938);-1!==q.indexOf("WebGL")?(L=parseFloat(/^WebGL (\d)/.exec(q)[1]),D=L>=1):-1!==q.indexOf("OpenGL ES")&&(L=parseFloat(/^OpenGL ES (\d)/.exec(q)[1]),D=L>=2);let R=null,O={};const I=t.getParameter(3088),k=t.getParameter(2978),B=(new Lt).fromArray(I),N=(new Lt).fromArray(k);function z(e,n,r){const i=new Uint8Array(4),a=t.createTexture();t.bindTexture(e,a),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;e<r;e++)t.texImage2D(n+e,0,6408,1,1,0,6408,5121,i);return a}const U={};function F(e){!0!==l[e]&&(t.enable(e),l[e]=!0)}function G(e){!1!==l[e]&&(t.disable(e),l[e]=!1)}U[3553]=z(3553,3553,1),U[34067]=z(34067,34069,6),i.setClear(0,0,0,1),a.setClear(1),o.setClear(0),F(2929),a.setFunc(3),W(!1),Q(1),F(2884),V(0);const j={[y]:32774,101:32778,102:32779};if(r)j[103]=32775,j[104]=32776;else{const t=e.get("EXT_blend_minmax");null!==t&&(j[103]=t.MIN_EXT,j[104]=t.MAX_EXT)}const H={200:0,201:1,202:768,204:770,210:776,208:774,206:772,203:769,205:771,209:775,207:773};function V(e,n,r,i,a,o,s,A){if(0!==e){if(!1===d&&(F(3042),d=!0),5===e)a=a||n,o=o||r,s=s||i,n===m&&a===x||(t.blendEquationSeparate(j[n],j[a]),m=n,x=a),r===g&&i===v&&o===b&&s===_||(t.blendFuncSeparate(H[r],H[i],H[o],H[s]),g=r,v=i,b=o,_=s),p=e,w=null;else if(e!==p||A!==w){if(m===y&&x===y||(t.blendEquation(32774),m=y,x=y),A)switch(e){case 1:t.blendFuncSeparate(1,771,1,771);break;case 2:t.blendFunc(1,1);break;case 3:t.blendFuncSeparate(0,769,0,1);break;case 4:t.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}else switch(e){case 1:t.blendFuncSeparate(770,771,1,771);break;case 2:t.blendFunc(770,1);break;case 3:t.blendFuncSeparate(0,769,0,1);break;case 4:t.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",e)}g=null,v=null,b=null,_=null,p=e,w=A}}else!0===d&&(G(3042),d=!1)}function W(e){M!==e&&(e?t.frontFace(2304):t.frontFace(2305),M=e)}function Q(e){0!==e?(F(2884),e!==S&&(1===e?t.cullFace(1029):2===e?t.cullFace(1028):t.cullFace(1032))):G(2884),S=e}function X(e,n,r){e?(F(32823),T===n&&C===r||(t.polygonOffset(n,r),T=n,C=r)):G(32823)}return{buffers:{color:i,depth:a,stencil:o},enable:F,disable:G,bindFramebuffer:function(e,n){return u[e]!==n&&(t.bindFramebuffer(e,n),u[e]=n,r&&(36009===e&&(u[36160]=n),36160===e&&(u[36009]=n)),!0)},drawBuffers:function(r,i){let a=h,o=!1;if(r)if(a=c.get(i),void 0===a&&(a=[],c.set(i,a)),r.isWebGLMultipleRenderTargets){const t=r.texture;if(a.length!==t.length||36064!==a[0]){for(let e=0,n=t.length;e<n;e++)a[e]=36064+e;a.length=t.length,o=!0}}else 36064!==a[0]&&(a[0]=36064,o=!0);else 1029!==a[0]&&(a[0]=1029,o=!0);o&&(n.isWebGL2?t.drawBuffers(a):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(a))},useProgram:function(e){return f!==e&&(t.useProgram(e),f=e,!0)},setBlending:V,setMaterial:function(t,e){2===t.side?G(2884):F(2884);let n=1===t.side;e&&(n=!n),W(n),1===t.blending&&!1===t.transparent?V(0):V(t.blending,t.blendEquation,t.blendSrc,t.blendDst,t.blendEquationAlpha,t.blendSrcAlpha,t.blendDstAlpha,t.premultipliedAlpha),a.setFunc(t.depthFunc),a.setTest(t.depthTest),a.setMask(t.depthWrite),i.setMask(t.colorWrite);const r=t.stencilWrite;o.setTest(r),r&&(o.setMask(t.stencilWriteMask),o.setFunc(t.stencilFunc,t.stencilRef,t.stencilFuncMask),o.setOp(t.stencilFail,t.stencilZFail,t.stencilZPass)),X(t.polygonOffset,t.polygonOffsetFactor,t.polygonOffsetUnits),!0===t.alphaToCoverage?F(32926):G(32926)},setFlipSided:W,setCullFace:Q,setLineWidth:function(e){e!==E&&(D&&t.lineWidth(e),E=e)},setPolygonOffset:X,setScissorTest:function(t){t?F(3089):G(3089)},activeTexture:function(e){void 0===e&&(e=33984+P-1),R!==e&&(t.activeTexture(e),R=e)},bindTexture:function(e,n,r){void 0===r&&(r=null===R?33984+P-1:R);let i=O[r];void 0===i&&(i={type:void 0,texture:void 0},O[r]=i),i.type===e&&i.texture===n||(R!==r&&(t.activeTexture(r),R=r),t.bindTexture(e,n||U[e]),i.type=e,i.texture=n)},unbindTexture:function(){const e=O[R];void 0!==e&&void 0!==e.type&&(t.bindTexture(e.type,null),e.type=void 0,e.texture=void 0)},compressedTexImage2D:function(){try{t.compressedTexImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexImage3D:function(){try{t.compressedTexImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage2D:function(){try{t.texImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texImage3D:function(){try{t.texImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},updateUBOMapping:function(e,n){let r=A.get(n);void 0===r&&(r=new WeakMap,A.set(n,r));let i=r.get(e);void 0===i&&(i=t.getUniformBlockIndex(n,e.name),r.set(e,i))},uniformBlockBinding:function(e,n){const r=A.get(n).get(e);s.get(e)!==r&&(t.uniformBlockBinding(n,r,e.__bindingPointIndex),s.set(e,r))},texStorage2D:function(){try{t.texStorage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texStorage3D:function(){try{t.texStorage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage2D:function(){try{t.texSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},texSubImage3D:function(){try{t.texSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage2D:function(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},compressedTexSubImage3D:function(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(t){console.error("THREE.WebGLState:",t)}},scissor:function(e){!1===B.equals(e)&&(t.scissor(e.x,e.y,e.z,e.w),B.copy(e))},viewport:function(e){!1===N.equals(e)&&(t.viewport(e.x,e.y,e.z,e.w),N.copy(e))},reset:function(){t.disable(3042),t.disable(2884),t.disable(2929),t.disable(32823),t.disable(3089),t.disable(2960),t.disable(32926),t.blendEquation(32774),t.blendFunc(1,0),t.blendFuncSeparate(1,0,1,0),t.colorMask(!0,!0,!0,!0),t.clearColor(0,0,0,0),t.depthMask(!0),t.depthFunc(513),t.clearDepth(1),t.stencilMask(4294967295),t.stencilFunc(519,0,4294967295),t.stencilOp(7680,7680,7680),t.clearStencil(0),t.cullFace(1029),t.frontFace(2305),t.polygonOffset(0,0),t.activeTexture(33984),t.bindFramebuffer(36160,null),!0===r&&(t.bindFramebuffer(36009,null),t.bindFramebuffer(36008,null)),t.useProgram(null),t.lineWidth(1),t.scissor(0,0,t.canvas.width,t.canvas.height),t.viewport(0,0,t.canvas.width,t.canvas.height),l={},R=null,O={},u={},c=new WeakMap,h=[],f=null,d=!1,p=null,m=null,g=null,v=null,x=null,b=null,_=null,w=!1,M=null,S=null,E=null,T=null,C=null,B.set(0,0,t.canvas.width,t.canvas.height),N.set(0,0,t.canvas.width,t.canvas.height),i.reset(),a.reset(),o.reset()}}}function ga(t,e,n,r,i,a,o){const s=i.isWebGL2,A=i.maxTextures,l=i.maxCubemapSize,u=i.maxTextureSize,c=i.maxSamples,h=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,f=/OculusBrowser/g.test("undefined"==typeof navigator?"":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(t){}function v(t,e){return g?new OffscreenCanvas(t,e):ft("canvas")}function x(t,e,n,r){let i=1;if((t.width>r||t.height>r)&&(i=r/Math.max(t.width,t.height)),i<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const r=e?ot:Math.floor,a=r(i*t.width),o=r(i*t.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(t,0,0,a,o),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+a+"x"+o+")."),s}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function y(t){return at(t.width)&&at(t.height)}function b(t,e){return t.generateMipmaps&&e&&t.minFilter!==T&&t.minFilter!==C}function _(e){t.generateMipmap(e)}function w(n,r,i,a,o=!1){if(!1===s)return r;if(null!==n){if(void 0!==t[n])return t[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let 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===j&&!1===o?35907:32856),32819===i&&(A=32854),32820===i&&(A=32855)),33325!==A&&33326!==A&&33327!==A&&33328!==A&&34842!==A&&34836!==A||e.get("EXT_color_buffer_float"),A}function N(t,e,n){return!0===b(t,n)||t.isFramebufferTexture&&t.minFilter!==T&&t.minFilter!==C?Math.log2(Math.max(e.width,e.height))+1:void 0!==t.mipmaps&&t.mipmaps.length>0?t.mipmaps.length:t.isCompressedTexture&&Array.isArray(t.image)?e.mipmaps.length:1}function z(t){return t===T||1004===t||1005===t?9728:9729}function U(t){const e=t.target;e.removeEventListener("dispose",U),function(t){const e=r.get(t);if(void 0===e.__webglInit)return;const n=t.source,i=m.get(n);if(i){const r=i[e.__cacheKey];r.usedTimes--,0===r.usedTimes&&H(t),0===Object.keys(i).length&&m.delete(n)}r.remove(t)}(e),e.isVideoTexture&&d.delete(e)}function F(e){const n=e.target;n.removeEventListener("dispose",F),function(e){const n=e.texture,i=r.get(e),a=r.get(n);void 0!==a.__webglTexture&&(t.deleteTexture(a.__webglTexture),o.memory.textures--);e.depthTexture&&e.depthTexture.dispose();if(e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(i.__webglFramebuffer[e]),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer[e]);else{if(t.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&t.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&t.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(let e=0;e<i.__webglColorRenderbuffer.length;e++)i.__webglColorRenderbuffer[e]&&t.deleteRenderbuffer(i.__webglColorRenderbuffer[e]);i.__webglDepthRenderbuffer&&t.deleteRenderbuffer(i.__webglDepthRenderbuffer)}if(e.isWebGLMultipleRenderTargets)for(let e=0,i=n.length;e<i;e++){const i=r.get(n[e]);i.__webglTexture&&(t.deleteTexture(i.__webglTexture),o.memory.textures--),r.remove(n[e])}r.remove(n),r.remove(e)}(n)}function H(e){const n=r.get(e);t.deleteTexture(n.__webglTexture);const i=e.source;delete m.get(i)[n.__cacheKey],o.memory.textures--}let V=0;function W(t,e){const i=r.get(t);if(t.isVideoTexture&&function(t){const e=o.render.frame;d.get(t)!==e&&(d.set(t,e),t.update())}(t),!1===t.isRenderTargetTexture&&t.version>0&&i.__version!==t.version){const n=t.image;if(null===n)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==n.complete)return void K(i,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(3553,i.__webglTexture,33984+e)}const Q={[M]:10497,[S]:33071,[E]:33648},X={[T]:9728,1004:9984,1005:9986,[C]:9729,1007:9985,[P]:9987};function Z(n,a,o){if(o?(t.texParameteri(n,10242,Q[a.wrapS]),t.texParameteri(n,10243,Q[a.wrapT]),32879!==n&&35866!==n||t.texParameteri(n,32882,Q[a.wrapR]),t.texParameteri(n,10240,X[a.magFilter]),t.texParameteri(n,10241,X[a.minFilter])):(t.texParameteri(n,10242,33071),t.texParameteri(n,10243,33071),32879!==n&&35866!==n||t.texParameteri(n,32882,33071),a.wrapS===S&&a.wrapT===S||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(n,10240,z(a.magFilter)),t.texParameteri(n,10241,z(a.minFilter)),a.minFilter!==T&&a.minFilter!==C&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===e.has("EXT_texture_filter_anisotropic")){const o=e.get("EXT_texture_filter_anisotropic");if(a.type===q&&!1===e.has("OES_texture_float_linear"))return;if(!1===s&&a.type===R&&!1===e.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(t.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function J(e,n){let r=!1;void 0===e.__webglInit&&(e.__webglInit=!0,n.addEventListener("dispose",U));const i=n.source;let a=m.get(i);void 0===a&&(a={},m.set(i,a));const s=function(t){const e=[];return e.push(t.wrapS),e.push(t.wrapT),e.push(t.wrapR||0),e.push(t.magFilter),e.push(t.minFilter),e.push(t.anisotropy),e.push(t.internalFormat),e.push(t.format),e.push(t.type),e.push(t.generateMipmaps),e.push(t.premultiplyAlpha),e.push(t.flipY),e.push(t.unpackAlignment),e.push(t.encoding),e.join()}(n);if(s!==e.__cacheKey){void 0===a[s]&&(a[s]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;const i=a[e.__cacheKey];void 0!==i&&(a[e.__cacheKey].usedTimes--,0===i.usedTimes&&H(n)),e.__cacheKey=s,e.__webglTexture=a[s].texture}return r}function K(e,i,o){let A=3553;(i.isDataArrayTexture||i.isCompressedArrayTexture)&&(A=35866),i.isData3DTexture&&(A=32879);const l=J(e,i),c=i.source;n.bindTexture(A,e.__webglTexture,33984+o);const h=r.get(c);if(c.version!==h.__version||!0===l){n.activeTexture(33984+o),t.pixelStorei(37440,i.flipY),t.pixelStorei(37441,i.premultiplyAlpha),t.pixelStorei(3317,i.unpackAlignment),t.pixelStorei(37443,0);const e=function(t){return!s&&(t.wrapS!==S||t.wrapT!==S||t.minFilter!==T&&t.minFilter!==C)}(i)&&!1===y(i.image);let r=x(i.image,e,!1,u);r=it(i,r);const f=y(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);Z(A,i,f);const v=i.mipmaps,M=s&&!0!==i.isVideoTexture,E=void 0===h.__version||!0===l,P=N(i,r,f);if(i.isDepthTexture)g=6402,s?g=i.type===q?36012:i.type===L?33190:i.type===O?35056:33189:i.type===q&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),i.format===k&&6402===g&&1012!==i.type&&i.type!==L&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=L,m=a.convert(i.type)),i.format===B&&6402===g&&(g=34041,i.type!==O&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=O,m=a.convert(i.type))),E&&(M?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){M&&E&&n.texStorage2D(3553,P,g,v[0].width,v[0].height);for(let t=0,e=v.length;t<e;t++)p=v[t],M?n.texSubImage2D(3553,t,0,0,p.width,p.height,d,m,p.data):n.texImage2D(3553,t,g,p.width,p.height,0,d,m,p.data);i.generateMipmaps=!1}else M?(E&&n.texStorage2D(3553,P,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){M&&E&&n.texStorage3D(35866,P,g,v[0].width,v[0].height,r.depth);for(let t=0,e=v.length;t<e;t++)p=v[t],i.format!==I?null!==d?M?n.compressedTexSubImage3D(35866,t,0,0,0,p.width,p.height,r.depth,d,p.data,0,0):n.compressedTexImage3D(35866,t,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()"):M?n.texSubImage3D(35866,t,0,0,0,p.width,p.height,r.depth,d,m,p.data):n.texImage3D(35866,t,g,p.width,p.height,r.depth,0,d,m,p.data)}else{M&&E&&n.texStorage2D(3553,P,g,v[0].width,v[0].height);for(let t=0,e=v.length;t<e;t++)p=v[t],i.format!==I?null!==d?M?n.compressedTexSubImage2D(3553,t,0,0,p.width,p.height,d,p.data):n.compressedTexImage2D(3553,t,g,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):M?n.texSubImage2D(3553,t,0,0,p.width,p.height,d,m,p.data):n.texImage2D(3553,t,g,p.width,p.height,0,d,m,p.data)}else if(i.isDataArrayTexture)M?(E&&n.texStorage3D(35866,P,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)M?(E&&n.texStorage3D(32879,P,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(M)n.texStorage2D(3553,P,g,r.width,r.height);else{let t=r.width,e=r.height;for(let r=0;r<P;r++)n.texImage2D(3553,r,g,t,e,0,d,m,null),t>>=1,e>>=1}}else if(v.length>0&&f){M&&E&&n.texStorage2D(3553,P,g,v[0].width,v[0].height);for(let t=0,e=v.length;t<e;t++)p=v[t],M?n.texSubImage2D(3553,t,0,0,d,m,p):n.texImage2D(3553,t,g,d,m,p);i.generateMipmaps=!1}else M?(E&&n.texStorage2D(3553,P,g,r.width,r.height),n.texSubImage2D(3553,0,0,0,d,m,r)):n.texImage2D(3553,0,g,d,m,r);b(i,f)&&_(A),h.__version=c.version,i.onUpdate&&i.onUpdate(i)}e.__version=i.version}function $(e,i,o,s,A){const l=a.convert(o.format,o.encoding),u=a.convert(o.type),c=w(o.internalFormat,l,u,o.encoding);r.get(i).__hasExternalTextures||(32879===A||35866===A?n.texImage3D(A,0,c,i.width,i.height,i.depth,0,l,u,null):n.texImage2D(A,0,c,i.width,i.height,0,l,u,null)),n.bindFramebuffer(36160,e),rt(i)?h.framebufferTexture2DMultisampleEXT(36160,s,A,r.get(o).__webglTexture,0,nt(i)):(3553===A||A>=34069&&A<=34074)&&t.framebufferTexture2D(36160,s,A,r.get(o).__webglTexture,0),n.bindFramebuffer(36160,null)}function tt(e,n,r){if(t.bindRenderbuffer(36161,e),n.depthBuffer&&!n.stencilBuffer){let i=33189;if(r||rt(n)){const e=n.depthTexture;e&&e.isDepthTexture&&(e.type===q?i=36012:e.type===L&&(i=33190));const r=nt(n);rt(n)?h.renderbufferStorageMultisampleEXT(36161,r,i,n.width,n.height):t.renderbufferStorageMultisample(36161,r,i,n.width,n.height)}else t.renderbufferStorage(36161,i,n.width,n.height);t.framebufferRenderbuffer(36160,36096,36161,e)}else if(n.depthBuffer&&n.stencilBuffer){const i=nt(n);r&&!1===rt(n)?t.renderbufferStorageMultisample(36161,i,35056,n.width,n.height):rt(n)?h.renderbufferStorageMultisampleEXT(36161,i,35056,n.width,n.height):t.renderbufferStorage(36161,34041,n.width,n.height),t.framebufferRenderbuffer(36160,33306,36161,e)}else{const e=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let i=0;i<e.length;i++){const o=e[i],s=a.convert(o.format,o.encoding),A=a.convert(o.type),l=w(o.internalFormat,s,A,o.encoding),u=nt(n);r&&!1===rt(n)?t.renderbufferStorageMultisample(36161,u,l,n.width,n.height):rt(n)?h.renderbufferStorageMultisampleEXT(36161,u,l,n.width,n.height):t.renderbufferStorage(36161,l,n.width,n.height)}}t.bindRenderbuffer(36161,null)}function et(e){const i=r.get(e),a=!0===e.isWebGLCubeRenderTarget;if(e.depthTexture&&!i.__autoAllocateDepthBuffer){if(a)throw new Error("target.depthTexture not supported in Cube render targets");!function(e,i){if(i&&i.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,e),!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),W(i.depthTexture,0);const a=r.get(i.depthTexture).__webglTexture,o=nt(i);if(i.depthTexture.format===k)rt(i)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,a,0,o):t.framebufferTexture2D(36160,36096,3553,a,0);else{if(i.depthTexture.format!==B)throw new Error("Unknown depthTexture format");rt(i)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,a,0,o):t.framebufferTexture2D(36160,33306,3553,a,0)}}(i.__webglFramebuffer,e)}else if(a){i.__webglDepthbuffer=[];for(let r=0;r<6;r++)n.bindFramebuffer(36160,i.__webglFramebuffer[r]),i.__webglDepthbuffer[r]=t.createRenderbuffer(),tt(i.__webglDepthbuffer[r],e,!1)}else n.bindFramebuffer(36160,i.__webglFramebuffer),i.__webglDepthbuffer=t.createRenderbuffer(),tt(i.__webglDepthbuffer,e,!1);n.bindFramebuffer(36160,null)}function nt(t){return Math.min(c,t.samples)}function rt(t){const n=r.get(t);return s&&t.samples>0&&!0===e.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function it(t,n){const r=t.encoding,i=t.format,a=t.type;return!0===t.isCompressedTexture||!0===t.isVideoTexture||t.format===Y||r!==G&&(r===j?!1===s?!0===e.has("EXT_sRGB")&&i===I?(t.format=Y,t.minFilter=C,t.generateMipmaps=!1):n=Et.sRGBToLinear(n):i===I&&a===D||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 t=V;return t>=A&&console.warn("THREE.WebGLTextures: Trying to use "+t+" texture units while this GPU supports only "+A),V+=1,t},this.resetTextureUnits=function(){V=0},this.setTexture2D=W,this.setTexture2DArray=function(t,e){const i=r.get(t);t.version>0&&i.__version!==t.version?K(i,t,e):n.bindTexture(35866,i.__webglTexture,33984+e)},this.setTexture3D=function(t,e){const i=r.get(t);t.version>0&&i.__version!==t.version?K(i,t,e):n.bindTexture(32879,i.__webglTexture,33984+e)},this.setTextureCube=function(e,i){const o=r.get(e);e.version>0&&o.__version!==e.version?function(e,i,o){if(6!==i.image.length)return;const A=J(e,i),u=i.source;n.bindTexture(34067,e.__webglTexture,33984+o);const c=r.get(u);if(u.version!==c.__version||!0===A){n.activeTexture(33984+o),t.pixelStorei(37440,i.flipY),t.pixelStorei(37441,i.premultiplyAlpha),t.pixelStorei(3317,i.unpackAlignment),t.pixelStorei(37443,0);const e=i.isCompressedTexture||i.image[0].isCompressedTexture,r=i.image[0]&&i.image[0].isDataTexture,h=[];for(let t=0;t<6;t++)h[t]=e||r?r?i.image[t].image:i.image[t]:x(i.image[t],!1,!0,l),h[t]=it(i,h[t]);const f=h[0],d=y(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,M=void 0===c.__version||!0===A;let S,E=N(i,f,d);if(Z(34067,i,d),e){v&&M&&n.texStorage2D(34067,E,g,f.width,f.height);for(let t=0;t<6;t++){S=h[t].mipmaps;for(let e=0;e<S.length;e++){const r=S[e];i.format!==I?null!==p?v?n.compressedTexSubImage2D(34069+t,e,0,0,r.width,r.height,p,r.data):n.compressedTexImage2D(34069+t,e,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+t,e,0,0,r.width,r.height,p,m,r.data):n.texImage2D(34069+t,e,g,r.width,r.height,0,p,m,r.data)}}}else{S=i.mipmaps,v&&M&&(S.length>0&&E++,n.texStorage2D(34067,E,g,h[0].width,h[0].height));for(let t=0;t<6;t++)if(r){v?n.texSubImage2D(34069+t,0,0,0,h[t].width,h[t].height,p,m,h[t].data):n.texImage2D(34069+t,0,g,h[t].width,h[t].height,0,p,m,h[t].data);for(let e=0;e<S.length;e++){const r=S[e].image[t].image;v?n.texSubImage2D(34069+t,e+1,0,0,r.width,r.height,p,m,r.data):n.texImage2D(34069+t,e+1,g,r.width,r.height,0,p,m,r.data)}}else{v?n.texSubImage2D(34069+t,0,0,0,p,m,h[t]):n.texImage2D(34069+t,0,g,p,m,h[t]);for(let e=0;e<S.length;e++){const r=S[e];v?n.texSubImage2D(34069+t,e+1,0,0,p,m,r.image[t]):n.texImage2D(34069+t,e+1,g,p,m,r.image[t])}}}b(i,d)&&_(34067),c.__version=u.version,i.onUpdate&&i.onUpdate(i)}e.__version=i.version}(o,e,i):n.bindTexture(34067,o.__webglTexture,33984+i)},this.rebindTextures=function(t,e,n){const i=r.get(t);void 0!==e&&$(i.__webglFramebuffer,t,t.texture,36064,3553),void 0!==n&&et(t)},this.setupRenderTarget=function(e){const A=e.texture,l=r.get(e),u=r.get(A);e.addEventListener("dispose",F),!0!==e.isWebGLMultipleRenderTargets&&(void 0===u.__webglTexture&&(u.__webglTexture=t.createTexture()),u.__version=A.version,o.memory.textures++);const c=!0===e.isWebGLCubeRenderTarget,h=!0===e.isWebGLMultipleRenderTargets,f=y(e)||s;if(c){l.__webglFramebuffer=[];for(let e=0;e<6;e++)l.__webglFramebuffer[e]=t.createFramebuffer()}else{if(l.__webglFramebuffer=t.createFramebuffer(),h)if(i.drawBuffers){const n=e.texture;for(let e=0,i=n.length;e<i;e++){const i=r.get(n[e]);void 0===i.__webglTexture&&(i.__webglTexture=t.createTexture(),o.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(s&&e.samples>0&&!1===rt(e)){const r=h?A:[A];l.__webglMultisampledFramebuffer=t.createFramebuffer(),l.__webglColorRenderbuffer=[],n.bindFramebuffer(36160,l.__webglMultisampledFramebuffer);for(let n=0;n<r.length;n++){const i=r[n];l.__webglColorRenderbuffer[n]=t.createRenderbuffer(),t.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===e.isXRRenderTarget),u=nt(e);t.renderbufferStorageMultisample(36161,u,A,e.width,e.height),t.framebufferRenderbuffer(36160,36064+n,36161,l.__webglColorRenderbuffer[n])}t.bindRenderbuffer(36161,null),e.depthBuffer&&(l.__webglDepthRenderbuffer=t.createRenderbuffer(),tt(l.__webglDepthRenderbuffer,e,!0)),n.bindFramebuffer(36160,null)}}if(c){n.bindTexture(34067,u.__webglTexture),Z(34067,A,f);for(let t=0;t<6;t++)$(l.__webglFramebuffer[t],e,A,36064,34069+t);b(A,f)&&_(34067),n.unbindTexture()}else if(h){const t=e.texture;for(let i=0,a=t.length;i<a;i++){const a=t[i],o=r.get(a);n.bindTexture(3553,o.__webglTexture),Z(3553,a,f),$(l.__webglFramebuffer,e,a,36064+i,3553),b(a,f)&&_(3553)}n.unbindTexture()}else{let t=3553;(e.isWebGL3DRenderTarget||e.isWebGLArrayRenderTarget)&&(s?t=e.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(t,u.__webglTexture),Z(t,A,f),$(l.__webglFramebuffer,e,A,36064,t),b(A,f)&&_(t),n.unbindTexture()}e.depthBuffer&&et(e)},this.updateRenderTargetMipmap=function(t){const e=y(t)||s,i=!0===t.isWebGLMultipleRenderTargets?t.texture:[t.texture];for(let a=0,o=i.length;a<o;a++){const o=i[a];if(b(o,e)){const e=t.isWebGLCubeRenderTarget?34067:3553,i=r.get(o).__webglTexture;n.bindTexture(e,i),_(e),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(e){if(s&&e.samples>0&&!1===rt(e)){const i=e.isWebGLMultipleRenderTargets?e.texture:[e.texture],a=e.width,o=e.height;let s=16384;const A=[],l=e.stencilBuffer?33306:36096,u=r.get(e),c=!0===e.isWebGLMultipleRenderTargets;if(c)for(let e=0;e<i.length;e++)n.bindFramebuffer(36160,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064+e,36161,null),n.bindFramebuffer(36160,u.__webglFramebuffer),t.framebufferTexture2D(36009,36064+e,3553,null,0);n.bindFramebuffer(36008,u.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,u.__webglFramebuffer);for(let n=0;n<i.length;n++){A.push(36064+n),e.depthBuffer&&A.push(l);const h=void 0!==u.__ignoreDepthValues&&u.__ignoreDepthValues;if(!1===h&&(e.depthBuffer&&(s|=256),e.stencilBuffer&&(s|=1024)),c&&t.framebufferRenderbuffer(36008,36064,36161,u.__webglColorRenderbuffer[n]),!0===h&&(t.invalidateFramebuffer(36008,[l]),t.invalidateFramebuffer(36009,[l])),c){const e=r.get(i[n]).__webglTexture;t.framebufferTexture2D(36009,36064,3553,e,0)}t.blitFramebuffer(0,0,a,o,0,0,a,o,s,9728),f&&t.invalidateFramebuffer(36008,A)}if(n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,null),c)for(let e=0;e<i.length;e++){n.bindFramebuffer(36160,u.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(36160,36064+e,36161,u.__webglColorRenderbuffer[e]);const a=r.get(i[e]).__webglTexture;n.bindFramebuffer(36160,u.__webglFramebuffer),t.framebufferTexture2D(36009,36064+e,3553,a,0)}n.bindFramebuffer(36009,u.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=et,this.setupFrameBufferTexture=$,this.useMultisampledRTT=rt}function va(t,e,n){const r=n.isWebGL2;return{convert:function(n,i=null){let a;if(n===D)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===L)return 5125;if(n===q)return 5126;if(n===R)return r?5131:(a=e.get("OES_texture_half_float"),null!==a?a.HALF_FLOAT_OES:null);if(1021===n)return 6406;if(n===I)return 6408;if(1024===n)return 6409;if(1025===n)return 6410;if(n===k)return 6402;if(n===B)return 34041;if(1028===n)return 6403;if(1022===n)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(n===Y)return a=e.get("EXT_sRGB"),null!==a?a.SRGB_ALPHA_EXT:null;if(1029===n)return 36244;if(1030===n)return 33319;if(1031===n)return 33320;if(1033===n)return 36249;if(n===N||n===z||n===U||n===F)if(i===j){if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),null===a)return null;if(n===N)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===z)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===U)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===F)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(a=e.get("WEBGL_compressed_texture_s3tc"),null===a)return null;if(n===N)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===z)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===U)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===F)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===n||35841===n||35842===n||35843===n){if(a=e.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=e.get("WEBGL_compressed_texture_etc1"),null!==a?a.COMPRESSED_RGB_ETC1_WEBGL:null;if(37492===n||37496===n){if(a=e.get("WEBGL_compressed_texture_etc"),null===a)return null;if(37492===n)return i===j?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(37496===n)return i===j?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=e.get("WEBGL_compressed_texture_astc"),null===a)return null;if(37808===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(37809===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(37810===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(37811===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(37812===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(37813===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(37814===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(37815===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(37816===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(37817===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(37818===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(37819===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(37820===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(37821===n)return i===j?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}if(36492===n){if(a=e.get("EXT_texture_compression_bptc"),null===a)return null;if(36492===n)return i===j?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}return n===O?r?34042:(a=e.get("WEBGL_depth_texture"),null!==a?a.UNSIGNED_INT_24_8_WEBGL:null):void 0!==t[n]?t[n]:null}}}class xa extends Nn{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}let ya=class extends Be{constructor(){super(),this.isGroup=!0,this.type="Group"}};const ba={type:"move"};class _a{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new ya,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 ya,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new kt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new kt),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new ya,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new kt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new kt),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,n){let r=null,i=null,a=null;const o=this._targetRay,s=this._grip,A=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(A&&t.hand){a=!0;for(const r of t.hand.values()){const t=e.getJointPose(r,n);if(void 0===A.joints[r.jointName]){const t=new ya;t.matrixAutoUpdate=!1,t.visible=!1,A.joints[r.jointName]=t,A.add(t)}const i=A.joints[r.jointName];null!==t&&(i.matrix.fromArray(t.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.jointRadius=t.radius),i.visible=null!==t}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:t.handedness,target:this})):!A.inputState.pinching&&o<=s-l&&(A.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==s&&t.gripSpace&&(i=e.getPose(t.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=e.getPose(t.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(ba)))}return null!==o&&(o.visible=null!==r),null!==s&&(s.visible=null!==i),null!==A&&(A.visible=null!==a),this}}class wa extends Dt{constructor(t,e,n,r,i,a,o,s,A,l){if((l=void 0!==l?l:k)!==k&&l!==B)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&l===k&&(n=L),void 0===n&&l===B&&(n=O),super(null,r,i,a,o,s,l,n,A),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=void 0!==o?o:T,this.minFilter=void 0!==s?s:T,this.flipY=!1,this.generateMipmaps=!1}}class Ma extends Z{constructor(t,e){super();const n=this;let r=null,i=1,a=null,o="local-floor",s=null,A=null,l=null,u=null,c=null,h=null;const f=e.getContextAttributes();let d=null,p=null;const m=[],g=[],v=new Nn;v.layers.enable(1),v.viewport=new Lt;const x=new Nn;x.layers.enable(2),x.viewport=new Lt;const y=[v,x],b=new xa;b.layers.enable(1),b.layers.enable(2);let _=null,w=null;function M(t){const e=g.indexOf(t.inputSource);if(-1===e)return;const n=m[e];void 0!==n&&n.dispatchEvent({type:t.type,data:t.inputSource})}function S(){r.removeEventListener("select",M),r.removeEventListener("selectstart",M),r.removeEventListener("selectend",M),r.removeEventListener("squeeze",M),r.removeEventListener("squeezestart",M),r.removeEventListener("squeezeend",M),r.removeEventListener("end",S),r.removeEventListener("inputsourceschange",E);for(let t=0;t<m.length;t++){const e=g[t];null!==e&&(g[t]=null,m[t].disconnect(e))}_=null,w=null,t.setRenderTarget(d),c=null,u=null,l=null,r=null,p=null,R.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function E(t){for(let e=0;e<t.removed.length;e++){const n=t.removed[e],r=g.indexOf(n);r>=0&&(g[r]=null,m[r].dispatchEvent({type:"disconnected",data:n}))}for(let e=0;e<t.added.length;e++){const n=t.added[e];let r=g.indexOf(n);if(-1===r){for(let t=0;t<m.length;t++){if(t>=g.length){g.push(n),r=t;break}if(null===g[t]){g[t]=n,r=t;break}}if(-1===r)break}const i=m[r];i&&i.dispatchEvent({type:"connected",data:n})}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(t){let e=m[t];return void 0===e&&(e=new _a,m[t]=e),e.getTargetRaySpace()},this.getControllerGrip=function(t){let e=m[t];return void 0===e&&(e=new _a,m[t]=e),e.getGripSpace()},this.getHand=function(t){let e=m[t];return void 0===e&&(e=new _a,m[t]=e),e.getHandSpace()},this.setFramebufferScaleFactor=function(t){i=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(t){o=t,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s||a},this.setReferenceSpace=function(t){s=t},this.getBaseLayer=function(){return null!==u?u:c},this.getBinding=function(){return l},this.getFrame=function(){return h},this.getSession=function(){return r},this.setSession=async function(A){if(r=A,null!==r){if(d=t.getRenderTarget(),r.addEventListener("select",M),r.addEventListener("selectstart",M),r.addEventListener("selectend",M),r.addEventListener("squeeze",M),r.addEventListener("squeezestart",M),r.addEventListener("squeezeend",M),r.addEventListener("end",S),r.addEventListener("inputsourceschange",E),!0!==f.xrCompatible&&await e.makeXRCompatible(),void 0===r.renderState.layers||!1===t.capabilities.isWebGL2){const n={antialias:void 0!==r.renderState.layers||f.antialias,alpha:f.alpha,depth:f.depth,stencil:f.stencil,framebufferScaleFactor:i};c=new XRWebGLLayer(r,e,n),r.updateRenderState({baseLayer:c}),p=new qt(c.framebufferWidth,c.framebufferHeight,{format:I,type:D,encoding:t.outputEncoding,stencilBuffer:f.stencil})}else{let n=null,a=null,o=null;f.depth&&(o=f.stencil?35056:33190,n=f.stencil?B:k,a=f.stencil?O:L);const s={colorFormat:32856,depthFormat:o,scaleFactor:i};l=new XRWebGLBinding(r,e),u=l.createProjectionLayer(s),r.updateRenderState({layers:[u]}),p=new qt(u.textureWidth,u.textureHeight,{format:I,type:D,depthTexture:new wa(u.textureWidth,u.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:f.stencil,encoding:t.outputEncoding,samples:f.antialias?4:0});t.properties.get(p).__ignoreDepthValues=u.ignoreDepthValues}p.isXRRenderTarget=!0,this.setFoveation(1),s=null,a=await r.requestReferenceSpace(o),R.setContext(r),R.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const T=new kt,C=new kt;function P(t,e){null===e?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.copy(t.matrixWorld).invert()}this.updateCamera=function(t){if(null===r)return;b.near=x.near=v.near=t.near,b.far=x.far=v.far=t.far,_===b.near&&w===b.far||(r.updateRenderState({depthNear:b.near,depthFar:b.far}),_=b.near,w=b.far);const e=t.parent,n=b.cameras;P(b,e);for(let t=0;t<n.length;t++)P(n[t],e);b.matrixWorld.decompose(b.position,b.quaternion,b.scale),t.matrix.copy(b.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale);const i=t.children;for(let t=0,e=i.length;t<e;t++)i[t].updateMatrixWorld(!0);2===n.length?function(t,e,n){T.setFromMatrixPosition(e.matrixWorld),C.setFromMatrixPosition(n.matrixWorld);const r=T.distanceTo(C),i=e.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],u=(i[8]-1)/i[0],c=(a[8]+1)/a[0],h=o*u,f=o*c,d=r/(-u+c),p=d*-u;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(p),t.translateZ(d),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.copy(t.matrixWorld).invert();const m=o+d,g=s+d,v=h-p,x=f+(r-p),y=A*s/g*m,b=l*s/g*m;t.projectionMatrix.makePerspective(v,x,y,b,m,g)}(b,v,x):b.projectionMatrix.copy(v.projectionMatrix)},this.getCamera=function(){return b},this.getFoveation=function(){return null!==u?u.fixedFoveation:null!==c?c.fixedFoveation:void 0},this.setFoveation=function(t){null!==u&&(u.fixedFoveation=t),null!==c&&void 0!==c.fixedFoveation&&(c.fixedFoveation=t)};let q=null;const R=new Zn;R.setAnimationLoop((function(e,n){if(A=n.getViewerPose(s||a),h=n,null!==A){const e=A.views;null!==c&&(t.setRenderTargetFramebuffer(p,c.framebuffer),t.setRenderTarget(p));let n=!1;e.length!==b.cameras.length&&(b.cameras.length=0,n=!0);for(let r=0;r<e.length;r++){const i=e[r];let a=null;if(null!==c)a=c.getViewport(i);else{const e=l.getViewSubImage(u,i);a=e.viewport,0===r&&(t.setRenderTargetTextures(p,e.colorTexture,u.ignoreDepthValues?void 0:e.depthStencilTexture),t.setRenderTarget(p))}let o=y[r];void 0===o&&(o=new Nn,o.layers.enable(r),o.viewport=new Lt,y[r]=o),o.matrix.fromArray(i.transform.matrix),o.projectionMatrix.fromArray(i.projectionMatrix),o.viewport.set(a.x,a.y,a.width,a.height),0===r&&b.matrix.copy(o.matrix),!0===n&&b.cameras.push(o)}}for(let t=0;t<m.length;t++){const e=g[t],r=m[t];null!==e&&void 0!==r&&r.update(e,n,s||a)}q&&q(e,n),h=null})),this.setAnimationLoop=function(t){q=t},this.dispose=function(){}}}function Sa(t,e){function n(n,r){n.opacity.value=r.opacity,r.color&&n.diffuse.value.copy(r.color),r.emissive&&n.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(n.map.value=r.map),r.alphaMap&&(n.alphaMap.value=r.alphaMap),r.bumpMap&&(n.bumpMap.value=r.bumpMap,n.bumpScale.value=r.bumpScale,1===r.side&&(n.bumpScale.value*=-1)),r.displacementMap&&(n.displacementMap.value=r.displacementMap,n.displacementScale.value=r.displacementScale,n.displacementBias.value=r.displacementBias),r.emissiveMap&&(n.emissiveMap.value=r.emissiveMap),r.normalMap&&(n.normalMap.value=r.normalMap,n.normalScale.value.copy(r.normalScale),1===r.side&&n.normalScale.value.negate()),r.specularMap&&(n.specularMap.value=r.specularMap),r.alphaTest>0&&(n.alphaTest.value=r.alphaTest);const i=e.get(r).envMap;if(i&&(n.envMap.value=i,n.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,n.reflectivity.value=r.reflectivity,n.ior.value=r.ior,n.refractionRatio.value=r.refractionRatio),r.lightMap){n.lightMap.value=r.lightMap;const e=!0!==t.physicallyCorrectLights?Math.PI:1;n.lightMapIntensity.value=r.lightMapIntensity*e}let a,o;r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity),r.map?a=r.map:r.specularMap?a=r.specularMap:r.displacementMap?a=r.displacementMap:r.normalMap?a=r.normalMap:r.bumpMap?a=r.bumpMap:r.roughnessMap?a=r.roughnessMap:r.metalnessMap?a=r.metalnessMap:r.alphaMap?a=r.alphaMap:r.emissiveMap?a=r.emissiveMap:r.clearcoatMap?a=r.clearcoatMap:r.clearcoatNormalMap?a=r.clearcoatNormalMap:r.clearcoatRoughnessMap?a=r.clearcoatRoughnessMap:r.iridescenceMap?a=r.iridescenceMap:r.iridescenceThicknessMap?a=r.iridescenceThicknessMap:r.specularIntensityMap?a=r.specularIntensityMap:r.specularColorMap?a=r.specularColorMap:r.transmissionMap?a=r.transmissionMap:r.thicknessMap?a=r.thicknessMap:r.sheenColorMap?a=r.sheenColorMap:r.sheenRoughnessMap&&(a=r.sheenRoughnessMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),n.uvTransform.value.copy(a.matrix)),r.aoMap?o=r.aoMap:r.lightMap&&(o=r.lightMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),n.uv2Transform.value.copy(o.matrix))}return{refreshFogUniforms:function(t,e){t.fogColor.value.copy(e.color),e.isFog?(t.fogNear.value=e.near,t.fogFar.value=e.far):e.isFogExp2&&(t.fogDensity.value=e.density)},refreshMaterialUniforms:function(t,r,i,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?n(t,r):r.isMeshToonMaterial?(n(t,r),function(t,e){e.gradientMap&&(t.gradientMap.value=e.gradientMap)}(t,r)):r.isMeshPhongMaterial?(n(t,r),function(t,e){t.specular.value.copy(e.specular),t.shininess.value=Math.max(e.shininess,1e-4)}(t,r)):r.isMeshStandardMaterial?(n(t,r),function(t,n){t.roughness.value=n.roughness,t.metalness.value=n.metalness,n.roughnessMap&&(t.roughnessMap.value=n.roughnessMap);n.metalnessMap&&(t.metalnessMap.value=n.metalnessMap);e.get(n).envMap&&(t.envMapIntensity.value=n.envMapIntensity)}(t,r),r.isMeshPhysicalMaterial&&function(t,e,n){t.ior.value=e.ior,e.sheen>0&&(t.sheenColor.value.copy(e.sheenColor).multiplyScalar(e.sheen),t.sheenRoughness.value=e.sheenRoughness,e.sheenColorMap&&(t.sheenColorMap.value=e.sheenColorMap),e.sheenRoughnessMap&&(t.sheenRoughnessMap.value=e.sheenRoughnessMap));e.clearcoat>0&&(t.clearcoat.value=e.clearcoat,t.clearcoatRoughness.value=e.clearcoatRoughness,e.clearcoatMap&&(t.clearcoatMap.value=e.clearcoatMap),e.clearcoatRoughnessMap&&(t.clearcoatRoughnessMap.value=e.clearcoatRoughnessMap),e.clearcoatNormalMap&&(t.clearcoatNormalScale.value.copy(e.clearcoatNormalScale),t.clearcoatNormalMap.value=e.clearcoatNormalMap,1===e.side&&t.clearcoatNormalScale.value.negate()));e.iridescence>0&&(t.iridescence.value=e.iridescence,t.iridescenceIOR.value=e.iridescenceIOR,t.iridescenceThicknessMinimum.value=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum.value=e.iridescenceThicknessRange[1],e.iridescenceMap&&(t.iridescenceMap.value=e.iridescenceMap),e.iridescenceThicknessMap&&(t.iridescenceThicknessMap.value=e.iridescenceThicknessMap));e.transmission>0&&(t.transmission.value=e.transmission,t.transmissionSamplerMap.value=n.texture,t.transmissionSamplerSize.value.set(n.width,n.height),e.transmissionMap&&(t.transmissionMap.value=e.transmissionMap),t.thickness.value=e.thickness,e.thicknessMap&&(t.thicknessMap.value=e.thicknessMap),t.attenuationDistance.value=e.attenuationDistance,t.attenuationColor.value.copy(e.attenuationColor));t.specularIntensity.value=e.specularIntensity,t.specularColor.value.copy(e.specularColor),e.specularIntensityMap&&(t.specularIntensityMap.value=e.specularIntensityMap);e.specularColorMap&&(t.specularColorMap.value=e.specularColorMap)}(t,r,o)):r.isMeshMatcapMaterial?(n(t,r),function(t,e){e.matcap&&(t.matcap.value=e.matcap)}(t,r)):r.isMeshDepthMaterial?n(t,r):r.isMeshDistanceMaterial?(n(t,r),function(t,e){t.referencePosition.value.copy(e.referencePosition),t.nearDistance.value=e.nearDistance,t.farDistance.value=e.farDistance}(t,r)):r.isMeshNormalMaterial?n(t,r):r.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,r),r.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,r)):r.isPointsMaterial?function(t,e,n,r){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*n,t.scale.value=.5*r,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);e.alphaTest>0&&(t.alphaTest.value=e.alphaTest);let i;e.map?i=e.map:e.alphaMap&&(i=e.alphaMap);void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,r,i,a):r.isSpriteMaterial?function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.rotation.value=e.rotation,e.map&&(t.map.value=e.map);e.alphaMap&&(t.alphaMap.value=e.alphaMap);e.alphaTest>0&&(t.alphaTest.value=e.alphaTest);let n;e.map?n=e.map:e.alphaMap&&(n=e.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),t.uvTransform.value.copy(n.matrix))}(t,r):r.isShadowMaterial?(t.color.value.copy(r.color),t.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Ea(t,e,n,r){let i={},a={},o=[];const s=n.isWebGL2?t.getParameter(35375):0;function A(t,e,n){const r=t.value;if(void 0===n[e])return n[e]="number"==typeof r?r:r.clone(),!0;if("number"==typeof r){if(n[e]!==r)return n[e]=r,!0}else{const t=n[e];if(!1===t.equals(r))return t.copy(r),!0}return!1}function l(t){const e=t.value,n={boundary:0,storage:0};return"number"==typeof e?(n.boundary=4,n.storage=4):e.isVector2?(n.boundary=8,n.storage=8):e.isVector3||e.isColor?(n.boundary=16,n.storage=12):e.isVector4?(n.boundary=16,n.storage=16):e.isMatrix3?(n.boundary=48,n.storage=48):e.isMatrix4?(n.boundary=64,n.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),n}function u(e){const n=e.target;n.removeEventListener("dispose",u);const r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),t.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}return{bind:function(t,e){const n=e.program;r.uniformBlockBinding(t,n)},update:function(n,c){let h=i[n.id];void 0===h&&(!function(t){const e=t.uniforms;let n=0;const r=16;let i=0;for(let t=0,a=e.length;t<a;t++){const a=e[t],o=l(a);if(a.__data=new Float32Array(o.storage/Float32Array.BYTES_PER_ELEMENT),a.__offset=n,t>0){i=n%r;const t=r-i;0!==i&&t-o.boundary<0&&(n+=r-i,a.__offset=n)}n+=o.storage}i=n%r,i>0&&(n+=r-i);t.__size=n,t.__cache={}}(n),h=function(e){const n=function(){for(let t=0;t<s;t++)if(-1===o.indexOf(t))return o.push(t),t;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();e.__bindingPointIndex=n;const r=t.createBuffer(),i=e.__size,a=e.usage;return t.bindBuffer(35345,r),t.bufferData(35345,i,a),t.bindBuffer(35345,null),t.bindBufferBase(35345,n,r),r}(n),i[n.id]=h,n.addEventListener("dispose",u));const f=c.program;r.updateUBOMapping(n,f);const d=e.render.frame;a[n.id]!==d&&(!function(e){const n=i[e.id],r=e.uniforms,a=e.__cache;t.bindBuffer(35345,n);for(let e=0,n=r.length;e<n;e++){const n=r[e];if(!0===A(n,e,a)){const e=n.value,r=n.__offset;"number"==typeof e?(n.__data[0]=e,t.bufferSubData(35345,r,n.__data)):(n.value.isMatrix3?(n.__data[0]=n.value.elements[0],n.__data[1]=n.value.elements[1],n.__data[2]=n.value.elements[2],n.__data[3]=n.value.elements[0],n.__data[4]=n.value.elements[3],n.__data[5]=n.value.elements[4],n.__data[6]=n.value.elements[5],n.__data[7]=n.value.elements[0],n.__data[8]=n.value.elements[6],n.__data[9]=n.value.elements[7],n.__data[10]=n.value.elements[8],n.__data[11]=n.value.elements[0]):e.toArray(n.__data),t.bufferSubData(35345,r,n.__data))}}t.bindBuffer(35345,null)}(n),a[n.id]=d)},dispose:function(){for(const e in i)t.deleteBuffer(i[e]);o=[],i={},a={}}}}function Ta(t={}){this.isWebGLRenderer=!0;const e=void 0!==t.canvas?t.canvas:function(){const t=ft("canvas");return t.style.display="block",t}(),n=void 0!==t.context?t.context:null,r=void 0===t.depth||t.depth,i=void 0===t.stencil||t.stencil,a=void 0!==t.antialias&&t.antialias,o=void 0===t.premultipliedAlpha||t.premultipliedAlpha,s=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,A=void 0!==t.powerPreference?t.powerPreference:"default",l=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat;let u;u=null!==n?n.getContextAttributes().alpha:void 0!==t.alpha&&t.alpha;let c=null,h=null;const f=[],d=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=G,this.physicallyCorrectLights=!1,this.toneMapping=0,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});const p=this;let m=!1,g=0,v=0,x=null,y=-1,b=null;const _=new Lt,w=new Lt;let M=null,S=e.width,E=e.height,T=1,C=null,L=null;const O=new Lt(0,0,S,E),k=new Lt(0,0,S,E);let B=!1;const N=new Yn;let z=!1,U=!1,F=null;const j=new he,H=new ut,V=new kt,W={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Q(){return null===x?T:1}let X,Y,Z,J,K,$,tt,et,nt,rt,it,at,st,At,lt,ct,ht,dt,pt,mt,gt,vt,xt,yt,bt=n;function _t(t,n){for(let r=0;r<t.length;r++){const i=t[r],a=e.getContext(i,n);if(null!==a)return a}return null}try{const t={alpha:!0,depth:r,stencil:i,antialias:a,premultipliedAlpha:o,preserveDrawingBuffer:s,powerPreference:A,failIfMajorPerformanceCaveat:l};if("setAttribute"in e&&e.setAttribute("data-engine","three.js r146"),e.addEventListener("webglcontextlost",St,!1),e.addEventListener("webglcontextrestored",Et,!1),e.addEventListener("webglcontextcreationerror",Tt,!1),null===bt){const e=["webgl2","webgl","experimental-webgl"];if(!0===p.isWebGL1Renderer&&e.shift(),bt=_t(e,t),null===bt)throw _t(e)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}void 0===bt.getShaderPrecisionFormat&&(bt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(t){throw console.error("THREE.WebGLRenderer: "+t.message),t}function wt(){X=new Mr(bt),Y=new ar(bt,X,t),X.init(Y),vt=new va(bt,X,Y),Z=new ma(bt,X,Y),J=new Tr,K=new na,$=new ga(bt,X,Z,K,Y,vt,J),tt=new sr(p),et=new wr(p),nt=new Jn(bt,Y),xt=new rr(bt,X,nt,Y),rt=new Sr(bt,nt,J,xt),it=new Lr(bt,rt,nt,J),pt=new Dr(bt,Y,$),ct=new or(K),at=new ea(p,tt,et,X,Y,xt,ct),st=new Sa(p,K),At=new oa,lt=new ha(X,Y),dt=new nr(p,tt,et,Z,it,u,o),ht=new pa(p,it,Y),yt=new Ea(bt,J,Y,Z),mt=new ir(bt,X,J,Y),gt=new Er(bt,X,J,Y),J.programs=at.programs,p.capabilities=Y,p.extensions=X,p.properties=K,p.renderLists=At,p.shadowMap=ht,p.state=Z,p.info=J}wt();const Mt=new Ma(p,bt);function St(t){t.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),m=!0}function Et(){console.log("THREE.WebGLRenderer: Context Restored."),m=!1;const t=J.autoReset,e=ht.enabled,n=ht.autoUpdate,r=ht.needsUpdate,i=ht.type;wt(),J.autoReset=t,ht.enabled=e,ht.autoUpdate=n,ht.needsUpdate=r,ht.type=i}function Tt(t){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",t.statusMessage)}function Ct(t){const e=t.target;e.removeEventListener("dispose",Ct),function(t){(function(t){const e=K.get(t).programs;void 0!==e&&(e.forEach((function(t){at.releaseProgram(t)})),t.isShaderMaterial&&at.releaseShaderCache(t))})(t),K.remove(t)}(e)}this.xr=Mt,this.getContext=function(){return bt},this.getContextAttributes=function(){return bt.getContextAttributes()},this.forceContextLoss=function(){const t=X.get("WEBGL_lose_context");t&&t.loseContext()},this.forceContextRestore=function(){const t=X.get("WEBGL_lose_context");t&&t.restoreContext()},this.getPixelRatio=function(){return T},this.setPixelRatio=function(t){void 0!==t&&(T=t,this.setSize(S,E,!1))},this.getSize=function(t){return t.set(S,E)},this.setSize=function(t,n,r){Mt.isPresenting?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(S=t,E=n,e.width=Math.floor(t*T),e.height=Math.floor(n*T),!1!==r&&(e.style.width=t+"px",e.style.height=n+"px"),this.setViewport(0,0,t,n))},this.getDrawingBufferSize=function(t){return t.set(S*T,E*T).floor()},this.setDrawingBufferSize=function(t,n,r){S=t,E=n,T=r,e.width=Math.floor(t*r),e.height=Math.floor(n*r),this.setViewport(0,0,t,n)},this.getCurrentViewport=function(t){return t.copy(_)},this.getViewport=function(t){return t.copy(O)},this.setViewport=function(t,e,n,r){t.isVector4?O.set(t.x,t.y,t.z,t.w):O.set(t,e,n,r),Z.viewport(_.copy(O).multiplyScalar(T).floor())},this.getScissor=function(t){return t.copy(k)},this.setScissor=function(t,e,n,r){t.isVector4?k.set(t.x,t.y,t.z,t.w):k.set(t,e,n,r),Z.scissor(w.copy(k).multiplyScalar(T).floor())},this.getScissorTest=function(){return B},this.setScissorTest=function(t){Z.setScissorTest(B=t)},this.setOpaqueSort=function(t){C=t},this.setTransparentSort=function(t){L=t},this.getClearColor=function(t){return t.copy(dt.getClearColor())},this.setClearColor=function(){dt.setClearColor.apply(dt,arguments)},this.getClearAlpha=function(){return dt.getClearAlpha()},this.setClearAlpha=function(){dt.setClearAlpha.apply(dt,arguments)},this.clear=function(t=!0,e=!0,n=!0){let r=0;t&&(r|=16384),e&&(r|=256),n&&(r|=1024),bt.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(){e.removeEventListener("webglcontextlost",St,!1),e.removeEventListener("webglcontextrestored",Et,!1),e.removeEventListener("webglcontextcreationerror",Tt,!1),At.dispose(),lt.dispose(),K.dispose(),tt.dispose(),et.dispose(),it.dispose(),xt.dispose(),yt.dispose(),at.dispose(),Mt.dispose(),Mt.removeEventListener("sessionstart",Dt),Mt.removeEventListener("sessionend",Rt),F&&(F.dispose(),F=null),Ot.stop()},this.renderBufferDirect=function(t,e,n,r,i,a){null===e&&(e=W);const o=i.isMesh&&i.matrixWorld.determinant()<0,s=function(t,e,n,r,i){!0!==e.isScene&&(e=W);$.resetTextureUnits();const a=e.fog,o=r.isMeshStandardMaterial?e.environment:null,s=null===x?p.outputEncoding:!0===x.isXRRenderTarget?x.texture.encoding:G,A=(r.isMeshStandardMaterial?et:tt).get(r.envMap||o),l=!0===r.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,u=!!r.normalMap&&!!n.attributes.tangent,c=!!n.morphAttributes.position,f=!!n.morphAttributes.normal,d=!!n.morphAttributes.color,m=r.toneMapped?p.toneMapping:0,g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,_=K.get(r),w=h.state.lights;if(!0===z&&(!0===U||t!==b)){const e=t===b&&r.id===y;ct.setState(r,t,e)}let M=!1;r.version===_.__version?_.needsLights&&_.lightsStateVersion!==w.state.version||_.outputEncoding!==s||i.isInstancedMesh&&!1===_.instancing?M=!0:i.isInstancedMesh||!0!==_.instancing?i.isSkinnedMesh&&!1===_.skinning?M=!0:i.isSkinnedMesh||!0!==_.skinning?_.envMap!==A||!0===r.fog&&_.fog!==a?M=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===ct.numPlanes&&_.numIntersection===ct.numIntersection?(_.vertexAlphas!==l||_.vertexTangents!==u||_.morphTargets!==c||_.morphNormals!==f||_.morphColors!==d||_.toneMapping!==m||!0===Y.isWebGL2&&_.morphTargetsCount!==v)&&(M=!0):M=!0:M=!0:M=!0:(M=!0,_.__version=r.version);let S=_.currentProgram;!0===M&&(S=Ut(r,e,i));let C=!1,P=!1,D=!1;const L=S.getUniforms(),q=_.uniforms;Z.useProgram(S.program)&&(C=!0,P=!0,D=!0);r.id!==y&&(y=r.id,P=!0);if(C||b!==t){if(L.setValue(bt,"projectionMatrix",t.projectionMatrix),Y.logarithmicDepthBuffer&&L.setValue(bt,"logDepthBufFC",2/(Math.log(t.far+1)/Math.LN2)),b!==t&&(b=t,P=!0,D=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshStandardMaterial||r.envMap){const e=L.map.cameraPosition;void 0!==e&&e.setValue(bt,V.setFromMatrixPosition(t.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&L.setValue(bt,"isOrthographic",!0===t.isOrthographicCamera),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isShadowMaterial||i.isSkinnedMesh)&&L.setValue(bt,"viewMatrix",t.matrixWorldInverse)}if(i.isSkinnedMesh){L.setOptional(bt,i,"bindMatrix"),L.setOptional(bt,i,"bindMatrixInverse");const t=i.skeleton;t&&(Y.floatVertexTextures?(null===t.boneTexture&&t.computeBoneTexture(),L.setValue(bt,"boneTexture",t.boneTexture,$),L.setValue(bt,"boneTextureSize",t.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 R=n.morphAttributes;(void 0!==R.position||void 0!==R.normal||void 0!==R.color&&!0===Y.isWebGL2)&&pt.update(i,n,r,S);(P||_.receiveShadow!==i.receiveShadow)&&(_.receiveShadow=i.receiveShadow,L.setValue(bt,"receiveShadow",i.receiveShadow));r.isMeshGouraudMaterial&&null!==r.envMap&&(q.envMap.value=A,q.flipEnvMap.value=A.isCubeTexture&&!1===A.isRenderTargetTexture?-1:1);P&&(L.setValue(bt,"toneMappingExposure",p.toneMappingExposure),_.needsLights&&(I=D,(O=q).ambientLightColor.needsUpdate=I,O.lightProbe.needsUpdate=I,O.directionalLights.needsUpdate=I,O.directionalLightShadows.needsUpdate=I,O.pointLights.needsUpdate=I,O.pointLightShadows.needsUpdate=I,O.spotLights.needsUpdate=I,O.spotLightShadows.needsUpdate=I,O.rectAreaLights.needsUpdate=I,O.hemisphereLights.needsUpdate=I),a&&!0===r.fog&&st.refreshFogUniforms(q,a),st.refreshMaterialUniforms(q,r,T,E,F),Ii.upload(bt,_.uniformsList,q,$));var O,I;r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(Ii.upload(bt,_.uniformsList,q,$),r.uniformsNeedUpdate=!1);r.isSpriteMaterial&&L.setValue(bt,"center",i.center);if(L.setValue(bt,"modelViewMatrix",i.modelViewMatrix),L.setValue(bt,"normalMatrix",i.normalMatrix),L.setValue(bt,"modelMatrix",i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){const t=r.uniformsGroups;for(let e=0,n=t.length;e<n;e++)if(Y.isWebGL2){const n=t[e];yt.update(n,S),yt.bind(n,S)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return S}(t,e,n,r,i);Z.setMaterial(r,o);let A=n.index;const l=n.attributes.position;if(null===A){if(void 0===l||0===l.count)return}else if(0===A.count)return;let u,c=1;!0===r.wireframe&&(A=rt.getWireframeAttribute(n),c=2),xt.setup(i,r,s,n,A);let f=mt;null!==A&&(u=nt.get(A),f=gt,f.setIndex(u));const d=null!==A?A.count:l.count,m=n.drawRange.start*c,g=n.drawRange.count*c,v=null!==a?a.start*c:0,_=null!==a?a.count*c:1/0,w=Math.max(m,v),M=Math.min(d,m+g,v+_)-1,S=Math.max(0,M-w+1);if(0!==S){if(i.isMesh)!0===r.wireframe?(Z.setLineWidth(r.wireframeLinewidth*Q()),f.setMode(1)):f.setMode(4);else if(i.isLine){let t=r.linewidth;void 0===t&&(t=1),Z.setLineWidth(t*Q()),i.isLineSegments?f.setMode(1):i.isLineLoop?f.setMode(2):f.setMode(3)}else i.isPoints?f.setMode(0):i.isSprite&&f.setMode(4);if(i.isInstancedMesh)f.renderInstances(w,S,i.count);else if(n.isInstancedBufferGeometry){const t=Math.min(n.instanceCount,n._maxInstanceCount);f.renderInstances(w,S,t)}else f.render(w,S)}},this.compile=function(t,e){function n(t,e,n){!0===t.transparent&&2===t.side?(t.side=1,t.needsUpdate=!0,Ut(t,e,n),t.side=0,t.needsUpdate=!0,Ut(t,e,n),t.side=2):Ut(t,e,n)}h=lt.get(t),h.init(),d.push(h),t.traverseVisible((function(t){t.isLight&&t.layers.test(e.layers)&&(h.pushLight(t),t.castShadow&&h.pushShadow(t))})),h.setupLights(p.physicallyCorrectLights),t.traverse((function(e){const r=e.material;if(r)if(Array.isArray(r))for(let i=0;i<r.length;i++){n(r[i],t,e)}else n(r,t,e)})),d.pop(),h=null};let Pt=null;function Dt(){Ot.stop()}function Rt(){Ot.start()}const Ot=new Zn;function It(t,e,n,r){if(!1===t.visible)return;if(t.layers.test(e.layers))if(t.isGroup)n=t.renderOrder;else if(t.isLOD)!0===t.autoUpdate&&t.update(e);else if(t.isLight)h.pushLight(t),t.castShadow&&h.pushShadow(t);else if(t.isSprite){if(!t.frustumCulled||N.intersectsSprite(t)){r&&V.setFromMatrixPosition(t.matrixWorld).applyMatrix4(j);const e=it.update(t),i=t.material;i.visible&&c.push(t,e,i,n,V.z,null)}}else if((t.isMesh||t.isLine||t.isPoints)&&(t.isSkinnedMesh&&t.skeleton.frame!==J.render.frame&&(t.skeleton.update(),t.skeleton.frame=J.render.frame),!t.frustumCulled||N.intersectsObject(t))){r&&V.setFromMatrixPosition(t.matrixWorld).applyMatrix4(j);const e=it.update(t),i=t.material;if(Array.isArray(i)){const r=e.groups;for(let a=0,o=r.length;a<o;a++){const o=r[a],s=i[o.materialIndex];s&&s.visible&&c.push(t,e,s,n,V.z,o)}}else i.visible&&c.push(t,e,i,n,V.z,null)}const i=t.children;for(let t=0,a=i.length;t<a;t++)It(i[t],e,n,r)}function Bt(t,e,n,r){const i=t.opaque,o=t.transmissive,s=t.transparent;h.setupLightsView(n),o.length>0&&function(t,e,n){const r=Y.isWebGL2;null===F&&(F=new qt(1,1,{generateMipmaps:!0,type:X.has("EXT_color_buffer_half_float")?R:D,minFilter:P,samples:r&&!0===a?4:0}));p.getDrawingBufferSize(H),r?F.setSize(H.x,H.y):F.setSize(ot(H.x),ot(H.y));const i=p.getRenderTarget();p.setRenderTarget(F),p.clear();const o=p.toneMapping;p.toneMapping=0,Nt(t,e,n),p.toneMapping=o,$.updateMultisampleRenderTarget(F),$.updateRenderTargetMipmap(F),p.setRenderTarget(i)}(i,e,n),r&&Z.viewport(_.copy(r)),i.length>0&&Nt(i,e,n),o.length>0&&Nt(o,e,n),s.length>0&&Nt(s,e,n),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function Nt(t,e,n){const r=!0===e.isScene?e.overrideMaterial:null;for(let i=0,a=t.length;i<a;i++){const a=t[i],o=a.object,s=a.geometry,A=null===r?a.material:r,l=a.group;o.layers.test(n.layers)&&zt(o,e,n,s,A,l)}}function zt(t,e,n,r,i,a){t.onBeforeRender(p,e,n,r,i,a),t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix),i.onBeforeRender(p,e,n,r,t,a),!0===i.transparent&&2===i.side?(i.side=1,i.needsUpdate=!0,p.renderBufferDirect(n,e,r,i,t,a),i.side=0,i.needsUpdate=!0,p.renderBufferDirect(n,e,r,i,t,a),i.side=2):p.renderBufferDirect(n,e,r,i,t,a),t.onAfterRender(p,e,n,r,i,a)}function Ut(t,e,n){!0!==e.isScene&&(e=W);const r=K.get(t),i=h.state.lights,a=h.state.shadowsArray,o=i.state.version,s=at.getParameters(t,i.state,a,e,n),A=at.getProgramCacheKey(s);let l=r.programs;r.environment=t.isMeshStandardMaterial?e.environment:null,r.fog=e.fog,r.envMap=(t.isMeshStandardMaterial?et:tt).get(t.envMap||r.environment),void 0===l&&(t.addEventListener("dispose",Ct),l=new Map,r.programs=l);let u=l.get(A);if(void 0!==u){if(r.currentProgram===u&&r.lightsStateVersion===o)return Ft(t,s),u}else s.uniforms=at.getUniforms(t),t.onBuild(n,s,p),t.onBeforeCompile(s,p),u=at.acquireProgram(s,A),l.set(A,u),r.uniforms=s.uniforms;const c=r.uniforms;(t.isShaderMaterial||t.isRawShaderMaterial)&&!0!==t.clipping||(c.clippingPlanes=ct.uniform),Ft(t,s),r.needsLights=function(t){return t.isMeshLambertMaterial||t.isMeshToonMaterial||t.isMeshPhongMaterial||t.isMeshStandardMaterial||t.isShadowMaterial||t.isShaderMaterial&&!0===t.lights}(t),r.lightsStateVersion=o,r.needsLights&&(c.ambientLightColor.value=i.state.ambient,c.lightProbe.value=i.state.probe,c.directionalLights.value=i.state.directional,c.directionalLightShadows.value=i.state.directionalShadow,c.spotLights.value=i.state.spot,c.spotLightShadows.value=i.state.spotShadow,c.rectAreaLights.value=i.state.rectArea,c.ltc_1.value=i.state.rectAreaLTC1,c.ltc_2.value=i.state.rectAreaLTC2,c.pointLights.value=i.state.point,c.pointLightShadows.value=i.state.pointShadow,c.hemisphereLights.value=i.state.hemi,c.directionalShadowMap.value=i.state.directionalShadowMap,c.directionalShadowMatrix.value=i.state.directionalShadowMatrix,c.spotShadowMap.value=i.state.spotShadowMap,c.spotLightMatrix.value=i.state.spotLightMatrix,c.spotLightMap.value=i.state.spotLightMap,c.pointShadowMap.value=i.state.pointShadowMap,c.pointShadowMatrix.value=i.state.pointShadowMatrix);const f=u.getUniforms(),d=Ii.seqWithValue(f.seq,c);return r.currentProgram=u,r.uniformsList=d,u}function Ft(t,e){const n=K.get(t);n.outputEncoding=e.outputEncoding,n.instancing=e.instancing,n.skinning=e.skinning,n.morphTargets=e.morphTargets,n.morphNormals=e.morphNormals,n.morphColors=e.morphColors,n.morphTargetsCount=e.morphTargetsCount,n.numClippingPlanes=e.numClippingPlanes,n.numIntersection=e.numClipIntersection,n.vertexAlphas=e.vertexAlphas,n.vertexTangents=e.vertexTangents,n.toneMapping=e.toneMapping}Ot.setAnimationLoop((function(t){Pt&&Pt(t)})),"undefined"!=typeof self&&Ot.setContext(self),this.setAnimationLoop=function(t){Pt=t,Mt.setAnimationLoop(t),null===t?Ot.stop():Ot.start()},Mt.addEventListener("sessionstart",Dt),Mt.addEventListener("sessionend",Rt),this.render=function(t,e){if(void 0!==e&&!0!==e.isCamera)return void console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===m)return;!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),null===e.parent&&!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),!0===Mt.enabled&&!0===Mt.isPresenting&&(!0===Mt.cameraAutoUpdate&&Mt.updateCamera(e),e=Mt.getCamera()),!0===t.isScene&&t.onBeforeRender(p,t,e,x),h=lt.get(t,d.length),h.init(),d.push(h),j.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),N.setFromProjectionMatrix(j),U=this.localClippingEnabled,z=ct.init(this.clippingPlanes,U,e),c=At.get(t,f.length),c.init(),f.push(c),It(t,e,0,p.sortObjects),c.finish(),!0===p.sortObjects&&c.sort(C,L),!0===z&&ct.beginShadows();const n=h.state.shadowsArray;if(ht.render(n,t,e),!0===z&&ct.endShadows(),!0===this.info.autoReset&&this.info.reset(),dt.render(c,t),h.setupLights(p.physicallyCorrectLights),e.isArrayCamera){const n=e.cameras;for(let e=0,r=n.length;e<r;e++){const r=n[e];Bt(c,t,r,r.viewport)}}else Bt(c,t,e);null!==x&&($.updateMultisampleRenderTarget(x),$.updateRenderTargetMipmap(x)),!0===t.isScene&&t.onAfterRender(p,t,e),xt.resetDefaultState(),y=-1,b=null,d.pop(),h=d.length>0?d[d.length-1]:null,f.pop(),c=f.length>0?f[f.length-1]:null},this.getActiveCubeFace=function(){return g},this.getActiveMipmapLevel=function(){return v},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(t,e,n){K.get(t.texture).__webglTexture=e,K.get(t.depthTexture).__webglTexture=n;const r=K.get(t);r.__hasExternalTextures=!0,r.__hasExternalTextures&&(r.__autoAllocateDepthBuffer=void 0===n,r.__autoAllocateDepthBuffer||!0===X.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(t,e){const n=K.get(t);n.__webglFramebuffer=e,n.__useDefaultFramebuffer=void 0===e},this.setRenderTarget=function(t,e=0,n=0){x=t,g=e,v=n;let r=!0,i=null,a=!1,o=!1;if(t){const n=K.get(t);void 0!==n.__useDefaultFramebuffer?(Z.bindFramebuffer(36160,null),r=!1):void 0===n.__webglFramebuffer?$.setupRenderTarget(t):n.__hasExternalTextures&&$.rebindTextures(t,K.get(t.texture).__webglTexture,K.get(t.depthTexture).__webglTexture);const s=t.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(o=!0);const A=K.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(i=A[e],a=!0):i=Y.isWebGL2&&t.samples>0&&!1===$.useMultisampledRTT(t)?K.get(t).__webglMultisampledFramebuffer:A,_.copy(t.viewport),w.copy(t.scissor),M=t.scissorTest}else _.copy(O).multiplyScalar(T).floor(),w.copy(k).multiplyScalar(T).floor(),M=B;if(Z.bindFramebuffer(36160,i)&&Y.drawBuffers&&r&&Z.drawBuffers(t,i),Z.viewport(_),Z.scissor(w),Z.setScissorTest(M),a){const r=K.get(t.texture);bt.framebufferTexture2D(36160,36064,34069+e,r.__webglTexture,n)}else if(o){const r=K.get(t.texture),i=e||0;bt.framebufferTextureLayer(36160,36064,r.__webglTexture,n||0,i)}y=-1},this.readRenderTargetPixels=function(t,e,n,r,i,a,o){if(!t||!t.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let s=K.get(t).__webglFramebuffer;if(t.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){Z.bindFramebuffer(36160,s);try{const o=t.texture,s=o.format,A=o.type;if(s!==I&&vt.convert(s)!==bt.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const l=A===R&&(X.has("EXT_color_buffer_half_float")||Y.isWebGL2&&X.has("EXT_color_buffer_float"));if(!(A===D||vt.convert(A)===bt.getParameter(35738)||A===q&&(Y.isWebGL2||X.has("OES_texture_float")||X.has("WEBGL_color_buffer_float"))||l))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");e>=0&&e<=t.width-r&&n>=0&&n<=t.height-i&&bt.readPixels(e,n,r,i,vt.convert(s),vt.convert(A),a)}finally{const t=null!==x?K.get(x).__webglFramebuffer:null;Z.bindFramebuffer(36160,t)}}},this.copyFramebufferToTexture=function(t,e,n=0){const r=Math.pow(2,-n),i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r);$.setTexture2D(e,0),bt.copyTexSubImage2D(3553,n,0,0,t.x,t.y,i,a),Z.unbindTexture()},this.copyTextureToTexture=function(t,e,n,r=0){const i=e.image.width,a=e.image.height,o=vt.convert(n.format),s=vt.convert(n.type);$.setTexture2D(n,0),bt.pixelStorei(37440,n.flipY),bt.pixelStorei(37441,n.premultiplyAlpha),bt.pixelStorei(3317,n.unpackAlignment),e.isDataTexture?bt.texSubImage2D(3553,r,t.x,t.y,i,a,o,s,e.image.data):e.isCompressedTexture?bt.compressedTexSubImage2D(3553,r,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,o,e.mipmaps[0].data):bt.texSubImage2D(3553,r,t.x,t.y,o,s,e.image),0===r&&n.generateMipmaps&&bt.generateMipmap(3553),Z.unbindTexture()},this.copyTextureToTexture3D=function(t,e,n,r,i=0){if(p.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const a=t.max.x-t.min.x+1,o=t.max.y-t.min.y+1,s=t.max.z-t.min.z+1,A=vt.convert(r.format),l=vt.convert(r.type);let u;if(r.isData3DTexture)$.setTexture3D(r,0),u=32879;else{if(!r.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");$.setTexture2DArray(r,0),u=35866}bt.pixelStorei(37440,r.flipY),bt.pixelStorei(37441,r.premultiplyAlpha),bt.pixelStorei(3317,r.unpackAlignment);const c=bt.getParameter(3314),h=bt.getParameter(32878),f=bt.getParameter(3316),d=bt.getParameter(3315),m=bt.getParameter(32877),g=n.isCompressedTexture?n.mipmaps[0]:n.image;bt.pixelStorei(3314,g.width),bt.pixelStorei(32878,g.height),bt.pixelStorei(3316,t.min.x),bt.pixelStorei(3315,t.min.y),bt.pixelStorei(32877,t.min.z),n.isDataTexture||n.isData3DTexture?bt.texSubImage3D(u,i,e.x,e.y,e.z,a,o,s,A,l,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),bt.compressedTexSubImage3D(u,i,e.x,e.y,e.z,a,o,s,A,g.data)):bt.texSubImage3D(u,i,e.x,e.y,e.z,a,o,s,A,l,g),bt.pixelStorei(3314,c),bt.pixelStorei(32878,h),bt.pixelStorei(3316,f),bt.pixelStorei(3315,d),bt.pixelStorei(32877,m),0===i&&r.generateMipmaps&&bt.generateMipmap(u),Z.unbindTexture()},this.initTexture=function(t){t.isCubeTexture?$.setTextureCube(t,0):t.isData3DTexture?$.setTexture3D(t,0):t.isDataArrayTexture||t.isCompressedArrayTexture?$.setTexture2DArray(t,0):$.setTexture2D(t,0),Z.unbindTexture()},this.resetState=function(){g=0,v=0,x=null,Z.reset(),xt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}(class extends Ta{}).prototype.isWebGL1Renderer=!0;class Ca{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=Q,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=et()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let r=0,i=this.stride;r<i;r++)this.array[t+r]=e.array[n+r];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=et()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return void 0===t.arrayBuffers&&(t.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=et()),void 0===t.arrayBuffers[this.array.buffer._uuid]&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Pa=new kt;class Da{constructor(t,e,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=!0===r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)Pa.fromBufferAttribute(this,e),Pa.applyMatrix4(t),this.setXYZ(e,Pa.x,Pa.y,Pa.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Pa.fromBufferAttribute(this,e),Pa.applyNormalMatrix(t),this.setXYZ(e,Pa.x,Pa.y,Pa.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Pa.fromBufferAttribute(this,e),Pa.transformDirection(t),this.setXYZ(e,Pa.x,Pa.y,Pa.z);return this}setX(t,e){return this.normalized&&(e=At(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=At(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=At(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=At(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=st(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=st(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=st(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=st(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=At(e,this.array),n=At(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=At(e,this.array),n=At(n,this.array),r=At(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this}setXYZW(t,e,n,r,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=At(e,this.array),n=At(n,this.array),r=At(r,this.array),i=At(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=r,this.data.array[t+3]=i,this}clone(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return new tn(new this.array.constructor(t),this.itemSize,this.normalized)}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Da(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(void 0===t){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will deinterleave buffer data.");const t=[];for(let e=0;e<this.count;e++){const n=e*this.data.stride+this.offset;for(let e=0;e<this.itemSize;e++)t.push(this.data.array[n+e])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}return void 0===t.interleavedBuffers&&(t.interleavedBuffers={}),void 0===t.interleavedBuffers[this.data.uuid]&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class La extends tn{constructor(t,e,n,r=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}class qa extends Ze{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new St(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const Ra=new kt,Oa=new kt,Ia=new he,ka=new ce,Ba=new re;class Na extends Be{constructor(t=new hn,e=new qa){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[0];for(let t=1,r=e.count;t<r;t++)Ra.fromBufferAttribute(e,t-1),Oa.fromBufferAttribute(e,t),n[t]=n[t-1],n[t]+=Ra.distanceTo(Oa);t.setAttribute("lineDistance",new rn(n,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,r=this.matrixWorld,i=t.params.Line.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Ba.copy(n.boundingSphere),Ba.applyMatrix4(r),Ba.radius+=i,!1===t.ray.intersectsSphere(Ba))return;Ia.copy(r).invert(),ka.copy(t.ray).applyMatrix4(Ia);const o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,A=new kt,l=new kt,u=new kt,c=new kt,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(ka.distanceSqToSegment(A,l,c,u)>s)continue;c.applyMatrix4(this.matrixWorld);const a=t.ray.origin.distanceTo(c);a<t.near||a>t.far||e.push({distance:a,point:u.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(ka.distanceSqToSegment(A,l,c,u)>s)continue;c.applyMatrix4(this.matrixWorld);const r=t.ray.origin.distanceTo(c);r<t.near||r>t.far||e.push({distance:r,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const t=this.geometry.morphAttributes,e=Object.keys(t);if(e.length>0){const n=t[e[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=n.length;t<e;t++){const e=n[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}}}}const za=new kt,Ua=new kt;class Fa extends Na{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(null===t.index){const e=t.attributes.position,n=[];for(let t=0,r=e.count;t<r;t+=2)za.fromBufferAttribute(e,t),Ua.fromBufferAttribute(e,t+1),n[t]=0===t?0:n[t-1],n[t+1]=n[t]+za.distanceTo(Ua);t.setAttribute("lineDistance",new rn(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Ga{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,r=this.getPoint(0),i=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),i+=n.distanceTo(r),e.push(i),r=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let r=0;const i=n.length;let a;a=e||t*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(t,e){const n=1e-4;let r=t-n,i=t+n;r<0&&(r=0),i>1&&(i=1);const a=this.getPoint(r),o=this.getPoint(i),s=e||(a.isVector2?new ut:new kt);return s.copy(o).sub(a).normalize(),s}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new kt,r=[],i=[],a=[],o=new kt,s=new he;for(let e=0;e<=t;e++){const n=e/t;r[e]=this.getTangentAt(n,new kt)}i[0]=new kt,a[0]=new kt;let A=Number.MAX_VALUE;const l=Math.abs(r[0].x),u=Math.abs(r[0].y),c=Math.abs(r[0].z);l<=A&&(A=l,n.set(1,0,0)),u<=A&&(A=u,n.set(0,1,0)),c<=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 e=1;e<=t;e++){if(i[e]=i[e-1].clone(),a[e]=a[e-1].clone(),o.crossVectors(r[e-1],r[e]),o.length()>Number.EPSILON){o.normalize();const t=Math.acos(nt(r[e-1].dot(r[e]),-1,1));i[e].applyMatrix4(s.makeRotationAxis(o,t))}a[e].crossVectors(r[e],i[e])}if(!0===e){let e=Math.acos(nt(i[0].dot(i[t]),-1,1));e/=t,r[0].dot(o.crossVectors(i[0],i[t]))>0&&(e=-e);for(let n=1;n<=t;n++)i[n].applyMatrix4(s.makeRotationAxis(r[n],e*n)),a[n].crossVectors(r[n],i[n])}return{tangents:r,normals:i,binormals:a}}clone(){return(new this.constructor).copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class ja extends Ga{constructor(t=0,e=0,n=1,r=1,i=0,a=2*Math.PI,o=!1,s=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=r,this.aStartAngle=i,this.aEndAngle=a,this.aClockwise=o,this.aRotation=s}getPoint(t,e){const n=e||new ut,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+t*i;let s=this.aX+this.xRadius*Math.cos(o),A=this.aY+this.yRadius*Math.sin(o);if(0!==this.aRotation){const t=Math.cos(this.aRotation),e=Math.sin(this.aRotation),n=s-this.aX,r=A-this.aY;s=n*t-r*e+this.aX,A=n*e+r*t+this.aY}return n.set(s,A)}copy(t){return super.copy(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}toJSON(){const t=super.toJSON();return t.aX=this.aX,t.aY=this.aY,t.xRadius=this.xRadius,t.yRadius=this.yRadius,t.aStartAngle=this.aStartAngle,t.aEndAngle=this.aEndAngle,t.aClockwise=this.aClockwise,t.aRotation=this.aRotation,t}fromJSON(t){return super.fromJSON(t),this.aX=t.aX,this.aY=t.aY,this.xRadius=t.xRadius,this.yRadius=t.yRadius,this.aStartAngle=t.aStartAngle,this.aEndAngle=t.aEndAngle,this.aClockwise=t.aClockwise,this.aRotation=t.aRotation,this}}function Ha(){let t=0,e=0,n=0,r=0;function i(i,a,o,s){t=i,e=o,n=-3*i+3*a-2*o-s,r=2*i-2*a+o+s}return{initCatmullRom:function(t,e,n,r,a){i(e,n,a*(n-t),a*(r-e))},initNonuniformCatmullRom:function(t,e,n,r,a,o,s){let A=(e-t)/a-(n-t)/(a+o)+(n-e)/o,l=(n-e)/o-(r-e)/(o+s)+(r-n)/s;A*=o,l*=o,i(e,n,A,l)},calc:function(i){const a=i*i;return t+e*i+n*a+r*(a*i)}}}const Va=new kt,Wa=new Ha,Qa=new Ha,Xa=new Ha;function Ya(t,e,n,r,i){const a=.5*(r-e),o=.5*(i-n),s=t*t;return(2*n-2*r+a+o)*(t*s)+(-3*n+3*r-2*a-o)*s+a*t+n}function Za(t,e,n,r){return function(t,e){const n=1-t;return n*n*e}(t,e)+function(t,e){return 2*(1-t)*t*e}(t,n)+function(t,e){return t*t*e}(t,r)}function Ja(t,e,n,r,i){return function(t,e){const n=1-t;return n*n*n*e}(t,e)+function(t,e){const n=1-t;return 3*n*n*t*e}(t,n)+function(t,e){return 3*(1-t)*t*t*e}(t,r)+function(t,e){return t*t*t*e}(t,i)}class Ka extends Ga{constructor(t=new ut,e=new ut,n=new ut,r=new ut){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new ut){const n=e,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(Ja(t,r.x,i.x,a.x,o.x),Ja(t,r.y,i.y,a.y,o.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class $a extends Ga{constructor(t=new kt,e=new kt,n=new kt,r=new kt){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=t,this.v1=e,this.v2=n,this.v3=r}getPoint(t,e=new kt){const n=e,r=this.v0,i=this.v1,a=this.v2,o=this.v3;return n.set(Ja(t,r.x,i.x,a.x,o.x),Ja(t,r.y,i.y,a.y,o.y),Ja(t,r.z,i.z,a.z,o.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t.v3=this.v3.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this.v3.fromArray(t.v3),this}}class to extends Ga{constructor(t=new ut,e=new ut){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=t,this.v2=e}getPoint(t,e=new ut){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}getTangent(t,e){const n=e||new ut;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class eo extends Ga{constructor(t=new ut,e=new ut,n=new ut){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new ut){const n=e,r=this.v0,i=this.v1,a=this.v2;return n.set(Za(t,r.x,i.x,a.x),Za(t,r.y,i.y,a.y)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class no extends Ga{constructor(t=new kt,e=new kt,n=new kt){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=t,this.v1=e,this.v2=n}getPoint(t,e=new kt){const n=e,r=this.v0,i=this.v1,a=this.v2;return n.set(Za(t,r.x,i.x,a.x),Za(t,r.y,i.y,a.y),Za(t,r.z,i.z,a.z)),n}copy(t){return super.copy(t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v0=this.v0.toArray(),t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v0.fromArray(t.v0),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}}class ro extends Ga{constructor(t=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=t}getPoint(t,e=new ut){const n=e,r=this.points,i=(r.length-1)*t,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],u=r[a>r.length-3?r.length-1:a+2];return n.set(Ya(o,s.x,A.x,l.x,u.x),Ya(o,s.y,A.y,l.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new ut).fromArray(n))}return this}}var io=Object.freeze({__proto__:null,ArcCurve:class extends ja{constructor(t,e,n,r,i,a){super(t,e,n,n,r,i,a),this.isArcCurve=!0,this.type="ArcCurve"}},CatmullRomCurve3:class extends Ga{constructor(t=[],e=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=t,this.closed=e,this.curveType=n,this.tension=r}getPoint(t,e=new kt){const n=e,r=this.points,i=r.length,a=(i-(this.closed?0:1))*t;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]:(Va.subVectors(r[0],r[1]).add(r[0]),o=Va);const u=r[A%i],c=r[(A+1)%i];if(this.closed||A+2<i?s=r[(A+2)%i]:(Va.subVectors(r[i-1],r[i-2]).add(r[i-1]),s=Va),"centripetal"===this.curveType||"chordal"===this.curveType){const t="chordal"===this.curveType?.5:.25;let e=Math.pow(o.distanceToSquared(u),t),n=Math.pow(u.distanceToSquared(c),t),r=Math.pow(c.distanceToSquared(s),t);n<1e-4&&(n=1),e<1e-4&&(e=n),r<1e-4&&(r=n),Wa.initNonuniformCatmullRom(o.x,u.x,c.x,s.x,e,n,r),Qa.initNonuniformCatmullRom(o.y,u.y,c.y,s.y,e,n,r),Xa.initNonuniformCatmullRom(o.z,u.z,c.z,s.z,e,n,r)}else"catmullrom"===this.curveType&&(Wa.initCatmullRom(o.x,u.x,c.x,s.x,this.tension),Qa.initCatmullRom(o.y,u.y,c.y,s.y,this.tension),Xa.initCatmullRom(o.z,u.z,c.z,s.z,this.tension));return n.set(Wa.calc(l),Qa.calc(l),Xa.calc(l)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push(n.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}toJSON(){const t=super.toJSON();t.points=[];for(let e=0,n=this.points.length;e<n;e++){const n=this.points[e];t.points.push(n.toArray())}return t.closed=this.closed,t.curveType=this.curveType,t.tension=this.tension,t}fromJSON(t){super.fromJSON(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++){const n=t.points[e];this.points.push((new kt).fromArray(n))}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this}},CubicBezierCurve:Ka,CubicBezierCurve3:$a,EllipseCurve:ja,LineCurve:to,LineCurve3:class extends Ga{constructor(t=new kt,e=new kt){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=t,this.v2=e}getPoint(t,e=new kt){const n=e;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n}getPointAt(t,e){return this.getPoint(t,e)}copy(t){return super.copy(t),this.v1.copy(t.v1),this.v2.copy(t.v2),this}toJSON(){const t=super.toJSON();return t.v1=this.v1.toArray(),t.v2=this.v2.toArray(),t}fromJSON(t){return super.fromJSON(t),this.v1.fromArray(t.v1),this.v2.fromArray(t.v2),this}},QuadraticBezierCurve:eo,QuadraticBezierCurve3:no,SplineCurve:ro});class ao extends Ga{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(t){this.curves.push(t)}closePath(){const t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new to(e,t))}getPoint(t,e){const n=t*this.getLength(),r=this.getCurveLengths();let i=0;for(;i<r.length;){if(r[i]>=n){const t=r[i]-n,a=this.curves[i],o=a.getLength(),s=0===o?0:1-t/o;return a.getPointAt(s,e)}i++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,r=this.curves.length;n<r;n++)e+=this.curves[n].getLength(),t.push(e);return this.cacheLengths=t,t}getSpacedPoints(t=40){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return this.autoClose&&e.push(e[0]),e}getPoints(t=12){const e=[];let n;for(let r=0,i=this.curves;r<i.length;r++){const a=i[r],o=a.isEllipseCurve?2*t:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?t*a.points.length:t,s=a.getPoints(o);for(let t=0;t<s.length;t++){const r=s[t];n&&n.equals(r)||(e.push(r),n=r)}}return this.autoClose&&e.length>1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push(n.clone())}return this.autoClose=t.autoClose,this}toJSON(){const t=super.toJSON();t.autoClose=this.autoClose,t.curves=[];for(let e=0,n=this.curves.length;e<n;e++){const n=this.curves[e];t.curves.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.autoClose=t.autoClose,this.curves=[];for(let e=0,n=t.curves.length;e<n;e++){const n=t.curves[e];this.curves.push((new io[n.type]).fromJSON(n))}return this}}let oo=class extends ao{constructor(t){super(),this.type="Path",this.currentPoint=new ut,t&&this.setFromPoints(t)}setFromPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++)this.lineTo(t[e].x,t[e].y);return this}moveTo(t,e){return this.currentPoint.set(t,e),this}lineTo(t,e){const n=new to(this.currentPoint.clone(),new ut(t,e));return this.curves.push(n),this.currentPoint.set(t,e),this}quadraticCurveTo(t,e,n,r){const i=new eo(this.currentPoint.clone(),new ut(t,e),new ut(n,r));return this.curves.push(i),this.currentPoint.set(n,r),this}bezierCurveTo(t,e,n,r,i,a){const o=new Ka(this.currentPoint.clone(),new ut(t,e),new ut(n,r),new ut(i,a));return this.curves.push(o),this.currentPoint.set(i,a),this}splineThru(t){const e=[this.currentPoint.clone()].concat(t),n=new ro(e);return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this}arc(t,e,n,r,i,a){const o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(t+o,e+s,n,r,i,a),this}absarc(t,e,n,r,i,a){return this.absellipse(t,e,n,n,r,i,a),this}ellipse(t,e,n,r,i,a,o,s){const A=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(t+A,e+l,n,r,i,a,o,s),this}absellipse(t,e,n,r,i,a,o,s){const A=new ja(t,e,n,r,i,a,o,s);if(this.curves.length>0){const t=A.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(A);const l=A.getPoint(1);return this.currentPoint.copy(l),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}};class so extends hn{constructor(t=1,e=8,n=0,r=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:r},e=Math.max(3,e);const i=[],a=[],o=[],s=[],A=new kt,l=new ut;a.push(0,0,0),o.push(0,0,1),s.push(.5,.5);for(let i=0,u=3;i<=e;i++,u+=3){const c=n+i/e*r;A.x=t*Math.cos(c),A.y=t*Math.sin(c),a.push(A.x,A.y,A.z),o.push(0,0,1),l.x=(a[u]/t+1)/2,l.y=(a[u+1]/t+1)/2,s.push(l.x,l.y)}for(let t=1;t<=e;t++)i.push(t,t+1,0);this.setIndex(i),this.setAttribute("position",new rn(a,3)),this.setAttribute("normal",new rn(o,3)),this.setAttribute("uv",new rn(s,2))}static fromJSON(t){return new so(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Ao extends hn{constructor(t=1,e=1,n=1,r=8,i=1,a=!1,o=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,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=[],u=[],c=[],h=[];let f=0;const d=[],p=n/2;let m=0;function g(n){const i=f,a=new ut,d=new kt;let g=0;const v=!0===n?t:e,x=!0===n?1:-1;for(let t=1;t<=r;t++)u.push(0,p*x,0),c.push(0,x,0),h.push(.5,.5),f++;const y=f;for(let t=0;t<=r;t++){const e=t/r*s+o,n=Math.cos(e),i=Math.sin(e);d.x=v*i,d.y=p*x,d.z=v*n,u.push(d.x,d.y,d.z),c.push(0,x,0),a.x=.5*n+.5,a.y=.5*i*x+.5,h.push(a.x,a.y),f++}for(let t=0;t<r;t++){const e=i+t,r=y+t;!0===n?l.push(r,r+1,e):l.push(r+1,r,e),g+=3}A.addGroup(m,g,!0===n?1:2),m+=g}!function(){const a=new kt,g=new kt;let v=0;const x=(e-t)/n;for(let A=0;A<=i;A++){const l=[],m=A/i,v=m*(e-t)+t;for(let t=0;t<=r;t++){const e=t/r,i=e*s+o,A=Math.sin(i),d=Math.cos(i);g.x=v*A,g.y=-m*n+p,g.z=v*d,u.push(g.x,g.y,g.z),a.set(A,x,d).normalize(),c.push(a.x,a.y,a.z),h.push(e,1-m),l.push(f++)}d.push(l)}for(let t=0;t<r;t++)for(let e=0;e<i;e++){const n=d[e][t],r=d[e+1][t],i=d[e+1][t+1],a=d[e][t+1];l.push(n,r,a),l.push(r,i,a),v+=6}A.addGroup(m,v,0),m+=v}(),!1===a&&(t>0&&g(!0),e>0&&g(!1)),this.setIndex(l),this.setAttribute("position",new rn(u,3)),this.setAttribute("normal",new rn(c,3)),this.setAttribute("uv",new rn(h,2))}static fromJSON(t){return new Ao(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class lo extends oo{constructor(t){super(t),this.uuid=et(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let n=0,r=this.holes.length;n<r;n++)e[n]=this.holes[n].getPoints(t);return e}extractPoints(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}}copy(t){super.copy(t),this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push(n.clone())}return this}toJSON(){const t=super.toJSON();t.uuid=this.uuid,t.holes=[];for(let e=0,n=this.holes.length;e<n;e++){const n=this.holes[e];t.holes.push(n.toJSON())}return t}fromJSON(t){super.fromJSON(t),this.uuid=t.uuid,this.holes=[];for(let e=0,n=t.holes.length;e<n;e++){const n=t.holes[e];this.holes.push((new oo).fromJSON(n))}return this}}const uo=function(t,e,n=2){const r=e&&e.length,i=r?e[0]*n:t.length;let a=co(t,0,i,n,!0);const o=[];if(!a||a.next===a.prev)return o;let s,A,l,u,c,h,f;if(r&&(a=function(t,e,n,r){const i=[];let a,o,s,A,l;for(a=0,o=e.length;a<o;a++)s=e[a]*r,A=a<o-1?e[a+1]*r:t.length,l=co(t,s,A,r,!1),l===l.next&&(l.steiner=!0),i.push(wo(l));for(i.sort(xo),a=0;a<i.length;a++)n=yo(i[a],n);return n}(t,e,a,n)),t.length>80*n){s=l=t[0],A=u=t[1];for(let e=n;e<i;e+=n)c=t[e],h=t[e+1],c<s&&(s=c),h<A&&(A=h),c>l&&(l=c),h>u&&(u=h);f=Math.max(l-s,u-A),f=0!==f?32767/f:0}return fo(a,o,n,s,A,f,0),o};function co(t,e,n,r,i){let a,o;if(i===function(t,e,n,r){let i=0;for(let a=e,o=n-r;a<n;a+=r)i+=(t[o]-t[a])*(t[a+1]+t[o+1]),o=a;return i}(t,e,n,r)>0)for(a=e;a<n;a+=r)o=Ro(a,t[a],t[a+1],o);else for(a=n-r;a>=e;a-=r)o=Ro(a,t[a],t[a+1],o);return o&&To(o,o.next)&&(Oo(o),o=o.next),o}function ho(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!To(r,r.next)&&0!==Eo(r.prev,r,r.next))r=r.next;else{if(Oo(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function fo(t,e,n,r,i,a,o){if(!t)return;!o&&a&&function(t,e,n,r){let i=t;do{0===i.z&&(i.z=_o(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,n,r,i,a,o,s,A,l=1;do{for(n=t,t=null,a=null,o=0;n;){for(o++,r=n,s=0,e=0;e<l&&(s++,r=r.nextZ,r);e++);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:t=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1)}(i)}(t,r,i,a);let s,A,l=t;for(;t.prev!==t.next;)if(s=t.prev,A=t.next,a?mo(t,r,i,a):po(t))e.push(s.i/n|0),e.push(t.i/n|0),e.push(A.i/n|0),Oo(t),t=A.next,l=A.next;else if((t=A)===l){o?1===o?fo(t=go(ho(t),e,n),e,n,r,i,a,2):2===o&&vo(t,e,n,r,i,a):fo(ho(t),e,n,r,i,a,1);break}}function po(t){const e=t.prev,n=t,r=t.next;if(Eo(e,n,r)>=0)return!1;const i=e.x,a=n.x,o=r.x,s=e.y,A=n.y,l=r.y,u=i<a?i<o?i:o:a<o?a:o,c=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!==e;){if(d.x>=u&&d.x<=h&&d.y>=c&&d.y<=f&&Mo(i,s,a,A,o,l,d.x,d.y)&&Eo(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function mo(t,e,n,r){const i=t.prev,a=t,o=t.next;if(Eo(i,a,o)>=0)return!1;const s=i.x,A=a.x,l=o.x,u=i.y,c=a.y,h=o.y,f=s<A?s<l?s:l:A<l?A:l,d=u<c?u<h?u:h:c<h?c:h,p=s>A?s>l?s:l:A>l?A:l,m=u>c?u>h?u:h:c>h?c:h,g=_o(f,d,e,n,r),v=_o(p,m,e,n,r);let x=t.prevZ,y=t.nextZ;for(;x&&x.z>=g&&y&&y.z<=v;){if(x.x>=f&&x.x<=p&&x.y>=d&&x.y<=m&&x!==i&&x!==o&&Mo(s,u,A,c,l,h,x.x,x.y)&&Eo(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,y.x>=f&&y.x<=p&&y.y>=d&&y.y<=m&&y!==i&&y!==o&&Mo(s,u,A,c,l,h,y.x,y.y)&&Eo(y.prev,y,y.next)>=0)return!1;y=y.nextZ}for(;x&&x.z>=g;){if(x.x>=f&&x.x<=p&&x.y>=d&&x.y<=m&&x!==i&&x!==o&&Mo(s,u,A,c,l,h,x.x,x.y)&&Eo(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=v;){if(y.x>=f&&y.x<=p&&y.y>=d&&y.y<=m&&y!==i&&y!==o&&Mo(s,u,A,c,l,h,y.x,y.y)&&Eo(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function go(t,e,n){let r=t;do{const i=r.prev,a=r.next.next;!To(i,a)&&Co(i,r,r.next,a)&&Lo(i,a)&&Lo(a,i)&&(e.push(i.i/n|0),e.push(r.i/n|0),e.push(a.i/n|0),Oo(r),Oo(r.next),r=t=a),r=r.next}while(r!==t);return ho(r)}function vo(t,e,n,r,i,a){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&So(o,t)){let s=qo(o,t);return o=ho(o,o.next),s=ho(s,s.next),fo(o,e,n,r,i,a,0),void fo(s,e,n,r,i,a,0)}t=t.next}o=o.next}while(o!==t)}function xo(t,e){return t.x-e.x}function yo(t,e){const n=function(t,e){let n,r=e,i=-1/0;const a=t.x,o=t.y;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){const t=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=a&&t>i&&(i=t,n=r.x<r.next.x?r:r.next,t===a))return n}r=r.next}while(r!==e);if(!n)return null;const s=n,A=n.x,l=n.y;let u,c=1/0;r=n;do{a>=r.x&&r.x>=A&&a!==r.x&&Mo(o<l?a:i,o,A,l,o<l?i:a,o,r.x,r.y)&&(u=Math.abs(o-r.y)/(a-r.x),Lo(r,t)&&(u<c||u===c&&(r.x>n.x||r.x===n.x&&bo(n,r)))&&(n=r,c=u)),r=r.next}while(r!==s);return n}(t,e);if(!n)return e;const r=qo(n,t);return ho(r,r.next),ho(n,n.next)}function bo(t,e){return Eo(t.prev,t,e.prev)<0&&Eo(e.next,t,t.next)<0}function _o(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function wo(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function Mo(t,e,n,r,i,a,o,s){return(i-o)*(e-s)>=(t-o)*(a-s)&&(t-o)*(r-s)>=(n-o)*(e-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function So(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Co(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Lo(t,e)&&Lo(e,t)&&function(t,e){let n=t,r=!1;const i=(t.x+e.x)/2,a=(t.y+e.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!==t);return r}(t,e)&&(Eo(t.prev,t,e.prev)||Eo(t,e.prev,e))||To(t,e)&&Eo(t.prev,t,t.next)>0&&Eo(e.prev,e,e.next)>0)}function Eo(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function To(t,e){return t.x===e.x&&t.y===e.y}function Co(t,e,n,r){const i=Do(Eo(t,e,n)),a=Do(Eo(t,e,r)),o=Do(Eo(n,r,t)),s=Do(Eo(n,r,e));return i!==a&&o!==s||(!(0!==i||!Po(t,n,e))||(!(0!==a||!Po(t,r,e))||(!(0!==o||!Po(n,t,r))||!(0!==s||!Po(n,e,r)))))}function Po(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Do(t){return t>0?1:t<0?-1:0}function Lo(t,e){return Eo(t.prev,t,t.next)<0?Eo(t,e,t.next)>=0&&Eo(t,t.prev,e)>=0:Eo(t,e,t.prev)<0||Eo(t,t.next,e)<0}function qo(t,e){const n=new Io(t.i,t.x,t.y),r=new Io(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function Ro(t,e,n,r){const i=new Io(t,e,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 Oo(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Io(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class ko{static area(t){const e=t.length;let n=0;for(let r=e-1,i=0;i<e;r=i++)n+=t[r].x*t[i].y-t[i].x*t[r].y;return.5*n}static isClockWise(t){return ko.area(t)<0}static triangulateShape(t,e){const n=[],r=[],i=[];Bo(t),No(n,t);let a=t.length;e.forEach(Bo);for(let t=0;t<e.length;t++)r.push(a),a+=e[t].length,No(n,e[t]);const o=uo(n,r);for(let t=0;t<o.length;t+=3)i.push(o.slice(t,t+3));return i}}function Bo(t){const e=t.length;e>2&&t[e-1].equals(t[0])&&t.pop()}function No(t,e){for(let n=0;n<e.length;n++)t.push(e[n].x),t.push(e[n].y)}class zo extends hn{constructor(t=new lo([new ut(.5,.5),new ut(-.5,.5),new ut(-.5,-.5),new ut(.5,-.5)]),e={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:t,options:e},t=Array.isArray(t)?t:[t];const n=this,r=[],i=[];for(let e=0,n=t.length;e<n;e++){a(t[e])}function a(t){const a=[],o=void 0!==e.curveSegments?e.curveSegments:12,s=void 0!==e.steps?e.steps:1,A=void 0!==e.depth?e.depth:1;let l=void 0===e.bevelEnabled||e.bevelEnabled,u=void 0!==e.bevelThickness?e.bevelThickness:.2,c=void 0!==e.bevelSize?e.bevelSize:u-.1,h=void 0!==e.bevelOffset?e.bevelOffset:0,f=void 0!==e.bevelSegments?e.bevelSegments:3;const d=e.extrudePath,p=void 0!==e.UVGenerator?e.UVGenerator:Uo;let m,g,v,x,y,b=!1;d&&(m=d.getSpacedPoints(s),b=!0,l=!1,g=d.computeFrenetFrames(s,!1),v=new kt,x=new kt,y=new kt),l||(f=0,u=0,c=0,h=0);const _=t.extractPoints(o);let w=_.shape;const M=_.holes;if(!ko.isClockWise(w)){w=w.reverse();for(let t=0,e=M.length;t<e;t++){const e=M[t];ko.isClockWise(e)&&(M[t]=e.reverse())}}const S=ko.triangulateShape(w,M),E=w;for(let t=0,e=M.length;t<e;t++){const e=M[t];w=w.concat(e)}function T(t,e,n){return e||console.error("THREE.ExtrudeGeometry: vec does not exist"),e.clone().multiplyScalar(n).add(t)}const C=w.length,P=S.length;function D(t,e,n){let r,i,a;const o=t.x-e.x,s=t.y-e.y,A=n.x-t.x,l=n.y-t.y,u=o*o+s*s,c=o*l-s*A;if(Math.abs(c)>Number.EPSILON){const c=Math.sqrt(u),h=Math.sqrt(A*A+l*l),f=e.x-s/c,d=e.y+o/c,p=((n.x-l/h-f)*l-(n.y+A/h-d)*A)/(o*l-s*A);r=f+o*p-t.x,i=d+s*p-t.y;const m=r*r+i*i;if(m<=2)return new ut(r,i);a=Math.sqrt(m/2)}else{let t=!1;o>Number.EPSILON?A>Number.EPSILON&&(t=!0):o<-Number.EPSILON?A<-Number.EPSILON&&(t=!0):Math.sign(s)===Math.sign(l)&&(t=!0),t?(r=-s,i=o,a=Math.sqrt(u)):(r=o,i=s,a=Math.sqrt(u/2))}return new ut(r/a,i/a)}const L=[];for(let t=0,e=E.length,n=e-1,r=t+1;t<e;t++,n++,r++)n===e&&(n=0),r===e&&(r=0),L[t]=D(E[t],E[n],E[r]);const q=[];let R,O=L.concat();for(let t=0,e=M.length;t<e;t++){const e=M[t];R=[];for(let t=0,n=e.length,r=n-1,i=t+1;t<n;t++,r++,i++)r===n&&(r=0),i===n&&(i=0),R[t]=D(e[t],e[r],e[i]);q.push(R),O=O.concat(R)}for(let t=0;t<f;t++){const e=t/f,n=u*Math.cos(e*Math.PI/2),r=c*Math.sin(e*Math.PI/2)+h;for(let t=0,e=E.length;t<e;t++){const e=T(E[t],L[t],r);B(e.x,e.y,-n)}for(let t=0,e=M.length;t<e;t++){const e=M[t];R=q[t];for(let t=0,i=e.length;t<i;t++){const i=T(e[t],R[t],r);B(i.x,i.y,-n)}}}const I=c+h;for(let t=0;t<C;t++){const e=l?T(w[t],O[t],I):w[t];b?(x.copy(g.normals[0]).multiplyScalar(e.x),v.copy(g.binormals[0]).multiplyScalar(e.y),y.copy(m[0]).add(x).add(v),B(y.x,y.y,y.z)):B(e.x,e.y,0)}for(let t=1;t<=s;t++)for(let e=0;e<C;e++){const n=l?T(w[e],O[e],I):w[e];b?(x.copy(g.normals[t]).multiplyScalar(n.x),v.copy(g.binormals[t]).multiplyScalar(n.y),y.copy(m[t]).add(x).add(v),B(y.x,y.y,y.z)):B(n.x,n.y,A/s*t)}for(let t=f-1;t>=0;t--){const e=t/f,n=u*Math.cos(e*Math.PI/2),r=c*Math.sin(e*Math.PI/2)+h;for(let t=0,e=E.length;t<e;t++){const e=T(E[t],L[t],r);B(e.x,e.y,A+n)}for(let t=0,e=M.length;t<e;t++){const e=M[t];R=q[t];for(let t=0,i=e.length;t<i;t++){const i=T(e[t],R[t],r);b?B(i.x,i.y+m[s-1].y,m[s-1].x+n):B(i.x,i.y,A+n)}}}function k(t,e){let n=t.length;for(;--n>=0;){const r=n;let i=n-1;i<0&&(i=t.length-1);for(let t=0,n=s+2*f;t<n;t++){const n=C*t,a=C*(t+1);z(e+r+n,e+i+n,e+i+a,e+r+a)}}}function B(t,e,n){a.push(t),a.push(e),a.push(n)}function N(t,e,i){U(t),U(e),U(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 z(t,e,i,a){U(t),U(e),U(a),U(e),U(i),U(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 U(t){r.push(a[3*t+0]),r.push(a[3*t+1]),r.push(a[3*t+2])}function F(t){i.push(t.x),i.push(t.y)}!function(){const t=r.length/3;if(l){let t=0,e=C*t;for(let t=0;t<P;t++){const n=S[t];N(n[2]+e,n[1]+e,n[0]+e)}t=s+2*f,e=C*t;for(let t=0;t<P;t++){const n=S[t];N(n[0]+e,n[1]+e,n[2]+e)}}else{for(let t=0;t<P;t++){const e=S[t];N(e[2],e[1],e[0])}for(let t=0;t<P;t++){const e=S[t];N(e[0]+C*s,e[1]+C*s,e[2]+C*s)}}n.addGroup(t,r.length/3-t,0)}(),function(){const t=r.length/3;let e=0;k(E,e),e+=E.length;for(let t=0,n=M.length;t<n;t++){const n=M[t];k(n,e),e+=n.length}n.addGroup(t,r.length/3-t,1)}()}this.setAttribute("position",new rn(r,3)),this.setAttribute("uv",new rn(i,2)),this.computeVertexNormals()}toJSON(){const t=super.toJSON();return function(t,e,n){if(n.shapes=[],Array.isArray(t))for(let e=0,r=t.length;e<r;e++){const r=t[e];n.shapes.push(r.uuid)}else n.shapes.push(t.uuid);n.options=Object.assign({},e),void 0!==e.extrudePath&&(n.options.extrudePath=e.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,t)}static fromJSON(t,e){const n=[];for(let r=0,i=t.shapes.length;r<i;r++){const i=e[t.shapes[r]];n.push(i)}const r=t.options.extrudePath;return void 0!==r&&(t.options.extrudePath=(new io[r.type]).fromJSON(r)),new zo(n,t.options)}}const Uo={generateTopUV:function(t,e,n,r,i){const a=e[3*n],o=e[3*n+1],s=e[3*r],A=e[3*r+1],l=e[3*i],u=e[3*i+1];return[new ut(a,o),new ut(s,A),new ut(l,u)]},generateSideWallUV:function(t,e,n,r,i,a){const o=e[3*n],s=e[3*n+1],A=e[3*n+2],l=e[3*r],u=e[3*r+1],c=e[3*r+2],h=e[3*i],f=e[3*i+1],d=e[3*i+2],p=e[3*a],m=e[3*a+1],g=e[3*a+2];return Math.abs(s-u)<Math.abs(o-l)?[new ut(o,1-A),new ut(l,1-c),new ut(h,1-d),new ut(p,1-g)]:[new ut(s,1-A),new ut(u,1-c),new ut(f,1-d),new ut(m,1-g)]}};class Fo extends hn{constructor(t=1,e=32,n=16,r=0,i=2*Math.PI,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:r,phiLength:i,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const s=Math.min(a+o,Math.PI);let A=0;const l=[],u=new kt,c=new kt,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/e:h==n&&s==Math.PI&&(v=-.5/e);for(let n=0;n<=e;n++){const s=n/e;u.x=-t*Math.cos(r+s*i)*Math.sin(a+g*o),u.y=t*Math.cos(a+g*o),u.z=t*Math.sin(r+s*i)*Math.sin(a+g*o),f.push(u.x,u.y,u.z),c.copy(u).normalize(),d.push(c.x,c.y,c.z),p.push(s+v,1-g),m.push(A++)}l.push(m)}for(let t=0;t<n;t++)for(let r=0;r<e;r++){const e=l[t][r+1],i=l[t][r],o=l[t+1][r],A=l[t+1][r+1];(0!==t||a>0)&&h.push(e,i,A),(t!==n-1||s<Math.PI)&&h.push(i,o,A)}this.setIndex(h),this.setAttribute("position",new rn(f,3)),this.setAttribute("normal",new rn(d,3)),this.setAttribute("uv",new rn(p,2))}static fromJSON(t){return new Fo(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Go extends hn{constructor(t=new no(new kt(-1,-1,0),new kt(-1,1,0),new kt(1,1,0)),e=64,n=1,r=8,i=!1){super(),this.type="TubeGeometry",this.parameters={path:t,tubularSegments:e,radius:n,radialSegments:r,closed:i};const a=t.computeFrenetFrames(e,i);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const o=new kt,s=new kt,A=new ut;let l=new kt;const u=[],c=[],h=[],f=[];function d(i){l=t.getPointAt(i/e,l);const A=a.normals[i],h=a.binormals[i];for(let t=0;t<=r;t++){const e=t/r*Math.PI*2,i=Math.sin(e),a=-Math.cos(e);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(),c.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,u.push(o.x,o.y,o.z)}}!function(){for(let t=0;t<e;t++)d(t);d(!1===i?e:0),function(){for(let t=0;t<=e;t++)for(let n=0;n<=r;n++)A.x=t/e,A.y=n/r,h.push(A.x,A.y)}(),function(){for(let t=1;t<=e;t++)for(let e=1;e<=r;e++){const n=(r+1)*(t-1)+(e-1),i=(r+1)*t+(e-1),a=(r+1)*t+e,o=(r+1)*(t-1)+e;f.push(n,i,o),f.push(i,a,o)}}()}(),this.setIndex(f),this.setAttribute("position",new rn(u,3)),this.setAttribute("normal",new rn(c,3)),this.setAttribute("uv",new rn(h,2))}toJSON(){const t=super.toJSON();return t.path=this.parameters.path.toJSON(),t}static fromJSON(t){return new Go((new io[t.path.type]).fromJSON(t.path),t.tubularSegments,t.radius,t.radialSegments,t.closed)}}function jo(t,e,n){const r=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`,i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`;return!0!==n.has(r)&&!0!==n.has(i)&&(n.add(r),n.add(i),!0)}class Ho extends Ze{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new St(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new St(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ut(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}const Vo={enabled:!1,files:{},add:function(t,e){!1!==this.enabled&&(this.files[t]=e)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class Wo{constructor(t,e,n){const r=this;let i,a=!1,o=0,s=0;const A=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this.itemStart=function(t){s++,!1===a&&void 0!==r.onStart&&r.onStart(t,o,s),a=!0},this.itemEnd=function(t){o++,void 0!==r.onProgress&&r.onProgress(t,o,s),o===s&&(a=!1,void 0!==r.onLoad&&r.onLoad())},this.itemError=function(t){void 0!==r.onError&&r.onError(t)},this.resolveURL=function(t){return i?i(t):t},this.setURLModifier=function(t){return i=t,this},this.addHandler=function(t,e){return A.push(t,e),this},this.removeHandler=function(t){const e=A.indexOf(t);return-1!==e&&A.splice(e,2),this},this.getHandler=function(t){for(let e=0,n=A.length;e<n;e+=2){const n=A[e],r=A[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return r}return null}}}const Qo=new Wo;class Xo{constructor(t){this.manager=void 0!==t?t:Qo,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const n=this;return new Promise((function(r,i){n.load(t,r,e,i)}))}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}class Yo extends Xo{constructor(t){super(t)}load(t,e,n,r){void 0!==this.path&&(t=this.path+t),t=this.manager.resolveURL(t);const i=this,a=Vo.get(t);if(void 0!==a)return i.manager.itemStart(t),setTimeout((function(){e&&e(a),i.manager.itemEnd(t)}),0),a;const o=ft("img");function s(){l(),Vo.add(t,this),e&&e(this),i.manager.itemEnd(t)}function A(e){l(),r&&r(e),i.manager.itemError(t),i.manager.itemEnd(t)}function l(){o.removeEventListener("load",s,!1),o.removeEventListener("error",A,!1)}return o.addEventListener("load",s,!1),o.addEventListener("error",A,!1),"data:"!==t.slice(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),i.manager.itemStart(t),o.src=t,o}}class Zo extends Xo{constructor(t){super(t)}load(t,e,n,r){const i=new Dt,a=new Yo(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,(function(t){i.image=t,i.needsUpdate=!0,void 0!==e&&e(i)}),n,r),i}}class Jo extends Be{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new St(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,void 0!==this.groundColor&&(e.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(e.object.distance=this.distance),void 0!==this.angle&&(e.object.angle=this.angle),void 0!==this.decay&&(e.object.decay=this.decay),void 0!==this.penumbra&&(e.object.penumbra=this.penumbra),void 0!==this.shadow&&(e.object.shadow=this.shadow.toJSON()),e}}const Ko=new he,$o=new kt,ts=new kt;class es{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ut(512,512),this.map=null,this.mapPass=null,this.matrix=new he,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Yn,this._frameExtents=new ut(1,1),this._viewportCount=1,this._viewports=[new Lt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;$o.setFromMatrixPosition(t.matrixWorld),e.position.copy($o),ts.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(ts),e.updateMatrixWorld(),Ko.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ko),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Ko)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const t={};return 0!==this.bias&&(t.bias=this.bias),0!==this.normalBias&&(t.normalBias=this.normalBias),1!==this.radius&&(t.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class ns extends es{constructor(){super(new Ar(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class rs{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=is(),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 t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=is();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function is(){return("undefined"==typeof performance?Date:performance).now()}class as extends Ca{constructor(t,e,n=1){super(t,e),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}clone(t){const e=super.clone(t);return e.meshPerAttribute=this.meshPerAttribute,e}toJSON(t){const e=super.toJSON(t);return e.isInstancedInterleavedBuffer=!0,e.meshPerAttribute=this.meshPerAttribute,e}}function os(t,e){return t.distance-e.distance}function ss(t,e,n,r){if(t.layers.test(e.layers)&&t.raycast(e,n),!0===r){const r=t.children;for(let t=0,i=r.length;t<i;t++)ss(r[t],e,n,!0)}}class As{constructor(t=1,e=0,n=0){return this.radius=t,this.phi=e,this.theta=n,this}set(t,e,n){return this.radius=t,this.phi=e,this.theta=n,this}copy(t){return this.radius=t.radius,this.phi=t.phi,this.theta=t.theta,this}makeSafe(){const t=1e-6;return this.phi=Math.max(t,Math.min(Math.PI-t,this.phi)),this}setFromVector3(t){return this.setFromCartesianCoords(t.x,t.y,t.z)}setFromCartesianCoords(t,e,n){return this.radius=Math.sqrt(t*t+e*e+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(t,n),this.phi=Math.acos(nt(e/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}const ls=new kt,us=new kt;class cs{constructor(){this.type="ShapePath",this.color=new St,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new oo,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,r){return this.currentPath.quadraticCurveTo(t,e,n,r),this}bezierCurveTo(t,e,n,r,i,a){return this.currentPath.bezierCurveTo(t,e,n,r,i,a),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(t,e){const n=e.length;let r=!1;for(let i=n-1,a=0;a<n;i=a++){let n=e[i],o=e[a],s=o.x-n.x,A=o.y-n.y;if(Math.abs(A)>Number.EPSILON){if(A<0&&(n=e[a],s=-s,o=e[i],A=-A),t.y<n.y||t.y>o.y)continue;if(t.y===n.y){if(t.x===n.x)return!0}else{const e=A*(t.x-n.x)-s*(t.y-n.y);if(0===e)return!0;if(e<0)continue;r=!r}}else{if(t.y!==n.y)continue;if(o.x<=t.x&&t.x<=n.x||n.x<=t.x&&t.x<=o.x)return!0}}return r}const n=ko.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 lo,o.curves=a.curves,s.push(o),s;let A=!n(r[0].getPoints());A=t?!A:A;const l=[],u=[];let c,h,f=[],d=0;u[d]=void 0,f[d]=[];for(let e=0,o=r.length;e<o;e++)a=r[e],c=a.getPoints(),i=n(c),i=t?!i:i,i?(!A&&u[d]&&d++,u[d]={s:new lo,p:c},u[d].s.curves=a.curves,A&&d++,f[d]=[]):f[d].push({h:a,p:c[0]});if(!u[0])return function(t){const e=[];for(let n=0,r=t.length;n<r;n++){const r=t[n],i=new lo;i.curves=r.curves,e.push(i)}return e}(r);if(u.length>1){let t=!1,n=0;for(let t=0,e=u.length;t<e;t++)l[t]=[];for(let r=0,i=u.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<u.length;i++)e(o.p,u[i].p)&&(r!==i&&n++,s?(s=!1,l[i].push(o)):t=!0);s&&l[r].push(o)}}n>0&&!1===t&&(f=l)}for(let t=0,e=u.length;t<e;t++){o=u[t].s,s.push(o),h=f[t];for(let t=0,e=h.length;t<e;t++)o.holes.push(h[t].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 hs=new kt,fs=new he,ds=new he,ps=new kt,ms=new kt;function gs(t,e,n){var r,i,a,o,s;function A(){var l=Date.now()-o;l<e&&l>=0?r=setTimeout(A,e-l):(r=null,n||(s=t.apply(a,i),a=i=null))}null==e&&(e=100);var l=function(){a=this,i=arguments,o=Date.now();var l=n&&!r;return r||(r=setTimeout(A,e)),l&&(s=t.apply(a,i),a=i=null),s};return l.clear=function(){r&&(clearTimeout(r),r=null)},l.flush=function(){r&&(s=t.apply(a,i),a=i=null,clearTimeout(r),r=null)},l}gs.debounce=gs;var vs=gs;function xs(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function ys(t,e,n){return e&&xs(t.prototype,e),n&&xs(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function bs(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var r,i,a=[],o=!0,s=!1;try{for(n=n.call(t);!(o=(r=n.next()).done)&&(a.push(r.value),!e||a.length!==e);o=!0);}catch(t){s=!0,i=t}finally{try{o||null==n.return||n.return()}finally{if(s)throw i}}return a}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return _s(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _s(t,e)}(t,e)||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 _s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var ws=ys((function t(e,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(t,e){}:s;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.name=e,this.defaultVal=i,this.triggerUpdate=o,this.onChange=A}));function Ms(t){var e=t.stateInit,n=void 0===e?function(){return{}}:e,r=t.props,i=void 0===r?{}:r,a=t.methods,o=void 0===a?{}:a,s=t.aliases,A=void 0===s?{}:s,l=t.init,u=void 0===l?function(){}:l,c=t.update,h=void 0===c?function(){}:c,f=Object.keys(i).map((function(t){return new ws(t,i[t])}));return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=Object.assign({},n instanceof Function?n(t):n,{initialised:!1}),r={};function i(e){return a(e,t),s(),i}var a=function(t,n){u.call(i,t,e,n),e.initialised=!0},s=vs((function(){e.initialised&&(h.call(i,e,r),r={})}),1);return f.forEach((function(t){i[t.name]=function(t){var n=t.name,a=t.triggerUpdate,o=void 0!==a&&a,A=t.onChange,l=void 0===A?function(t,e){}:A,u=t.defaultVal,c=void 0===u?null:u;return function(t){var a=e[n];if(!arguments.length)return a;var A=void 0===t?c:t;return e[n]=A,l.call(i,A,e,a),!r.hasOwnProperty(n)&&(r[n]=a),o&&s(),i}}(t)})),Object.keys(o).forEach((function(t){i[t]=function(){for(var n,r=arguments.length,a=new Array(r),s=0;s<r;s++)a[s]=arguments[s];return(n=o[t]).call.apply(n,[i,e].concat(a))}})),Object.entries(A).forEach((function(t){var e=bs(t,2),n=e[0],r=e[1];return i[n]=i[r]})),i.resetProps=function(){return f.forEach((function(t){i[t.name](t.defaultVal)})),i},i.resetProps(),e._rerender=s,i}}var Ss,Es={Linear:{None:function(t){return t}},Quadratic:{In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}},Cubic:{In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}},Quartic:{In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}},Quintic:{In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},Sinusoidal:{In:function(t){return 1-Math.cos(t*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.cos(Math.PI*t))}},Exponential:{In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}},Circular:{In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},Elastic:{In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}},Back:{In:function(t){var e=1.70158;return t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},Bounce:{In:function(t){return 1-Es.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*Es.Bounce.In(2*t):.5*Es.Bounce.Out(2*t-1)+.5}}},Ts="undefined"==typeof self&&"undefined"!=typeof process&&process.hrtime?function(){var t=process.hrtime();return 1e3*t[0]+t[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()},Cs=function(){function t(){this._tweens={},this._tweensAddedDuringUpdate={}}return t.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map((function(e){return t._tweens[e]}))},t.prototype.removeAll=function(){this._tweens={}},t.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},t.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},t.prototype.update=function(t,e){void 0===t&&(t=Ts()),void 0===e&&(e=!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=!e;i&&!1===i.update(t,a)&&!e&&delete this._tweens[n[r]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},t}(),Ps={Linear:function(t,e){var n=t.length-1,r=n*e,i=Math.floor(r),a=Ps.Utils.Linear;return e<0?a(t[0],t[1],r):e>1?a(t[n],t[n-1],n-r):a(t[i],t[i+1>n?n:i+1],r-i)},Bezier:function(t,e){for(var n=0,r=t.length-1,i=Math.pow,a=Ps.Utils.Bernstein,o=0;o<=r;o++)n+=i(1-e,r-o)*i(e,o)*t[o]*a(r,o);return n},CatmullRom:function(t,e){var n=t.length-1,r=n*e,i=Math.floor(r),a=Ps.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(i=Math.floor(r=n*(1+e))),a(t[(i-1+n)%n],t[i],t[(i+1)%n],t[(i+2)%n],r-i)):e<0?t[0]-(a(t[0],t[0],t[1],t[1],-r)-t[0]):e>1?t[n]-(a(t[n],t[n],t[n-1],t[n-1],r-n)-t[n]):a(t[i?i-1:0],t[i],t[n<i+1?n:i+1],t[n<i+2?n:i+2],r-i)},Utils:{Linear:function(t,e,n){return(e-t)*n+t},Bernstein:function(t,e){var n=Ps.Utils.Factorial;return n(t)/n(e)/n(t-e)},Factorial:(Ss=[1],function(t){var e=1;if(Ss[t])return Ss[t];for(var n=t;n>1;n--)e*=n;return Ss[t]=e,e}),CatmullRom:function(t,e,n,r,i){var a=.5*(n-t),o=.5*(r-e),s=i*i;return(2*e-2*n+a+o)*(i*s)+(-3*e+3*n-2*a-o)*s+a*i+e}}},Ds=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),Ls=new Cs,qs=function(){function t(t,e){void 0===e&&(e=Ls),this._object=t,this._group=e,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=Es.Linear.None,this._interpolationFunction=Ps.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._id=Ds.nextId(),this._isChainStopped=!1,this._goToEnd=!1}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.to=function(t,e){return this._valuesEnd=Object.create(t),void 0!==e&&(this._duration=e),this},t.prototype.duration=function(t){return this._duration=t,this},t.prototype.start=function(t){if(this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var e in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(e),this._valuesStart[e]=this._valuesStartRepeat[e];return this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=void 0!==t?"string"==typeof t?Ts()+parseFloat(t):t:Ts(),this._startTime+=this._delayTime,this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat),this},t.prototype._setupProperties=function(t,e,n,r){for(var i in n){var a=t[i],o=Array.isArray(a),s=o?"array":typeof a,A=!o&&Array.isArray(n[i]);if("undefined"!==s&&"function"!==s){if(A){var l=n[i];if(0===l.length)continue;l=l.map(this._handleRelativeValue.bind(this,a)),n[i]=[a].concat(l)}if("object"!==s&&!o||!a||A)void 0===e[i]&&(e[i]=a),o||(e[i]*=1),r[i]=A?n[i].slice().reverse():e[i]||0;else{for(var u in e[i]=o?[]:{},a)e[i][u]=a[u];r[i]=o?[]:{},this._setupProperties(a,e[i],n[i],r[i])}}}},t.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},t.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},t.prototype.pause=function(t){return void 0===t&&(t=Ts()),this._isPaused||!this._isPlaying||(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this)),this},t.prototype.resume=function(t){return void 0===t&&(t=Ts()),this._isPaused&&this._isPlaying?(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this):this},t.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},t.prototype.group=function(t){return this._group=t,this},t.prototype.delay=function(t){return this._delayTime=t,this},t.prototype.repeat=function(t){return this._initialRepeat=t,this._repeat=t,this},t.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},t.prototype.yoyo=function(t){return this._yoyo=t,this},t.prototype.easing=function(t){return this._easingFunction=t,this},t.prototype.interpolation=function(t){return this._interpolationFunction=t,this},t.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},t.prototype.onStart=function(t){return this._onStartCallback=t,this},t.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},t.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},t.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},t.prototype.onStop=function(t){return this._onStopCallback=t,this},t.prototype.update=function(t,e){if(void 0===t&&(t=Ts()),void 0===e&&(e=!0),this._isPaused)return!0;var n,r,i=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>i)return!1;e&&this.start(t)}if(this._goToEnd=!1,t<this._startTime)return!0;!1===this._onStartCallbackFired&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),r=(t-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=t+this._repeatDelayTime:this._startTime=t+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),!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);return this._isPlaying=!1,!1}return!0},t.prototype._updateProperties=function(t,e,n,r){for(var i in n)if(void 0!==e[i]){var a=e[i]||0,o=n[i],s=Array.isArray(t[i]),A=Array.isArray(o);!s&&A?t[i]=this._interpolationFunction(o,r):"object"==typeof o&&o?this._updateProperties(t[i],a,o,r):"number"==typeof(o=this._handleRelativeValue(a,o))&&(t[i]=a+(o-a)*r)}},t.prototype._handleRelativeValue=function(t,e){return"string"!=typeof e?e:"+"===e.charAt(0)||"-"===e.charAt(0)?t+parseFloat(e):parseFloat(e)},t.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],n=this._valuesEnd[t];this._valuesStartRepeat[t]="string"==typeof n?this._valuesStartRepeat[t]+parseFloat(n):this._valuesEnd[t],this._valuesEnd[t]=e},t}(),Rs=Ds.nextId,Os=Ls,Is=Os.getAll.bind(Os),ks=Os.removeAll.bind(Os),Bs=Os.add.bind(Os),Ns=Os.remove.bind(Os),zs=Os.update.bind(Os),Us={Easing:Es,Group:Cs,Interpolation:Ps,now:Ts,Sequence:Ds,nextId:Rs,Tween:qs,VERSION:"18.6.4",getAll:Is,removeAll:ks,add:Bs,remove:Ns,update:zs},Fs={exports:{}};function Gs(t,e,n){n=n||2;var r,i,a,o,s,A,l,u=e&&e.length,c=u?e[0]*n:t.length,h=js(t,0,c,n,!0),f=[];if(!h||h.next===h.prev)return f;if(u&&(h=function(t,e,n,r){var i,a,o,s=[];for(i=0,a=e.length;i<a;i++)(o=js(t,e[i]*r,i<a-1?e[i+1]*r:t.length,r,!1))===o.next&&(o.steiner=!0),s.push(tA(o));for(s.sort(Zs),i=0;i<s.length;i++)n=Js(s[i],n);return n}(t,e,h,n)),t.length>80*n){r=a=t[0],i=o=t[1];for(var d=n;d<c;d+=n)(s=t[d])<r&&(r=s),(A=t[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 Vs(h,f,n,r,i,l,0),f}function js(t,e,n,r,i){var a,o;if(i===fA(t,e,n,r)>0)for(a=e;a<n;a+=r)o=uA(a,t[a],t[a+1],o);else for(a=n-r;a>=e;a-=r)o=uA(a,t[a],t[a+1],o);return o&&iA(o,o.next)&&(cA(o),o=o.next),o}function Hs(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!iA(r,r.next)&&0!==rA(r.prev,r,r.next))r=r.next;else{if(cA(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function Vs(t,e,n,r,i,a,o){if(t){!o&&a&&function(t,e,n,r){var i=t;do{0===i.z&&(i.z=$s(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,a,o,s,A,l=1;do{for(n=t,t=null,a=null,o=0;n;){for(o++,r=n,s=0,e=0;e<l&&(s++,r=r.nextZ);e++);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:t=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1)}(i)}(t,r,i,a);for(var s,A,l=t;t.prev!==t.next;)if(s=t.prev,A=t.next,a?Qs(t,r,i,a):Ws(t))e.push(s.i/n|0),e.push(t.i/n|0),e.push(A.i/n|0),cA(t),t=A.next,l=A.next;else if((t=A)===l){o?1===o?Vs(t=Xs(Hs(t),e,n),e,n,r,i,a,2):2===o&&Ys(t,e,n,r,i,a):Vs(Hs(t),e,n,r,i,a,1);break}}}function Ws(t){var e=t.prev,n=t,r=t.next;if(rA(e,n,r)>=0)return!1;for(var i=e.x,a=n.x,o=r.x,s=e.y,A=n.y,l=r.y,u=i<a?i<o?i:o:a<o?a:o,c=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!==e;){if(d.x>=u&&d.x<=h&&d.y>=c&&d.y<=f&&eA(i,s,a,A,o,l,d.x,d.y)&&rA(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function Qs(t,e,n,r){var i=t.prev,a=t,o=t.next;if(rA(i,a,o)>=0)return!1;for(var s=i.x,A=a.x,l=o.x,u=i.y,c=a.y,h=o.y,f=s<A?s<l?s:l:A<l?A:l,d=u<c?u<h?u:h:c<h?c:h,p=s>A?s>l?s:l:A>l?A:l,m=u>c?u>h?u:h:c>h?c:h,g=$s(f,d,e,n,r),v=$s(p,m,e,n,r),x=t.prevZ,y=t.nextZ;x&&x.z>=g&&y&&y.z<=v;){if(x.x>=f&&x.x<=p&&x.y>=d&&x.y<=m&&x!==i&&x!==o&&eA(s,u,A,c,l,h,x.x,x.y)&&rA(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,y.x>=f&&y.x<=p&&y.y>=d&&y.y<=m&&y!==i&&y!==o&&eA(s,u,A,c,l,h,y.x,y.y)&&rA(y.prev,y,y.next)>=0)return!1;y=y.nextZ}for(;x&&x.z>=g;){if(x.x>=f&&x.x<=p&&x.y>=d&&x.y<=m&&x!==i&&x!==o&&eA(s,u,A,c,l,h,x.x,x.y)&&rA(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=v;){if(y.x>=f&&y.x<=p&&y.y>=d&&y.y<=m&&y!==i&&y!==o&&eA(s,u,A,c,l,h,y.x,y.y)&&rA(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Xs(t,e,n){var r=t;do{var i=r.prev,a=r.next.next;!iA(i,a)&&aA(i,r,r.next,a)&&AA(i,a)&&AA(a,i)&&(e.push(i.i/n|0),e.push(r.i/n|0),e.push(a.i/n|0),cA(r),cA(r.next),r=t=a),r=r.next}while(r!==t);return Hs(r)}function Ys(t,e,n,r,i,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&nA(o,s)){var A=lA(o,s);return o=Hs(o,o.next),A=Hs(A,A.next),Vs(o,e,n,r,i,a,0),void Vs(A,e,n,r,i,a,0)}s=s.next}o=o.next}while(o!==t)}function Zs(t,e){return t.x-e.x}function Js(t,e){var n=function(t,e){var n,r=e,i=t.x,a=t.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!==e);if(!n)return null;var A,l=n,u=n.x,c=n.y,h=1/0;r=n;do{i>=r.x&&r.x>=u&&i!==r.x&&eA(a<c?i:o,a,u,c,a<c?o:i,a,r.x,r.y)&&(A=Math.abs(a-r.y)/(i-r.x),AA(r,t)&&(A<h||A===h&&(r.x>n.x||r.x===n.x&&Ks(n,r)))&&(n=r,h=A)),r=r.next}while(r!==l);return n}(t,e);if(!n)return e;var r=lA(n,t);return Hs(r,r.next),Hs(n,n.next)}function Ks(t,e){return rA(t.prev,t,e.prev)<0&&rA(e.next,t,t.next)<0}function $s(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function tA(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function eA(t,e,n,r,i,a,o,s){return(i-o)*(e-s)>=(t-o)*(a-s)&&(t-o)*(r-s)>=(n-o)*(e-s)&&(n-o)*(a-s)>=(i-o)*(r-s)}function nA(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&aA(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(AA(t,e)&&AA(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,a=(t.y+e.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!==t);return r}(t,e)&&(rA(t.prev,t,e.prev)||rA(t,e.prev,e))||iA(t,e)&&rA(t.prev,t,t.next)>0&&rA(e.prev,e,e.next)>0)}function rA(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function iA(t,e){return t.x===e.x&&t.y===e.y}function aA(t,e,n,r){var i=sA(rA(t,e,n)),a=sA(rA(t,e,r)),o=sA(rA(n,r,t)),s=sA(rA(n,r,e));return i!==a&&o!==s||(!(0!==i||!oA(t,n,e))||(!(0!==a||!oA(t,r,e))||(!(0!==o||!oA(n,t,r))||!(0!==s||!oA(n,e,r)))))}function oA(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function sA(t){return t>0?1:t<0?-1:0}function AA(t,e){return rA(t.prev,t,t.next)<0?rA(t,e,t.next)>=0&&rA(t,t.prev,e)>=0:rA(t,e,t.prev)<0||rA(t,t.next,e)<0}function lA(t,e){var n=new hA(t.i,t.x,t.y),r=new hA(e.i,e.x,e.y),i=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function uA(t,e,n,r){var i=new hA(t,e,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 cA(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function hA(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function fA(t,e,n,r){for(var i=0,a=e,o=n-r;a<n;a+=r)i+=(t[o]-t[a])*(t[a+1]+t[o+1]),o=a;return i}function dA(t,e){return null==t||null==e?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function pA(t,e){return null==t||null==e?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function mA(t){let e,n,r;function i(t,r,i=0,a=t.length){if(i<a){if(0!==e(r,r))return a;do{const e=i+a>>>1;n(t[e],r)<0?i=e+1:a=e}while(i<a)}return i}return 2!==t.length?(e=dA,n=(e,n)=>dA(t(e),n),r=(e,n)=>t(e)-n):(e=t===dA||t===pA?t:gA,n=t,r=t),{left:i,center:function(t,e,n=0,a=t.length){const o=i(t,e,n,a-1);return o>n&&r(t[o-1],e)>-r(t[o],e)?o-1:o},right:function(t,r,i=0,a=t.length){if(i<a){if(0!==e(r,r))return a;do{const e=i+a>>>1;n(t[e],r)<=0?i=e+1:a=e}while(i<a)}return i}}}function gA(){return 0}Fs.exports=Gs,Fs.exports.default=Gs,Gs.deviation=function(t,e,n,r){var i=e&&e.length,a=i?e[0]*n:t.length,o=Math.abs(fA(t,0,a,n));if(i)for(var s=0,A=e.length;s<A;s++){var l=e[s]*n,u=s<A-1?e[s+1]*n:t.length;o-=Math.abs(fA(t,l,u,n))}var c=0;for(s=0;s<r.length;s+=3){var h=r[s]*n,f=r[s+1]*n,d=r[s+2]*n;c+=Math.abs((t[h]-t[d])*(t[f+1]-t[h+1])-(t[h]-t[f])*(t[d+1]-t[h+1]))}return 0===o&&0===c?0:Math.abs((c-o)/o)},Gs.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},r=0,i=0;i<t.length;i++){for(var a=0;a<t[i].length;a++)for(var o=0;o<e;o++)n.vertices.push(t[i][a][o]);i>0&&(r+=t[i-1].length,n.holes.push(r))}return n};const vA=mA(dA).right;mA((function(t){return null===t?NaN:+t})).center;var xA=vA;function yA(t,e){let n,r;if(void 0===e)for(const e of t)null!=e&&(void 0===n?e>=e&&(n=r=e):(n>e&&(n=e),r<e&&(r=e)));else{let i=-1;for(let a of t)null!=(a=e(a,++i,t))&&(void 0===n?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)))}return[n,r]}class bA{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const e=this._partials;let n=0;for(let r=0;r<this._n&&r<32;r++){const i=e[r],a=t+i,o=Math.abs(t)<Math.abs(i)?t-(a-i):i-(a-t);o&&(e[n++]=o),t=a}return e[n]=t,this._n=n+1,this}valueOf(){const t=this._partials;let e,n,r,i=this._n,a=0;if(i>0){for(a=t[--i];i>0&&(e=a,n=t[--i],a=e+n,r=n-(a-e),!r););i>0&&(r<0&&t[i-1]<0||r>0&&t[i-1]>0)&&(n=2*r,e=a+n,n==e-a&&(a=e))}return a}}var _A=Math.sqrt(50),wA=Math.sqrt(10),MA=Math.sqrt(2);function SA(t,e,n){var r=(e-t)/Math.max(0,n),i=Math.floor(Math.log(r)/Math.LN10),a=r/Math.pow(10,i);return i>=0?(a>=_A?10:a>=wA?5:a>=MA?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(a>=_A?10:a>=wA?5:a>=MA?2:1)}function EA(t,e){let n=0,r=0;if(void 0===e)for(let e of t)null!=e&&(e=+e)>=e&&(++n,r+=e);else{let i=-1;for(let a of t)null!=(a=e(a,++i,t))&&(a=+a)>=a&&(++n,r+=a)}if(n)return r/n}function TA(t){return Array.from(function*(t){for(const e of t)yield*e}(t))}function CA(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=0|Math.max(0,Math.ceil((e-t)/n)),a=new Array(i);++r<i;)a[r]=t+r*n;return a}var PA=1e-6,DA=1e-12,LA=Math.PI,qA=LA/2,RA=LA/4,OA=2*LA,IA=180/LA,kA=LA/180,BA=Math.abs,NA=Math.atan,zA=Math.atan2,UA=Math.cos,FA=Math.ceil,GA=Math.hypot,jA=Math.sin,HA=Math.sign||function(t){return t>0?1:t<0?-1:0},VA=Math.sqrt;function WA(t){return t>1?qA:t<-1?-qA:Math.asin(t)}function QA(t){return(t=jA(t/2))*t}function XA(){}function YA(t,e){t&&JA.hasOwnProperty(t.type)&&JA[t.type](t,e)}var ZA={Feature:function(t,e){YA(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r<i;)YA(n[r].geometry,e)}},JA={Sphere:function(t,e){e.sphere()},Point:function(t,e){t=t.coordinates,e.point(t[0],t[1],t[2])},MultiPoint:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)t=n[r],e.point(t[0],t[1],t[2])},LineString:function(t,e){KA(t.coordinates,e,0)},MultiLineString:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)KA(n[r],e,0)},Polygon:function(t,e){$A(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)$A(n[r],e)},GeometryCollection:function(t,e){for(var n=t.geometries,r=-1,i=n.length;++r<i;)YA(n[r],e)}};function KA(t,e,n){var r,i=-1,a=t.length-n;for(e.lineStart();++i<a;)r=t[i],e.point(r[0],r[1],r[2]);e.lineEnd()}function $A(t,e){var n=-1,r=t.length;for(e.polygonStart();++n<r;)KA(t[n],e,1);e.polygonEnd()}function tl(t,e){t&&ZA.hasOwnProperty(t.type)?ZA[t.type](t,e):YA(t,e)}var el,nl,rl,il,al,ol,sl,Al,ll,ul,cl,hl,fl,dl,pl,ml,gl=new bA,vl=new bA,xl={point:XA,lineStart:XA,lineEnd:XA,polygonStart:function(){gl=new bA,xl.lineStart=yl,xl.lineEnd=bl},polygonEnd:function(){var t=+gl;vl.add(t<0?OA+t:t),this.lineStart=this.lineEnd=this.point=XA},sphere:function(){vl.add(OA)}};function yl(){xl.point=_l}function bl(){wl(el,nl)}function _l(t,e){xl.point=wl,el=t,nl=e,rl=t*=kA,il=UA(e=(e*=kA)/2+RA),al=jA(e)}function wl(t,e){var n=(t*=kA)-rl,r=n>=0?1:-1,i=r*n,a=UA(e=(e*=kA)/2+RA),o=jA(e),s=al*o,A=il*a+s*UA(i),l=s*r*jA(i);gl.add(zA(l,A)),rl=t,il=a,al=o}function Ml(t){return[zA(t[1],t[0]),WA(t[2])]}function Sl(t){var e=t[0],n=t[1],r=UA(n);return[r*UA(e),r*jA(e),jA(n)]}function El(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Tl(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function Cl(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function Pl(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Dl(t){var e=VA(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}var Ll,ql,Rl,Ol,Il,kl,Bl,Nl,zl,Ul,Fl,Gl,jl,Hl,Vl,Wl,Ql={point:Xl,lineStart:Zl,lineEnd:Jl,polygonStart:function(){Ql.point=Kl,Ql.lineStart=$l,Ql.lineEnd=tu,dl=new bA,xl.polygonStart()},polygonEnd:function(){xl.polygonEnd(),Ql.point=Xl,Ql.lineStart=Zl,Ql.lineEnd=Jl,gl<0?(ol=-(Al=180),sl=-(ll=90)):dl>PA?ll=90:dl<-1e-6&&(sl=-90),ml[0]=ol,ml[1]=Al},sphere:function(){ol=-(Al=180),sl=-(ll=90)}};function Xl(t,e){pl.push(ml=[ol=t,Al=t]),e<sl&&(sl=e),e>ll&&(ll=e)}function Yl(t,e){var n=Sl([t*kA,e*kA]);if(fl){var r=Tl(fl,n),i=Tl([r[1],-r[0],0],r);Dl(i),i=Ml(i);var a,o=t-ul,s=o>0?1:-1,A=i[0]*IA*s,l=BA(o)>180;l^(s*ul<A&&A<s*t)?(a=i[1]*IA)>ll&&(ll=a):l^(s*ul<(A=(A+360)%360-180)&&A<s*t)?(a=-i[1]*IA)<sl&&(sl=a):(e<sl&&(sl=e),e>ll&&(ll=e)),l?t<ul?eu(ol,t)>eu(ol,Al)&&(Al=t):eu(t,Al)>eu(ol,Al)&&(ol=t):Al>=ol?(t<ol&&(ol=t),t>Al&&(Al=t)):t>ul?eu(ol,t)>eu(ol,Al)&&(Al=t):eu(t,Al)>eu(ol,Al)&&(ol=t)}else pl.push(ml=[ol=t,Al=t]);e<sl&&(sl=e),e>ll&&(ll=e),fl=n,ul=t}function Zl(){Ql.point=Yl}function Jl(){ml[0]=ol,ml[1]=Al,Ql.point=Xl,fl=null}function Kl(t,e){if(fl){var n=t-ul;dl.add(BA(n)>180?n+(n>0?360:-360):n)}else cl=t,hl=e;xl.point(t,e),Yl(t,e)}function $l(){xl.lineStart()}function tu(){Kl(cl,hl),xl.lineEnd(),BA(dl)>PA&&(ol=-(Al=180)),ml[0]=ol,ml[1]=Al,fl=null}function eu(t,e){return(e-=t)<0?e+360:e}function nu(t,e){return t[0]-e[0]}function ru(t,e){return t[0]<=t[1]?t[0]<=e&&e<=t[1]:e<t[0]||t[1]<e}function iu(t){var e,n,r,i,a,o,s;if(ll=Al=-(ol=sl=1/0),pl=[],tl(t,Ql),n=pl.length){for(pl.sort(nu),e=1,a=[r=pl[0]];e<n;++e)ru(r,(i=pl[e])[0])||ru(r,i[1])?(eu(r[0],i[1])>eu(r[0],r[1])&&(r[1]=i[1]),eu(i[0],r[1])>eu(r[0],r[1])&&(r[0]=i[0])):a.push(r=i);for(o=-1/0,e=0,r=a[n=a.length-1];e<=n;r=i,++e)i=a[e],(s=eu(r[1],i[0]))>o&&(o=s,ol=i[0],Al=r[1])}return pl=ml=null,ol===1/0||sl===1/0?[[NaN,NaN],[NaN,NaN]]:[[ol,sl],[Al,ll]]}var au={sphere:XA,point:ou,lineStart:Au,lineEnd:cu,polygonStart:function(){au.lineStart=hu,au.lineEnd=fu},polygonEnd:function(){au.lineStart=Au,au.lineEnd=cu}};function ou(t,e){t*=kA;var n=UA(e*=kA);su(n*UA(t),n*jA(t),jA(e))}function su(t,e,n){++Ll,Rl+=(t-Rl)/Ll,Ol+=(e-Ol)/Ll,Il+=(n-Il)/Ll}function Au(){au.point=lu}function lu(t,e){t*=kA;var n=UA(e*=kA);Hl=n*UA(t),Vl=n*jA(t),Wl=jA(e),au.point=uu,su(Hl,Vl,Wl)}function uu(t,e){t*=kA;var n=UA(e*=kA),r=n*UA(t),i=n*jA(t),a=jA(e),o=zA(VA((o=Vl*a-Wl*i)*o+(o=Wl*r-Hl*a)*o+(o=Hl*i-Vl*r)*o),Hl*r+Vl*i+Wl*a);ql+=o,kl+=o*(Hl+(Hl=r)),Bl+=o*(Vl+(Vl=i)),Nl+=o*(Wl+(Wl=a)),su(Hl,Vl,Wl)}function cu(){au.point=ou}function hu(){au.point=du}function fu(){pu(Gl,jl),au.point=ou}function du(t,e){Gl=t,jl=e,t*=kA,e*=kA,au.point=pu;var n=UA(e);Hl=n*UA(t),Vl=n*jA(t),Wl=jA(e),su(Hl,Vl,Wl)}function pu(t,e){t*=kA;var n=UA(e*=kA),r=n*UA(t),i=n*jA(t),a=jA(e),o=Vl*a-Wl*i,s=Wl*r-Hl*a,A=Hl*i-Vl*r,l=GA(o,s,A),u=WA(l),c=l&&-u/l;zl.add(c*o),Ul.add(c*s),Fl.add(c*A),ql+=u,kl+=u*(Hl+(Hl=r)),Bl+=u*(Vl+(Vl=i)),Nl+=u*(Wl+(Wl=a)),su(Hl,Vl,Wl)}function mu(t){Ll=ql=Rl=Ol=Il=kl=Bl=Nl=0,zl=new bA,Ul=new bA,Fl=new bA,tl(t,au);var e=+zl,n=+Ul,r=+Fl,i=GA(e,n,r);return i<DA&&(e=kl,n=Bl,r=Nl,ql<PA&&(e=Rl,n=Ol,r=Il),(i=GA(e,n,r))<DA)?[NaN,NaN]:[zA(n,e)*IA,WA(r/i)*IA]}function gu(t,e){function n(n,r){return n=t(n,r),e(n[0],n[1])}return t.invert&&e.invert&&(n.invert=function(n,r){return(n=e.invert(n,r))&&t.invert(n[0],n[1])}),n}function vu(t,e){return[BA(t)>LA?t+Math.round(-t/OA)*OA:t,e]}function xu(t,e,n){return(t%=OA)?e||n?gu(bu(t),_u(e,n)):bu(t):e||n?_u(e,n):vu}function yu(t){return function(e,n){return[(e+=t)>LA?e-OA:e<-LA?e+OA:e,n]}}function bu(t){var e=yu(t);return e.invert=yu(-t),e}function _u(t,e){var n=UA(t),r=jA(t),i=UA(e),a=jA(e);function o(t,e){var o=UA(e),s=UA(t)*o,A=jA(t)*o,l=jA(e),u=l*n+s*r;return[zA(A*i-u*a,s*n-l*r),WA(u*i+A*a)]}return o.invert=function(t,e){var o=UA(e),s=UA(t)*o,A=jA(t)*o,l=jA(e),u=l*i-A*a;return[zA(A*i+l*a,s*n+u*r),WA(u*n-s*r)]},o}function wu(t,e){(e=Sl(e))[0]-=t,Dl(e);var n,r=(n=-e[1])>1?0:n<-1?LA:Math.acos(n);return((-e[2]<0?-r:r)+OA-PA)%OA}function Mu(){var t,e=[];return{point:function(e,n,r){t.push([e,n,r])},lineStart:function(){e.push(t=[])},lineEnd:XA,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function Su(t,e){return BA(t[0]-e[0])<PA&&BA(t[1]-e[1])<PA}function Eu(t,e,n,r){this.x=t,this.z=e,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function Tu(t,e,n,r,i){var a,o,s=[],A=[];if(t.forEach((function(t){if(!((e=t.length-1)<=0)){var e,n,r=t[0],o=t[e];if(Su(r,o)){if(!r[2]&&!o[2]){for(i.lineStart(),a=0;a<e;++a)i.point((r=t[a])[0],r[1]);return void i.lineEnd()}o[0]+=2e-6}s.push(n=new Eu(r,t,null,!0)),A.push(n.o=new Eu(r,null,n,!1)),s.push(n=new Eu(o,t,null,!1)),A.push(n.o=new Eu(o,null,n,!0))}})),s.length){for(A.sort(e),Cu(s),Cu(A),a=0,o=A.length;a<o;++a)A[a].e=n=!n;for(var l,u,c=s[0];;){for(var h=c,f=!0;h.v;)if((h=h.n)===c)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((u=l[a])[0],u[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((u=l[a])[0],u[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 Cu(t){if(e=t.length){for(var e,n,r=0,i=t[0];++r<e;)i.n=n=t[r],n.p=i,i=n;i.n=n=t[0],n.p=i}}function Pu(t){return BA(t[0])<=LA?t[0]:HA(t[0])*((BA(t[0])+LA)%OA-LA)}function Du(t,e){var n=Pu(e),r=e[1],i=jA(r),a=[jA(n),-UA(n),0],o=0,s=0,A=new bA;1===i?r=qA+PA:-1===i&&(r=-qA-PA);for(var l=0,u=t.length;l<u;++l)if(h=(c=t[l]).length)for(var c,h,f=c[h-1],d=Pu(f),p=f[1]/2+RA,m=jA(p),g=UA(p),v=0;v<h;++v,d=y,m=_,g=w,f=x){var x=c[v],y=Pu(x),b=x[1]/2+RA,_=jA(b),w=UA(b),M=y-d,S=M>=0?1:-1,E=S*M,T=E>LA,C=m*_;if(A.add(zA(C*S*jA(E),g*w+C*UA(E))),o+=T?M+S*OA:M,T^d>=n^y>=n){var P=Tl(Sl(f),Sl(x));Dl(P);var D=Tl(a,P);Dl(D);var L=(T^M>=0?-1:1)*WA(D[2]);(r>L||r===L&&(P[0]||P[1]))&&(s+=T^M>=0?1:-1)}}return(o<-1e-6||o<PA&&A<-1e-12)^1&s}function Lu(t,e,n,r){return function(i){var a,o,s,A=e(i),l=Mu(),u=e(l),c=!1,h={point:f,lineStart:p,lineEnd:m,polygonStart:function(){h.point=g,h.lineStart=v,h.lineEnd=x,o=[],a=[]},polygonEnd:function(){h.point=f,h.lineStart=p,h.lineEnd=m,o=TA(o);var t=Du(a,r);o.length?(c||(i.polygonStart(),c=!0),Tu(o,Ru,t,n,i)):t&&(c||(i.polygonStart(),c=!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),c&&(i.polygonEnd(),c=!1),o=a=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function f(e,n){t(e,n)&&i.point(e,n)}function d(t,e){A.point(t,e)}function p(){h.point=d,A.lineStart()}function m(){h.point=f,A.lineEnd()}function g(t,e){s.push([t,e]),u.point(t,e)}function v(){u.lineStart(),s=[]}function x(){g(s[0][0],s[0][1]),u.lineEnd();var t,e,n,r,A=u.clean(),h=l.result(),f=h.length;if(s.pop(),a.push(s),s=null,f)if(1&A){if((e=(n=h[0]).length-1)>0){for(c||(i.polygonStart(),c=!0),i.lineStart(),t=0;t<e;++t)i.point((r=n[t])[0],r[1]);i.lineEnd()}}else f>1&&2&A&&h.push(h.pop().concat(h.shift())),o.push(h.filter(qu))}return h}}function qu(t){return t.length>1}function Ru(t,e){return((t=t.x)[0]<0?t[1]-qA-PA:qA-t[1])-((e=e.x)[0]<0?e[1]-qA-PA:qA-e[1])}vu.invert=vu;var Ou=Lu((function(){return!0}),(function(t){var e,n=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(a,o){var s=a>0?LA:-LA,A=BA(a-n);BA(A-LA)<PA?(t.point(n,r=(r+o)/2>0?qA:-qA),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(a,r),e=0):i!==s&&A>=LA&&(BA(n-i)<PA&&(n-=i*PA),BA(a-s)<PA&&(a-=s*PA),r=function(t,e,n,r){var i,a,o=jA(t-n);return BA(o)>PA?NA((jA(e)*(a=UA(r))*jA(n)-jA(r)*(i=UA(e))*jA(t))/(i*a*o)):(e+r)/2}(n,r,a,o),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),e=0),t.point(n=a,r=o),i=s},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}}),(function(t,e,n,r){var i;if(null==t)i=n*qA,r.point(-LA,i),r.point(0,i),r.point(LA,i),r.point(LA,0),r.point(LA,-i),r.point(0,-i),r.point(-LA,-i),r.point(-LA,0),r.point(-LA,i);else if(BA(t[0]-e[0])>PA){var a=t[0]<e[0]?LA:-LA;i=n*a/2,r.point(-a,i),r.point(0,i),r.point(a,i)}else r.point(e[0],e[1])}),[-LA,-qA]);function Iu(t){var e=UA(t),n=6*kA,r=e>0,i=BA(e)>PA;function a(t,n){return UA(t)*UA(n)>e}function o(t,n,r){var i=[1,0,0],a=Tl(Sl(t),Sl(n)),o=El(a,a),s=a[0],A=o-s*s;if(!A)return!r&&t;var l=e*o/A,u=-e*s/A,c=Tl(i,a),h=Pl(i,l);Cl(h,Pl(a,u));var f=c,d=El(h,f),p=El(f,f),m=d*d-p*(El(h,h)-1);if(!(m<0)){var g=VA(m),v=Pl(f,(-d-g)/p);if(Cl(v,h),v=Ml(v),!r)return v;var x,y=t[0],b=n[0],_=t[1],w=n[1];b<y&&(x=y,y=b,b=x);var M=b-y,S=BA(M-LA)<PA;if(!S&&w<_&&(x=_,_=w,w=x),S||M<PA?S?_+w>0^v[1]<(BA(v[0]-y)<PA?_:w):_<=v[1]&&v[1]<=w:M>LA^(y<=v[0]&&v[0]<=b)){var E=Pl(f,(-d+g)/p);return Cl(E,h),[v,Ml(E)]}}}function s(e,n){var i=r?t:LA-t,a=0;return e<-i?a|=1:e>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}return Lu(a,(function(t){var e,n,A,l,u;return{lineStart:function(){l=A=!1,u=1},point:function(c,h){var f,d=[c,h],p=a(c,h),m=r?p?0:s(c,h):p?s(c+(c<0?LA:-LA),h):0;if(!e&&(l=A=p)&&t.lineStart(),p!==A&&(!(f=o(e,d))||Su(e,f)||Su(d,f))&&(d[2]=1),p!==A)u=0,p?(t.lineStart(),f=o(d,e),t.point(f[0],f[1])):(f=o(e,d),t.point(f[0],f[1],2),t.lineEnd()),e=f;else if(i&&e&&r^p){var g;m&n||!(g=o(d,e,!0))||(u=0,r?(t.lineStart(),t.point(g[0][0],g[0][1]),t.point(g[1][0],g[1][1]),t.lineEnd()):(t.point(g[1][0],g[1][1]),t.lineEnd(),t.lineStart(),t.point(g[0][0],g[0][1],3)))}!p||e&&Su(e,d)||t.point(d[0],d[1]),e=d,A=p,n=m},lineEnd:function(){A&&t.lineEnd(),e=null},clean:function(){return u|(l&&A)<<1}}}),(function(e,r,i,a){!function(t,e,n,r,i,a){if(n){var o=UA(e),s=jA(e),A=r*n;null==i?(i=e+r*OA,a=e-A/2):(i=wu(o,i),a=wu(o,a),(r>0?i<a:i>a)&&(i+=r*OA));for(var l,u=i;r>0?u>a:u<a;u-=A)l=Ml([o,-s*UA(u),-s*jA(u)]),t.point(l[0],l[1])}}(a,t,n,i,e,r)}),r?[0,-t]:[-LA,t-LA])}var ku,Bu,Nu,zu,Uu=1e9,Fu=-Uu;function Gu(t,e,n,r){function i(i,a){return t<=i&&i<=n&&e<=a&&a<=r}function a(i,a,s,l){var u=0,c=0;if(null==i||(u=o(i,s))!==(c=o(a,s))||A(i,a)<0^s>0)do{l.point(0===u||3===u?t:n,u>1?r:e)}while((u=(u+s+4)%4)!==c);else l.point(a[0],a[1])}function o(r,i){return BA(r[0]-t)<PA?i>0?0:3:BA(r[0]-n)<PA?i>0?2:1:BA(r[1]-e)<PA?i>0?1:0:i>0?3:2}function s(t,e){return A(t.x,e.x)}function A(t,e){var n=o(t,1),r=o(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(o){var A,l,u,c,h,f,d,p,m,g,v,x=o,y=Mu(),b={point:_,lineStart:function(){b.point=w,l&&l.push(u=[]);g=!0,m=!1,d=p=NaN},lineEnd:function(){A&&(w(c,h),f&&m&&y.rejoin(),A.push(y.result()));b.point=_,m&&x.lineEnd()},polygonStart:function(){x=y,A=[],l=[],v=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,i=l.length;n<i;++n)for(var a,o,s=l[n],A=1,u=s.length,c=s[0],h=c[0],f=c[1];A<u;++A)a=h,o=f,h=(c=s[A])[0],f=c[1],o<=r?f>r&&(h-a)*(r-o)>(f-o)*(t-a)&&++e:f<=r&&(h-a)*(r-o)<(f-o)*(t-a)&&--e;return e}(),n=v&&e,i=(A=TA(A)).length;(n||i)&&(o.polygonStart(),n&&(o.lineStart(),a(null,null,1,o),o.lineEnd()),i&&Tu(A,s,e,a,o),o.polygonEnd());x=o,A=l=u=null}};function _(t,e){i(t,e)&&x.point(t,e)}function w(a,o){var s=i(a,o);if(l&&u.push([a,o]),g)c=a,h=o,f=s,g=!1,s&&(x.lineStart(),x.point(a,o));else if(s&&m)x.point(a,o);else{var A=[d=Math.max(Fu,Math.min(Uu,d)),p=Math.max(Fu,Math.min(Uu,p))],y=[a=Math.max(Fu,Math.min(Uu,a)),o=Math.max(Fu,Math.min(Uu,o))];!function(t,e,n,r,i,a){var o,s=t[0],A=t[1],l=0,u=1,c=e[0]-s,h=e[1]-A;if(o=n-s,c||!(o>0)){if(o/=c,c<0){if(o<l)return;o<u&&(u=o)}else if(c>0){if(o>u)return;o>l&&(l=o)}if(o=i-s,c||!(o<0)){if(o/=c,c<0){if(o>u)return;o>l&&(l=o)}else if(c>0){if(o<l)return;o<u&&(u=o)}if(o=r-A,h||!(o>0)){if(o/=h,h<0){if(o<l)return;o<u&&(u=o)}else if(h>0){if(o>u)return;o>l&&(l=o)}if(o=a-A,h||!(o<0)){if(o/=h,h<0){if(o>u)return;o>l&&(l=o)}else if(h>0){if(o<l)return;o<u&&(u=o)}return l>0&&(t[0]=s+l*c,t[1]=A+l*h),u<1&&(e[0]=s+u*c,e[1]=A+u*h),!0}}}}}(A,y,t,e,n,r)?s&&(x.lineStart(),x.point(a,o),v=!1):(m||(x.lineStart(),x.point(A[0],A[1])),x.point(y[0],y[1]),s||x.lineEnd(),v=!1)}d=a,p=o,m=s}return b}}var ju={sphere:XA,point:XA,lineStart:function(){ju.point=Vu,ju.lineEnd=Hu},lineEnd:XA,polygonStart:XA,polygonEnd:XA};function Hu(){ju.point=ju.lineEnd=XA}function Vu(t,e){Bu=t*=kA,Nu=jA(e*=kA),zu=UA(e),ju.point=Wu}function Wu(t,e){t*=kA;var n=jA(e*=kA),r=UA(e),i=BA(t-Bu),a=UA(i),o=r*jA(i),s=zu*n-Nu*r*a,A=Nu*n+zu*r*a;ku.add(zA(VA(o*o+s*s),A)),Bu=t,Nu=n,zu=r}var Qu=[null,null],Xu={type:"LineString",coordinates:Qu};function Yu(t,e){return Qu[0]=t,Qu[1]=e,function(t){return ku=new bA,tl(t,ju),+ku}(Xu)}var Zu={Feature:function(t,e){return Ku(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r<i;)if(Ku(n[r].geometry,e))return!0;return!1}},Ju={Sphere:function(){return!0},Point:function(t,e){return $u(t.coordinates,e)},MultiPoint:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if($u(n[r],e))return!0;return!1},LineString:function(t,e){return tc(t.coordinates,e)},MultiLineString:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if(tc(n[r],e))return!0;return!1},Polygon:function(t,e){return ec(t.coordinates,e)},MultiPolygon:function(t,e){for(var n=t.coordinates,r=-1,i=n.length;++r<i;)if(ec(n[r],e))return!0;return!1},GeometryCollection:function(t,e){for(var n=t.geometries,r=-1,i=n.length;++r<i;)if(Ku(n[r],e))return!0;return!1}};function Ku(t,e){return!(!t||!Ju.hasOwnProperty(t.type))&&Ju[t.type](t,e)}function $u(t,e){return 0===Yu(t,e)}function tc(t,e){for(var n,r,i,a=0,o=t.length;a<o;a++){if(0===(r=Yu(t[a],e)))return!0;if(a>0&&(i=Yu(t[a],t[a-1]))>0&&n<=i&&r<=i&&(n+r-i)*(1-Math.pow((n-r)/i,2))<DA*i)return!0;n=r}return!1}function ec(t,e){return!!Du(t.map(nc),rc(e))}function nc(t){return(t=t.map(rc)).pop(),t}function rc(t){return[t[0]*kA,t[1]*kA]}function ic(t,e){return(t&&Zu.hasOwnProperty(t.type)?Zu[t.type]:Ku)(t,e)}function ac(t,e,n){var r=CA(t,e-PA,n).concat(e);return function(t){return r.map((function(e){return[t,e]}))}}function oc(t,e,n){var r=CA(t,e-PA,n).concat(e);return function(t){return r.map((function(e){return[e,t]}))}}function sc(){return function(){var t,e,n,r,i,a,o,s,A,l,u,c,h=10,f=h,d=90,p=360,m=2.5;function g(){return{type:"MultiLineString",coordinates:v()}}function v(){return CA(FA(r/d)*d,n,d).map(u).concat(CA(FA(s/p)*p,o,p).map(c)).concat(CA(FA(e/h)*h,t,h).filter((function(t){return BA(t%d)>PA})).map(A)).concat(CA(FA(a/f)*f,i,f).filter((function(t){return BA(t%p)>PA})).map(l))}return g.lines=function(){return v().map((function(t){return{type:"LineString",coordinates:t}}))},g.outline=function(){return{type:"Polygon",coordinates:[u(r).concat(c(o).slice(1),u(n).reverse().slice(1),c(s).reverse().slice(1))]}},g.extent=function(t){return arguments.length?g.extentMajor(t).extentMinor(t):g.extentMinor()},g.extentMajor=function(t){return arguments.length?(r=+t[0][0],n=+t[1][0],s=+t[0][1],o=+t[1][1],r>n&&(t=r,r=n,n=t),s>o&&(t=s,s=o,o=t),g.precision(m)):[[r,s],[n,o]]},g.extentMinor=function(n){return arguments.length?(e=+n[0][0],t=+n[1][0],a=+n[0][1],i=+n[1][1],e>t&&(n=e,e=t,t=n),a>i&&(n=a,a=i,i=n),g.precision(m)):[[e,a],[t,i]]},g.step=function(t){return arguments.length?g.stepMajor(t).stepMinor(t):g.stepMinor()},g.stepMajor=function(t){return arguments.length?(d=+t[0],p=+t[1],g):[d,p]},g.stepMinor=function(t){return arguments.length?(h=+t[0],f=+t[1],g):[h,f]},g.precision=function(h){return arguments.length?(m=+h,A=ac(a,i,90),l=oc(e,t,m),u=ac(s,o,90),c=oc(r,n,m),g):m},g.extentMajor([[-180,-89.999999],[180,89.999999]]).extentMinor([[-180,-80.000001],[180,80.000001]])}()()}function Ac(t,e){var n=t[0]*kA,r=t[1]*kA,i=e[0]*kA,a=e[1]*kA,o=UA(r),s=jA(r),A=UA(a),l=jA(a),u=o*UA(n),c=o*jA(n),h=A*UA(i),f=A*jA(i),d=2*WA(VA(QA(a-r)+o*A*QA(i-n))),p=jA(d),m=d?function(t){var e=jA(t*=d)/p,n=jA(d-t)/p,r=n*u+e*h,i=n*c+e*f,a=n*s+e*l;return[zA(i,r)*IA,zA(a,VA(r*r+i*i))*IA]}:function(){return[n*IA,r*IA]};return m.distance=d,m}var lc=t=>t,uc=1/0,cc=uc,hc=-uc,fc=hc;var dc={point:function(t,e){t<uc&&(uc=t);t>hc&&(hc=t);e<cc&&(cc=e);e>fc&&(fc=e)},lineStart:XA,lineEnd:XA,polygonStart:XA,polygonEnd:XA,result:function(){var t=[[uc,cc],[hc,fc]];return hc=fc=-(cc=uc=1/0),t}};function pc(t){return function(e){var n=new mc;for(var r in t)n[r]=t[r];return n.stream=e,n}}function mc(){}function gc(t,e,n){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),null!=r&&t.clipExtent(null),tl(n,t.stream(dc)),e(dc.result()),null!=r&&t.clipExtent(r),t}function vc(t,e,n){return gc(t,(function(n){var r=e[1][0]-e[0][0],i=e[1][1]-e[0][1],a=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+e[0][0]+(r-a*(n[1][0]+n[0][0]))/2,s=+e[0][1]+(i-a*(n[1][1]+n[0][1]))/2;t.scale(150*a).translate([o,s])}),n)}mc.prototype={constructor:mc,point:function(t,e){this.stream.point(t,e)},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 xc=UA(30*kA);function yc(t,e){return+e?function(t,e){function n(r,i,a,o,s,A,l,u,c,h,f,d,p,m){var g=l-r,v=u-i,x=g*g+v*v;if(x>4*e&&p--){var y=o+h,b=s+f,_=A+d,w=VA(y*y+b*b+_*_),M=WA(_/=w),S=BA(BA(_)-1)<PA||BA(a-c)<PA?(a+c)/2:zA(b,y),E=t(S,M),T=E[0],C=E[1],P=T-r,D=C-i,L=v*P-g*D;(L*L/x>e||BA((g*P+v*D)/x-.5)>.3||o*h+s*f+A*d<xc)&&(n(r,i,a,o,s,A,T,C,S,y/=w,b/=w,_,p,m),m.point(T,C),n(T,C,S,y,b,_,l,u,c,h,f,d,p,m))}}return function(e){var r,i,a,o,s,A,l,u,c,h,f,d,p={point:m,lineStart:g,lineEnd:x,polygonStart:function(){e.polygonStart(),p.lineStart=y},polygonEnd:function(){e.polygonEnd(),p.lineStart=g}};function m(n,r){n=t(n,r),e.point(n[0],n[1])}function g(){u=NaN,p.point=v,e.lineStart()}function v(r,i){var a=Sl([r,i]),o=t(r,i);n(u,c,l,h,f,d,u=o[0],c=o[1],l=r,h=a[0],f=a[1],d=a[2],16,e),e.point(u,c)}function x(){p.point=m,e.lineEnd()}function y(){g(),p.point=b,p.lineEnd=_}function b(t,e){v(r=t,e),i=u,a=c,o=h,s=f,A=d,p.point=v}function _(){n(u,c,l,h,f,d,i,a,r,o,s,A,16,e),p.lineEnd=x,x()}return p}}(t,e):function(t){return pc({point:function(e,n){e=t(e,n),this.stream.point(e[0],e[1])}})}(t)}var bc=pc({point:function(t,e){this.stream.point(t*kA,e*kA)}});function _c(t,e,n,r,i,a){if(!a)return function(t,e,n,r,i){function a(a,o){return[e+t*(a*=r),n-t*(o*=i)]}return a.invert=function(a,o){return[(a-e)/t*r,(n-o)/t*i]},a}(t,e,n,r,i);var o=UA(a),s=jA(a),A=o*t,l=s*t,u=o/t,c=s/t,h=(s*n-o*e)/t,f=(s*e+o*n)/t;function d(t,a){return[A*(t*=r)-l*(a*=i)+e,n-l*t-A*a]}return d.invert=function(t,e){return[r*(u*t-c*e+h),i*(f-c*t-u*e)]},d}function wc(t){return function(t){var e,n,r,i,a,o,s,A,l,u,c=150,h=480,f=250,d=0,p=0,m=0,g=0,v=0,x=0,y=1,b=1,_=null,w=Ou,M=null,S=lc,E=.5;function T(t){return A(t[0]*kA,t[1]*kA)}function C(t){return(t=A.invert(t[0],t[1]))&&[t[0]*IA,t[1]*IA]}function P(){var t=_c(c,0,0,y,b,x).apply(null,e(d,p)),r=_c(c,h-t[0],f-t[1],y,b,x);return n=xu(m,g,v),s=gu(e,r),A=gu(n,s),o=yc(s,E),D()}function D(){return l=u=null,T}return T.stream=function(t){return l&&u===t?l:l=bc(function(t){return pc({point:function(e,n){var r=t(e,n);return this.stream.point(r[0],r[1])}})}(n)(w(o(S(u=t)))))},T.preclip=function(t){return arguments.length?(w=t,_=void 0,D()):w},T.postclip=function(t){return arguments.length?(S=t,M=r=i=a=null,D()):S},T.clipAngle=function(t){return arguments.length?(w=+t?Iu(_=t*kA):(_=null,Ou),D()):_*IA},T.clipExtent=function(t){return arguments.length?(S=null==t?(M=r=i=a=null,lc):Gu(M=+t[0][0],r=+t[0][1],i=+t[1][0],a=+t[1][1]),D()):null==M?null:[[M,r],[i,a]]},T.scale=function(t){return arguments.length?(c=+t,P()):c},T.translate=function(t){return arguments.length?(h=+t[0],f=+t[1],P()):[h,f]},T.center=function(t){return arguments.length?(d=t[0]%360*kA,p=t[1]%360*kA,P()):[d*IA,p*IA]},T.rotate=function(t){return arguments.length?(m=t[0]%360*kA,g=t[1]%360*kA,v=t.length>2?t[2]%360*kA:0,P()):[m*IA,g*IA,v*IA]},T.angle=function(t){return arguments.length?(x=t%360*kA,P()):x*IA},T.reflectX=function(t){return arguments.length?(y=t?-1:1,P()):y<0},T.reflectY=function(t){return arguments.length?(b=t?-1:1,P()):b<0},T.precision=function(t){return arguments.length?(o=yc(s,E=t*t),D()):VA(E)},T.fitExtent=function(t,e){return vc(T,t,e)},T.fitSize=function(t,e){return function(t,e,n){return vc(t,[[0,0],e],n)}(T,t,e)},T.fitWidth=function(t,e){return function(t,e,n){return gc(t,(function(n){var r=+e,i=r/(n[1][0]-n[0][0]),a=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];t.scale(150*i).translate([a,o])}),n)}(T,t,e)},T.fitHeight=function(t,e){return function(t,e,n){return gc(t,(function(n){var r=+e,i=r/(n[1][1]-n[0][1]),a=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;t.scale(150*i).translate([a,o])}),n)}(T,t,e)},function(){return e=t.apply(this,arguments),T.invert=e.invert&&C,P()}}((function(){return t}))()}function Mc(t,e){var n=UA(e),r=1+UA(t)*n;return[n*jA(t)/r,jA(e)/r]}function Sc(){return wc(Mc).scale(250).clipAngle(142)}function Ec(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Tc(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Cc(t){return Cc=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Cc(t)}function Pc(t,e){return Pc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Pc(t,e)}function Dc(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Lc(t){var e=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(t){return!1}}();return function(){var n,r=Cc(t);if(e){var i=Cc(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Dc(this,n)}}function qc(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==n)return;var r,i,a=[],o=!0,s=!1;try{for(n=n.call(t);!(o=(r=n.next()).done)&&(a.push(r.value),!e||a.length!==e);o=!0);}catch(t){s=!0,i=t}finally{try{o||null==n.return||n.return()}finally{if(s)throw i}}return a}(t,e)||Rc(t,e)||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 Rc(t,e){if(t){if("string"==typeof t)return Oc(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Oc(t,e):void 0}}function Oc(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}Mc.invert=function(t){return function(e,n){var r=VA(e*e+n*n),i=t(r),a=jA(i),o=UA(i);return[zA(e*a,r*o),WA(r&&n*a/r)]}}((function(t){return 2*NA(t)}));var Ic=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=[],r=null;return t.forEach((function(t){if(r){var i=180*Yu(t,r)/Math.PI;if(i>e)for(var a=Ac(r,t),o=1/Math.ceil(i/e),s=o;s<1;)n.push(a(s)),s+=o}n.push(r=t)})),n},kc="undefined"!=typeof window&&window.THREE?window.THREE:{BufferGeometry:hn,Float32BufferAttribute:rn},Bc=(new kc.BufferGeometry).setAttribute?"setAttribute":"addAttribute",Nc=function(t){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Pc(t,e)}(a,t);var e,n,r,i=Lc(a);function a(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;Ec(this,a),(e=i.call(this)).type="GeoJsonGeometry",e.parameters={geoJson:t,radius:n,resolution:r};var o=({Point:u,MultiPoint:c,LineString:h,MultiLineString:f,Polygon:d,MultiPolygon:p}[t.type]||function(){return[]})(t.coordinates,n),s=[],A=[],l=0;function u(t,e){return[{vertices:Fc(t[1],t[0],e),indices:[]}]}function c(t,e){var n={vertices:[],indices:[]};return t.map((function(t){return u(t,e)})).forEach((function(t){var e=qc(t,1)[0];zc(n,e)})),[n]}function h(t,e){for(var n=Ic(t,r).map((function(t){var n=qc(t,2),r=n[0];return Fc(n[1],r,e)})),i=Fs.exports.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 f(t,e){var n={vertices:[],indices:[]};return t.map((function(t){return h(t,e)})).forEach((function(t){var e=qc(t,1)[0];zc(n,e)})),[n]}function d(t,e){for(var n=t.map((function(t){return Ic(t,r).map((function(t){var n=qc(t,2),r=n[0];return Fc(n[1],r,e)}))})),i=Fs.exports.flatten(n),a=i.vertices,o=i.holes,s=o[0]||1/0,A=a.slice(0,3*s),l=a.slice(3*s),u=new Set(o),c=Math.round(a.length/3),h=[],f=[],d=1;d<c;d++)u.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}function p(t,e){var n={vertices:[],indices:[]},r={vertices:[],indices:[]};t.map((function(t){return d(t,e)})).forEach((function(t){var e=qc(t,2),i=e[0],a=e[1];zc(n,i),a&&zc(r,a)}));var i=[n];return r.vertices.length&&i.push(r),i}return o.forEach((function(t){var n=s.length;zc({indices:s,vertices:A},t),e.addGroup(n,s.length-n,l++)})),s.length&&e.setIndex(s),A.length&&e[Bc]("position",new kc.Float32BufferAttribute(A,3)),e}return e=a,n&&Tc(e.prototype,n),r&&Tc(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}(kc.BufferGeometry);function zc(t,e){var n=Math.round(t.vertices.length/3);Uc(t.vertices,e.vertices),Uc(t.indices,e.indices.map((function(t){return t+n})))}function Uc(t,e){var n,r=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=Rc(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},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(t)},n:function(){var t=n.next();return o=t.done,t},e:function(t){s=!0,a=t},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw a}}}}(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;t.push(i)}}catch(t){r.e(t)}finally{r.f()}}function Fc(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=(90-t)*Math.PI/180,i=(90-e)*Math.PI/180;return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}function Gc(t){let e,n,r,i=0;for(let a=0;a<t.length;++a){const o=t[a];if(o.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(void 0===e&&(e=o.array.constructor),e!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() 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: .mergeBufferAttributes() 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: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;i+=o.array.length}const a=new e(i);let o=0;for(let e=0;e<t.length;++e)a.set(t[e].array,o),o+=t[e].array.length;return new tn(a,n,r)}function jc(t){const e=t.data.array.constructor,n=t.count,r=t.itemSize,i=t.normalized,a=new e(n*r);let o;o=t.isInstancedInterleavedBufferAttribute?new La(a,r,i,t.meshPerAttribute):new tn(a,r,i);for(let e=0;e<n;e++)o.setX(e,t.getX(e)),r>=2&&o.setY(e,t.getY(e)),r>=3&&o.setZ(e,t.getZ(e)),r>=4&&o.setW(e,t.getW(e));return o}var Hc=Object.freeze({__proto__:null,deepCloneAttribute:function(t){return t.isInstancedInterleavedBufferAttribute||t.isInterleavedBufferAttribute?jc(t):t.isInstancedBufferAttribute?(new La).copy(t):(new tn).copy(t)},deinterleaveAttribute:jc,deinterleaveGeometry:function(t){const e=t.attributes,n=t.morphTargets,r=new Map;for(const t in e){const n=e[t];n.isInterleavedBufferAttribute&&(r.has(n)||r.set(n,jc(n)),e[t]=r.get(n))}for(const t in n){const e=n[t];e.isInterleavedBufferAttribute&&(r.has(e)||r.set(e,jc(e)),n[t]=r.get(e))}},computeTangents:function(){throw new Error("BufferGeometryUtils: computeTangents renamed to computeMikkTSpaceTangents.")},computeMikkTSpaceTangents:function(t,e,n=!0){if(!e||!e.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!t.hasAttribute("position")||!t.hasAttribute("normal")||!t.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function r(t){if(t.normalized||t.isInterleavedBufferAttribute){const e=new Float32Array(t.getCount()*t.itemSize);for(let n=0,r=0;n<t.getCount();n++)e[r++]=t.getX(n),e[r++]=t.getY(n),t.itemSize>2&&(e[r++]=t.getZ(n));return e}return t.array instanceof Float32Array?t.array:new Float32Array(t.array)}const i=t.index?t.toNonIndexed():t,a=e.generateTangents(r(i.attributes.position),r(i.attributes.normal),r(i.attributes.uv));if(n)for(let t=3;t<a.length;t+=4)a[t]*=-1;return i.setAttribute("tangent",new tn(a,4)),t!==i&&t.copy(i),t},mergeBufferGeometries:function(t,e=!1){const n=null!==t[0].index,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),a={},o={},s=t[0].morphTargetsRelative,A=new hn;let l=0;for(let u=0;u<t.length;++u){const c=t[u];let h=0;if(n!==(null!==c.index))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const t in c.attributes){if(!r.has(t))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+t+'" attribute exists among all geometries, or in none of them.'),null;void 0===a[t]&&(a[t]=[]),a[t].push(c.attributes[t]),h++}if(h!==r.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(s!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const t in c.morphAttributes){if(!i.has(t))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;void 0===o[t]&&(o[t]=[]),o[t].push(c.morphAttributes[t])}if(e){let t;if(n)t=c.index.count;else{if(void 0===c.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;t=c.attributes.position.count}A.addGroup(l,t,u),l+=t}}if(n){let e=0;const n=[];for(let r=0;r<t.length;++r){const i=t[r].index;for(let t=0;t<i.count;++t)n.push(i.getX(t)+e);e+=t[r].attributes.position.count}A.setIndex(n)}for(const t in a){const e=Gc(a[t]);if(!e)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+t+" attribute."),null;A.setAttribute(t,e)}for(const t in o){const e=o[t][0].length;if(0===e)break;A.morphAttributes=A.morphAttributes||{},A.morphAttributes[t]=[];for(let n=0;n<e;++n){const e=[];for(let r=0;r<o[t].length;++r)e.push(o[t][r][n]);const r=Gc(e);if(!r)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+t+" morphAttribute."),null;A.morphAttributes[t].push(r)}}return A},mergeBufferAttributes:Gc,interleaveAttributes:function(t){let e,n=0,r=0;for(let i=0,a=t.length;i<a;++i){const a=t[i];if(void 0===e&&(e=a.array.constructor),e!==a.array.constructor)return console.error("AttributeBuffers of different types cannot be interleaved"),null;n+=a.array.length,r+=a.itemSize}const i=new Ca(new e(n),r);let a=0;const o=[],s=["getX","getY","getZ","getW"],A=["setX","setY","setZ","setW"];for(let e=0,n=t.length;e<n;e++){const n=t[e],r=n.itemSize,l=n.count,u=new Da(i,r,a,n.normalized);o.push(u),a+=r;for(let t=0;t<l;t++)for(let e=0;e<r;e++)u[A[e]](t,n[s[e]](t))}return o},estimateBytesUsed:function(t){let e=0;for(const n in t.attributes){const r=t.getAttribute(n);e+=r.count*r.itemSize*r.array.BYTES_PER_ELEMENT}const n=t.getIndex();return e+=n?n.count*n.itemSize*n.array.BYTES_PER_ELEMENT:0,e},mergeVertices:function(t,e=1e-4){e=Math.max(e,Number.EPSILON);const n={},r=t.getIndex(),i=t.getAttribute("position"),a=r?r.count:i.count;let o=0;const s=Object.keys(t.attributes),A={},l={},u=[],c=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let e=0,n=s.length;e<n;e++){const n=s[e],r=t.attributes[n];A[n]=new tn(new r.array.constructor(r.count*r.itemSize),r.itemSize,r.normalized);const i=t.morphAttributes[n];i&&(l[n]=new tn(new i.array.constructor(i.count*i.itemSize),i.itemSize,i.normalized))}const f=Math.log10(1/e),d=Math.pow(10,f);for(let e=0;e<a;e++){const i=r?r.getX(e):e;let a="";for(let e=0,n=s.length;e<n;e++){const n=s[e],r=t.getAttribute(n),o=r.itemSize;for(let t=0;t<o;t++)a+=~~(r[c[t]](i)*d)+","}if(a in n)u.push(n[a]);else{for(let e=0,n=s.length;e<n;e++){const n=s[e],r=t.getAttribute(n),a=t.morphAttributes[n],u=r.itemSize,f=A[n],d=l[n];for(let t=0;t<u;t++){const e=c[t],n=h[t];if(f[n](o,r[e](i)),a)for(let t=0,r=a.length;t<r;t++)d[t][n](o,a[t][e](i))}}n[a]=o,u.push(o),o++}}const p=t.clone();for(const e in t.attributes){const t=A[e];if(p.setAttribute(e,new tn(t.array.slice(0,o*t.itemSize),t.itemSize,t.normalized)),e in l)for(let t=0;t<l[e].length;t++){const n=l[e][t];p.morphAttributes[e][t]=new tn(n.array.slice(0,o*n.itemSize),n.itemSize,n.normalized)}}return p.setIndex(u),p},toTrianglesDrawMode:function(t,e){if(0===e)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),t;if(2===e||1===e){let n=t.getIndex();if(null===n){const e=[],r=t.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),t;for(let t=0;t<r.count;t++)e.push(t);t.setIndex(e),n=t.getIndex()}const r=n.count-2,i=[];if(2===e)for(let t=1;t<=r;t++)i.push(n.getX(0)),i.push(n.getX(t)),i.push(n.getX(t+1));else for(let t=0;t<r;t++)t%2==0?(i.push(n.getX(t)),i.push(n.getX(t+1)),i.push(n.getX(t+2))):(i.push(n.getX(t+2)),i.push(n.getX(t+1)),i.push(n.getX(t)));i.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const a=t.clone();return a.setIndex(i),a.clearGroups(),a}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),t},computeMorphedAttributes:function(t){if(!0!==t.geometry.isBufferGeometry)return console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry."),null;const e=new kt,n=new kt,r=new kt,i=new kt,a=new kt,o=new kt,s=new kt,A=new kt,l=new kt;function u(t,u,c,h,f,d,p,m){e.fromBufferAttribute(u,f),n.fromBufferAttribute(u,d),r.fromBufferAttribute(u,p);const g=t.morphTargetInfluences;if(c&&g){s.set(0,0,0),A.set(0,0,0),l.set(0,0,0);for(let t=0,u=c.length;t<u;t++){const u=g[t],m=c[t];0!==u&&(i.fromBufferAttribute(m,f),a.fromBufferAttribute(m,d),o.fromBufferAttribute(m,p),h?(s.addScaledVector(i,u),A.addScaledVector(a,u),l.addScaledVector(o,u)):(s.addScaledVector(i.sub(e),u),A.addScaledVector(a.sub(n),u),l.addScaledVector(o.sub(r),u)))}e.add(s),n.add(A),r.add(l)}t.isSkinnedMesh&&(t.boneTransform(f,e),t.boneTransform(d,n),t.boneTransform(p,r)),m[3*f+0]=e.x,m[3*f+1]=e.y,m[3*f+2]=e.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 c=t.geometry,h=t.material;let f,d,p;const m=c.index,g=c.attributes.position,v=c.morphAttributes.position,x=c.morphTargetsRelative,y=c.attributes.normal,b=c.morphAttributes.position,_=c.groups,w=c.drawRange;let M,S,E,T,C,P,D;const L=new Float32Array(g.count*g.itemSize),q=new Float32Array(y.count*y.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),D=Math.min(C.start+C.count,w.start+w.count),S=P,T=D;S<T;S+=3)f=m.getX(S),d=m.getX(S+1),p=m.getX(S+2),u(t,g,v,x,f,d,p,L),u(t,y,b,x,f,d,p,q);else for(P=Math.max(0,w.start),D=Math.min(m.count,w.start+w.count),M=P,E=D;M<E;M+=3)f=m.getX(M),d=m.getX(M+1),p=m.getX(M+2),u(t,g,v,x,f,d,p,L),u(t,y,b,x,f,d,p,q);else if(Array.isArray(h))for(M=0,E=_.length;M<E;M++)for(C=_[M],P=Math.max(C.start,w.start),D=Math.min(C.start+C.count,w.start+w.count),S=P,T=D;S<T;S+=3)f=S,d=S+1,p=S+2,u(t,g,v,x,f,d,p,L),u(t,y,b,x,f,d,p,q);else for(P=Math.max(0,w.start),D=Math.min(g.count,w.start+w.count),M=P,E=D;M<E;M+=3)f=M,d=M+1,p=M+2,u(t,g,v,x,f,d,p,L),u(t,y,b,x,f,d,p,q);return{positionAttribute:g,normalAttribute:y,morphedPositionAttribute:new rn(L,3),morphedNormalAttribute:new rn(q,3)}},mergeGroups:function(t){if(0===t.groups.length)return console.warn("THREE.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),t;let e=t.groups;if(e=e.sort(((t,e)=>t.materialIndex!==e.materialIndex?t.materialIndex-e.materialIndex:t.start-e.start)),null===t.getIndex()){const e=t.getAttribute("position"),n=[];for(let t=0;t<e.count;t+=3)n.push(t,t+1,t+2);t.setIndex(n)}const n=t.getIndex(),r=[];for(let t=0;t<e.length;t++){const i=e[t],a=i.start,o=a+i.count;for(let t=a;t<o;t++)r.push(n.getX(t))}t.dispose(),t.setIndex(r);let i=0;for(let t=0;t<e.length;t++){const n=e[t];n.start=i,i+=n.count}let a=e[0];t.groups=[a];for(let n=1;n<e.length;n++){const r=e[n];a.materialIndex===r.materialIndex?a.count+=r.count:(a=r,t.groups.push(a))}return t}}),Vc=function(t){return t instanceof Function?t:"string"==typeof t?function(e){return e[t]}:function(e){return t}},Wc={exports:{}};!function(t){!function(e){var n=/^\s+/,r=/\s+$/,i=0,a=e.round,o=e.min,s=e.max,A=e.random;function l(t,A){if(A=A||{},(t=t||"")instanceof l)return t;if(!(this instanceof l))return new l(t,A);var u=function(t){var i={r:0,g:0,b:0},a=1,A=null,l=null,u=null,c=!1,h=!1;"string"==typeof t&&(t=function(t){t=t.replace(n,"").replace(r,"").toLowerCase();var e,i=!1;if(T[t])t=T[t],i=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};if(e=U.rgb.exec(t))return{r:e[1],g:e[2],b:e[3]};if(e=U.rgba.exec(t))return{r:e[1],g:e[2],b:e[3],a:e[4]};if(e=U.hsl.exec(t))return{h:e[1],s:e[2],l:e[3]};if(e=U.hsla.exec(t))return{h:e[1],s:e[2],l:e[3],a:e[4]};if(e=U.hsv.exec(t))return{h:e[1],s:e[2],v:e[3]};if(e=U.hsva.exec(t))return{h:e[1],s:e[2],v:e[3],a:e[4]};if(e=U.hex8.exec(t))return{r:q(e[1]),g:q(e[2]),b:q(e[3]),a:k(e[4]),format:i?"name":"hex8"};if(e=U.hex6.exec(t))return{r:q(e[1]),g:q(e[2]),b:q(e[3]),format:i?"name":"hex"};if(e=U.hex4.exec(t))return{r:q(e[1]+""+e[1]),g:q(e[2]+""+e[2]),b:q(e[3]+""+e[3]),a:k(e[4]+""+e[4]),format:i?"name":"hex8"};if(e=U.hex3.exec(t))return{r:q(e[1]+""+e[1]),g:q(e[2]+""+e[2]),b:q(e[3]+""+e[3]),format:i?"name":"hex"};return!1}(t));"object"==typeof t&&(F(t.r)&&F(t.g)&&F(t.b)?(f=t.r,d=t.g,p=t.b,i={r:255*D(f,255),g:255*D(d,255),b:255*D(p,255)},c=!0,h="%"===String(t.r).substr(-1)?"prgb":"rgb"):F(t.h)&&F(t.s)&&F(t.v)?(A=O(t.s),l=O(t.v),i=function(t,n,r){t=6*D(t,360),n=D(n,100),r=D(r,100);var i=e.floor(t),a=t-i,o=r*(1-n),s=r*(1-a*n),A=r*(1-(1-a)*n),l=i%6;return{r:255*[r,s,o,o,A,r][l],g:255*[A,r,r,s,o,o][l],b:255*[o,o,A,r,r,s][l]}}(t.h,A,l),c=!0,h="hsv"):F(t.h)&&F(t.s)&&F(t.l)&&(A=O(t.s),u=O(t.l),i=function(t,e,n){var r,i,a;function o(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}if(t=D(t,360),e=D(e,100),n=D(n,100),0===e)r=i=a=n;else{var s=n<.5?n*(1+e):n+e-n*e,A=2*n-s;r=o(A,s,t+1/3),i=o(A,s,t),a=o(A,s,t-1/3)}return{r:255*r,g:255*i,b:255*a}}(t.h,A,u),c=!0,h="hsl"),t.hasOwnProperty("a")&&(a=t.a));var f,d,p;return a=P(a),{ok:c,format:t.format||h,r:o(255,s(i.r,0)),g:o(255,s(i.g,0)),b:o(255,s(i.b,0)),a:a}}(t);this._originalInput=t,this._r=u.r,this._g=u.g,this._b=u.b,this._a=u.a,this._roundA=a(100*this._a)/100,this._format=A.format||u.format,this._gradientType=A.gradientType,this._r<1&&(this._r=a(this._r)),this._g<1&&(this._g=a(this._g)),this._b<1&&(this._b=a(this._b)),this._ok=u.ok,this._tc_id=i++}function u(t,e,n){t=D(t,255),e=D(e,255),n=D(n,255);var r,i,a=s(t,e,n),A=o(t,e,n),l=(a+A)/2;if(a==A)r=i=0;else{var u=a-A;switch(i=l>.5?u/(2-a-A):u/(a+A),a){case t:r=(e-n)/u+(e<n?6:0);break;case e:r=(n-t)/u+2;break;case n:r=(t-e)/u+4}r/=6}return{h:r,s:i,l:l}}function c(t,e,n){t=D(t,255),e=D(e,255),n=D(n,255);var r,i,a=s(t,e,n),A=o(t,e,n),l=a,u=a-A;if(i=0===a?0:u/a,a==A)r=0;else{switch(a){case t:r=(e-n)/u+(e<n?6:0);break;case e:r=(n-t)/u+2;break;case n:r=(t-e)/u+4}r/=6}return{h:r,s:i,v:l}}function h(t,e,n,r){var i=[R(a(t).toString(16)),R(a(e).toString(16)),R(a(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 f(t,e,n,r){return[R(I(r)),R(a(t).toString(16)),R(a(e).toString(16)),R(a(n).toString(16))].join("")}function d(t,e){e=0===e?0:e||10;var n=l(t).toHsl();return n.s-=e/100,n.s=L(n.s),l(n)}function p(t,e){e=0===e?0:e||10;var n=l(t).toHsl();return n.s+=e/100,n.s=L(n.s),l(n)}function m(t){return l(t).desaturate(100)}function g(t,e){e=0===e?0:e||10;var n=l(t).toHsl();return n.l+=e/100,n.l=L(n.l),l(n)}function v(t,e){e=0===e?0:e||10;var n=l(t).toRgb();return n.r=s(0,o(255,n.r-a(-e/100*255))),n.g=s(0,o(255,n.g-a(-e/100*255))),n.b=s(0,o(255,n.b-a(-e/100*255))),l(n)}function x(t,e){e=0===e?0:e||10;var n=l(t).toHsl();return n.l-=e/100,n.l=L(n.l),l(n)}function y(t,e){var n=l(t).toHsl(),r=(n.h+e)%360;return n.h=r<0?360+r:r,l(n)}function b(t){var e=l(t).toHsl();return e.h=(e.h+180)%360,l(e)}function _(t){var e=l(t).toHsl(),n=e.h;return[l(t),l({h:(n+120)%360,s:e.s,l:e.l}),l({h:(n+240)%360,s:e.s,l:e.l})]}function w(t){var e=l(t).toHsl(),n=e.h;return[l(t),l({h:(n+90)%360,s:e.s,l:e.l}),l({h:(n+180)%360,s:e.s,l:e.l}),l({h:(n+270)%360,s:e.s,l:e.l})]}function M(t){var e=l(t).toHsl(),n=e.h;return[l(t),l({h:(n+72)%360,s:e.s,l:e.l}),l({h:(n+216)%360,s:e.s,l:e.l})]}function S(t,e,n){e=e||6,n=n||30;var r=l(t).toHsl(),i=360/n,a=[l(t)];for(r.h=(r.h-(i*e>>1)+720)%360;--e;)r.h=(r.h+i)%360,a.push(l(r));return a}function E(t,e){e=e||6;for(var n=l(t).toHsv(),r=n.h,i=n.s,a=n.v,o=[],s=1/e;e--;)o.push(l({h:r,s:i,v:a})),a=(a+s)%1;return o}l.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 t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},getLuminance:function(){var t,n,r,i=this.toRgb();return t=i.r/255,n=i.g/255,r=i.b/255,.2126*(t<=.03928?t/12.92:e.pow((t+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:e.pow((n+.055)/1.055,2.4))+.0722*(r<=.03928?r/12.92:e.pow((r+.055)/1.055,2.4))},setAlpha:function(t){return this._a=P(t),this._roundA=a(100*this._a)/100,this},toHsv:function(){var t=c(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=c(this._r,this._g,this._b),e=a(360*t.h),n=a(100*t.s),r=a(100*t.v);return 1==this._a?"hsv("+e+", "+n+"%, "+r+"%)":"hsva("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var t=u(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=u(this._r,this._g,this._b),e=a(360*t.h),n=a(100*t.s),r=a(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+r+"%)":"hsla("+e+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(t){return h(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(t){return function(t,e,n,r,i){var o=[R(a(t).toString(16)),R(a(e).toString(16)),R(a(n).toString(16)),R(I(r))];if(i&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1))return o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0);return o.join("")}(this._r,this._g,this._b,this._a,t)},toHex8String:function(t){return"#"+this.toHex8(t)},toRgb:function(){return{r:a(this._r),g:a(this._g),b:a(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+a(this._r)+", "+a(this._g)+", "+a(this._b)+")":"rgba("+a(this._r)+", "+a(this._g)+", "+a(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:a(100*D(this._r,255))+"%",g:a(100*D(this._g,255))+"%",b:a(100*D(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+a(100*D(this._r,255))+"%, "+a(100*D(this._g,255))+"%, "+a(100*D(this._b,255))+"%)":"rgba("+a(100*D(this._r,255))+"%, "+a(100*D(this._g,255))+"%, "+a(100*D(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(C[h(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+f(this._r,this._g,this._b,this._a),n=e,r=this._gradientType?"GradientType = 1, ":"";if(t){var i=l(t);n="#"+f(i._r,i._g,i._b,i._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+e+",endColorstr="+n+")"},toString:function(t){var e=!!t;t=t||this._format;var n=!1,r=this._a<1&&this._a>=0;return e||!r||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"hex4"!==t&&"hex8"!==t&&"name"!==t?("rgb"===t&&(n=this.toRgbString()),"prgb"===t&&(n=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(n=this.toHexString()),"hex3"===t&&(n=this.toHexString(!0)),"hex4"===t&&(n=this.toHex8String(!0)),"hex8"===t&&(n=this.toHex8String()),"name"===t&&(n=this.toName()),"hsl"===t&&(n=this.toHslString()),"hsv"===t&&(n=this.toHsvString()),n||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},clone:function(){return l(this.toString())},_applyModification:function(t,e){var n=t.apply(null,[this].concat([].slice.call(e)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(g,arguments)},brighten:function(){return this._applyModification(v,arguments)},darken:function(){return this._applyModification(x,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(p,arguments)},greyscale:function(){return this._applyModification(m,arguments)},spin:function(){return this._applyModification(y,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(S,arguments)},complement:function(){return this._applyCombination(b,arguments)},monochromatic:function(){return this._applyCombination(E,arguments)},splitcomplement:function(){return this._applyCombination(M,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(w,arguments)}},l.fromRatio=function(t,e){if("object"==typeof t){var n={};for(var r in t)t.hasOwnProperty(r)&&(n[r]="a"===r?t[r]:O(t[r]));t=n}return l(t,e)},l.equals=function(t,e){return!(!t||!e)&&l(t).toRgbString()==l(e).toRgbString()},l.random=function(){return l.fromRatio({r:A(),g:A(),b:A()})},l.mix=function(t,e,n){n=0===n?0:n||50;var r=l(t).toRgb(),i=l(e).toRgb(),a=n/100;return l({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)
|