zhitong.yu
2024-03-15 ebd89b9ffa8980ac944a7e79ecc64c01637d4f17
1
2
/**Released Version v3.0.9,BUILD 171,Time 1650280941292. Fengmap Javascript SDK , see: https://www.fengmap.com for details**/
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.fengmap=n():t.fengmap=n()}(this,function(){return i={},r.m=e=[function(t,n,e){"use strict";e.r(n);var h={};function i(){}e.r(h),e.d(h,"ShadowMaterial",function(){return fn}),e.d(h,"SpriteMaterial",function(){return dn}),e.d(h,"RawShaderMaterial",function(){return An}),e.d(h,"ShaderMaterial",function(){return xn}),e.d(h,"PointsMaterial",function(){return k}),e.d(h,"MeshPhysicalMaterial",function(){return yn}),e.d(h,"MeshStandardMaterial",function(){return wn}),e.d(h,"MeshPhongMaterial",function(){return Sn}),e.d(h,"MeshToonMaterial",function(){return bn}),e.d(h,"MeshNormalMaterial",function(){return Mn}),e.d(h,"MeshLambertMaterial",function(){return Tn}),e.d(h,"MeshDepthMaterial",function(){return Ln}),e.d(h,"MeshDistanceMaterial",function(){return En}),e.d(h,"MeshBasicMaterial",function(){return Pn}),e.d(h,"MeshMatcapMaterial",function(){return Fn}),e.d(h,"LineDashedMaterial",function(){return Dn}),e.d(h,"LineBasicMaterial",function(){return Nn}),e.d(h,"Material",function(){return I}),Object.assign(i.prototype,{addEventListener:function(t,n){void 0===this.e&&(this.e={});var e=this.e;void 0===e[t]&&(e[t]=[]),-1===e[t].indexOf(n)&&e[t].push(n)},hasEventListener:function(t,n){if(void 0===this.e)return!1;var e=this.e;return void 0!==e[t]&&-1!==e[t].indexOf(n)},removeEventListener:function(t,n){void 0!==this.e&&(void 0===(t=this.e[t])||-1!==(n=t.indexOf(n))&&t.splice(n,1))},dispatchEvent:function(t){if(void 0!==this.e){var n=this.e[t.type];if(void 0!==n){t.target=this;for(var e=n.slice(0),i=0,r=e.length;i<r;i++)e[i].call(this,t)}}}});for(var L=0,l=1,c=2,a=0,r=1,u=2,o=100,s=204,f=205,d=3,v=0,m=306,p=1001,g=1003,E=1006,_=1008,S=1009,P=1022,x=1023,b=x,A=3e3,w=3200,y=0,M=7680,T=519,F=35044,N=[],D=0;D<256;D++)N[D]=(D<16?"0":"")+D.toString(16);var C={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(N[255&t]+N[t>>8&255]+N[t>>16&255]+N[t>>24&255]+"-"+N[255&n]+N[n>>8&255]+"-"+N[n>>16&15|64]+N[n>>24&255]+"-"+N[63&e|128]+N[e>>8&255]+"-"+N[e>>16&255]+N[e>>24&255]+N[255&i]+N[i>>8&255]+N[i>>16&255]+N[i>>24&255]).toUpperCase()},clamp:function(t,n,e){return Math.max(n,Math.min(e,t))},euclideanModulo:function(t,n){return(t%n+n)%n},mapLinear:function(t,n,e,i,r){return i+(t-n)*(r-i)/(e-n)},lerp:function(t,n,e){return(1-e)*t+e*n},smoothstep:function(t,n,e){return t<=n?0:e<=t?1:(t=(t-n)/(e-n))*t*(3-2*t)},smootherstep:function(t,n,e){return t<=n?0:e<=t?1:(t=(t-n)/(e-n))*t*t*(t*(6*t-15)+10)},randInt:function(t,n){return t+Math.floor(Math.random()*(n-t+1))},randFloat:function(t,n){return t+Math.random()*(n-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:function(t){return t*C.DEG2RAD},radToDeg:function(t){return t*C.RAD2DEG},isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,n,e,i,r){var a=Math.cos,o=Math.sin,s=a(e/2),h=o(e/2),l=a((n+i)/2),c=o((n+i)/2),u=a((n-i)/2),e=o((n-i)/2),a=a((i-n)/2),n=o((i-n)/2);"XYX"===r?t.set(s*c,h*u,h*e,s*l):"YZY"===r?t.set(h*e,s*c,h*u,s*l):"ZXZ"===r?t.set(h*u,h*e,s*c,s*l):"XZX"===r?t.set(s*c,h*n,h*a,s*l):"YXY"===r?t.set(h*a,s*c,h*n,s*l):"ZYZ"===r?t.set(h*n,h*a,s*c,s*l):console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order.")}},R=0;function I(){Object.defineProperty(this,"id",{value:R++}),this.uuid=C.generateUUID(),this.name="",this.type="Material",this.fog=!0,this.blending=r,this.side=L,this.flatShading=!1,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=s,this.blendDst=f,this.blendEquation=o,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=d,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=T,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=M,this.stencilZFail=M,this.stencilZPass=M,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.alphaTest=0,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0}I.prototype=Object.assign(Object.create(i.prototype),{constructor:I,isMaterial:!0,onBeforeCompile:function(){},setValues:function(t){if(void 0!==t)for(var n in t){var e,i=t[n];void 0!==i?"shading"!==n?void 0!==(e=this[n])?e&&e.isColor?e.set(i):e&&e.isVector3&&i&&i.isVector3?e.copy(i):this[n]=i:console.warn("THREE."+this.type+": '"+n+"' is not a property of this material."):(console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===i):console.warn("THREE.Material: '"+n+"' parameter is undefined.")}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.name=t.name,this.fog=t.fog,this.blending=t.blending,this.side=t.side,this.flatShading=t.flatShading,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;var n=t.clippingPlanes,e=null;if(null!==n)for(var i=n.length,e=new Array(i),r=0;r!==i;++r)e[r]=n[r].clone();return this.clippingPlanes=e,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.premultipliedAlpha=t.premultipliedAlpha,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Object.defineProperty(I.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}});var O={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},U={h:0,s:0,l:0},H={h:0,s:0,l:0};function X(t,n,e){return void 0===n&&void 0===e?this.set(t):this.setRGB(t,n,e)}function G(t,n,e){return e<0&&(e+=1),1<e&&--e,e<1/6?t+6*(n-t)*e:e<.5?n:e<2/3?t+6*(n-t)*(2/3-e):t}function z(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function B(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}function k(t){I.call(this),this.type="PointsMaterial",this.color=new X(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.morphTargets=!1,this.setValues(t)}function V(t,n,e,i){this.u=t||0,this.f=n||0,this.v=e||0,this._=void 0!==i?i:1}Object.assign(X.prototype,{isColor:!0,r:1,g:1,b:1,set:function(t){return t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setScalar:function(t){return this.r=t,this.g=t,this.b=t,this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,n,e){return this.r=t,this.g=n,this.b=e,this},setHSL:function(t,n,e){return t=C.euclideanModulo(t,1),n=C.clamp(n,0,1),e=C.clamp(e,0,1),0===n?this.r=this.g=this.b=e:(this.r=G(n=2*e-(e=e<=.5?e*(1+n):e+n-e*n),e,t+1/3),this.g=G(n,e,t),this.b=G(n,e,t-1/3)),this},setStyle:function(n){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+n+" will be ignored.")}if(h=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(n)){var e,i=h[1],r=h[2];switch(i){case"rgb":case"rgba":if(e=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(r))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[5]),this;if(e=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(r))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[5]),this;break;case"hsl":case"hsla":if(e=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(r)){var a=parseFloat(e[1])/360,o=parseInt(e[2],10)/100,s=parseInt(e[3],10)/100;return t(e[5]),this.setHSL(a,o,s)}}}else if(h=/^\#([A-Fa-f0-9]+)$/.exec(n)){var i=h[1],h=i.length;if(3===h)return this.r=parseInt(i.charAt(0)+i.charAt(0),16)/255,this.g=parseInt(i.charAt(1)+i.charAt(1),16)/255,this.b=parseInt(i.charAt(2)+i.charAt(2),16)/255,this;if(6===h)return this.r=parseInt(i.charAt(0)+i.charAt(1),16)/255,this.g=parseInt(i.charAt(2)+i.charAt(3),16)/255,this.b=parseInt(i.charAt(4)+i.charAt(5),16)/255,this}return n&&0<n.length?this.setColorName(n):this},setColorName:function(t){var n=O[t];return void 0!==n?this.setHex(n):console.warn("THREE.Color: Unknown color "+t),this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t,n){return void 0===n&&(n=2),this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this},copyLinearToGamma:function(t,n){n=0<(n=void 0===n?2:n)?1/n:1;return this.r=Math.pow(t.r,n),this.g=Math.pow(t.g,n),this.b=Math.pow(t.b,n),this},convertGammaToLinear:function(t){return this.copyGammaToLinear(this,t),this},convertLinearToGamma:function(t){return this.copyLinearToGamma(this,t),this},copySRGBToLinear:function(t){return this.r=z(t.r),this.g=z(t.g),this.b=z(t.b),this},copyLinearToSRGB:function(t){return this.r=B(t.r),this.g=B(t.g),this.b=B(t.b),this},convertSRGBToLinear:function(){return this.copySRGBToLinear(this),this},convertLinearToSRGB:function(){return this.copyLinearToSRGB(this),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){void 0===t&&(console.warn("THREE.Color: .getHSL() target is now required"),t={h:0,s:0,l:0});var n,e=this.r,i=this.g,r=this.b,a=Math.max(e,i,r),o=Math.min(e,i,r),s=(o+a)/2;if(o===a)l=n=0;else{var h=a-o,l=s<=.5?h/(a+o):h/(2-a-o);switch(a){case e:n=(i-r)/h+(i<r?6:0);break;case i:n=(r-e)/h+2;break;case r:n=(e-i)/h+4}n/=6}return t.h=n,t.s=l,t.l=s,t},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(t,n,e){return this.getHSL(U),U.h+=t,U.s+=n,U.l+=e,this.setHSL(U.h,U.s,U.l),this},add:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},addColors:function(t,n){return this.r=t.r+n.r,this.g=t.g+n.g,this.b=t.b+n.b,this},addScalar:function(t){return this.r+=t,this.g+=t,this.b+=t,this},sub:function(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:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},multiplyScalar:function(t){return this.r*=t,this.g*=t,this.b*=t,this},lerp:function(t,n){return this.r+=(t.r-this.r)*n,this.g+=(t.g-this.g)*n,this.b+=(t.b-this.b)*n,this},lerpHSL:function(t,n){this.getHSL(U),t.getHSL(H);var e=C.lerp(U.h,H.h,n),t=C.lerp(U.s,H.s,n),n=C.lerp(U.l,H.l,n);return this.setHSL(e,t,n),this},equals:function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},fromArray:function(t,n){return this.r=t[n=void 0===n?0:n],this.g=t[n+1],this.b=t[n+2],this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.r,t[n+1]=this.g,t[n+2]=this.b,t}}),X.NAMES=O,((k.prototype=Object.create(I.prototype)).constructor=k).prototype.isPointsMaterial=!0,k.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.morphTargets=t.morphTargets,this},Object.assign(V,{slerp:function(t,n,e,i){return e.copy(t).slerp(n,i)},slerpFlat:function(t,n,e,i,r,a,o){var s=e[i+0],h=e[i+1],l=e[i+2],c=e[i+3],u=r[a+0],f=r[a+1],d=r[a+2],v=r[a+3];c===v&&s===u&&h===f&&l===d||(e=1-o,r=0<=(i=s*u+h*f+l*d+c*v)?1:-1,(a=1-i*i)>Number.EPSILON&&(a=Math.sqrt(a),i=Math.atan2(a,i*r),e=Math.sin(e*i)/a,o=Math.sin(o*i)/a),s=s*e+u*(r=o*r),h=h*e+f*r,l=l*e+d*r,c=c*e+v*r,e===1-o&&(s*=o=1/Math.sqrt(s*s+h*h+l*l+c*c),h*=o,l*=o,c*=o)),t[n]=s,t[n+1]=h,t[n+2]=l,t[n+3]=c}}),Object.defineProperties(V.prototype,{x:{get:function(){return this.u},set:function(t){this.u=t,this.A()}},y:{get:function(){return this.f},set:function(t){this.f=t,this.A()}},z:{get:function(){return this.v},set:function(t){this.v=t,this.A()}},w:{get:function(){return this._},set:function(t){this._=t,this.A()}}}),Object.assign(V.prototype,{isQuaternion:!0,set:function(t,n,e,i){return this.u=t,this.f=n,this.v=e,this._=i,this.A(),this},clone:function(){return new this.constructor(this.u,this.f,this.v,this._)},copy:function(t){return this.u=t.x,this.f=t.y,this.v=t.z,this._=t.w,this.A(),this},setFromEuler:function(t,n){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var e=t.u,i=t.f,r=t.v,a=t.order,o=Math.cos,s=Math.sin,h=o(e/2),t=o(i/2),o=o(r/2),e=s(e/2),i=s(i/2),r=s(r/2);return"XYZ"===a?(this.u=e*t*o+h*i*r,this.f=h*i*o-e*t*r,this.v=h*t*r+e*i*o,this._=h*t*o-e*i*r):"YXZ"===a?(this.u=e*t*o+h*i*r,this.f=h*i*o-e*t*r,this.v=h*t*r-e*i*o,this._=h*t*o+e*i*r):"ZXY"===a?(this.u=e*t*o-h*i*r,this.f=h*i*o+e*t*r,this.v=h*t*r+e*i*o,this._=h*t*o-e*i*r):"ZYX"===a?(this.u=e*t*o-h*i*r,this.f=h*i*o+e*t*r,this.v=h*t*r-e*i*o,this._=h*t*o+e*i*r):"YZX"===a?(this.u=e*t*o+h*i*r,this.f=h*i*o+e*t*r,this.v=h*t*r-e*i*o,this._=h*t*o-e*i*r):"XZY"===a&&(this.u=e*t*o-h*i*r,this.f=h*i*o-e*t*r,this.v=h*t*r+e*i*o,this._=h*t*o+e*i*r),!1!==n&&this.A(),this},setFromAxisAngle:function(t,n){var e=n/2,n=Math.sin(e);return this.u=t.x*n,this.f=t.y*n,this.v=t.z*n,this._=Math.cos(e),this.A(),this},setFromRotationMatrix:function(t){var n,e=t.elements,i=e[0],r=e[4],a=e[8],o=e[1],s=e[5],h=e[9],l=e[2],c=e[6],t=e[10],e=i+s+t;return 0<e?(n=.5/Math.sqrt(e+1),this._=.25/n,this.u=(c-h)*n,this.f=(a-l)*n,this.v=(o-r)*n):s<i&&t<i?(n=2*Math.sqrt(1+i-s-t),this._=(c-h)/n,this.u=.25*n,this.f=(r+o)/n,this.v=(a+l)/n):t<s?(n=2*Math.sqrt(1+s-i-t),this._=(a-l)/n,this.u=(r+o)/n,this.f=.25*n,this.v=(h+c)/n):(n=2*Math.sqrt(1+t-i-s),this._=(o-r)/n,this.u=(a+l)/n,this.f=(h+c)/n,this.v=.25*n),this.A(),this},setFromUnitVectors:function(t,n){var e=t.dot(n)+1;return e<1e-6?(e=0,Math.abs(t.x)>Math.abs(t.z)?(this.u=-t.y,this.f=t.x,this.v=0):(this.u=0,this.f=-t.z,this.v=t.y)):(this.u=t.y*n.z-t.z*n.y,this.f=t.z*n.x-t.x*n.z,this.v=t.x*n.y-t.y*n.x),this._=e,this.normalize()},angleTo:function(t){return 2*Math.acos(Math.abs(C.clamp(this.dot(t),-1,1)))},rotateTowards:function(t,n){var e=this.angleTo(t);if(0===e)return this;e=Math.min(1,n/e);return this.slerp(t,e),this},inverse:function(){return this.conjugate()},conjugate:function(){return this.u*=-1,this.f*=-1,this.v*=-1,this.A(),this},dot:function(t){return this.u*t.u+this.f*t.f+this.v*t.v+this._*t._},lengthSq:function(){return this.u*this.u+this.f*this.f+this.v*this.v+this._*this._},length:function(){return Math.sqrt(this.u*this.u+this.f*this.f+this.v*this.v+this._*this._)},normalize:function(){var t=this.length();return 0===t?(this.u=0,this.f=0,this.v=0,this._=1):(this.u=this.u*(t=1/t),this.f=this.f*t,this.v=this.v*t,this._=this._*t),this.A(),this},multiply:function(t,n){return void 0!==n?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,n)):this.multiplyQuaternions(this,t)},premultiply:function(t){return this.multiplyQuaternions(t,this)},multiplyQuaternions:function(t,n){var e=t.u,i=t.f,r=t.v,a=t._,o=n.u,s=n.f,t=n.v,n=n._;return this.u=e*n+a*o+i*t-r*s,this.f=i*n+a*s+r*o-e*t,this.v=r*n+a*t+e*s-i*o,this._=a*n-e*o-i*s-r*t,this.A(),this},slerp:function(t,n){if(0===n)return this;if(1===n)return this.copy(t);var e=this.u,i=this.f,r=this.v,a=this._,o=a*t._+e*t.u+i*t.f+r*t.v;if(o<0?(this._=-t._,this.u=-t.u,this.f=-t.f,this.v=-t.v,o=-o):this.copy(t),1<=o)return this._=a,this.u=e,this.f=i,this.v=r,this;t=1-o*o;if(t<=Number.EPSILON){var s=1-n;return this._=s*a+n*this._,this.u=s*e+n*this.u,this.f=s*i+n*this.f,this.v=s*r+n*this.v,this.normalize(),this.A(),this}s=Math.sqrt(t),t=Math.atan2(s,o),o=Math.sin((1-n)*t)/s,s=Math.sin(n*t)/s;return this._=a*o+this._*s,this.u=e*o+this.u*s,this.f=i*o+this.f*s,this.v=r*o+this.v*s,this.A(),this},equals:function(t){return t.u===this.u&&t.f===this.f&&t.v===this.v&&t._===this._},fromArray:function(t,n){return this.u=t[n=void 0===n?0:n],this.f=t[n+1],this.v=t[n+2],this._=t[n+3],this.A(),this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.u,t[n+1]=this.f,t[n+2]=this.v,t[n+3]=this._,t},fromBufferAttribute:function(t,n){return this.u=t.getX(n),this.f=t.getY(n),this.v=t.getZ(n),this._=t.getW(n),this},S:function(t){return this.A=t,this},A:function(){}});var Y=new Q,j=new V;function Q(t,n,e){this.x=t||0,this.y=n||0,this.z=e||0}Object.assign(Q.prototype,{isVector3:!0,set:function(t,n,e){return this.x=t,this.y=n,this.z=e,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(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:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,n){return void 0!==n?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,n)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this},addScaledVector:function(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this},sub:function(t,n){return void 0!==n?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,n)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this},subVectors:function(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this},multiply:function(t,n){return void 0!==n?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,n)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,n){return this.x=t.x*n.x,this.y=t.y*n.y,this.z=t.z*n.z,this},applyEuler:function(t){return t&&t.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(j.setFromEuler(t))},applyAxisAngle:function(t,n){return this.applyQuaternion(j.setFromAxisAngle(t,n))},applyMatrix3:function(t){var n=this.x,e=this.y,i=this.z,t=t.elements;return this.x=t[0]*n+t[3]*e+t[6]*i,this.y=t[1]*n+t[4]*e+t[7]*i,this.z=t[2]*n+t[5]*e+t[8]*i,this},applyNormalMatrix:function(t){return this.applyMatrix3(t).normalize()},applyMatrix4:function(t){var n=this.x,e=this.y,i=this.z,r=t.elements,t=1/(r[3]*n+r[7]*e+r[11]*i+r[15]);return this.x=(r[0]*n+r[4]*e+r[8]*i+r[12])*t,this.y=(r[1]*n+r[5]*e+r[9]*i+r[13])*t,this.z=(r[2]*n+r[6]*e+r[10]*i+r[14])*t,this},applyQuaternion:function(t){var n=this.x,e=this.y,i=this.z,r=t.x,a=t.y,o=t.z,s=t.w,h=s*n+a*i-o*e,l=s*e+o*n-r*i,t=s*i+r*e-a*n,i=-r*n-a*e-o*i;return this.x=h*s+i*-r+l*-o-t*-a,this.y=l*s+i*-a+t*-r-h*-o,this.z=t*s+i*-o+h*-a-l*-r,this},project:function(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)},unproject:function(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)},transformDirection:function(t){var n=this.x,e=this.y,i=this.z,t=t.elements;return this.x=t[0]*n+t[4]*e+t[8]*i,this.y=t[1]*n+t[5]*e+t[9]*i,this.z=t[2]*n+t[6]*e+t[10]*i,this.normalize()},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){return this.multiplyScalar(1/t)},min:function(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:function(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:function(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this.z=Math.max(t.z,Math.min(n.z,this.z)),this},clampScalar:function(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this.z=Math.max(t,Math.min(n,this.z)),this},clampLength:function(t,n){var e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){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:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this},lerpVectors:function(t,n,e){return this.subVectors(n,t).multiplyScalar(e).add(t)},cross:function(t,n){return void 0!==n?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,n)):this.crossVectors(this,t)},crossVectors:function(t,n){var e=t.x,i=t.y,r=t.z,a=n.x,t=n.y,n=n.z;return this.x=i*n-r*t,this.y=r*a-e*n,this.z=e*t-i*a,this},projectOnVector:function(t){var n=t.lengthSq();if(0===n)return this.set(0,0,0);n=t.dot(this)/n;return this.copy(t).multiplyScalar(n)},projectOnPlane:function(t){return Y.copy(this).projectOnVector(t),this.sub(Y)},reflect:function(t){return this.sub(Y.copy(t).multiplyScalar(2*this.dot(t)))},angleTo:function(t){var n=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===n)return Math.PI/2;n=this.dot(t)/n;return Math.acos(C.clamp(n,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var n=this.x-t.x,e=this.y-t.y,t=this.z-t.z;return n*n+e*e+t*t},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},setFromSpherical:function(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)},setFromSphericalCoords:function(t,n,e){var i=Math.sin(n)*t;return this.x=i*Math.sin(e),this.y=Math.cos(n)*t,this.z=i*Math.cos(e),this},setFromCylindrical:function(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)},setFromCylindricalCoords:function(t,n,e){return this.x=t*Math.sin(n),this.y=e,this.z=t*Math.cos(n),this},setFromMatrixPosition:function(t){t=t.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this},setFromMatrixScale:function(t){var n=this.setFromMatrixColumn(t,0).length(),e=this.setFromMatrixColumn(t,1).length(),t=this.setFromMatrixColumn(t,2).length();return this.x=n,this.y=e,this.z=t,this},setFromMatrixColumn:function(t,n){return this.fromArray(t.elements,4*n)},setFromMatrix3Column:function(t,n){return this.fromArray(t.elements,3*n)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,n){return this.x=t[n=void 0===n?0:n],this.y=t[n+1],this.z=t[n+2],this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t},fromBufferAttribute:function(t,n,e){return void 0!==e&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(n),this.y=t.getY(n),this.z=t.getZ(n),this}});var W=[new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q],Z=new Q,q=new st,K=new Q,J=new Q,$=new Q,tt=new Q,nt=new Q,et=new Q,it=new Q,rt=new Q,at=new Q,ot=new Q;function st(t,n){this.min=void 0!==t?t:new Q(1/0,1/0,1/0),this.max=void 0!==n?n:new Q(-1/0,-1/0,-1/0)}function ht(t,n,e,i,r){for(var a=0,o=t.length-3;a<=o;a+=3){ot.fromArray(t,a);var s=r.x*Math.abs(ot.x)+r.y*Math.abs(ot.y)+r.z*Math.abs(ot.z),h=n.dot(ot),l=e.dot(ot),c=i.dot(ot);if(Math.max(-Math.max(h,l,c),Math.min(h,l,c))>s)return!1}return!0}function lt(t,n,e,i){this.x=t||0,this.y=n||0,this.z=e||0,this.w=void 0!==i?i:1}function ct(t,n){this.x=t||0,this.y=n||0}Object.assign(st.prototype,{isBox3:!0,set:function(t,n){return this.min.copy(t),this.max.copy(n),this},setFromArray:function(t){for(var n=1/0,e=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0,s=0,h=t.length;s<h;s+=3){var l=t[s],c=t[s+1],u=t[s+2];l<n&&(n=l),c<e&&(e=c),u<i&&(i=u),r<l&&(r=l),a<c&&(a=c),o<u&&(o=u)}return this.min.set(n,e,i),this.max.set(r,a,o),this},setFromBufferAttribute:function(t){for(var n=1/0,e=1/0,i=1/0,r=-1/0,a=-1/0,o=-1/0,s=0,h=t.count;s<h;s++){var l=t.getX(s),c=t.getY(s),u=t.getZ(s);l<n&&(n=l),c<e&&(e=c),u<i&&(i=u),r<l&&(r=l),a<c&&(a=c),o<u&&(o=u)}return this.min.set(n,e,i),this.max.set(r,a,o),this},setFromPoints:function(t){this.makeEmpty();for(var n=0,e=t.length;n<e;n++)this.expandByPoint(t[n]);return this},setFromCenterAndSize:function(t,n){n=Z.copy(n).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this},setFromObject:function(t){return this.makeEmpty(),this.expandByObject(t)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){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:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(t){return void 0===t&&(console.warn("THREE.Box3: .getCenter() target is now required"),t=new Q),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(t){return void 0===t&&(console.warn("THREE.Box3: .getSize() target is now required"),t=new Q),this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},expandByObject:function(t){t.updateWorldMatrix(!1,!1);var n=t.geometry;void 0!==n&&(null===n.boundingBox&&n.computeBoundingBox(),q.copy(n.boundingBox),q.applyMatrix4(t.matrixWorld),this.union(q));for(var e=t.children,i=0,r=e.length;i<r;i++)this.expandByObject(e[i]);return this},containsPoint:function(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:function(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:function(t,n){return void 0===n&&(console.warn("THREE.Box3: .getParameter() target is now required"),n=new Q),n.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:function(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:function(t){return this.clampPoint(t.center,Z),Z.distanceToSquared(t.center)<=t.radius*t.radius},intersectsPlane:function(t){var n,e=0<t.normal.x?(n=t.normal.x*this.min.x,t.normal.x*this.max.x):(n=t.normal.x*this.max.x,t.normal.x*this.min.x);return 0<t.normal.y?(n+=t.normal.y*this.min.y,e+=t.normal.y*this.max.y):(n+=t.normal.y*this.max.y,e+=t.normal.y*this.min.y),0<t.normal.z?(n+=t.normal.z*this.min.z,e+=t.normal.z*this.max.z):(n+=t.normal.z*this.max.z,e+=t.normal.z*this.min.z),n<=-t.constant&&e>=-t.constant},intersectsTriangle:function(t){if(this.isEmpty())return!1;this.getCenter(it),rt.subVectors(this.max,it),K.subVectors(t.a,it),J.subVectors(t.b,it),$.subVectors(t.c,it),tt.subVectors(J,K),nt.subVectors($,J),et.subVectors(K,$);t=[0,-tt.z,tt.y,0,-nt.z,nt.y,0,-et.z,et.y,tt.z,0,-tt.x,nt.z,0,-nt.x,et.z,0,-et.x,-tt.y,tt.x,0,-nt.y,nt.x,0,-et.y,et.x,0];return!!ht(t,K,J,$,rt)&&(!!ht(t=[1,0,0,0,1,0,0,0,1],K,J,$,rt)&&(at.crossVectors(tt,nt),ht(t=[at.x,at.y,at.z],K,J,$,rt)))},clampPoint:function(t,n){return void 0===n&&(console.warn("THREE.Box3: .clampPoint() target is now required"),n=new Q),n.copy(t).clamp(this.min,this.max)},distanceToPoint:function(t){return Z.copy(t).clamp(this.min,this.max).sub(t).length()},getBoundingSphere:function(t){return void 0===t&&console.error("THREE.Box3: .getBoundingSphere() target is now required"),this.getCenter(t.center),t.radius=.5*this.getSize(Z).length(),t},intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:function(t){return this.isEmpty()||(W[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),W[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),W[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),W[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),W[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),W[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),W[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),W[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(W)),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}),Object.defineProperties(lt.prototype,{width:{get:function(){return this.z},set:function(t){this.z=t}},height:{get:function(){return this.w},set:function(t){this.w=t}}}),Object.assign(lt.prototype,{isVector4:!0,set:function(t,n,e,i){return this.x=t,this.y=n,this.z=e,this.w=i,this},setScalar:function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(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:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(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:function(t,n){return void 0!==n?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,n)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this.w=t.w+n.w,this},addScaledVector:function(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this.w+=t.w*n,this},sub:function(t,n){return void 0!==n?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,n)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subScalar:function(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this},subVectors:function(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this.w=t.w-n.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var n=this.x,e=this.y,i=this.z,r=this.w,t=t.elements;return this.x=t[0]*n+t[4]*e+t[8]*i+t[12]*r,this.y=t[1]*n+t[5]*e+t[9]*i+t[13]*r,this.z=t[2]*n+t[6]*e+t[10]*i+t[14]*r,this.w=t[3]*n+t[7]*e+t[11]*i+t[15]*r,this},divideScalar:function(t){return this.multiplyScalar(1/t)},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var n=Math.sqrt(1-t.w*t.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/n,this.y=t.y/n,this.z=t.z/n),this},setAxisAngleFromRotationMatrix:function(t){var n,e,i,r=t.elements,a=r[0],o=r[4],s=r[8],h=r[1],l=r[5],c=r[9],u=r[2],f=r[6],d=r[10];if(Math.abs(o-h)<.01&&Math.abs(s-u)<.01&&Math.abs(c-f)<.01){if(Math.abs(o+h)<.1&&Math.abs(s+u)<.1&&Math.abs(c+f)<.1&&Math.abs(a+l+d-3)<.1)return this.set(1,0,0,0),this;var v=Math.PI,m=(a+1)/2,p=(l+1)/2,g=(d+1)/2,_=(o+h)/4,t=(s+u)/4,r=(c+f)/4;return p<m&&g<m?i=m<.01?(n=0,e=.707106781):(e=_/(n=Math.sqrt(m)),t/n):g<p?i=p<.01?(e=0,n=.707106781):(n=_/(e=Math.sqrt(p)),r/e):g<.01?(e=n=.707106781,i=0):(n=t/(i=Math.sqrt(g)),e=r/i),this.set(n,e,i,v),this}v=Math.sqrt((f-c)*(f-c)+(s-u)*(s-u)+(h-o)*(h-o));return Math.abs(v)<.001&&(v=1),this.x=(f-c)/v,this.y=(s-u)/v,this.z=(h-o)/v,this.w=Math.acos((a+l+d-1)/2),this},min:function(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:function(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:function(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this.z=Math.max(t.z,Math.min(n.z,this.z)),this.w=Math.max(t.w,Math.min(n.w,this.w)),this},clampScalar:function(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this.z=Math.max(t,Math.min(n,this.z)),this.w=Math.max(t,Math.min(n,this.w)),this},clampLength:function(t,n){var e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))},floor:function(){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:function(){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:function(){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:function(){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:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this.w+=(t.w-this.w)*n,this},lerpVectors:function(t,n,e){return this.subVectors(n,t).multiplyScalar(e).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,n){return this.x=t[n=void 0===n?0:n],this.y=t[n+1],this.z=t[n+2],this.w=t[n+3],this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.x,t[n+1]=this.y,t[n+2]=this.z,t[n+3]=this.w,t},fromBufferAttribute:function(t,n,e){return void 0!==e&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(n),this.y=t.getY(n),this.z=t.getZ(n),this.w=t.getW(n),this}}),Object.defineProperties(ct.prototype,{width:{get:function(){return this.x},set:function(t){this.x=t}},height:{get:function(){return this.y},set:function(t){this.y=t}}}),Object.assign(ct.prototype,{isVector2:!0,set:function(t,n){return this.x=t,this.y=n,this},setScalar:function(t){return this.x=t,this.y=t,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,n){switch(t){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+t)}return this},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,n){return void 0!==n?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,n)):(this.x+=t.x,this.y+=t.y,this)},addScalar:function(t){return this.x+=t,this.y+=t,this},addVectors:function(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this},addScaledVector:function(t,n){return this.x+=t.x*n,this.y+=t.y*n,this},sub:function(t,n){return void 0!==n?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,n)):(this.x-=t.x,this.y-=t.y,this)},subScalar:function(t){return this.x-=t,this.y-=t,this},subVectors:function(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){return this.multiplyScalar(1/t)},applyMatrix3:function(t){var n=this.x,e=this.y,t=t.elements;return this.x=t[0]*n+t[3]*e+t[6],this.y=t[1]*n+t[4]*e+t[7],this},min:function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},max:function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},clamp:function(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this},clampScalar:function(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this},clampLength:function(t,n){var e=this.length();return this.divideScalar(e||1).multiplyScalar(Math.max(t,Math.min(n,e)))},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){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:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},cross:function(t){return this.x*t.y-this.y*t.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){return Math.atan2(-this.y,-this.x)+Math.PI},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var n=this.x-t.x,t=this.y-t.y;return n*n+t*t},manhattanDistanceTo:function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},setLength:function(t){return this.normalize().multiplyScalar(t)},lerp:function(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this},lerpVectors:function(t,n,e){return this.subVectors(n,t).multiplyScalar(e).add(t)},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,n){return this.x=t[n=void 0===n?0:n],this.y=t[n+1],this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.x,t[n+1]=this.y,t},fromBufferAttribute:function(t,n,e){return void 0!==e&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=t.getX(n),this.y=t.getY(n),this},rotateAround:function(t,n){var e=Math.cos(n),i=Math.sin(n),r=this.x-t.x,n=this.y-t.y;return this.x=r*e-n*i+t.x,this.y=r*i+n*e+t.y,this}});var ut=new Q;function ft(t,n,e){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="",this.array=t,this.itemSize=n,this.count=void 0!==t?t.length/n:0,this.normalized=!0===e,this.usage=F,this.updateRange={offset:0,count:-1},this.version=0}function dt(t,n,e){ft.call(this,new Int8Array(t),n,e)}function vt(t,n,e){ft.call(this,new Uint8Array(t),n,e)}function mt(t,n,e){ft.call(this,new Uint8ClampedArray(t),n,e)}function pt(t,n,e){ft.call(this,new Int16Array(t),n,e)}function gt(t,n,e){ft.call(this,new Uint16Array(t),n,e)}function _t(t,n,e){ft.call(this,new Int32Array(t),n,e)}function xt(t,n,e){ft.call(this,new Uint32Array(t),n,e)}function At(t,n,e){ft.call(this,new Float32Array(t),n,e)}function wt(t,n,e){ft.call(this,new Float64Array(t),n,e)}Object.defineProperty(ft.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(ft.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(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:function(t,n,e){t*=this.itemSize,e*=n.itemSize;for(var i=0,r=this.itemSize;i<r;i++)this.array[t+i]=n.array[e+i];return this},copyArray:function(t){return this.array.set(t),this},copyColorsArray:function(t){for(var n=this.array,e=0,i=0,r=t.length;i<r;i++){var a=t[i];void 0===a&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",i),a=new X),n[e++]=a.r,n[e++]=a.g,n[e++]=a.b}return this},copyVector2sArray:function(t){for(var n=this.array,e=0,i=0,r=t.length;i<r;i++){var a=t[i];void 0===a&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",i),a=new ct),n[e++]=a.x,n[e++]=a.y}return this},copyVector3sArray:function(t){for(var n=this.array,e=0,i=0,r=t.length;i<r;i++){var a=t[i];void 0===a&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",i),a=new Q),n[e++]=a.x,n[e++]=a.y,n[e++]=a.z}return this},copyVector4sArray:function(t){for(var n=this.array,e=0,i=0,r=t.length;i<r;i++){var a=t[i];void 0===a&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",i),a=new lt),n[e++]=a.x,n[e++]=a.y,n[e++]=a.z,n[e++]=a.w}return this},applyMatrix3:function(t){for(var n=0,e=this.count;n<e;n++)ut.x=this.getX(n),ut.y=this.getY(n),ut.z=this.getZ(n),ut.applyMatrix3(t),this.setXYZ(n,ut.x,ut.y,ut.z);return this},applyMatrix4:function(t){for(var n=0,e=this.count;n<e;n++)ut.x=this.getX(n),ut.y=this.getY(n),ut.z=this.getZ(n),ut.applyMatrix4(t),this.setXYZ(n,ut.x,ut.y,ut.z);return this},applyNormalMatrix:function(t){for(var n=0,e=this.count;n<e;n++)ut.x=this.getX(n),ut.y=this.getY(n),ut.z=this.getZ(n),ut.applyNormalMatrix(t),this.setXYZ(n,ut.x,ut.y,ut.z);return this},transformDirection:function(t){for(var n=0,e=this.count;n<e;n++)ut.x=this.getX(n),ut.y=this.getY(n),ut.z=this.getZ(n),ut.transformDirection(t),this.setXYZ(n,ut.x,ut.y,ut.z);return this},set:function(t,n){return this.array.set(t,n=void 0===n?0:n),this},getX:function(t){return this.array[t*this.itemSize]},setX:function(t,n){return this.array[t*this.itemSize]=n,this},getY:function(t){return this.array[t*this.itemSize+1]},setY:function(t,n){return this.array[t*this.itemSize+1]=n,this},getZ:function(t){return this.array[t*this.itemSize+2]},setZ:function(t,n){return this.array[t*this.itemSize+2]=n,this},getW:function(t){return this.array[t*this.itemSize+3]},setW:function(t,n){return this.array[t*this.itemSize+3]=n,this},setXY:function(t,n,e){return t*=this.itemSize,this.array[t+0]=n,this.array[t+1]=e,this},setXYZ:function(t,n,e,i){return t*=this.itemSize,this.array[t+0]=n,this.array[t+1]=e,this.array[t+2]=i,this},setXYZW:function(t,n,e,i,r){return t*=this.itemSize,this.array[t+0]=n,this.array[t+1]=e,this.array[t+2]=i,this.array[t+3]=r,this},onUpload:function(t){return this.onUploadCallback=t,this},clone:function(){return new this.constructor(this.array,this.itemSize).copy(this)}}),(dt.prototype=Object.create(ft.prototype)).constructor=dt,(vt.prototype=Object.create(ft.prototype)).constructor=vt,(mt.prototype=Object.create(ft.prototype)).constructor=mt,(pt.prototype=Object.create(ft.prototype)).constructor=pt,gt.prototype=Object.create(ft.prototype),gt.prototype.constructor=gt,(_t.prototype=Object.create(ft.prototype)).constructor=_t,xt.prototype=Object.create(ft.prototype),xt.prototype.constructor=xt,(At.prototype=Object.create(ft.prototype)).constructor=At,(wt.prototype=Object.create(ft.prototype)).constructor=wt;var yt=new st;function St(t,n){this.center=void 0!==t?t:new Q,this.radius=void 0!==n?n:0}function bt(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}Object.assign(St.prototype,{set:function(t,n){return this.center.copy(t),this.radius=n,this},setFromPoints:function(t,n){var e=this.center;void 0!==n?e.copy(n):yt.setFromPoints(t).getCenter(e);for(var i=0,r=0,a=t.length;r<a;r++)i=Math.max(i,e.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.center.copy(t.center),this.radius=t.radius,this},empty:function(){return this.radius<=0},containsPoint:function(t){return t.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(t){return t.distanceTo(this.center)-this.radius},intersectsSphere:function(t){var n=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=n*n},intersectsBox:function(t){return t.intersectsSphere(this)},intersectsPlane:function(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius},clampPoint:function(t,n){var e=this.center.distanceToSquared(t);return void 0===n&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),n=new Q),n.copy(t),e>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(t){return void 0===t&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),t=new st),t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius}}),Object.assign(bt.prototype,{computeGroups:function(t){for(var n,e=[],i=void 0,r=t.faces,a=0;a<r.length;a++){var o=r[a];o.materialIndex!==i&&(i=o.materialIndex,void 0!==n&&(n.count=3*a-n.start,e.push(n)),n={start:3*a,materialIndex:i})}void 0!==n&&(n.count=3*a-n.start,e.push(n)),this.groups=e},fromGeometry:function(t){var n=t.faces,e=t.vertices,i=t.faceVertexUvs,r=i[0]&&0<i[0].length,a=i[1]&&0<i[1].length,o=t.morphTargets,s=o.length;if(0<s){for(var h=[],l=0;l<s;l++)h[l]={name:o[l].name,data:[]};this.morphTargets.position=h}var c=t.morphNormals,u=c.length;if(0<u){for(var f=[],l=0;l<u;l++)f[l]={name:c[l].name,data:[]};this.morphTargets.normal=f}var d=t.skinIndices,v=t.skinWeights,m=d.length===e.length,p=v.length===e.length;0<e.length&&0===n.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(l=0;l<n.length;l++){var g=n[l];this.vertices.push(e[g.a],e[g.b],e[g.c]);var _=g.vertexNormals;3===_.length?this.normals.push(_[0],_[1],_[2]):(A=g.normal,this.normals.push(A,A,A));var x,A=g.vertexColors;3===A.length?this.colors.push(A[0],A[1],A[2]):(A=g.color,this.colors.push(A,A,A)),!0===r&&(void 0!==(x=i[0][l])?this.uvs.push(x[0],x[1],x[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",l),this.uvs.push(new ct,new ct,new ct))),!0===a&&(void 0!==(x=i[1][l])?this.uvs2.push(x[0],x[1],x[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",l),this.uvs2.push(new ct,new ct,new ct)));for(var w=0;w<s;w++){var y=o[w].vertices;h[w].data.push(y[g.a],y[g.b],y[g.c])}for(w=0;w<u;w++){var S=c[w].vertexNormals[l];f[w].data.push(S.a,S.b,S.c)}m&&this.skinIndices.push(d[g.a],d[g.b],d[g.c]),p&&this.skinWeights.push(v[g.a],v[g.b],v[g.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this}});var Mt=new Q,Tt=new Dt,Lt=new Q(0,0,0),Et=new Q(1,1,1),Pt=new Q,Ft=new Q,Nt=new Q;function Dt(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}Object.assign(Dt.prototype,{isMatrix4:!0,set:function(t,n,e,i,r,a,o,s,h,l,c,u,f,d,v,m){var p=this.elements;return p[0]=t,p[4]=n,p[8]=e,p[12]=i,p[1]=r,p[5]=a,p[9]=o,p[13]=s,p[2]=h,p[6]=l,p[10]=c,p[14]=u,p[3]=f,p[7]=d,p[11]=v,p[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new Dt).fromArray(this.elements)},copy:function(t){var n=this.elements,t=t.elements;return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],this},copyPosition:function(t){var n=this.elements,t=t.elements;return n[12]=t[12],n[13]=t[13],n[14]=t[14],this},extractBasis:function(t,n,e){return t.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),e.setFromMatrixColumn(this,2),this},makeBasis:function(t,n,e){return this.set(t.x,n.x,e.x,0,t.y,n.y,e.y,0,t.z,n.z,e.z,0,0,0,0,1),this},extractRotation:function(t){var n=this.elements,e=t.elements,i=1/Mt.setFromMatrixColumn(t,0).length(),r=1/Mt.setFromMatrixColumn(t,1).length(),t=1/Mt.setFromMatrixColumn(t,2).length();return n[0]=e[0]*i,n[1]=e[1]*i,n[2]=e[2]*i,n[3]=0,n[4]=e[4]*r,n[5]=e[5]*r,n[6]=e[6]*r,n[7]=0,n[8]=e[8]*t,n[9]=e[9]*t,n[10]=e[10]*t,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this},makeRotationFromEuler:function(t){t&&t.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var n,e,i,r,a,o,s,h,l,c,u,f,d=this.elements,v=t.x,m=t.y,p=t.z,g=Math.cos(v),_=Math.sin(v),x=Math.cos(m),v=Math.sin(m),m=Math.cos(p),p=Math.sin(p);return"XYZ"===t.order?(a=g*m,o=g*p,s=_*m,h=_*p,d[0]=x*m,d[4]=-x*p,d[8]=v,d[1]=o+s*v,d[5]=a-h*v,d[9]=-_*x,d[2]=h-a*v,d[6]=s+o*v,d[10]=g*x):"YXZ"===t.order?(e=x*p,i=v*m,d[0]=(n=x*m)+(r=v*p)*_,d[4]=i*_-e,d[8]=g*v,d[1]=g*p,d[5]=g*m,d[9]=-_,d[2]=e*_-i,d[6]=r+n*_,d[10]=g*x):"ZXY"===t.order?(e=x*p,i=v*m,d[0]=(n=x*m)-(r=v*p)*_,d[4]=-g*p,d[8]=i+e*_,d[1]=e+i*_,d[5]=g*m,d[9]=r-n*_,d[2]=-g*v,d[6]=_,d[10]=g*x):"ZYX"===t.order?(a=g*m,o=g*p,s=_*m,h=_*p,d[0]=x*m,d[4]=s*v-o,d[8]=a*v+h,d[1]=x*p,d[5]=h*v+a,d[9]=o*v-s,d[2]=-v,d[6]=_*x,d[10]=g*x):"YZX"===t.order?(l=g*x,c=g*v,u=_*x,f=_*v,d[0]=x*m,d[4]=f-l*p,d[8]=u*p+c,d[1]=p,d[5]=g*m,d[9]=-_*m,d[2]=-v*m,d[6]=c*p+u,d[10]=l-f*p):"XZY"===t.order&&(l=g*x,c=g*v,u=_*x,f=_*v,d[0]=x*m,d[4]=-p,d[8]=v*m,d[1]=l*p+f,d[5]=g*m,d[9]=c*p-u,d[2]=u*p-c,d[6]=_*m,d[10]=f*p+l),d[3]=0,d[7]=0,d[11]=0,d[12]=0,d[13]=0,d[14]=0,d[15]=1,this},makeRotationFromQuaternion:function(t){return this.compose(Lt,t,Et)},lookAt:function(t,n,e){var i=this.elements;return Nt.subVectors(t,n),0===Nt.lengthSq()&&(Nt.z=1),Nt.normalize(),Pt.crossVectors(e,Nt),0===Pt.lengthSq()&&(1===Math.abs(e.z)?Nt.x+=1e-4:Nt.z+=1e-4,Nt.normalize(),Pt.crossVectors(e,Nt)),Pt.normalize(),Ft.crossVectors(Nt,Pt),i[0]=Pt.x,i[4]=Ft.x,i[8]=Nt.x,i[1]=Pt.y,i[5]=Ft.y,i[9]=Nt.y,i[2]=Pt.z,i[6]=Ft.z,i[10]=Nt.z,this},multiply:function(t,n){return void 0!==n?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,n)):this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,n){var e=t.elements,i=n.elements,r=this.elements,a=e[0],o=e[4],s=e[8],h=e[12],l=e[1],c=e[5],u=e[9],f=e[13],d=e[2],v=e[6],m=e[10],p=e[14],g=e[3],_=e[7],x=e[11],A=e[15],w=i[0],y=i[4],S=i[8],b=i[12],M=i[1],T=i[5],L=i[9],E=i[13],P=i[2],F=i[6],N=i[10],D=i[14],t=i[3],n=i[7],e=i[11],i=i[15];return r[0]=a*w+o*M+s*P+h*t,r[4]=a*y+o*T+s*F+h*n,r[8]=a*S+o*L+s*N+h*e,r[12]=a*b+o*E+s*D+h*i,r[1]=l*w+c*M+u*P+f*t,r[5]=l*y+c*T+u*F+f*n,r[9]=l*S+c*L+u*N+f*e,r[13]=l*b+c*E+u*D+f*i,r[2]=d*w+v*M+m*P+p*t,r[6]=d*y+v*T+m*F+p*n,r[10]=d*S+v*L+m*N+p*e,r[14]=d*b+v*E+m*D+p*i,r[3]=g*w+_*M+x*P+A*t,r[7]=g*y+_*T+x*F+A*n,r[11]=g*S+_*L+x*N+A*e,r[15]=g*b+_*E+x*D+A*i,this},multiplyScalar:function(t){var n=this.elements;return n[0]*=t,n[4]*=t,n[8]*=t,n[12]*=t,n[1]*=t,n[5]*=t,n[9]*=t,n[13]*=t,n[2]*=t,n[6]*=t,n[10]*=t,n[14]*=t,n[3]*=t,n[7]*=t,n[11]*=t,n[15]*=t,this},determinant:function(){var t=this.elements,n=t[0],e=t[4],i=t[8],r=t[12],a=t[1],o=t[5],s=t[9],h=t[13],l=t[2],c=t[6],u=t[10],f=t[14];return t[3]*(+r*s*c-i*h*c-r*o*u+e*h*u+i*o*f-e*s*f)+t[7]*(+n*s*f-n*h*u+r*a*u-i*a*f+i*h*l-r*s*l)+t[11]*(+n*h*c-n*o*f-r*a*c+e*a*f+r*o*l-e*h*l)+t[15]*(-i*o*l-n*s*c+n*o*u+i*a*c-e*a*u+e*s*l)},transpose:function(){var t=this.elements,n=t[1];return t[1]=t[4],t[4]=n,n=t[2],t[2]=t[8],t[8]=n,n=t[6],t[6]=t[9],t[9]=n,n=t[3],t[3]=t[12],t[12]=n,n=t[7],t[7]=t[13],t[13]=n,n=t[11],t[11]=t[14],t[14]=n,this},setPosition:function(t,n,e){var i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=n,i[14]=e),this},getInverse:function(t,n){void 0!==n&&console.warn("THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.");var e=this.elements,i=t.elements,r=i[0],a=i[1],o=i[2],s=i[3],h=i[4],l=i[5],c=i[6],u=i[7],f=i[8],d=i[9],v=i[10],m=i[11],p=i[12],g=i[13],_=i[14],x=i[15],A=d*_*u-g*v*u+g*c*m-l*_*m-d*c*x+l*v*x,w=p*v*u-f*_*u-p*c*m+h*_*m+f*c*x-h*v*x,n=f*g*u-p*d*u+p*l*m-h*g*m-f*l*x+h*d*x,t=p*d*c-f*g*c-p*l*v+h*g*v+f*l*_-h*d*_,i=r*A+a*w+o*n+s*t;if(0==i)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);i=1/i;return e[0]=A*i,e[1]=(g*v*s-d*_*s-g*o*m+a*_*m+d*o*x-a*v*x)*i,e[2]=(l*_*s-g*c*s+g*o*u-a*_*u-l*o*x+a*c*x)*i,e[3]=(d*c*s-l*v*s-d*o*u+a*v*u+l*o*m-a*c*m)*i,e[4]=w*i,e[5]=(f*_*s-p*v*s+p*o*m-r*_*m-f*o*x+r*v*x)*i,e[6]=(p*c*s-h*_*s-p*o*u+r*_*u+h*o*x-r*c*x)*i,e[7]=(h*v*s-f*c*s+f*o*u-r*v*u-h*o*m+r*c*m)*i,e[8]=n*i,e[9]=(p*d*s-f*g*s-p*a*m+r*g*m+f*a*x-r*d*x)*i,e[10]=(h*g*s-p*l*s+p*a*u-r*g*u-h*a*x+r*l*x)*i,e[11]=(f*l*s-h*d*s-f*a*u+r*d*u+h*a*m-r*l*m)*i,e[12]=t*i,e[13]=(f*g*o-p*d*o+p*a*v-r*g*v-f*a*_+r*d*_)*i,e[14]=(p*l*o-h*g*o-p*a*c+r*g*c+h*a*_-r*l*_)*i,e[15]=(h*d*o-f*l*o+f*a*c-r*d*c-h*a*v+r*l*v)*i,this},scale:function(t){var n=this.elements,e=t.x,i=t.y,t=t.z;return n[0]*=e,n[4]*=i,n[8]*=t,n[1]*=e,n[5]*=i,n[9]*=t,n[2]*=e,n[6]*=i,n[10]*=t,n[3]*=e,n[7]*=i,n[11]*=t,this},getMaxScaleOnAxis:function(){var t=this.elements,n=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],e=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],t=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(n,e,t))},makeTranslation:function(t,n,e){return this.set(1,0,0,t,0,1,0,n,0,0,1,e,0,0,0,1),this},makeRotationX:function(t){var n=Math.cos(t),t=Math.sin(t);return this.set(1,0,0,0,0,n,-t,0,0,t,n,0,0,0,0,1),this},makeRotationY:function(t){var n=Math.cos(t),t=Math.sin(t);return this.set(n,0,t,0,0,1,0,0,-t,0,n,0,0,0,0,1),this},makeRotationZ:function(t){var n=Math.cos(t),t=Math.sin(t);return this.set(n,-t,0,0,t,n,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(t,n){var e=Math.cos(n),i=Math.sin(n),r=1-e,a=t.x,o=t.y,s=t.z,n=r*a,t=r*o;return this.set(n*a+e,n*o-i*s,n*s+i*o,0,n*o+i*s,t*o+e,t*s-i*a,0,n*s-i*o,t*s+i*a,r*s*s+e,0,0,0,0,1),this},makeScale:function(t,n,e){return this.set(t,0,0,0,0,n,0,0,0,0,e,0,0,0,0,1),this},makeShear:function(t,n,e){return this.set(1,n,e,0,t,1,e,0,t,n,1,0,0,0,0,1),this},compose:function(t,n,e){var i=this.elements,r=n.u,a=n.f,o=n.v,s=n._,h=r+r,l=a+a,c=o+o,u=r*h,f=r*l,d=r*c,n=a*l,r=a*c,a=o*c,o=s*h,h=s*l,l=s*c,s=e.x,c=e.y,e=e.z;return i[0]=(1-(n+a))*s,i[1]=(f+l)*s,i[2]=(d-h)*s,i[3]=0,i[4]=(f-l)*c,i[5]=(1-(u+a))*c,i[6]=(r+o)*c,i[7]=0,i[8]=(d+h)*e,i[9]=(r-o)*e,i[10]=(1-(u+n))*e,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this},decompose:function(t,n,e){var i=this.elements,r=Mt.set(i[0],i[1],i[2]).length(),a=Mt.set(i[4],i[5],i[6]).length(),o=Mt.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),t.x=i[12],t.y=i[13],t.z=i[14],Tt.copy(this);var s=1/r,t=1/a,i=1/o;return Tt.elements[0]*=s,Tt.elements[1]*=s,Tt.elements[2]*=s,Tt.elements[4]*=t,Tt.elements[5]*=t,Tt.elements[6]*=t,Tt.elements[8]*=i,Tt.elements[9]*=i,Tt.elements[10]*=i,n.setFromRotationMatrix(Tt),e.x=r,e.y=a,e.z=o,this},makePerspective:function(t,n,e,i,r,a){void 0===a&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");var o=this.elements,s=2*r/(e-i),h=(n+t)/(n-t),e=(e+i)/(e-i),i=-(a+r)/(a-r),a=-2*a*r/(a-r);return o[0]=2*r/(n-t),o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=s,o[9]=e,o[13]=0,o[2]=0,o[6]=0,o[10]=i,o[14]=a,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this},makeOrthographic:function(t,n,e,i,r,a){var o=this.elements,s=1/(n-t),h=1/(e-i),l=1/(a-r),t=(n+t)*s,i=(e+i)*h,r=(a+r)*l;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-t,o[1]=0,o[5]=2*h,o[9]=0,o[13]=-i,o[2]=0,o[6]=0,o[10]=-2*l,o[14]=-r,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this},equals:function(t){for(var n=this.elements,e=t.elements,i=0;i<16;i++)if(n[i]!==e[i])return!1;return!0},fromArray:function(t,n){void 0===n&&(n=0);for(var e=0;e<16;e++)this.elements[e]=t[e+n];return this},toArray:function(t,n){var e=this.elements;return(t=void 0===t?[]:t)[n=void 0===n?0:n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8],t[n+9]=e[9],t[n+10]=e[10],t[n+11]=e[11],t[n+12]=e[12],t[n+13]=e[13],t[n+14]=e[14],t[n+15]=e[15],t}});var Ct=new Dt,Rt=new V;function It(t,n,e,i){this.u=t||0,this.f=n||0,this.v=e||0,this.M=i||It.DefaultOrder}function Ot(){this.mask=1}function Ut(){this.elements=[1,0,0,0,1,0,0,0,1],0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}It.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],It.DefaultOrder="XYZ",Object.defineProperties(It.prototype,{x:{get:function(){return this.u},set:function(t){this.u=t,this.A()}},y:{get:function(){return this.f},set:function(t){this.f=t,this.A()}},z:{get:function(){return this.v},set:function(t){this.v=t,this.A()}},order:{get:function(){return this.M},set:function(t){this.M=t,this.A()}}}),Object.assign(It.prototype,{isEuler:!0,set:function(t,n,e,i){return this.u=t,this.f=n,this.v=e,this.M=i||this.M,this.A(),this},clone:function(){return new this.constructor(this.u,this.f,this.v,this.M)},copy:function(t){return this.u=t.u,this.f=t.f,this.v=t.v,this.M=t.M,this.A(),this},setFromRotationMatrix:function(t,n,e){var i=C.clamp,r=t.elements,a=r[0],o=r[4],s=r[8],h=r[1],l=r[5],c=r[9],u=r[2],t=r[6],r=r[10];return"XYZ"===(n=n||this.M)?(this.f=Math.asin(i(s,-1,1)),Math.abs(s)<.9999999?(this.u=Math.atan2(-c,r),this.v=Math.atan2(-o,a)):(this.u=Math.atan2(t,l),this.v=0)):"YXZ"===n?(this.u=Math.asin(-i(c,-1,1)),Math.abs(c)<.9999999?(this.f=Math.atan2(s,r),this.v=Math.atan2(h,l)):(this.f=Math.atan2(-u,a),this.v=0)):"ZXY"===n?(this.u=Math.asin(i(t,-1,1)),Math.abs(t)<.9999999?(this.f=Math.atan2(-u,r),this.v=Math.atan2(-o,l)):(this.f=0,this.v=Math.atan2(h,a))):"ZYX"===n?(this.f=Math.asin(-i(u,-1,1)),Math.abs(u)<.9999999?(this.u=Math.atan2(t,r),this.v=Math.atan2(h,a)):(this.u=0,this.v=Math.atan2(-o,l))):"YZX"===n?(this.v=Math.asin(i(h,-1,1)),Math.abs(h)<.9999999?(this.u=Math.atan2(-c,l),this.f=Math.atan2(-u,a)):(this.u=0,this.f=Math.atan2(s,r))):"XZY"===n?(this.v=Math.asin(-i(o,-1,1)),Math.abs(o)<.9999999?(this.u=Math.atan2(t,l),this.f=Math.atan2(s,a)):(this.u=Math.atan2(-c,r),this.f=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+n),this.M=n,!1!==e&&this.A(),this},setFromQuaternion:function(t,n,e){return Ct.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Ct,n,e)},setFromVector3:function(t,n){return this.set(t.x,t.y,t.z,n||this.M)},reorder:function(t){return Rt.setFromEuler(this),this.setFromQuaternion(Rt,t)},equals:function(t){return t.u===this.u&&t.f===this.f&&t.v===this.v&&t.M===this.M},fromArray:function(t){return this.u=t[0],this.f=t[1],this.v=t[2],void 0!==t[3]&&(this.M=t[3]),this.A(),this},toArray:function(t,n){return(t=void 0===t?[]:t)[n=void 0===n?0:n]=this.u,t[n+1]=this.f,t[n+2]=this.v,t[n+3]=this.M,t},toVector3:function(t){return t?t.set(this.u,this.f,this.v):new Q(this.u,this.f,this.v)},S:function(t){return this.A=t,this},A:function(){}}),Object.assign(Ot.prototype,{set:function(t){this.mask=1<<t|0},enable:function(t){this.mask|=1<<t|0},enableAll:function(){this.mask=-1},toggle:function(t){this.mask^=1<<t|0},disable:function(t){this.mask&=~(1<<t|0)},disableAll:function(){this.mask=0},test:function(t){return 0!=(this.mask&t.mask)}}),Object.assign(Ut.prototype,{isMatrix3:!0,set:function(t,n,e,i,r,a,o,s,h){var l=this.elements;return l[0]=t,l[1]=i,l[2]=o,l[3]=n,l[4]=r,l[5]=s,l[6]=e,l[7]=a,l[8]=h,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(t){var n=this.elements,t=t.elements;return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],this},extractBasis:function(t,n,e){return t.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),e.setFromMatrix3Column(this,2),this},setFromMatrix4:function(t){t=t.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this},multiply:function(t){return this.multiplyMatrices(this,t)},premultiply:function(t){return this.multiplyMatrices(t,this)},multiplyMatrices:function(t,n){var e=t.elements,i=n.elements,r=this.elements,a=e[0],o=e[3],s=e[6],h=e[1],l=e[4],c=e[7],u=e[2],f=e[5],d=e[8],v=i[0],m=i[3],p=i[6],g=i[1],_=i[4],t=i[7],n=i[2],e=i[5],i=i[8];return r[0]=a*v+o*g+s*n,r[3]=a*m+o*_+s*e,r[6]=a*p+o*t+s*i,r[1]=h*v+l*g+c*n,r[4]=h*m+l*_+c*e,r[7]=h*p+l*t+c*i,r[2]=u*v+f*g+d*n,r[5]=u*m+f*_+d*e,r[8]=u*p+f*t+d*i,this},multiplyScalar:function(t){var n=this.elements;return n[0]*=t,n[3]*=t,n[6]*=t,n[1]*=t,n[4]*=t,n[7]*=t,n[2]*=t,n[5]*=t,n[8]*=t,this},determinant:function(){var t=this.elements,n=t[0],e=t[1],i=t[2],r=t[3],a=t[4],o=t[5],s=t[6],h=t[7],t=t[8];return n*a*t-n*o*h-e*r*t+e*o*s+i*r*h-i*a*s},getInverse:function(t,n){void 0!==n&&console.warn("THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.");var e=t.elements,i=this.elements,r=e[0],a=e[1],o=e[2],s=e[3],h=e[4],l=e[5],c=e[6],u=e[7],f=e[8],d=f*h-l*u,n=l*c-f*s,t=u*s-h*c,e=r*d+a*n+o*t;if(0==e)return this.set(0,0,0,0,0,0,0,0,0);e=1/e;return i[0]=d*e,i[1]=(o*u-f*a)*e,i[2]=(l*a-o*h)*e,i[3]=n*e,i[4]=(f*r-o*c)*e,i[5]=(o*s-l*r)*e,i[6]=t*e,i[7]=(a*c-u*r)*e,i[8]=(h*r-a*s)*e,this},transpose:function(){var t=this.elements,n=t[1];return t[1]=t[3],t[3]=n,n=t[2],t[2]=t[6],t[6]=n,n=t[5],t[5]=t[7],t[7]=n,this},getNormalMatrix:function(t){return this.setFromMatrix4(t).getInverse(this).transpose()},transposeIntoArray:function(t){var n=this.elements;return t[0]=n[0],t[1]=n[3],t[2]=n[6],t[3]=n[1],t[4]=n[4],t[5]=n[7],t[6]=n[2],t[7]=n[5],t[8]=n[8],this},setUvTransform:function(t,n,e,i,r,a,o){var s=Math.cos(r),r=Math.sin(r);this.set(e*s,e*r,-e*(s*a+r*o)+a+t,-i*r,i*s,-i*(-r*a+s*o)+o+n,0,0,1)},scale:function(t,n){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=n,e[4]*=n,e[7]*=n,this},rotate:function(t){var n=Math.cos(t),e=Math.sin(t),i=this.elements,r=i[0],a=i[3],o=i[6],s=i[1],h=i[4],t=i[7];return i[0]=n*r+e*s,i[3]=n*a+e*h,i[6]=n*o+e*t,i[1]=-e*r+n*s,i[4]=-e*a+n*h,i[7]=-e*o+n*t,this},translate:function(t,n){var e=this.elements;return e[0]+=t*e[2],e[3]+=t*e[5],e[6]+=t*e[8],e[1]+=n*e[2],e[4]+=n*e[5],e[7]+=n*e[8],this},equals:function(t){for(var n=this.elements,e=t.elements,i=0;i<9;i++)if(n[i]!==e[i])return!1;return!0},fromArray:function(t,n){void 0===n&&(n=0);for(var e=0;e<9;e++)this.elements[e]=t[e+n];return this},toArray:function(t,n){var e=this.elements;return(t=void 0===t?[]:t)[n=void 0===n?0:n]=e[0],t[n+1]=e[1],t[n+2]=e[2],t[n+3]=e[3],t[n+4]=e[4],t[n+5]=e[5],t[n+6]=e[6],t[n+7]=e[7],t[n+8]=e[8],t}});var Ht=0,Xt=new Q,Gt=new V,zt=new Dt,Bt=new Q,kt=new Q,Vt=new Q,Yt=new V,jt=new Q(1,0,0),Qt=new Q(0,1,0),Wt=new Q(0,0,1),Zt={type:"added"},qt={type:"removed"};function Kt(){Object.defineProperty(this,"id",{value:Ht++}),this.uuid=C.generateUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Kt.DefaultUp.clone();var t=new Q,n=new It,e=new V,i=new Q(1,1,1);n.S(function(){e.setFromEuler(n,!1)}),e.S(function(){n.setFromQuaternion(e,void 0,!1)}),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:e},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Dt},normalMatrix:{value:new Ut}}),this.matrix=new Dt,this.matrixWorld=new Dt,this.matrixAutoUpdate=Kt.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new Ot,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={}}Kt.DefaultUp=new Q(0,1,0),Kt.DefaultMatrixAutoUpdate=!0,Kt.prototype=Object.assign(Object.create(i.prototype),{constructor:Kt,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix4:function(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(t){return this.quaternion.premultiply(t),this},setRotationFromAxisAngle:function(t,n){this.quaternion.setFromAxisAngle(t,n)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:function(t,n){return Gt.setFromAxisAngle(t,n),this.quaternion.multiply(Gt),this},rotateOnWorldAxis:function(t,n){return Gt.setFromAxisAngle(t,n),this.quaternion.premultiply(Gt),this},rotateX:function(t){return this.rotateOnAxis(jt,t)},rotateY:function(t){return this.rotateOnAxis(Qt,t)},rotateZ:function(t){return this.rotateOnAxis(Wt,t)},translateOnAxis:function(t,n){return Xt.copy(t).applyQuaternion(this.quaternion),this.position.add(Xt.multiplyScalar(n)),this},translateX:function(t){return this.translateOnAxis(jt,t)},translateY:function(t){return this.translateOnAxis(Qt,t)},translateZ:function(t){return this.translateOnAxis(Wt,t)},localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:function(t){return t.applyMatrix4(zt.getInverse(this.matrixWorld))},lookAt:function(t,n,e){t.isVector3?Bt.copy(t):Bt.set(t,n,e);e=this.parent;this.updateWorldMatrix(!0,!1),kt.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?zt.lookAt(kt,Bt,this.up):zt.lookAt(Bt,kt,this.up),this.quaternion.setFromRotationMatrix(zt),e&&(zt.extractRotation(e.matrixWorld),Gt.setFromRotationMatrix(zt),this.quaternion.premultiply(Gt.inverse()))},add:function(t){if(1<arguments.length){for(var n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return t===this?console.error("THREE.Object3D.add: object can't be added as a child of itself.",t):t&&t.isObject3D?(null!==t.parent&&t.parent.remove(t),(t.parent=this).children.push(t),t.dispatchEvent(Zt)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this},remove:function(t){if(1<arguments.length){for(var n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}var e=this.children.indexOf(t);return-1!==e&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(qt)),this},attach:function(t){return this.updateWorldMatrix(!0,!1),zt.getInverse(this.matrixWorld),null!==t.parent&&(t.parent.updateWorldMatrix(!0,!1),zt.multiply(t.parent.matrixWorld)),t.applyMatrix4(zt),t.updateWorldMatrix(!1,!1),this.add(t),this},getObjectById:function(t){return this.getObjectByProperty("id",t)},getObjectByName:function(t){return this.getObjectByProperty("name",t)},getObjectByProperty:function(t,n){if(this[t]===n)return this;for(var e=0,i=this.children.length;e<i;e++){var r=this.children[e].getObjectByProperty(t,n);if(void 0!==r)return r}},getWorldPosition:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),t=new Q),this.updateMatrixWorld(!0),t.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),t=new V),this.updateMatrixWorld(!0),this.matrixWorld.decompose(kt,t,Vt),t},getWorldScale:function(t){return void 0===t&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),t=new Q),this.updateMatrixWorld(!0),this.matrixWorld.decompose(kt,Yt,t),t},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),t=new Q),this.updateMatrixWorld(!0);var n=this.matrixWorld.elements;return t.set(n[8],n[9],n[10]).normalize()},raycast:function(){},traverse:function(t){t(this);for(var n=this.children,e=0,i=n.length;e<i;e++)n[e].traverse(t)},traverseVisible:function(t){if(!1!==this.visible){t(this);for(var n=this.children,e=0,i=n.length;e<i;e++)n[e].traverseVisible(t)}},traverseAncestors:function(t){var n=this.parent;null!==n&&(t(n),n.traverseAncestors(t))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t=!(this.matrixWorldNeedsUpdate=!1));for(var n=this.children,e=0,i=n.length;e<i;e++)n[e].updateMatrixWorld(t)},updateWorldMatrix:function(t,n){var e=this.parent;if(!0===t&&null!==e&&e.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===n)for(var i=this.children,r=0,a=i.length;r<a;r++)i[r].updateWorldMatrix(!1,!0)},clone:function(t){return(new this.constructor).copy(this,t)},copy:function(t,n){if(void 0===n&&(n=!0),this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),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.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===n)for(var e=0;e<t.children.length;e++){var i=t.children[e];this.add(i.clone())}return this}});var Jt=1,$t=new Dt,tn=new Kt,nn=new Q,en=new st,rn=new st,an=new Q;function on(){Object.defineProperty(this,"id",{value:Jt+=2}),this.uuid=C.generateUUID(),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={}}on.prototype=Object.assign(Object.create(i.prototype),{constructor:on,isBufferGeometry:!0,getIndex:function(){return this.index},setIndex:function(t){Array.isArray(t)?this.index=new(65535<function(t){if(0===t.length)return-1/0;for(var n=t[0],e=1,i=t.length;e<i;++e)t[e]>n&&(n=t[e]);return n}(t)?xt:gt)(t,1):this.index=t},getAttribute:function(t){return this.attributes[t]},setAttribute:function(t,n){return this.attributes[t]=n,this},deleteAttribute:function(t){return delete this.attributes[t],this},addGroup:function(t,n,e){this.groups.push({start:t,count:n,materialIndex:void 0!==e?e:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(t,n){this.drawRange.start=t,this.drawRange.count=n},applyMatrix4:function(t){var n=this.attributes.position;void 0!==n&&(n.applyMatrix4(t),n.needsUpdate=!0);var e=this.attributes.normal;void 0!==e&&(n=(new Ut).getNormalMatrix(t),e.applyNormalMatrix(n),e.needsUpdate=!0);e=this.attributes.tangent;return void 0!==e&&(e.transformDirection(t),e.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this},rotateX:function(t){return $t.makeRotationX(t),this.applyMatrix4($t),this},rotateY:function(t){return $t.makeRotationY(t),this.applyMatrix4($t),this},rotateZ:function(t){return $t.makeRotationZ(t),this.applyMatrix4($t),this},translate:function(t,n,e){return $t.makeTranslation(t,n,e),this.applyMatrix4($t),this},scale:function(t,n,e){return $t.makeScale(t,n,e),this.applyMatrix4($t),this},lookAt:function(t){return tn.lookAt(t),tn.updateMatrix(),this.applyMatrix4(tn.matrix),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(nn).negate(),this.translate(nn.x,nn.y,nn.z),this},setFromObject:function(t){var n,e,i=t.geometry;return t.isPoints||t.isLine?(n=new At(3*i.vertices.length,3),e=new At(3*i.colors.length,3),this.setAttribute("position",n.copyVector3sArray(i.vertices)),this.setAttribute("color",e.copyColorsArray(i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length&&(e=new At(i.lineDistances.length,1),this.setAttribute("lineDistance",e.copyArray(i.lineDistances))),null!==i.boundingSphere&&(this.boundingSphere=i.boundingSphere.clone()),null!==i.boundingBox&&(this.boundingBox=i.boundingBox.clone())):t.isMesh&&i&&i.isGeometry&&this.fromGeometry(i),this},setFromPoints:function(t){for(var n=[],e=0,i=t.length;e<i;e++){var r=t[e];n.push(r.x,r.y,r.z||0)}return this.setAttribute("position",new At(n,3)),this},updateFromObject:function(t){var n,e=t.geometry;if(t.isMesh){var i=e.T;if(!0===e.elementsNeedUpdate&&(i=void 0,e.elementsNeedUpdate=!1),void 0===i)return this.fromGeometry(e);i.verticesNeedUpdate=e.verticesNeedUpdate,i.normalsNeedUpdate=e.normalsNeedUpdate,i.colorsNeedUpdate=e.colorsNeedUpdate,i.uvsNeedUpdate=e.uvsNeedUpdate,i.groupsNeedUpdate=e.groupsNeedUpdate,e.verticesNeedUpdate=!1,e.normalsNeedUpdate=!1,e.colorsNeedUpdate=!1,e.uvsNeedUpdate=!1,e.groupsNeedUpdate=!1,e=i}return!0===e.verticesNeedUpdate&&(void 0!==(n=this.attributes.position)&&(n.copyVector3sArray(e.vertices),n.needsUpdate=!0),e.verticesNeedUpdate=!1),!0===e.normalsNeedUpdate&&(void 0!==(n=this.attributes.normal)&&(n.copyVector3sArray(e.normals),n.needsUpdate=!0),e.normalsNeedUpdate=!1),!0===e.colorsNeedUpdate&&(void 0!==(n=this.attributes.color)&&(n.copyColorsArray(e.colors),n.needsUpdate=!0),e.colorsNeedUpdate=!1),e.uvsNeedUpdate&&(void 0!==(n=this.attributes.uv)&&(n.copyVector2sArray(e.uvs),n.needsUpdate=!0),e.uvsNeedUpdate=!1),e.lineDistancesNeedUpdate&&(void 0!==(n=this.attributes.lineDistance)&&(n.copyArray(e.lineDistances),n.needsUpdate=!0),e.lineDistancesNeedUpdate=!1),e.groupsNeedUpdate&&(e.computeGroups(t.geometry),this.groups=e.groups,e.groupsNeedUpdate=!1),this},fromGeometry:function(t){return t.T=(new bt).fromGeometry(t),this.fromDirectGeometry(t.T)},fromDirectGeometry:function(t){var n,e,i,r,a=new Float32Array(3*t.vertices.length);for(i in this.setAttribute("position",new ft(a,3).copyVector3sArray(t.vertices)),0<t.normals.length&&(n=new Float32Array(3*t.normals.length),this.setAttribute("normal",new ft(n,3).copyVector3sArray(t.normals))),0<t.colors.length&&(n=new Float32Array(3*t.colors.length),this.setAttribute("color",new ft(n,3).copyColorsArray(t.colors))),0<t.uvs.length&&(e=new Float32Array(2*t.uvs.length),this.setAttribute("uv",new ft(e,2).copyVector2sArray(t.uvs))),0<t.uvs2.length&&(e=new Float32Array(2*t.uvs2.length),this.setAttribute("uv2",new ft(e,2).copyVector2sArray(t.uvs2))),this.groups=t.groups,t.morphTargets){for(var o=[],s=t.morphTargets[i],h=0,l=s.length;h<l;h++){var c=s[h],u=new At(3*c.data.length,3);u.name=c.name,o.push(u.copyVector3sArray(c.data))}this.morphAttributes[i]=o}return 0<t.skinIndices.length&&(r=new At(4*t.skinIndices.length,4),this.setAttribute("skinIndex",r.copyVector4sArray(t.skinIndices))),0<t.skinWeights.length&&(r=new At(4*t.skinWeights.length,4),this.setAttribute("skinWeight",r.copyVector4sArray(t.skinWeights))),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),this},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new St);var t=this.attributes.position,n=this.morphAttributes.position;if(t){var e=this.boundingSphere.center;if(en.setFromBufferAttribute(t),n)for(var i=0,r=n.length;i<r;i++){var a=n[i];rn.setFromBufferAttribute(a),this.morphTargetsRelative?(an.addVectors(en.min,rn.min),en.expandByPoint(an),an.addVectors(en.max,rn.max),en.expandByPoint(an)):(en.expandByPoint(rn.min),en.expandByPoint(rn.max))}en.getCenter(e);for(var o=0,i=0,r=t.count;i<r;i++)an.fromBufferAttribute(t,i),o=Math.max(o,e.distanceToSquared(an));if(n)for(i=0,r=n.length;i<r;i++)for(var a=n[i],s=this.morphTargetsRelative,h=0,l=a.count;h<l;h++)an.fromBufferAttribute(a,h),s&&(nn.fromBufferAttribute(t,h),an.add(nn)),o=Math.max(o,e.distanceToSquared(an));this.boundingSphere.radius=Math.sqrt(o),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}},computeFaceNormals:function(){},computeVertexNormals:function(){var t=this.index,n=this.attributes;if(n.position){var e=n.position.array;if(void 0===n.normal)this.setAttribute("normal",new ft(new Float32Array(e.length),3));else for(var i=n.normal.array,r=0,a=i.length;r<a;r++)i[r]=0;var o,s,h,l=n.normal.array,c=new Q,u=new Q,f=new Q,d=new Q,v=new Q;if(t)for(var m=t.array,r=0,a=t.count;r<a;r+=3)o=3*m[r+0],s=3*m[r+1],h=3*m[r+2],c.fromArray(e,o),u.fromArray(e,s),f.fromArray(e,h),d.subVectors(f,u),v.subVectors(c,u),d.cross(v),l[o]+=d.x,l[1+o]+=d.y,l[2+o]+=d.z,l[s]+=d.x,l[1+s]+=d.y,l[2+s]+=d.z,l[h]+=d.x,l[1+h]+=d.y,l[2+h]+=d.z;else for(r=0,a=e.length;r<a;r+=9)c.fromArray(e,r),u.fromArray(e,r+3),f.fromArray(e,r+6),d.subVectors(f,u),v.subVectors(c,u),d.cross(v),l[r]=d.x,l[r+1]=d.y,l[r+2]=d.z,l[r+3]=d.x,l[r+4]=d.y,l[r+5]=d.z,l[r+6]=d.x,l[r+7]=d.y,l[r+8]=d.z;this.normalizeNormals(),n.normal.needsUpdate=!0}},normalizeNormals:function(){for(var t=this.attributes.normal,n=0,e=t.count;n<e;n++)an.x=t.getX(n),an.y=t.getY(n),an.z=t.getZ(n),an.normalize(),t.setXYZ(n,an.x,an.y,an.z)},dispose:function(){this.dispatchEvent({type:"dispose"})}});var sn={enabled:!1,files:{},add:function(t,n){!1!==this.enabled&&(this.files[t]=n)},get:function(t){if(!1!==this.enabled)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};function hn(t,n,e){var i=this,r=!1,a=0,o=0,s=void 0,h=[];this.onStart=void 0,this.onLoad=t,this.onProgress=n,this.onError=e,this.itemStart=function(t){o++,!1===r&&void 0!==i.onStart&&i.onStart(t,a,o),r=!0},this.itemEnd=function(t){a++,void 0!==i.onProgress&&i.onProgress(t,a,o),a===o&&(r=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(t){void 0!==i.onError&&i.onError(t)},this.resolveURL=function(t){return s?s(t):t},this.setURLModifier=function(t){return s=t,this},this.addHandler=function(t,n){return h.push(t,n),this},this.removeHandler=function(t){t=h.indexOf(t);return-1!==t&&h.splice(t,2),this},this.getHandler=function(t){for(var n=0,e=h.length;n<e;n+=2){var i=h[n],r=h[n+1];if(i.global&&(i.lastIndex=0),i.test(t))return r}return null}}var ln=new hn,cn={};function un(t){Hn.call(this,t)}function fn(t){I.call(this),this.type="ShadowMaterial",this.color=new X(0),this.transparent=!0,this.setValues(t)}function dn(t){I.call(this),this.type="SpriteMaterial",this.color=new X(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.setValues(t)}function vn(t){var n,e={};for(n in t)for(var i in e[n]={},t[n]){var r=t[n][i];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture)?e[n][i]=r.clone():Array.isArray(r)?e[n][i]=r.slice():e[n][i]=r}return e}function mn(t){for(var n={},e=0;e<t.length;e++){var i,r=vn(t[e]);for(i in r)n[i]=r[i]}return n}un.prototype=Object.assign(Object.create(Hn.prototype),{constructor:un,load:function(o,t,n,e){void 0===o&&(o=""),void 0!==this.path&&(o=this.path+o),o=this.manager.resolveURL(o);var s=this,i=sn.get(o);if(void 0!==i)return s.manager.itemStart(o),setTimeout(function(){t&&t(i),s.manager.itemEnd(o)},0),i;if(void 0===cn[o]){var r=o.match(/^data:(.*?)(;base64)?,(.*)$/);if(r){var a=r[1],h=!!r[2],l=r[3],l=decodeURIComponent(l);h&&(l=atob(l));try{var c=(this.responseType||"").toLowerCase();switch(c){case"arraybuffer":case"blob":for(var u=new Uint8Array(l.length),f=0;f<l.length;f++)u[f]=l.charCodeAt(f);d="blob"===c?new Blob([u.buffer],{type:a}):u.buffer;break;case"document":var d=(new DOMParser).parseFromString(l,a);break;case"json":d=JSON.parse(l);break;default:d=l}setTimeout(function(){t&&t(d),s.manager.itemEnd(o)},0)}catch(t){setTimeout(function(){e&&e(t),s.manager.itemError(o),s.manager.itemEnd(o)},0)}}else{cn[o]=[],cn[o].push({onLoad:t,onProgress:n,onError:e});var v,m=new XMLHttpRequest;for(v in m.open("GET",o,!0),m.addEventListener("load",function(t){var n=this.response,e=cn[o];if(delete cn[o],200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),sn.add(o,n);for(var i=0,r=e.length;i<r;i++)(a=e[i]).onLoad&&a.onLoad(n);s.manager.itemEnd(o)}else{for(var a,i=0,r=e.length;i<r;i++)(a=e[i]).onError&&a.onError(t);s.manager.itemError(o),s.manager.itemEnd(o)}},!1),m.addEventListener("progress",function(t){for(var n=cn[o],e=0,i=n.length;e<i;e++){var r=n[e];r.onProgress&&r.onProgress(t)}},!1),m.addEventListener("error",function(t){var n=cn[o];delete cn[o];for(var e=0,i=n.length;e<i;e++){var r=n[e];r.onError&&r.onError(t)}s.manager.itemError(o),s.manager.itemEnd(o)},!1),m.addEventListener("abort",function(t){var n=cn[o];delete cn[o];for(var e=0,i=n.length;e<i;e++){var r=n[e];r.onError&&r.onError(t)}s.manager.itemError(o),s.manager.itemEnd(o)},!1),void 0!==this.responseType&&(m.responseType=this.responseType),void 0!==this.withCredentials&&(m.withCredentials=this.withCredentials),m.overrideMimeType&&m.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain"),this.requestHeader)m.setRequestHeader(v,this.requestHeader[v]);m.send(null)}return s.manager.itemStart(o),m}cn[o].push({onLoad:t,onProgress:n,onError:e})},setResponseType:function(t){return this.responseType=t,this},setWithCredentials:function(t){return this.withCredentials=t,this},setMimeType:function(t){return this.mimeType=t,this},setRequestHeader:function(t){return this.requestHeader=t,this}}),((fn.prototype=Object.create(I.prototype)).constructor=fn).prototype.isShadowMaterial=!0,fn.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.color.copy(t.color),this},((dn.prototype=Object.create(I.prototype)).constructor=dn).prototype.isSpriteMaterial=!0,dn.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this};var pn={clone:vn,merge:mn},gn="\nvoid main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n",_n="\nvoid main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}\n";function xn(t){I.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=gn,this.fragmentShader=_n,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!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,void 0!==t&&(void 0!==t.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(t))}function An(t){xn.call(this,t),this.type="RawShaderMaterial"}function wn(t){I.call(this),this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new X(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=y,this.normalScale=new ct(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.vertexTangents=!1,this.setValues(t)}function yn(t){wn.call(this),this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoat=0,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ct(1,1),this.clearcoatNormalMap=null,this.reflectivity=.5,this.sheen=null,this.transparency=0,this.setValues(t)}function Sn(t){I.call(this),this.type="MeshPhongMaterial",this.color=new X(16777215),this.specular=new X(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=y,this.normalScale=new ct(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=v,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function bn(t){I.call(this),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new X(16777215),this.specular=new X(1118481),this.shininess=30,this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=y,this.normalScale=new ct(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Mn(t){I.call(this),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=y,this.normalScale=new ct(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Tn(t){I.call(this),this.type="MeshLambertMaterial",this.color=new X(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new X(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=v,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Ln(t){I.call(this),this.type="MeshDepthMaterial",this.depthPacking=w,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(t)}function En(t){I.call(this),this.type="MeshDistanceMaterial",this.referencePosition=new Q,this.nearDistance=1,this.farDistance=1e3,this.skinning=!1,this.morphTargets=!1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.setValues(t)}function Pn(t){I.call(this),this.type="MeshBasicMaterial",this.color=new X(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=v,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.skinning=!1,this.morphTargets=!1,this.setValues(t)}function Fn(t){I.call(this),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new X(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=y,this.normalScale=new ct(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)}function Nn(t){I.call(this),this.type="LineBasicMaterial",this.color=new X(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.setValues(t)}function Dn(t){Nn.call(this),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}function Cn(t){Hn.call(this,t),this.textures={}}((xn.prototype=Object.create(I.prototype)).constructor=xn).prototype.isShaderMaterial=!0,xn.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=vn(t.uniforms),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.lights=t.lights,this.clipping=t.clipping,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.extensions=t.extensions,this},((An.prototype=Object.create(xn.prototype)).constructor=An).prototype.isRawShaderMaterial=!0,((wn.prototype=Object.create(I.prototype)).constructor=wn).prototype.isMeshStandardMaterial=!0,wn.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this.vertexTangents=t.vertexTangents,this},((yn.prototype=Object.create(wn.prototype)).constructor=yn).prototype.isMeshPhysicalMaterial=!0,yn.prototype.copy=function(t){return wn.prototype.copy.call(this,t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.reflectivity=t.reflectivity,t.sheen?this.sheen=(this.sheen||new X).copy(t.sheen):this.sheen=null,this.transparency=t.transparency,this},((Sn.prototype=Object.create(I.prototype)).constructor=Sn).prototype.isMeshPhongMaterial=!0,Sn.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,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.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},((bn.prototype=Object.create(I.prototype)).constructor=bn).prototype.isMeshToonMaterial=!0,bn.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.gradientMap=t.gradientMap,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.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},((Mn.prototype=Object.create(I.prototype)).constructor=Mn).prototype.isMeshNormalMaterial=!0,Mn.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},((Tn.prototype=Object.create(I.prototype)).constructor=Tn).prototype.isMeshLambertMaterial=!0,Tn.prototype.copy=function(t){return I.prototype.copy.call(this,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.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.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},((Ln.prototype=Object.create(I.prototype)).constructor=Ln).prototype.isMeshDepthMaterial=!0,Ln.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.depthPacking=t.depthPacking,this.skinning=t.skinning,this.morphTargets=t.morphTargets,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},((En.prototype=Object.create(I.prototype)).constructor=En).prototype.isMeshDistanceMaterial=!0,En.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.referencePosition.copy(t.referencePosition),this.nearDistance=t.nearDistance,this.farDistance=t.farDistance,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this},((Pn.prototype=Object.create(I.prototype)).constructor=Pn).prototype.isMeshBasicMaterial=!0,Pn.prototype.copy=function(t){return I.prototype.copy.call(this,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.skinning=t.skinning,this.morphTargets=t.morphTargets,this},((Fn.prototype=Object.create(I.prototype)).constructor=Fn).prototype.isMeshMatcapMaterial=!0,Fn.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,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.alphaMap=t.alphaMap,this.skinning=t.skinning,this.morphTargets=t.morphTargets,this.morphNormals=t.morphNormals,this},((Nn.prototype=Object.create(I.prototype)).constructor=Nn).prototype.isLineBasicMaterial=!0,Nn.prototype.copy=function(t){return I.prototype.copy.call(this,t),this.color.copy(t.color),this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this},((Dn.prototype=Object.create(Nn.prototype)).constructor=Dn).prototype.isLineDashedMaterial=!0,Dn.prototype.copy=function(t){return Nn.prototype.copy.call(this,t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this},Cn.prototype=Object.assign(Object.create(Hn.prototype),{constructor:Cn,load:function(t,n,e,i){var r=this,a=new un(r.manager);a.setPath(r.path),a.load(t,function(t){n(r.parse(JSON.parse(t)))},e,i)},parse:function(t){var n=this.textures;function e(t){return void 0===n[t]&&console.warn("THREE.MaterialLoader: Undefined texture",t),n[t]}var i,r=new h[t.type];if(void 0!==t.uuid&&(r.uuid=t.uuid),void 0!==t.name&&(r.name=t.name),void 0!==t.color&&r.color.setHex(t.color),void 0!==t.roughness&&(r.roughness=t.roughness),void 0!==t.metalness&&(r.metalness=t.metalness),void 0!==t.sheen&&(r.sheen=(new X).setHex(t.sheen)),void 0!==t.emissive&&r.emissive.setHex(t.emissive),void 0!==t.specular&&r.specular.setHex(t.specular),void 0!==t.shininess&&(r.shininess=t.shininess),void 0!==t.clearcoat&&(r.clearcoat=t.clearcoat),void 0!==t.clearcoatRoughness&&(r.clearcoatRoughness=t.clearcoatRoughness),void 0!==t.fog&&(r.fog=t.fog),void 0!==t.flatShading&&(r.flatShading=t.flatShading),void 0!==t.blending&&(r.blending=t.blending),void 0!==t.combine&&(r.combine=t.combine),void 0!==t.side&&(r.side=t.side),void 0!==t.opacity&&(r.opacity=t.opacity),void 0!==t.transparent&&(r.transparent=t.transparent),void 0!==t.alphaTest&&(r.alphaTest=t.alphaTest),void 0!==t.depthTest&&(r.depthTest=t.depthTest),void 0!==t.depthWrite&&(r.depthWrite=t.depthWrite),void 0!==t.colorWrite&&(r.colorWrite=t.colorWrite),void 0!==t.stencilWrite&&(r.stencilWrite=t.stencilWrite),void 0!==t.stencilWriteMask&&(r.stencilWriteMask=t.stencilWriteMask),void 0!==t.stencilFunc&&(r.stencilFunc=t.stencilFunc),void 0!==t.stencilRef&&(r.stencilRef=t.stencilRef),void 0!==t.stencilFuncMask&&(r.stencilFuncMask=t.stencilFuncMask),void 0!==t.stencilFail&&(r.stencilFail=t.stencilFail),void 0!==t.stencilZFail&&(r.stencilZFail=t.stencilZFail),void 0!==t.stencilZPass&&(r.stencilZPass=t.stencilZPass),void 0!==t.wireframe&&(r.wireframe=t.wireframe),void 0!==t.wireframeLinewidth&&(r.wireframeLinewidth=t.wireframeLinewidth),void 0!==t.wireframeLinecap&&(r.wireframeLinecap=t.wireframeLinecap),void 0!==t.wireframeLinejoin&&(r.wireframeLinejoin=t.wireframeLinejoin),void 0!==t.rotation&&(r.rotation=t.rotation),1!==t.linewidth&&(r.linewidth=t.linewidth),void 0!==t.dashSize&&(r.dashSize=t.dashSize),void 0!==t.gapSize&&(r.gapSize=t.gapSize),void 0!==t.scale&&(r.scale=t.scale),void 0!==t.polygonOffset&&(r.polygonOffset=t.polygonOffset),void 0!==t.polygonOffsetFactor&&(r.polygonOffsetFactor=t.polygonOffsetFactor),void 0!==t.polygonOffsetUnits&&(r.polygonOffsetUnits=t.polygonOffsetUnits),void 0!==t.skinning&&(r.skinning=t.skinning),void 0!==t.morphTargets&&(r.morphTargets=t.morphTargets),void 0!==t.morphNormals&&(r.morphNormals=t.morphNormals),void 0!==t.dithering&&(r.dithering=t.dithering),void 0!==t.vertexTangents&&(r.vertexTangents=t.vertexTangents),void 0!==t.visible&&(r.visible=t.visible),void 0!==t.toneMapped&&(r.toneMapped=t.toneMapped),void 0!==t.userData&&(r.userData=t.userData),void 0!==t.vertexColors&&("number"==typeof t.vertexColors?r.vertexColors=0<t.vertexColors:r.vertexColors=t.vertexColors),void 0!==t.uniforms)for(var a in t.uniforms){var o=t.uniforms[a];switch(r.uniforms[a]={},o.type){case"t":r.uniforms[a].value=e(o.value);break;case"c":r.uniforms[a].value=(new X).setHex(o.value);break;case"v2":r.uniforms[a].value=(new ct).fromArray(o.value);break;case"v3":r.uniforms[a].value=(new Q).fromArray(o.value);break;case"v4":r.uniforms[a].value=(new lt).fromArray(o.value);break;case"m3":r.uniforms[a].value=(new Ut).fromArray(o.value);case"m4":r.uniforms[a].value=(new Dt).fromArray(o.value);break;default:r.uniforms[a].value=o.value}}if(void 0!==t.defines&&(r.defines=t.defines),void 0!==t.vertexShader&&(r.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(r.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(var s in t.extensions)r.extensions[s]=t.extensions[s];return void 0!==t.shading&&(r.flatShading=1===t.shading),void 0!==t.size&&(r.size=t.size),void 0!==t.sizeAttenuation&&(r.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(r.map=e(t.map)),void 0!==t.matcap&&(r.matcap=e(t.matcap)),void 0!==t.alphaMap&&(r.alphaMap=e(t.alphaMap)),void 0!==t.bumpMap&&(r.bumpMap=e(t.bumpMap)),void 0!==t.bumpScale&&(r.bumpScale=t.bumpScale),void 0!==t.normalMap&&(r.normalMap=e(t.normalMap)),void 0!==t.normalMapType&&(r.normalMapType=t.normalMapType),void 0!==t.normalScale&&(i=t.normalScale,!1===Array.isArray(i)&&(i=[i,i]),r.normalScale=(new ct).fromArray(i)),void 0!==t.displacementMap&&(r.displacementMap=e(t.displacementMap)),void 0!==t.displacementScale&&(r.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(r.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(r.roughnessMap=e(t.roughnessMap)),void 0!==t.metalnessMap&&(r.metalnessMap=e(t.metalnessMap)),void 0!==t.emissiveMap&&(r.emissiveMap=e(t.emissiveMap)),void 0!==t.emissiveIntensity&&(r.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(r.specularMap=e(t.specularMap)),void 0!==t.envMap&&(r.envMap=e(t.envMap)),void 0!==t.envMapIntensity&&(r.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(r.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(r.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(r.lightMap=e(t.lightMap)),void 0!==t.lightMapIntensity&&(r.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(r.aoMap=e(t.aoMap)),void 0!==t.aoMapIntensity&&(r.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(r.gradientMap=e(t.gradientMap)),void 0!==t.clearcoatMap&&(r.clearcoatMap=e(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(r.clearcoatRoughnessMap=e(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(r.clearcoatNormalMap=e(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(r.clearcoatNormalScale=(new ct).fromArray(t.clearcoatNormalScale)),r},setTextures:function(t){return this.textures=t,this}});var Rn,In,On,Un;function Hn(t){this.manager=void 0!==t?t:ln,this.crossOrigin="anonymous",this.path="",this.resourcePath=""}function Xn(t){Hn.call(this,t)}Object.assign(Hn.prototype,{load:function(){},parse:function(){},setCrossOrigin:function(t){return this.crossOrigin=t,this},setPath:function(t){return this.path=t,this},setResourcePath:function(t){return this.resourcePath=t,this}}),Object.assign(Hn.prototype,{crossOrigin:"anonymous",onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(t,n,e){for(var i=[],r=0;r<t.length;++r)i[r]=this.createMaterial(t[r],n,e);return i},createMaterial:(Rn={NoBlending:0,NormalBlending:1,AdditiveBlending:2,SubtractiveBlending:3,MultiplyBlending:4,CustomBlending:5},In=new X,On=new Bn,Un=new Cn,function(t,o,s){var h={};function n(t,n,e,i,r){var a=o+t,t=(new hn).getHandler(a),a=null!==t?t.load(a):(On.setCrossOrigin(s),On.load(a));void 0!==n&&(a.repeat.fromArray(n),1!==n[0]&&(a.wrapS=1e3),1!==n[1]&&(a.wrapT=1e3)),void 0!==e&&a.offset.fromArray(e),void 0!==i&&("repeat"===i[0]&&(a.wrapS=1e3),"mirror"===i[0]&&(a.wrapS=1002),"repeat"===i[1]&&(a.wrapT=1e3),"mirror"===i[1]&&(a.wrapT=1002)),void 0!==r&&(a.anisotropy=r);r=C.generateUUID();return h[r]=a,r}var e,i={uuid:C.generateUUID(),type:"MeshLambertMaterial"};for(e in t){var r=t[e];switch(e){case"DbgColor":case"DbgIndex":case"opticalDensity":case"illumination":break;case"DbgName":i.name=r;break;case"blending":i.blending=Rn[r];break;case"colorAmbient":case"mapAmbient":break;case"colorDiffuse":i.color=In.fromArray(r).getHex();break;case"colorSpecular":i.specular=In.fromArray(r).getHex();break;case"colorEmissive":i.emissive=In.fromArray(r).getHex();break;case"specularCoef":i.shininess=r;break;case"shading":"basic"===r.toLowerCase()&&(i.type="MeshBasicMaterial"),"phong"===r.toLowerCase()&&(i.type="MeshPhongMaterial"),"standard"===r.toLowerCase()&&(i.type="MeshStandardMaterial");break;case"mapDiffuse":i.map=n(r,t.mapDiffuseRepeat,t.mapDiffuseOffset,t.mapDiffuseWrap,t.mapDiffuseAnisotropy);break;case"mapDiffuseRepeat":case"mapDiffuseOffset":case"mapDiffuseWrap":case"mapDiffuseAnisotropy":break;case"mapEmissive":i.emissiveMap=n(r,t.mapEmissiveRepeat,t.mapEmissiveOffset,t.mapEmissiveWrap,t.mapEmissiveAnisotropy);break;case"mapEmissiveRepeat":case"mapEmissiveOffset":case"mapEmissiveWrap":case"mapEmissiveAnisotropy":break;case"mapLight":i.lightMap=n(r,t.mapLightRepeat,t.mapLightOffset,t.mapLightWrap,t.mapLightAnisotropy);break;case"mapLightRepeat":case"mapLightOffset":case"mapLightWrap":case"mapLightAnisotropy":break;case"mapAO":i.aoMap=n(r,t.mapAORepeat,t.mapAOOffset,t.mapAOWrap,t.mapAOAnisotropy);break;case"mapAORepeat":case"mapAOOffset":case"mapAOWrap":case"mapAOAnisotropy":break;case"mapBump":i.bumpMap=n(r,t.mapBumpRepeat,t.mapBumpOffset,t.mapBumpWrap,t.mapBumpAnisotropy);break;case"mapBumpScale":i.bumpScale=r;break;case"mapBumpRepeat":case"mapBumpOffset":case"mapBumpWrap":case"mapBumpAnisotropy":break;case"mapNormal":i.normalMap=n(r,t.mapNormalRepeat,t.mapNormalOffset,t.mapNormalWrap,t.mapNormalAnisotropy);break;case"mapNormalFactor":i.normalScale=r;break;case"mapNormalRepeat":case"mapNormalOffset":case"mapNormalWrap":case"mapNormalAnisotropy":break;case"mapSpecular":i.specularMap=n(r,t.mapSpecularRepeat,t.mapSpecularOffset,t.mapSpecularWrap,t.mapSpecularAnisotropy);break;case"mapSpecularRepeat":case"mapSpecularOffset":case"mapSpecularWrap":case"mapSpecularAnisotropy":break;case"mapMetalness":i.metalnessMap=n(r,t.mapMetalnessRepeat,t.mapMetalnessOffset,t.mapMetalnessWrap,t.mapMetalnessAnisotropy);break;case"mapMetalnessRepeat":case"mapMetalnessOffset":case"mapMetalnessWrap":case"mapMetalnessAnisotropy":break;case"mapRoughness":i.roughnessMap=n(r,t.mapRoughnessRepeat,t.mapRoughnessOffset,t.mapRoughnessWrap,t.mapRoughnessAnisotropy);break;case"mapRoughnessRepeat":case"mapRoughnessOffset":case"mapRoughnessWrap":case"mapRoughnessAnisotropy":break;case"mapAlpha":i.alphaMap=n(r,t.mapAlphaRepeat,t.mapAlphaOffset,t.mapAlphaWrap,t.mapAlphaAnisotropy);break;case"mapAlphaRepeat":case"mapAlphaOffset":case"mapAlphaWrap":case"mapAlphaAnisotropy":break;case"flipSided":i.side=1;break;case"doubleSided":i.side=2;break;case"transparency":i.opacity=r;break;case"depthTest":case"depthWrite":case"colorWrite":case"opacity":case"reflectivity":case"transparent":case"visible":case"wireframe":i[e]=r;break;case"vertexColors":!0===r&&(i.vertexColors=2),"face"===r&&(i.vertexColors=1)}}return"MeshBasicMaterial"===i.type&&delete i.emissive,"MeshPhongMaterial"!==i.type&&delete i.specular,i.opacity<1&&(i.transparent=!0),Un.setTextures(h),Un.parse(i)})}),Xn.prototype=Object.assign(Object.create(Hn.prototype),{constructor:Xn,load:function(n,t,e,i){void 0!==this.path&&(n=this.path+n),n=this.manager.resolveURL(n);var r=this,a=sn.get(n);if(void 0!==a)return r.manager.itemStart(n),setTimeout(function(){t&&t(a),r.manager.itemEnd(n)},0),a;var o=document.createElementNS("http://www.w3.org/1999/xhtml","img");function s(){o.removeEventListener("load",s,!1),o.removeEventListener("error",h,!1),sn.add(n,this),t&&t(this),r.manager.itemEnd(n)}function h(t){o.removeEventListener("load",s,!1),o.removeEventListener("error",h,!1),i&&i(t),r.manager.itemError(n),r.manager.itemEnd(n)}return o.addEventListener("load",s,!1),o.addEventListener("error",h,!1),"data:"!==n.substr(0,5)&&void 0!==this.crossOrigin&&(o.crossOrigin=this.crossOrigin),r.manager.itemStart(n),o.src=n,o}});var Gn=0;function zn(t,n,e,i,r,a,o,s,h,l){Object.defineProperty(this,"id",{value:Gn++}),this.uuid=C.generateUUID(),this.name="",this.image=void 0!==t?t:zn.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==n?n:zn.DEFAULT_MAPPING,this.wrapS=void 0!==e?e:p,this.wrapT=void 0!==i?i:p,this.magFilter=void 0!==r?r:E,this.minFilter=void 0!==a?a:_,this.anisotropy=void 0!==h?h:1,this.format=void 0!==o?o:x,this.internalFormat=null,this.type=void 0!==s?s:S,this.offset=new ct(0,0),this.repeat=new ct(1,1),this.center=new ct(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ut,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=void 0!==l?l:A,this.version=0,this.onUpdate=null}function Bn(t){Hn.call(this,t)}zn.DEFAULT_IMAGE=void 0,zn.DEFAULT_MAPPING=300,zn.prototype=Object.assign(Object.create(i.prototype),{constructor:zn,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.name=t.name,this.image=t.image,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},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||1<t.x)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case p:t.x=t.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||1<t.y)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case p:t.y=t.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}}),Object.defineProperty(zn.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Bn.prototype=Object.assign(Object.create(Hn.prototype),{constructor:Bn,load:function(n,e,t,i){var r=new zn,a=new Xn(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(n,function(t){r.image=t;t=0<n.search(/\.jpe?g($|\?)/i)||0===n.search(/^data\:image\/jpeg/);r.format=t?P:x,r.needsUpdate=!0,void 0!==e&&e(r)},t,i),r}});var kn=new Q,Vn=new Q,Yn=new Q,jn=new Q,Qn=new Q,Wn=new Q,Zn=new Q;function qn(t,n){this.origin=void 0!==t?t:new Q,this.direction=void 0!==n?n:new Q(0,0,-1)}Object.assign(qn.prototype,{set:function(t,n){return this.origin.copy(t),this.direction.copy(n),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,n){return void 0===n&&(console.warn("THREE.Ray: .at() target is now required"),n=new Q),n.copy(this.direction).multiplyScalar(t).add(this.origin)},lookAt:function(t){return this.direction.copy(t).sub(this.origin).normalize(),this},recast:function(t){return this.origin.copy(this.at(t,kn)),this},closestPointToPoint:function(t,n){void 0===n&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),n=new Q),n.subVectors(t,this.origin);t=n.dot(this.direction);return t<0?n.copy(this.origin):n.copy(this.direction).multiplyScalar(t).add(this.origin)},distanceToPoint:function(t){return Math.sqrt(this.distanceSqToPoint(t))},distanceSqToPoint:function(t){var n=kn.subVectors(t,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(t):(kn.copy(this.direction).multiplyScalar(n).add(this.origin),kn.distanceToSquared(t))},distanceSqToSegment:function(t,n,e,i){Vn.copy(t).add(n).multiplyScalar(.5),Yn.copy(n).sub(t).normalize(),jn.copy(this.origin).sub(Vn);var r,a,o=.5*t.distanceTo(n),s=-this.direction.dot(Yn),h=jn.dot(this.direction),l=-jn.dot(Yn),c=jn.lengthSq(),t=Math.abs(1-s*s);return c=0<t?(a=s*h-l,n=o*t,0<=(r=s*l-h)?-n<=a?a<=n?(r*=t=1/t)*(r+s*(a*=t)+2*h)+a*(s*r+a+2*l)+c:(a=o,-(r=Math.max(0,-(s*a+h)))*r+a*(a+2*l)+c):(a=-o,-(r=Math.max(0,-(s*a+h)))*r+a*(a+2*l)+c):a<=-n?-(r=Math.max(0,-(-s*o+h)))*r+(a=0<r?-o:Math.min(Math.max(-o,-l),o))*(a+2*l)+c:a<=n?(r=0,(a=Math.min(Math.max(-o,-l),o))*(a+2*l)+c):-(r=Math.max(0,-(s*o+h)))*r+(a=0<r?o:Math.min(Math.max(-o,-l),o))*(a+2*l)+c):(a=0<s?-o:o,-(r=Math.max(0,-(s*a+h)))*r+a*(a+2*l)+c),e&&e.copy(this.direction).multiplyScalar(r).add(this.origin),i&&i.copy(Yn).multiplyScalar(a).add(Vn),c},intersectSphere:function(t,n){kn.subVectors(t.center,this.origin);var e=kn.dot(this.direction),i=kn.dot(kn)-e*e,t=t.radius*t.radius;if(t<i)return null;t=Math.sqrt(t-i),i=e-t,t=e+t;return i<0&&t<0?null:i<0?this.at(t,n):this.at(i,n)},intersectsSphere:function(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius},distanceToPlane:function(t){var n=t.normal.dot(this.direction);if(0===n)return 0===t.distanceToPoint(this.origin)?0:null;n=-(this.origin.dot(t.normal)+t.constant)/n;return 0<=n?n:null},intersectPlane:function(t,n){t=this.distanceToPlane(t);return null===t?null:this.at(t,n)},intersectsPlane:function(t){var n=t.distanceToPoint(this.origin);return 0===n||t.normal.dot(this.direction)*n<0},intersectBox:function(t,n){var e,i,r,a=1/this.direction.x,o=1/this.direction.y,s=1/this.direction.z,h=this.origin,a=0<=a?(e=(t.min.x-h.x)*a,(t.max.x-h.x)*a):(e=(t.max.x-h.x)*a,(t.min.x-h.x)*a),o=0<=o?(i=(t.min.y-h.y)*o,(t.max.y-h.y)*o):(i=(t.max.y-h.y)*o,(t.min.y-h.y)*o);return o<e||a<i?null:((o<a||a!=a)&&(a=o),(s=0<=s?(r=(t.min.z-h.z)*s,(t.max.z-h.z)*s):(r=(t.max.z-h.z)*s,(t.min.z-h.z)*s))<(e=e<i||e!=e?i:e)||a<r?null:((e<r||e!=e)&&(e=r),(a=s<a||a!=a?s:a)<0?null:this.at(0<=e?e:a,n)))},intersectsBox:function(t){return null!==this.intersectBox(t,kn)},intersectTriangle:function(t,n,e,i,r){Qn.subVectors(n,t),Wn.subVectors(e,t),Zn.crossVectors(Qn,Wn);e=this.direction.dot(Zn);if(0<e){if(i)return null;a=1}else{if(!(e<0))return null;a=-1,e=-e}jn.subVectors(this.origin,t);i=a*this.direction.dot(Wn.crossVectors(jn,Wn));if(i<0)return null;t=a*this.direction.dot(Qn.cross(jn));if(t<0)return null;if(e<i+t)return null;var a=-a*jn.dot(Zn);return a<0?null:this.at(a/e,r)},applyMatrix4:function(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}});var Kn=new Dt,Jn=new qn,$n=new St,te=new Q;function ne(t,n){Kt.call(this),this.type="Points",this.geometry=void 0!==t?t:new on,this.material=void 0!==n?n:new k,this.updateMorphTargets()}function ee(t,n,e,i,r,a,o){var s=Jn.distanceSqToPoint(t);s<e&&(e=new Q,Jn.closestPointToPoint(t,e),e.applyMatrix4(i),(i=r.ray.origin.distanceTo(e))<r.near||i>r.far||a.push({distance:i,distanceToRay:Math.sqrt(s),point:e,index:n,face:null,object:o}))}function ie(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}ne.prototype=Object.assign(Object.create(Kt.prototype),{constructor:ne,isPoints:!0,raycast:function(t,n){var e=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold;if(null===e.boundingSphere&&e.computeBoundingSphere(),$n.copy(e.boundingSphere),$n.applyMatrix4(i),$n.radius+=r,!1!==t.ray.intersectsSphere($n)){Kn.getInverse(i),Jn.copy(t.ray).applyMatrix4(Kn);var r=r/((this.scale.x+this.scale.y+this.scale.z)/3),a=r*r;if(e.isBufferGeometry){var r=e.index,o=e.attributes.position.array;if(null!==r)for(var s=r.array,h=0,l=s.length;h<l;h++){var c=s[h];te.fromArray(o,3*c),ee(te,c,a,i,t,n,this)}else for(var h=0,u=o.length/3;h<u;h++)te.fromArray(o,3*h),ee(te,h,a,i,t,n,this)}else for(var f=e.vertices,h=0,u=f.length;h<u;h++)ee(f[h],h,a,i,t,n,this)}},updateMorphTargets:function(){var t,n,e,i=this.geometry;if(i.isBufferGeometry){var r=i.morphAttributes,a=Object.keys(r);if(0<a.length){var o=r[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,n=o.length;t<n;t++)e=o[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}else{i=i.morphTargets;void 0!==i&&0<i.length&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var re=function(){function i(t,n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,i);var e=new k({opacity:1,transparent:!0,depthTest:!1,size:5});this.material=e,this.geo=new on;n=(new Bn).load(n);e.map=n,e.needsUpdate=!0,this.pointsArrayLength=t.length,this.pointsArray=t,this.geo.setFromPoints(t),this.plength=t.length,this.points=new ne(this.geo,e)}var t,n,e;return t=i,(n=[{key:"updatePoints",value:function(t){this.geo.setFromPoints(t)}},{key:"changePositions",value:function(t,n,e,i,r){for(var a=this.geo.attributes.position,o=0;o<this.plength;o++){var s=a.getX(o)+t*this.runstatus[o].x.sign*this.runstatus[o].x.weight,h=a.getY(o)+n*this.runstatus[o].y.sign*this.runstatus[o].y.weight,l=a.getZ(o)+e*this.runstatus[o].z.sign*this.runstatus[o].z.weight;i(s,h,l)?a.setXYZ(o,s,h,l):(l=r(),a.setXYZ(o,l.x,l.y,l.z))}a.needsUpdate=!0}},{key:"setRunStatus",value:function(t){this.runstatus=t}},{key:"setParticleCount",value:function(t){this.pointsArray.length=this.pointsArrayLength*t,this.geo.setFromPoints(this.pointsArray),this.points=new ne(this.geo,this.material)}}])&&ie(t.prototype,n),e&&ie(t,e),i}(),ae={NONE:0,EXTRUDE_MARKER:2,IMAGE_MARKER:8,LOCATION_MARKER:16,POLYGON_MARKER:32,TEXT_MARKER:64,LINE_MARKER:128,HEAT_MAP_MARKER:512,EXTENT:1024,EXTERNAL_MODEL:2048,MODEL:4096,FACILITY:8192,LABEL:16384,DYNAMIC_MODEL_MARKER:32768,DOM_MARKER:65536,EXTENT_LAYER:1<<20,EXTERNAL_MODEL_LAYER:1<<21,MODEL_LAYER:1<<22,FACILITY_LAYER:1<<23,LABEL_LAYER:1<<24,MARKER_GROUP:1<<25};function oe(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var se=function(){function t(){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.type="effect",this.waterLayers=new Map,this.bloom=null,this.particle=null,this.sky=null,this.rain=null,this.flowlines=new Map,this.sweep=null,this.sao=null}var n,e,i;return n=t,(e=[{key:"render",value:function(){var n=this;this.renderer.clear(),this.resize(),this.skyNeedTexture&&this.skyNeedTexture.render(),this.sky&&this.sky.render(),this.sao&&this.sao.render(),this.waterLayers.forEach(function(t){t.traverse(function(t){t.L.material.uniforms.time.value+=1/60}),n.renderer.render(t.P,n.parent.camera)});for(var t=Array.from(this.getRenderList()),e=0;e<t.length;e++){var i=t[e][0].split("_"),r=parseInt(i[0]),a=parseInt(i[1]);this.sweep&&this.sweep.render(t[e][1]),this.flowlines.forEach(function(t){return t.render()}),this.sao&&this.sao.add(t[e][1]);i=this.waterLayers.get(r);i&&0!=(a&i.F)||this.renderer.render(t[e][1],this.parent.camera),!this.bloom||(r=this.bloom.N.get(r))&&(a=this.getLayerType(a),(a=r.get(a))&&(this.bloom.updateCamera(),this.bloom.D.add(a.scene),this.bloom.C.render(),this.bloom.D.remove(a.scene)))}this.parent.getMarkerGroup()&&this.renderer.render(this.parent.getMarkerGroup().scene,this.parent.camera),this.particle&&this.particle.render(),this.rain&&this.rain.render(),this.needLogo&&this.xx45f6&&this.renderer.render(this.xx45f6,this.parent.camera)}},{key:"getLayerType",value:function(t){switch(t){case ae.EXTENT:return ae.EXTENT_LAYER;case ae.EXTERNAL_MODEL:return ae.EXTERNAL_MODEL_LAYER;case ae.MODEL:return ae.MODEL_LAYER;case ae.FACILITY:return ae.FACILITY_LAYER;case ae.LABEL:return ae.LABEL_LAYER;default:return t}}}])&&oe(n.prototype,e),i&&oe(n,i),t}();function he(){Kt.call(this),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function le(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}he.prototype=Object.assign(Object.create(Kt.prototype),{constructor:he,isScene:!0,copy:function(t,n){return Kt.prototype.copy.call(this,t,n),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.autoUpdate=t.autoUpdate,this.matrixAutoUpdate=t.matrixAutoUpdate,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var ce=function(){function n(t){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),this.R=t,this.P=new he,this.I=null,this.O="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9TS0UqDnYQ6ZChOlkQK8VRqlgEC6Wt0KqDyaVf0MSQpLg4Cq4FBz8Wqw4uzro6uAqC4AeIk6OToouU+L+k0CLGg+N+vLv3uHsHCK06U82+SUDVLCObSoqF4ooYfEUAEfiRQFxipp7OLeThOb7u4ePrXYxneZ/7cwwqJZMBPpF4lumGRbxOnNi0dM77xGFWlRTic+IJgy5I/Mh12eU3zhWHBZ4ZNvLZOeIwsVjpYbmHWdVQiaeJo4qqUb5QcFnhvMVZrTdY5578haGStpzjOs0IUlhEGhmIkNFADXVYiNGqkWIiS/tJD/+o48+QSyZXDYwc89iACsnxg//B727NcnzKTQolgcCLbX+MAcFdoN207e9j226fAP5n4Err+jdawMwn6c2uFj0ChraBi+uuJu8BlzvAyJMuGZIj+WkK5TLwfkbfVASGb4GBVbe3zj5OH4A8dbV0AxwcAuMVyl7zeHd/b2//nun09wPqUXLXvsrewQAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB+QFHAQMLuREfnwAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAA9UlEQVQY002Pu0oDQRRA7517d0ISFwKaIKLgphPSqGltxEYk/2AnBNILdhba2PkBNv6BJn8QxLR2KVwEH6xBEk1G3ezMXBsDOeWpzgGYoxPbZvsxa807BgC4ibNSYhy9TdwGAvjzrglrK5oaUTDCTmx3p06O343rhzl1azK/hwC9coEOCeGMHVN38JlerZb4WxNeLCHZl6HdekjS9mZUvFdifhEJlpMvd6QUsngIKgt0WWR8IgRk1kG9zFJLJv46/phuF7S6G6d+J1rM1f2Pf8ZZZO8182uhOhUR7cGerId53q/ygAEAGlEw+t/siwgdVPPD2eYf14pkaPQAZiEAAAAASUVORK5CYII=",this.points=[],this.pointsStatus=[],this._=t.getBound().size.x,this.U=t.getBound().size.y,this.H=1e5,this.X=0,this.G=this.G.bind(this),this.B(this.H),this.k()}var t,e,i;return t=n,(e=[{key:"enable",value:function(){(this.R.getRenderManager().particle=this).R.on("beforeRender",this.G)}},{key:"disable",value:function(){this.R.getRenderManager().particle=null,this.R.off("beforeRender",this.G),this.G()}},{key:"dispose",value:function(){this.disable(),this.O=null,this.P.dispose(),this.P=null,this.points=null,this.pointsStatus=null}},{key:"setUrl",value:function(t){this.P.children[0].material.map=(new Bn).load(t)}},{key:"setAmount",value:function(t){this.P.remove(this.I.points),this.points=[],this.pointsStatus=[];t=this.H*t;this.B(t)}},{key:"render",value:function(){var t=this;null!==this.I&&this.I.changePositions(.1,-.32,.1,function(t,n){return 0<=n},function(){return new Q((Math.random()-.5)*t._,1e3*Math.random(),(Math.random()-.5)*t.U)}),this.R.getRenderManager().renderer.render(this.P,this.R.camera)}}])&&le(t.prototype,e),i&&le(t,i),n}();Object.assign(ce.prototype,{G:function(){this.R.enableUpdateRender()},V:function(t,n,e){for(var i=0;i<t;i++){var r=(Math.random()-.5)*this._,a=1e3*Math.random(),o=(Math.random()-.5)*this.U,s=Math.random()-.5,h=s/Math.abs(s),l=3*Math.random(),s=Math.random()-.5,s=s/Math.abs(s);n.push(new Q(r,a,o)),e.push({x:{sign:h,weight:l},y:{sign:1,weight:1},z:{sign:s,weight:3*Math.random()}})}},B:function(t){this.V(t,this.points,this.pointsStatus),this.I=new re(this.points,this.O),this.I.setRunStatus(this.pointsStatus),this.P.add(this.I.points)},k:function(){"basic"===this.R.getRenderManager().type&&this.R.setRenderManager(new se)}});var ue=ce;function fe(){Kt.call(this),this.type="Camera",this.matrixWorldInverse=new Dt,this.projectionMatrix=new Dt,this.projectionMatrixInverse=new Dt}function de(t,n,e,i,r,a){fe.call(this),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=void 0!==t?t:-1,this.right=void 0!==n?n:1,this.top=void 0!==e?e:1,this.bottom=void 0!==i?i:-1,this.near=void 0!==r?r:.1,this.far=void 0!==a?a:2e3,this.updateProjectionMatrix()}function ve(t,n,e,i){on.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:n,widthSegments:e,heightSegments:i};for(var r=(t=t||1)/2,a=(n=n||1)/2,o=Math.floor(e)||1,s=Math.floor(i)||1,h=o+1,l=s+1,c=t/o,u=n/s,f=[],d=[],v=[],m=[],p=0;p<l;p++)for(var g=p*u-a,_=0;_<h;_++)d.push(_*c-r,-g,0),v.push(0,0,1),m.push(_/o),m.push(1-p/s);for(p=0;p<s;p++)for(_=0;_<o;_++){var x=_+h*(p+1),A=_+1+h*(p+1),w=_+1+h*p;f.push(_+h*p,x,w),f.push(x,A,w)}this.setIndex(f),this.setAttribute("position",new At(d,3)),this.setAttribute("normal",new At(v,3)),this.setAttribute("uv",new At(m,2))}fe.prototype=Object.assign(Object.create(Kt.prototype),{constructor:fe,isCamera:!0,copy:function(t,n){return Kt.prototype.copy.call(this,t,n),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this},getWorldDirection:function(t){void 0===t&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),t=new Q),this.updateMatrixWorld(!0);var n=this.matrixWorld.elements;return t.set(-n[8],-n[9],-n[10]).normalize()},updateMatrixWorld:function(t){Kt.prototype.updateMatrixWorld.call(this,t),this.matrixWorldInverse.getInverse(this.matrixWorld)},updateWorldMatrix:function(t,n){Kt.prototype.updateWorldMatrix.call(this,t,n),this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}}),de.prototype=Object.assign(Object.create(fe.prototype),{constructor:de,isOrthographicCamera:!0,copy:function(t,n){return fe.prototype.copy.call(this,t,n),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:function(t,n,e,i,r,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=n,this.view.offsetX=e,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),e=(this.right+this.left)/2,i=(this.top+this.bottom)/2,r=e-t,a=e+t,e=i+n,t=i-n;null!==this.view&&this.view.enabled&&(i=(this.right-this.left)/this.view.fullWidth/this.zoom,n=(this.top-this.bottom)/this.view.fullHeight/this.zoom,a=(r+=i*this.view.offsetX)+i*this.view.width,t=(e-=n*this.view.offsetY)-n*this.view.height),this.projectionMatrix.makeOrthographic(r,a,e,t,this.near,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)}}),(ve.prototype=Object.create(on.prototype)).constructor=ve;var me=new Q,pe=new Q,ge=new Ut;function _e(t,n){this.normal=void 0!==t?t:new Q(1,0,0),this.constant=void 0!==n?n:0}Object.assign(_e.prototype,{isPlane:!0,set:function(t,n){return this.normal.copy(t),this.constant=n,this},setComponents:function(t,n,e,i){return this.normal.set(t,n,e),this.constant=i,this},setFromNormalAndCoplanarPoint:function(t,n){return this.normal.copy(t),this.constant=-n.dot(this.normal),this},setFromCoplanarPoints:function(t,n,e){n=me.subVectors(e,n).cross(pe.subVectors(t,n)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,n){return void 0===n&&(console.warn("THREE.Plane: .projectPoint() target is now required"),n=new Q),n.copy(this.normal).multiplyScalar(-this.distanceToPoint(t)).add(t)},intersectLine:function(t,n){void 0===n&&(console.warn("THREE.Plane: .intersectLine() target is now required"),n=new Q);var e=t.delta(me),i=this.normal.dot(e);if(0===i)return 0===this.distanceToPoint(t.start)?n.copy(t.start):void 0;i=-(t.start.dot(this.normal)+this.constant)/i;return i<0||1<i?void 0:n.copy(e).multiplyScalar(i).add(t.start)},intersectsLine:function(t){var n=this.distanceToPoint(t.start),t=this.distanceToPoint(t.end);return n<0&&0<t||t<0&&0<n},intersectsBox:function(t){return t.intersectsPlane(this)},intersectsSphere:function(t){return t.intersectsPlane(this)},coplanarPoint:function(t){return void 0===t&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),t=new Q),t.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(t,n){n=n||ge.getNormalMatrix(t),t=this.coplanarPoint(me).applyMatrix4(t),n=this.normal.applyMatrix3(n).normalize();return this.constant=-t.dot(n),this},translate:function(t){return this.constant-=t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant===this.constant}});var xe=new Q,Ae=new Q,we=new Q,ye=new Q,Se=new Q,be=new Q,Me=new Q,Te=new Q,Le=new Q,Ee=new Q;function Pe(t,n,e){this.a=void 0!==t?t:new Q,this.b=void 0!==n?n:new Q,this.c=void 0!==e?e:new Q}function Fe(t,n,e,i,r,a){this.a=t,this.b=n,this.c=e,this.normal=i&&i.isVector3?i:new Q,this.vertexNormals=Array.isArray(i)?i:[],this.color=r&&r.isColor?r:new X,this.vertexColors=Array.isArray(r)?r:[],this.materialIndex=void 0!==a?a:0}Object.assign(Pe,{getNormal:function(t,n,e,i){void 0===i&&(console.warn("THREE.Triangle: .getNormal() target is now required"),i=new Q),i.subVectors(e,n),xe.subVectors(t,n),i.cross(xe);n=i.lengthSq();return 0<n?i.multiplyScalar(1/Math.sqrt(n)):i.set(0,0,0)},getBarycoord:function(t,n,e,i,r){xe.subVectors(i,n),Ae.subVectors(e,n),we.subVectors(t,n);var a=xe.dot(xe),o=xe.dot(Ae),i=xe.dot(we),e=Ae.dot(Ae),t=Ae.dot(we),n=a*e-o*o;if(void 0===r&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),r=new Q),0==n)return r.set(-2,-1,-1);n=1/n,e=(e*i-o*t)*n,n*=a*t-o*i;return r.set(1-e-n,n,e)},containsPoint:function(t,n,e,i){return Pe.getBarycoord(t,n,e,i,ye),0<=ye.x&&0<=ye.y&&ye.x+ye.y<=1},getUV:function(t,n,e,i,r,a,o,s){return this.getBarycoord(t,n,e,i,ye),s.set(0,0),s.addScaledVector(r,ye.x),s.addScaledVector(a,ye.y),s.addScaledVector(o,ye.z),s},isFrontFacing:function(t,n,e,i){return xe.subVectors(e,n),Ae.subVectors(t,n),xe.cross(Ae).dot(i)<0}}),Object.assign(Pe.prototype,{set:function(t,n,e){return this.a.copy(t),this.b.copy(n),this.c.copy(e),this},setFromPointsAndIndices:function(t,n,e,i){return this.a.copy(t[n]),this.b.copy(t[e]),this.c.copy(t[i]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},getArea:function(){return xe.subVectors(this.c,this.b),Ae.subVectors(this.a,this.b),.5*xe.cross(Ae).length()},getMidpoint:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),t=new Q),t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(t){return Pe.getNormal(this.a,this.b,this.c,t)},getPlane:function(t){return void 0===t&&(console.warn("THREE.Triangle: .getPlane() target is now required"),t=new _e),t.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(t,n){return Pe.getBarycoord(t,this.a,this.b,this.c,n)},getUV:function(t,n,e,i,r){return Pe.getUV(t,this.a,this.b,this.c,n,e,i,r)},containsPoint:function(t){return Pe.containsPoint(t,this.a,this.b,this.c)},isFrontFacing:function(t){return Pe.isFrontFacing(this.a,this.b,this.c,t)},intersectsBox:function(t){return t.intersectsTriangle(this)},closestPointToPoint:function(t,n){void 0===n&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),n=new Q);var e=this.a,i=this.b,r=this.c;Se.subVectors(i,e),be.subVectors(r,e),Te.subVectors(t,e);var a=Se.dot(Te),o=be.dot(Te);if(a<=0&&o<=0)return n.copy(e);Le.subVectors(t,i);var s=Se.dot(Le),h=be.dot(Le);if(0<=s&&h<=s)return n.copy(i);var l=a*h-s*o;if(l<=0&&0<=a&&s<=0)return u=a/(a-s),n.copy(e).addScaledVector(Se,u);Ee.subVectors(t,r);var c=Se.dot(Ee),t=be.dot(Ee);if(0<=t&&c<=t)return n.copy(r);a=c*o-a*t;if(a<=0&&0<=o&&t<=0)return f=o/(o-t),n.copy(e).addScaledVector(be,f);o=s*t-c*h;if(o<=0&&0<=h-s&&0<=c-t)return Me.subVectors(r,i),f=(h-s)/(h-s+(c-t)),n.copy(i).addScaledVector(Me,f);var o=1/(o+a+l),u=a*o,f=l*o;return n.copy(e).addScaledVector(Se,u).addScaledVector(be,f)},equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}),Object.assign(Fe.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.normal.copy(t.normal),this.color.copy(t.color),this.materialIndex=t.materialIndex;for(var n=0,e=t.vertexNormals.length;n<e;n++)this.vertexNormals[n]=t.vertexNormals[n].clone();for(n=0,e=t.vertexColors.length;n<e;n++)this.vertexColors[n]=t.vertexColors[n].clone();return this}});var Ne=new Dt,De=new qn,Ce=new St,Re=new Q,Ie=new Q,Oe=new Q,Ue=new Q,He=new Q,Xe=new Q,Ge=new Q,ze=new Q,Be=new Q,ke=new ct,Ve=new ct,Ye=new ct,je=new Q,Qe=new Q;function We(t,n){Kt.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new on,this.material=void 0!==n?n:new Pn,this.updateMorphTargets()}function Ze(t,n,e,i,r,a,o,s){n=n.side===l?i.intersectTriangle(o,a,r,!0,s):i.intersectTriangle(r,a,o,n.side!==c,s);if(null===n)return null;Qe.copy(s),Qe.applyMatrix4(t.matrixWorld);s=e.ray.origin.distanceTo(Qe);return s<e.near||s>e.far?null:{distance:s,point:Qe.clone(),object:t}}function qe(t,n,e,i,r,a,o,s,h,l,c,u){Re.fromBufferAttribute(r,l),Ie.fromBufferAttribute(r,c),Oe.fromBufferAttribute(r,u);var f=t.morphTargetInfluences;if(n.morphTargets&&a&&f){Ge.set(0,0,0),ze.set(0,0,0),Be.set(0,0,0);for(var d=0,v=a.length;d<v;d++){var m=f[d],p=a[d];0!==m&&(Ue.fromBufferAttribute(p,l),He.fromBufferAttribute(p,c),Xe.fromBufferAttribute(p,u),o?(Ge.addScaledVector(Ue,m),ze.addScaledVector(He,m),Be.addScaledVector(Xe,m)):(Ge.addScaledVector(Ue.sub(Re),m),ze.addScaledVector(He.sub(Ie),m),Be.addScaledVector(Xe.sub(Oe),m)))}Re.add(Ge),Ie.add(ze),Oe.add(Be)}i=Ze(t,n,e,i,Re,Ie,Oe,je);return i&&(s&&(ke.fromBufferAttribute(s,l),Ve.fromBufferAttribute(s,c),Ye.fromBufferAttribute(s,u),i.uv=Pe.getUV(je,Re,Ie,Oe,ke,Ve,Ye,new ct)),h&&(ke.fromBufferAttribute(h,l),Ve.fromBufferAttribute(h,c),Ye.fromBufferAttribute(h,u),i.uv2=Pe.getUV(je,Re,Ie,Oe,ke,Ve,Ye,new ct)),h=new Fe(l,c,u),Pe.getNormal(Re,Ie,Oe,h.normal),i.face=h),i}function Ke(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}We.prototype=Object.assign(Object.create(Kt.prototype),{constructor:We,isMesh:!0,copy:function(t){return Kt.prototype.copy.call(this,t),void 0!==t.morphTargetInfluences&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),void 0!==t.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this},updateMorphTargets:function(){var t,n,e,i=this.geometry;if(i.isBufferGeometry){var r=i.morphAttributes,a=Object.keys(r);if(0<a.length){var o=r[a[0]];if(void 0!==o)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},t=0,n=o.length;t<n;t++)e=o[t].name||String(t),this.morphTargetInfluences.push(0),this.morphTargetDictionary[e]=t}}else{i=i.morphTargets;void 0!==i&&0<i.length&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}},raycast:function(t,n){var e=this.geometry,i=this.material,r=this.matrixWorld;if(void 0!==i&&(null===e.boundingSphere&&e.computeBoundingSphere(),Ce.copy(e.boundingSphere),Ce.applyMatrix4(r),!1!==t.ray.intersectsSphere(Ce)&&(Ne.getInverse(r),De.copy(t.ray).applyMatrix4(Ne),null===e.boundingBox||!1!==De.intersectsBox(e.boundingBox))))if(e.isBufferGeometry){var a,o,s,h,l,c,u,f,d,v=e.index,m=e.attributes.position,p=e.morphAttributes.position,g=e.morphTargetsRelative,_=e.attributes.uv,x=e.attributes.uv2,A=e.groups,w=e.drawRange;if(null!==v)if(Array.isArray(i))for(h=0,c=A.length;h<c;h++)for(d=i[(f=A[h]).materialIndex],l=Math.max(f.start,w.start),u=Math.min(f.start+f.count,w.start+w.count);l<u;l+=3)a=v.getX(l),o=v.getX(l+1),s=v.getX(l+2),(N=qe(this,d,t,De,m,p,g,_,x,a,o,s))&&(N.faceIndex=Math.floor(l/3),N.face.materialIndex=f.materialIndex,n.push(N));else for(h=Math.max(0,w.start),c=Math.min(v.count,w.start+w.count);h<c;h+=3)a=v.getX(h),o=v.getX(h+1),s=v.getX(h+2),(N=qe(this,i,t,De,m,p,g,_,x,a,o,s))&&(N.faceIndex=Math.floor(h/3),n.push(N));else if(void 0!==m)if(Array.isArray(i))for(h=0,c=A.length;h<c;h++)for(d=i[(f=A[h]).materialIndex],l=Math.max(f.start,w.start),u=Math.min(f.start+f.count,w.start+w.count);l<u;l+=3)(N=qe(this,d,t,De,m,p,g,_,x,a=l,o=l+1,s=l+2))&&(N.faceIndex=Math.floor(l/3),N.face.materialIndex=f.materialIndex,n.push(N));else for(h=Math.max(0,w.start),c=Math.min(m.count,w.start+w.count);h<c;h+=3)(N=qe(this,i,t,De,m,p,g,_,x,a=h,o=h+1,s=h+2))&&(N.faceIndex=Math.floor(h/3),n.push(N))}else if(e.isGeometry){var y,S=Array.isArray(i),b=e.vertices,M=e.faces,e=e.faceVertexUvs[0];0<e.length&&(y=e);for(var T=0,L=M.length;T<L;T++){var E,P,F,N,D=M[T],C=S?i[D.materialIndex]:i;void 0!==C&&(E=b[D.a],P=b[D.b],F=b[D.c],(N=Ze(this,C,t,De,E,P,F,je))&&(y&&y[T]&&(C=y[T],ke.copy(C[0]),Ve.copy(C[1]),Ye.copy(C[2]),N.uv=Pe.getUV(je,E,P,F,ke,Ve,Ye,new ct)),N.face=D,N.faceIndex=T,n.push(N)))}}},clone:function(){return new this.constructor(this.geometry,this.material).copy(this)}});var Je,$e,ti=function t(){Ke(this,t),this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1};function ni(t){Ke(this,ni),this.Y=new We($e,t)}Object.assign(ti.prototype,{setSize:function(){},render:function(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}),ti.FullScreenQuad=(Je=new de(-1,1,1,-1,0,1),$e=new ve(2,2),Object.defineProperty(ni.prototype,"material",{get:function(){return this.Y.material},set:function(t){this.Y.material=t}}),Object.assign(ni.prototype,{render:function(t){t.render(this.Y,Je)}}),ni);var ei={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","gl_FragColor = opacity * texel;","}"].join("\n")};function ii(t,n,e){this.width=t,this.height=n,this.scissor=new lt(0,0,t,n),this.scissorTest=!1,this.viewport=new lt(0,0,t,n),this.texture=new zn(void 0,(e=e||{}).mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.encoding),this.texture.image={},this.texture.image.width=t,this.texture.image.height=n,this.texture.generateMipmaps=void 0!==e.generateMipmaps&&e.generateMipmaps,this.texture.minFilter=void 0!==e.minFilter?e.minFilter:E,this.depthBuffer=void 0===e.depthBuffer||e.depthBuffer,this.stencilBuffer=void 0===e.stencilBuffer||e.stencilBuffer,this.depthTexture=void 0!==e.depthTexture?e.depthTexture:null}function ri(t){return(ri="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})(t)}function ai(t,n){return(ai=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}function oi(e){var i=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 t,n=si(e);return t=i?(t=si(this).constructor,Reflect.construct(n,arguments,t)):n.apply(this,arguments),n=this,!(t=t)||"object"!==ri(t)&&"function"!=typeof t?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(n):t}}function si(t){return(si=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}ii.prototype=Object.assign(Object.create(i.prototype),{constructor:ii,isWebGLRenderTarget:!0,setSize:function(t,n){this.width===t&&this.height===n||(this.width=t,this.height=n,this.texture.image.width=t,this.texture.image.height=n,this.dispose()),this.viewport.set(0,0,t,n),this.scissor.set(0,0,t,n)},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.width=t.width,this.height=t.height,this.viewport.copy(t.viewport),this.texture=t.texture.clone(),this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.depthTexture=t.depthTexture,this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var hi=function(){!function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),n&&ai(t,n)}(i,ti);var e=oi(i);function i(){var t;!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,i),(t=e.call(this)).renderTarget=new ii(1,1,{minFilter:E,magFilter:E,format:x}),t.compositeMaterial=t.getCompositeMaterial(t.nMips),void 0===ei&&console.error("RainPass relies on CopyShader");var n=ei;return t.copyUniforms=pn.clone(n.uniforms),t.copyUniforms.opacity.value=1,t.materialCopy=new xn({uniforms:t.copyUniforms,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,blending:u,depthTest:!1,depthWrite:!1,transparent:!0}),t.clearColor=new X(0,0,0),t.oldClearColor=new X,t.oldClearAlpha=1,t.basic=new Pn,t.basic.transparent=!0,t.fsQuad=new ti.FullScreenQuad(null),t}return i}();hi.prototype=Object.assign(Object.create(ti.prototype),{constructor:hi,dispose:function(){this.renderTarget.dispose()},setSize:function(t,n){t=Math.round(t/2),n=Math.round(n/2);this.renderTarget.setSize(t,n)},render:function(t,n,e,i,r){this.oldClearColor.copy(t.getClearColor()),this.oldClearAlpha=t.getClearAlpha();var a=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),r&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=e.texture,t.setRenderTarget(null),this.fsQuad.render(t)),this.fsQuad.material=this.compositeMaterial,t.setRenderTarget(this.renderTarget),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTarget.texture,r&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?t.setRenderTarget(null):t.setRenderTarget(e),this.fsQuad.render(t),t.setClearColor(this.oldClearColor,this.oldClearAlpha),t.autoClear=a},getCompositeMaterial:function(){return new xn({uniforms:{iTime:{value:0},rainSize:{value:.1},iResolution:{value:new ct(300,200)},iChannel3:{value:null}},vertexShader:"\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"\n                varying vec2 vUv;\n                uniform float iTime;\n                uniform float rainSize;\n                uniform vec2 iResolution;\n                uniform vec2 iMouse;\n                uniform sampler2D iChannel3;\n                uniform sampler2D tDiffuse;\n\n                void main() {\n                  float speed = fract(iTime);\n                  vec3 col = vec3(0.0, 0.0, 0.0);\n                  float aspect = iResolution.x / iResolution.y;\n\n                  // 屏幕uv 0~1\n                  vec2 q = gl_FragCoord.xy / iResolution.xy;\n                  q.x *= aspect;\n\n                  // 雨的倾斜方向, 1: 向右; -1:向左\n                  float rainDir = 1.;\n                  // 倾斜强度\n                  float tiltIntensity = 0.2;\n                  float offsetX = speed + q.y * rainDir * tiltIntensity;\n\n                  // 采样uv\n                  vec2 p = -1.0 + 2.0 * q;\n                  vec2 st = p * vec2(.5, 0.01) + vec2(offsetX, speed);\n\n                  // 整体透明度\n                  float opacity = .655;\n                  // 垂直竖线\n                  float f = texture2D(iChannel3, st).y;\n                  // 垂直竖线在水平方向上明暗变化\n                  f *= texture2D(iChannel3, st * 0.775).y;\n                  f *= opacity;\n\n                  col += f;\n                  col *= min(rainSize, 1.0);\n                  gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);\n                }\n                "})}});function li(t,n,e,i,r){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,li),ti.call(this),this.scene=t,this.camera=n,this.overrideMaterial=e,this.clearColor=i,this.clearAlpha=void 0!==r?r:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1}li.prototype=Object.assign(Object.create(ti.prototype),{constructor:li,setPass:function(t,n){this.scene=t,this.camera=n},render:function(t,n,e){var i,r,a=t.autoClear;t.autoClear=!1,this.scene.overrideMaterial=this.overrideMaterial,void 0!==this.clearColor&&(i=t.getClearColor().getHex(),r=t.getClearAlpha(),t.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&t.clearDepth(),t.setRenderTarget(this.renderToScreen?null:e),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),t.render(this.scene,this.camera),void 0!==this.clearColor&&t.setClearColor(i,r),this.scene.overrideMaterial=null,t.autoClear=a}});function ci(t,n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,ci),ti.call(this),this.textureID=void 0!==n?n:"tDiffuse",t instanceof xn?(this.uniforms=t.uniforms,this.material=t):t&&(this.uniforms=pn.clone(t.uniforms),this.material=new xn({defines:Object.assign({},t.defines),uniforms:this.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader})),this.fsQuad=new ti.FullScreenQuad(this.material)}function ui(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}ci.prototype=Object.assign(Object.create(ti.prototype),{constructor:ci,render:function(t,n,e){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=e.texture),this.fsQuad.material=this.material,this.renderToScreen?t.setRenderTarget(null):(t.setRenderTarget(n),this.clear&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil)),this.fsQuad.render(t)}});function fi(t,n){ui(this,fi),ti.call(this),this.scene=t,this.camera=n,this.clear=!0,this.needsSwap=!1,this.inverse=!1}fi.prototype=Object.assign(Object.create(ti.prototype),{constructor:fi,render:function(t,n,e){var i,r,a=t.getContext(),o=t.state;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0),r=this.inverse?(i=0,1):(i=1,0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(a.REPLACE,a.REPLACE,a.REPLACE),o.buffers.stencil.setFunc(a.ALWAYS,i,4294967295),o.buffers.stencil.setClear(r),t.setRenderTarget(e),this.clear&&t.clear(),t.render(this.scene,this.camera),t.setRenderTarget(n),this.clear&&t.clear(),t.render(this.scene,this.camera),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.stencil.setFunc(a.EQUAL,1,4294967295),o.buffers.stencil.setOp(a.KEEP,a.KEEP,a.KEEP)}});function di(){ui(this,di),ti.call(this),this.needsSwap=!1}function vi(t){this.autoStart=void 0===t||t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}function mi(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}di.prototype=Object.create(ti.prototype),Object.assign(di.prototype,{render:function(t){t.state.buffers.stencil.setTest(!1)}}),Object.assign(vi.prototype,{start:function(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1,this.autoStart=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var t,n=0;return this.autoStart&&!this.running?(this.start(),0):(this.running&&(n=((t=("undefined"==typeof performance?Date:performance).now())-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=n),n)}});function pi(t,n){var e,i;mi(this,pi),this.renderer=t,void 0===n?(e={minFilter:E,magFilter:E,format:x,stencilBuffer:!1},i=t.getSize(new ct),this.j=t.getPixelRatio(),this.Q=i.width,this.W=i.height,(n=new ii(this.Q*this.j,this.W*this.j,e)).texture.name="EffectComposer.rt1"):(this.j=1,this.Q=n.width,this.W=n.height),this.renderTarget1=n,this.renderTarget2=n.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],void 0===ei&&console.error("THREE.EffectComposer relies on CopyShader"),this.copyPass=new ci(ei),this.clock=new vi}Object.assign(pi.prototype,{swapBuffers:function(){var t=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=t},clearPass:function(){for(var t=0;t<this.passes.length;t++)this.passes[t].scene=null,this.passes[t].camera=null},addPass:function(t){this.passes.push(t),t.setSize(this.Q*this.j,this.W*this.j)},insertPass:function(t,n){this.passes.splice(n,0,t)},isLastEnabledPass:function(t){for(var n=t+1;n<this.passes.length;n++)if(this.passes[n].enabled)return!1;return!0},render:function(t){void 0===t&&(t=this.clock.getDelta());for(var n,e,i,r=this.renderer.getRenderTarget(),a=!1,o=this.passes.length,s=0;s<o;s++)!1!==(i=this.passes[s]).enabled&&(i.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(s),i.render(this.renderer,this.writeBuffer,this.readBuffer,t,a),i.needsSwap&&(a&&(n=this.renderer.getContext(),(e=this.renderer.state.buffers.stencil).setFunc(n.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,t),e.setFunc(n.EQUAL,1,4294967295)),this.swapBuffers()),i instanceof fi?a=!0:i instanceof di&&(a=!1));this.renderer.setRenderTarget(r)},reset:function(t){var n;void 0===t&&(n=this.renderer.getSize(new ct),this.j=this.renderer.getPixelRatio(),this.Q=n.width,this.W=n.height,(t=this.renderTarget1.clone()).setSize(this.Q*this.j,this.W*this.j)),this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=t,this.renderTarget2=t.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2},setSize:function(t,n){this.Q=t,this.W=n;var e=this.Q*this.j,i=this.W*this.j;this.renderTarget1.setSize(e,i),this.renderTarget2.setSize(e,i);for(var r=0;r<this.passes.length;r++)this.passes[r].setSize(e,i)},setPixelRatio:function(t){this.j=t,this.setSize(this.Q,this.W)}});var gi,_i,xi=function t(){mi(this,t),this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1};function Ai(t){mi(this,Ai),this.Y=new We(_i,t)}function wi(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.assign(xi.prototype,{setSize:function(){},render:function(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}),xi.FullScreenQuad=(gi=new de(-1,1,1,-1,0,1),_i=new ve(2,2),Object.defineProperty(Ai.prototype,"material",{get:function(){return this.Y.material},set:function(t){this.Y.material=t}}),Object.assign(Ai.prototype,{dispose:function(){this.Y.geometry.dispose()},render:function(t){t.render(this.Y,gi)}}),Ai);var yi=function(){function e(t,n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.R=t,this.Z=-1,this.q=-1,this.K=this.J(),this.G=this.G.bind(this),this.B(n)}var t,n,i;return t=e,(n=[{key:"getRaindrops",value:function(){return this.$}},{key:"setRaindrops",value:function(t){this.$=t}},{key:"getUrl",value:function(){return this.O}},{key:"setUrl",value:function(t){this.O=t,this.tt.compositeMaterial.uniforms.iChannel3.value=(new Bn).load(t,function(t){t.wrapS=1e3,t.wrapT=1e3,t.anisotropy=16,t.repeat.set(4,4)})}},{key:"enable",value:function(){(this.R.getRenderManager().rain=this).R.on("beforeRender",this.G)}},{key:"disable",value:function(){this.R.getRenderManager().rain=null,this.R.off("beforeRender",this.G),this.G()}},{key:"dispose",value:function(){this.disable(),this.tt.dispose(),this.P.dispose(),this.tt=null,this.P=null,this.nt=null,this.et=null}},{key:"render",value:function(){this.it(),this.rt+=.05,this.tt.compositeMaterial.uniforms.iTime.value=this.rt,this.tt.compositeMaterial.uniforms.rainSize.value=this.$,this.nt.render()}}])&&wi(t.prototype,n),i&&wi(t,i),e}();Object.assign(yi.prototype,{G:function(){this.R.enableUpdateRender()},J:function(){return"basic"===this.R.getRenderManager().type&&this.R.setRenderManager(new se),this.R.getRenderManager()},B:function(t){this.O=t.url,this.tt=new hi,this.P=new he,this.et=new li(this.P,this.R.camera),this.et.clear=!1,this.nt=new pi(this.K.renderer),this.nt.addPass(this.et),this.nt.addPass(this.tt),this.setUrl(this.O),this.tt.compositeMaterial.uniforms.iTime.value=.2,this.tt.compositeMaterial.uniforms.iResolution.value=new ct(60,60),this.rt=.6,this.$=t.raindrops},it:function(){var t,n,e;this.nt&&(t=(e=this.nt.renderer.domElement).clientWidth,n=e.clientHeight,e=!1,this.Z!=t&&(e=!0,this.Z=t),this.q!=n&&(e=!0,this.q=n),e&&this.tt&&this.nt.setSize(this.Z,this.q))}});var Si=yi,bi=0,Mi=new Dt,Ti=new Kt,Li=new Q;function Ei(){Object.defineProperty(this,"id",{value:bi+=2}),this.uuid=C.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}function Pi(t){return(Pi="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})(t)}function Fi(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function Ni(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),n&&Di(t,n)}function Di(t,n){return(Di=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}function Ci(e){var i=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 t,n=Ii(e);return t=i?(t=Ii(this).constructor,Reflect.construct(n,arguments,t)):n.apply(this,arguments),n=this,!(t=t)||"object"!==Pi(t)&&"function"!=typeof t?Ri(n):t}}function Ri(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Ii(t){return(Ii=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}Ei.prototype=Object.assign(Object.create(i.prototype),{constructor:Ei,isGeometry:!0,applyMatrix4:function(t){for(var n=(new Ut).getNormalMatrix(t),e=0,i=this.vertices.length;e<i;e++)this.vertices[e].applyMatrix4(t);for(e=0,i=this.faces.length;e<i;e++){var r=this.faces[e];r.normal.applyMatrix3(n).normalize();for(var a=0,o=r.vertexNormals.length;a<o;a++)r.vertexNormals[a].applyMatrix3(n).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(t){return Mi.makeRotationX(t),this.applyMatrix4(Mi),this},rotateY:function(t){return Mi.makeRotationY(t),this.applyMatrix4(Mi),this},rotateZ:function(t){return Mi.makeRotationZ(t),this.applyMatrix4(Mi),this},translate:function(t,n,e){return Mi.makeTranslation(t,n,e),this.applyMatrix4(Mi),this},scale:function(t,n,e){return Mi.makeScale(t,n,e),this.applyMatrix4(Mi),this},lookAt:function(t){return Ti.lookAt(t),Ti.updateMatrix(),this.applyMatrix4(Ti.matrix),this},fromBufferGeometry:function(t){var a=this,n=null!==t.index?t.index.array:void 0,e=t.attributes;if(void 0===e.position)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;var i=e.position.array,o=void 0!==e.normal?e.normal.array:void 0,s=void 0!==e.color?e.color.array:void 0,h=void 0!==e.uv?e.uv.array:void 0,l=void 0!==e.uv2?e.uv2.array:void 0;void 0!==l&&(this.faceVertexUvs[1]=[]);for(var r=0;r<i.length;r+=3)a.vertices.push((new Q).fromArray(i,r)),void 0!==s&&a.colors.push((new X).fromArray(s,r));function c(t,n,e,i){var r=void 0===s?[]:[a.colors[t].clone(),a.colors[n].clone(),a.colors[e].clone()],i=new Fe(t,n,e,void 0===o?[]:[(new Q).fromArray(o,3*t),(new Q).fromArray(o,3*n),(new Q).fromArray(o,3*e)],r,i);a.faces.push(i),void 0!==h&&a.faceVertexUvs[0].push([(new ct).fromArray(h,2*t),(new ct).fromArray(h,2*n),(new ct).fromArray(h,2*e)]),void 0!==l&&a.faceVertexUvs[1].push([(new ct).fromArray(l,2*t),(new ct).fromArray(l,2*n),(new ct).fromArray(l,2*e)])}var u=t.groups;if(0<u.length)for(r=0;r<u.length;r++)for(var f=u[r],d=f.start,v=d,m=d+f.count;v<m;v+=3)void 0!==n?c(n[v],n[v+1],n[v+2],f.materialIndex):c(v,v+1,v+2,f.materialIndex);else if(void 0!==n)for(r=0;r<n.length;r+=3)c(n[r],n[r+1],n[r+2]);else for(r=0;r<i.length/3;r+=3)c(r,r+1,r+2);return this.computeFaceNormals(),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(Li).negate(),this.translate(Li.x,Li.y,Li.z),this},normalize:function(){this.computeBoundingSphere();var t=this.boundingSphere.center,n=this.boundingSphere.radius,e=0===n?1:1/n,n=new Dt;return n.set(e,0,0,-e*t.x,0,e,0,-e*t.y,0,0,e,-e*t.z,0,0,0,1),this.applyMatrix4(n),this},computeFaceNormals:function(){for(var t=new Q,n=new Q,e=0,i=this.faces.length;e<i;e++){var r=this.faces[e],a=this.vertices[r.a],o=this.vertices[r.b],s=this.vertices[r.c];t.subVectors(s,o),n.subVectors(a,o),t.cross(n),t.normalize(),r.normal.copy(t)}},computeVertexNormals:function(t){var n,e,i;for(void 0===t&&(t=!0),i=new Array(this.vertices.length),n=0,e=this.vertices.length;n<e;n++)i[n]=new Q;if(t)for(var r,a,o,s=new Q,h=new Q,l=0,c=this.faces.length;l<c;l++)u=this.faces[l],r=this.vertices[u.a],a=this.vertices[u.b],o=this.vertices[u.c],s.subVectors(o,a),h.subVectors(r,a),s.cross(h),i[u.a].add(s),i[u.b].add(s),i[u.c].add(s);else for(this.computeFaceNormals(),l=0,c=this.faces.length;l<c;l++)i[(u=this.faces[l]).a].add(u.normal),i[u.b].add(u.normal),i[u.c].add(u.normal);for(n=0,e=this.vertices.length;n<e;n++)i[n].normalize();for(l=0,c=this.faces.length;l<c;l++){var u,f=(u=this.faces[l]).vertexNormals;3===f.length?(f[0].copy(i[u.a]),f[1].copy(i[u.b]),f[2].copy(i[u.c])):(f[0]=i[u.a].clone(),f[1]=i[u.b].clone(),f[2]=i[u.c].clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var t,n;for(this.computeFaceNormals(),t=0,n=this.faces.length;t<n;t++){var e,i=(e=this.faces[t]).vertexNormals;3===i.length?(i[0].copy(e.normal),i[1].copy(e.normal),i[2].copy(e.normal)):(i[0]=e.normal.clone(),i[1]=e.normal.clone(),i[2]=e.normal.clone())}0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var t,n,e;for(o=0,s=this.faces.length;o<s;o++)for((e=this.faces[o]).ot?e.ot.copy(e.normal):e.ot=e.normal.clone(),e.st||(e.st=[]),t=0,n=e.vertexNormals.length;t<n;t++)e.st[t]?e.st[t].copy(e.vertexNormals[t]):e.st[t]=e.vertexNormals[t].clone();var i=new Ei;for(i.faces=this.faces,t=0,n=this.morphTargets.length;t<n;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];for(var r=this.morphNormals[t].faceNormals,a=this.morphNormals[t].vertexNormals,o=0,s=this.faces.length;o<s;o++)h=new Q,l={a:new Q,b:new Q,c:new Q},r.push(h),a.push(l)}var h,l,c=this.morphNormals[t];for(i.vertices=this.morphTargets[t].vertices,i.computeFaceNormals(),i.computeVertexNormals(),o=0,s=this.faces.length;o<s;o++)e=this.faces[o],h=c.faceNormals[o],l=c.vertexNormals[o],h.copy(e.normal),l.a.copy(e.vertexNormals[0]),l.b.copy(e.vertexNormals[1]),l.c.copy(e.vertexNormals[2])}for(o=0,s=this.faces.length;o<s;o++)(e=this.faces[o]).normal=e.ot,e.vertexNormals=e.st},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new st),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new St),this.boundingSphere.setFromPoints(this.vertices)},mergeVertices:function(){for(var t,n,e,i,r={},a=[],o=[],s=Math.pow(10,4),h=0,l=this.vertices.length;h<l;h++)t=this.vertices[h],void 0===r[t=Math.round(t.x*s)+"_"+Math.round(t.y*s)+"_"+Math.round(t.z*s)]?(r[t]=h,a.push(this.vertices[h]),o[h]=a.length-1):o[h]=o[r[t]];var c=[];for(h=0,l=this.faces.length;h<l;h++){(n=this.faces[h]).a=o[n.a],n.b=o[n.b],n.c=o[n.c];for(var u=[n.a,n.b,n.c],f=0;f<3;f++)if(u[f]===u[(f+1)%3]){c.push(h);break}}for(h=c.length-1;0<=h;h--){var d=c[h];for(this.faces.splice(d,1),e=0,i=this.faceVertexUvs.length;e<i;e++)this.faceVertexUvs[e].splice(d,1)}var v=this.vertices.length-a.length;return this.vertices=a,v},setFromPoints:function(t){this.vertices=[];for(var n=0,e=t.length;n<e;n++){var i=t[n];this.vertices.push(new Q(i.x,i.y,i.z||0))}return this},sortFacesByMaterialIndex:function(){for(var t=this.faces,n=t.length,e=0;e<n;e++)t[e].ht=e;t.sort(function(t,n){return t.materialIndex-n.materialIndex});var i,r,a=this.faceVertexUvs[0],o=this.faceVertexUvs[1];a&&a.length===n&&(i=[]),o&&o.length===n&&(r=[]);for(e=0;e<n;e++){var s=t[e].ht;i&&i.push(a[s]),r&&r.push(o[s])}i&&(this.faceVertexUvs[0]=i),r&&(this.faceVertexUvs[1]=r)},dispose:function(){this.dispatchEvent({type:"dispose"})}});var Oi=function(){Ni(l,on);var h=Ci(l);function l(t,n,e,i,r,a){var o;Fi(this,l),(o=h.call(this)).type="BoxBufferGeometry",o.parameters={width:t,height:n,depth:e,widthSegments:i,heightSegments:r,depthSegments:a};var L=Ri(o);t=t||1,n=n||1,e=e||1,i=Math.floor(i)||1,r=Math.floor(r)||1,a=Math.floor(a)||1;var E=[],P=[],F=[],N=[],D=0,C=0;function s(t,n,e,i,r,a,o,s,h,l,c){for(var u=a/h,f=o/l,d=a/2,v=o/2,m=s/2,p=h+1,g=l+1,_=0,x=0,A=new Q,w=0;w<g;w++)for(var y=w*f-v,S=0;S<p;S++)A[t]=(S*u-d)*i,A[n]=y*r,A[e]=m,P.push(A.x,A.y,A.z),A[t]=0,A[n]=0,A[e]=0<s?1:-1,F.push(A.x,A.y,A.z),N.push(S/h),N.push(1-w/l),_+=1;for(w=0;w<l;w++)for(S=0;S<h;S++){var b=D+S+p*(w+1),M=D+(S+1)+p*(w+1),T=D+(S+1)+p*w;E.push(D+S+p*w,b,T),E.push(b,M,T),x+=6}L.addGroup(C,x,c),C+=x,D+=_}return s("z","y","x",-1,-1,e,n,t,a,r,0),s("z","y","x",1,-1,e,n,-t,a,r,1),s("x","z","y",1,1,t,e,n,i,a,2),s("x","z","y",1,-1,t,e,-n,i,a,3),s("x","y","z",1,-1,t,n,e,i,r,4),s("x","y","z",-1,-1,t,n,-e,i,r,5),o.setIndex(E),o.setAttribute("position",new At(P,3)),o.setAttribute("normal",new At(F,3)),o.setAttribute("uv",new At(N,2)),o}return l}();function Ui(){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,Ui);var t=new xn({fragmentShader:(t=Ui.SkyShader).fragmentShader,vertexShader:t.vertexShader,uniforms:pn.clone(t.uniforms),side:l});We.call(this,new Oi(1,1,1),t)}function Hi(t,n,e,i,r,a,o){Ei.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:n,heightSegments:e,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},this.fromBufferGeometry(new Xi(t,n,e,i,r,a,o)),this.mergeVertices()}function Xi(t,n,e,i,r,a,o){on.call(this),this.type="SphereBufferGeometry",this.parameters={radius:t,widthSegments:n,heightSegments:e,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},t=t||1,n=Math.max(3,Math.floor(n)||8),e=Math.max(2,Math.floor(e)||6),i=void 0!==i?i:0,r=void 0!==r?r:2*Math.PI,a=void 0!==a?a:0,o=void 0!==o?o:Math.PI;for(var s,h=Math.min(a+o,Math.PI),l=0,c=[],u=new Q,f=new Q,d=[],v=[],m=[],p=[],g=0;g<=e;g++){var _=[],x=g/e,A=0;for(0==g&&0==a?A=.5/n:g==e&&h==Math.PI&&(A=-.5/n),s=0;s<=n;s++){var w=s/n;u.x=-t*Math.cos(i+w*r)*Math.sin(a+x*o),u.y=t*Math.cos(a+x*o),u.z=t*Math.sin(i+w*r)*Math.sin(a+x*o),v.push(u.x,u.y,u.z),f.copy(u).normalize(),m.push(f.x,f.y,f.z),p.push(w+A,1-x),_.push(l++)}c.push(_)}for(g=0;g<e;g++)for(s=0;s<n;s++){var y=c[g][s+1],S=c[g][s],b=c[g+1][s],M=c[g+1][s+1];(0!==g||0<a)&&d.push(y,S,M),(g!==e-1||h<Math.PI)&&d.push(S,b,M)}this.setIndex(d),this.setAttribute("position",new At(v,3)),this.setAttribute("normal",new At(m,3)),this.setAttribute("uv",new At(p,2))}function Gi(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Ui.prototype=Object.create(We.prototype),Ui.SkyShader={uniforms:{luminance:{value:1},turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new Q},up:{value:new Q(0,1,0)}},vertexShader:["uniform vec3 sunPosition;","uniform float rayleigh;","uniform float turbidity;","uniform float mieCoefficient;","uniform vec3 up;","varying vec3 vWorldPosition;","varying vec3 vSunDirection;","varying float vSunFade;","varying vec3 vBetaR;","varying vec3 vBetaM;","varying float vSunE;","const float e = 2.71828182845904523536028747135266249775724709369995957;","const float pi = 3.141592653589793238462643383279502884197169;","const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );","const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );","const float v = 4.0;","const vec3 K = vec3( 0.686, 0.678, 0.666 );","const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );","const float cutoffAngle = 1.6110731556870734;","const float steepness = 1.5;","const float EE = 1000.0;","float sunIntensity( float zenithAngleCos ) {","\tzenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );","\treturn EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );","}","vec3 totalMie( float T ) {","\tfloat c = ( 0.2 * T ) * 10E-18;","\treturn 0.434 * c * MieConst;","}","void main() {","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tvWorldPosition = worldPosition.xyz;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","\tgl_Position.z = gl_Position.w;","\tvSunDirection = normalize( sunPosition );","\tvSunE = sunIntensity( dot( vSunDirection, up ) );","\tvSunFade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );","\tfloat rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunFade ) );","\tvBetaR = totalRayleigh * rayleighCoefficient;","\tvBetaM = totalMie( turbidity ) * mieCoefficient;","}"].join("\n"),fragmentShader:["varying vec3 vWorldPosition;","varying vec3 vSunDirection;","varying float vSunFade;","varying vec3 vBetaR;","varying vec3 vBetaM;","varying float vSunE;","uniform float luminance;","uniform float mieDirectionalG;","uniform vec3 up;","const vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );","const float pi = 3.141592653589793238462643383279502884197169;","const float n = 1.0003;","const float N = 2.545E25;","const float rayleighZenithLength = 8.4E3;","const float mieZenithLength = 1.25E3;","const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;","const float THREE_OVER_SIXTEENPI = 0.05968310365946075;","const float ONE_OVER_FOURPI = 0.07957747154594767;","float rayleighPhase( float cosTheta ) {","\treturn THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );","}","float hgPhase( float cosTheta, float g ) {","\tfloat g2 = pow( g, 2.0 );","\tfloat inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );","\treturn ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );","}","const float A = 0.15;","const float B = 0.50;","const float C = 0.10;","const float D = 0.20;","const float E = 0.02;","const float F = 0.30;","const float whiteScale = 1.0748724675633854;","vec3 Uncharted2Tonemap( vec3 x ) {","\treturn ( ( x * ( A * x + C * B ) + D * E ) / ( x * ( A * x + B ) + D * F ) ) - E / F;","}","void main() {","\tfloat zenithAngle = acos( max( 0.0, dot( up, normalize( vWorldPosition - cameraPos ) ) ) );","\tfloat inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );","\tfloat sR = rayleighZenithLength * inverse;","\tfloat sM = mieZenithLength * inverse;","\tvec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );","\tfloat cosTheta = dot( normalize( vWorldPosition - cameraPos ), vSunDirection );","\tfloat rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );","\tvec3 betaRTheta = vBetaR * rPhase;","\tfloat mPhase = hgPhase( cosTheta, mieDirectionalG );","\tvec3 betaMTheta = vBetaM * mPhase;","\tvec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );","\tLin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );","\tvec3 direction = normalize( vWorldPosition - cameraPos );","\tfloat theta = acos( direction.y ); // elevation --\x3e y-axis, [-pi/2, pi/2]","\tfloat phi = atan( direction.z, direction.x ); // azimuth --\x3e x-axis [-pi/2, pi/2]","\tvec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );","\tvec3 L0 = vec3( 0.1 ) * Fex;","\tfloat sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );","\tL0 += ( vSunE * 19000.0 * Fex ) * sundisk;","\tvec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );","\tvec3 curr = Uncharted2Tonemap( ( log2( 2.0 / pow( luminance, 4.0 ) ) ) * texColor );","\tvec3 color = curr * whiteScale;","\tvec3 retColor = pow( color, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunFade ) ) ) );","\tgl_FragColor = vec4( retColor, 1.0 );","}"].join("\n")},(Hi.prototype=Object.create(Ei.prototype)).constructor=Hi,(Xi.prototype=Object.create(on.prototype)).constructor=Xi;var zi=function(){function n(t){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),this.R=t,this.P=new he,this.lt=null,this.ct=null,this.ct={turbidity:10,rayleigh:3,mieCoefficient:.005,mieDirectionalG:.7,luminance:1,inclination:.49,azimuth:.25,scale:500},this.ut=4e5,this.ft=0,this.dt=1,this.B(),this.k()}var t,e,i;return t=n,(e=[{key:"getState",value:function(){var t=this.sky.material.uniforms;return{turbidity:t.turbidity.value,rayleigh:t.rayleigh.value,luminance:t.luminance.value,scale:this.sky.scale.x}}},{key:"setState",value:function(t){t.scale&&this.sky.scale.setScalar(t.scale);var n=this.sky.material.uniforms;n.turbidity.value=("number"==typeof t.turbidity?t:this.ct).turbidity,n.rayleigh.value=("number"==typeof t.rayleigh?t:this.ct).rayleigh,n.luminance.value=("number"==typeof t.luminance?t:this.ct).luminance,this.vt(this.ct.inclination)}},{key:"enable",value:function(){(this.R.getRenderManager().sky=this).R.enableUpdateNode()}},{key:"disable",value:function(){this.R.getRenderManager().sky=null,this.R.enableUpdateNode()}},{key:"setTime",value:function(t){t=(t-6)/12;1<t&&(t-=2),this.vt(t)}},{key:"autoTime",value:function(){}},{key:"render",value:function(){this.R.getRenderManager().renderer.render(this.P,this.R.camera)}}])&&Gi(t.prototype,e),i&&Gi(t,i),n}();Object.assign(zi.prototype,{B:function(){this.sky=new Ui,this.sky.scale.setScalar(this.ct.scale),this.P.add(this.sky),this.lt=new We(new Xi(2e4,16,8),new Pn({color:16777215})),this.lt.position.y=-7e5,this.lt.visible=!0,this.P.add(this.lt),this.setState(this.ct)},k:function(){"basic"===this.R.getRenderManager().type&&this.R.setRenderManager(new se)},vt:function(t){var n=this.sky.material.uniforms,e=Math.PI*(t+1),t=2*Math.PI*(this.ct.azimuth-.5);this.lt.position.z=this.ut*Math.cos(t),this.lt.position.y=this.ut*Math.sin(t)*Math.sin(e),this.lt.position.x=this.ut*Math.sin(t)*Math.cos(e),n.sunPosition.value=this.lt.position,this.R.enableUpdateRender()}});var Bi=zi,ki={common:{diffuse:{value:new X(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Ut},uv2Transform:{value:new Ut},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},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 ct(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 X(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new X(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ut}},sprite:{diffuse:{value:new X(15658734)},opacity:{value:1},center:{value:new ct(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},uvTransform:{value:new Ut}}},Vi={alphamap_fragment:"\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n\n#endif\n",alphamap_pars_fragment:"\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n",alphatest_fragment:"\n#ifdef ALPHATEST\n\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n\n#endif\n",aomap_fragment:"\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\n\t#endif\n\n#endif\n",aomap_pars_fragment:"\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n\n#ifdef USE_TANGENT\n\n\tvec3 objectTangent = vec3( tangent.xyz );\n\n#endif\n",bsdfs:'\n\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via \'environmentBRDF\' from "Physically Based Shading on Mobile"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\n\tvec4 r = roughness * c0 + c1;\n\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n\n}\n\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\n\t// based upon Frostbite 3 Moving to Physically-based Rendering\n\t// page 32, equation 26: E[window1]\n\t// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t// this is intended to be used on spot and point lights who are represented as luminous intensity\n\t// but who must be converted to luminous irradiance for surface lighting calculation\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\n\tif( cutoffDistance > 0.0 ) {\n\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\n\t}\n\n\treturn distanceFalloff;\n\n#else\n\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\n\t}\n\n\treturn 1.0;\n\n#endif\n\n}\n\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\n\treturn RECIPROCAL_PI * diffuseColor;\n\n} // validated\n\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\n\t// Original approximation by Christophe Schlick \'94\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\n\n\t// Optimized variant (presented by Epic at SIGGRAPH \'13)\n\t// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n\n} // validated\n\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\n\t// See F_Schlick\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\n\treturn Fr * fresnel + F0;\n\n}\n\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney’s reparameterization\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\t// geometry term (normalized) = G(l)⋅G(v) / 4(n⋅l)(n⋅v)\n\t// also see #12151\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\n\treturn 1.0 / ( gl * gv );\n\n} // validated\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\tfloat a2 = pow2( alpha );\n\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\n\treturn 0.5 / max( gv + gl, EPSILON );\n\n}\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney’s reparameterization\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n\n}\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat alpha = pow2( roughness ); // UE4\'s roughness\n\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\n\tfloat D = D_GGX( alpha, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// Rect Area Light\n\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\n// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt\n// code: https://github.com/selfshadow/ltc_code/\n\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\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\n\tfloat dotNV = saturate( dot( N, V ) );\n\n\t// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\treturn uv;\n\n}\n\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\n\t// Real-Time Area Lighting: a Journey from Research to Production (p.102)\n\t// An approximation of the form factor of a horizon-clipped rectangle.\n\n\tfloat l = length( f );\n\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n\n}\n\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\n\tfloat x = dot( v1, v2 );\n\n\tfloat y = abs( x );\n\n\t// rational polynomial approximation to theta / sin( theta ) / 2PI\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\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\n\treturn cross( v1, v2 ) * theta_sintheta;\n\n}\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\n\t// bail if point is on back side of plane of light\n\t// assumes ccw winding order of light vertices\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\n\t// construct orthonormal basis around N\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system\n\n\t// compute transform\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\n\t// transform rect\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\n\t// project rect onto sphere\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\n\t// calculate vector form factor\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\n\t// adjust for horizon clipping\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\n/*\n\t// alternate method of adjusting for horizon clipping (see referece)\n\t// refactoring required\n\tfloat len = length( vectorFormFactor );\n\tfloat z = vectorFormFactor.z / len;\n\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\n\t// tabulated horizon-clipped sphere, apparently...\n\tvec2 uv = vec2( z * 0.5 + 0.5, len );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\tfloat scale = texture2D( ltc_2, uv ).w;\n\n\tfloat result = len * scale;\n*/\n\n\treturn vec3( result );\n\n}\n\n// End Rect Area Light\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\n\treturn specularColor * brdf.x + brdf.y;\n\n} // validated\n\n// Fdez-Agüera\'s "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21\n\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n\n}\n\nfloat G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\n\n\t// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\n\treturn 0.25;\n\n}\n\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n\n}\n\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\n\t//float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\t//float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\n\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\n\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n\n#if defined( USE_SHEEN )\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L94\nfloat D_Charlie(float roughness, float NoH) {\n\t// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF"\n\tfloat invAlpha  = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L136\nfloat V_Neubelt(float NoV, float NoL) {\n\t// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\n\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n\n}\n\n#endif\n',bumpmap_pars_fragment:"\n#ifdef USE_BUMPMAP\n\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\n\t// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen\n\t// http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf\n\n\t// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\n\n\tvec2 dHdxy_fwd() {\n\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\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\n\t\treturn vec2( dBx, dBy );\n\n\t}\n\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\t\t// normalized\n\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\n\t}\n\n#endif\n",clipping_planes_fragment:"\n#if NUM_CLIPPING_PLANES > 0\n\n\tvec4 plane;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\n\t\tbool clipped = true;\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t\tif ( clipped ) discard;\n\n\t#endif\n\n#endif\n",clipping_planes_pars_fragment:"\n#if NUM_CLIPPING_PLANES > 0\n\n\tvarying vec3 vClipPosition;\n\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n\n#endif\n",clipping_planes_pars_vertex:"\n#if NUM_CLIPPING_PLANES > 0\n\n\tvarying vec3 vClipPosition;\n\n#endif\n",clipping_planes_vertex:"\n#if NUM_CLIPPING_PLANES > 0\n\n\tvClipPosition = - mvPosition.xyz;\n\n#endif\n",color_fragment:"\n#ifdef USE_COLOR\n\n\tdiffuseColor.rgb *= vColor;\n\n#endif\n",color_pars_fragment:"\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n",color_pars_vertex:"\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n",color_vertex:"\n#ifdef USE_COLOR\n\n\tvColor.xyz = color.xyz;\n\n#endif\n",common:"\n#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n\n#ifndef saturate\n// <tonemapping_pars_fragment> may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\n\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\n// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.\n// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\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\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\n\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\n\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n}\n\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t// dir can be either a direction vector or a normal vector\n\t// upper-left 3x3 of matrix is assumed to be orthogonal\n\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n\n}\n\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\n\treturn - distance * planeNormal + point;\n\n}\n\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n\n}\n\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n\n}\n\nmat3 transposeMat3( const in mat3 m ) {\n\n\tmat3 tmp;\n\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\n\treturn tmp;\n\n}\n\n// https://en.wikipedia.org/wiki/Relative_luminance\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\n\treturn dot( weights, color.rgb );\n\n}\n\nbool isPerspectiveMatrix( mat4 m ) {\n\n  return m[ 2 ][ 3 ] == - 1.0;\n\n}\n",cube_uv_reflection_fragment:"\n#ifdef ENVMAP_TYPE_CUBE_UV\n\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\n\n// These shader functions convert between the UV coordinates of a single face of\n// a cubemap, the 0-5 integer index of a cube face, and the direction vector for\n// sampling a textureCube (not generally normalized).\n\nfloat getFace(vec3 direction) {\n    vec3 absDirection = abs(direction);\n    float face = -1.0;\n    if (absDirection.x > absDirection.z) {\n      if (absDirection.x > absDirection.y)\n        face = direction.x > 0.0 ? 0.0 : 3.0;\n      else\n        face = direction.y > 0.0 ? 1.0 : 4.0;\n    } else {\n      if (absDirection.z > absDirection.y)\n        face = direction.z > 0.0 ? 2.0 : 5.0;\n      else\n        face = direction.y > 0.0 ? 1.0 : 4.0;\n    }\n    return face;\n}\n\nvec2 getUV(vec3 direction, float face) {\n    vec2 uv;\n    if (face == 0.0) {\n      uv = vec2(-direction.z, direction.y) / abs(direction.x);\n    } else if (face == 1.0) {\n      uv = vec2(direction.x, -direction.z) / abs(direction.y);\n    } else if (face == 2.0) {\n      uv = direction.xy / abs(direction.z);\n    } else if (face == 3.0) {\n      uv = vec2(direction.z, direction.y) / abs(direction.x);\n    } else if (face == 4.0) {\n      uv = direction.xz / abs(direction.y);\n    } else {\n      uv = vec2(-direction.x, direction.y) / abs(direction.z);\n    }\n    return 0.5 * (uv + 1.0);\n}\n\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n  float face = getFace(direction);\n  float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n  mipInt = max(mipInt, cubeUV_minMipLevel);\n  float faceSize = exp2(mipInt);\n\n  float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n\n  vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n  vec2 f = fract(uv);\n  uv += 0.5 - f;\n  if (face > 2.0) {\n    uv.y += faceSize;\n    face -= 3.0;\n  }\n  uv.x += face * faceSize;\n  if(mipInt < cubeUV_maxMipLevel){\n    uv.y += 2.0 * cubeUV_maxTileSize;\n  }\n  uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n  uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n  uv *= texelSize;\n\n  vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n  uv.x += texelSize;\n  vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n  uv.y += texelSize;\n  vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n  uv.x -= texelSize;\n  vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n  vec3 tm = mix(tl, tr, f.x);\n  vec3 bm = mix(bl, br, f.x);\n  return mix(tm, bm, f.y);\n}\n\n// These defines must match with PMREMGenerator\n\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\n\nfloat roughnessToMip(float roughness) {\n  float mip = 0.0;\n  if (roughness >= r1) {\n    mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n  } else if (roughness >= r4) {\n    mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n  } else if (roughness >= r5) {\n    mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n  } else if (roughness >= r6) {\n    mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n  } else {\n    mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n  }\n  return mip;\n}\n\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n  float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n  float mipF = fract(mip);\n  float mipInt = floor(mip);\n\n  vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n  if (mipF == 0.0) {\n    return vec4(color0, 1.0);\n  } else {\n    vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n    return vec4(mix(color0, color1, mipF), 1.0);\n  }\n}\n#endif\n",defaultnormal_vertex:"\nvec3 transformedNormal = objectNormal;\n\n#ifdef USE_INSTANCING\n\n\t// this is in lieu of a per-instance normal-matrix\n\t// shear transforms in the instance matrix are not supported\n\n\tmat3 m = mat3( instanceMatrix );\n\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\n\ttransformedNormal = m * transformedNormal;\n\n#endif\n\ntransformedNormal = normalMatrix * transformedNormal;\n\n#ifdef FLIP_SIDED\n\n\ttransformedNormal = - transformedNormal;\n\n#endif\n\n#ifdef USE_TANGENT\n\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#ifdef FLIP_SIDED\n\n\t\ttransformedTangent = - transformedTangent;\n\n\t#endif\n\n#endif\n",displacementmap_pars_vertex:"\n#ifdef USE_DISPLACEMENTMAP\n\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n\n#endif\n",displacementmap_vertex:"\n#ifdef USE_DISPLACEMENTMAP\n\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n\n#endif\n",emissivemap_fragment:"\n#ifdef USE_EMISSIVEMAP\n\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n\n#endif\n",emissivemap_pars_fragment:"\n#ifdef USE_EMISSIVEMAP\n\n\tuniform sampler2D emissiveMap;\n\n#endif\n",encodings_fragment:"\ngl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\n// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/\n\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\n\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\n\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\n\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\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}\n\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\n\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n//  return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\n\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\n\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\t// NOTE: The implementation with min causes the shader to not compile on\n\t// a common Alcatel A502DL in Chrome 78/Android 8.1. Some research suggests \n\t// that the chipset is Mediatek MT6739 w/ IMG PowerVR GE8100 GPU.\n\t// D = min( floor( D ) / 255.0, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\n\n// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html\n\n// M matrix, for encoding\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value )  {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\n\n// Inverse M matrix, for decoding\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}\n",envmap_fragment:"\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t}  else {\n\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\n\t\t}\n\n\t\t// Transforming Normal Vectors with the Inverse Transformation\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\n\t\t#else\n\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#else\n\n\t\tvec3 reflectVec = vReflect;\n\n\t#endif\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\tvec2 sampleUV;\n\n\t\treflectVec = normalize( reflectVec );\n\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\n\t\treflectVec = normalize( reflectVec );\n\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\n\t#else\n\n\t\tvec4 envColor = vec4( 0.0 );\n\n\t#endif\n\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\n\t\tenvColor = envMapTexelToLinear( envColor );\n\n\t#endif\n\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\n\t#endif\n\n#endif\n",envmap_common_pars_fragment:"\n#ifdef USE_ENVMAP\n\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\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\n",envmap_pars_fragment:"\n#ifdef USE_ENVMAP\n\n\tuniform float reflectivity;\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n\n#endif\n",envmap_pars_vertex:"\n#ifdef USE_ENVMAP\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\n\t#else\n\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\n\t#endif\n\n#endif\n",envmap_physical_pars_fragment:"\n#if defined( USE_ENVMAP )\n\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\n\tvec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {\n\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\n\t\t\t// TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level\n\t\t\t// of a specular cubemap, or just the default level of a specially created irradiance cubemap.\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#else\n\n\t\t\t\t// force the bias high to get the last LOD level as it is the most blurred.\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\n\t\t#else\n\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\n\t\t#endif\n\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\n\t}\n\n\t// Trowbridge-Reitz distribution to Mip level, following the logic of http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\n\t\t// clamp to allowable LOD ranges.\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\n\t}\n\n\tvec3 getLightProbeIndirectRadiance( /*const in SpecularLightProbe specularLightProbe,*/ const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t  vec3 reflectVec = reflect( -viewDir, normal );\n\n\t\t  // Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.\n\t\t  reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\n\t\t#else\n\n\t\t  vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\n\t\t#endif\n\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#endif\n\n\t\treturn envMapColor.rgb * envMapIntensity;\n\n\t}\n\n#endif\n",envmap_vertex:"\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvWorldPosition = worldPosition.xyz;\n\n\t#else\n\n\t\tvec3 cameraToVertex;\n\n\t\tif ( isOrthographic ) { \n\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\n\t\t}\n\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\n\t\t#else\n\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n",fog_vertex:"\n#ifdef USE_FOG\n\n\tfogDepth = -mvPosition.z;\n\n#endif\n",fog_pars_vertex:"\n#ifdef USE_FOG\n\n\tvarying float fogDepth;\n\n#endif\n",fog_fragment:"\n#ifdef USE_FOG\n\n\t#ifdef FOG_EXP2\n\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\n\t#else\n\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\n\t#endif\n\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n\n#endif\n",fog_pars_fragment:"\n#ifdef USE_FOG\n\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\n\t#ifdef FOG_EXP2\n\n\t\tuniform float fogDensity;\n\n\t#else\n\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\n\t#endif\n\n#endif\n",gradientmap_pars_fragment:"\n\n#ifdef USE_GRADIENTMAP\n\n\tuniform sampler2D gradientMap;\n\n#endif\n\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\n\t// dotNL will be from -1.0 to 1.0\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\n\t#ifdef USE_GRADIENTMAP\n\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\n\t#else\n\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\n\t#endif\n\n}\n\n",lightmap_fragment:"\n#ifdef USE_LIGHTMAP\n\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage\n\n#endif\n",lightmap_pars_fragment:"\n#ifdef USE_LIGHTMAP\n\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n\n#endif\n",lights_lambert_vertex:"\nvec3 diffuse = vec3( 1.0 );\n\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\n\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\n\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\n\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n\n#if NUM_POINT_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_SPOT_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n/*\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\t// TODO (abelnation): implement\n\n\t}\n\n#endif\n*/\n\n#if NUM_DIR_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_HEMI_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n",lights_pars_begin:"\nuniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\n\n// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\n\t// normal is assumed to have unit length\n\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\n\t// band 0\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\n\t// band 1\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\n\t// band 2\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\n\treturn result;\n\n}\n\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\n\treturn irradiance;\n\n}\n\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\n\tvec3 irradiance = ambientLightColor;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI;\n\n\t#endif\n\n\treturn irradiance;\n\n}\n\n#if NUM_DIR_LIGHTS > 0\n\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\n\t}\n\n#endif\n\n\n#if NUM_POINT_LIGHTS > 0\n\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\n\t}\n\n#endif\n\n\n#if NUM_SPOT_LIGHTS > 0\n\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\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight  ) {\n\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\n\t\tif ( angleCos > spotLight.coneCos ) {\n\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\n\t\t} else {\n\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\n\t\t}\n\t}\n\n#endif\n\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\n\t// Pre-computed values of LinearTransformedCosine approximation of BRDF\n\t// BRDF approximation Texture is 64x64\n\tuniform sampler2D ltc_1; // RGBA Float\n\tuniform sampler2D ltc_2; // RGBA Float\n\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n\n#endif\n\n\n#if NUM_HEMI_LIGHTS > 0\n\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tirradiance *= PI;\n\n\t\t#endif\n\n\t\treturn irradiance;\n\n\t}\n\n#endif\n",lights_toon_fragment:"\nToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_toon_pars_fragment:"\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct ToonMaterial {\n\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n\n};\n\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n\n}\n\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n\n#define Material_LightProbeLOD( material )\t(0)\n",lights_phong_fragment:"\nBlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct BlinnPhongMaterial {\n\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n\n};\n\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n\n}\n\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n\n#define Material_LightProbeLOD( material )\t(0)\n",lights_physical_fragment:"\nPhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\n\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\n\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n\n#ifdef REFLECTIVITY\n\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\n#else\n\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n\n#endif\n\n#ifdef CLEARCOAT\n\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\n\t#ifdef USE_CLEARCOATMAP\n\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\n\t#endif\n\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\n\t#endif\n\n\tmaterial.clearcoat = saturate( material.clearcoat ); // Burley clearcoat model\n\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n\n#endif\n\n#ifdef USE_SHEEN\n\n\tmaterial.sheenColor = sheen;\n\n#endif\n",lights_physical_pars_fragment:"\nstruct PhysicalMaterial {\n\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n\n};\n\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\n\n// Clear coat directional hemishperical reflectance (this approximation should be improved)\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n\n}\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\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.specularRoughness;\n\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction\n\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\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\n\t\t// LTC Fresnel Approximation by Stephen Hill\n\t\t// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\n\t}\n\n#endif\n\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tccIrradiance *= PI; // punctual light\n\n\t\t#endif\n\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\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\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\n\t// Both indirect specular and indirect diffuse light accumulate here\n\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\n}\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\n\n// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n\n}\n",lights_fragment_begin:"\n/**\n * This is a template that can be used to light a material, it uses pluggable\n * RenderEquations (RE)for specific lighting scenarios.\n *\n * Instructions for use:\n * - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined\n * - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???\n * - Create a material parameter that is to be passed as the third parameter to your lighting functions.\n *\n * TODO:\n * - Add area light support.\n * - Add sphere light support.\n * - Add diffuse light probe (irradiance cubemap) support.\n */\n\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n\tgeometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\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\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\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\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",lights_fragment_maps:"\n#if defined( RE_IndirectDiffuse )\n\n\t#ifdef USE_LIGHTMAP\n\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tlightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage\n\n\t\t#endif\n\n\t\tirradiance += lightMapIrradiance;\n\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );\n\n\t#endif\n\n#endif\n\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\n\tradiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\n\t#ifdef CLEARCOAT\n\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\n\t#endif\n\n#endif\n",lights_fragment_end:"\n#if defined( RE_IndirectDiffuse )\n\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n\n#endif\n",logdepthbuf_fragment:"\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\t// Doing a strict comparison with == 1.0 can cause noise artifacts\n\t// on some platforms. See issue #17623.\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n\n#endif\n",logdepthbuf_pars_fragment:"\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n\n#endif\n",logdepthbuf_pars_vertex:"\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\n\t#else\n\n\t\tuniform float logDepthBufFC;\n\n\t#endif\n\n#endif\n",logdepthbuf_vertex:"\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\n\t#else\n\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\n\t\t\tgl_Position.z *= gl_Position.w;\n\n\t\t}\n\n\t#endif\n\n#endif\n",map_fragment:"\n#ifdef USE_MAP\n\n\tvec4 texelColor = texture2D( map, vUv );\n\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n\n#endif\n",map_fragment_1:"\n#ifdef USE_MAP\n\n\tvec4 texelColor = texture2D( map, vUv );\n\n\ttexelColor = mapTexelToLinear( texelColor );\n\t\n\tif(mapMixColor){\n\t    diffuseColor = texelColor*texelColor.a + diffuseColor*(1.0-texelColor.a);\n\t}else {\n\t    diffuseColor *= texelColor;\n\t}\n\n#endif\n",map_pars_fragment:"\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n",map_particle_fragment:"\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_MAP\n\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n\n#endif\n",map_particle_pars_fragment:"\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tuniform mat3 uvTransform;\n\n#endif\n\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n",metalnessmap_fragment:"\nfloat metalnessFactor = metalness;\n\n#ifdef USE_METALNESSMAP\n\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\n\t// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tmetalnessFactor *= texelMetalness.b;\n\n#endif\n",metalnessmap_pars_fragment:"\n#ifdef USE_METALNESSMAP\n\n\tuniform sampler2D metalnessMap;\n\n#endif\n",morphnormal_vertex:"\n#ifdef USE_MORPHNORMALS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\n#endif\n",morphtarget_pars_vertex:"\n#ifdef USE_MORPHTARGETS\n\n\tuniform float morphTargetBaseInfluence;\n\n\t#ifndef USE_MORPHNORMALS\n\n\tuniform float morphTargetInfluences[ 8 ];\n\n\t#else\n\n\tuniform float morphTargetInfluences[ 4 ];\n\n\t#endif\n\n#endif\n",morphtarget_vertex:"\n#ifdef USE_MORPHTARGETS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\n\t#ifndef USE_MORPHNORMALS\n\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\n\t#endif\n\n#endif\n",normal_fragment_begin:"\n#ifdef FLAT_SHADED\n\n\t// Workaround for Adreno/Nexus5 not able able to do dFdx( vViewPosition ) ...\n\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n\n#else\n\n\tvec3 normal = normalize( vNormal );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\t#ifdef USE_TANGENT\n\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\t#endif\n\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n\n// non perturbed normal for clearcoat among others\n\nvec3 geometryNormal = normal;\n\n",normal_fragment_maps:"\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n\t#ifdef FLIP_SIDED\n\n\t\tnormal = - normal;\n\n\t#endif\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\tnormal = normalize( normalMatrix * normal );\n\n#elif defined( TANGENTSPACE_NORMALMAP )\n\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tnormal = normalize( vTBN * mapN );\n\n\t#else\n\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\n\t#endif\n\n#elif defined( USE_BUMPMAP )\n\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n\n#endif\n",normalmap_pars_fragment:"\n#ifdef USE_NORMALMAP\n\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\n#endif\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tuniform mat3 normalMatrix;\n\n#endif\n\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\n\t// Per-Pixel Tangent Space Normal Mapping\n\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude\n\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\n\t\tmat3 tsn = mat3( S, T, N );\n\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\treturn normalize( tsn * mapN );\n\n\t}\n\n#endif\n",clearcoat_normal_fragment_begin:"\n#ifdef CLEARCOAT\n\n\tvec3 clearcoatNormal = geometryNormal;\n\n#endif\n",clearcoat_normal_fragment_maps:"\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\n\t#else\n\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\n\t#endif\n\n#endif\n",clearcoat_pars_fragment:"\n\n#ifdef USE_CLEARCOATMAP\n\n\tuniform sampler2D clearcoatMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\tuniform sampler2D clearcoatRoughnessMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n\n#endif\n",packing:"\nvec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\n\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\n\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\n\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256.,  256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\n\nconst float ShiftRight8 = 1. / 256.;\n\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8; // tidy overflow\n\treturn r * PackUpscale;\n}\n\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\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}\n\n// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions\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}\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}\n",premultiplied_alpha_fragment:"\n#ifdef PREMULTIPLIED_ALPHA\n\n\t// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.\n\tgl_FragColor.rgb *= gl_FragColor.a;\n\n#endif\n",project_vertex:"\nvec4 mvPosition = vec4( transformed, 1.0 );\n\n#ifdef USE_INSTANCING\n\n\tmvPosition = instanceMatrix * mvPosition;\n\n#endif\n\nmvPosition = modelViewMatrix * mvPosition;\n\ngl_Position = projectionMatrix * mvPosition;\n",dithering_fragment:"\n#ifdef DITHERING\n\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n\n#endif\n",dithering_pars_fragment:"\n#ifdef DITHERING\n\n\t// based on https://www.shadertoy.com/view/MslGR8\n\tvec3 dithering( vec3 color ) {\n\t\t//Calculate grid position\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\n\t\t//Shift the individual colors differently, thus making it even harder to see the dithering pattern\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\n\t\t//modify shift acording to grid position.\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\n\t\t//shift the color by dither_shift\n\t\treturn color + dither_shift_RGB;\n\t}\n\n#endif\n",roughnessmap_fragment:"\nfloat roughnessFactor = roughness;\n\n#ifdef USE_ROUGHNESSMAP\n\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\n\t// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\troughnessFactor *= texelRoughness.g;\n\n#endif\n",roughnessmap_pars_fragment:"\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform sampler2D roughnessMap;\n\n#endif\n",shadowmap_pars_fragment:"\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): create uniforms for area light shadows\n\n\t#endif\n\t*/\n\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\n\t}\n\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\n\t}\n\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\n\t\tfloat occlusion = 1.0;\n\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\n\t\tfloat hard_shadow = step( compare , distribution.x ); // Hard Shadow\n\n\t\tif (hard_shadow != 1.0 ) {\n\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 ); // Chebeyshevs inequality\n\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed\n\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\n\t\t}\n\t\treturn occlusion;\n\n\t}\n\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\n\t\tfloat shadow = 1.0;\n\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\n\t\t// if ( something && something ) breaks ATI OpenGL shader compiler\n\t\t// if ( all( something, something ) ) using this instead\n\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\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n\t\tbool frustumTest = all( frustumTestVec );\n\n\t\tif ( frustumTest ) {\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\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\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\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\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\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#else // no percentage-closer filtering:\n\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#endif\n\n\t\t}\n\n\t\treturn shadow;\n\n\t}\n\n\t// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D\n\t// vector suitable for 2D texture mapping. This code uses the following layout for the\n\t// 2D texture:\n\t//\n\t// xzXZ\n\t//  y Y\n\t//\n\t// Y - Positive y direction\n\t// y - Negative y direction\n\t// X - Positive x direction\n\t// x - Negative x direction\n\t// Z - Positive z direction\n\t// z - Negative z direction\n\t//\n\t// Source and test bed:\n\t// https://gist.github.com/tschw/da10c43c467ce8afd0c4\n\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\n\t\t// Number of texels to avoid at the edge of each square\n\n\t\tvec3 absV = abs( v );\n\n\t\t// Intersect unit cube\n\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\n\t\t// Apply scale to avoid seams\n\n\t\t// two texels less per square (one texel will do for NEAREST)\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\n\t\t// Unwrap\n\n\t\t// space: -1 ... 1 range for each square\n\t\t//\n\t\t// #X##\t\tdim    := ( 4 , 2 )\n\t\t//  # #\t\tcenter := ( 1 , 1 )\n\n\t\tvec2 planar = v.xy;\n\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\n\t\tif ( absV.z >= almostOne ) {\n\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\n\t\t} else if ( absV.x >= almostOne ) {\n\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\n\t\t} else if ( absV.y >= almostOne ) {\n\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\n\t\t}\n\n\t\t// Transform to UV space\n\n\t\t// scale := 0.5 / dim\n\t\t// translate := ( center + 0.5 ) / dim\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\n\t}\n\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\n\t\t// for point lights, the uniform @vShadowCoord is re-purposed to hold\n\t\t// the vector from the light to the world-space position of the fragment.\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\n\t\t// dp = normalized distance from light to fragment position\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?\n\t\tdp += shadowBias;\n\n\t\t// bd3D = base direction 3D\n\t\tvec3 bd3D = normalize( lightToPosition );\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\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\n\t\t#else // no percentage-closer filtering\n\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\n\t\t#endif\n\n\t}\n\n#endif\n",shadowmap_pars_vertex:"\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): uniforms for area light shadows\n\n\t#endif\n\t*/\n\n#endif\n",shadowmap_vertex:"\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update vAreaShadowCoord with area light info\n\n\t#endif\n\t*/\n\n#endif\n",shadowmask_pars_fragment:"\nfloat getShadowMask() {\n\n\tfloat shadow = 1.0;\n\n\t#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\tDirectionalLightShadow directionalLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\tSpotLightShadow spotLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\tPointLightShadow pointLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\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\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update shadow for Area light\n\n\t#endif\n\t*/\n\n\t#endif\n\n\treturn shadow;\n\n}\n",skinbase_vertex:"\n#ifdef USE_SKINNING\n\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\n#endif\n",skinning_pars_vertex:"\n#ifdef USE_SKINNING\n\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\n\t#ifdef BONE_TEXTURE\n\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\n\t\t\ty = dy * ( y + 0.5 );\n\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\n\t\t\treturn bone;\n\n\t\t}\n\n\t#else\n\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\n\t\t}\n\n\t#endif\n\n#endif\n",skinning_vertex:"\n#ifdef USE_SKINNING\n\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\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\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n\n#endif\n",skinnormal_vertex:"\n#ifdef USE_SKINNING\n\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\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\n\t#ifdef USE_TANGENT\n\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#endif\n\n#endif\n",specularmap_fragment:"\nfloat specularStrength;\n\n#ifdef USE_SPECULARMAP\n\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n\n#else\n\n\tspecularStrength = 1.0;\n\n#endif\n",specularmap_pars_fragment:"\n#ifdef USE_SPECULARMAP\n\n\tuniform sampler2D specularMap;\n\n#endif\n",tonemapping_fragment:"\n#if defined( TONE_MAPPING )\n\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n\n#endif\n",tonemapping_pars_fragment:"\n#ifndef saturate\n// <common> may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\n\n// exposure only\nvec3 LinearToneMapping( vec3 color ) {\n\n\treturn toneMappingExposure * color;\n\n}\n\n// source: https://www.cs.utah.edu/~reinhard/cdrom/\nvec3 ReinhardToneMapping( vec3 color ) {\n\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n\n}\n\n// source: http://filmicgames.com/archives/75\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\n\t// John Hable's filmic operator from Uncharted 2 video game\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n\n}\n\n// source: http://filmicgames.com/archives/75\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\n\t// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson\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\n}\n\n// source: https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n\n}\n",uv_pars_fragment:"\n#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\n\tvarying vec2 vUv;\n\n#endif\n",uv_pars_vertex:"\n#ifdef USE_UV\n\n\t#ifdef UVS_VERTEX_ONLY\n\n\t\tvec2 vUv;\n\n\t#else\n\n\t\tvarying vec2 vUv;\n\n\t#endif\n\n\tuniform mat3 uvTransform;\n\n#endif\n",uv_vertex:"\n#ifdef USE_UV\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n#endif\n",uv2_pars_fragment:"\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvarying vec2 vUv2;\n\n#endif\n",uv2_pars_vertex:"\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\n\tuniform mat3 uv2Transform;\n\n#endif\n",uv2_vertex:"\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n\n#endif\n",worldpos_vertex:"\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t#ifdef USE_INSTANCING\n\n\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t#endif\n\n\tworldPosition = modelMatrix * worldPosition;\n\n#endif\n",background_frag:"\nuniform sampler2D t2D;\n\nvarying vec2 vUv;\n\nvoid main() {\n\n\tvec4 texColor = texture2D( t2D, vUv );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\n}\n",background_vert:"\nvarying vec2 vUv;\nuniform mat3 uvTransform;\n\nvoid main() {\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n\n}\n",cube_frag:"\n\n#include <envmap_common_pars_fragment>\nuniform float opacity;\n\nvarying vec3 vWorldDirection;\n\n#include <cube_uv_reflection_fragment>\n\nvoid main() {\n\n\tvec3 vReflect = vWorldDirection;\n\t#include <envmap_fragment>\n\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\n}\n",cube_vert:"\nvarying vec3 vWorldDirection;\n\n#include <common>\n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\n\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n}\n",depth_frag:"\n#if DEPTH_PACKING == 3200\n\n\tuniform float opacity;\n\n#endif\n\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tdiffuseColor.a = opacity;\n\n\t#endif\n\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\n\t#include <logdepthbuf_fragment>\n\n\t// Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values.\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\n\t#elif DEPTH_PACKING == 3201\n\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\n\t#endif\n\n}\n",depth_vert:"\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 <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n\n\t#include <uv_vertex>\n\n\t#include <skinbase_vertex>\n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\n\t#endif\n\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\n\tvHighPrecisionZW = gl_Position.zw;\n\n}\n",distanceRGBA_frag:"\n#define DISTANCE\n\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main () {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist ); // clamp to [ 0, 1 ]\n\n\tgl_FragColor = packDepthToRGBA( dist );\n\n}\n",distanceRGBA_vert:"\n#define DISTANCE\n\nvarying vec3 vWorldPosition;\n\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>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\n\t#include <skinbase_vertex>\n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\n\t#endif\n\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\n\tvWorldPosition = worldPosition.xyz;\n\n}\n",equirect_frag:"\nuniform sampler2D tEquirect;\n\nvarying vec3 vWorldDirection;\n\n#include <common>\n\nvoid main() {\n\n\tvec3 direction = normalize( vWorldDirection );\n\n\tvec2 sampleUV;\n\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\n}\n",equirect_vert:"\nvarying vec3 vWorldDirection;\n\n#include <common>\n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\n}\n",linedashed_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\nuniform float dashSize;\nuniform float totalSize;\n\nvarying float vLineDistance;\n\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\n\t\tdiscard;\n\n\t}\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\n\toutgoingLight = diffuseColor.rgb; // simple shader\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\n}\n",linedashed_vert:"\nuniform float scale;\nattribute float lineDistance;\n\nvarying float vLineDistance;\n\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\tvLineDistance = scale * lineDistance;\n\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\n}\n",meshbasic_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include <common>\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 <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\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\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\n\t// accumulation (baked indirect lighting only)\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\n\t#endif\n\n\t// modulation\n\t#include <aomap_fragment>\n\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\n\t#include <envmap_fragment>\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\n}\n",meshbasic_vert:"\n#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>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\n\t#ifdef USE_ENVMAP\n\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\n\t#endif\n\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\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n\n}\n",meshlambert_frag:"\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n\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 <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 <cube_uv_reflection_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\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\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 <emissivemap_fragment>\n\n\t// accumulation\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\n\t#endif\n\n\t#include <lightmap_fragment>\n\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\n\t#else\n\n\t\treflectedLight.directDiffuse = vLightFront;\n\n\t#endif\n\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\n\t// modulation\n\t#include <aomap_fragment>\n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n\t#include <envmap_fragment>\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\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}\n",meshlambert_vert:"\n#define LAMBERT\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_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>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\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\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\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}\n",meshmatcap_frag:"\n#define MATCAP\n\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\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\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; // 0.495 to remove artifacts caused by undersized matcap disks\n\n\t#ifdef USE_MATCAP\n\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\n\t#else\n\n\t\tvec4 matcapColor = vec4( 1.0 );\n\n\t#endif\n\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\n}\n",meshmatcap_vert:"\n#define MATCAP\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\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 <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\t#include <color_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\n\t#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\t\tvNormal = normalize( transformedNormal );\n\n\t#endif\n\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\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\n\tvViewPosition = - mvPosition.xyz;\n\n}\n",meshtoon_frag:"\n#define TOON\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n\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 <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 <lights_toon_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>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\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\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\n\t// accumulation\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\n\t// modulation\n\t#include <aomap_fragment>\n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\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\n}\n",meshtoon_vert:"\n#define TOON\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\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 <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\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\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\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\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n\n}\n",meshphong_frag:"\n#define PHONG\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n\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 <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 <cube_uv_reflection_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\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>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\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\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\n\t// accumulation\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\n\t// modulation\n\t#include <aomap_fragment>\n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t#include <envmap_fragment>\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\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\n}\n",meshphong_vert:"\n#define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\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 <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\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\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\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\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n\n}\n",meshphysical_frag:"\n#define STANDARD\n\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\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 <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\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 <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\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\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\n\t// accumulation\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\n\t// modulation\n\t#include <aomap_fragment>\n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t// this is a stub for the transparency model\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\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\n}\n",meshphysical_vert:"\n#define STANDARD\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\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 <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\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\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\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\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n\n}\n",normal_frag:"\n#define NORMAL\n\nuniform float opacity;\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\n}\n",normal_vert:"\n#define NORMAL\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\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 <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\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\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\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\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvViewPosition = - mvPosition.xyz;\n\n#endif\n\n}\n",points_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\n}\n",points_vert:"\nuniform float size;\nuniform float scale;\n\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\n\tgl_PointSize = size;\n\n\t#ifdef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\n\t#endif\n\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n\n}\n",shadow_frag:"\nuniform vec3 color;\nuniform float opacity;\n\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>\n\nvoid main() {\n\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\n}\n",shadow_vert:"\n#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\n\nvoid main() {\n\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n\n}\n",sprite_frag:"\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\t#include <clipping_planes_fragment>\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\n}\n",sprite_vert:"\nuniform float rotation;\nuniform vec2 center;\n\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#include <uv_vertex>\n\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\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\n\t#ifndef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\n\t#endif\n\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\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\n\tmvPosition.xy += rotatedPosition;\n\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\n}\n"};function Yi(t,n,e,i){fe.call(this),this.type="PerspectiveCamera",this.fov=void 0!==t?t:50,this.zoom=1,this.near=void 0!==e?e:.1,this.far=void 0!==i?i:2e3,this.focus=10,this.aspect=void 0!==n?n:1,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}Yi.prototype=Object.assign(Object.create(fe.prototype),{constructor:Yi,isPerspectiveCamera:!0,copy:function(t,n){return fe.prototype.copy.call(this,t,n),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:function(t){t=.5*this.getFilmHeight()/t;this.fov=2*C.RAD2DEG*Math.atan(t),this.updateProjectionMatrix()},getFocalLength:function(){var t=Math.tan(.5*C.DEG2RAD*this.fov);return.5*this.getFilmHeight()/t},getEffectiveFOV:function(){return 2*C.RAD2DEG*Math.atan(Math.tan(.5*C.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(t,n,e,i,r,a){this.aspect=t/n,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=n,this.view.offsetX=e,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()},updateProjectionMatrix:function(){var t,n=this.near,e=n*Math.tan(.5*C.DEG2RAD*this.fov)/this.zoom,i=2*e,r=this.aspect*i,a=-.5*r,o=this.view;null!==this.view&&this.view.enabled&&(t=o.fullWidth,s=o.fullHeight,a+=o.offsetX*r/t,e-=o.offsetY*i/s,r*=o.width/t,i*=o.height/s);var s=this.filmOffset;0!==s&&(a+=n*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+r,e,e-i,n,this.far),this.projectionMatrixInverse.getInverse(this.projectionMatrix)}});function ji(t,n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,ji),We.call(this,t);var o=this,e=void 0!==(n=n||{}).textureWidth?n.textureWidth:512,i=void 0!==n.textureHeight?n.textureHeight:512,s=void 0!==n.clipBias?n.clipBias:0,r=void 0!==n.alpha?n.alpha:1,a=void 0!==n.time?n.time:0,h=void 0!==n.waterNormals?n.waterNormals:null,l=void 0!==n.sunDirection?n.sunDirection:new Q(.70707,.70707,0),c=new X(void 0!==n.sunColor?n.sunColor:16777215),u=new X(void 0!==n.waterColor?n.waterColor:8355711),f=void 0!==n.eye?n.eye:new Q(0,0,0),d=void 0!==n.distortionScale?n.distortionScale:20,t=void 0!==n.side?n.side:L,n=void 0!==n.fog&&n.fog,v=new _e,m=new Q,p=new Q,g=new Q,_=new Dt,x=new Q(0,0,-1),A=new lt,w=new Q,y=new Q,S=new lt,b=new Dt,M=new Yi,T=new ii(e,i,{minFilter:E,magFilter:E,format:P,stencilBuffer:!1});C.isPowerOfTwo(e)&&C.isPowerOfTwo(i)||(T.texture.generateMipmaps=!1),i={uniforms:pn.merge([ki.fog,ki.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new Dt},sunColor:{value:new X(8355711)},sunDirection:{value:new Q(.70707,.70707,0)},eye:{value:new Q},waterColor:{value:new X(5592405)}}]),vertexShader:["uniform mat4 textureMatrix;","uniform float time;","varying vec4 mirrorCoord;","varying vec4 worldPosition;",Vi.fog_pars_vertex,Vi.shadowmap_pars_vertex,"void main() {","\tmirrorCoord = modelMatrix * vec4( position, 1.0 );","\tworldPosition = mirrorCoord.xyzw;","\tmirrorCoord = textureMatrix * mirrorCoord;","\tvec4 mvPosition =  modelViewMatrix * vec4( position, 1.0 );","\tgl_Position = projectionMatrix * mvPosition;",Vi.fog_vertex,Vi.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform sampler2D mirrorSampler;","uniform float alpha;","uniform float time;","uniform float size;","uniform float distortionScale;","uniform sampler2D normalSampler;","uniform vec3 sunColor;","uniform vec3 sunDirection;","uniform vec3 eye;","uniform vec3 waterColor;","varying vec4 mirrorCoord;","varying vec4 worldPosition;","vec4 getNoise( vec2 uv ) {","\tvec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);","\tvec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );","\tvec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );","\tvec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );","\tvec4 noise = texture2D( normalSampler, uv0 ) +","\t\ttexture2D( normalSampler, uv1 ) +","\t\ttexture2D( normalSampler, uv2 ) +","\t\ttexture2D( normalSampler, uv3 );","\treturn noise * 0.5 - 1.0;","}","void sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {","\tvec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );","\tfloat direction = max( 0.0, dot( eyeDirection, reflection ) );","\tspecularColor += pow( direction, shiny ) * sunColor * spec;","\tdiffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;","}",Vi.common,Vi.packing,Vi.bsdfs,Vi.fog_pars_fragment,Vi.lights_pars_begin,Vi.shadowmap_pars_fragment,Vi.shadowmask_pars_fragment,"void main() {","\tvec4 noise = getNoise( worldPosition.xz * size );","\tvec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );","\tvec3 diffuseLight = vec3(0.0);","\tvec3 specularLight = vec3(0.0);","\tvec3 worldToEye = eye-worldPosition.xyz;","\tvec3 eyeDirection = normalize( worldToEye );","\tsunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );","\tfloat distance = length(worldToEye);","\tvec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;","\tvec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );","\tfloat theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );","\tfloat rf0 = 0.3;","\tfloat reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );","\tvec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;","\tvec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);","\tvec3 outgoingLight = albedo;","\tgl_FragColor = vec4( outgoingLight, alpha );",Vi.tonemapping_fragment,Vi.fog_fragment,"}"].join("\n")},(n=new xn({fragmentShader:i.fragmentShader,vertexShader:i.vertexShader,uniforms:pn.clone(i.uniforms),lights:!0,side:t,fog:n})).uniforms.mirrorSampler.value=T.texture,n.uniforms.textureMatrix.value=b,n.uniforms.alpha.value=r,n.uniforms.time.value=a,n.uniforms.normalSampler.value=h,n.uniforms.sunColor.value=c,n.uniforms.waterColor.value=u,n.uniforms.sunDirection.value=l,n.uniforms.distortionScale.value=d,n.uniforms.eye.value=f,o.material=n,o.onBeforeRender=function(t,n,e){var i,r,a;p.setFromMatrixPosition(o.matrixWorld),g.setFromMatrixPosition(e.matrixWorld),_.extractRotation(o.matrixWorld),m.set(0,0,1),m.applyMatrix4(_),w.subVectors(p,g),0<w.dot(m)||(w.reflect(m).negate(),w.add(p),_.extractRotation(e.matrixWorld),x.set(0,0,-1),x.applyMatrix4(_),x.add(g),y.subVectors(p,x),y.reflect(m).negate(),y.add(p),M.position.copy(w),M.up.set(0,1,0),M.up.applyMatrix4(_),M.up.reflect(m),M.lookAt(y),M.far=e.far,M.updateMatrixWorld(),M.projectionMatrix.copy(e.projectionMatrix),b.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),b.multiply(M.projectionMatrix),b.multiply(M.matrixWorldInverse),v.setFromNormalAndCoplanarPoint(m,p),v.applyMatrix4(M.matrixWorldInverse),A.set(v.normal.x,v.normal.y,v.normal.z,v.constant),a=M.projectionMatrix,S.x=(Math.sign(A.x)+a.elements[8])/a.elements[0],S.y=(Math.sign(A.y)+a.elements[9])/a.elements[5],S.z=-1,S.w=(1+a.elements[10])/a.elements[14],A.multiplyScalar(2/A.dot(S)),a.elements[2]=A.x,a.elements[6]=A.y,a.elements[10]=A.z+1-s,a.elements[14]=A.w,f.setFromMatrixPosition(e.matrixWorld),i=t.getRenderTarget(),r=t.xr.enabled,a=t.shadowMap.autoUpdate,o.visible=!1,t.xr.enabled=!1,t.shadowMap.autoUpdate=!1,t.setRenderTarget(T),!1===t.autoClear&&t.clear(),t.render(n,M),o.visible=!0,t.xr.enabled=r,t.shadowMap.autoUpdate=a,t.setRenderTarget(i),void 0!==(e=e.viewport)&&t.state.viewport(e))}}function Qi(){this.type="Curve",this.arcLengthDivisions=200}function Wi(t,n,e,i,r,a,o,s){Qi.call(this),this.type="EllipseCurve",this.aX=t||0,this.aY=n||0,this.xRadius=e||1,this.yRadius=i||1,this.aStartAngle=r||0,this.aEndAngle=a||2*Math.PI,this.aClockwise=o||!1,this.aRotation=s||0}function Zi(t,n,e,i,r,a){Wi.call(this,t,n,e,e,i,r,a),this.type="ArcCurve"}function qi(){var r=0,a=0,o=0,s=0;function h(t,n,e,i){o=-3*(r=t)+3*n-2*(a=e)-i,s=2*t-2*n+e+i}return{initCatmullRom:function(t,n,e,i,r){h(n,e,r*(e-t),r*(i-n))},initNonuniformCatmullRom:function(t,n,e,i,r,a,o){r=(n-t)/r-(e-t)/(r+a)+(e-n)/a,o=(e-n)/a-(i-n)/(a+o)+(i-e)/o;h(n,e,r*=a,o*=a)},calc:function(t){var n=t*t;return r+a*t+o*n+s*(n*t)}}}(ji.prototype=Object.create(We.prototype)).constructor=ji,Object.assign(Qi.prototype,{getPoint:function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},getPointAt:function(t,n){t=this.getUtoTmapping(t);return this.getPoint(t,n)},getPoints:function(t){void 0===t&&(t=5);for(var n=[],e=0;e<=t;e++)n.push(this.getPoint(e/t));return n},getSpacedPoints:function(t){void 0===t&&(t=5);for(var n=[],e=0;e<=t;e++)n.push(this.getPointAt(e/t));return n},getLength:function(){var t=this.getLengths();return t[t.length-1]},getLengths:function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var n,e,i=[],r=this.getPoint(0),a=0;for(i.push(0),e=1;e<=t;e++)a+=(n=this.getPoint(e/t)).distanceTo(r),i.push(a),r=n;return this.cacheArcLengths=i},updateArcLengths:function(){this.needsUpdate=!0,this.getLengths()},getUtoTmapping:function(t,n){for(var e,i=this.getLengths(),r=0,a=i.length,o=n||t*i[a-1],s=0,h=a-1;s<=h;)if((e=i[r=Math.floor(s+(h-s)/2)]-o)<0)s=r+1;else{if(!(0<e)){h=r;break}h=r-1}if(i[r=h]===o)return r/(a-1);t=i[r];return(r+(o-t)/(i[r+1]-t))/(a-1)},getTangent:function(t){var n=t-1e-4,t=t+1e-4;1<t&&(t=1);n=this.getPoint(n=n<0?0:n);return this.getPoint(t).clone().sub(n).normalize()},getTangentAt:function(t){t=this.getUtoTmapping(t);return this.getTangent(t)},computeFrenetFrames:function(t,n){for(var e,i=new Q,r=[],a=[],o=[],s=new Q,h=new Dt,l=0;l<=t;l++)r[l]=this.getTangentAt(l/t),r[l].normalize();a[0]=new Q,o[0]=new Q;var c=Number.MAX_VALUE,u=Math.abs(r[0].x),f=Math.abs(r[0].y),d=Math.abs(r[0].z);for(u<=c&&(c=u,i.set(1,0,0)),f<=c&&(c=f,i.set(0,1,0)),d<=c&&i.set(0,0,1),s.crossVectors(r[0],i).normalize(),a[0].crossVectors(r[0],s),o[0].crossVectors(r[0],a[0]),l=1;l<=t;l++)a[l]=a[l-1].clone(),o[l]=o[l-1].clone(),s.crossVectors(r[l-1],r[l]),s.length()>Number.EPSILON&&(s.normalize(),e=Math.acos(C.clamp(r[l-1].dot(r[l]),-1,1)),a[l].applyMatrix4(h.makeRotationAxis(s,e))),o[l].crossVectors(r[l],a[l]);if(!0===n)for(e=Math.acos(C.clamp(a[0].dot(a[t]),-1,1)),e/=t,0<r[0].dot(s.crossVectors(a[0],a[t]))&&(e=-e),l=1;l<=t;l++)a[l].applyMatrix4(h.makeRotationAxis(r[l],e*l)),o[l].crossVectors(r[l],a[l]);return{tangents:r,normals:a,binormals:o}},clone:function(){return(new this.constructor).copy(this)},copy:function(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}),((Wi.prototype=Object.create(Qi.prototype)).constructor=Wi).prototype.isEllipseCurve=!0,Wi.prototype.getPoint=function(t,n){for(var e=n||new ct,i=2*Math.PI,r=this.aEndAngle-this.aStartAngle,a=Math.abs(r)<Number.EPSILON;r<0;)r+=i;for(;i<r;)r-=i;r<Number.EPSILON&&(r=a?0:i),!0!==this.aClockwise||a||(r===i?r=-i:r-=i);var o=this.aStartAngle+t*r,s=this.aX+this.xRadius*Math.cos(o),h=this.aY+this.yRadius*Math.sin(o);return 0!==this.aRotation&&(n=Math.cos(this.aRotation),a=Math.sin(this.aRotation),s=(t=s-this.aX)*n-(o=h-this.aY)*a+this.aX,h=t*a+o*n+this.aY),e.set(s,h)},Wi.prototype.copy=function(t){return Qi.prototype.copy.call(this,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},((Zi.prototype=Object.create(Wi.prototype)).constructor=Zi).prototype.isArcCurve=!0;var Ki=new Q,Ji=new qi,$i=new qi,tr=new qi;function nr(t,n,e,i){Qi.call(this),this.type="CatmullRomCurve3",this.points=t||[],this.closed=n||!1,this.curveType=e||"centripetal",this.tension=i||.5}function er(t,n,e,i,r){var a=.5*(i-n),n=.5*(r-e),r=t*t;return(2*e-2*i+a+n)*(t*r)+(-3*e+3*i-2*a-n)*r+a*t+e}function ir(t,n,e,i){return(r=1-(r=t))*r*n+2*(1-(n=t))*n*e+(t=t)*t*i;var r}function rr(t,n,e,i,r){return(a=1-(a=t))*a*a*n+3*(n=1-(a=t))*n*a*e+3*(1-(e=t))*e*e*i+(t=t)*t*t*r;var a}function ar(t,n,e,i){Qi.call(this),this.type="CubicBezierCurve",this.v0=t||new ct,this.v1=n||new ct,this.v2=e||new ct,this.v3=i||new ct}function or(t,n,e,i){Qi.call(this),this.type="CubicBezierCurve3",this.v0=t||new Q,this.v1=n||new Q,this.v2=e||new Q,this.v3=i||new Q}function sr(t,n){Qi.call(this),this.type="LineCurve",this.v1=t||new ct,this.v2=n||new ct}function hr(t,n){Qi.call(this),this.type="LineCurve3",this.v1=t||new Q,this.v2=n||new Q}function lr(t,n,e){Qi.call(this),this.type="QuadraticBezierCurve",this.v0=t||new ct,this.v1=n||new ct,this.v2=e||new ct}function cr(t){Qi.call(this),this.type="SplineCurve",this.points=t||[]}function ur(){Qi.call(this),this.type="CurvePath",this.curves=[],this.autoClose=!1}function fr(t){ur.call(this),this.type="Path",this.currentPoint=new ct,t&&this.setFromPoints(t)}function dr(t){fr.call(this,t),this.uuid=C.generateUUID(),this.type="Shape",this.holes=[]}((nr.prototype=Object.create(Qi.prototype)).constructor=nr).prototype.isCatmullRomCurve3=!0,nr.prototype.getPoint=function(t,n){var e,i=n||new Q,r=this.points,a=r.length,o=(a-(this.closed?0:1))*t,s=Math.floor(o),h=o-s;return this.closed?s+=0<s?0:(Math.floor(Math.abs(s)/a)+1)*a:0===h&&s===a-1&&(s=a-2,h=1),e=this.closed||0<s?r[(s-1)%a]:(Ki.subVectors(r[0],r[1]).add(r[0]),Ki),n=r[s%a],t=r[(s+1)%a],o=this.closed||s+2<a?r[(s+2)%a]:(Ki.subVectors(r[a-1],r[a-2]).add(r[a-1]),Ki),"centripetal"===this.curveType||"chordal"===this.curveType?(s="chordal"===this.curveType?.5:.25,r=Math.pow(e.distanceToSquared(n),s),a=Math.pow(n.distanceToSquared(t),s),s=Math.pow(t.distanceToSquared(o),s),a<1e-4&&(a=1),Ji.initNonuniformCatmullRom(e.x,n.x,t.x,o.x,r=r<1e-4?a:r,a,s=s<1e-4?a:s),$i.initNonuniformCatmullRom(e.y,n.y,t.y,o.y,r,a,s),tr.initNonuniformCatmullRom(e.z,n.z,t.z,o.z,r,a,s)):"catmullrom"===this.curveType&&(Ji.initCatmullRom(e.x,n.x,t.x,o.x,this.tension),$i.initCatmullRom(e.y,n.y,t.y,o.y,this.tension),tr.initCatmullRom(e.z,n.z,t.z,o.z,this.tension)),i.set(Ji.calc(h),$i.calc(h),tr.calc(h)),i},nr.prototype.copy=function(t){Qi.prototype.copy.call(this,t),this.points=[];for(var n=0,e=t.points.length;n<e;n++){var i=t.points[n];this.points.push(i.clone())}return this.closed=t.closed,this.curveType=t.curveType,this.tension=t.tension,this},((ar.prototype=Object.create(Qi.prototype)).constructor=ar).prototype.isCubicBezierCurve=!0,ar.prototype.getPoint=function(t,n){var e=n||new ct,i=this.v0,r=this.v1,a=this.v2,n=this.v3;return e.set(rr(t,i.x,r.x,a.x,n.x),rr(t,i.y,r.y,a.y,n.y)),e},ar.prototype.copy=function(t){return Qi.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},((or.prototype=Object.create(Qi.prototype)).constructor=or).prototype.isCubicBezierCurve3=!0,or.prototype.getPoint=function(t,n){var e=n||new Q,i=this.v0,r=this.v1,a=this.v2,n=this.v3;return e.set(rr(t,i.x,r.x,a.x,n.x),rr(t,i.y,r.y,a.y,n.y),rr(t,i.z,r.z,a.z,n.z)),e},or.prototype.copy=function(t){return Qi.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this.v3.copy(t.v3),this},((sr.prototype=Object.create(Qi.prototype)).constructor=sr).prototype.isLineCurve=!0,sr.prototype.getPoint=function(t,n){n=n||new ct;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n},sr.prototype.getPointAt=function(t,n){return this.getPoint(t,n)},sr.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()},sr.prototype.copy=function(t){return Qi.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},((hr.prototype=Object.create(Qi.prototype)).constructor=hr).prototype.isLineCurve3=!0,hr.prototype.getPoint=function(t,n){n=n||new Q;return 1===t?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(t).add(this.v1)),n},hr.prototype.getPointAt=function(t,n){return this.getPoint(t,n)},hr.prototype.copy=function(t){return Qi.prototype.copy.call(this,t),this.v1.copy(t.v1),this.v2.copy(t.v2),this},((lr.prototype=Object.create(Qi.prototype)).constructor=lr).prototype.isQuadraticBezierCurve=!0,lr.prototype.getPoint=function(t,n){var e=n||new ct,i=this.v0,r=this.v1,n=this.v2;return e.set(ir(t,i.x,r.x,n.x),ir(t,i.y,r.y,n.y)),e},lr.prototype.copy=function(t){return Qi.prototype.copy.call(this,t),this.v0.copy(t.v0),this.v1.copy(t.v1),this.v2.copy(t.v2),this},((cr.prototype=Object.create(Qi.prototype)).constructor=cr).prototype.isSplineCurve=!0,cr.prototype.getPoint=function(t,n){var e=n||new ct,i=this.points,r=(i.length-1)*t,a=Math.floor(r),o=r-a,n=i[0===a?a:a-1],t=i[a],r=i[a>i.length-2?i.length-1:a+1],a=i[a>i.length-3?i.length-1:a+2];return e.set(er(o,n.x,t.x,r.x,a.x),er(o,n.y,t.y,r.y,a.y)),e},cr.prototype.copy=function(t){Qi.prototype.copy.call(this,t),this.points=[];for(var n=0,e=t.points.length;n<e;n++){var i=t.points[n];this.points.push(i.clone())}return this},ur.prototype=Object.assign(Object.create(Qi.prototype),{constructor:ur,add:function(t){this.curves.push(t)},closePath:function(){var t=this.curves[0].getPoint(0),n=this.curves[this.curves.length-1].getPoint(1);t.equals(n)||this.curves.push(new sr(n,t))},getPoint:function(t){for(var n=t*this.getLength(),e=this.getCurveLengths(),i=0;i<e.length;){if(e[i]>=n){var r=e[i]-n,a=this.curves[i],o=a.getLength();return a.getPointAt(0===o?0:1-r/o)}i++}return null},getLength:function(){var t=this.getCurveLengths();return t[t.length-1]},updateArcLengths:function(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var t=[],n=0,e=0,i=this.curves.length;e<i;e++)n+=this.curves[e].getLength(),t.push(n);return this.cacheLengths=t},getSpacedPoints:function(t){void 0===t&&(t=40);for(var n=[],e=0;e<=t;e++)n.push(this.getPoint(e/t));return this.autoClose&&n.push(n[0]),n},getPoints:function(t){t=t||12;for(var n,e=[],i=0,r=this.curves;i<r.length;i++)for(var a=r[i],o=a&&a.isEllipseCurve?2*t:a&&(a.isLineCurve||a.isLineCurve3)?1:a&&a.isSplineCurve?t*a.points.length:t,s=a.getPoints(o),h=0;h<s.length;h++){var l=s[h];n&&n.equals(l)||(e.push(l),n=l)}return this.autoClose&&1<e.length&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e},copy:function(t){Qi.prototype.copy.call(this,t),this.curves=[];for(var n=0,e=t.curves.length;n<e;n++){var i=t.curves[n];this.curves.push(i.clone())}return this.autoClose=t.autoClose,this}}),fr.prototype=Object.assign(Object.create(ur.prototype),{constructor:fr,setFromPoints:function(t){this.moveTo(t[0].x,t[0].y);for(var n=1,e=t.length;n<e;n++)this.lineTo(t[n].x,t[n].y);return this},moveTo:function(t,n){return this.currentPoint.set(t,n),this},lineTo:function(t,n){var e=new sr(this.currentPoint.clone(),new ct(t,n));return this.curves.push(e),this.currentPoint.set(t,n),this},quadraticCurveTo:function(t,n,e,i){n=new lr(this.currentPoint.clone(),new ct(t,n),new ct(e,i));return this.curves.push(n),this.currentPoint.set(e,i),this},bezierCurveTo:function(t,n,e,i,r,a){i=new ar(this.currentPoint.clone(),new ct(t,n),new ct(e,i),new ct(r,a));return this.curves.push(i),this.currentPoint.set(r,a),this},splineThru:function(t){var n=new cr([this.currentPoint.clone()].concat(t));return this.curves.push(n),this.currentPoint.copy(t[t.length-1]),this},arc:function(t,n,e,i,r,a){var o=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(t+o,n+s,e,i,r,a),this},absarc:function(t,n,e,i,r,a){return this.absellipse(t,n,e,e,i,r,a),this},ellipse:function(t,n,e,i,r,a,o,s){var h=this.currentPoint.x,l=this.currentPoint.y;return this.absellipse(t+h,n+l,e,i,r,a,o,s),this},absellipse:function(t,n,e,i,r,a,o,s){o=new Wi(t,n,e,i,r,a,o,s);0<this.curves.length&&((s=o.getPoint(0)).equals(this.currentPoint)||this.lineTo(s.x,s.y)),this.curves.push(o);o=o.getPoint(1);return this.currentPoint.copy(o),this},copy:function(t){return ur.prototype.copy.call(this,t),this.currentPoint.copy(t.currentPoint),this}}),dr.prototype=Object.assign(Object.create(fr.prototype),{constructor:dr,getPointsHoles:function(t){for(var n=[],e=0,i=this.holes.length;e<i;e++)n[e]=this.holes[e].getPoints(t);return n},extractPoints:function(t){return{shape:this.getPoints(t),holes:this.getPointsHoles(t)}},copy:function(t){fr.prototype.copy.call(this,t),this.holes=[];for(var n=0,e=t.holes.length;n<e;n++){var i=t.holes[n];this.holes.push(i.clone())}return this}});var vr=function(t,n,e){e=e||2;var i,r,a,o,s,h=n&&n.length,l=h?n[0]*e:t.length,c=mr(t,0,l,e,!0),u=[];if(!c||c.next===c.prev)return u;if(h&&(c=function(t,n,e,i){var r,a,o,s,h=[];for(r=0,a=n.length;r<a;r++)o=n[r]*i,s=r<a-1?n[r+1]*i:t.length,(s=mr(t,o,s,i,!1))===s.next&&(s.steiner=!0),h.push(function(t){var n=t,e=t;for(;(n.x<e.x||n.x===e.x&&n.y<e.y)&&(e=n),n=n.next,n!==t;);return e}(s));for(h.sort(_r),r=0;r<h.length;r++)!function(t,n){(n=function(t,n){var e,i=n,r=t.x,a=t.y,o=-1/0;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=r&&o<s){if((o=s)===r){if(a===i.y)return i;if(a===i.next.y)return i.next}e=i.x<i.next.x?i:i.next}}}while(i=i.next,i!==n);if(!e)return null;if(r===o)return e.prev;var h,l=e,c=e.x,u=e.y,f=1/0;i=e.next;for(;i!==l;)r>=i.x&&i.x>=c&&r!==i.x&&Ar(a<u?r:o,a,c,u,a<u?o:r,a,i.x,i.y)&&((h=Math.abs(a-i.y)/(r-i.x))<f||h===f&&i.x>e.x)&&br(i,t)&&(e=i,f=h),i=i.next;return e}(t,n))&&pr(t=Mr(n,t),t.next)}(h[r],e),e=pr(e,e.next);return e}(t,n,c,e)),t.length>80*e){for(var f=i=t[0],d=r=t[1],v=e;v<l;v+=e)(a=t[v])<f&&(f=a),(o=t[v+1])<d&&(d=o),i<a&&(i=a),r<o&&(r=o);s=0!==(s=Math.max(i-f,r-d))?1/s:0}return gr(c,u,e,f,d,s),u};function mr(t,n,e,i,r){var a,o;if(r===0<function(t,n,e,i){for(var r=0,a=n,o=e-i;a<e;a+=i)r+=(t[o]-t[a])*(t[a+1]+t[o+1]),o=a;return r}(t,n,e,i))for(a=n;a<e;a+=i)o=Tr(a,t[a],t[a+1],o);else for(a=e-i;n<=a;a-=i)o=Tr(a,t[a],t[a+1],o);return o&&yr(o,o.next)&&(Lr(o),o=o.next),o}function pr(t,n){if(!t)return t;n=n||t;var e,i=t;do{if(e=!1,i.steiner||!yr(i,i.next)&&0!==wr(i.prev,i,i.next))i=i.next;else{if(Lr(i),(i=n=i.prev)===i.next)break;e=!0}}while(e||i!==n);return n}function gr(t,n,e,i,r,a,o){if(t){!o&&a&&function(t,n,e,i){var r=t;for(;null===r.z&&(r.z=xr(r.x,r.y,n,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next,r!==t;);r.prevZ.nextZ=null,r.prevZ=null,function(t){var n,e,i,r,a,o,s,h,l=1;do{for(e=t,a=t=null,o=0;e;){for(o++,i=e,n=s=0;n<l&&(s++,i=i.nextZ);n++);for(h=l;0<s||0<h&&i;)0!==s&&(0===h||!i||e.z<=i.z)?(e=(r=e).nextZ,s--):(i=(r=i).nextZ,h--),a?a.nextZ=r:t=r,r.prevZ=a,a=r;e=i}}while(a.nextZ=null,l*=2,1<o)}(r)}(t,i,r,a);for(var s,h,l=t;t.prev!==t.next;)if(s=t.prev,h=t.next,a?function(t,n,e,i){var r=t.prev,a=t,o=t.next;if(0<=wr(r,a,o))return!1;var s=(r.x<a.x?r.x<o.x?r:o:a.x<o.x?a:o).x,h=(r.y<a.y?r.y<o.y?r:o:a.y<o.y?a:o).y,l=(r.x>a.x?r.x>o.x?r:o:a.x>o.x?a:o).x,c=(r.y>a.y?r.y>o.y?r:o:a.y>o.y?a:o).y,u=xr(s,h,n,e,i),f=xr(l,c,n,e,i),d=t.prevZ,v=t.nextZ;for(;d&&d.z>=u&&v&&v.z<=f;){if(d!==t.prev&&d!==t.next&&Ar(r.x,r.y,a.x,a.y,o.x,o.y,d.x,d.y)&&0<=wr(d.prev,d,d.next))return!1;if(d=d.prevZ,v!==t.prev&&v!==t.next&&Ar(r.x,r.y,a.x,a.y,o.x,o.y,v.x,v.y)&&0<=wr(v.prev,v,v.next))return!1;v=v.nextZ}for(;d&&d.z>=u;){if(d!==t.prev&&d!==t.next&&Ar(r.x,r.y,a.x,a.y,o.x,o.y,d.x,d.y)&&0<=wr(d.prev,d,d.next))return!1;d=d.prevZ}for(;v&&v.z<=f;){if(v!==t.prev&&v!==t.next&&Ar(r.x,r.y,a.x,a.y,o.x,o.y,v.x,v.y)&&0<=wr(v.prev,v,v.next))return!1;v=v.nextZ}return!0}(t,i,r,a):function(t){var n=t.prev,e=t,i=t.next;if(0<=wr(n,e,i))return!1;var r=t.next.next;for(;r!==t.prev;){if(Ar(n.x,n.y,e.x,e.y,i.x,i.y,r.x,r.y)&&0<=wr(r.prev,r,r.next))return!1;r=r.next}return!0}(t))n.push(s.i/e),n.push(t.i/e),n.push(h.i/e),Lr(t),t=h.next,l=h.next;else if((t=h)===l){o?1===o?gr(t=function(t,n,e){var i=t;do{var r=i.prev,a=i.next.next}while(!yr(r,a)&&Sr(r,i,i.next,a)&&br(r,a)&&br(a,r)&&(n.push(r.i/e),n.push(i.i/e),n.push(a.i/e),Lr(i),Lr(i.next),i=t=a),i=i.next,i!==t);return i}(t,n,e),n,e,i,r,a,2):2===o&&function(t,n,e,i,r,a){var o=t;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&function(t,n){return t.next.i!==n.i&&t.prev.i!==n.i&&!function(t,n){var e=t;do{if(e.i!==t.i&&e.next.i!==t.i&&e.i!==n.i&&e.next.i!==n.i&&Sr(e,e.next,t,n))return!0}while(e=e.next,e!==t);return!1}(t,n)&&br(t,n)&&br(n,t)&&function(t,n){var e=t,i=!1,r=(t.x+n.x)/2,a=(t.y+n.y)/2;for(;e.y>a!=e.next.y>a&&e.next.y!==e.y&&r<(e.next.x-e.x)*(a-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next,e!==t;);return i}(t,n)}(o,s)){var h=Mr(o,s);return o=pr(o,o.next),h=pr(h,h.next),gr(o,n,e,i,r,a),gr(h,n,e,i,r,a)}s=s.next}}while(o=o.next,o!==t)}(t,n,e,i,r,a):gr(pr(t),n,e,i,r,a,1);break}}}function _r(t,n){return t.x-n.x}function xr(t,n,e,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-e)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=32767*(n-i)*r)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function Ar(t,n,e,i,r,a,o,s){return 0<=(r-o)*(n-s)-(t-o)*(a-s)&&0<=(t-o)*(i-s)-(e-o)*(n-s)&&0<=(e-o)*(a-s)-(r-o)*(i-s)}function wr(t,n,e){return(n.y-t.y)*(e.x-n.x)-(n.x-t.x)*(e.y-n.y)}function yr(t,n){return t.x===n.x&&t.y===n.y}function Sr(t,n,e,i){return yr(t,e)&&yr(n,i)||yr(t,i)&&yr(e,n)||0<wr(t,n,e)!=0<wr(t,n,i)&&0<wr(e,i,t)!=0<wr(e,i,n)}function br(t,n){return wr(t.prev,t,t.next)<0?0<=wr(t,n,t.next)&&0<=wr(t,t.prev,n):wr(t,n,t.prev)<0||wr(t,t.next,n)<0}function Mr(t,n){var e=new Er(t.i,t.x,t.y),i=new Er(n.i,n.x,n.y),r=t.next,a=n.prev;return(t.next=n).prev=t,(e.next=r).prev=e,(i.next=e).prev=i,(a.next=i).prev=a,i}function Tr(t,n,e,i){e=new Er(t,n,e);return i?(e.next=i.next,(e.prev=i).next.prev=e,i.next=e):(e.prev=e).next=e,e}function Lr(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 Er(t,n,e){this.i=t,this.x=n,this.y=e,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var Pr={area:function(t){for(var n=t.length,e=0,i=n-1,r=0;r<n;i=r++)e+=t[i].x*t[r].y-t[r].x*t[i].y;return.5*e},isClockWise:function(t){return Pr.area(t)<0},triangulateShape:function(t,n){var e=[],i=[],r=[];Fr(t),Nr(e,t);var a=t.length;n.forEach(Fr);for(var o=0;o<n.length;o++)i.push(a),a+=n[o].length,Nr(e,n[o]);for(var s=vr(e,i),o=0;o<s.length;o+=3)r.push(s.slice(o,o+3));return r}};function Fr(t){var n=t.length;2<n&&t[n-1].equals(t[0])&&t.pop()}function Nr(t,n){for(var e=0;e<n.length;e++)t.push(n[e].x),t.push(n[e].y)}function Dr(t){return(Dr="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})(t)}function Cr(t,n){Ei.call(this),this.type="ShapeGeometry","object"===Dr(n)&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),n=n.curveSegments),this.parameters={shapes:t,curveSegments:n},this.fromBufferGeometry(new Rr(t,n)),this.mergeVertices()}function Rr(t,f){on.call(this),this.type="ShapeBufferGeometry",this.parameters={shapes:t,curveSegments:f},f=f||12;var d=[],v=[],m=[],p=[],n=0,g=0;if(!1===Array.isArray(t))i(t);else for(var e=0;e<t.length;e++)i(t[e]),this.addGroup(n,g,e),n+=g,g=0;function i(t){var n,e=v.length/3,t=t.extractPoints(f),i=t.shape,r=t.holes;for(!1===Pr.isClockWise(i)&&(i=i.reverse()),o=0,s=r.length;o<s;o++)n=r[o],!0===Pr.isClockWise(n)&&(r[o]=n.reverse());for(var a=Pr.triangulateShape(i,r),o=0,s=r.length;o<s;o++)n=r[o],i=i.concat(n);for(o=0,s=i.length;o<s;o++){var h=i[o];v.push(h.x,h.y,0),m.push(0,0,1),p.push(h.x,h.y)}for(o=0,s=a.length;o<s;o++){var l=a[o],c=l[0]+e,u=l[1]+e,l=l[2]+e;d.push(c,u,l),g+=3}}this.setIndex(d),this.setAttribute("position",new At(v,3)),this.setAttribute("normal",new At(m,3)),this.setAttribute("uv",new At(p,2))}function Ir(t,n){Kt.call(this),this.type="Light",this.color=new X(t),this.intensity=void 0!==n?n:1,this.receiveShadow=void 0}function Or(t,n){Ir.call(this,t,n),this.type="AmbientLight",this.castShadow=void 0}(Cr.prototype=Object.create(Ei.prototype)).constructor=Cr,(Rr.prototype=Object.create(on.prototype)).constructor=Rr,Ir.prototype=Object.assign(Object.create(Kt.prototype),{constructor:Ir,isLight:!0,copy:function(t){return Kt.prototype.copy.call(this,t),this.color.copy(t.color),this.intensity=t.intensity,this}}),Or.prototype=Object.assign(Object.create(Ir.prototype),{constructor:Or,isAmbientLight:!0});var Ur=new St,Hr=new Q;function Xr(t,n,e,i,r,a){this.planes=[void 0!==t?t:new _e,void 0!==n?n:new _e,void 0!==e?e:new _e,void 0!==i?i:new _e,void 0!==r?r:new _e,void 0!==a?a:new _e]}function Gr(t){this.camera=t,this.bias=0,this.radius=1,this.mapSize=new ct(512,512),this.map=null,this.mapPass=null,this.matrix=new Dt,this.mt=new Xr,this.pt=new ct(1,1),this.gt=1,this._t=[new lt(0,0,1,1)]}function zr(){Gr.call(this,new de(-5,5,5,-5,.5,500))}function Br(t,n){Ir.call(this,t,n),this.type="DirectionalLight",this.position.copy(Kt.DefaultUp),this.updateMatrix(),this.target=new Kt,this.shadow=new zr}function kr(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.assign(Xr.prototype,{set:function(t,n,e,i,r,a){var o=this.planes;return o[0].copy(t),o[1].copy(n),o[2].copy(e),o[3].copy(i),o[4].copy(r),o[5].copy(a),this},clone:function(){return(new this.constructor).copy(this)},copy:function(t){for(var n=this.planes,e=0;e<6;e++)n[e].copy(t.planes[e]);return this},setFromProjectionMatrix:function(t){var n=this.planes,e=t.elements,i=e[0],r=e[1],a=e[2],o=e[3],s=e[4],h=e[5],l=e[6],c=e[7],u=e[8],f=e[9],d=e[10],v=e[11],m=e[12],p=e[13],t=e[14],e=e[15];return n[0].setComponents(o-i,c-s,v-u,e-m).normalize(),n[1].setComponents(o+i,c+s,v+u,e+m).normalize(),n[2].setComponents(o+r,c+h,v+f,e+p).normalize(),n[3].setComponents(o-r,c-h,v-f,e-p).normalize(),n[4].setComponents(o-a,c-l,v-d,e-t).normalize(),n[5].setComponents(o+a,c+l,v+d,e+t).normalize(),this},intersectsObject:function(t){var n=t.geometry;return null===n.boundingSphere&&n.computeBoundingSphere(),Ur.copy(n.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(Ur)},intersectsSprite:function(t){return Ur.center.set(0,0,0),Ur.radius=.7071067811865476,Ur.applyMatrix4(t.matrixWorld),this.intersectsSphere(Ur)},intersectsSphere:function(t){for(var n=this.planes,e=t.center,i=-t.radius,r=0;r<6;r++)if(n[r].distanceToPoint(e)<i)return!1;return!0},intersectsBox:function(t){for(var n=this.planes,e=0;e<6;e++){var i=n[e];if(Hr.x=(0<i.normal.x?t.max:t.min).x,Hr.y=(0<i.normal.y?t.max:t.min).y,Hr.z=(0<i.normal.z?t.max:t.min).z,i.distanceToPoint(Hr)<0)return!1}return!0},containsPoint:function(t){for(var n=this.planes,e=0;e<6;e++)if(n[e].distanceToPoint(t)<0)return!1;return!0}}),Object.assign(Gr.prototype,{xt:new Dt,At:new Q,wt:new Q,getViewportCount:function(){return this.gt},getFrustum:function(){return this.mt},updateMatrices:function(t){var n=this.camera,e=this.matrix,i=this.xt,r=this.wt,a=this.At;a.setFromMatrixPosition(t.matrixWorld),n.position.copy(a),r.setFromMatrixPosition(t.target.matrixWorld),n.lookAt(r),n.updateMatrixWorld(),i.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this.mt.setFromProjectionMatrix(i),e.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),e.multiply(n.projectionMatrix),e.multiply(n.matrixWorldInverse)},getViewport:function(t){return this._t[t]},getFrameExtents:function(){return this.pt},copy:function(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this},clone:function(){return(new this.constructor).copy(this)}}),zr.prototype=Object.assign(Object.create(Gr.prototype),{constructor:zr,isDirectionalLightShadow:!0,updateMatrices:function(t){Gr.prototype.updateMatrices.call(this,t)}}),Br.prototype=Object.assign(Object.create(Ir.prototype),{constructor:Br,isDirectionalLight:!0,copy:function(t){return Ir.prototype.copy.call(this,t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}});var Vr=function(){function n(t){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),this.R=t,this.yt=[],this.St=null,this.bt=fengmap.FMType.EXTENT_LAYER|fengmap.FMType.MODEL_LAYER|fengmap.FMType.EXTERNAL_MODEL_LAYER,this.F=fengmap.FMType.EXTENT|fengmap.FMType.MODEL|fengmap.FMType.EXTERNAL_MODEL,this.P=new he}var t,e,i;return t=n,(e=[{key:"traverse",value:function(t){for(var n=0;n<this.yt.length;n++)t(this.yt[n])}}])&&kr(t.prototype,e),i&&kr(t,i),n}();Object.assign(Vr.prototype,{B:function(){this.P.position.y=this.St.height;for(var t=this.St.getLayers(this.bt),n=0;n<t.length;n++)t[n].scene.position.y=0,t[n].removeLight&&t[n].removeLight(),this.P.add(t[n].scene);this.Mt()},Mt:function(){this.Tt=new Or(7631988),this.Lt=new Kt,this.Et=new Br(8947848,1.2),this.Et.position.set(-1,1,1).normalize(),this.Et.castShadow=!1,this.Et.target=this.Lt,this.Pt=new Br(3355443),this.Pt.position.set(-.5,1,-1).normalize(),this.Pt.target=this.Lt,this.P.add(this.Et),this.P.add(this.Tt),this.P.add(this.Pt),this.P.add(this.Lt)},Ft:function(t){this.St=t,this.R.getRenderManager().waterLayers.set(t.level,this),this.B()},Nt:function(){this.R.getRenderManager().waterLayers.delete(this.St.level);for(var t=this.St.getLayers(this.bt),n=0;n<t.length;n++)t[n].scene.position.y=this.St.height,t[n].putLight&&t[n].putLight(),this.P.remove(t[n].scene);this.St=null},Dt:function(t){t.St=this,(t.Ct||t.B())&&this.Rt(t)},Rt:function(t){this.yt.push(t),this.P.add(t.L)},It:function(t){this.Ot(t),t.Ut();t=this.yt.indexOf(t);-1<t&&this.yt.splice(t,1),0===this.yt.length&&this.Nt()},Ot:function(t){t.St=void 0,this.P.remove(t.L)}});var Yr=Vr;function jr(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var Qr=function(){function e(t,n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.R=t,this.Ht=n.color,this.Xt=n.alpha,this.W="number"==typeof n.height?n.height:0,this.Gt=n.points,this.O=n.url,this.St=null,this.L=null,this.Ct=!1,this.G=this.G.bind(this)}var t,n,i;return t=e,(n=[{key:"color",get:function(){return this.Ht},set:function(t){this.Ht=t,this.L&&(this.L.material.uniforms.waterColor.value=new X(t))}},{key:"alpha",get:function(){return this.Xt},set:function(t){this.Xt=t,this.L&&(this.L.material.uniforms.alpha.value=t)}},{key:"height",get:function(){return this.W},set:function(t){this.W=t,this.L&&(this.L.position.y=t)}},{key:"addTo",value:function(t){var n=this.R.getRenderManager();n.waterLayers||"basic"===this.R.getRenderManager().type&&this.R.setRenderManager(new se);n=n.waterLayers.get(t.level);n||(n=new Yr(this.R)).Ft(t),n.Dt(this),this.R.on("beforeRender",this.G)}},{key:"remove",value:function(){this.St.It(this)}}])&&jr(t.prototype,n),i&&jr(t,i),e}();Object.assign(Qr.prototype,{B:function(){var t=this.R.getBuilding(),n=new dr;n.moveTo(this.Gt[0].x-t.x,this.Gt[0].y-t.y);for(var e=1;e<this.Gt.length;e++)n.lineTo(this.Gt[e].x-t.x,this.Gt[e].y-t.y);var i=new Rr(n);return this.L=new ji(i,{textureWidth:512,textureHeight:512,waterNormals:(new Bn).load(this.O,function(t){t.wrapS=t.wrapT=1e3}),alpha:this.Xt,waterColor:this.Ht,distortionScale:5.7}),this.L.rotation.x=-Math.PI/2,this.L.position.y=this.W,this.Ct=!0,this.Ct},G:function(){this.R.enableUpdateRender()},Ut:function(){this.L.geometry.dispose(),this.L.geometry=null,this.L.material.dispose(),this.L.material=null,this.L=null,this.Ct=!1}});var e=Qr,Wr={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new X(0)},defaultOpacity:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec3 defaultColor;","uniform float defaultOpacity;","uniform float luminosityThreshold;","uniform float smoothWidth;","varying vec2 vUv;","void main() {","\tvec4 texel = texture2D( tDiffuse, vUv );","\tvec3 luma = vec3( 0.299, 0.587, 0.114 );","\tfloat v = dot( texel.xyz, luma );","\tvec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );","\tfloat alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );","\tgl_FragColor = mix( outputColor, texel, alpha );","}"].join("\n")};function Zr(t,n,e,i){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,Zr),ti.call(this),this.strength=void 0!==n?n:1,this.radius=e,this.threshold=i,this.resolution=void 0!==t?new ct(t.x,t.y):new ct(256,256),this.clearColor=new X(0,0,0);var r={minFilter:E,magFilter:E,format:x};this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;var a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);this.renderTargetBright=new ii(a,o,r),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(var s=0;s<this.nMips;s++){var h=new ii(a,o,r);h.texture.name="UnrealBloomPass.h"+s,h.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(h);h=new ii(a,o,r);h.texture.name="UnrealBloomPass.v"+s,h.texture.generateMipmaps=!1,this.renderTargetsVertical.push(h),a=Math.round(a/2),o=Math.round(o/2)}t=Wr,this.highPassUniforms=pn.clone(t.uniforms),this.highPassUniforms.luminosityThreshold.value=i,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new xn({uniforms:this.highPassUniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,defines:{}}),this.separableBlurMaterials=[];for(var l=[3,5,7,9,11],a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2),s=0;s<this.nMips;s++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(l[s])),this.separableBlurMaterials[s].uniforms.texSize.value=new ct(a,o),a=Math.round(a/2),o=Math.round(o/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=n,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0,this.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],this.bloomTintColors=[new Q(1,1,1),new Q(1,1,1),new Q(1,1,1),new Q(1,1,1),new Q(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,void 0===ei&&console.error("UnrealBloomPass relies on CopyShader"),n=ei,this.copyUniforms=pn.clone(n.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new xn({uniforms:this.copyUniforms,vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,blending:u,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new X,this.oldClearAlpha=1,this.basic=new Pn,this.fsQuad=new ti.FullScreenQuad(null)}function qr(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Zr.prototype=Object.assign(Object.create(ti.prototype),{constructor:Zr,dispose:function(){for(var t=0;t<this.renderTargetsHorizontal.length;t++)this.renderTargetsHorizontal[t].dispose();for(t=0;t<this.renderTargetsVertical.length;t++)this.renderTargetsVertical[t].dispose();this.renderTargetBright.dispose()},setSize:function(t,n){var e=Math.round(t/2),i=Math.round(n/2);this.renderTargetBright.setSize(e,i);for(var r=0;r<this.nMips;r++)this.renderTargetsHorizontal[r].setSize(e,i),this.renderTargetsVertical[r].setSize(e,i),this.separableBlurMaterials[r].uniforms.texSize.value=new ct(e,i),e=Math.round(e/2),i=Math.round(i/2)},render:function(t,n,e,i,r){this.oldClearColor.copy(t.getClearColor()),this.oldClearAlpha=t.getClearAlpha();var a=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,1),r&&t.state.buffers.stencil.setTest(!1),this.highPassUniforms.tDiffuse.value=e.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this.fsQuad.render(t);for(var o=this.renderTargetBright,s=0;s<this.nMips;s++)this.fsQuad.material=this.separableBlurMaterials[s],this.separableBlurMaterials[s].uniforms.enableAlpha.value=1!==this.oldClearAlpha,this.separableBlurMaterials[s].uniforms.colorTexture.value=o.texture,this.separableBlurMaterials[s].uniforms.direction.value=Zr.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[s]),t.clear(),this.fsQuad.render(t),this.separableBlurMaterials[s].uniforms.enableAlpha.value=1!==this.oldClearAlpha,this.separableBlurMaterials[s].uniforms.colorTexture.value=this.renderTargetsHorizontal[s].texture,this.separableBlurMaterials[s].uniforms.direction.value=Zr.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[s]),t.clear(),this.fsQuad.render(t),o=this.renderTargetsVertical[s];this.fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,r&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?t.setRenderTarget(null):t.setRenderTarget(e),this.fsQuad.render(t),t.setClearColor(this.oldClearColor,this.oldClearAlpha),t.autoClear=a},getSeperableBlurMaterial:function(t){return new xn({defines:{KERNEL_RADIUS:t,SIGMA:t},uniforms:{enableAlpha:{value:!1},colorTexture:{value:null},texSize:{value:new ct(.5,.5)},direction:{value:new ct(.5,.5)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"\n                varying vec2 vUv;\n                uniform sampler2D colorTexture;\n                uniform vec2 texSize;\n                uniform vec2 direction;\n                uniform bool enableAlpha;\n         \n                float gaussianPdf( in float x, in float sigma) {\n                    return 0.39894 * exp(-0.5 * x * x / (sigma * sigma)) / sigma;\n                }\n                \n                void main() {\n                    vec2 invSize = 1.0 / texSize; \n                    float fSigma = float(SIGMA);\n                    float weightSum = gaussianPdf(0.0, fSigma);\n                    float alphaSum = 0.0;\n                    vec3 diffuseSum = texture2D(colorTexture, vUv).rgb * weightSum;\n                    \n                    for (int i = 1; i < KERNEL_RADIUS; i++) {\n                    \n                        float x = float(i);\n                        float w = gaussianPdf(x, fSigma);\n                        \n                        vec2 uvOffset = direction * invSize * x;\n                        vec4 sample1 = texture2D(colorTexture, vUv + uvOffset);\n                        vec4 sample2 = texture2D(colorTexture, vUv - uvOffset);\n                        \n                        diffuseSum += (sample1.rgb + sample2.rgb) * w;\n                        alphaSum += (sample1.a + sample2.a) * w;\n                        weightSum += 2.0 * w;\n                    }\n                    \n                    if(enableAlpha){\n                        gl_FragColor = vec4(diffuseSum / weightSum, alphaSum / weightSum);\n                    } else{\n                        gl_FragColor = vec4(diffuseSum / weightSum, 1.0);\n                    }\n                    \n                }"})},getCompositeMaterial:function(t){return new xn({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},dirtTexture:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;            uniform sampler2D blurTexture1;            uniform sampler2D blurTexture2;            uniform sampler2D blurTexture3;            uniform sampler2D blurTexture4;            uniform sampler2D blurTexture5;            uniform sampler2D dirtTexture;            uniform float bloomStrength;            uniform float bloomRadius;            uniform float bloomFactors[NUM_MIPS];            uniform vec3 bloomTintColors[NUM_MIPS];                        float lerpBloomFactor(const in float factor) {                float mirrorFactor = 1.2 - factor;                return mix(factor, mirrorFactor, bloomRadius);            }                        void main() {                gl_FragColor = bloomStrength * (                    lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +                    lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +                    lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +                    lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +                    lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );            }"})}}),Zr.BlurDirectionX=new ct(1,0),Zr.BlurDirectionY=new ct(0,1);ce=function(){function e(t,n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.R=t,this.zt="number"==typeof(n=n||{}).strength?n.strength:.62,this.Bt="number"==typeof n.radius?n.radius:.6,this.kt="number"==typeof n.threshold?n.threshold:.4,this.K=null,this.D=new he,this.N=new Map,this.Vt=null,this.B()}var t,n,i;return t=e,(n=[{key:"getThreshold",value:function(){return this.Vt.threshold}},{key:"setThreshold",value:function(t){this.Vt.threshold=t,this.R.enableUpdateRender()}},{key:"getStrength",value:function(){return this.Vt.strength}},{key:"setStrength",value:function(t){this.Vt.strength=t,this.R.enableUpdateRender()}},{key:"getRadius",value:function(){return this.Vt.radius}},{key:"setRadius",value:function(t){this.Vt.radius=t,this.R.enableUpdateRender()}},{key:"enable",value:function(){(this.K.bloom=this).R.enableUpdateRender()}},{key:"disable",value:function(){this.K.bloom=null,this.R.enableUpdateRender()}},{key:"add",value:function(t){var n=t.parent.level,e=this.N.get(n);e||(e=new Map,this.N.set(n,e)),e.set(t.type,t),this.R.enableUpdateRender()}},{key:"remove",value:function(t){var n=t.parent.level,n=this.N.get(n);n&&(n.delete(t.type),this.R.enableUpdateRender())}},{key:"clear",value:function(){this.N.forEach(function(t,n,e){t.clear()}),this.N.clear(),this.R.enableUpdateRender()}},{key:"updateCamera",value:function(){for(var t=0;t<this.C.passes.length;t++)this.C.passes[t].constructor===li&&this.C.passes[t].setPass(this.D,this.R.camera)}}])&&qr(t.prototype,n),i&&qr(t,i),e}();Object.assign(ce.prototype,{B:function(){"basic"===this.R.getRenderManager().type&&this.R.setRenderManager(new se),this.K=this.R.getRenderManager(),this.C=new pi(this.K.renderer);var t=new li(this.D,this.R.camera,null,0,1);this.C.addPass(t),this.Vt=new Zr(new ct(this.R.getContainer().clientWidth,this.R.getContainer().clientHeight),this.zt,this.Bt,this.kt),this.C.addPass(this.Vt),this.it=this.it.bind(this),this.R.on("resize",this.it)},it:function(){var t,n;this.C&&(t=(n=this.R.getContainer()).clientWidth,n=n.clientHeight,this.C.setSize(t,n))}});xi=ce;function Kr(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}yi=function(){function n(t){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),this.R=t,this.Yt=[],this.jt={x:0,y:0,maxR:0,radius:0,minR:0,widthR:0,length:0,distance:0,width:0,height:0,color_a:0,color_r:0,point:null,endPoint:null,startPoint:null,se2N:null,speed:1,se2RN:null},this.Qt=!1,this.Wt=!1,this.K=this.J(),this.Zt=(new Date).getTime(),this.G=this.G.bind(this),this.B()}var t,e,i;return t=n,(e=[{key:"enable",value:function(){(this.K.sweep=this).R.on("beforeRender",this.G)}},{key:"disable",value:function(){this.K.sweep=null,this.R.off("beforeRender",this.G),this.G()}},{key:"annulus",value:function(t){this.jt.x=t.x,this.jt.y=t.y,this.jt.maxR=t.maxRadius,this.jt.minR=t.minRadius,this.jt.radius=t.minRadius+t.width,this.jt.widthR=t.width,this.jt.duration_a=1e3*t.duration,this.jt.color_a=new X(t.color),this.Qt=!0}},{key:"rect",value:function(t){this.jt.endPoint=new ct(t.endPoint.x-this.R.getX(),-t.endPoint.y+this.R.getY()),this.jt.startPoint=new ct(t.startPoint.x-this.R.getX(),-t.startPoint.y+this.R.getY()),this.jt.point=this.jt.startPoint.clone();var n=new ct(t.endPoint.x-t.startPoint.x,-t.endPoint.y+t.startPoint.y);this.jt.se2N=n.normalize(),this.jt.se2RN=n.clone().rotateAround(new ct(0,0),Math.PI/2).normalize(),this.jt.duration_r=1e3*t.duration,this.jt.width=t.width,this.jt.height=t.height,this.jt.distance=this.jt.endPoint.distanceTo(this.jt.startPoint),this.jt.color_r=new X(t.color),this.Wt=!0}},{key:"render",value:function(t){var n,e=this;this.Qt&&(this.jt.radius<this.jt.maxR?this.jt.radius+=((new Date).getTime()-this.Zt)*this.jt.maxR/this.jt.duration_a:this.jt.radius=this.jt.minR),this.Wt&&(n=((new Date).getTime()-this.Zt)*this.jt.distance/this.jt.duration_r,n=this.jt.se2N.clone().multiplyScalar(n),this.jt.length<=this.jt.distance?(this.jt.point.add(n),this.jt.length+=n.length()):(this.jt.point=this.jt.startPoint.clone(),this.jt.length=0)),t.traverse(function(t){"Mesh"===t.type&&"FMMeshStandardMaterial"===t.material.type&&(e.Qt&&(t.material.uniforms.isAnnulus.value||(t.material.uniforms.isAnnulus.value=!0,t.material.uniforms.circleC.value=new ct(e.jt.x-e.R.getX(),-e.jt.y+e.R.getY()),t.material.uniforms.color_a.value=e.jt.color_a),t.material.uniforms.maxR.value=e.jt.radius+e.jt.widthR,t.material.uniforms.minR.value=e.jt.radius),e.Wt&&(t.material.uniforms.isRect.value||(t.material.uniforms.isRect.value=!0,t.material.uniforms.sweepW.value=e.jt.width,t.material.uniforms.sweepH.value=e.jt.height,t.material.uniforms.se2N.value=e.jt.se2N,t.material.uniforms.se2RN.value=e.jt.se2RN,t.material.uniforms.color_r.value=e.jt.color_r),t.material.uniforms.moveP.value=e.jt.point))}),this.Zt=(new Date).getTime()}}])&&Kr(t.prototype,e),i&&Kr(t,i),n}();Object.assign(yi.prototype,{G:function(){this.R.enableUpdateRender()},J:function(){return"basic"===this.R.getRenderManager().type&&this.R.setRenderManager(new se),this.R.getRenderManager()},B:function(){for(var n=this,t=this.R.getBuilding().getFloors(),e=0;e<t.length;e++)for(var i=t[e].getLayers(),r=0;r<i.length;r++)i[r].type===fengmap.FMType.EXTERNAL_MODEL_LAYER&&i[r].scene.traverse(function(t){t.isGltf&&"Mesh"===t.type&&n.Yt.push(t)})}});var zi=yi,Jr={uniforms:{tDiffuse:{value:null},resolution:{value:new ct(1/1024,1/512)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["precision highp float;","","uniform sampler2D tDiffuse;","","uniform vec2 resolution;","","varying vec2 vUv;","","// FXAA 3.11 implementation by NVIDIA, ported to WebGL by Agost Biro (biro@archilogic.com)","","//----------------------------------------------------------------------------------","// File:        es3-keplerFXAAassetsshaders/FXAA_DefaultES.frag","// SDK Version: v3.00","// Email:       gameworks@nvidia.com","// Site:        http://developer.nvidia.com/","//","// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.","//","// Redistribution and use in source and binary forms, with or without","// modification, are permitted provided that the following conditions","// are met:","//  * Redistributions of source code must retain the above copyright","//    notice, this list of conditions and the following disclaimer.","//  * Redistributions in binary form must reproduce the above copyright","//    notice, this list of conditions and the following disclaimer in the","//    documentation and/or other materials provided with the distribution.","//  * Neither the name of NVIDIA CORPORATION nor the names of its","//    contributors may be used to endorse or promote products derived","//    from this software without specific prior written permission.","//","// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY","// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE","// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR","// PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR","// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,","// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,","// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR","// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY","// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT","// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE","// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.","//","//----------------------------------------------------------------------------------","","#define FXAA_PC 1","#define FXAA_GLSL_100 1","#define FXAA_QUALITY_PRESET 12","","#define FXAA_GREEN_AS_LUMA 1","","/*--------------------------------------------------------------------------*/","#ifndef FXAA_PC_CONSOLE","    //","    // The console algorithm for PC is included","    // for developers targeting really low spec machines.","    // Likely better to just run FXAA_PC, and use a really low preset.","    //","    #define FXAA_PC_CONSOLE 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_GLSL_120","    #define FXAA_GLSL_120 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_GLSL_130","    #define FXAA_GLSL_130 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_HLSL_3","    #define FXAA_HLSL_3 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_HLSL_4","    #define FXAA_HLSL_4 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_HLSL_5","    #define FXAA_HLSL_5 0","#endif","/*==========================================================================*/","#ifndef FXAA_GREEN_AS_LUMA","    //","    // For those using non-linear color,","    // and either not able to get luma in alpha, or not wanting to,","    // this enables FXAA to run using green as a proxy for luma.","    // So with this enabled, no need to pack luma in alpha.","    //","    // This will turn off AA on anything which lacks some amount of green.","    // Pure red and blue or combination of only R and B, will get no AA.","    //","    // Might want to lower the settings for both,","    //    fxaaConsoleEdgeThresholdMin","    //    fxaaQualityEdgeThresholdMin","    // In order to insure AA does not get turned off on colors","    // which contain a minor amount of green.","    //","    // 1 = On.","    // 0 = Off.","    //","    #define FXAA_GREEN_AS_LUMA 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_EARLY_EXIT","    //","    // Controls algorithm's early exit path.","    // On PS3 turning this ON adds 2 cycles to the shader.","    // On 360 turning this OFF adds 10ths of a millisecond to the shader.","    // Turning this off on console will result in a more blurry image.","    // So this defaults to on.","    //","    // 1 = On.","    // 0 = Off.","    //","    #define FXAA_EARLY_EXIT 1","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_DISCARD","    //","    // Only valid for PC OpenGL currently.","    // Probably will not work when FXAA_GREEN_AS_LUMA = 1.","    //","    // 1 = Use discard on pixels which don't need AA.","    //     For APIs which enable concurrent TEX+ROP from same surface.","    // 0 = Return unchanged color on pixels which don't need AA.","    //","    #define FXAA_DISCARD 0","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_FAST_PIXEL_OFFSET","    //","    // Used for GLSL 120 only.","    //","    // 1 = GL API supports fast pixel offsets","    // 0 = do not use fast pixel offsets","    //","    #ifdef GL_EXT_gpu_shader4","        #define FXAA_FAST_PIXEL_OFFSET 1","    #endif","    #ifdef GL_NV_gpu_shader5","        #define FXAA_FAST_PIXEL_OFFSET 1","    #endif","    #ifdef GL_ARB_gpu_shader5","        #define FXAA_FAST_PIXEL_OFFSET 1","    #endif","    #ifndef FXAA_FAST_PIXEL_OFFSET","        #define FXAA_FAST_PIXEL_OFFSET 0","    #endif","#endif","/*--------------------------------------------------------------------------*/","#ifndef FXAA_GATHER4_ALPHA","    //","    // 1 = API supports gather4 on alpha channel.","    // 0 = API does not support gather4 on alpha channel.","    //","    #if (FXAA_HLSL_5 == 1)","        #define FXAA_GATHER4_ALPHA 1","    #endif","    #ifdef GL_ARB_gpu_shader5","        #define FXAA_GATHER4_ALPHA 1","    #endif","    #ifdef GL_NV_gpu_shader5","        #define FXAA_GATHER4_ALPHA 1","    #endif","    #ifndef FXAA_GATHER4_ALPHA","        #define FXAA_GATHER4_ALPHA 0","    #endif","#endif","","","/*============================================================================","                        FXAA QUALITY - TUNING KNOBS","------------------------------------------------------------------------------","NOTE the other tuning knobs are now in the shader function inputs!","============================================================================*/","#ifndef FXAA_QUALITY_PRESET","    //","    // Choose the quality preset.","    // This needs to be compiled into the shader as it effects code.","    // Best option to include multiple presets is to","    // in each shader define the preset, then include this file.","    //","    // OPTIONS","    // -----------------------------------------------------------------------","    // 10 to 15 - default medium dither (10=fastest, 15=highest quality)","    // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)","    // 39       - no dither, very expensive","    //","    // NOTES","    // -----------------------------------------------------------------------","    // 12 = slightly faster then FXAA 3.9 and higher edge quality (default)","    // 13 = about same speed as FXAA 3.9 and better than 12","    // 23 = closest to FXAA 3.9 visually and performance wise","    //  _ = the lowest digit is directly related to performance","    // _  = the highest digit is directly related to style","    //","    #define FXAA_QUALITY_PRESET 12","#endif","","","/*============================================================================","","                           FXAA QUALITY - PRESETS","","============================================================================*/","","/*============================================================================","                     FXAA QUALITY - MEDIUM DITHER PRESETS","============================================================================*/","#if (FXAA_QUALITY_PRESET == 10)","    #define FXAA_QUALITY_PS 3","    #define FXAA_QUALITY_P0 1.5","    #define FXAA_QUALITY_P1 3.0","    #define FXAA_QUALITY_P2 12.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 11)","    #define FXAA_QUALITY_PS 4","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 3.0","    #define FXAA_QUALITY_P3 12.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 12)","    #define FXAA_QUALITY_PS 5","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 4.0","    #define FXAA_QUALITY_P4 12.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 13)","    #define FXAA_QUALITY_PS 6","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 2.0","    #define FXAA_QUALITY_P4 4.0","    #define FXAA_QUALITY_P5 12.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 14)","    #define FXAA_QUALITY_PS 7","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 2.0","    #define FXAA_QUALITY_P4 2.0","    #define FXAA_QUALITY_P5 4.0","    #define FXAA_QUALITY_P6 12.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 15)","    #define FXAA_QUALITY_PS 8","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 2.0","    #define FXAA_QUALITY_P4 2.0","    #define FXAA_QUALITY_P5 2.0","    #define FXAA_QUALITY_P6 4.0","    #define FXAA_QUALITY_P7 12.0","#endif","","/*============================================================================","                     FXAA QUALITY - LOW DITHER PRESETS","============================================================================*/","#if (FXAA_QUALITY_PRESET == 20)","    #define FXAA_QUALITY_PS 3","    #define FXAA_QUALITY_P0 1.5","    #define FXAA_QUALITY_P1 2.0","    #define FXAA_QUALITY_P2 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 21)","    #define FXAA_QUALITY_PS 4","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 22)","    #define FXAA_QUALITY_PS 5","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 2.0","    #define FXAA_QUALITY_P4 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 23)","    #define FXAA_QUALITY_PS 6","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 2.0","    #define FXAA_QUALITY_P4 2.0","    #define FXAA_QUALITY_P5 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 24)","    #define FXAA_QUALITY_PS 7","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 2.0","    #define FXAA_QUALITY_P4 2.0","    #define FXAA_QUALITY_P5 3.0","    #define FXAA_QUALITY_P6 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 25)","    #define FXAA_QUALITY_PS 8","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 2.0","    #define FXAA_QUALITY_P4 2.0","    #define FXAA_QUALITY_P5 2.0","    #define FXAA_QUALITY_P6 4.0","    #define FXAA_QUALITY_P7 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 26)","    #define FXAA_QUALITY_PS 9","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 2.0","    #define FXAA_QUALITY_P4 2.0","    #define FXAA_QUALITY_P5 2.0","    #define FXAA_QUALITY_P6 2.0","    #define FXAA_QUALITY_P7 4.0","    #define FXAA_QUALITY_P8 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 27)","    #define FXAA_QUALITY_PS 10","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 2.0","    #define FXAA_QUALITY_P4 2.0","    #define FXAA_QUALITY_P5 2.0","    #define FXAA_QUALITY_P6 2.0","    #define FXAA_QUALITY_P7 2.0","    #define FXAA_QUALITY_P8 4.0","    #define FXAA_QUALITY_P9 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 28)","    #define FXAA_QUALITY_PS 11","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 2.0","    #define FXAA_QUALITY_P4 2.0","    #define FXAA_QUALITY_P5 2.0","    #define FXAA_QUALITY_P6 2.0","    #define FXAA_QUALITY_P7 2.0","    #define FXAA_QUALITY_P8 2.0","    #define FXAA_QUALITY_P9 4.0","    #define FXAA_QUALITY_P10 8.0","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_QUALITY_PRESET == 29)","    #define FXAA_QUALITY_PS 12","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.5","    #define FXAA_QUALITY_P2 2.0","    #define FXAA_QUALITY_P3 2.0","    #define FXAA_QUALITY_P4 2.0","    #define FXAA_QUALITY_P5 2.0","    #define FXAA_QUALITY_P6 2.0","    #define FXAA_QUALITY_P7 2.0","    #define FXAA_QUALITY_P8 2.0","    #define FXAA_QUALITY_P9 2.0","    #define FXAA_QUALITY_P10 4.0","    #define FXAA_QUALITY_P11 8.0","#endif","","/*============================================================================","                     FXAA QUALITY - EXTREME QUALITY","============================================================================*/","#if (FXAA_QUALITY_PRESET == 39)","    #define FXAA_QUALITY_PS 12","    #define FXAA_QUALITY_P0 1.0","    #define FXAA_QUALITY_P1 1.0","    #define FXAA_QUALITY_P2 1.0","    #define FXAA_QUALITY_P3 1.0","    #define FXAA_QUALITY_P4 1.0","    #define FXAA_QUALITY_P5 1.5","    #define FXAA_QUALITY_P6 2.0","    #define FXAA_QUALITY_P7 2.0","    #define FXAA_QUALITY_P8 2.0","    #define FXAA_QUALITY_P9 2.0","    #define FXAA_QUALITY_P10 4.0","    #define FXAA_QUALITY_P11 8.0","#endif","","","","/*============================================================================","","                                API PORTING","","============================================================================*/","#if (FXAA_GLSL_100 == 1) || (FXAA_GLSL_120 == 1) || (FXAA_GLSL_130 == 1)","    #define FxaaBool bool","    #define FxaaDiscard discard","    #define FxaaFloat float","    #define FxaaFloat2 vec2","    #define FxaaFloat3 vec3","    #define FxaaFloat4 vec4","    #define FxaaHalf float","    #define FxaaHalf2 vec2","    #define FxaaHalf3 vec3","    #define FxaaHalf4 vec4","    #define FxaaInt2 ivec2","    #define FxaaSat(x) clamp(x, 0.0, 1.0)","    #define FxaaTex sampler2D","#else","    #define FxaaBool bool","    #define FxaaDiscard clip(-1)","    #define FxaaFloat float","    #define FxaaFloat2 float2","    #define FxaaFloat3 float3","    #define FxaaFloat4 float4","    #define FxaaHalf half","    #define FxaaHalf2 half2","    #define FxaaHalf3 half3","    #define FxaaHalf4 half4","    #define FxaaSat(x) saturate(x)","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_GLSL_100 == 1)","  #define FxaaTexTop(t, p) texture2D(t, p, 0.0)","  #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_GLSL_120 == 1)","    // Requires,","    //  #version 120","    // And at least,","    //  #extension GL_EXT_gpu_shader4 : enable","    //  (or set FXAA_FAST_PIXEL_OFFSET 1 to work like DX9)","    #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)","    #if (FXAA_FAST_PIXEL_OFFSET == 1)","        #define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)","    #else","        #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)","    #endif","    #if (FXAA_GATHER4_ALPHA == 1)","        // use #extension GL_ARB_gpu_shader5 : enable","        #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)","        #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)","        #define FxaaTexGreen4(t, p) textureGather(t, p, 1)","        #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)","    #endif","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_GLSL_130 == 1)",'    // Requires "#version 130" or better',"    #define FxaaTexTop(t, p) textureLod(t, p, 0.0)","    #define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)","    #if (FXAA_GATHER4_ALPHA == 1)","        // use #extension GL_ARB_gpu_shader5 : enable","        #define FxaaTexAlpha4(t, p) textureGather(t, p, 3)","        #define FxaaTexOffAlpha4(t, p, o) textureGatherOffset(t, p, o, 3)","        #define FxaaTexGreen4(t, p) textureGather(t, p, 1)","        #define FxaaTexOffGreen4(t, p, o) textureGatherOffset(t, p, o, 1)","    #endif","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_HLSL_3 == 1)","    #define FxaaInt2 float2","    #define FxaaTex sampler2D","    #define FxaaTexTop(t, p) tex2Dlod(t, float4(p, 0.0, 0.0))","    #define FxaaTexOff(t, p, o, r) tex2Dlod(t, float4(p + (o * r), 0, 0))","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_HLSL_4 == 1)","    #define FxaaInt2 int2","    struct FxaaTex { SamplerState smpl; Texture2D tex; };","    #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)","    #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)","#endif","/*--------------------------------------------------------------------------*/","#if (FXAA_HLSL_5 == 1)","    #define FxaaInt2 int2","    struct FxaaTex { SamplerState smpl; Texture2D tex; };","    #define FxaaTexTop(t, p) t.tex.SampleLevel(t.smpl, p, 0.0)","    #define FxaaTexOff(t, p, o, r) t.tex.SampleLevel(t.smpl, p, 0.0, o)","    #define FxaaTexAlpha4(t, p) t.tex.GatherAlpha(t.smpl, p)","    #define FxaaTexOffAlpha4(t, p, o) t.tex.GatherAlpha(t.smpl, p, o)","    #define FxaaTexGreen4(t, p) t.tex.GatherGreen(t.smpl, p)","    #define FxaaTexOffGreen4(t, p, o) t.tex.GatherGreen(t.smpl, p, o)","#endif","","","/*============================================================================","                   GREEN AS LUMA OPTION SUPPORT FUNCTION","============================================================================*/","#if (FXAA_GREEN_AS_LUMA == 0)","    FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }","#else","    FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }","#endif","","","","","/*============================================================================","","                             FXAA3 QUALITY - PC","","============================================================================*/","#if (FXAA_PC == 1)","/*--------------------------------------------------------------------------*/","FxaaFloat4 FxaaPixelShader(","    //","    // Use noperspective interpolation here (turn off perspective interpolation).","    // {xy} = center of pixel","    FxaaFloat2 pos,","    //","    // Used only for FXAA Console, and not used on the 360 version.","    // Use noperspective interpolation here (turn off perspective interpolation).","    // {xy_} = upper left of pixel","    // {_zw} = lower right of pixel","    FxaaFloat4 fxaaConsolePosPos,","    //","    // Input color texture.","    // {rgb_} = color in linear or perceptual color space","    // if (FXAA_GREEN_AS_LUMA == 0)","    //     {__a} = luma in perceptual color space (not linear)","    FxaaTex tex,","    //","    // Only used on the optimized 360 version of FXAA Console.",'    // For everything but 360, just use the same input here as for "tex".',"    // For 360, same texture, just alias with a 2nd sampler.","    // This sampler needs to have an exponent bias of -1.","    FxaaTex fxaaConsole360TexExpBiasNegOne,","    //","    // Only used on the optimized 360 version of FXAA Console.",'    // For everything but 360, just use the same input here as for "tex".',"    // For 360, same texture, just alias with a 3nd sampler.","    // This sampler needs to have an exponent bias of -2.","    FxaaTex fxaaConsole360TexExpBiasNegTwo,","    //","    // Only used on FXAA Quality.","    // This must be from a constant/uniform.","    // {x_} = 1.0/screenWidthInPixels","    // {_y} = 1.0/screenHeightInPixels","    FxaaFloat2 fxaaQualityRcpFrame,","    //","    // Only used on FXAA Console.","    // This must be from a constant/uniform.","    // This effects sub-pixel AA quality and inversely sharpness.","    //   Where N ranges between,","    //     N = 0.50 (default)","    //     N = 0.33 (sharper)","    // {x__} = -N/screenWidthInPixels","    // {_y_} = -N/screenHeightInPixels","    // {_z_} =  N/screenWidthInPixels","    // {__w} =  N/screenHeightInPixels","    FxaaFloat4 fxaaConsoleRcpFrameOpt,","    //","    // Only used on FXAA Console.","    // Not used on 360, but used on PS3 and PC.","    // This must be from a constant/uniform.","    // {x__} = -2.0/screenWidthInPixels","    // {_y_} = -2.0/screenHeightInPixels","    // {_z_} =  2.0/screenWidthInPixels","    // {__w} =  2.0/screenHeightInPixels","    FxaaFloat4 fxaaConsoleRcpFrameOpt2,","    //","    // Only used on FXAA Console.","    // Only used on 360 in place of fxaaConsoleRcpFrameOpt2.","    // This must be from a constant/uniform.","    // {x__} =  8.0/screenWidthInPixels","    // {_y_} =  8.0/screenHeightInPixels","    // {_z_} = -4.0/screenWidthInPixels","    // {__w} = -4.0/screenHeightInPixels","    FxaaFloat4 fxaaConsole360RcpFrameOpt2,","    //","    // Only used on FXAA Quality.","    // This used to be the FXAA_QUALITY_SUBPIX define.","    // It is here now to allow easier tuning.","    // Choose the amount of sub-pixel aliasing removal.","    // This can effect sharpness.","    //   1.00 - upper limit (softer)","    //   0.75 - default amount of filtering","    //   0.50 - lower limit (sharper, less sub-pixel aliasing removal)","    //   0.25 - almost off","    //   0.00 - completely off","    FxaaFloat fxaaQualitySubpix,","    //","    // Only used on FXAA Quality.","    // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.","    // It is here now to allow easier tuning.","    // The minimum amount of local contrast required to apply algorithm.","    //   0.333 - too little (faster)","    //   0.250 - low quality","    //   0.166 - default","    //   0.125 - high quality","    //   0.063 - overkill (slower)","    FxaaFloat fxaaQualityEdgeThreshold,","    //","    // Only used on FXAA Quality.","    // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.","    // It is here now to allow easier tuning.","    // Trims the algorithm from processing darks.","    //   0.0833 - upper limit (default, the start of visible unfiltered edges)","    //   0.0625 - high quality (faster)","    //   0.0312 - visible limit (slower)","    // Special notes when using FXAA_GREEN_AS_LUMA,","    //   Likely want to set this to zero.","    //   As colors that are mostly not-green","    //   will appear very dark in the green channel!","    //   Tune by looking at mostly non-green content,","    //   then start at zero and increase until aliasing is a problem.","    FxaaFloat fxaaQualityEdgeThresholdMin,","    //","    // Only used on FXAA Console.","    // This used to be the FXAA_CONSOLE_EDGE_SHARPNESS define.","    // It is here now to allow easier tuning.","    // This does not effect PS3, as this needs to be compiled in.","    //   Use FXAA_CONSOLE_PS3_EDGE_SHARPNESS for PS3.","    //   Due to the PS3 being ALU bound,","    //   there are only three safe values here: 2 and 4 and 8.","    //   These options use the shaders ability to a free *|/ by 2|4|8.","    // For all other platforms can be a non-power of two.","    //   8.0 is sharper (default!!!)","    //   4.0 is softer","    //   2.0 is really soft (good only for vector graphics inputs)","    FxaaFloat fxaaConsoleEdgeSharpness,","    //","    // Only used on FXAA Console.","    // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD define.","    // It is here now to allow easier tuning.","    // This does not effect PS3, as this needs to be compiled in.","    //   Use FXAA_CONSOLE_PS3_EDGE_THRESHOLD for PS3.","    //   Due to the PS3 being ALU bound,","    //   there are only two safe values here: 1/4 and 1/8.","    //   These options use the shaders ability to a free *|/ by 2|4|8.","    // The console setting has a different mapping than the quality setting.","    // Other platforms can use other values.","    //   0.125 leaves less aliasing, but is softer (default!!!)","    //   0.25 leaves more aliasing, and is sharper","    FxaaFloat fxaaConsoleEdgeThreshold,","    //","    // Only used on FXAA Console.","    // This used to be the FXAA_CONSOLE_EDGE_THRESHOLD_MIN define.","    // It is here now to allow easier tuning.","    // Trims the algorithm from processing darks.","    // The console setting has a different mapping than the quality setting.","    // This only applies when FXAA_EARLY_EXIT is 1.","    // This does not apply to PS3,","    // PS3 was simplified to avoid more shader instructions.","    //   0.06 - faster but more aliasing in darks","    //   0.05 - default","    //   0.04 - slower and less aliasing in darks","    // Special notes when using FXAA_GREEN_AS_LUMA,","    //   Likely want to set this to zero.","    //   As colors that are mostly not-green","    //   will appear very dark in the green channel!","    //   Tune by looking at mostly non-green content,","    //   then start at zero and increase until aliasing is a problem.","    FxaaFloat fxaaConsoleEdgeThresholdMin,","    //","    // Extra constants for 360 FXAA Console only.","    // Use zeros or anything else for other platforms.","    // These must be in physical constant registers and NOT immediates.","    // Immediates will result in compiler un-optimizing.","    // {xyzw} = float4(1.0, -1.0, 0.25, -0.25)","    FxaaFloat4 fxaaConsole360ConstDir",") {","/*--------------------------------------------------------------------------*/","    FxaaFloat2 posM;","    posM.x = pos.x;","    posM.y = pos.y;","    #if (FXAA_GATHER4_ALPHA == 1)","        #if (FXAA_DISCARD == 0)","            FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);","            #if (FXAA_GREEN_AS_LUMA == 0)","                #define lumaM rgbyM.w","            #else","                #define lumaM rgbyM.y","            #endif","        #endif","        #if (FXAA_GREEN_AS_LUMA == 0)","            FxaaFloat4 luma4A = FxaaTexAlpha4(tex, posM);","            FxaaFloat4 luma4B = FxaaTexOffAlpha4(tex, posM, FxaaInt2(-1, -1));","        #else","            FxaaFloat4 luma4A = FxaaTexGreen4(tex, posM);","            FxaaFloat4 luma4B = FxaaTexOffGreen4(tex, posM, FxaaInt2(-1, -1));","        #endif","        #if (FXAA_DISCARD == 1)","            #define lumaM luma4A.w","        #endif","        #define lumaE luma4A.z","        #define lumaS luma4A.x","        #define lumaSE luma4A.y","        #define lumaNW luma4B.w","        #define lumaN luma4B.z","        #define lumaW luma4B.x","    #else","        FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);","        #if (FXAA_GREEN_AS_LUMA == 0)","            #define lumaM rgbyM.w","        #else","            #define lumaM rgbyM.y","        #endif","        #if (FXAA_GLSL_100 == 1)","          FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0, 1.0), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 0.0), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 0.0,-1.0), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));","        #else","          FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));","        #endif","    #endif","/*--------------------------------------------------------------------------*/","    FxaaFloat maxSM = max(lumaS, lumaM);","    FxaaFloat minSM = min(lumaS, lumaM);","    FxaaFloat maxESM = max(lumaE, maxSM);","    FxaaFloat minESM = min(lumaE, minSM);","    FxaaFloat maxWN = max(lumaN, lumaW);","    FxaaFloat minWN = min(lumaN, lumaW);","    FxaaFloat rangeMax = max(maxWN, maxESM);","    FxaaFloat rangeMin = min(minWN, minESM);","    FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;","    FxaaFloat range = rangeMax - rangeMin;","    FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);","    FxaaBool earlyExit = range < rangeMaxClamped;","/*--------------------------------------------------------------------------*/","    if(earlyExit)","        #if (FXAA_DISCARD == 1)","            FxaaDiscard;","        #else","            return rgbyM;","        #endif","/*--------------------------------------------------------------------------*/","    #if (FXAA_GATHER4_ALPHA == 0)","        #if (FXAA_GLSL_100 == 1)","          FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0, 1.0), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2( 1.0,-1.0), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));","        #else","          FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));","          FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));","        #endif","    #else","        FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));","        FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));","    #endif","/*--------------------------------------------------------------------------*/","    FxaaFloat lumaNS = lumaN + lumaS;","    FxaaFloat lumaWE = lumaW + lumaE;","    FxaaFloat subpixRcpRange = 1.0/range;","    FxaaFloat subpixNSWE = lumaNS + lumaWE;","    FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;","    FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;","/*--------------------------------------------------------------------------*/","    FxaaFloat lumaNESE = lumaNE + lumaSE;","    FxaaFloat lumaNWNE = lumaNW + lumaNE;","    FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;","    FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;","/*--------------------------------------------------------------------------*/","    FxaaFloat lumaNWSW = lumaNW + lumaSW;","    FxaaFloat lumaSWSE = lumaSW + lumaSE;","    FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);","    FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);","    FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;","    FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;","    FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;","    FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;","/*--------------------------------------------------------------------------*/","    FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;","    FxaaFloat lengthSign = fxaaQualityRcpFrame.x;","    FxaaBool horzSpan = edgeHorz >= edgeVert;","    FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;","/*--------------------------------------------------------------------------*/","    if(!horzSpan) lumaN = lumaW;","    if(!horzSpan) lumaS = lumaE;","    if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;","    FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;","/*--------------------------------------------------------------------------*/","    FxaaFloat gradientN = lumaN - lumaM;","    FxaaFloat gradientS = lumaS - lumaM;","    FxaaFloat lumaNN = lumaN + lumaM;","    FxaaFloat lumaSS = lumaS + lumaM;","    FxaaBool pairN = abs(gradientN) >= abs(gradientS);","    FxaaFloat gradient = max(abs(gradientN), abs(gradientS));","    if(pairN) lengthSign = -lengthSign;","    FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);","/*--------------------------------------------------------------------------*/","    FxaaFloat2 posB;","    posB.x = posM.x;","    posB.y = posM.y;","    FxaaFloat2 offNP;","    offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;","    offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;","    if(!horzSpan) posB.x += lengthSign * 0.5;","    if( horzSpan) posB.y += lengthSign * 0.5;","/*--------------------------------------------------------------------------*/","    FxaaFloat2 posN;","    posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;","    posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;","    FxaaFloat2 posP;","    posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;","    posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;","    FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;","    FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));","    FxaaFloat subpixE = subpixC * subpixC;","    FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));","/*--------------------------------------------------------------------------*/","    if(!pairN) lumaNN = lumaSS;","    FxaaFloat gradientScaled = gradient * 1.0/4.0;","    FxaaFloat lumaMM = lumaM - lumaNN * 0.5;","    FxaaFloat subpixF = subpixD * subpixE;","    FxaaBool lumaMLTZero = lumaMM < 0.0;","/*--------------------------------------------------------------------------*/","    lumaEndN -= lumaNN * 0.5;","    lumaEndP -= lumaNN * 0.5;","    FxaaBool doneN = abs(lumaEndN) >= gradientScaled;","    FxaaBool doneP = abs(lumaEndP) >= gradientScaled;","    if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;","    if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;","    FxaaBool doneNP = (!doneN) || (!doneP);","    if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;","    if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;","/*--------------------------------------------------------------------------*/","    if(doneNP) {","        if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","        if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","        if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","        if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","        doneN = abs(lumaEndN) >= gradientScaled;","        doneP = abs(lumaEndP) >= gradientScaled;","        if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;","        if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;","        doneNP = (!doneN) || (!doneP);","        if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;","        if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;","/*--------------------------------------------------------------------------*/","        #if (FXAA_QUALITY_PS > 3)","        if(doneNP) {","            if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","            if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","            if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","            if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","            doneN = abs(lumaEndN) >= gradientScaled;","            doneP = abs(lumaEndP) >= gradientScaled;","            if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;","            if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;","            doneNP = (!doneN) || (!doneP);","            if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;","            if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;","/*--------------------------------------------------------------------------*/","            #if (FXAA_QUALITY_PS > 4)","            if(doneNP) {","                if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","                if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","                if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","                if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","                doneN = abs(lumaEndN) >= gradientScaled;","                doneP = abs(lumaEndP) >= gradientScaled;","                if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;","                if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;","                doneNP = (!doneN) || (!doneP);","                if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;","                if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;","/*--------------------------------------------------------------------------*/","                #if (FXAA_QUALITY_PS > 5)","                if(doneNP) {","                    if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","                    if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","                    if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","                    if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","                    doneN = abs(lumaEndN) >= gradientScaled;","                    doneP = abs(lumaEndP) >= gradientScaled;","                    if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;","                    if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;","                    doneNP = (!doneN) || (!doneP);","                    if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;","                    if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;","/*--------------------------------------------------------------------------*/","                    #if (FXAA_QUALITY_PS > 6)","                    if(doneNP) {","                        if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","                        if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","                        if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","                        if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","                        doneN = abs(lumaEndN) >= gradientScaled;","                        doneP = abs(lumaEndP) >= gradientScaled;","                        if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;","                        if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;","                        doneNP = (!doneN) || (!doneP);","                        if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;","                        if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;","/*--------------------------------------------------------------------------*/","                        #if (FXAA_QUALITY_PS > 7)","                        if(doneNP) {","                            if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","                            if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","                            if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","                            if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","                            doneN = abs(lumaEndN) >= gradientScaled;","                            doneP = abs(lumaEndP) >= gradientScaled;","                            if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;","                            if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;","                            doneNP = (!doneN) || (!doneP);","                            if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;","                            if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;","/*--------------------------------------------------------------------------*/","    #if (FXAA_QUALITY_PS > 8)","    if(doneNP) {","        if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","        if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","        if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","        if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","        doneN = abs(lumaEndN) >= gradientScaled;","        doneP = abs(lumaEndP) >= gradientScaled;","        if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;","        if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;","        doneNP = (!doneN) || (!doneP);","        if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;","        if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;","/*--------------------------------------------------------------------------*/","        #if (FXAA_QUALITY_PS > 9)","        if(doneNP) {","            if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","            if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","            if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","            if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","            doneN = abs(lumaEndN) >= gradientScaled;","            doneP = abs(lumaEndP) >= gradientScaled;","            if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;","            if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;","            doneNP = (!doneN) || (!doneP);","            if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;","            if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;","/*--------------------------------------------------------------------------*/","            #if (FXAA_QUALITY_PS > 10)","            if(doneNP) {","                if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","                if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","                if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","                if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","                doneN = abs(lumaEndN) >= gradientScaled;","                doneP = abs(lumaEndP) >= gradientScaled;","                if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;","                if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;","                doneNP = (!doneN) || (!doneP);","                if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;","                if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;","/*--------------------------------------------------------------------------*/","                #if (FXAA_QUALITY_PS > 11)","                if(doneNP) {","                    if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","                    if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","                    if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","                    if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","                    doneN = abs(lumaEndN) >= gradientScaled;","                    doneP = abs(lumaEndP) >= gradientScaled;","                    if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;","                    if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;","                    doneNP = (!doneN) || (!doneP);","                    if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;","                    if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;","/*--------------------------------------------------------------------------*/","                    #if (FXAA_QUALITY_PS > 12)","                    if(doneNP) {","                        if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));","                        if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));","                        if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;","                        if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;","                        doneN = abs(lumaEndN) >= gradientScaled;","                        doneP = abs(lumaEndP) >= gradientScaled;","                        if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;","                        if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;","                        doneNP = (!doneN) || (!doneP);","                        if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;","                        if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;","/*--------------------------------------------------------------------------*/","                    }","                    #endif","/*--------------------------------------------------------------------------*/","                }","                #endif","/*--------------------------------------------------------------------------*/","            }","            #endif","/*--------------------------------------------------------------------------*/","        }","        #endif","/*--------------------------------------------------------------------------*/","    }","    #endif","/*--------------------------------------------------------------------------*/","                        }","                        #endif","/*--------------------------------------------------------------------------*/","                    }","                    #endif","/*--------------------------------------------------------------------------*/","                }","                #endif","/*--------------------------------------------------------------------------*/","            }","            #endif","/*--------------------------------------------------------------------------*/","        }","        #endif","/*--------------------------------------------------------------------------*/","    }","/*--------------------------------------------------------------------------*/","    FxaaFloat dstN = posM.x - posN.x;","    FxaaFloat dstP = posP.x - posM.x;","    if(!horzSpan) dstN = posM.y - posN.y;","    if(!horzSpan) dstP = posP.y - posM.y;","/*--------------------------------------------------------------------------*/","    FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;","    FxaaFloat spanLength = (dstP + dstN);","    FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;","    FxaaFloat spanLengthRcp = 1.0/spanLength;","/*--------------------------------------------------------------------------*/","    FxaaBool directionN = dstN < dstP;","    FxaaFloat dst = min(dstN, dstP);","    FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;","    FxaaFloat subpixG = subpixF * subpixF;","    FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;","    FxaaFloat subpixH = subpixG * fxaaQualitySubpix;","/*--------------------------------------------------------------------------*/","    FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;","    FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);","    if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;","    if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;","    #if (FXAA_DISCARD == 1)","        return FxaaTexTop(tex, posM);","    #else","        return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);","    #endif","}","/*==========================================================================*/","#endif","","void main() {","  gl_FragColor = FxaaPixelShader(","    vUv,","    vec4(0.0),","    tDiffuse,","    tDiffuse,","    tDiffuse,","    resolution,","    vec4(0.0),","    vec4(0.0),","    vec4(0.0),","    0.75,","    0.166,","    0.0833,","    0.0,","    0.0,","    0.0,","    vec4(0.0)","  );","","  // TODO avoid querying texture twice for same texel","  gl_FragColor.a = texture2D(tDiffuse, vUv).a;","}"].join("\n")},$r={defines:{NUM_SAMPLES:7,NUM_RINGS:4,NORMAL_TEXTURE:0,DIFFUSE_TEXTURE:0,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},tDiffuse:{value:null},tNormal:{value:null},size:{value:new ct(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new Dt},cameraInverseProjectionMatrix:{value:new Dt},scale:{value:1},intensity:{value:.1},bias:{value:.5},minResolution:{value:0},kernelRadius:{value:100},randomSeed:{value:0}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","varying vec2 vUv;","#if DIFFUSE_TEXTURE == 1","uniform sampler2D tDiffuse;","#endif","uniform sampler2D tDepth;","#if NORMAL_TEXTURE == 1","uniform sampler2D tNormal;","#endif","uniform float cameraNear;","uniform float cameraFar;","uniform mat4 cameraProjectionMatrix;","uniform mat4 cameraInverseProjectionMatrix;","uniform float scale;","uniform float intensity;","uniform float bias;","uniform float kernelRadius;","uniform float minResolution;","uniform vec2 size;","uniform float randomSeed;","// RGBA depth","#include <packing>","vec4 getDefaultColor( const in vec2 screenPosition ) {","\t#if DIFFUSE_TEXTURE == 1","\treturn texture2D( tDiffuse, vUv );","\t#else","\treturn vec4( 1.0 );","\t#endif","}","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","\t#else","\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );","\t#endif","}","vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {","\tfloat clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];","\tvec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );","\tclipPosition *= clipW; // unprojection.","\treturn ( cameraInverseProjectionMatrix * clipPosition ).xyz;","}","vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {","\t#if NORMAL_TEXTURE == 1","\treturn unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );","\t#else","\treturn normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );","\t#endif","}","float scaleDividedByCameraFar;","float minResolutionMultipliedByCameraFar;","float getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {","\tvec3 viewDelta = sampleViewPosition - centerViewPosition;","\tfloat viewDistance = length( viewDelta );","\tfloat scaledScreenDistance = scaleDividedByCameraFar * viewDistance;","\treturn max(0.0, (dot(centerViewNormal, viewDelta) - minResolutionMultipliedByCameraFar) / scaledScreenDistance - bias) / (1.0 + pow2( scaledScreenDistance ) );","}","// moving costly divides into consts","const float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );","const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );","float getAmbientOcclusion( const in vec3 centerViewPosition ) {","\t// precompute some variables require in getOcclusion.","\tscaleDividedByCameraFar = scale / cameraFar;","\tminResolutionMultipliedByCameraFar = minResolution * cameraFar;","\tvec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );","\t// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/","\tfloat angle = rand( vUv + randomSeed ) * PI2;","\tvec2 radius = vec2( kernelRadius * INV_NUM_SAMPLES ) / size;","\tvec2 radiusStep = radius;","\tfloat occlusionSum = 0.0;","\tfloat weightSum = 0.0;","\tfor( int i = 0; i < NUM_SAMPLES; i ++ ) {","\t\tvec2 sampleUv = vUv + vec2( cos( angle ), sin( angle ) ) * radius;","\t\tradius += radiusStep;","\t\tangle += ANGLE_STEP;","\t\tfloat sampleDepth = getDepth( sampleUv );","\t\tif( sampleDepth >= ( 1.0 - EPSILON ) ) {","\t\t\tcontinue;","\t\t}","\t\tfloat sampleViewZ = getViewZ( sampleDepth );","\t\tvec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );","\t\tocclusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );","\t\tweightSum += 1.0;","\t}","\tif( weightSum == 0.0 ) discard;","\treturn occlusionSum * ( intensity / weightSum );","}","void main() {","\tfloat centerDepth = getDepth( vUv );","\tif( centerDepth >= ( 1.0 - EPSILON ) ) {","\t\tdiscard;","\t}","\tfloat centerViewZ = getViewZ( centerDepth );","\tvec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );","\tfloat ambientOcclusion = getAmbientOcclusion( viewPosition );","\tgl_FragColor = getDefaultColor( vUv );","\tgl_FragColor.xyz *=  1.0 - ambientOcclusion;","}"].join("\n")},ta={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new ct(512,512)},sampleUvOffsets:{value:[new ct(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader:["#include <common>","uniform vec2 size;","varying vec2 vUv;","varying vec2 vInvSize;","void main() {","\tvUv = uv;","\tvInvSize = 1.0 / size;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","#include <packing>","uniform sampler2D tDiffuse;","uniform sampler2D tDepth;","uniform float cameraNear;","uniform float cameraFar;","uniform float depthCutoff;","uniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];","uniform float sampleWeights[ KERNEL_RADIUS + 1 ];","varying vec2 vUv;","varying vec2 vInvSize;","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","\t#else","\treturn orthographicDepthToViewZ( depth, cameraNear, cameraFar );","\t#endif","}","void main() {","\tfloat depth = getDepth( vUv );","\tif( depth >= ( 1.0 - EPSILON ) ) {","\t\tdiscard;","\t}","\tfloat centerViewZ = -getViewZ( depth );","\tbool rBreak = false, lBreak = false;","\tfloat weightSum = sampleWeights[0];","\tvec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;","\tfor( int i = 1; i <= KERNEL_RADIUS; i ++ ) {","\t\tfloat sampleWeight = sampleWeights[i];","\t\tvec2 sampleUvOffset = sampleUvOffsets[i] * vInvSize;","\t\tvec2 sampleUv = vUv + sampleUvOffset;","\t\tfloat viewZ = -getViewZ( getDepth( sampleUv ) );","\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) rBreak = true;","\t\tif( ! rBreak ) {","\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;","\t\t\tweightSum += sampleWeight;","\t\t}","\t\tsampleUv = vUv - sampleUvOffset;","\t\tviewZ = -getViewZ( getDepth( sampleUv ) );","\t\tif( abs( viewZ - centerViewZ ) > depthCutoff ) lBreak = true;","\t\tif( ! lBreak ) {","\t\t\tdiffuseSum += texture2D( tDiffuse, sampleUv ) * sampleWeight;","\t\t\tweightSum += sampleWeight;","\t\t}","\t}","\tgl_FragColor = diffuseSum / weightSum;","}"].join("\n")},na={createSampleWeights:function(t,n){for(var e,i,r=[],a=0;a<=t;a++)r.push((e=a,i=n,Math.exp(-e*e/(i*i*2))/(Math.sqrt(2*Math.PI)*i)));return r},createSampleOffsets:function(t,n){for(var e=[],i=0;i<=t;i++)e.push(n.clone().multiplyScalar(i));return e},configure:function(t,n,e,i){t.defines.KERNEL_RADIUS=n,t.uniforms.sampleUvOffsets.value=na.createSampleOffsets(n,i),t.uniforms.sampleWeights.value=na.createSampleWeights(n,e),t.needsUpdate=!0}},ea={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","#include <packing>","void main() {","\tfloat depth = 1.0 - unpackRGBAToDepth( texture2D( tDiffuse, vUv ) );","\tgl_FragColor = vec4( vec3( depth ), opacity );","}"].join("\n")};function ia(t,n,e,i,r,a,o,s,h,l){if(1026!==(l=void 0!==l?l:1026)&&1027!==l)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");zn.call(this,null,i,r,a,o,s,l,e=void 0===(e=void 0===e&&1026===l?1012:e)&&1027===l?1020:e,h),this.image={width:t,height:n},this.magFilter=void 0!==o?o:g,this.minFilter=void 0!==s?s:g,this.flipY=!1,this.generateMipmaps=!1}((ia.prototype=Object.create(zn.prototype)).constructor=ia).prototype.isDepthTexture=!0;function ra(t,n,e,i,r){ti.call(this),this.scene=t,this.camera=n,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=void 0!==e&&e,this.supportsNormalTexture=void 0!==i&&i,this.originalClearColor=new X,this.oldClearColor=new X,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=void 0!==r?new ct(r.x,r.y):new ct(256,256),this.saoRenderTarget=new ii(this.resolution.x,this.resolution.y,{minFilter:E,magFilter:E,format:x}),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new ii(this.resolution.x,this.resolution.y,{minFilter:g,magFilter:g,format:x}),this.depthRenderTarget=this.normalRenderTarget.clone(),this.supportsDepthTextureExtension&&((e=new ia).type=1012,e.minFilter=g,e.maxFilter=g,this.beautyRenderTarget.depthTexture=e,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new Ln,this.depthMaterial.depthPacking=3201,this.depthMaterial.blending=a,this.normalMaterial=new Mn,this.normalMaterial.blending=a,this.saoMaterial=new xn({defines:Object.assign({},$r.defines),fragmentShader:$r.fragmentShader,vertexShader:$r.vertexShader,uniforms:pn.clone($r.uniforms)}),this.saoMaterial.extensions.derivatives=!0,this.saoMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.saoMaterial.defines.NORMAL_TEXTURE=this.supportsNormalTexture?1:0,this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?e:this.depthRenderTarget.texture,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(this.camera.projectionMatrix),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=a,this.vBlurMaterial=new xn({uniforms:pn.clone(ta.uniforms),defines:Object.assign({},ta.defines),vertexShader:ta.vertexShader,fragmentShader:ta.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?e:this.depthRenderTarget.texture,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=a,this.hBlurMaterial=new xn({uniforms:pn.clone(ta.uniforms),defines:Object.assign({},ta.defines),vertexShader:ta.vertexShader,fragmentShader:ta.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?e:this.depthRenderTarget.texture,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=a,void 0===ei&&console.error("THREE.SAOPass relies on CopyShader"),this.materialCopy=new xn({uniforms:pn.clone(ei.uniforms),vertexShader:ei.vertexShader,fragmentShader:ei.fragmentShader,blending:a}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=5,this.materialCopy.blendSrc=208,this.materialCopy.blendDst=200,this.materialCopy.blendEquation=o,this.materialCopy.blendSrcAlpha=206,this.materialCopy.blendDstAlpha=200,this.materialCopy.blendEquationAlpha=o,this.depthCopy=new xn({uniforms:pn.clone(ea.uniforms),vertexShader:ea.vertexShader,fragmentShader:ea.fragmentShader,blending:a}),this.fsQuad=new ti.FullScreenQuad(null)}function aa(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}ra.OUTPUT={Beauty:1,Default:0,SAO:2,Depth:3,Normal:4},ra.prototype=Object.assign(Object.create(ti.prototype),{constructor:ra,render:function(t,n,e){var i,r;this.renderToScreen&&(this.materialCopy.blending=a,this.materialCopy.uniforms.tDiffuse.value=e.texture,this.materialCopy.needsUpdate=!0,this.renderPass(t,this.materialCopy,null)),1!==this.params.output&&(this.oldClearColor.copy(t.getClearColor()),this.oldClearAlpha=t.getClearAlpha(),i=t.autoClear,t.autoClear=!1,t.setRenderTarget(this.depthRenderTarget),t.clear(),this.saoMaterial.uniforms.bias.value=this.params.saoBias,this.saoMaterial.uniforms.intensity.value=this.params.saoIntensity,this.saoMaterial.uniforms.scale.value=this.params.saoScale,this.saoMaterial.uniforms.kernelRadius.value=this.params.saoKernelRadius,this.saoMaterial.uniforms.minResolution.value=this.params.saoMinResolution,this.saoMaterial.uniforms.cameraNear.value=this.camera.near,this.saoMaterial.uniforms.cameraFar.value=this.camera.far,r=this.params.saoBlurDepthCutoff*(this.camera.far-this.camera.near),this.vBlurMaterial.uniforms.depthCutoff.value=r,this.hBlurMaterial.uniforms.depthCutoff.value=r,this.vBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.vBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.hBlurMaterial.uniforms.cameraNear.value=this.camera.near,this.hBlurMaterial.uniforms.cameraFar.value=this.camera.far,this.params.saoBlurRadius=Math.floor(this.params.saoBlurRadius),this.prevStdDev===this.params.saoBlurStdDev&&this.prevNumSamples===this.params.saoBlurRadius||(na.configure(this.vBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new ct(0,1)),na.configure(this.hBlurMaterial,this.params.saoBlurRadius,this.params.saoBlurStdDev,new ct(1,0)),this.prevStdDev=this.params.saoBlurStdDev,this.prevNumSamples=this.params.saoBlurRadius),t.setClearColor(0),t.setRenderTarget(this.beautyRenderTarget),t.clear(),t.render(this.scene,this.camera),this.supportsDepthTextureExtension||this.renderOverride(t,this.depthMaterial,this.depthRenderTarget,0,1),this.supportsNormalTexture&&this.renderOverride(t,this.normalMaterial,this.normalRenderTarget,7829503,1),this.renderPass(t,this.saoMaterial,this.saoRenderTarget,16777215,1),this.params.saoBlur&&(this.renderPass(t,this.vBlurMaterial,this.blurIntermediateRenderTarget,16777215,1),this.renderPass(t,this.hBlurMaterial,this.saoRenderTarget,16777215,1)),r=this.materialCopy,3===this.params.output?this.supportsDepthTextureExtension?(this.materialCopy.uniforms.tDiffuse.value=this.beautyRenderTarget.depthTexture,this.materialCopy.needsUpdate=!0):(this.depthCopy.uniforms.tDiffuse.value=this.depthRenderTarget.texture,this.depthCopy.needsUpdate=!0,r=this.depthCopy):(4===this.params.output?this.materialCopy.uniforms.tDiffuse.value=this.normalRenderTarget.texture:this.materialCopy.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.materialCopy.needsUpdate=!0),0===this.params.output?r.blending=5:r.blending=a,this.renderPass(t,r,this.renderToScreen?null:e),t.setClearColor(this.oldClearColor,this.oldClearAlpha),t.autoClear=i)},renderPass:function(t,n,e,i,r){this.originalClearColor.copy(t.getClearColor());var a=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(e),t.autoClear=!1,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.fsQuad.material=n,this.fsQuad.render(t),t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(a)},renderOverride:function(t,n,e,i,r){this.originalClearColor.copy(t.getClearColor());var a=t.getClearAlpha(),o=t.autoClear;t.setRenderTarget(e),t.autoClear=!1,i=n.clearColor||i,r=n.clearAlpha||r,null!=i&&(t.setClearColor(i),t.setClearAlpha(r||0),t.clear()),this.scene.overrideMaterial=n,t.render(this.scene,this.camera),this.scene.overrideMaterial=null,t.autoClear=o,t.setClearColor(this.originalClearColor),t.setClearAlpha(a)},setSize:function(t,n){this.beautyRenderTarget.setSize(t,n),this.saoRenderTarget.setSize(t,n),this.blurIntermediateRenderTarget.setSize(t,n),this.normalRenderTarget.setSize(t,n),this.depthRenderTarget.setSize(t,n),this.saoMaterial.uniforms.size.value.set(t,n),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(this.camera.projectionMatrix),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.needsUpdate=!0,this.vBlurMaterial.uniforms.size.value.set(t,n),this.vBlurMaterial.needsUpdate=!0,this.hBlurMaterial.uniforms.size.value.set(t,n),this.hBlurMaterial.needsUpdate=!0}});Vr=function(){function e(t,n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.R=t,this.P=new he,this.K=this.J(),this.B(n)}var t,n,i;return t=e,(n=[{key:"getAttribute",value:function(t){for(var n in this.qt.params)if(n.toLowerCase()===("sao"+t).toLowerCase())return this.qt.params[n]}},{key:"setAttribute",value:function(t,n){for(var e in this.qt.params)e.toLowerCase()===("sao"+t).toLowerCase()&&(this.qt.params[e]=n)}},{key:"add",value:function(t){this.P.add(t)}},{key:"enable",value:function(){this.K.sao=this}},{key:"disable",value:function(){this.K.sao=null}},{key:"render",value:function(){this.Kt.render()}}])&&aa(t.prototype,n),i&&aa(t,i),e}();Object.assign(Vr.prototype,{J:function(){return"basic"===this.R.getRenderManager().type&&this.R.setRenderManager(new se),this.R.getRenderManager()},B:function(t){this.Kt=new pi(this.K.renderer),this.Jt=new ci(Jr),this.Jt.uniforms.resolution.value.set(1/this.R.getContainer().clientWidth,1/this.R.getContainer().clientHeight),this.$t=new li(this.P,this.R.camera),this.qt=new ra(this.P,this.R.camera,!1,!0),this.qt.params.output=ra.OUTPUT.Default,this.qt.params.saoBias=t.bias||-.8,this.qt.params.saoIntensity=t.intensity||12e-5,this.qt.params.saoScale=t.scale||30,this.qt.params.saoKernelRadius=t.radius||30,this.qt.params.saoMinResolution=t.minResolution||0,this.qt.params.saoBlurRadius=t.blurRadius||4.1,this.qt.params.saoBlurStdDev=t.blurStdDev||4,this.qt.params.saoBlurDepthCutoff=t.blurDepthCutoff||.01,this.Kt.addPass(this.$t),this.Kt.addPass(this.qt),this.Kt.addPass(this.Jt)}});Qr=Vr;function oa(){on.call(this),this.type="InstancedBufferGeometry",this.maxInstancedCount=void 0}function sa(t,n){this.array=t,this.stride=n,this.count=void 0!==t?t.length/n:0,this.usage=F,this.updateRange={offset:0,count:-1},this.version=0}function ha(t,n,e){sa.call(this,t,n),this.meshPerAttribute=e||1}oa.prototype=Object.assign(Object.create(on.prototype),{constructor:oa,isInstancedBufferGeometry:!0,copy:function(t){return on.prototype.copy.call(this,t),this.maxInstancedCount=t.maxInstancedCount,this},clone:function(){return(new this.constructor).copy(this)}}),Object.defineProperty(sa.prototype,"needsUpdate",{set:function(t){!0===t&&this.version++}}),Object.assign(sa.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setUsage:function(t){return this.usage=t,this},copy:function(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this},copyAt:function(t,n,e){t*=this.stride,e*=n.stride;for(var i=0,r=this.stride;i<r;i++)this.array[t+i]=n.array[e+i];return this},set:function(t,n){return this.array.set(t,n=void 0===n?0:n),this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(t){return this.onUploadCallback=t,this}}),ha.prototype=Object.assign(Object.create(sa.prototype),{constructor:ha,isInstancedInterleavedBuffer:!0,copy:function(t){return sa.prototype.copy.call(this,t),this.meshPerAttribute=t.meshPerAttribute,this}});var la=new Q;function ca(t,n,e,i){this.data=t,this.itemSize=n,this.offset=e,this.normalized=!0===i}function ua(t){on.call(this),this.type="WireframeGeometry";var n,e,i,r,a,o,s=[],h=[0,0],l={},c=["a","b","c"];if(t&&t.isGeometry){for(var u=t.faces,f=0,d=u.length;f<d;f++)for(var v=u[f],m=0;m<3;m++)r=v[c[m]],a=v[c[(m+1)%3]],h[0]=Math.min(r,a),h[1]=Math.max(r,a),void 0===l[o=h[0]+","+h[1]]&&(l[o]={index1:h[0],index2:h[1]});for(o in l)i=l[o],A=t.vertices[i.index1],s.push(A.x,A.y,A.z),A=t.vertices[i.index2],s.push(A.x,A.y,A.z)}else if(t&&t.isBufferGeometry){var p,g,_,x,A=new Q;if(null!==t.index){for(p=t.attributes.position,g=t.index,e=(_=(n=0)===(_=t.groups).length?[{start:0,count:g.count,materialIndex:0}]:_).length;n<e;++n)for(d=(f=(x=_[n]).start)+x.count;f<d;f+=3)for(m=0;m<3;m++)r=g.getX(f+m),a=g.getX(f+(m+1)%3),h[0]=Math.min(r,a),h[1]=Math.max(r,a),void 0===l[o=h[0]+","+h[1]]&&(l[o]={index1:h[0],index2:h[1]});for(o in l)i=l[o],A.fromBufferAttribute(p,i.index1),s.push(A.x,A.y,A.z),A.fromBufferAttribute(p,i.index2),s.push(A.x,A.y,A.z)}else for(f=0,d=(p=t.attributes.position).count/3;f<d;f++)for(m=0;m<3;m++)A.fromBufferAttribute(p,3*f+m),s.push(A.x,A.y,A.z),A.fromBufferAttribute(p,3*f+(m+1)%3),s.push(A.x,A.y,A.z)}this.setAttribute("position",new At(s,3))}function fa(t){return(fa="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})(t)}function da(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function va(t,n){return(va=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}function ma(e){var i=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 t,n=pa(e);return t=i?(t=pa(this).constructor,Reflect.construct(n,arguments,t)):n.apply(this,arguments),n=this,!(t=t)||"object"!==fa(t)&&"function"!=typeof t?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(n):t}}function pa(t){return(pa=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}Object.defineProperties(ca.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}}),Object.assign(ca.prototype,{isInterleavedBufferAttribute:!0,applyMatrix4:function(t){for(var n=0,e=this.data.count;n<e;n++)la.x=this.getX(n),la.y=this.getY(n),la.z=this.getZ(n),la.applyMatrix4(t),this.setXYZ(n,la.x,la.y,la.z);return this},setX:function(t,n){return this.data.array[t*this.data.stride+this.offset]=n,this},setY:function(t,n){return this.data.array[t*this.data.stride+this.offset+1]=n,this},setZ:function(t,n){return this.data.array[t*this.data.stride+this.offset+2]=n,this},setW:function(t,n){return this.data.array[t*this.data.stride+this.offset+3]=n,this},getX:function(t){return this.data.array[t*this.data.stride+this.offset]},getY:function(t){return this.data.array[t*this.data.stride+this.offset+1]},getZ:function(t){return this.data.array[t*this.data.stride+this.offset+2]},getW:function(t){return this.data.array[t*this.data.stride+this.offset+3]},setXY:function(t,n,e){return t=t*this.data.stride+this.offset,this.data.array[t+0]=n,this.data.array[t+1]=e,this},setXYZ:function(t,n,e,i){return t=t*this.data.stride+this.offset,this.data.array[t+0]=n,this.data.array[t+1]=e,this.data.array[t+2]=i,this},setXYZW:function(t,n,e,i,r){return t=t*this.data.stride+this.offset,this.data.array[t+0]=n,this.data.array[t+1]=e,this.data.array[t+2]=i,this.data.array[t+3]=r,this}}),(ua.prototype=Object.create(on.prototype)).constructor=ua;var ga=function(){!function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),n&&va(t,n)}(r,oa);var t,n,e,i=ma(r);function r(){var t;!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,r),(t=i.call(this)).type="LineSegmentsGeometry";return t.isLineSegmentsGeometry=!0,t.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),t.setAttribute("position",new At([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),t.setAttribute("uv",new At([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2)),t.setAttribute("uv2",new At([0,0,1,0,0,1/3,1,1/3,0,2/3,1,2/3,0,1,1,1],2)),t}return t=r,(n=[{key:"applyMatrix",value:function(t){var n=this.attributes.instanceStart,e=this.attributes.instanceEnd;return void 0!==n&&(t.applyToBufferAttribute(n),t.applyToBufferAttribute(e),n.data.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}},{key:"setPositions",value:function(t){t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));var n=new ha(n,6,1);return this.setAttribute("instanceStart",new ca(n,3,0)),this.setAttribute("instanceEnd",new ca(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}},{key:"setColors",value:function(t){t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));var n=new ha(n,6,1);return this.setAttribute("instanceColorStart",new ca(n,3,0)),this.setAttribute("instanceColorEnd",new ca(n,3,3)),this}},{key:"setUvys",value:function(t){t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));var n=new ha(n,2,1);return this.setAttribute("uvyStart",new ca(n,1,0)),this.setAttribute("uvyEnd",new ca(n,1,1)),this}},{key:"fromWireframeGeometry",value:function(t){return this.setPositions(t.attributes.position.array),this}},{key:"fromEdgesGeometry",value:function(t){return this.setPositions(t.attributes.position.array),this}},{key:"fromMesh",value:function(t){return this.fromWireframeGeometry(new ua(t.geometry)),this}},{key:"fromLineSegements",value:function(t){t=t.geometry;return t.isGeometry?this.setPositions(t.vertices):t.isBufferGeometry&&this.setPositions(t.position.array),this}},{key:"computeBoundingBox",value:function(){var t=new st;null===this.boundingBox&&(this.boundingBox=new st);var n=this.attributes.instanceStart,e=this.attributes.instanceEnd;void 0!==n&&void 0!==e&&(this.boundingBox.setFromBufferAttribute(n),t.setFromBufferAttribute(e),this.boundingBox.union(t))}},{key:"computeBoundingSphere",value:function(){var t=new Q;null===this.boundingSphere&&(this.boundingSphere=new St),null===this.boundingBox&&this.computeBoundingBox();var n=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(void 0!==n&&void 0!==e){var i=this.boundingSphere.center;this.boundingBox.getCenter(i);for(var r=0,a=0,o=n.count;a<o;a++)t.fromBufferAttribute(n,a),r=Math.max(r,i.distanceToSquared(t)),t.fromBufferAttribute(e,a),r=Math.max(r,i.distanceToSquared(t));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error("fm.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}},{key:"toJSON",value:function(){}},{key:"clone",value:function(){}},{key:"copy",value:function(t){return this}}])&&da(t.prototype,n),e&&da(t,e),r}();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})(t)}function xa(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function Aa(t,n){return(Aa=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}function wa(e){var i=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 t,n=ya(e);return t=i?(t=ya(this).constructor,Reflect.construct(n,arguments,t)):n.apply(this,arguments),n=this,!(t=t)||"object"!==_a(t)&&"function"!=typeof t?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(n):t}}function ya(t){return(ya=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Sa=function(){!function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),n&&Aa(t,n)}(r,ga);var t,n,e,i=wa(r);function r(){var t;return function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,r),(t=i.call(this)).type="LineGeometry",t.isLineGeometry=!0,t}return t=r,(n=[{key:"setPositions",value:function(t){for(var n=t.length-3,e=new Float32Array(2*n),i=0;i<n;i+=3)e[2*i]=t[i],e[2*i+1]=t[i+1],e[2*i+2]=t[i+2],e[2*i+3]=t[i+3],e[2*i+4]=t[i+4],e[2*i+5]=t[i+5];return(new ga).setPositions.call(this,e),this}},{key:"setColors",value:function(t){for(var n=t.length-3,e=new Float32Array(2*n),i=0;i<n;i+=3)e[2*i]=t[i],e[2*i+1]=t[i+1],e[2*i+2]=t[i+2],e[2*i+3]=t[i+3],e[2*i+4]=t[i+4],e[2*i+5]=t[i+5];return(new ga).setColors.call(this,e),this}},{key:"fromLine",value:function(t){t=t.geometry;return t.isGeometry?this.setPositions(t.vertices):t.isBufferGeometry&&this.setPositions(t.position.array),this}},{key:"copy",value:function(t){return this}}])&&xa(t.prototype,n),e&&xa(t,e),r}(),ba={basic:{uniforms:mn([ki.common,ki.specularmap,ki.envmap,ki.aomap,ki.lightmap,ki.fog]),vertexShader:Vi.meshbasic_vert,fragmentShader:Vi.meshbasic_frag},lambert:{uniforms:mn([ki.common,ki.specularmap,ki.envmap,ki.aomap,ki.lightmap,ki.emissivemap,ki.fog,ki.lights,{emissive:{value:new X(0)}}]),vertexShader:Vi.meshlambert_vert,fragmentShader:Vi.meshlambert_frag},phong:{uniforms:mn([ki.common,ki.specularmap,ki.envmap,ki.aomap,ki.lightmap,ki.emissivemap,ki.bumpmap,ki.normalmap,ki.displacementmap,ki.fog,ki.lights,{emissive:{value:new X(0)},specular:{value:new X(1118481)},shininess:{value:30}}]),vertexShader:Vi.meshphong_vert,fragmentShader:Vi.meshphong_frag},standard:{uniforms:mn([ki.common,ki.envmap,ki.aomap,ki.lightmap,ki.emissivemap,ki.bumpmap,ki.normalmap,ki.displacementmap,ki.roughnessmap,ki.metalnessmap,ki.fog,ki.lights,{emissive:{value:new X(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:Vi.meshphysical_vert,fragmentShader:Vi.meshphysical_frag},toon:{uniforms:mn([ki.common,ki.specularmap,ki.aomap,ki.lightmap,ki.emissivemap,ki.bumpmap,ki.normalmap,ki.displacementmap,ki.gradientmap,ki.fog,ki.lights,{emissive:{value:new X(0)},specular:{value:new X(1118481)},shininess:{value:30}}]),vertexShader:Vi.meshtoon_vert,fragmentShader:Vi.meshtoon_frag},matcap:{uniforms:mn([ki.common,ki.bumpmap,ki.normalmap,ki.displacementmap,ki.fog,{matcap:{value:null}}]),vertexShader:Vi.meshmatcap_vert,fragmentShader:Vi.meshmatcap_frag},points:{uniforms:mn([ki.points,ki.fog]),vertexShader:Vi.points_vert,fragmentShader:Vi.points_frag},dashed:{uniforms:mn([ki.common,ki.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Vi.linedashed_vert,fragmentShader:Vi.linedashed_frag},depth:{uniforms:mn([ki.common,ki.displacementmap]),vertexShader:Vi.depth_vert,fragmentShader:Vi.depth_frag},normal:{uniforms:mn([ki.common,ki.bumpmap,ki.normalmap,ki.displacementmap,{opacity:{value:1}}]),vertexShader:Vi.normal_vert,fragmentShader:Vi.normal_frag},sprite:{uniforms:mn([ki.sprite,ki.fog]),vertexShader:Vi.sprite_vert,fragmentShader:Vi.sprite_frag},background:{uniforms:{uvTransform:{value:new Ut},t2D:{value:null}},vertexShader:Vi.background_vert,fragmentShader:Vi.background_frag},cube:{uniforms:mn([ki.envmap,{opacity:{value:1}}]),vertexShader:Vi.cube_vert,fragmentShader:Vi.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Vi.equirect_vert,fragmentShader:Vi.equirect_frag},distanceRGBA:{uniforms:mn([ki.common,ki.displacementmap,{referencePosition:{value:new Q},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Vi.distanceRGBA_vert,fragmentShader:Vi.distanceRGBA_frag},shadow:{uniforms:mn([ki.lights,ki.fog,{color:{value:new X(0)},opacity:{value:1}}]),vertexShader:Vi.shadow_vert,fragmentShader:Vi.shadow_frag}};ba.physical={uniforms:mn([ba.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new ct(1,1)},clearcoatNormalMap:{value:null},sheen:{value:new X(0)},transparency:{value:0}}]),vertexShader:Vi.meshphysical_vert,fragmentShader:Vi.meshphysical_frag},ki.line2={linewidth:{value:1},resolution:{value:new ct(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},luminance:{value:1}},ba.line2={uniforms:pn.merge([ki.common,ki.fog,ki.line2]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\t\tuniform float luminance;\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = luminance*vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\n\t\t}\n\t\t"};function Ma(t){xn.call(this,{type:"LineMaterial",uniforms:pn.clone(ba.line2.uniforms),vertexShader:ba.line2.vertexShader,fragmentShader:ba.line2.fragmentShader,clipping:!0}),this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},lineWidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}}}),this.setValues(t)}function Ta(t){return(Ta="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})(t)}function La(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function Ea(t,n){return(Ea=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}function Pa(e){var i=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 t,n=Fa(e);return t=i?(t=Fa(this).constructor,Reflect.construct(n,arguments,t)):n.apply(this,arguments),n=this,!(t=t)||"object"!==Ta(t)&&"function"!=typeof t?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(n):t}}function Fa(t){return(Fa=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}((Ma.prototype=Object.create(xn.prototype)).constructor=Ma).prototype.isLineMaterial=!0;var Na=function(){!function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),n&&Ea(t,n)}(r,We);var t,n,e,i=Pa(r);function r(t,n){return function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,r),(n=i.call(this,t,n)).type="LineSegments2",n.isLineSegments2=!0,n}return t=r,(n=[{key:"computeLineDistances",value:function(){for(var t=new Q,n=new Q,e=this.geometry,i=e.attributes.instanceStart,r=e.attributes.instanceEnd,a=new Float32Array(2*i.data.count),o=0,s=0,h=i.data.count;o<h;o++,s+=2)t.fromBufferAttribute(i,o),n.fromBufferAttribute(r,o),a[s]=0===s?0:a[s-1],a[s+1]=a[s]+t.distanceTo(n);var l=new ha(a,2,1);return e.setAttribute("instanceDistanceStart",new ca(l,1,0)),e.setAttribute("instanceDistanceEnd",new ca(l,1,1)),this}},{key:"copy",value:function(t){return this}}])&&La(t.prototype,n),e&&La(t,e),r}();function Da(t){return(Da="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})(t)}function Ca(t,n){return(Ca=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}function Ra(e){var i=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 t,n=Ia(e);return t=i?(t=Ia(this).constructor,Reflect.construct(n,arguments,t)):n.apply(this,arguments),n=this,!(t=t)||"object"!==Da(t)&&"function"!=typeof t?function(t){if(void 0!==t)return t;throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}(n):t}}function Ia(t){return(Ia=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}var Oa=function(){!function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),n&&Ca(t,n)}(i,Na);var e=Ra(i);function i(t,n){return function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,i),(n=e.call(this,t,n)).type="Line2",n.isLine2=!0,n}return i}();function Ua(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}ce=function(){function e(t,n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,e),this.R=t,this.Ht=n.color,this.tn=n.backgroundColor,this.nn=n.lineWidth,this.en=n.speed,this.in=n.opacity,this.rn=void 0!==n.lineLength?n.lineLength:5,this.an=void 0!==n.luminance?n.luminance:1,this.Gt=this.sn(n.points),this.hn=this.ln(),this.P=new he,this.P.rotation.y=this.R.getAutoRotate(),this.St=null,this.cn=null,this.Ct=!1,this.it=this.it.bind(this),this.G=this.G.bind(this),this.un=this.un.bind(this),this.fn=this.fn.bind(this)}var t,n,i;return t=e,(n=[{key:"parent",get:function(){return this.St}},{key:"scene",get:function(){return this.P}},{key:"getColor",value:function(){return this.Ht}},{key:"setColor",value:function(t){this.Ht=t,this.dn()}},{key:"getBackgroundColor",value:function(){return this.tn}},{key:"setBackgroundColor",value:function(t){this.tn=t,this.dn()}},{key:"getLineWidth",value:function(){return this.nn}},{key:"setLineWidth",value:function(t){this.nn=t,this.cn.material.lineWidth=t}},{key:"getSpeed",value:function(){return this.en}},{key:"setSpeed",value:function(t){this.en=t,this.cn.userData.speed=t}},{key:"setLuminance",value:function(t){this.an=t,this.cn.material.uniforms.luminance.value=t}},{key:"getLuminance",value:function(){return this.an}},{key:"addTo",value:function(t){this.P.position.y=t.height,this.St=t,"basic"===this.R.getRenderManager().type&&this.R.setRenderManager(new se),this.R.getRenderManager().flowlines.set(this.P.uuid,this),this.Ct||(this.B(),this.R.on("beforeRender",this.G))}},{key:"remove",value:function(){this.R.getRenderManager().flowlines.delete(this.P.uuid),this.Ut(),this.R.off("beforeRender",this.G)}},{key:"getScene",value:function(){return this.P}},{key:"render",value:function(){var t,n,e,i;(new Date).getTime()-this.cn.userData.time>20/this.cn.userData.speed&&(n=(t=this.cn.userData.colors).pop(),e=t.pop(),i=t.pop(),t.splice(0,0,n),t.splice(0,0,e),t.splice(0,0,i),this.cn.geometry.setColors(t),this.cn.userData.time=(new Date).getTime()),-1!==this.R.getVisibleLevels().indexOf(this.St.level)&&this.R.getRenderManager().renderer.render(this.P,this.R.camera)}}])&&Ua(t.prototype,n),i&&Ua(t,i),e}();Object.assign(ce.prototype,{G:function(){this.R.enableUpdateRender()},B:function(){var t=new Sa;t.setPositions(this.Gt),t.setColors(this.hn);var n=new Ma({lineWidth:this.nn,vertexColors:!0});n.uniforms.opacity.value=this.in,n.uniforms.luminance.value=this.an,n.resolution.set(this.R.getContainer().clientWidth,this.R.getContainer().clientHeight),n.uniformsNeedUpdate=!0;n=new Oa(t,n);n.userData.colors=this.hn,n.userData.speed=this.en,n.userData.time=(new Date).getTime(),this.cn=n,this.P.add(n),this.R.on("resize",this.it),this.R.on("levelChanged",this.un),this.R.on("autoRotate",this.fn),this.Ct=!0},fn:function(){this.P.rotation.y=this.R.getAutoRotate()},un:function(){this.P.visible=-1!==this.R.getVisibleLevels().indexOf(event.level)},it:function(){var t=this.R.getContainer(),n=t.clientWidth,t=t.clientHeight;this.cn.material.resolution.set(n,t)},vn:function(t){for(var n=0,e=0;e<t.length;e+=3){var i=new Q(t[e],t[e+2],-t[e+1]),r=new Q(t[e+3],t[e+5],-t[e+4]),a=i.distanceToSquared(r);0===e?n=i.distanceToSquared(r):a<n&&(n=a)}return Math.sqrt(n)},sn:function(t){for(var n=[],e=this.vn(t),i=0;i<t.length-3;i+=3)for(var r=new Q(t[i]-this.R.getX(),t[i+2],-t[i+1]+this.R.getY()),a=new Q(t[i+3]-this.R.getX(),t[i+5],-t[i+4]+this.R.getY()),o=new hr(r,a),a=r.distanceTo(a),a=Math.ceil(a/(e*this.rn)),s=o.getPoints(10*a),h=0;h<s.length;h++)n.push(s[h].x,s[h].y,s[h].z);return n},ln:function(){for(var t=[],n=new X(this.Ht),e=new X(this.tn),i=0;i<this.Gt.length/3;i++)3*i<3*this.rn?t.push(n.r,n.g,n.b):t.push(e.r,e.g,e.b);return t},dn:function(){this.hn=this.ln(),this.cn.geometry.setColors(this.hn),this.cn.userData.colors=this.hn},Ut:function(){this.R.off("resize",this.it),this.R.off("levelChanged",this.un),this.R.off("autoRotate",this.fn),this.R.off("beforeRender",this.G),this.P.remove(this.cn),this.cn.geometry.dispose(),this.cn.material.dispose(),this.cn=null,this.Ct=!1}});yi=ce;function Ha(t,n,e,i,r,a,o,s,h,l,c,u){zn.call(this,null,a,o,s,h,l,i,r,c,u),this.image={data:t||null,width:n||1,height:e||1},this.magFilter=void 0!==h?h:g,this.minFilter=void 0!==l?l:g,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.needsUpdate=!0}function Xa(t){Hn.call(this,t)}((Ha.prototype=Object.create(zn.prototype)).constructor=Ha).prototype.isDataTexture=!0,Xa.prototype=Object.assign(Object.create(Hn.prototype),{constructor:Xa,load:function(t,n,e,i){var r=this,a=new Ha,o=new un(this.manager);return o.setResponseType("arraybuffer"),o.setPath(this.path),o.load(t,function(t){t=r.parse(t);t&&(void 0!==t.image?a.image=t.image:void 0!==t.data&&(a.image.width=t.width,a.image.height=t.height,a.image.data=t.data),a.wrapS=void 0!==t.wrapS?t.wrapS:p,a.wrapT=void 0!==t.wrapT?t.wrapT:p,a.magFilter=void 0!==t.magFilter?t.magFilter:E,a.minFilter=void 0!==t.minFilter?t.minFilter:E,a.anisotropy=void 0!==t.anisotropy?t.anisotropy:1,void 0!==t.format&&(a.format=t.format),void 0!==t.type&&(a.type=t.type),void 0!==t.mipmaps&&(a.mipmaps=t.mipmaps,a.minFilter=_),1===t.mipmapCount&&(a.minFilter=E),a.needsUpdate=!0,n&&n(a,t))},e,i),a}});function Ga(t){Xa.call(this,t),this.type=S}function za(t,n,e,i,r,a,o,s,h,l){zn.call(this,t=void 0!==t?t:[],n=void 0!==n?n:301,e,i,r,a,o=void 0!==o?o:P,s,h,l),this.flipY=!1}function Ba(t){Hn.call(this,t)}Ga.prototype=Object.assign(Object.create(Xa.prototype),{constructor:Ga,parse:function(t){function _(t,n){switch(t){case 1:console.error("RGBELoader Read Error: "+(n||""));break;case 2:console.error("RGBELoader Write Error: "+(n||""));break;case 3:console.error("RGBELoader Bad File Format: "+(n||""));break;default:console.error("RGBELoader: Error: "+(n||""))}return-1}function h(t,n,e){n=n||1024;for(var i=t.pos,r=-1,a=0,o="",s=String.fromCharCode.apply(null,new Uint16Array(t.subarray(i,i+128)));(r=s.indexOf("\n"))<0&&a<n&&i<t.byteLength;)o+=s,a+=s.length,i+=128,s+=String.fromCharCode.apply(null,new Uint16Array(t.subarray(i,i+128)));return-1<r&&(!1!==e&&(t.pos+=a+r+1),o+s.slice(0,r))}var r,a,n=(r=new Float32Array(1),a=new Int32Array(r.buffer),function(t,n,e,i){var r=t[n+3],r=Math.pow(2,r-128)/255;e[i+0]=o(t[n+0]*r),e[i+1]=o(t[n+1]*r),e[i+2]=o(t[n+2]*r)});function o(t){r[0]=t;var n=a[0],e=n>>16&32768,i=n>>12&2047,t=n>>23&255;return t<103?e:142<t?(e|=31744,e|=(255==t?0:1)&&8388607&n):t<113?e|=((i|=2048)>>114-t)+(i>>113-t&1):(e|=t-112<<10|i>>1,e+=1&i)}var e=new Uint8Array(t);e.pos=0;var i,s,l,c,u,f=function(t){var n,e,i=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,a=/^\s*FORMAT=(\S+)\s*$/,o=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,s={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};if(t.pos>=t.byteLength||!(n=h(t)))return _(1,"no header found");if(!(e=n.match(/^#\?(\S+)$/)))return _(3,"bad initial token");for(s.valid|=1,s.programtype=e[1],s.string+=n+"\n";!1!==(n=h(t));)if(s.string+=n+"\n","#"!==n.charAt(0)){if((e=n.match(i))&&(s.gamma=parseFloat(e[1],10)),(e=n.match(r))&&(s.exposure=parseFloat(e[1],10)),(e=n.match(a))&&(s.valid|=2,s.format=e[1]),(e=n.match(o))&&(s.valid|=4,s.height=parseInt(e[1],10),s.width=parseInt(e[2],10)),2&s.valid&&4&s.valid)break}else s.comments+=n+"\n";return 2&s.valid?4&s.valid?s:_(3,"missing image size specifier"):_(3,"missing format specifier")}(e);if(-1!==f){var d=f.width,t=f.height,v=function(t,n,e){var i,r,a,o,s,h,l,c,u,f,d,v,m,p=n,g=e;if(p<8||32767<p||2!==t[0]||2!==t[1]||128&t[2])return new Uint8Array(t);if(p!==(t[2]<<8|t[3]))return _(3,"wrong scanline width");if(!(i=new Uint8Array(4*n*e))||!i.length)return _(4,"unable to allocate buffer space");for(a=r=0,c=4*p,m=new Uint8Array(4),h=new Uint8Array(c);0<g&&a<t.byteLength;){if(a+4>t.byteLength)return _(1);if(m[0]=t[a++],m[1]=t[a++],m[2]=t[a++],m[3]=t[a++],2!=m[0]||2!=m[1]||(m[2]<<8|m[3])!=p)return _(3,"bad rgbe scanline format");for(l=0;l<c&&a<t.byteLength;){if((v=128<(o=t[a++]))&&(o-=128),0===o||c<l+o)return _(3,"bad scanline data");if(v)for(s=t[a++],u=0;u<o;u++)h[l++]=s;else h.set(t.subarray(a,a+o),l),l+=o,a+=o}for(f=p,u=0;u<f;u++)i[r]=h[u+(d=0)],d+=p,i[r+1]=h[u+d],d+=p,i[r+2]=h[u+d],d+=p,i[r+3]=h[u+d],r+=4;g--}return i}(e.subarray(e.pos),d,t);if(-1!==v){switch(this.type){case S:var m=v,p=b,g=S;break;case 1015:for(var x=v.length/4*3,A=new Float32Array(x),w=0;w<x;w++)l=A,c=3*w,u=u=void 0,u=(i=v)[(s=4*w)+3],u=Math.pow(2,u-128)/255,l[c+0]=i[s+0]*u,l[c+1]=i[s+1]*u,l[c+2]=i[s+2]*u;m=A,p=P,g=1015;break;case 1016:for(var x=v.length/4*3,y=new Uint16Array(x),w=0;w<x;w++)n(v,4*w,y,3*w);m=y,p=P,g=1016;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:d,height:t,data:m,header:f.string,gamma:f.gamma,exposure:f.exposure,format:p,type:g}}}return null},setDataType:function(t){return this.type=t,this},load:function(t,e,n,i){return Xa.prototype.load.call(this,t,function(t,n){switch(t.type){case S:t.encoding=3002,t.minFilter=g,t.magFilter=g,t.generateMipmaps=!1,t.flipY=!0;break;case 1015:case 1016:t.encoding=A,t.minFilter=E,t.magFilter=E,t.generateMipmaps=!1,t.flipY=!0}e&&e(t,n)},n,i)}}),((za.prototype=Object.create(zn.prototype)).constructor=za).prototype.isCubeTexture=!0,Object.defineProperty(za.prototype,"images",{get:function(){return this.image},set:function(t){this.image=t}}),Ba.prototype=Object.assign(Object.create(Hn.prototype),{constructor:Ba,load:function(t,e,n,i){var r=new za,a=new Xn(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);var o=0;for(var s=0;s<t.length;++s)!function(n){a.load(t[n],function(t){r.images[n]=t,6===++o&&(r.needsUpdate=!0,e&&e(r))},void 0,i)}(s);return r}});function ka(t){Hn.call(this,t),this.hdrLoader=new Ga,this.type=S}ka.prototype=Object.assign(Object.create(Hn.prototype),{constructor:ka,load:function(r,t,n,e){Array.isArray(r)||(console.warn("THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead."),this.setDataType(r),r=t,t=n,n=e,e=arguments[4]);var a=new za;switch(a.type=this.type,a.type){case S:a.encoding=3002,a.format=x,a.minFilter=g,a.magFilter=g,a.generateMipmaps=!1;break;case 1015:case 1016:a.encoding=A,a.format=P,a.minFilter=E,a.magFilter=E,a.generateMipmaps=!1}var o=this,s=0;for(var i=0;i<r.length;i++)!function(n,e,t,i){new un(o.manager).setPath(o.path).setResponseType("arraybuffer").load(r[n],function(t){s++;t=o.hdrLoader.parse(t);t&&(void 0!==t.data&&((t=new Ha(t.data,t.width,t.height)).type=a.type,t.encoding=a.encoding,t.format=a.format,t.minFilter=a.minFilter,t.magFilter=a.magFilter,t.generateMipmaps=a.generateMipmaps,a.images[n]=t),6===s&&(a.needsUpdate=!0,e&&e(a)))},t,i)}(i,t,n,e);return a},setDataType:function(t){return this.type=t,this.hdrLoader.setDataType(t),this}});function Va(t,n,e,i){Kt.call(this),this.type="CubeCamera";var a=new Yi(90,1,t,n);a.up.set(0,-1,0),a.lookAt(new Q(1,0,0)),this.add(a);var o=new Yi(90,1,t,n);o.up.set(0,-1,0),o.lookAt(new Q(-1,0,0)),this.add(o);var s=new Yi(90,1,t,n);s.up.set(0,0,1),s.lookAt(new Q(0,1,0)),this.add(s);var h=new Yi(90,1,t,n);h.up.set(0,0,-1),h.lookAt(new Q(0,-1,0)),this.add(h);var l=new Yi(90,1,t,n);l.up.set(0,-1,0),l.lookAt(new Q(0,0,1)),this.add(l);var c=new Yi(90,1,t,n);c.up.set(0,-1,0),c.lookAt(new Q(0,0,-1)),this.add(c),this.renderTarget=new Ya(e,i=i||{format:P,magFilter:E,minFilter:E}),this.renderTarget.texture.name="CubeCamera",this.update=function(t,n){null===this.parent&&this.updateMatrixWorld();var e=t.getRenderTarget(),i=this.renderTarget,r=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0),t.render(n,a),t.setRenderTarget(i,1),t.render(n,o),t.setRenderTarget(i,2),t.render(n,s),t.setRenderTarget(i,3),t.render(n,h),t.setRenderTarget(i,4),t.render(n,l),i.texture.generateMipmaps=r,t.setRenderTarget(i,5),t.render(n,c),t.setRenderTarget(e)},this.clear=function(t,n,e,i){for(var r=t.getRenderTarget(),a=this.renderTarget,o=0;o<6;o++)t.setRenderTarget(a,o),t.clear(n,e,i);t.setRenderTarget(r)}}function Ya(t,n,e){Number.isInteger(n)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),n=e),ii.call(this,t,t,n)}function ja(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}(Va.prototype=Object.create(Kt.prototype)).constructor=Va,((Ya.prototype=Object.create(ii.prototype)).constructor=Ya).prototype.isWebGLCubeRenderTarget=!0,Ya.prototype.fromEquirectangularTexture=function(t,n){this.texture.type=n.type,this.texture.format=n.format,this.texture.encoding=n.encoding;var e=new he,i={uniforms:{tEquirect:{value:null}},vertexShader:["varying vec3 vWorldDirection;","vec3 transformDirection( in vec3 dir, in mat4 matrix ) {","\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );","}","void main() {","\tvWorldDirection = transformDirection( position, modelMatrix );","\t#include <begin_vertex>","\t#include <project_vertex>","}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;","varying vec3 vWorldDirection;","#define RECIPROCAL_PI 0.31830988618","#define RECIPROCAL_PI2 0.15915494","void main() {","\tvec3 direction = normalize( vWorldDirection );","\tvec2 sampleUV;","\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;","\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;","\tgl_FragColor = texture2D( tEquirect, sampleUV );","}"].join("\n")},i=new xn({type:"CubemapFromEquirect",uniforms:vn(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:l,blending:a});i.uniforms.tEquirect.value=n;n=new We(new Oi(5,5,5),i);e.add(n);i=new Va(1,10,1);return i.renderTarget=this,i.renderTarget.texture.name="CubeCameraTexture",i.update(t,e),n.geometry.dispose(),n.material.dispose(),this};var Qa,Wa,Za,qa=4,Ka=8,Ja=Math.pow(2,Ka),$a=[.125,.215,.35,.446,.526,.582],to=Ka-qa+1+$a.length,no=20,eo=(ja(Vr={},A,0),ja(Vr,3001,1),ja(Vr,3002,2),ja(Vr,3004,3),ja(Vr,3005,4),ja(Vr,3006,5),ja(Vr,3007,6),Vr),io=new de,ro=(Qa=no,Wa=new Float32Array(Qa),Za=new Q(0,1,0),(Za=new An({defines:{n:Qa},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:Wa},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:Za},inputEncoding:{value:eo[A]},outputEncoding:{value:eo[A]}},vertexShader:To(),fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform int samples;\nuniform float weights[n];\nuniform bool latitudinal;\nuniform float dTheta;\nuniform float mipInt;\nuniform vec3 poleAxis;\n\n".concat(Lo(),"\n\n#define ENVMAP_TYPE_CUBE_UV\n#include <cube_uv_reflection_fragment>\n\nvec3 getSample(float theta, vec3 axis) {\n\tfloat cosTheta = cos(theta);\n\t// Rodrigues' axis-angle rotation\n\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t+ cross(axis, vOutputDirection) * sin(theta)\n\t\t+ axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n\treturn bilinearCubeUV(envMap, sampleDirection, mipInt);\n}\n\nvoid main() {\n\tvec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n\tif (all(equal(axis, vec3(0.0))))\n\t\taxis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);\n\taxis = normalize(axis);\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb += weights[0] * getSample(0.0, axis);\n\tfor (int i = 1; i < n; i++) {\n\t\tif (i >= samples)\n\t\t\tbreak;\n\t\tfloat theta = dTheta * float(i);\n\t\tgl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);\n\t\tgl_FragColor.rgb += weights[i] * getSample(theta, axis);\n\t}\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t"),blending:a,depthTest:!1,depthWrite:!1})).type="SphericalGaussianBlur",Za),ao=null,oo=null,ce=function(){for(var t=[],n=[],e=[],i=Ka,r=0;r<to;r++){var a=Math.pow(2,i);n.push(a);var o=1/a;Ka-qa<r?o=$a[r-Ka+qa-1]:0==r&&(o=0),e.push(o);for(var o=1/(a-1),a=-o/2,o=1+o/2,s=[a,a,o,a,o,o,a,a,o,o,a,o],h=new Float32Array(108),l=new Float32Array(72),c=new Float32Array(36),u=0;u<6;u++){var f=u%3*2/3-1,d=2<u?0:-1,d=[f,d,0,f+2/3,d,0,f+2/3,1+d,0,f,d,0,f+2/3,1+d,0,f,1+d,0];h.set(d,18*u),l.set(s,12*u);d=[u,u,u,u,u,u];c.set(d,6*u)}o=new on;o.setAttribute("position",new ft(h,3)),o.setAttribute("uv",new ft(l,2)),o.setAttribute("faceIndex",new ft(c,1)),t.push(o),qa<i&&i--}return{mn:t,pn:n,gn:e}}(),so=ce.mn,ho=ce.pn,lo=ce.gn,co=null,uo=null,fo=null,Vr=(1+Math.sqrt(5))/2,ce=1/Vr,vo=[new Q(1,1,1),new Q(-1,1,1),new Q(1,1,-1),new Q(-1,1,-1),new Q(0,Vr,ce),new Q(0,Vr,-ce),new Q(ce,0,Vr),new Q(-ce,0,Vr),new Q(Vr,ce,0),new Q(-Vr,ce,0)];function mo(t){uo=t,_o(ro)}function po(t){var n={magFilter:g,minFilter:g,generateMipmaps:!1,type:t?t.type:S,format:t?t.format:b,encoding:t?t.encoding:3002,depthBuffer:!1,stencilBuffer:!1},e=xo(n);return e.depthBuffer=!t,co=xo(n),e}function go(t){co.dispose(),uo.setRenderTarget(fo),t.scissorTest=!1,t.setSize(t.width,t.height)}function _o(t){var n=new he;n.add(new We(so[0],t)),uo.compile(n,io)}function xo(t){t=new ii(3*Ja,3*Ja,t);return t.texture.mapping=m,t.texture.name="PMREM.cubeUv",t.scissorTest=!0,t}function Ao(t,n,e,i,r){t.viewport.set(n,e,i,r),t.scissor.set(n,e,i,r)}function wo(t){var n=uo.autoClear;uo.autoClear=!1;for(var e=1;e<to;e++)yo(t,e-1,e,Math.sqrt(lo[e]*lo[e]-lo[e-1]*lo[e-1]),vo[(e-1)%vo.length]);uo.autoClear=n}function yo(t,n,e,i,r){So(t,co,n,e,i,"latitudinal",r),So(co,t,e,e,i,"longitudinal",r)}function So(t,n,e,i,r,a,o){"latitudinal"!==a&&"longitudinal"!==a&&console.error("blur direction must be either latitudinal or longitudinal!");var s=new he;s.add(new We(so[i],ro));var h=ro.uniforms,l=ho[e]-1,l=isFinite(r)?Math.PI/(2*l):2*Math.PI/(2*no-1),c=r/l,u=isFinite(r)?1+Math.floor(3*c):no;no<u&&console.warn("sigmaRadians, ".concat(r,", is too large and will clip, as it requested ").concat(u," samples when the maximum is set to ").concat(no));for(var f=[],d=0,v=0;v<no;++v){var m=v/c,p=Math.exp(-m*m/2);f.push(p),0==v?d+=p:v<u&&(d+=2*p)}for(v=0;v<f.length;v++)f[v]=f[v]/d;h.envMap.value=t.texture,h.samples.value=u,h.weights.value=f,h.latitudinal.value="latitudinal"===a,o&&(h.poleAxis.value=o),h.dTheta.value=l,h.mipInt.value=Ka-e,h.inputEncoding.value=eo[t.texture.encoding],h.outputEncoding.value=eo[t.texture.encoding];t=ho[i];Ao(n,m=3*Math.max(0,Ja-2*t),(0===i?0:2*Ja)+2*t*(Ka-qa<i?i-Ka+qa:0),3*t,2*t),uo.setRenderTarget(n),uo.render(s,io)}function bo(){var t=new An({uniforms:{envMap:{value:null},texelSize:{value:new ct(1,1)},inputEncoding:{value:eo[A]},outputEncoding:{value:eo[A]}},vertexShader:To(),fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform sampler2D envMap;\nuniform vec2 texelSize;\n\n".concat(Lo(),"\n\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tvec3 outputDirection = normalize(vOutputDirection);\n\tvec2 uv;\n\tuv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n\tuv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;\n\tvec2 f = fract(uv / texelSize - 0.5);\n\tuv -= f * texelSize;\n\tvec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x += texelSize.x;\n\tvec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.y += texelSize.y;\n\tvec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tuv.x -= texelSize.x;\n\tvec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n\tvec3 tm = mix(tl, tr, f.x);\n\tvec3 bm = mix(bl, br, f.x);\n\tgl_FragColor.rgb = mix(tm, bm, f.y);\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t"),blending:a,depthTest:!1,depthWrite:!1});return t.type="EquirectangularToCubeUV",t}function Mo(){var t=new An({uniforms:{envMap:{value:null},inputEncoding:{value:eo[A]},outputEncoding:{value:eo[A]}},vertexShader:To(),fragmentShader:"\nprecision mediump float;\nprecision mediump int;\nvarying vec3 vOutputDirection;\nuniform samplerCube envMap;\n\n".concat(Lo(),"\n\nvoid main() {\n\tgl_FragColor = vec4(0.0);\n\tgl_FragColor.rgb = envMapTexelToLinear(textureCube(envMap, vec3( - vOutputDirection.x, vOutputDirection.yz ))).rgb;\n\tgl_FragColor = linearToOutputTexel(gl_FragColor);\n}\n\t\t"),blending:a,depthTest:!1,depthWrite:!1});return t.type="CubemapToCubeUV",t}function To(){return"\nprecision mediump float;\nprecision mediump int;\nattribute vec3 position;\nattribute vec2 uv;\nattribute float faceIndex;\nvarying vec3 vOutputDirection;\nvec3 getDirection(vec2 uv, float face) {\n\tuv = 2.0 * uv - 1.0;\n\tvec3 direction = vec3(uv, 1.0);\n\tif (face == 0.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 1.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.z *= -1.0;\n\t} else if (face == 3.0) {\n\t\tdirection = direction.zyx;\n\t\tdirection.x *= -1.0;\n\t} else if (face == 4.0) {\n\t\tdirection = direction.xzy;\n\t\tdirection.y *= -1.0;\n\t} else if (face == 5.0) {\n\t\tdirection.xz *= -1.0;\n\t}\n\treturn direction;\n}\nvoid main() {\n\tvOutputDirection = getDirection(uv, faceIndex);\n\tgl_Position = vec4( position, 1.0 );\n}\n\t"}function Lo(){return"\nuniform int inputEncoding;\nuniform int outputEncoding;\n\n#include <encodings_pars_fragment>\n\nvec4 inputTexelToLinear(vec4 value){\n\tif(inputEncoding == 0){\n\t\treturn value;\n\t}else if(inputEncoding == 1){\n\t\treturn sRGBToLinear(value);\n\t}else if(inputEncoding == 2){\n\t\treturn RGBEToLinear(value);\n\t}else if(inputEncoding == 3){\n\t\treturn RGBMToLinear(value, 7.0);\n\t}else if(inputEncoding == 4){\n\t\treturn RGBMToLinear(value, 16.0);\n\t}else if(inputEncoding == 5){\n\t\treturn RGBDToLinear(value, 256.0);\n\t}else{\n\t\treturn GammaToLinear(value, 2.2);\n\t}\n}\n\nvec4 linearToOutputTexel(vec4 value){\n\tif(outputEncoding == 0){\n\t\treturn value;\n\t}else if(outputEncoding == 1){\n\t\treturn LinearTosRGB(value);\n\t}else if(outputEncoding == 2){\n\t\treturn LinearToRGBE(value);\n\t}else if(outputEncoding == 3){\n\t\treturn LinearToRGBM(value, 7.0);\n\t}else if(outputEncoding == 4){\n\t\treturn LinearToRGBM(value, 16.0);\n\t}else if(outputEncoding == 5){\n\t\treturn LinearToRGBD(value, 256.0);\n\t}else{\n\t\treturn LinearToGamma(value, 2.2);\n\t}\n}\n\nvec4 envMapTexelToLinear(vec4 color) {\n\treturn inputTexelToLinear(color);\n}\n\t"}function Eo(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}mo.prototype={constructor:mo,fromScene:function(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:.1,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:100;fo=uo.getRenderTarget();var r=po();return function(t,n,e,i){var r=new Yi(90,1,n,e),a=[1,1,1,1,-1,1],o=[1,1,-1,-1,-1,1],s=uo.outputEncoding,h=uo.toneMapping,l=uo.toneMappingExposure,c=uo.getClearColor(),u=uo.getClearAlpha();uo.toneMapping=1,uo.toneMappingExposure=1,uo.outputEncoding=A,t.scale.z*=-1;n=t.background;n&&n.isColor&&(n.convertSRGBToLinear(),e=Math.max(n.r,n.g,n.b),e=Math.min(Math.max(Math.ceil(Math.log2(e)),-128),127),n=n.multiplyScalar(Math.pow(2,-e)),e=(e+128)/255,uo.setClearColor(n,e),t.background=null);for(var f=0;f<6;f++){var d=f%3;0==d?(r.up.set(0,a[f],0),r.lookAt(o[f],0,0)):1==d?(r.up.set(0,0,a[f]),r.lookAt(0,o[f],0)):(r.up.set(0,a[f],0),r.lookAt(0,0,o[f])),Ao(i,d*Ja,2<f?Ja:0,Ja,Ja),uo.setRenderTarget(i),uo.render(t,r)}uo.toneMapping=h,uo.toneMappingExposure=l,uo.outputEncoding=s,uo.setClearColor(c,u),t.scale.z*=-1}(t,e,i,r),0<n&&yo(r,0,0,n),wo(r),go(r),r},fromEquirectangular:function(t){return t.magFilter=g,t.minFilter=g,t.generateMipmaps=!1,this.fromCubemap(t)},fromCubemap:function(t){fo=uo.getRenderTarget();var n=po(t);return function(t,n){var e=new he;t.isCubeTexture?null==oo&&(oo=Mo()):null==ao&&(ao=bo());var i=t.isCubeTexture?oo:ao;e.add(new We(so[0],i));i=i.uniforms;(i.envMap.value=t).isCubeTexture||i.texelSize.value.set(1/t.image.width,1/t.image.height);i.inputEncoding.value=eo[t.encoding],i.outputEncoding.value=eo[t.encoding],Ao(n,0,0,3*Ja,2*Ja),uo.setRenderTarget(n),uo.render(e,io)}(t,n),wo(n),go(n),n},compileCubemapShader:function(){null==oo&&_o(oo=Mo())},compileEquirectangularShader:function(){null==ao&&_o(ao=bo())},dispose:function(){ro.dispose(),null!=oo&&oo.dispose(),null!=ao&&ao.dispose();for(var t=0;t<so.length;t++)so[t].dispose()}};var Po=function(){function n(){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n);var t=vn(ba.cube.uniforms);t.projectionMatrixFixZoom={value:[]},this.boxMesh=new We(new Oi(1,1,1),new xn({type:"BackgroundCubeMaterial",uniforms:t,vertexShader:"varying vec3 vWorldDirection;\n    #include <common>\n    // 固定zoom的缩放,仅用于正交相机\n    uniform mat4 projectionMatrixFixZoom;\n    void main() {\n\n      vWorldDirection = transformDirection( position, modelMatrix );\n\n      #include <begin_vertex>\n      #include <project_vertex>\n\n      if (isPerspectiveMatrix(projectionMatrix)) {\n        gl_Position = projectionMatrix * mvPosition;\n      } else {\n        gl_Position = projectionMatrixFixZoom * mvPosition;\n      }\n      gl_Position.z = gl_Position.w; // set z to camera.far\n    }",fragmentShader:"\n      #include <envmap_common_pars_fragment>\n      uniform float opacity;\n      varying vec3 vWorldDirection;\n      #include <cube_uv_reflection_fragment>\n      void main() {\n        vec3 vReflect = vWorldDirection;\n        #include <envmap_fragment>\n        gl_FragColor = envColor;\n        gl_FragColor.a *= opacity;\n\n        #include <tonemapping_fragment>\n        #include <encodings_fragment>\n      }",side:l,depthTest:!1,depthWrite:!1,fog:!1})),this.boxMesh.frustumCulled=!1,this.boxMesh.geometry.deleteAttribute("normal"),this.boxMesh.geometry.deleteAttribute("uv"),this.boxMesh.onBeforeRender=function(t,n,e){this.matrixWorld.copyPosition(e.matrixWorld)},Object.defineProperty(this.boxMesh.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),this.tempMatix=new Dt}var t,e,i;return t=n,(e=[{key:"setTexture",value:function(t){this.boxMesh.material.uniforms.envMap.value=t,this.boxMesh.material.uniforms.flipEnvMap.value=t.isCubeTexture?-1:1,this.boxMesh.material.needsUpdate=!0,this._n=t}},{key:"setOrthographicScale",value:function(t,n){var e;"OrthographicCamera"===t.type&&(e=t.zoom,t.zoom=n,t.updateProjectionMatrix(),this.tempMatix.copy(t.projectionMatrix),this.boxMesh.material.uniforms.projectionMatrixFixZoom.value=this.tempMatix,t.zoom=e,t.updateProjectionMatrix())}}])&&Eo(t.prototype,e),i&&Eo(t,i),n}();function Fo(t,n,e){return n in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function No(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.assign(Po.prototype,{Ut:function(){this.tempMatix=null,this.boxMesh&&(this.boxMesh.geometry.dispose(),this.boxMesh.material.dispose(),this._n&&this._n.dispose(),this.boxMesh=null)}});ce=function(){function n(t){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),this.SkyBoxType={cube6HDR:0,cube6Normal:1,cube1HDR:2,cube1Normal:3},this.R=t,this.xn=!0,this.An=1,this.wn=2e3,this.yn=!1,this.P=null,this.Sn=null,this.bn=[],this.Mn=!1,this.Tn=null,this.Ln=null,this.En=this.Pn(),this.Fn=this.Nn(),"basic"===this.R.getRenderManager().type&&this.R.setRenderManager(new se)}var t,e,i;return t=n,(e=[{key:"isHDR",get:function(){return this.Mn}},{key:"exposure",get:function(){return this.An},set:function(t){this.An=t}},{key:"imagePath",get:function(){return this.Sn},set:function(t){this.Sn=t}},{key:"scale",get:function(){return this.wn},set:function(t){this.wn=t}},{key:"imageNames",get:function(){return this.bn},set:function(t){var n=t[0],n=n.slice(n.match(/(?=\.)/).index+1).toLocaleLowerCase();this.Mn="hdr"===n,this.bn=t}},{key:"enable",value:function(){this.xn=!0,(this.R.getRenderManager().skyNeedTexture=this).R.enableUpdateNode()}},{key:"disable",value:function(){this.xn=!1,this.R.getRenderManager().skyNeedTexture=null,this.R.enableUpdateNode()}},{key:"render",value:function(){this.Dn(this.R.getRenderManager().renderer,this.R.camera)}},{key:"setState",value:function(t){var n=t.imagePath,e=t.imageNames,i=(t.enable,t.exposure),t=t.scale;n&&(this.imagePath=n),e&&(this.imageNames=e),(n||e)&&this.Cn(),void 0!==i&&(this.exposure=i),void 0!==t&&(this.scale=t),this.R.enableUpdateNode()}},{key:"getState",value:function(){return{exposure:this.An,imageNames:this.bn,imagePath:this.Sn,scale:this.wn}}},{key:"dispose",value:function(){this.disable(),this.Tn&&this.Tn.Ut(),this.Sn=null,this.bn=[],this.Tn=null,this.En=null,this.Fn=null,this.yn=!1}}])&&No(t.prototype,e),i&&No(t,i),n}();function Do(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}Object.assign(ce.prototype,{Pn:function(){var n=this,t={};return Fo(t,this.SkyBoxType.cube6HDR,function(t){t.toneMappingExposure=n.exposure,t.toneMapping=1,t.outputEncoding=3001}),Fo(t,this.SkyBoxType.cube6Normal,function(t){}),Fo(t,this.SkyBoxType.cube1HDR,function(t){t.toneMappingExposure=n.exposure,t.toneMapping=5,t.outputEncoding=3001}),Fo(t,this.SkyBoxType.cube1Normal,function(t){}),t},Nn:function(){var i=this,t={};return Fo(t,this.SkyBoxType.cube6HDR,function(){(new ka).setPath(i.Sn).setDataType(S).load(i.bn,function(t){t.magFilter=E,t.needsUpdate=!0,i.Rn(t),i.yn=!0})}),Fo(t,this.SkyBoxType.cube6Normal,function(){var n=[];i.imageNames.forEach(function(t){n.push(i.Sn+t)}),(new Ba).load(n,function(t){t.mapping=301,i.Rn(t),i.yn=!0})}),Fo(t,this.SkyBoxType.cube1HDR,function(){var e=new mo(i.R.getRenderManager().renderer);e.compileEquirectangularShader(),(new Ga).setPath(i.Sn).load(i.bn[0],function(t){var n=e.fromEquirectangular(t);t.dispose(),e.dispose(),i.Rn(n.texture),i.yn=!0})}),Fo(t,this.SkyBoxType.cube1Normal,function(){(new Bn).load(i.Sn+i.bn[0],function(t){t.mapping=300;t=new Ya(1024,{generateMipmaps:!0,minFilter:_,magFilter:E}).fromEquirectangularTexture(i.R.getRenderManager().renderer,t);i.Rn(t),i.yn=!0})}),t},Rn:function(t){this.Tn&&this.Tn.Ut(),this.Tn=new Po,this.Tn.setTexture(t),0<this.P.children.length&&this.P.remove(this.P.children[0]),this.P.add(this.Tn.boxMesh),this.R.enableUpdateNode()},Dn:function(t,n){var e,i,r,a;this.xn&&this.yn&&(e=t.toneMappingExposure,i=t.toneMapping,r=t.outputEncoding,this.Tn&&this.Tn.setOrthographicScale(n,this.wn),(a=this.En[this.Ln])&&a(t),t.render(this.P,n),t.toneMappingExposure=e,t.toneMapping=i,t.outputEncoding=r)},Cn:function(){null!==this.Sn&&0!==this.bn.length&&null!=this.Fn&&(this.P||(this.P=new he),this.Ln=null,6===this.imageNames.length&&this.isHDR&&(this.Ln=this.SkyBoxType.cube6HDR),6===this.imageNames.length&&!1===this.isHDR&&(this.Ln=this.SkyBoxType.cube6Normal),1===this.imageNames.length&&this.isHDR&&(this.Ln=this.SkyBoxType.cube1HDR),1===this.imageNames.length&&!1===this.isHDR&&(this.Ln=this.SkyBoxType.cube1Normal),null!==this.Ln?this.Fn[this.Ln]():console.warn("天空盒设置失败..."))}});var Co,Ro={FMParticle:ue,FMRain:Si,FMSky:Bi,FMTextureBasedSkybox:ce,FMWater:e,FMBloom:xi,FMSweep:zi,FMSAO:Qr,FMFlowline:yi,FMHDR:function(){function n(t){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),this.url=t.url}var t,e,i;return t=n,(e=[{key:"load",value:function(e,i){(new Ga).setDataType(S).load(this.url,function(t){var n=new mo(e.getRenderManager().renderer);n.compileEquirectangularShader();t=n.fromEquirectangular(t).texture;i&&i(t)})}}])&&Do(t.prototype,e),i&&Do(t,i),n}()};for(Co in Ro)window.fengmap[Co]=Ro[Co];n.default=fengmap}],r.c=i,r.d=function(t,n,e){r.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"In",{value:!0})},r.t=function(n,t){if(1&t&&(n=r(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.In)return n;var e=Object.create(null);if(r.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var i in n)r.d(e,i,function(t){return n[t]}.bind(null,i));return e},r.n=function(t){var n=t&&t.In?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=0).default;function r(t){if(i[t])return i[t].exports;var n=i[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,r),n.l=!0,n.exports}var e,i});