!function webpackUniversalModuleDefinition(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports.three=t():e.three=t()}(window,function(){return function(e){var t={};function __webpack_require__(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,__webpack_require__),r.l=!0,r.exports}return __webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.d=function(e,t,n){__webpack_require__.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},__webpack_require__.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.t=function(e,t){if(1&t&&(e=__webpack_require__(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(__webpack_require__.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)__webpack_require__.d(n,r,function(t){return e[t]}.bind(null,r));return n},__webpack_require__.n=function(e){var t=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};return __webpack_require__.d(t,"a",t),t},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.p="./",__webpack_require__(__webpack_require__.s=151)}({10:function(e,t,n){"use strict";var r=n(3);function get_get(e,t,n){return(get_get="undefined"!==typeof Reflect&&Reflect.get?Reflect.get:function _get(e,t,n){var i=function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=Object(r.a)(e)););return e}(e,t);if(i){var a=Object.getOwnPropertyDescriptor(i,t);return a.get?a.get.call(n):a.value}})(e,t,n||e)}n.d(t,"a",function(){return get_get})},13:function(e,t,n){"use strict";function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}n.d(t,"a",function(){return _assertThisInitialized})},15:function(e,t,n){e.exports=n(77)},151:function(e,t,n){"use strict";n.r(t);var r=n(3),i=n(20);function construct_construct(e,t,n){return(construct_construct=function isNativeReflectConstruct(){if("undefined"===typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"===typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function _construct(e,t,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&Object(i.a)(a,n.prototype),a}).apply(null,arguments)}function wrapNativeSuper_wrapNativeSuper(e){var t="function"===typeof Map?new Map:void 0;return(wrapNativeSuper_wrapNativeSuper=function _wrapNativeSuper(e){if(null===e||!function _isNativeFunction(e){return-1!==Function.toString.call(e).indexOf("[native code]")}(e))return e;if("function"!==typeof e)throw new TypeError("Super expression must either be null or a function");if("undefined"!==typeof t){if(t.has(e))return t.get(e);t.set(e,Wrapper)}function Wrapper(){return construct_construct(e,arguments,Object(r.a)(this).constructor)}return Wrapper.prototype=Object.create(e.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),Object(i.a)(Wrapper,e)})(e)}function _toConsumableArray(e){return function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t>8&255]+kn[e>>16&255]+kn[e>>24&255]+"-"+kn[255&t]+kn[t>>8&255]+"-"+kn[t>>16&15|64]+kn[t>>24&255]+"-"+kn[63&n|128]+kn[n>>8&255]+"-"+kn[n>>16&255]+kn[n>>24&255]+kn[255&r]+kn[r>>8&255]+kn[r>>16&255]+kn[r>>24&255]).toLowerCase()}function clamp(e,t,n){return Math.max(t,Math.min(n,e))}function euclideanModulo(e,t){return(e%t+t)%t}function lerp(e,t,n){return(1-n)*e+n*t}function isPowerOfTwo(e){return 0===(e&e-1)&&0!==e}function ceilPowerOfTwo(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function floorPowerOfTwo(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}var In=Object.freeze({__proto__:null,DEG2RAD:Pn,RAD2DEG:Rn,generateUUID:generateUUID,clamp:clamp,euclideanModulo:euclideanModulo,mapLinear:function mapLinear(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)},inverseLerp:function inverseLerp(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:lerp,damp:function damp(e,t,n,r){return lerp(e,t,1-Math.exp(-n*r))},pingpong:function pingpong(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return t-Math.abs(euclideanModulo(e,2*t)-t)},smoothstep:function smoothstep(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function smootherstep(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function randInt(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function randFloat(e,t){return e+Math.random()*(t-e)},randFloatSpread:function randFloatSpread(e){return e*(.5-Math.random())},seededRandom:function seededRandom(e){void 0!==e&&(En=e);var t=En+=1831565813;return t=Math.imul(t^t>>>15,1|t),(((t^=t+Math.imul(t^t>>>7,61|t))^t>>>14)>>>0)/4294967296},degToRad:function degToRad(e){return e*Pn},radToDeg:function radToDeg(e){return e*Rn},isPowerOfTwo:isPowerOfTwo,ceilPowerOfTwo:ceilPowerOfTwo,floorPowerOfTwo:floorPowerOfTwo,setQuaternionFromProperEuler:function setQuaternionFromProperEuler(e,t,n,r,i){var a=Math.cos,o=Math.sin,s=a(n/2),u=o(n/2),l=a((t+r)/2),c=o((t+r)/2),h=a((t-r)/2),d=o((t-r)/2),f=a((r-t)/2),p=o((r-t)/2);switch(i){case"XYX":e.set(s*c,u*h,u*d,s*l);break;case"YZY":e.set(u*d,s*c,u*h,s*l);break;case"ZXZ":e.set(u*h,u*d,s*c,s*l);break;case"XZX":e.set(s*c,u*p,u*f,s*l);break;case"YXY":e.set(u*f,s*c,u*p,s*l);break;case"ZYZ":e.set(u*p,u*f,s*c,s*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}},normalize:function normalize(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}},denormalize:function denormalize$1(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}}),Dn=function(){function Vector2(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Object(f.a)(this,Vector2),Vector2.prototype.isVector2=!0,this.x=e,this.y=t}return Object(p.a)(Vector2,[{key:"set",value:function set(e,t){return this.x=e,this.y=t,this}},{key:"setScalar",value:function setScalar(e){return this.x=e,this.y=e,this}},{key:"setX",value:function setX(e){return this.x=e,this}},{key:"setY",value:function setY(e){return this.y=e,this}},{key:"setComponent",value:function setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}},{key:"getComponent",value:function getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}},{key:"clone",value:function clone(){return new this.constructor(this.x,this.y)}},{key:"copy",value:function copy(e){return this.x=e.x,this.y=e.y,this}},{key:"add",value:function add(e){return this.x+=e.x,this.y+=e.y,this}},{key:"addScalar",value:function addScalar(e){return this.x+=e,this.y+=e,this}},{key:"addVectors",value:function addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}},{key:"addScaledVector",value:function addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}},{key:"sub",value:function sub(e){return this.x-=e.x,this.y-=e.y,this}},{key:"subScalar",value:function subScalar(e){return this.x-=e,this.y-=e,this}},{key:"subVectors",value:function subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}},{key:"multiply",value:function multiply(e){return this.x*=e.x,this.y*=e.y,this}},{key:"multiplyScalar",value:function multiplyScalar(e){return this.x*=e,this.y*=e,this}},{key:"divide",value:function divide(e){return this.x/=e.x,this.y/=e.y,this}},{key:"divideScalar",value:function divideScalar(e){return this.multiplyScalar(1/e)}},{key:"applyMatrix3",value:function applyMatrix3(e){var t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}},{key:"min",value:function min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}},{key:"max",value:function max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}},{key:"clamp",value:function clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}},{key:"clampScalar",value:function clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}},{key:"clampLength",value:function clampLength(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}},{key:"floor",value:function floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}},{key:"ceil",value:function ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}},{key:"round",value:function round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},{key:"roundToZero",value:function roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}},{key:"negate",value:function negate(){return this.x=-this.x,this.y=-this.y,this}},{key:"dot",value:function dot(e){return this.x*e.x+this.y*e.y}},{key:"cross",value:function cross(e){return this.x*e.y-this.y*e.x}},{key:"lengthSq",value:function lengthSq(){return this.x*this.x+this.y*this.y}},{key:"length",value:function length(){return Math.sqrt(this.x*this.x+this.y*this.y)}},{key:"manhattanLength",value:function manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}},{key:"normalize",value:function normalize(){return this.divideScalar(this.length()||1)}},{key:"angle",value:function angle(){var angle=Math.atan2(-this.y,-this.x)+Math.PI;return angle}},{key:"distanceTo",value:function distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}},{key:"distanceToSquared",value:function distanceToSquared(e){var t=this.x-e.x,n=this.y-e.y;return t*t+n*n}},{key:"manhattanDistanceTo",value:function manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}},{key:"setLength",value:function setLength(e){return this.normalize().multiplyScalar(e)}},{key:"lerp",value:function lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}},{key:"lerpVectors",value:function lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}},{key:"equals",value:function equals(e){return e.x===this.x&&e.y===this.y}},{key:"fromArray",value:function fromArray(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this}},{key:"toArray",value:function toArray(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.x,e[t+1]=this.y,e}},{key:"fromBufferAttribute",value:function fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}},{key:"rotateAround",value:function rotateAround(e,t){var n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}},{key:"random",value:function random(){return this.x=Math.random(),this.y=Math.random(),this}},{key:Symbol.iterator,value:d.a.mark(function value(){return d.a.wrap(function value$(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.x;case 2:return e.next=4,this.y;case 4:case"end":return e.stop()}},value,this)})},{key:"width",get:function get(){return this.x},set:function set(e){this.x=e}},{key:"height",get:function get(){return this.y},set:function set(e){this.y=e}}]),Vector2}(),jn=function(){function Matrix3(){Object(f.a)(this,Matrix3),Matrix3.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}return Object(p.a)(Matrix3,[{key:"set",value:function set(e,t,n,r,i,a,o,s,u){var l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=u,this}},{key:"identity",value:function identity(){return this.set(1,0,0,0,1,0,0,0,1),this}},{key:"copy",value:function copy(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}},{key:"extractBasis",value:function extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}},{key:"setFromMatrix4",value:function setFromMatrix4(e){var t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}},{key:"multiply",value:function multiply(e){return this.multiplyMatrices(this,e)}},{key:"premultiply",value:function premultiply(e){return this.multiplyMatrices(e,this)}},{key:"multiplyMatrices",value:function multiplyMatrices(e,t){var n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],u=n[1],l=n[4],c=n[7],h=n[2],d=n[5],f=n[8],p=r[0],m=r[3],v=r[6],g=r[1],y=r[4],b=r[7],x=r[2],_=r[5],M=r[8];return i[0]=a*p+o*g+s*x,i[3]=a*m+o*y+s*_,i[6]=a*v+o*b+s*M,i[1]=u*p+l*g+c*x,i[4]=u*m+l*y+c*_,i[7]=u*v+l*b+c*M,i[2]=h*p+d*g+f*x,i[5]=h*m+d*y+f*_,i[8]=h*v+d*b+f*M,this}},{key:"multiplyScalar",value:function multiplyScalar(e){var t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}},{key:"determinant",value:function determinant(){var e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],l=e[8];return t*a*l-t*o*u-n*i*l+n*o*s+r*i*u-r*a*s}},{key:"invert",value:function invert(){var e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],l=e[8],c=l*a-o*u,h=o*s-l*i,d=u*i-a*s,f=t*c+n*h+r*d;if(0===f)return this.set(0,0,0,0,0,0,0,0,0);var p=1/f;return e[0]=c*p,e[1]=(r*u-l*n)*p,e[2]=(o*n-r*a)*p,e[3]=h*p,e[4]=(l*t-r*s)*p,e[5]=(r*i-o*t)*p,e[6]=d*p,e[7]=(n*s-u*t)*p,e[8]=(a*t-n*i)*p,this}},{key:"transpose",value:function transpose(){var e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}},{key:"getNormalMatrix",value:function getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}},{key:"transposeIntoArray",value:function transposeIntoArray(e){var t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}},{key:"setUvTransform",value:function setUvTransform(e,t,n,r,i,a,o){var s=Math.cos(i),u=Math.sin(i);return this.set(n*s,n*u,-n*(s*a+u*o)+a+e,-r*u,r*s,-r*(-u*a+s*o)+o+t,0,0,1),this}},{key:"scale",value:function scale(e,t){var n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}},{key:"rotate",value:function rotate(e){var t=Math.cos(e),n=Math.sin(e),r=this.elements,i=r[0],a=r[3],o=r[6],s=r[1],u=r[4],l=r[7];return r[0]=t*i+n*s,r[3]=t*a+n*u,r[6]=t*o+n*l,r[1]=-n*i+t*s,r[4]=-n*a+t*u,r[7]=-n*o+t*l,this}},{key:"translate",value:function translate(e,t){var n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}},{key:"equals",value:function equals(e){for(var t=this.elements,n=e.elements,r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}},{key:"fromArray",value:function fromArray(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0;n<9;n++)this.elements[n]=e[n+t];return this}},{key:"toArray",value:function toArray(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}},{key:"clone",value:function clone(){return(new this.constructor).fromArray(this.elements)}}]),Matrix3}();function arrayNeedsUint32(e){for(var t=e.length-1;t>=0;--t)if(e[t]>65535)return!0;return!1}var Bn={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function getTypedArray(e,t){return new Bn[e](t)}function createElementNS(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function SRGBToLinear(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function LinearToSRGB(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}var Nn=(_defineProperty(c={},Qt,_defineProperty({},$t,SRGBToLinear)),_defineProperty(c,$t,_defineProperty({},Qt,LinearToSRGB)),c),zn={legacyMode:!0,get workingColorSpace(){return $t},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function convert(e,t,n){if(this.legacyMode||t===n||!t||!n)return e;if(Nn[t]&&void 0!==Nn[t][n]){var r=Nn[t][n];return e.r=r(e.r),e.g=r(e.g),e.b=r(e.b),e}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function fromWorkingColorSpace(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function toWorkingColorSpace(e,t){return this.convert(e,t,this.workingColorSpace)}},Fn={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},Gn={r:0,g:0,b:0},Un={h:0,s:0,l:0},Vn={h:0,s:0,l:0};function hue2rgb(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function toComponents(e,t){return t.r=e.r,t.g=e.g,t.b=e.b,t}var Wn,Hn=function(){function Color(e,t,n){return Object(f.a)(this,Color),this.isColor=!0,this.r=1,this.g=1,this.b=1,void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}return Object(p.a)(Color,[{key:"set",value:function set(e){return e&&e.isColor?this.copy(e):"number"===typeof e?this.setHex(e):"string"===typeof e&&this.setStyle(e),this}},{key:"setScalar",value:function setScalar(e){return this.r=e,this.g=e,this.b=e,this}},{key:"setHex",value:function setHex(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Qt;return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,zn.toWorkingColorSpace(this,t),this}},{key:"setRGB",value:function setRGB(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:$t;return this.r=e,this.g=t,this.b=n,zn.toWorkingColorSpace(this,r),this}},{key:"setHSL",value:function setHSL(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:$t;if(e=euclideanModulo(e,1),t=clamp(t,0,1),n=clamp(n,0,1),0===t)this.r=this.g=this.b=n;else{var i=n<=.5?n*(1+t):n+t-n*t,a=2*n-i;this.r=hue2rgb(a,i,e+1/3),this.g=hue2rgb(a,i,e),this.b=hue2rgb(a,i,e-1/3)}return zn.toWorkingColorSpace(this,r),this}},{key:"setStyle",value:function setStyle(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Qt;function handleAlpha(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}if(t=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){var r,i=t[1],a=t[2];switch(i){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(r[1],10))/255,this.g=Math.min(255,parseInt(r[2],10))/255,this.b=Math.min(255,parseInt(r[3],10))/255,zn.toWorkingColorSpace(this,n),handleAlpha(r[4]),this;if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(r[1],10))/100,this.g=Math.min(100,parseInt(r[2],10))/100,this.b=Math.min(100,parseInt(r[3],10))/100,zn.toWorkingColorSpace(this,n),handleAlpha(r[4]),this;break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a)){var o=parseFloat(r[1])/360,s=parseInt(r[2],10)/100,u=parseInt(r[3],10)/100;return handleAlpha(r[4]),this.setHSL(o,s,u,n)}}}else if(t=/^\#([A-Fa-f\d]+)$/.exec(e)){var l=t[1],c=l.length;if(3===c)return this.r=parseInt(l.charAt(0)+l.charAt(0),16)/255,this.g=parseInt(l.charAt(1)+l.charAt(1),16)/255,this.b=parseInt(l.charAt(2)+l.charAt(2),16)/255,zn.toWorkingColorSpace(this,n),this;if(6===c)return this.r=parseInt(l.charAt(0)+l.charAt(1),16)/255,this.g=parseInt(l.charAt(2)+l.charAt(3),16)/255,this.b=parseInt(l.charAt(4)+l.charAt(5),16)/255,zn.toWorkingColorSpace(this,n),this}return e&&e.length>0?this.setColorName(e,n):this}},{key:"setColorName",value:function setColorName(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Qt,n=Fn[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}},{key:"clone",value:function clone(){return new this.constructor(this.r,this.g,this.b)}},{key:"copy",value:function copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}},{key:"copySRGBToLinear",value:function copySRGBToLinear(e){return this.r=SRGBToLinear(e.r),this.g=SRGBToLinear(e.g),this.b=SRGBToLinear(e.b),this}},{key:"copyLinearToSRGB",value:function copyLinearToSRGB(e){return this.r=LinearToSRGB(e.r),this.g=LinearToSRGB(e.g),this.b=LinearToSRGB(e.b),this}},{key:"convertSRGBToLinear",value:function convertSRGBToLinear(){return this.copySRGBToLinear(this),this}},{key:"convertLinearToSRGB",value:function convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}},{key:"getHex",value:function getHex(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Qt;return zn.fromWorkingColorSpace(toComponents(this,Gn),e),clamp(255*Gn.r,0,255)<<16^clamp(255*Gn.g,0,255)<<8^clamp(255*Gn.b,0,255)<<0}},{key:"getHexString",value:function getHexString(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Qt;return("000000"+this.getHex(e).toString(16)).slice(-6)}},{key:"getHSL",value:function getHSL(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$t;zn.fromWorkingColorSpace(toComponents(this,Gn),t);var n,r,i=Gn.r,a=Gn.g,o=Gn.b,s=Math.max(i,a,o),u=Math.min(i,a,o),l=(u+s)/2;if(u===s)n=0,r=0;else{var c=s-u;switch(r=l<=.5?c/(s+u):c/(2-s-u),s){case i:n=(a-o)/c+(a1&&void 0!==arguments[1]?arguments[1]:$t;return zn.fromWorkingColorSpace(toComponents(this,Gn),t),e.r=Gn.r,e.g=Gn.g,e.b=Gn.b,e}},{key:"getStyle",value:function getStyle(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Qt;return zn.fromWorkingColorSpace(toComponents(this,Gn),e),e!==Qt?"color(".concat(e," ").concat(Gn.r," ").concat(Gn.g," ").concat(Gn.b,")"):"rgb(".concat(255*Gn.r|0,",").concat(255*Gn.g|0,",").concat(255*Gn.b|0,")")}},{key:"offsetHSL",value:function offsetHSL(e,t,n){return this.getHSL(Un),Un.h+=e,Un.s+=t,Un.l+=n,this.setHSL(Un.h,Un.s,Un.l),this}},{key:"add",value:function add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}},{key:"addColors",value:function addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}},{key:"addScalar",value:function addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}},{key:"sub",value:function sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}},{key:"multiply",value:function multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}},{key:"multiplyScalar",value:function multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}},{key:"lerp",value:function lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}},{key:"lerpColors",value:function lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}},{key:"lerpHSL",value:function lerpHSL(e,t){this.getHSL(Un),e.getHSL(Vn);var n=lerp(Un.h,Vn.h,t),r=lerp(Un.s,Vn.s,t),i=lerp(Un.l,Vn.l,t);return this.setHSL(n,r,i),this}},{key:"equals",value:function equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}},{key:"fromArray",value:function fromArray(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}},{key:"toArray",value:function toArray(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}},{key:"fromBufferAttribute",value:function fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),!0===e.normalized&&(this.r/=255,this.g/=255,this.b/=255),this}},{key:"toJSON",value:function toJSON(){return this.getHex()}},{key:Symbol.iterator,value:d.a.mark(function value(){return d.a.wrap(function value$(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.r;case 2:return e.next=4,this.g;case 4:return e.next=6,this.b;case 6:case"end":return e.stop()}},value,this)})}]),Color}();Hn.NAMES=Fn;var qn=function(){function ImageUtils(){Object(f.a)(this,ImageUtils)}return Object(p.a)(ImageUtils,null,[{key:"getDataURL",value:function getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;var t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===Wn&&(Wn=createElementNS("canvas")),Wn.width=e.width,Wn.height=e.height;var n=Wn.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Wn}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}},{key:"sRGBToLinear",value:function sRGBToLinear(e){if("undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&e instanceof ImageBitmap){var t=createElementNS("canvas");t.width=e.width,t.height=e.height;var n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);for(var r=n.getImageData(0,0,e.width,e.height),i=r.data,a=0;a0&&void 0!==arguments[0]?arguments[0]:null;Object(f.a)(this,Source),this.isSource=!0,this.uuid=generateUUID(),this.data=e,this.version=0}return Object(p.a)(Source,[{key:"toJSON",value:function toJSON(e){var t=void 0===e||"string"===typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];var n={uuid:this.uuid,url:""},r=this.data;if(null!==r){var i;if(Array.isArray(r)){i=[];for(var a=0,o=r.length;a0&&void 0!==arguments[0]?arguments[0]:Texture.DEFAULT_IMAGE,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Texture.DEFAULT_MAPPING,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:we,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:we,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Ee,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:Ie,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:Ye,h=arguments.length>7&&void 0!==arguments[7]?arguments[7]:je,d=arguments.length>8&&void 0!==arguments[8]?arguments[8]:1,p=arguments.length>9&&void 0!==arguments[9]?arguments[9]:Ht;return Object(f.a)(this,Texture),(e=Object(s.a)(this,Object(r.a)(Texture).call(this))).isTexture=!0,Object.defineProperty(Object(l.a)(Object(l.a)(e)),"id",{value:Jn++}),e.uuid=generateUUID(),e.name="",e.source=new Xn(t),e.mipmaps=[],e.mapping=n,e.wrapS=i,e.wrapT=a,e.magFilter=o,e.minFilter=u,e.anisotropy=d,e.format=c,e.internalFormat=null,e.type=h,e.offset=new Dn(0,0),e.repeat=new Dn(1,1),e.center=new Dn(0,0),e.rotation=0,e.matrixAutoUpdate=!0,e.matrix=new jn,e.generateMipmaps=!0,e.premultiplyAlpha=!1,e.flipY=!0,e.unpackAlignment=4,e.encoding=p,e.userData={},e.version=0,e.onUpdate=null,e.isRenderTargetTexture=!1,e.needsPMREMUpdate=!1,e}return Object(u.a)(Texture,e),Object(p.a)(Texture,[{key:"updateMatrix",value:function updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}},{key:"copy",value:function copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}},{key:"toJSON",value:function toJSON(e){var t=void 0===e||"string"===typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];var n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}},{key:"dispose",value:function dispose(){this.dispatchEvent({type:"dispose"})}},{key:"transformUv",value:function transformUv(e){if(this.mapping!==ge)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Se:e.x=e.x-Math.floor(e.x);break;case we:e.x=e.x<0?0:1;break;case Te:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case Se:e.y=e.y-Math.floor(e.y);break;case we:e.y=e.y<0?0:1;break;case Te:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}},{key:"image",get:function get(){return this.source.data},set:function set(e){this.source.data=e}},{key:"needsUpdate",set:function set(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}}]),Texture}(Ln);Yn.DEFAULT_IMAGE=null,Yn.DEFAULT_MAPPING=ge;var Zn=function(){function Vector4(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;Object(f.a)(this,Vector4),Vector4.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}return Object(p.a)(Vector4,[{key:"set",value:function set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}},{key:"setScalar",value:function setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}},{key:"setX",value:function setX(e){return this.x=e,this}},{key:"setY",value:function setY(e){return this.y=e,this}},{key:"setZ",value:function setZ(e){return this.z=e,this}},{key:"setW",value:function setW(e){return this.w=e,this}},{key:"setComponent",value:function setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}},{key:"getComponent",value:function getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}},{key:"clone",value:function clone(){return new this.constructor(this.x,this.y,this.z,this.w)}},{key:"copy",value:function copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}},{key:"add",value:function add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}},{key:"addScalar",value:function addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}},{key:"addVectors",value:function addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}},{key:"addScaledVector",value:function addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}},{key:"sub",value:function sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}},{key:"subScalar",value:function subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}},{key:"subVectors",value:function subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}},{key:"multiply",value:function multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}},{key:"multiplyScalar",value:function multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}},{key:"applyMatrix4",value:function applyMatrix4(e){var t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}},{key:"divideScalar",value:function divideScalar(e){return this.multiplyScalar(1/e)}},{key:"setAxisAngleFromQuaternion",value:function setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}},{key:"setAxisAngleFromRotationMatrix",value:function setAxisAngleFromRotationMatrix(e){var t,n,r,i,a=e.elements,o=a[0],s=a[4],u=a[8],l=a[1],c=a[5],h=a[9],d=a[2],f=a[6],p=a[10];if(Math.abs(s-l)<.01&&Math.abs(u-d)<.01&&Math.abs(h-f)<.01){if(Math.abs(s+l)<.1&&Math.abs(u+d)<.1&&Math.abs(h+f)<.1&&Math.abs(o+c+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(o+1)/2,v=(c+1)/2,g=(p+1)/2,y=(s+l)/4,b=(u+d)/4,x=(h+f)/4;return m>v&&m>g?m<.01?(n=0,r=.707106781,i=.707106781):(r=y/(n=Math.sqrt(m)),i=b/n):v>g?v<.01?(n=.707106781,r=0,i=.707106781):(n=y/(r=Math.sqrt(v)),i=x/r):g<.01?(n=.707106781,r=.707106781,i=0):(n=b/(i=Math.sqrt(g)),r=x/i),this.set(n,r,i,t),this}var _=Math.sqrt((f-h)*(f-h)+(u-d)*(u-d)+(l-s)*(l-s));return Math.abs(_)<.001&&(_=1),this.x=(f-h)/_,this.y=(u-d)/_,this.z=(l-s)/_,this.w=Math.acos((o+c+p-1)/2),this}},{key:"min",value:function min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}},{key:"max",value:function max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}},{key:"clamp",value:function clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this}},{key:"clampScalar",value:function clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this.w=Math.max(e,Math.min(t,this.w)),this}},{key:"clampLength",value:function clampLength(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}},{key:"floor",value:function floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}},{key:"ceil",value:function ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}},{key:"round",value:function round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}},{key:"roundToZero",value:function roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}},{key:"negate",value:function negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}},{key:"dot",value:function dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}},{key:"lengthSq",value:function lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}},{key:"length",value:function length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}},{key:"manhattanLength",value:function manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}},{key:"normalize",value:function normalize(){return this.divideScalar(this.length()||1)}},{key:"setLength",value:function setLength(e){return this.normalize().multiplyScalar(e)}},{key:"lerp",value:function lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}},{key:"lerpVectors",value:function lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}},{key:"equals",value:function equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}},{key:"fromArray",value:function fromArray(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}},{key:"toArray",value:function toArray(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}},{key:"fromBufferAttribute",value:function fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}},{key:"random",value:function random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}},{key:Symbol.iterator,value:d.a.mark(function value(){return d.a.wrap(function value$(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.x;case 2:return e.next=4,this.y;case 4:return e.next=6,this.z;case 6:return e.next=8,this.w;case 8:case"end":return e.stop()}},value,this)})},{key:"width",get:function get(){return this.z},set:function set(e){this.z=e}},{key:"height",get:function get(){return this.w},set:function set(e){this.w=e}}]),Vector4}(),Kn=function(e){function WebGLRenderTarget(e,t){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Object(f.a)(this,WebGLRenderTarget),(n=Object(s.a)(this,Object(r.a)(WebGLRenderTarget).call(this))).isWebGLRenderTarget=!0,n.width=e,n.height=t,n.depth=1,n.scissor=new Zn(0,0,e,t),n.scissorTest=!1,n.viewport=new Zn(0,0,e,t);var a={width:e,height:t,depth:1};return n.texture=new Yn(a,i.mapping,i.wrapS,i.wrapT,i.magFilter,i.minFilter,i.format,i.type,i.anisotropy,i.encoding),n.texture.isRenderTargetTexture=!0,n.texture.flipY=!1,n.texture.generateMipmaps=void 0!==i.generateMipmaps&&i.generateMipmaps,n.texture.internalFormat=void 0!==i.internalFormat?i.internalFormat:null,n.texture.minFilter=void 0!==i.minFilter?i.minFilter:Ee,n.depthBuffer=void 0===i.depthBuffer||i.depthBuffer,n.stencilBuffer=void 0!==i.stencilBuffer&&i.stencilBuffer,n.depthTexture=void 0!==i.depthTexture?i.depthTexture:null,n.samples=void 0!==i.samples?i.samples:0,n}return Object(u.a)(WebGLRenderTarget,e),Object(p.a)(WebGLRenderTarget,[{key:"setSize",value:function setSize(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this.width===e&&this.height===t&&this.depth===n||(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}},{key:"copy",value:function copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;var t=Object.assign({},e.texture.image);return this.texture.source=new Xn(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}},{key:"dispose",value:function dispose(){this.dispatchEvent({type:"dispose"})}}]),WebGLRenderTarget}(Ln),Qn=function(e){function DataArrayTexture(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return Object(f.a)(this,DataArrayTexture),(e=Object(s.a)(this,Object(r.a)(DataArrayTexture).call(this,null))).isDataArrayTexture=!0,e.image={data:t,width:n,height:i,depth:a},e.magFilter=Ae,e.minFilter=Ae,e.wrapR=we,e.generateMipmaps=!1,e.flipY=!1,e.unpackAlignment=1,e}return Object(u.a)(DataArrayTexture,e),DataArrayTexture}(Yn),$n=function(e){function WebGLArrayRenderTarget(e,t,n){var i;return Object(f.a)(this,WebGLArrayRenderTarget),(i=Object(s.a)(this,Object(r.a)(WebGLArrayRenderTarget).call(this,e,t))).isWebGLArrayRenderTarget=!0,i.depth=n,i.texture=new Qn(null,e,t,n),i.texture.isRenderTargetTexture=!0,i}return Object(u.a)(WebGLArrayRenderTarget,e),WebGLArrayRenderTarget}(Kn),er=function(e){function Data3DTexture(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return Object(f.a)(this,Data3DTexture),(e=Object(s.a)(this,Object(r.a)(Data3DTexture).call(this,null))).isData3DTexture=!0,e.image={data:t,width:n,height:i,depth:a},e.magFilter=Ae,e.minFilter=Ae,e.wrapR=we,e.generateMipmaps=!1,e.flipY=!1,e.unpackAlignment=1,e}return Object(u.a)(Data3DTexture,e),Data3DTexture}(Yn),tr=function(e){function WebGL3DRenderTarget(e,t,n){var i;return Object(f.a)(this,WebGL3DRenderTarget),(i=Object(s.a)(this,Object(r.a)(WebGL3DRenderTarget).call(this,e,t))).isWebGL3DRenderTarget=!0,i.depth=n,i.texture=new er(null,e,t,n),i.texture.isRenderTargetTexture=!0,i}return Object(u.a)(WebGL3DRenderTarget,e),WebGL3DRenderTarget}(Kn),nr=function(e){function WebGLMultipleRenderTargets(e,t,n){var i,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};Object(f.a)(this,WebGLMultipleRenderTargets),(i=Object(s.a)(this,Object(r.a)(WebGLMultipleRenderTargets).call(this,e,t,a))).isWebGLMultipleRenderTargets=!0;var o=i.texture;i.texture=[];for(var u=0;u2&&void 0!==arguments[2]?arguments[2]:1;if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(var r=0,i=this.texture.length;r0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;Object(f.a)(this,Quaternion),this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}return Object(p.a)(Quaternion,[{key:"set",value:function set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}},{key:"clone",value:function clone(){return new this.constructor(this._x,this._y,this._z,this._w)}},{key:"copy",value:function copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}},{key:"setFromEuler",value:function setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,u=o(n/2),l=o(r/2),c=o(i/2),h=s(n/2),d=s(r/2),f=s(i/2);switch(a){case"XYZ":this._x=h*l*c+u*d*f,this._y=u*d*c-h*l*f,this._z=u*l*f+h*d*c,this._w=u*l*c-h*d*f;break;case"YXZ":this._x=h*l*c+u*d*f,this._y=u*d*c-h*l*f,this._z=u*l*f-h*d*c,this._w=u*l*c+h*d*f;break;case"ZXY":this._x=h*l*c-u*d*f,this._y=u*d*c+h*l*f,this._z=u*l*f+h*d*c,this._w=u*l*c-h*d*f;break;case"ZYX":this._x=h*l*c-u*d*f,this._y=u*d*c+h*l*f,this._z=u*l*f-h*d*c,this._w=u*l*c+h*d*f;break;case"YZX":this._x=h*l*c+u*d*f,this._y=u*d*c+h*l*f,this._z=u*l*f-h*d*c,this._w=u*l*c-h*d*f;break;case"XZY":this._x=h*l*c-u*d*f,this._y=u*d*c-h*l*f,this._z=u*l*f+h*d*c,this._w=u*l*c+h*d*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!1!==t&&this._onChangeCallback(),this}},{key:"setFromAxisAngle",value:function setFromAxisAngle(e,t){var n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}},{key:"setFromRotationMatrix",value:function setFromRotationMatrix(e){var t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],u=t[2],l=t[6],c=t[10],h=n+o+c;if(h>0){var d=.5/Math.sqrt(h+1);this._w=.25/d,this._x=(l-s)*d,this._y=(i-u)*d,this._z=(a-r)*d}else if(n>o&&n>c){var f=2*Math.sqrt(1+n-o-c);this._w=(l-s)/f,this._x=.25*f,this._y=(r+a)/f,this._z=(i+u)/f}else if(o>c){var p=2*Math.sqrt(1+o-n-c);this._w=(i-u)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(s+l)/p}else{var m=2*Math.sqrt(1+c-n-o);this._w=(a-r)/m,this._x=(i+u)/m,this._y=(s+l)/m,this._z=.25*m}return this._onChangeCallback(),this}},{key:"setFromUnitVectors",value:function setFromUnitVectors(e,t){var n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}},{key:"angleTo",value:function angleTo(e){return 2*Math.acos(Math.abs(clamp(this.dot(e),-1,1)))}},{key:"rotateTowards",value:function rotateTowards(e,t){var n=this.angleTo(e);if(0===n)return this;var r=Math.min(1,t/n);return this.slerp(e,r),this}},{key:"identity",value:function identity(){return this.set(0,0,0,1)}},{key:"invert",value:function invert(){return this.conjugate()}},{key:"conjugate",value:function conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}},{key:"dot",value:function dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}},{key:"lengthSq",value:function lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}},{key:"length",value:function length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}},{key:"normalize",value:function normalize(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}},{key:"multiply",value:function multiply(e){return this.multiplyQuaternions(this,e)}},{key:"premultiply",value:function premultiply(e){return this.multiplyQuaternions(e,this)}},{key:"multiplyQuaternions",value:function multiplyQuaternions(e,t){var n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,u=t._z,l=t._w;return this._x=n*l+a*o+r*u-i*s,this._y=r*l+a*s+i*o-n*u,this._z=i*l+a*u+n*s-r*o,this._w=a*l-n*o-r*s-i*u,this._onChangeCallback(),this}},{key:"slerp",value:function slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);var n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;var s=1-o*o;if(s<=Number.EPSILON){var u=1-t;return this._w=u*a+t*this._w,this._x=u*n+t*this._x,this._y=u*r+t*this._y,this._z=u*i+t*this._z,this.normalize(),this._onChangeCallback(),this}var l=Math.sqrt(s),c=Math.atan2(l,o),h=Math.sin((1-t)*c)/l,d=Math.sin(t*c)/l;return this._w=a*h+this._w*d,this._x=n*h+this._x*d,this._y=r*h+this._y*d,this._z=i*h+this._z*d,this._onChangeCallback(),this}},{key:"slerpQuaternions",value:function slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}},{key:"random",value:function random(){var e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),r=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(t*Math.cos(r),n*Math.sin(i),n*Math.cos(i),t*Math.sin(r))}},{key:"equals",value:function equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}},{key:"fromArray",value:function fromArray(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}},{key:"toArray",value:function toArray(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}},{key:"fromBufferAttribute",value:function fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}},{key:"_onChange",value:function _onChange(e){return this._onChangeCallback=e,this}},{key:"_onChangeCallback",value:function _onChangeCallback(){}},{key:Symbol.iterator,value:d.a.mark(function value(){return d.a.wrap(function value$(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._x;case 2:return e.next=4,this._y;case 4:return e.next=6,this._z;case 6:return e.next=8,this._w;case 8:case"end":return e.stop()}},value,this)})},{key:"x",get:function get(){return this._x},set:function set(e){this._x=e,this._onChangeCallback()}},{key:"y",get:function get(){return this._y},set:function set(e){this._y=e,this._onChangeCallback()}},{key:"z",get:function get(){return this._z},set:function set(e){this._z=e,this._onChangeCallback()}},{key:"w",get:function get(){return this._w},set:function set(e){this._w=e,this._onChangeCallback()}}],[{key:"slerpFlat",value:function slerpFlat(e,t,n,r,i,a,o){var s=n[r+0],u=n[r+1],l=n[r+2],c=n[r+3],h=i[a+0],d=i[a+1],f=i[a+2],p=i[a+3];if(0===o)return e[t+0]=s,e[t+1]=u,e[t+2]=l,void(e[t+3]=c);if(1===o)return e[t+0]=h,e[t+1]=d,e[t+2]=f,void(e[t+3]=p);if(c!==p||s!==h||u!==d||l!==f){var m=1-o,v=s*h+u*d+l*f+c*p,g=v>=0?1:-1,y=1-v*v;if(y>Number.EPSILON){var b=Math.sqrt(y),x=Math.atan2(b,v*g);m=Math.sin(m*x)/b,o=Math.sin(o*x)/b}var _=o*g;if(s=s*m+h*_,u=u*m+d*_,l=l*m+f*_,c=c*m+p*_,m===1-o){var M=1/Math.sqrt(s*s+u*u+l*l+c*c);s*=M,u*=M,l*=M,c*=M}}e[t]=s,e[t+1]=u,e[t+2]=l,e[t+3]=c}},{key:"multiplyQuaternionsFlat",value:function multiplyQuaternionsFlat(e,t,n,r,i,a){var o=n[r],s=n[r+1],u=n[r+2],l=n[r+3],c=i[a],h=i[a+1],d=i[a+2],f=i[a+3];return e[t]=o*f+l*c+s*d-u*h,e[t+1]=s*f+l*h+u*c-o*d,e[t+2]=u*f+l*d+o*h-s*c,e[t+3]=l*f-o*c-s*h-u*d,e}}]),Quaternion}(),ir=function(){function Vector3(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;Object(f.a)(this,Vector3),Vector3.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}return Object(p.a)(Vector3,[{key:"set",value:function set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}},{key:"setScalar",value:function setScalar(e){return this.x=e,this.y=e,this.z=e,this}},{key:"setX",value:function setX(e){return this.x=e,this}},{key:"setY",value:function setY(e){return this.y=e,this}},{key:"setZ",value:function setZ(e){return this.z=e,this}},{key:"setComponent",value:function setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}},{key:"getComponent",value:function getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}},{key:"clone",value:function clone(){return new this.constructor(this.x,this.y,this.z)}},{key:"copy",value:function copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}},{key:"add",value:function add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}},{key:"addScalar",value:function addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}},{key:"addVectors",value:function addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}},{key:"addScaledVector",value:function addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}},{key:"sub",value:function sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}},{key:"subScalar",value:function subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}},{key:"subVectors",value:function subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}},{key:"multiply",value:function multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}},{key:"multiplyScalar",value:function multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}},{key:"multiplyVectors",value:function multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}},{key:"applyEuler",value:function applyEuler(e){return this.applyQuaternion(or.setFromEuler(e))}},{key:"applyAxisAngle",value:function applyAxisAngle(e,t){return this.applyQuaternion(or.setFromAxisAngle(e,t))}},{key:"applyMatrix3",value:function applyMatrix3(e){var t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}},{key:"applyNormalMatrix",value:function applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}},{key:"applyMatrix4",value:function applyMatrix4(e){var t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}},{key:"applyQuaternion",value:function applyQuaternion(e){var t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,u=s*t+a*r-o*n,l=s*n+o*t-i*r,c=s*r+i*n-a*t,h=-i*t-a*n-o*r;return this.x=u*s+h*-i+l*-o-c*-a,this.y=l*s+h*-a+c*-i-u*-o,this.z=c*s+h*-o+u*-a-l*-i,this}},{key:"project",value:function project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}},{key:"unproject",value:function unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}},{key:"transformDirection",value:function transformDirection(e){var t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}},{key:"divide",value:function divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}},{key:"divideScalar",value:function divideScalar(e){return this.multiplyScalar(1/e)}},{key:"min",value:function min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}},{key:"max",value:function max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}},{key:"clamp",value:function clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}},{key:"clampScalar",value:function clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}},{key:"clampLength",value:function clampLength(e,t){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}},{key:"floor",value:function floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}},{key:"ceil",value:function ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}},{key:"round",value:function round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}},{key:"roundToZero",value:function roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}},{key:"negate",value:function negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}},{key:"dot",value:function dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}},{key:"lengthSq",value:function lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}},{key:"length",value:function length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}},{key:"manhattanLength",value:function manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}},{key:"normalize",value:function normalize(){return this.divideScalar(this.length()||1)}},{key:"setLength",value:function setLength(e){return this.normalize().multiplyScalar(e)}},{key:"lerp",value:function lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}},{key:"lerpVectors",value:function lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}},{key:"cross",value:function cross(e){return this.crossVectors(this,e)}},{key:"crossVectors",value:function crossVectors(e,t){var n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}},{key:"projectOnVector",value:function projectOnVector(e){var t=e.lengthSq();if(0===t)return this.set(0,0,0);var n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}},{key:"projectOnPlane",value:function projectOnPlane(e){return ar.copy(this).projectOnVector(e),this.sub(ar)}},{key:"reflect",value:function reflect(e){return this.sub(ar.copy(e).multiplyScalar(2*this.dot(e)))}},{key:"angleTo",value:function angleTo(e){var t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;var n=this.dot(e)/t;return Math.acos(clamp(n,-1,1))}},{key:"distanceTo",value:function distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}},{key:"distanceToSquared",value:function distanceToSquared(e){var t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}},{key:"manhattanDistanceTo",value:function manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}},{key:"setFromSpherical",value:function setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}},{key:"setFromSphericalCoords",value:function setFromSphericalCoords(e,t,n){var r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}},{key:"setFromCylindrical",value:function setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}},{key:"setFromCylindricalCoords",value:function setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}},{key:"setFromMatrixPosition",value:function setFromMatrixPosition(e){var t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}},{key:"setFromMatrixScale",value:function setFromMatrixScale(e){var t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}},{key:"setFromMatrixColumn",value:function setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}},{key:"setFromMatrix3Column",value:function setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}},{key:"setFromEuler",value:function setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}},{key:"equals",value:function equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}},{key:"fromArray",value:function fromArray(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}},{key:"toArray",value:function toArray(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}},{key:"fromBufferAttribute",value:function fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}},{key:"random",value:function random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}},{key:"randomDirection",value:function randomDirection(){var e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-Math.pow(e,2));return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}},{key:Symbol.iterator,value:d.a.mark(function value(){return d.a.wrap(function value$(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.x;case 2:return e.next=4,this.y;case 4:return e.next=6,this.z;case 6:case"end":return e.stop()}},value,this)})}]),Vector3}(),ar=new ir,or=new rr,sr=function(){function Box3(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir(1/0,1/0,1/0),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir(-1/0,-1/0,-1/0);Object(f.a)(this,Box3),this.isBox3=!0,this.min=e,this.max=t}return Object(p.a)(Box3,[{key:"set",value:function set(e,t){return this.min.copy(e),this.max.copy(t),this}},{key:"setFromArray",value:function setFromArray(e){for(var t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,u=e.length;si&&(i=l),c>a&&(a=c),h>o&&(o=h)}return this.min.set(t,n,r),this.max.set(i,a,o),this}},{key:"setFromBufferAttribute",value:function setFromBufferAttribute(e){for(var t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,u=e.count;si&&(i=l),c>a&&(a=c),h>o&&(o=h)}return this.min.set(t,n,r),this.max.set(i,a,o),this}},{key:"setFromPoints",value:function setFromPoints(e){this.makeEmpty();for(var t=0,n=e.length;t1&&void 0!==arguments[1]&&arguments[1];return this.makeEmpty(),this.expandByObject(e,t)}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}},{key:"copy",value:function copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}},{key:"makeEmpty",value:function makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}},{key:"isEmpty",value:function isEmpty(){return this.max.x1&&void 0!==arguments[1]&&arguments[1];e.updateWorldMatrix(!1,!1);var n=e.geometry;if(void 0!==n)if(t&&void 0!=n.attributes&&void 0!==n.attributes.position)for(var r=n.attributes.position,i=0,a=r.count;ithis.max.x||e.ythis.max.y||e.zthis.max.z)}},{key:"containsBox",value:function containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}},{key:"getParameter",value:function getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}},{key:"intersectsBox",value:function intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}},{key:"intersectsSphere",value:function intersectsSphere(e){return this.clampPoint(e.center,lr),lr.distanceToSquared(e.center)<=e.radius*e.radius}},{key:"intersectsPlane",value:function intersectsPlane(e){var t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}},{key:"intersectsTriangle",value:function intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(gr),yr.subVectors(this.max,gr),hr.subVectors(e.a,gr),dr.subVectors(e.b,gr),fr.subVectors(e.c,gr),pr.subVectors(dr,hr),mr.subVectors(fr,dr),vr.subVectors(hr,fr);var t=[0,-pr.z,pr.y,0,-mr.z,mr.y,0,-vr.z,vr.y,pr.z,0,-pr.x,mr.z,0,-mr.x,vr.z,0,-vr.x,-pr.y,pr.x,0,-mr.y,mr.x,0,-vr.y,vr.x,0];return!!satForAxes(t,hr,dr,fr,yr)&&(!!satForAxes(t=[1,0,0,0,1,0,0,0,1],hr,dr,fr,yr)&&(br.crossVectors(pr,mr),satForAxes(t=[br.x,br.y,br.z],hr,dr,fr,yr)))}},{key:"clampPoint",value:function clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}},{key:"distanceToPoint",value:function distanceToPoint(e){return lr.copy(e).clamp(this.min,this.max).sub(e).length()}},{key:"getBoundingSphere",value:function getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(lr).length(),e}},{key:"intersect",value:function intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}},{key:"union",value:function union(e){return this.min.min(e.min),this.max.max(e.max),this}},{key:"applyMatrix4",value:function applyMatrix4(e){return this.isEmpty()?this:(ur[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),ur[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),ur[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),ur[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),ur[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),ur[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),ur[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),ur[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(ur),this)}},{key:"translate",value:function translate(e){return this.min.add(e),this.max.add(e),this}},{key:"equals",value:function equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}]),Box3}(),ur=[new ir,new ir,new ir,new ir,new ir,new ir,new ir,new ir],lr=new ir,cr=new sr,hr=new ir,dr=new ir,fr=new ir,pr=new ir,mr=new ir,vr=new ir,gr=new ir,yr=new ir,br=new ir,xr=new ir;function satForAxes(e,t,n,r,i){for(var a=0,o=e.length-3;a<=o;a+=3){xr.fromArray(e,a);var s=i.x*Math.abs(xr.x)+i.y*Math.abs(xr.y)+i.z*Math.abs(xr.z),u=t.dot(xr),l=n.dot(xr),c=r.dot(xr);if(Math.max(-Math.max(u,l,c),Math.min(u,l,c))>s)return!1}return!0}var _r=new sr,Mr=new ir,Sr=new ir,wr=new ir,Tr=function(){function Sphere(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;Object(f.a)(this,Sphere),this.center=e,this.radius=t}return Object(p.a)(Sphere,[{key:"set",value:function set(e,t){return this.center.copy(e),this.radius=t,this}},{key:"setFromPoints",value:function setFromPoints(e,t){var n=this.center;void 0!==t?n.copy(t):_r.setFromPoints(e).getCenter(n);for(var r=0,i=0,a=e.length;ithis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}},{key:"getBoundingBox",value:function getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}},{key:"applyMatrix4",value:function applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}},{key:"translate",value:function translate(e){return this.center.add(e),this}},{key:"expandByPoint",value:function expandByPoint(e){wr.subVectors(e,this.center);var t=wr.lengthSq();if(t>this.radius*this.radius){var n=Math.sqrt(t),r=.5*(n-this.radius);this.center.add(wr.multiplyScalar(r/n)),this.radius+=r}return this}},{key:"union",value:function union(e){return!0===this.center.equals(e.center)?Sr.set(0,0,1).multiplyScalar(e.radius):Sr.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Mr.copy(e.center).add(Sr)),this.expandByPoint(Mr.copy(e.center).sub(Sr)),this}},{key:"equals",value:function equals(e){return e.center.equals(this.center)&&e.radius===this.radius}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}}]),Sphere}(),Ar=new ir,Or=new ir,Cr=new ir,Lr=new ir,kr=new ir,Er=new ir,Pr=new ir,Rr=function(){function Ray(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir(0,0,-1);Object(f.a)(this,Ray),this.origin=e,this.direction=t}return Object(p.a)(Ray,[{key:"set",value:function set(e,t){return this.origin.copy(e),this.direction.copy(t),this}},{key:"copy",value:function copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}},{key:"at",value:function at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}},{key:"lookAt",value:function lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}},{key:"recast",value:function recast(e){return this.origin.copy(this.at(e,Ar)),this}},{key:"closestPointToPoint",value:function closestPointToPoint(e,t){t.subVectors(e,this.origin);var n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}},{key:"distanceToPoint",value:function distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}},{key:"distanceSqToPoint",value:function distanceSqToPoint(e){var t=Ar.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ar.copy(this.direction).multiplyScalar(t).add(this.origin),Ar.distanceToSquared(e))}},{key:"distanceSqToSegment",value:function distanceSqToSegment(e,t,n,r){Or.copy(e).add(t).multiplyScalar(.5),Cr.copy(t).sub(e).normalize(),Lr.copy(this.origin).sub(Or);var i,a,o,s,u=.5*e.distanceTo(t),l=-this.direction.dot(Cr),c=Lr.dot(this.direction),h=-Lr.dot(Cr),d=Lr.lengthSq(),f=Math.abs(1-l*l);if(f>0)if(a=l*c-h,s=u*f,(i=l*h-c)>=0)if(a>=-s)if(a<=s){var p=1/f;o=(i*=p)*(i+l*(a*=p)+2*c)+a*(l*i+a+2*h)+d}else a=u,o=-(i=Math.max(0,-(l*a+c)))*i+a*(a+2*h)+d;else a=-u,o=-(i=Math.max(0,-(l*a+c)))*i+a*(a+2*h)+d;else a<=-s?o=-(i=Math.max(0,-(-l*u+c)))*i+(a=i>0?-u:Math.min(Math.max(-u,-h),u))*(a+2*h)+d:a<=s?(i=0,o=(a=Math.min(Math.max(-u,-h),u))*(a+2*h)+d):o=-(i=Math.max(0,-(l*u+c)))*i+(a=i>0?u:Math.min(Math.max(-u,-h),u))*(a+2*h)+d;else a=l>0?-u:u,o=-(i=Math.max(0,-(l*a+c)))*i+a*(a+2*h)+d;return n&&n.copy(this.direction).multiplyScalar(i).add(this.origin),r&&r.copy(Cr).multiplyScalar(a).add(Or),o}},{key:"intersectSphere",value:function intersectSphere(e,t){Ar.subVectors(e.center,this.origin);var n=Ar.dot(this.direction),r=Ar.dot(Ar)-n*n,i=e.radius*e.radius;if(r>i)return null;var a=Math.sqrt(i-r),o=n-a,s=n+a;return o<0&&s<0?null:o<0?this.at(s,t):this.at(o,t)}},{key:"intersectsSphere",value:function intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}},{key:"distanceToPlane",value:function distanceToPlane(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}},{key:"intersectPlane",value:function intersectPlane(e,t){var n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}},{key:"intersectsPlane",value:function intersectsPlane(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0}},{key:"intersectBox",value:function intersectBox(e,t){var n,r,i,a,o,s,u=1/this.direction.x,l=1/this.direction.y,c=1/this.direction.z,h=this.origin;return u>=0?(n=(e.min.x-h.x)*u,r=(e.max.x-h.x)*u):(n=(e.max.x-h.x)*u,r=(e.min.x-h.x)*u),l>=0?(i=(e.min.y-h.y)*l,a=(e.max.y-h.y)*l):(i=(e.max.y-h.y)*l,a=(e.min.y-h.y)*l),n>a||i>r?null:((i>n||n!==n)&&(n=i),(a=0?(o=(e.min.z-h.z)*c,s=(e.max.z-h.z)*c):(o=(e.max.z-h.z)*c,s=(e.min.z-h.z)*c),n>s||o>r?null:((o>n||n!==n)&&(n=o),(s=0?n:r,t)))}},{key:"intersectsBox",value:function intersectsBox(e){return null!==this.intersectBox(e,Ar)}},{key:"intersectTriangle",value:function intersectTriangle(e,t,n,r,i){kr.subVectors(t,e),Er.subVectors(n,e),Pr.crossVectors(kr,Er);var a,o=this.direction.dot(Pr);if(o>0){if(r)return null;a=1}else{if(!(o<0))return null;a=-1,o=-o}Lr.subVectors(this.origin,e);var s=a*this.direction.dot(Er.crossVectors(Lr,Er));if(s<0)return null;var u=a*this.direction.dot(kr.cross(Lr));if(u<0)return null;if(s+u>o)return null;var l=-a*Lr.dot(Pr);return l<0?null:this.at(l/o,i)}},{key:"applyMatrix4",value:function applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}},{key:"equals",value:function equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}}]),Ray}(),Ir=function(){function Matrix4(){Object(f.a)(this,Matrix4),Matrix4.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}return Object(p.a)(Matrix4,[{key:"set",value:function set(e,t,n,r,i,a,o,s,u,l,c,h,d,f,p,m){var v=this.elements;return v[0]=e,v[4]=t,v[8]=n,v[12]=r,v[1]=i,v[5]=a,v[9]=o,v[13]=s,v[2]=u,v[6]=l,v[10]=c,v[14]=h,v[3]=d,v[7]=f,v[11]=p,v[15]=m,this}},{key:"identity",value:function identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}},{key:"clone",value:function clone(){return(new Matrix4).fromArray(this.elements)}},{key:"copy",value:function copy(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}},{key:"copyPosition",value:function copyPosition(e){var t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}},{key:"setFromMatrix3",value:function setFromMatrix3(e){var t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}},{key:"extractBasis",value:function extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}},{key:"makeBasis",value:function makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}},{key:"extractRotation",value:function extractRotation(e){var t=this.elements,n=e.elements,r=1/Dr.setFromMatrixColumn(e,0).length(),i=1/Dr.setFromMatrixColumn(e,1).length(),a=1/Dr.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}},{key:"makeRotationFromEuler",value:function makeRotationFromEuler(e){var t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),u=Math.sin(r),l=Math.cos(i),c=Math.sin(i);if("XYZ"===e.order){var h=a*l,d=a*c,f=o*l,p=o*c;t[0]=s*l,t[4]=-s*c,t[8]=u,t[1]=d+f*u,t[5]=h-p*u,t[9]=-o*s,t[2]=p-h*u,t[6]=f+d*u,t[10]=a*s}else if("YXZ"===e.order){var m=s*l,v=s*c,g=u*l,y=u*c;t[0]=m+y*o,t[4]=g*o-v,t[8]=a*u,t[1]=a*c,t[5]=a*l,t[9]=-o,t[2]=v*o-g,t[6]=y+m*o,t[10]=a*s}else if("ZXY"===e.order){var b=s*l,x=s*c,_=u*l,M=u*c;t[0]=b-M*o,t[4]=-a*c,t[8]=_+x*o,t[1]=x+_*o,t[5]=a*l,t[9]=M-b*o,t[2]=-a*u,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){var S=a*l,w=a*c,T=o*l,A=o*c;t[0]=s*l,t[4]=T*u-w,t[8]=S*u+A,t[1]=s*c,t[5]=A*u+S,t[9]=w*u-T,t[2]=-u,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){var O=a*s,C=a*u,L=o*s,k=o*u;t[0]=s*l,t[4]=k-O*c,t[8]=L*c+C,t[1]=c,t[5]=a*l,t[9]=-o*l,t[2]=-u*l,t[6]=C*c+L,t[10]=O-k*c}else if("XZY"===e.order){var E=a*s,P=a*u,R=o*s,I=o*u;t[0]=s*l,t[4]=-c,t[8]=u*l,t[1]=E*c+I,t[5]=a*l,t[9]=P*c-R,t[2]=R*c-P,t[6]=o*l,t[10]=I*c+E}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}},{key:"makeRotationFromQuaternion",value:function makeRotationFromQuaternion(e){return this.compose(Br,e,Nr)}},{key:"lookAt",value:function lookAt(e,t,n){var r=this.elements;return Gr.subVectors(e,t),0===Gr.lengthSq()&&(Gr.z=1),Gr.normalize(),zr.crossVectors(n,Gr),0===zr.lengthSq()&&(1===Math.abs(n.z)?Gr.x+=1e-4:Gr.z+=1e-4,Gr.normalize(),zr.crossVectors(n,Gr)),zr.normalize(),Fr.crossVectors(Gr,zr),r[0]=zr.x,r[4]=Fr.x,r[8]=Gr.x,r[1]=zr.y,r[5]=Fr.y,r[9]=Gr.y,r[2]=zr.z,r[6]=Fr.z,r[10]=Gr.z,this}},{key:"multiply",value:function multiply(e){return this.multiplyMatrices(this,e)}},{key:"premultiply",value:function premultiply(e){return this.multiplyMatrices(e,this)}},{key:"multiplyMatrices",value:function multiplyMatrices(e,t){var n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],u=n[12],l=n[1],c=n[5],h=n[9],d=n[13],f=n[2],p=n[6],m=n[10],v=n[14],g=n[3],y=n[7],b=n[11],x=n[15],_=r[0],M=r[4],S=r[8],w=r[12],T=r[1],A=r[5],O=r[9],C=r[13],L=r[2],k=r[6],E=r[10],P=r[14],R=r[3],I=r[7],D=r[11],j=r[15];return i[0]=a*_+o*T+s*L+u*R,i[4]=a*M+o*A+s*k+u*I,i[8]=a*S+o*O+s*E+u*D,i[12]=a*w+o*C+s*P+u*j,i[1]=l*_+c*T+h*L+d*R,i[5]=l*M+c*A+h*k+d*I,i[9]=l*S+c*O+h*E+d*D,i[13]=l*w+c*C+h*P+d*j,i[2]=f*_+p*T+m*L+v*R,i[6]=f*M+p*A+m*k+v*I,i[10]=f*S+p*O+m*E+v*D,i[14]=f*w+p*C+m*P+v*j,i[3]=g*_+y*T+b*L+x*R,i[7]=g*M+y*A+b*k+x*I,i[11]=g*S+y*O+b*E+x*D,i[15]=g*w+y*C+b*P+x*j,this}},{key:"multiplyScalar",value:function multiplyScalar(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}},{key:"determinant",value:function determinant(){var e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],u=e[13],l=e[2],c=e[6],h=e[10],d=e[14];return e[3]*(+i*s*c-r*u*c-i*o*h+n*u*h+r*o*d-n*s*d)+e[7]*(+t*s*d-t*u*h+i*a*h-r*a*d+r*u*l-i*s*l)+e[11]*(+t*u*c-t*o*d-i*a*c+n*a*d+i*o*l-n*u*l)+e[15]*(-r*o*l-t*s*c+t*o*h+r*a*c-n*a*h+n*s*l)}},{key:"transpose",value:function transpose(){var e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}},{key:"setPosition",value:function setPosition(e,t,n){var r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}},{key:"invert",value:function invert(){var e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],l=e[8],c=e[9],h=e[10],d=e[11],f=e[12],p=e[13],m=e[14],v=e[15],g=c*m*u-p*h*u+p*s*d-o*m*d-c*s*v+o*h*v,y=f*h*u-l*m*u-f*s*d+a*m*d+l*s*v-a*h*v,b=l*p*u-f*c*u+f*o*d-a*p*d-l*o*v+a*c*v,x=f*c*s-l*p*s-f*o*h+a*p*h+l*o*m-a*c*m,_=t*g+n*y+r*b+i*x;if(0===_)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var M=1/_;return e[0]=g*M,e[1]=(p*h*i-c*m*i-p*r*d+n*m*d+c*r*v-n*h*v)*M,e[2]=(o*m*i-p*s*i+p*r*u-n*m*u-o*r*v+n*s*v)*M,e[3]=(c*s*i-o*h*i-c*r*u+n*h*u+o*r*d-n*s*d)*M,e[4]=y*M,e[5]=(l*m*i-f*h*i+f*r*d-t*m*d-l*r*v+t*h*v)*M,e[6]=(f*s*i-a*m*i-f*r*u+t*m*u+a*r*v-t*s*v)*M,e[7]=(a*h*i-l*s*i+l*r*u-t*h*u-a*r*d+t*s*d)*M,e[8]=b*M,e[9]=(f*c*i-l*p*i-f*n*d+t*p*d+l*n*v-t*c*v)*M,e[10]=(a*p*i-f*o*i+f*n*u-t*p*u-a*n*v+t*o*v)*M,e[11]=(l*o*i-a*c*i-l*n*u+t*c*u+a*n*d-t*o*d)*M,e[12]=x*M,e[13]=(l*p*r-f*c*r+f*n*h-t*p*h-l*n*m+t*c*m)*M,e[14]=(f*o*r-a*p*r-f*n*s+t*p*s+a*n*m-t*o*m)*M,e[15]=(a*c*r-l*o*r+l*n*s-t*c*s-a*n*h+t*o*h)*M,this}},{key:"scale",value:function scale(e){var t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}},{key:"getMaxScaleOnAxis",value:function getMaxScaleOnAxis(){var e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}},{key:"makeTranslation",value:function makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}},{key:"makeRotationX",value:function makeRotationX(e){var t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}},{key:"makeRotationY",value:function makeRotationY(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}},{key:"makeRotationZ",value:function makeRotationZ(e){var t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}},{key:"makeRotationAxis",value:function makeRotationAxis(e,t){var n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,u=i*a,l=i*o;return this.set(u*a+n,u*o-r*s,u*s+r*o,0,u*o+r*s,l*o+n,l*s-r*a,0,u*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}},{key:"makeScale",value:function makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}},{key:"makeShear",value:function makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}},{key:"compose",value:function compose(e,t,n){var r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,u=i+i,l=a+a,c=o+o,h=i*u,d=i*l,f=i*c,p=a*l,m=a*c,v=o*c,g=s*u,y=s*l,b=s*c,x=n.x,_=n.y,M=n.z;return r[0]=(1-(p+v))*x,r[1]=(d+b)*x,r[2]=(f-y)*x,r[3]=0,r[4]=(d-b)*_,r[5]=(1-(h+v))*_,r[6]=(m+g)*_,r[7]=0,r[8]=(f+y)*M,r[9]=(m-g)*M,r[10]=(1-(h+p))*M,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}},{key:"decompose",value:function decompose(e,t,n){var r=this.elements,i=Dr.set(r[0],r[1],r[2]).length(),a=Dr.set(r[4],r[5],r[6]).length(),o=Dr.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],jr.copy(this);var s=1/i,u=1/a,l=1/o;return jr.elements[0]*=s,jr.elements[1]*=s,jr.elements[2]*=s,jr.elements[4]*=u,jr.elements[5]*=u,jr.elements[6]*=u,jr.elements[8]*=l,jr.elements[9]*=l,jr.elements[10]*=l,t.setFromRotationMatrix(jr),n.x=i,n.y=a,n.z=o,this}},{key:"makePerspective",value:function makePerspective(e,t,n,r,i,a){var o=this.elements,s=2*i/(t-e),u=2*i/(n-r),l=(t+e)/(t-e),c=(n+r)/(n-r),h=-(a+i)/(a-i),d=-2*a*i/(a-i);return o[0]=s,o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=u,o[9]=c,o[13]=0,o[2]=0,o[6]=0,o[10]=h,o[14]=d,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}},{key:"makeOrthographic",value:function makeOrthographic(e,t,n,r,i,a){var o=this.elements,s=1/(t-e),u=1/(n-r),l=1/(a-i),c=(t+e)*s,h=(n+r)*u,d=(a+i)*l;return o[0]=2*s,o[4]=0,o[8]=0,o[12]=-c,o[1]=0,o[5]=2*u,o[9]=0,o[13]=-h,o[2]=0,o[6]=0,o[10]=-2*l,o[14]=-d,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}},{key:"equals",value:function equals(e){for(var t=this.elements,n=e.elements,r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}},{key:"fromArray",value:function fromArray(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0;n<16;n++)this.elements[n]=e[n+t];return this}},{key:"toArray",value:function toArray(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}]),Matrix4}(),Dr=new ir,jr=new Ir,Br=new ir(0,0,0),Nr=new ir(1,1,1),zr=new ir,Fr=new ir,Gr=new ir,Ur=new Ir,Vr=new rr,Wr=function(){function Euler(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Euler.DefaultOrder;Object(f.a)(this,Euler),this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}return Object(p.a)(Euler,[{key:"set",value:function set(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this._order;return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}},{key:"clone",value:function clone(){return new this.constructor(this._x,this._y,this._z,this._order)}},{key:"copy",value:function copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}},{key:"setFromRotationMatrix",value:function setFromRotationMatrix(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._order,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],u=r[5],l=r[9],c=r[2],h=r[6],d=r[10];switch(t){case"XYZ":this._y=Math.asin(clamp(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(h,u),this._z=0);break;case"YXZ":this._x=Math.asin(-clamp(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(s,u)):(this._y=Math.atan2(-c,i),this._z=0);break;case"ZXY":this._x=Math.asin(clamp(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,u)):(this._y=0,this._z=Math.atan2(s,i));break;case"ZYX":this._y=Math.asin(-clamp(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(h,d),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,u));break;case"YZX":this._z=Math.asin(clamp(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,u),this._y=Math.atan2(-c,i)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-clamp(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(h,u),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}},{key:"setFromQuaternion",value:function setFromQuaternion(e,t,n){return Ur.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ur,t,n)}},{key:"setFromVector3",value:function setFromVector3(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._order;return this.set(e.x,e.y,e.z,t)}},{key:"reorder",value:function reorder(e){return Vr.setFromEuler(this),this.setFromQuaternion(Vr,e)}},{key:"equals",value:function equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}},{key:"fromArray",value:function fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}},{key:"toArray",value:function toArray(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}},{key:"_onChange",value:function _onChange(e){return this._onChangeCallback=e,this}},{key:"_onChangeCallback",value:function _onChangeCallback(){}},{key:Symbol.iterator,value:d.a.mark(function value(){return d.a.wrap(function value$(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._x;case 2:return e.next=4,this._y;case 4:return e.next=6,this._z;case 6:return e.next=8,this._order;case 8:case"end":return e.stop()}},value,this)})},{key:"toVector3",value:function toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}},{key:"x",get:function get(){return this._x},set:function set(e){this._x=e,this._onChangeCallback()}},{key:"y",get:function get(){return this._y},set:function set(e){this._y=e,this._onChangeCallback()}},{key:"z",get:function get(){return this._z},set:function set(e){this._z=e,this._onChangeCallback()}},{key:"order",get:function get(){return this._order},set:function set(e){this._order=e,this._onChangeCallback()}}]),Euler}();Wr.DefaultOrder="XYZ",Wr.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];var Hr=function(){function Layers(){Object(f.a)(this,Layers),this.mask=1}return Object(p.a)(Layers,[{key:"set",value:function set(e){this.mask=(1<>>0}},{key:"enable",value:function enable(e){this.mask|=1<1){for(var t=0;t1){for(var t=0;t0){r.children=[];for(var d=0;d0){r.animations=[];for(var f=0;f0&&(n.geometries=m),v.length>0&&(n.materials=v),g.length>0&&(n.textures=g),y.length>0&&(n.images=y),b.length>0&&(n.shapes=b),x.length>0&&(n.skeletons=x),_.length>0&&(n.animations=_),M.length>0&&(n.nodes=M)}return n.object=r,n;function extractFromCache(e){var t=[];for(var n in e){var r=e[n];delete r.metadata,t.push(r)}return t}}},{key:"clone",value:function clone(e){return(new this.constructor).copy(this,e)}},{key:"copy",value:function copy(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:new ir,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ir;Object(f.a)(this,Triangle),this.a=e,this.b=t,this.c=n}return Object(p.a)(Triangle,[{key:"set",value:function set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}},{key:"setFromPointsAndIndices",value:function setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}},{key:"setFromAttributeAndIndices",value:function setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}},{key:"copy",value:function copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}},{key:"getArea",value:function getArea(){return oi.subVectors(this.c,this.b),si.subVectors(this.a,this.b),.5*oi.cross(si).length()}},{key:"getMidpoint",value:function getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}},{key:"getNormal",value:function getNormal(e){return Triangle.getNormal(this.a,this.b,this.c,e)}},{key:"getPlane",value:function getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}},{key:"getBarycoord",value:function getBarycoord(e,t){return Triangle.getBarycoord(e,this.a,this.b,this.c,t)}},{key:"getUV",value:function getUV(e,t,n,r,i){return Triangle.getUV(e,this.a,this.b,this.c,t,n,r,i)}},{key:"containsPoint",value:function containsPoint(e){return Triangle.containsPoint(e,this.a,this.b,this.c)}},{key:"isFrontFacing",value:function isFrontFacing(e){return Triangle.isFrontFacing(this.a,this.b,this.c,e)}},{key:"intersectsBox",value:function intersectsBox(e){return e.intersectsTriangle(this)}},{key:"closestPointToPoint",value:function closestPointToPoint(e,t){var n,r,i=this.a,a=this.b,o=this.c;ci.subVectors(a,i),hi.subVectors(o,i),fi.subVectors(e,i);var s=ci.dot(fi),u=hi.dot(fi);if(s<=0&&u<=0)return t.copy(i);pi.subVectors(e,a);var l=ci.dot(pi),c=hi.dot(pi);if(l>=0&&c<=l)return t.copy(a);var h=s*c-l*u;if(h<=0&&s>=0&&l<=0)return n=s/(s-l),t.copy(i).addScaledVector(ci,n);mi.subVectors(e,o);var d=ci.dot(mi),f=hi.dot(mi);if(f>=0&&d<=f)return t.copy(o);var p=d*u-s*f;if(p<=0&&u>=0&&f<=0)return r=u/(u-f),t.copy(i).addScaledVector(hi,r);var m=l*f-d*c;if(m<=0&&c-l>=0&&d-f>=0)return di.subVectors(o,a),r=(c-l)/(c-l+(d-f)),t.copy(a).addScaledVector(di,r);var v=1/(m+p+h);return n=p*v,r=h*v,t.copy(i).addScaledVector(ci,n).addScaledVector(hi,r)}},{key:"equals",value:function equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}],[{key:"getNormal",value:function getNormal(e,t,n,r){r.subVectors(n,t),oi.subVectors(e,t),r.cross(oi);var i=r.lengthSq();return i>0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}},{key:"getBarycoord",value:function getBarycoord(e,t,n,r,i){oi.subVectors(r,t),si.subVectors(n,t),ui.subVectors(e,t);var a=oi.dot(oi),o=oi.dot(si),s=oi.dot(ui),u=si.dot(si),l=si.dot(ui),c=a*u-o*o;if(0===c)return i.set(-2,-1,-1);var h=1/c,d=(u*s-o*l)*h,f=(a*l-o*s)*h;return i.set(1-d-f,f,d)}},{key:"containsPoint",value:function containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,li),li.x>=0&&li.y>=0&&li.x+li.y<=1}},{key:"getUV",value:function getUV(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,li),s.set(0,0),s.addScaledVector(i,li.x),s.addScaledVector(a,li.y),s.addScaledVector(o,li.z),s}},{key:"isFrontFacing",value:function isFrontFacing(e,t,n,r){return oi.subVectors(n,t),si.subVectors(e,t),oi.cross(si).dot(r)<0}}]),Triangle}(),gi=0,yi=function(e){function Material(){var e;return Object(f.a)(this,Material),(e=Object(s.a)(this,Object(r.a)(Material).call(this))).isMaterial=!0,Object.defineProperty(Object(l.a)(Object(l.a)(e)),"id",{value:gi++}),e.uuid=generateUUID(),e.name="",e.type="Material",e.blending=R,e.side=O,e.vertexColors=!1,e.opacity=1,e.transparent=!1,e.blendSrc=X,e.blendDst=J,e.blendEquation=N,e.blendSrcAlpha=null,e.blendDstAlpha=null,e.blendEquationAlpha=null,e.depthFunc=re,e.depthTest=!0,e.depthWrite=!0,e.stencilWriteMask=255,e.stencilFunc=vn,e.stencilRef=0,e.stencilFuncMask=255,e.stencilFail=tn,e.stencilZFail=tn,e.stencilZPass=tn,e.stencilWrite=!1,e.clippingPlanes=null,e.clipIntersection=!1,e.clipShadows=!1,e.shadowSide=null,e.colorWrite=!0,e.precision=null,e.polygonOffset=!1,e.polygonOffsetFactor=0,e.polygonOffsetUnits=0,e.dithering=!1,e.alphaToCoverage=!1,e.premultipliedAlpha=!1,e.visible=!0,e.toneMapped=!0,e.userData={},e.version=0,e._alphaTest=0,e}return Object(u.a)(Material,e),Object(p.a)(Material,[{key:"onBuild",value:function onBuild(){}},{key:"onBeforeRender",value:function onBeforeRender(){}},{key:"onBeforeCompile",value:function onBeforeCompile(){}},{key:"customProgramCacheKey",value:function customProgramCacheKey(){return this.onBeforeCompile.toString()}},{key:"setValues",value:function setValues(e){if(void 0!==e)for(var t in e){var n=e[t];if(void 0!==n)if("shading"!==t){var r=this[t];void 0!==r?r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n:console.warn("THREE."+this.type+": '"+t+"' is not a property of this material.")}else console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=n===k;else console.warn("THREE.Material: '"+t+"' parameter is undefined.")}}},{key:"toJSON",value:function toJSON(e){var t=void 0===e||"string"===typeof e;t&&(e={textures:{},images:{}});var n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function extractFromCache(e){var t=[];for(var n in e){var r=e[n];delete r.metadata,t.push(r)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==R&&(n.blending=this.blending),this.side!==O&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){var r=extractFromCache(e.textures),i=extractFromCache(e.images);r.length>0&&(n.textures=r),i.length>0&&(n.images=i)}return n}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}},{key:"copy",value:function copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;var t=e.clippingPlanes,n=null;if(null!==t){var r=t.length;n=new Array(r);for(var i=0;i!==r;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}},{key:"dispose",value:function dispose(){this.dispatchEvent({type:"dispose"})}},{key:"alphaTest",get:function get(){return this._alphaTest},set:function set(e){this._alphaTest>0!==e>0&&this.version++,this._alphaTest=e}},{key:"needsUpdate",set:function set(e){!0===e&&this.version++}}]),Material}(Ln),bi=function(e){function MeshBasicMaterial(e){var t;return Object(f.a)(this,MeshBasicMaterial),(t=Object(s.a)(this,Object(r.a)(MeshBasicMaterial).call(this))).isMeshBasicMaterial=!0,t.type="MeshBasicMaterial",t.color=new Hn(16777215),t.map=null,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=null,t.aoMapIntensity=1,t.specularMap=null,t.alphaMap=null,t.envMap=null,t.combine=ue,t.reflectivity=1,t.refractionRatio=.98,t.wireframe=!1,t.wireframeLinewidth=1,t.wireframeLinecap="round",t.wireframeLinejoin="round",t.fog=!0,t.setValues(e),t}return Object(u.a)(MeshBasicMaterial,e),Object(p.a)(MeshBasicMaterial,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(MeshBasicMaterial.prototype),"copy",this).call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}]),MeshBasicMaterial}(yi),xi=new ir,_i=new Dn,Mi=function(){function BufferAttribute(e,t,n){if(Object(f.a)(this,BufferAttribute),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.usage=gn,this.updateRange={offset:0,count:-1},this.version=0}return Object(p.a)(BufferAttribute,[{key:"onUploadCallback",value:function onUploadCallback(){}},{key:"setUsage",value:function setUsage(e){return this.usage=e,this}},{key:"copy",value:function copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}},{key:"copyAt",value:function copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(var r=0,i=this.itemSize;r1&&void 0!==arguments[1]?arguments[1]:0;return this.array.set(e,t),this}},{key:"getX",value:function getX(e){return this.array[e*this.itemSize]}},{key:"setX",value:function setX(e,t){return this.array[e*this.itemSize]=t,this}},{key:"getY",value:function getY(e){return this.array[e*this.itemSize+1]}},{key:"setY",value:function setY(e,t){return this.array[e*this.itemSize+1]=t,this}},{key:"getZ",value:function getZ(e){return this.array[e*this.itemSize+2]}},{key:"setZ",value:function setZ(e,t){return this.array[e*this.itemSize+2]=t,this}},{key:"getW",value:function getW(e){return this.array[e*this.itemSize+3]}},{key:"setW",value:function setW(e,t){return this.array[e*this.itemSize+3]=t,this}},{key:"setXY",value:function setXY(e,t,n){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this}},{key:"setXYZ",value:function setXYZ(e,t,n,r){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}},{key:"setXYZW",value:function setXYZW(e,t,n,r,i){return e*=this.itemSize,this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=i,this}},{key:"onUpload",value:function onUpload(e){return this.onUploadCallback=e,this}},{key:"clone",value:function clone(){return new this.constructor(this.array,this.itemSize).copy(this)}},{key:"toJSON",value:function toJSON(){var e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==gn&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}},{key:"needsUpdate",set:function set(e){!0===e&&this.version++}}]),BufferAttribute}(),Si=function(e){function Int8BufferAttribute(e,t,n){return Object(f.a)(this,Int8BufferAttribute),Object(s.a)(this,Object(r.a)(Int8BufferAttribute).call(this,new Int8Array(e),t,n))}return Object(u.a)(Int8BufferAttribute,e),Int8BufferAttribute}(Mi),wi=function(e){function Uint8BufferAttribute(e,t,n){return Object(f.a)(this,Uint8BufferAttribute),Object(s.a)(this,Object(r.a)(Uint8BufferAttribute).call(this,new Uint8Array(e),t,n))}return Object(u.a)(Uint8BufferAttribute,e),Uint8BufferAttribute}(Mi),Ti=function(e){function Uint8ClampedBufferAttribute(e,t,n){return Object(f.a)(this,Uint8ClampedBufferAttribute),Object(s.a)(this,Object(r.a)(Uint8ClampedBufferAttribute).call(this,new Uint8ClampedArray(e),t,n))}return Object(u.a)(Uint8ClampedBufferAttribute,e),Uint8ClampedBufferAttribute}(Mi),Ai=function(e){function Int16BufferAttribute(e,t,n){return Object(f.a)(this,Int16BufferAttribute),Object(s.a)(this,Object(r.a)(Int16BufferAttribute).call(this,new Int16Array(e),t,n))}return Object(u.a)(Int16BufferAttribute,e),Int16BufferAttribute}(Mi),Oi=function(e){function Uint16BufferAttribute(e,t,n){return Object(f.a)(this,Uint16BufferAttribute),Object(s.a)(this,Object(r.a)(Uint16BufferAttribute).call(this,new Uint16Array(e),t,n))}return Object(u.a)(Uint16BufferAttribute,e),Uint16BufferAttribute}(Mi),Ci=function(e){function Int32BufferAttribute(e,t,n){return Object(f.a)(this,Int32BufferAttribute),Object(s.a)(this,Object(r.a)(Int32BufferAttribute).call(this,new Int32Array(e),t,n))}return Object(u.a)(Int32BufferAttribute,e),Int32BufferAttribute}(Mi),Li=function(e){function Uint32BufferAttribute(e,t,n){return Object(f.a)(this,Uint32BufferAttribute),Object(s.a)(this,Object(r.a)(Uint32BufferAttribute).call(this,new Uint32Array(e),t,n))}return Object(u.a)(Uint32BufferAttribute,e),Uint32BufferAttribute}(Mi),ki=function(e){function Float16BufferAttribute(e,t,n){var i;return Object(f.a)(this,Float16BufferAttribute),(i=Object(s.a)(this,Object(r.a)(Float16BufferAttribute).call(this,new Uint16Array(e),t,n))).isFloat16BufferAttribute=!0,i}return Object(u.a)(Float16BufferAttribute,e),Float16BufferAttribute}(Mi),Ei=function(e){function Float32BufferAttribute(e,t,n){return Object(f.a)(this,Float32BufferAttribute),Object(s.a)(this,Object(r.a)(Float32BufferAttribute).call(this,new Float32Array(e),t,n))}return Object(u.a)(Float32BufferAttribute,e),Float32BufferAttribute}(Mi),Pi=function(e){function Float64BufferAttribute(e,t,n){return Object(f.a)(this,Float64BufferAttribute),Object(s.a)(this,Object(r.a)(Float64BufferAttribute).call(this,new Float64Array(e),t,n))}return Object(u.a)(Float64BufferAttribute,e),Float64BufferAttribute}(Mi),Ri=0,Ii=new Ir,Di=new ai,ji=new ir,Bi=new sr,Ni=new sr,zi=new ir,Fi=function(e){function BufferGeometry(){var e;return Object(f.a)(this,BufferGeometry),(e=Object(s.a)(this,Object(r.a)(BufferGeometry).call(this))).isBufferGeometry=!0,Object.defineProperty(Object(l.a)(Object(l.a)(e)),"id",{value:Ri++}),e.uuid=generateUUID(),e.name="",e.type="BufferGeometry",e.index=null,e.attributes={},e.morphAttributes={},e.morphTargetsRelative=!1,e.groups=[],e.boundingBox=null,e.boundingSphere=null,e.drawRange={start:0,count:1/0},e.userData={},e}return Object(u.a)(BufferGeometry,e),Object(p.a)(BufferGeometry,[{key:"getIndex",value:function getIndex(){return this.index}},{key:"setIndex",value:function setIndex(e){return Array.isArray(e)?this.index=new(arrayNeedsUint32(e)?Li:Oi)(e,1):this.index=e,this}},{key:"getAttribute",value:function getAttribute(e){return this.attributes[e]}},{key:"setAttribute",value:function setAttribute(e,t){return this.attributes[e]=t,this}},{key:"deleteAttribute",value:function deleteAttribute(e){return delete this.attributes[e],this}},{key:"hasAttribute",value:function hasAttribute(e){return void 0!==this.attributes[e]}},{key:"addGroup",value:function addGroup(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.groups.push({start:e,count:t,materialIndex:n})}},{key:"clearGroups",value:function clearGroups(){this.groups=[]}},{key:"setDrawRange",value:function setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}},{key:"applyMatrix4",value:function applyMatrix4(e){var t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);var n=this.attributes.normal;if(void 0!==n){var r=(new jn).getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}var i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}},{key:"applyQuaternion",value:function applyQuaternion(e){return Ii.makeRotationFromQuaternion(e),this.applyMatrix4(Ii),this}},{key:"rotateX",value:function rotateX(e){return Ii.makeRotationX(e),this.applyMatrix4(Ii),this}},{key:"rotateY",value:function rotateY(e){return Ii.makeRotationY(e),this.applyMatrix4(Ii),this}},{key:"rotateZ",value:function rotateZ(e){return Ii.makeRotationZ(e),this.applyMatrix4(Ii),this}},{key:"translate",value:function translate(e,t,n){return Ii.makeTranslation(e,t,n),this.applyMatrix4(Ii),this}},{key:"scale",value:function scale(e,t,n){return Ii.makeScale(e,t,n),this.applyMatrix4(Ii),this}},{key:"lookAt",value:function lookAt(e){return Di.lookAt(e),Di.updateMatrix(),this.applyMatrix4(Di.matrix),this}},{key:"center",value:function center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ji).negate(),this.translate(ji.x,ji.y,ji.z),this}},{key:"setFromPoints",value:function setFromPoints(e){for(var t=[],n=0,r=e.length;n0&&(e.userData=this.userData),void 0!==this.parameters){var t=this.parameters;for(var n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};var r=this.index;null!==r&&(e.data.index={type:r.array.constructor.name,array:Array.prototype.slice.call(r.array)});var i=this.attributes;for(var a in i){var o=i[a];e.data.attributes[a]=o.toJSON(e.data)}var s={},u=!1;for(var l in this.morphAttributes){for(var c=this.morphAttributes[l],h=[],d=0,f=c.length;d0&&(s[l]=h,u=!0)}u&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);var m=this.groups;m.length>0&&(e.data.groups=JSON.parse(JSON.stringify(m)));var v=this.boundingSphere;return null!==v&&(e.data.boundingSphere={center:v.center.toArray(),radius:v.radius}),e}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}},{key:"copy",value:function copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;var t={};this.name=e.name;var n=e.index;null!==n&&this.setIndex(n.clone(t));var r=e.attributes;for(var i in r){var a=r[i];this.setAttribute(i,a.clone(t))}var o=e.morphAttributes;for(var s in o){for(var u=[],l=o[s],c=0,h=l.length;c0&&void 0!==arguments[0]?arguments[0]:new Fi,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new bi;return Object(f.a)(this,Mesh),(e=Object(s.a)(this,Object(r.a)(Mesh).call(this))).isMesh=!0,e.type="Mesh",e.geometry=t,e.material=n,e.updateMorphTargets(),e}return Object(u.a)(Mesh,e),Object(p.a)(Mesh,[{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(Mesh.prototype),"copy",this).call(this,e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}},{key:"updateMorphTargets",value:function updateMorphTargets(){var e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){var n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var r=0,i=n.length;rn.far?null:{distance:u,point:ra.clone(),object:e}}(e,t,n,r,Wi,Hi,qi,na);if(g){s&&($i.fromBufferAttribute(s,l),ea.fromBufferAttribute(s,c),ta.fromBufferAttribute(s,h),g.uv=vi.getUV(na,Wi,Hi,qi,$i,ea,ta,new Dn)),u&&($i.fromBufferAttribute(u,l),ea.fromBufferAttribute(u,c),ta.fromBufferAttribute(u,h),g.uv2=vi.getUV(na,Wi,Hi,qi,$i,ea,ta,new Dn));var y={a:l,b:c,c:h,normal:new ir,materialIndex:0};vi.getNormal(Wi,Hi,qi,y.normal),g.face=y}return g}var aa=function(e){function BoxGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1;Object(f.a)(this,BoxGeometry),(e=Object(s.a)(this,Object(r.a)(BoxGeometry).call(this))).type="BoxGeometry",e.parameters={width:t,height:n,depth:i,widthSegments:a,heightSegments:o,depthSegments:u};var c=Object(l.a)(Object(l.a)(e));a=Math.floor(a),o=Math.floor(o),u=Math.floor(u);var h=[],d=[],p=[],m=[],v=0,g=0;function buildPlane(e,t,n,r,i,a,o,s,u,l,f){for(var y=a/u,b=o/l,x=a/2,_=o/2,M=s/2,S=u+1,w=l+1,T=0,A=0,O=new ir,C=0;C0?1:-1,p.push(O.x,O.y,O.z),m.push(k/u),m.push(1-C/l),T+=1}for(var P=0;P0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;var a={};for(var s in this.extensions)!0===this.extensions[s]&&(a[s]=!0);return Object.keys(a).length>0&&(t.extensions=a),t}}]),ShaderMaterial}(yi),ca=function(e){function Camera(){var e;return Object(f.a)(this,Camera),(e=Object(s.a)(this,Object(r.a)(Camera).call(this))).isCamera=!0,e.type="Camera",e.matrixWorldInverse=new Ir,e.projectionMatrix=new Ir,e.projectionMatrixInverse=new Ir,e}return Object(u.a)(Camera,e),Object(p.a)(Camera,[{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(Camera.prototype),"copy",this).call(this,e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}},{key:"getWorldDirection",value:function getWorldDirection(e){this.updateWorldMatrix(!0,!1);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}},{key:"updateMatrixWorld",value:function updateMatrixWorld(e){Object(o.a)(Object(r.a)(Camera.prototype),"updateMatrixWorld",this).call(this,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}},{key:"updateWorldMatrix",value:function updateWorldMatrix(e,t){Object(o.a)(Object(r.a)(Camera.prototype),"updateWorldMatrix",this).call(this,e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}}]),Camera}(ai),ha=function(e){function PerspectiveCamera(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:50,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2e3;return Object(f.a)(this,PerspectiveCamera),(e=Object(s.a)(this,Object(r.a)(PerspectiveCamera).call(this))).isPerspectiveCamera=!0,e.type="PerspectiveCamera",e.fov=t,e.zoom=1,e.near=i,e.far=a,e.focus=10,e.aspect=n,e.view=null,e.filmGauge=35,e.filmOffset=0,e.updateProjectionMatrix(),e}return Object(u.a)(PerspectiveCamera,e),Object(p.a)(PerspectiveCamera,[{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(PerspectiveCamera.prototype),"copy",this).call(this,e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}},{key:"setFocalLength",value:function setFocalLength(e){var t=.5*this.getFilmHeight()/e;this.fov=2*Rn*Math.atan(t),this.updateProjectionMatrix()}},{key:"getFocalLength",value:function getFocalLength(){var e=Math.tan(.5*Pn*this.fov);return.5*this.getFilmHeight()/e}},{key:"getEffectiveFOV",value:function getEffectiveFOV(){return 2*Rn*Math.atan(Math.tan(.5*Pn*this.fov)/this.zoom)}},{key:"getFilmWidth",value:function getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}},{key:"getFilmHeight",value:function getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}},{key:"setViewOffset",value:function setViewOffset(e,t,n,r,i,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}},{key:"clearViewOffset",value:function clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}},{key:"updateProjectionMatrix",value:function updateProjectionMatrix(){var e=this.near,t=e*Math.tan(.5*Pn*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(null!==this.view&&this.view.enabled){var o=a.fullWidth,s=a.fullHeight;i+=a.offsetX*r/o,t-=a.offsetY*n/s,r*=a.width/o,n*=a.height/s}var u=this.filmOffset;0!==u&&(i+=e*u/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}},{key:"toJSON",value:function toJSON(e){var t=Object(o.a)(Object(r.a)(PerspectiveCamera.prototype),"toJSON",this).call(this,e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}]),PerspectiveCamera}(ca),da=90,fa=1,pa=function(e){function CubeCamera(e,t,n){var i;if(Object(f.a)(this,CubeCamera),(i=Object(s.a)(this,Object(r.a)(CubeCamera).call(this))).type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter."),Object(s.a)(i);i.renderTarget=n;var a=new ha(da,fa,e,t);a.layers=i.layers,a.up.set(0,-1,0),a.lookAt(new ir(1,0,0)),i.add(a);var o=new ha(da,fa,e,t);o.layers=i.layers,o.up.set(0,-1,0),o.lookAt(new ir(-1,0,0)),i.add(o);var u=new ha(da,fa,e,t);u.layers=i.layers,u.up.set(0,0,1),u.lookAt(new ir(0,1,0)),i.add(u);var l=new ha(da,fa,e,t);l.layers=i.layers,l.up.set(0,0,-1),l.lookAt(new ir(0,-1,0)),i.add(l);var c=new ha(da,fa,e,t);c.layers=i.layers,c.up.set(0,-1,0),c.lookAt(new ir(0,0,1)),i.add(c);var h=new ha(da,fa,e,t);return h.layers=i.layers,h.up.set(0,-1,0),h.lookAt(new ir(0,0,-1)),i.add(h),i}return Object(u.a)(CubeCamera,e),Object(p.a)(CubeCamera,[{key:"update",value:function update(e,t){null===this.parent&&this.updateMatrixWorld();var n=this.renderTarget,r=Object(a.a)(this.children,6),i=r[0],o=r[1],s=r[2],u=r[3],l=r[4],c=r[5],h=e.getRenderTarget(),d=e.toneMapping,f=e.xr.enabled;e.toneMapping=he,e.xr.enabled=!1;var p=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,o),e.setRenderTarget(n,2),e.render(t,s),e.setRenderTarget(n,3),e.render(t,u),e.setRenderTarget(n,4),e.render(t,l),n.texture.generateMipmaps=p,e.setRenderTarget(n,5),e.render(t,c),e.setRenderTarget(h),e.toneMapping=d,e.xr.enabled=f,n.texture.needsPMREMUpdate=!0}}]),CubeCamera}(ai),ma=function(e){function CubeTexture(e,t,n,i,a,o,u,l,c,h){var d;return Object(f.a)(this,CubeTexture),e=void 0!==e?e:[],t=void 0!==t?t:ye,(d=Object(s.a)(this,Object(r.a)(CubeTexture).call(this,e,t,n,i,a,o,u,l,c,h))).isCubeTexture=!0,d.flipY=!1,d}return Object(u.a)(CubeTexture,e),Object(p.a)(CubeTexture,[{key:"images",get:function get(){return this.image},set:function set(e){this.image=e}}]),CubeTexture}(Yn),va=function(e){function WebGLCubeRenderTarget(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(f.a)(this,WebGLCubeRenderTarget),(t=Object(s.a)(this,Object(r.a)(WebGLCubeRenderTarget).call(this,e,e,n))).isWebGLCubeRenderTarget=!0;var i={width:e,height:e,depth:1},a=[i,i,i,i,i,i];return t.texture=new ma(a,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),t.texture.isRenderTargetTexture=!0,t.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,t.texture.minFilter=void 0!==n.minFilter?n.minFilter:Ee,t}return Object(u.a)(WebGLCubeRenderTarget,e),Object(p.a)(WebGLCubeRenderTarget,[{key:"fromEquirectangularTexture",value:function fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;var n={tEquirect:{value:null}},r="\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",i="\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t",a=new aa(5,5,5),o=new la({name:"CubemapFromEquirect",uniforms:cloneUniforms(n),vertexShader:r,fragmentShader:i,side:C,blending:P});o.uniforms.tEquirect.value=t;var s=new ia(a,o),u=t.minFilter;return t.minFilter===Ie&&(t.minFilter=Ee),new pa(1,10,this).update(e,s),t.minFilter=u,s.geometry.dispose(),s.material.dispose(),this}},{key:"clear",value:function clear(e,t,n,r){for(var i=e.getRenderTarget(),a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(i)}}]),WebGLCubeRenderTarget}(Kn),ga=new ir,ya=new ir,ba=new jn,xa=function(){function Plane(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir(1,0,0),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Object(f.a)(this,Plane),this.isPlane=!0,this.normal=e,this.constant=t}return Object(p.a)(Plane,[{key:"set",value:function set(e,t){return this.normal.copy(e),this.constant=t,this}},{key:"setComponents",value:function setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}},{key:"setFromNormalAndCoplanarPoint",value:function setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}},{key:"setFromCoplanarPoints",value:function setFromCoplanarPoints(e,t,n){var r=ga.subVectors(n,t).cross(ya.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}},{key:"copy",value:function copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}},{key:"normalize",value:function normalize(){var e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}},{key:"negate",value:function negate(){return this.constant*=-1,this.normal.negate(),this}},{key:"distanceToPoint",value:function distanceToPoint(e){return this.normal.dot(e)+this.constant}},{key:"distanceToSphere",value:function distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}},{key:"projectPoint",value:function projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}},{key:"intersectLine",value:function intersectLine(e,t){var n=e.delta(ga),r=this.normal.dot(n);if(0===r)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;var i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(n).multiplyScalar(i).add(e.start)}},{key:"intersectsLine",value:function intersectsLine(e){var t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}},{key:"intersectsBox",value:function intersectsBox(e){return e.intersectsPlane(this)}},{key:"intersectsSphere",value:function intersectsSphere(e){return e.intersectsPlane(this)}},{key:"coplanarPoint",value:function coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}},{key:"applyMatrix4",value:function applyMatrix4(e,t){var n=t||ba.getNormalMatrix(e),r=this.coplanarPoint(ga).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}},{key:"translate",value:function translate(e){return this.constant-=e.dot(this.normal),this}},{key:"equals",value:function equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}}]),Plane}(),_a=new Tr,Ma=new ir,Sa=function(){function Frustum(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new xa,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new xa,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new xa,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new xa,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:new xa,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:new xa;Object(f.a)(this,Frustum),this.planes=[e,t,n,r,i,a]}return Object(p.a)(Frustum,[{key:"set",value:function set(e,t,n,r,i,a){var o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}},{key:"copy",value:function copy(e){for(var t=this.planes,n=0;n<6;n++)t[n].copy(e.planes[n]);return this}},{key:"setFromProjectionMatrix",value:function setFromProjectionMatrix(e){var t=this.planes,n=e.elements,r=n[0],i=n[1],a=n[2],o=n[3],s=n[4],u=n[5],l=n[6],c=n[7],h=n[8],d=n[9],f=n[10],p=n[11],m=n[12],v=n[13],g=n[14],y=n[15];return t[0].setComponents(o-r,c-s,p-h,y-m).normalize(),t[1].setComponents(o+r,c+s,p+h,y+m).normalize(),t[2].setComponents(o+i,c+u,p+d,y+v).normalize(),t[3].setComponents(o-i,c-u,p-d,y-v).normalize(),t[4].setComponents(o-a,c-l,p-f,y-g).normalize(),t[5].setComponents(o+a,c+l,p+f,y+g).normalize(),this}},{key:"intersectsObject",value:function intersectsObject(e){var t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),_a.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(_a)}},{key:"intersectsSprite",value:function intersectsSprite(e){return _a.center.set(0,0,0),_a.radius=.7071067811865476,_a.applyMatrix4(e.matrixWorld),this.intersectsSphere(_a)}},{key:"intersectsSphere",value:function intersectsSphere(e){for(var t=this.planes,n=e.center,r=-e.radius,i=0;i<6;i++){if(t[i].distanceToPoint(n)0?e.max.x:e.min.x,Ma.y=r.normal.y>0?e.max.y:e.min.y,Ma.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Ma)<0)return!1}return!0}},{key:"containsPoint",value:function containsPoint(e){for(var t=this.planes,n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}}]),Frustum}();function WebGLAnimation(){var e=null,t=!1,n=null,r=null;function onAnimationFrame(t,i){n(t,i),r=e.requestAnimationFrame(onAnimationFrame)}return{start:function start(){!0!==t&&null!==n&&(r=e.requestAnimationFrame(onAnimationFrame),t=!0)},stop:function stop(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function setAnimationLoop(e){n=e},setContext:function setContext(t){e=t}}}function WebGLAttributes(e,t){var n=t.isWebGL2,r=new WeakMap;return{get:function get(e){return e.isInterleavedBufferAttribute&&(e=e.data),r.get(e)},remove:function remove(t){t.isInterleavedBufferAttribute&&(t=t.data);var n=r.get(t);n&&(e.deleteBuffer(n.buffer),r.delete(t))},update:function update(t,i){if(t.isGLBufferAttribute){var a=r.get(t);(!a||a.version0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;Object(f.a)(this,PlaneGeometry),(e=Object(s.a)(this,Object(r.a)(PlaneGeometry).call(this))).type="PlaneGeometry",e.parameters={width:t,height:n,widthSegments:i,heightSegments:a};for(var o=t/2,u=n/2,l=Math.floor(i),c=Math.floor(a),h=l+1,d=c+1,p=t/l,m=n/c,v=[],g=[],y=[],b=[],x=0;x 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, 1.0, dotVH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n\tconst mat3 XYZ_TO_REC709 = mat3(\n\t\t 3.2404542, -0.9692660, 0.0556434,\n\t\t-1.5371385, 1.8760108, -0.2040259,\n\t\t-0.4985314, 0.0415560, 1.0572252\n\t);\n\tvec3 Fresnel0ToIor( vec3 fresnel0 ) {\n\t\tvec3 sqrtF0 = sqrt( fresnel0 );\n\t\treturn ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\t}\n\tvec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n\t}\n\tfloat IorToFresnel0( float transmittedIor, float incidentIor ) {\n\t\treturn pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n\t}\n\tvec3 evalSensitivity( float OPD, vec3 shift ) {\n\t\tfloat phase = 2.0 * PI * OPD * 1.0e-9;\n\t\tvec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n\t\tvec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n\t\tvec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n\t\tvec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n\t\txyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n\t\txyz /= 1.0685e-7;\n\t\tvec3 rgb = XYZ_TO_REC709 * xyz;\n\t\treturn rgb;\n\t}\n\tvec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n\t\tvec3 I;\n\t\tfloat iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n\t\tfloat sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n\t\tfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\n\t\tif ( cosTheta2Sq < 0.0 ) {\n\t\t\t return vec3( 1.0 );\n\t\t}\n\t\tfloat cosTheta2 = sqrt( cosTheta2Sq );\n\t\tfloat R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n\t\tfloat R12 = F_Schlick( R0, 1.0, cosTheta1 );\n\t\tfloat R21 = R12;\n\t\tfloat T121 = 1.0 - R12;\n\t\tfloat phi12 = 0.0;\n\t\tif ( iridescenceIOR < outsideIOR ) phi12 = PI;\n\t\tfloat phi21 = PI - phi12;\n\t\tvec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );\t\tvec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n\t\tvec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n\t\tvec3 phi23 = vec3( 0.0 );\n\t\tif ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n\t\tif ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n\t\tif ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n\t\tfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n\t\tvec3 phi = vec3( phi21 ) + phi23;\n\t\tvec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n\t\tvec3 r123 = sqrt( R123 );\n\t\tvec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n\t\tvec3 C0 = R12 + Rs;\n\t\tI = C0;\n\t\tvec3 Cm = Rs - T121;\n\t\tfor ( int m = 1; m <= 2; ++ m ) {\n\t\t\tCm *= r123;\n\t\t\tvec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n\t\t\tI += Cm * Sm;\n\t\t}\n\t\treturn max( I, vec3( 0.0 ) );\n\t}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos.xyz );\n\t\tvec3 vSigmaY = dFdy( surf_pos.xyz );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 ) * faceDirection;\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\tvec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define r0 1.0\n\t#define v0 0.339\n\t#define m0 - 2.0\n\t#define r1 0.8\n\t#define v1 0.276\n\t#define m1 - 1.0\n\t#define r4 0.4\n\t#define v4 0.046\n\t#define m4 2.0\n\t#define r5 0.305\n\t#define v5 0.016\n\t#define m5 3.0\n\t#define r6 0.21\n\t#define v6 0.0038\n\t#define m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= r1 ) {\n\t\t\tmip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;\n\t\t} else if ( roughness >= r4 ) {\n\t\t\tmip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;\n\t\t} else if ( roughness >= r5 ) {\n\t\t\tmip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;\n\t\t} else if ( roughness >= r6 ) {\n\t\t\tmip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#if defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );\n#ifdef DOUBLE_SIDED\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );\n#endif\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointLightInfo( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotLightInfo( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalLightInfo( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( - dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#else\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD( material )\t(0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\t#ifdef SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULARINTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;\n\t\t#endif\n\t\t#ifdef USE_SPECULARCOLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vUv ).rgb;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;\n\t#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );\n\t#else\n\t\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if 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\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tvec4 sampledDiffuseColor = texture2D( map, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tsampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );\n\t#endif\n\tdiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\tuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = 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#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * faceDirection;\n\t\t\tbitangent = bitangent * faceDirection;\n\t\t#endif\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\t#ifdef USE_TANGENT\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );\n\t\treturn normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\t#ifdef USE_TANGENT\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );\n\t#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\t#endif\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tfloat transmissionAlpha = 1.0;\n\tfloat transmissionFactor = transmission;\n\tfloat thicknessFactor = thickness;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\ttransmissionFactor *= texture2D( transmissionMap, vUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tthicknessFactor *= texture2D( thicknessMap, vUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmission = getIBLVolumeRefraction(\n\t\tn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\n\t\tattenuationColor, attenuationDistance );\n\ttotalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );\n\ttransmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\t#ifdef texture2DLodEXT\n\t\t\treturn texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#else\n\t\t\treturn texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );\n\t\t#endif\n\t}\n\tvec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( attenuationDistance == 0.0 ) {\n\t\t\treturn radiance;\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance * radiance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );\n\t}\n#endif",uv_pars_fragment:"#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\t#ifdef UVS_VERTEX_ONLY\n\t\tvec2 vUv;\n\t#else\n\t\tvarying vec2 vUv;\n\t#endif\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\tuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tgl_FragColor = texture2D( t2D, vUv );\n\t#ifdef DECODE_VIDEO_TEXTURE\n\t\tgl_FragColor = vec4( mix( pow( gl_FragColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), gl_FragColor.rgb * 0.0773993808, vec3( lessThanEqual( gl_FragColor.rgb, vec3( 0.04045 ) ) ) ), gl_FragColor.w );\n\t#endif\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULARINTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n\t#ifdef USE_SPECULARCOLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEENCOLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEENROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},Aa={common:{diffuse:{value:new Hn(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new jn},uv2Transform:{value:new jn},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new Dn(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 Hn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Hn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new jn}},sprite:{diffuse:{value:new Hn(16777215)},opacity:{value:1},center:{value:new Dn(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new jn}}},Oa={basic:{uniforms:mergeUniforms([Aa.common,Aa.specularmap,Aa.envmap,Aa.aomap,Aa.lightmap,Aa.fog]),vertexShader:Ta.meshbasic_vert,fragmentShader:Ta.meshbasic_frag},lambert:{uniforms:mergeUniforms([Aa.common,Aa.specularmap,Aa.envmap,Aa.aomap,Aa.lightmap,Aa.emissivemap,Aa.fog,Aa.lights,{emissive:{value:new Hn(0)}}]),vertexShader:Ta.meshlambert_vert,fragmentShader:Ta.meshlambert_frag},phong:{uniforms:mergeUniforms([Aa.common,Aa.specularmap,Aa.envmap,Aa.aomap,Aa.lightmap,Aa.emissivemap,Aa.bumpmap,Aa.normalmap,Aa.displacementmap,Aa.fog,Aa.lights,{emissive:{value:new Hn(0)},specular:{value:new Hn(1118481)},shininess:{value:30}}]),vertexShader:Ta.meshphong_vert,fragmentShader:Ta.meshphong_frag},standard:{uniforms:mergeUniforms([Aa.common,Aa.envmap,Aa.aomap,Aa.lightmap,Aa.emissivemap,Aa.bumpmap,Aa.normalmap,Aa.displacementmap,Aa.roughnessmap,Aa.metalnessmap,Aa.fog,Aa.lights,{emissive:{value:new Hn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ta.meshphysical_vert,fragmentShader:Ta.meshphysical_frag},toon:{uniforms:mergeUniforms([Aa.common,Aa.aomap,Aa.lightmap,Aa.emissivemap,Aa.bumpmap,Aa.normalmap,Aa.displacementmap,Aa.gradientmap,Aa.fog,Aa.lights,{emissive:{value:new Hn(0)}}]),vertexShader:Ta.meshtoon_vert,fragmentShader:Ta.meshtoon_frag},matcap:{uniforms:mergeUniforms([Aa.common,Aa.bumpmap,Aa.normalmap,Aa.displacementmap,Aa.fog,{matcap:{value:null}}]),vertexShader:Ta.meshmatcap_vert,fragmentShader:Ta.meshmatcap_frag},points:{uniforms:mergeUniforms([Aa.points,Aa.fog]),vertexShader:Ta.points_vert,fragmentShader:Ta.points_frag},dashed:{uniforms:mergeUniforms([Aa.common,Aa.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ta.linedashed_vert,fragmentShader:Ta.linedashed_frag},depth:{uniforms:mergeUniforms([Aa.common,Aa.displacementmap]),vertexShader:Ta.depth_vert,fragmentShader:Ta.depth_frag},normal:{uniforms:mergeUniforms([Aa.common,Aa.bumpmap,Aa.normalmap,Aa.displacementmap,{opacity:{value:1}}]),vertexShader:Ta.meshnormal_vert,fragmentShader:Ta.meshnormal_frag},sprite:{uniforms:mergeUniforms([Aa.sprite,Aa.fog]),vertexShader:Ta.sprite_vert,fragmentShader:Ta.sprite_frag},background:{uniforms:{uvTransform:{value:new jn},t2D:{value:null}},vertexShader:Ta.background_vert,fragmentShader:Ta.background_frag},cube:{uniforms:mergeUniforms([Aa.envmap,{opacity:{value:1}}]),vertexShader:Ta.cube_vert,fragmentShader:Ta.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ta.equirect_vert,fragmentShader:Ta.equirect_frag},distanceRGBA:{uniforms:mergeUniforms([Aa.common,Aa.displacementmap,{referencePosition:{value:new ir},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ta.distanceRGBA_vert,fragmentShader:Ta.distanceRGBA_frag},shadow:{uniforms:mergeUniforms([Aa.lights,Aa.fog,{color:{value:new Hn(0)},opacity:{value:1}}]),vertexShader:Ta.shadow_vert,fragmentShader:Ta.shadow_frag}};function WebGLBackground(e,t,n,r,i,a){var o,s,u=new Hn(0),l=!0===i?0:1,c=null,h=0,d=null;function setClear(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,a)}return{getClearColor:function getClearColor(){return u},setClearColor:function setClearColor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;u.set(e),setClear(u,l=t)},getClearAlpha:function getClearAlpha(){return l},setClearAlpha:function setClearAlpha(e){setClear(u,l=e)},render:function render(n,i){var a=!1,f=!0===i.isScene?i.background:null;f&&f.isTexture&&(f=t.get(f));var p=e.xr,m=p.getSession&&p.getSession();m&&"additive"===m.environmentBlendMode&&(f=null),null===f?setClear(u,l):f&&f.isColor&&(setClear(f,1),a=!0),(e.autoClear||a)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),f&&(f.isCubeTexture||f.mapping===Me)?(void 0===s&&((s=new ia(new aa(1,1,1),new la({name:"BackgroundCubeMaterial",uniforms:cloneUniforms(Oa.cube.uniforms),vertexShader:Oa.cube.vertexShader,fragmentShader:Oa.cube.fragmentShader,side:C,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function get(){return this.uniforms.envMap.value}}),r.update(s)),s.material.uniforms.envMap.value=f,s.material.uniforms.flipEnvMap.value=f.isCubeTexture&&!1===f.isRenderTargetTexture?-1:1,c===f&&h===f.version&&d===e.toneMapping||(s.material.needsUpdate=!0,c=f,h=f.version,d=e.toneMapping),s.layers.enableAll(),n.unshift(s,s.geometry,s.material,0,0,null)):f&&f.isTexture&&(void 0===o&&((o=new ia(new wa(2,2),new la({name:"BackgroundMaterial",uniforms:cloneUniforms(Oa.background.uniforms),vertexShader:Oa.background.vertexShader,fragmentShader:Oa.background.fragmentShader,side:O,depthTest:!1,depthWrite:!1,fog:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function get(){return this.uniforms.t2D.value}}),r.update(o)),o.material.uniforms.t2D.value=f,!0===f.matrixAutoUpdate&&f.updateMatrix(),o.material.uniforms.uvTransform.value.copy(f.matrix),c===f&&h===f.version&&d===e.toneMapping||(o.material.needsUpdate=!0,c=f,h=f.version,d=e.toneMapping),o.layers.enableAll(),n.unshift(o,o.geometry,o.material,0,0,null))}}}function WebGLBindingStates(e,t,n,r){var i=e.getParameter(34921),a=r.isWebGL2?null:t.get("OES_vertex_array_object"),o=r.isWebGL2||null!==a,s={},u=createBindingState(null),l=u,c=!1;function bindVertexArrayObject(t){return r.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function deleteVertexArrayObject(t){return r.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function createBindingState(e){for(var t=[],n=[],r=[],a=0;a=0){var h=i[u],d=a[u];if(void 0===d&&("instanceMatrix"===u&&e.instanceMatrix&&(d=e.instanceMatrix),"instanceColor"===u&&e.instanceColor&&(d=e.instanceColor)),void 0===h)return!0;if(h.attribute!==d)return!0;if(d&&h.data!==d.data)return!0;o++}}return l.attributesNum!==o||l.index!==r}(i,d,h,f))&&function saveCache(e,t,n,r){var i={},a=t.attributes,o=0,s=n.getAttributes();for(var u in s){var c=s[u];if(c.location>=0){var h=a[u];void 0===h&&("instanceMatrix"===u&&e.instanceMatrix&&(h=e.instanceMatrix),"instanceColor"===u&&e.instanceColor&&(h=e.instanceColor));var d={};d.attribute=h,h&&h.data&&(d.data=h.data),i[u]=d,o++}}l.attributes=i,l.attributesNum=o,l.index=r}(i,d,h,f)}else{var v=!0===u.wireframe;l.geometry===d.id&&l.program===h.id&&l.wireframe===v||(l.geometry=d.id,l.program=h.id,l.wireframe=v,p=!0)}null!==f&&n.update(f,34963),(p||c)&&(c=!1,function setupVertexAttributes(i,a,o,s){if(!1!==r.isWebGL2||!i.isInstancedMesh&&!s.isInstancedBufferGeometry||null!==t.get("ANGLE_instanced_arrays")){initAttributes();var u=s.attributes,l=o.getAttributes(),c=a.defaultAttributeValues;for(var h in l){var d=l[h];if(d.location>=0){var f=u[h];if(void 0===f&&("instanceMatrix"===h&&i.instanceMatrix&&(f=i.instanceMatrix),"instanceColor"===h&&i.instanceColor&&(f=i.instanceColor)),void 0!==f){var p=f.normalized,m=f.itemSize,v=n.get(f);if(void 0===v)continue;var g=v.buffer,y=v.type,b=v.bytesPerElement;if(f.isInterleavedBufferAttribute){var x=f.data,_=x.stride,M=f.offset;if(x.isInstancedInterleavedBuffer){for(var S=0;S0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}var i="undefined"!==typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!==typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext,a=void 0!==n.precision?n.precision:"highp",o=getMaxPrecision(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);var s=i||t.has("WEBGL_draw_buffers"),u=!0===n.logarithmicDepthBuffer,l=e.getParameter(34930),c=e.getParameter(35660),h=e.getParameter(3379),d=e.getParameter(34076),f=e.getParameter(34921),p=e.getParameter(36347),m=e.getParameter(36348),v=e.getParameter(36349),g=c>0,y=i||t.has("OES_texture_float");return{isWebGL2:i,drawBuffers:s,getMaxAnisotropy:function getMaxAnisotropy(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){var n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:getMaxPrecision,precision:a,logarithmicDepthBuffer:u,maxTextures:l,maxVertexTextures:c,maxTextureSize:h,maxCubemapSize:d,maxAttributes:f,maxVertexUniforms:p,maxVaryings:m,maxFragmentUniforms:v,vertexTextures:g,floatFragmentTextures:y,floatVertexTextures:g&&y,maxSamples:i?e.getParameter(36183):0}}function WebGLClipping(e){var t=this,n=null,r=0,i=!1,a=!1,o=new xa,s=new jn,u={value:null,needsUpdate:!1};function resetGlobalState(){u.value!==n&&(u.value=n,u.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function projectPlanes(e,n,r,i){var a=null!==e?e.length:0,l=null;if(0!==a){if(l=u.value,!0!==i||null===l){var c=r+4*a,h=n.matrixWorldInverse;s.getNormalMatrix(h),(null===l||l.length0){var a=new va(i.height/2);return a.fromEquirectangularTexture(e,n),t.set(n,a),n.addEventListener("dispose",onTextureDispose),mapTextureMapping(a.texture,n.mapping)}return null}}return n},dispose:function dispose(){t=new WeakMap}}}Oa.physical={uniforms:mergeUniforms([Oa.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new Dn(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Hn(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new Dn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Hn(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Hn(1,1,1)},specularColorMap:{value:null}}]),vertexShader:Ta.meshphysical_vert,fragmentShader:Ta.meshphysical_frag};var Ca=function(e){function OrthographicCamera(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:-1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.1,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2e3;return Object(f.a)(this,OrthographicCamera),(e=Object(s.a)(this,Object(r.a)(OrthographicCamera).call(this))).isOrthographicCamera=!0,e.type="OrthographicCamera",e.zoom=1,e.view=null,e.left=t,e.right=n,e.top=i,e.bottom=a,e.near=o,e.far=u,e.updateProjectionMatrix(),e}return Object(u.a)(OrthographicCamera,e),Object(p.a)(OrthographicCamera,[{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(OrthographicCamera.prototype),"copy",this).call(this,e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}},{key:"setViewOffset",value:function setViewOffset(e,t,n,r,i,a){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}},{key:"clearViewOffset",value:function clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}},{key:"updateProjectionMatrix",value:function updateProjectionMatrix(){var e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(null!==this.view&&this.view.enabled){var u=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;a=(i+=u*this.view.offsetX)+u*this.view.width,s=(o-=l*this.view.offsetY)-l*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}},{key:"toJSON",value:function toJSON(e){var t=Object(o.a)(Object(r.a)(OrthographicCamera.prototype),"toJSON",this).call(this,e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}]),OrthographicCamera}(ca),La=4,ka=[.125,.215,.35,.446,.526,.582],Ea=20,Pa=new Ca,Ra=new Hn,Ia=null,Da=(1+Math.sqrt(5))/2,ja=1/Da,Ba=[new ir(1,1,1),new ir(-1,1,1),new ir(1,1,-1),new ir(-1,1,-1),new ir(0,Da,ja),new ir(0,Da,-ja),new ir(ja,0,Da),new ir(-ja,0,Da),new ir(Da,ja,0),new ir(-Da,ja,0)],Na=function(){function PMREMGenerator(e){Object(f.a)(this,PMREMGenerator),this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}return Object(p.a)(PMREMGenerator,[{key:"fromScene",value:function fromScene(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.1,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:100;Ia=this._renderer.getRenderTarget(),this._setSize(256);var i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}},{key:"fromEquirectangular",value:function fromEquirectangular(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this._fromTexture(e,t)}},{key:"fromCubemap",value:function fromCubemap(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this._fromTexture(e,t)}},{key:"compileCubemapShader",value:function compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=_getCubemapMaterial(),this._compileMaterial(this._cubemapMaterial))}},{key:"compileEquirectangularShader",value:function compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=_getEquirectMaterial(),this._compileMaterial(this._equirectMaterial))}},{key:"dispose",value:function dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}},{key:"_setSize",value:function _setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}},{key:"_dispose",value:function _dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(var e=0;ee-La?u=ka[o-e+La-1]:0===o&&(u=0),r.push(u);for(var l=1/(s-2),c=-l,h=1+l,d=[c,c,h,c,h,h,c,c,h,h,c,h],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36),v=0;v<6;v++){var g=v%3*2/3-1,y=v>2?0:-1,b=[g,y,0,g+2/3,y,0,g+2/3,y+1,0,g,y,0,g+2/3,y+1,0,g,y+1,0];f.set(b,18*v),p.set(d,12*v);var x=[v,v,v,v,v,v];m.set(x,6*v)}var _=new Fi;_.setAttribute("position",new Mi(f,3)),_.setAttribute("uv",new Mi(p,2)),_.setAttribute("faceIndex",new Mi(m,1)),t.push(_),i>La&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}(i);this._sizeLods=a.sizeLods,this._lodPlanes=a.lodPlanes,this._sigmas=a.sigmas,this._blurMaterial=function _getBlurShader(e,t,n){var r=new Float32Array(Ea),i=new ir(0,1,0);return new la({name:"SphericalGaussianBlur",defines:{n:Ea,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:"".concat(e,".0")},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:P,depthTest:!1,depthWrite:!1})}(i,e,t)}return r}},{key:"_compileMaterial",value:function _compileMaterial(e){var t=new ia(this._lodPlanes[0],e);this._renderer.compile(t,Pa)}},{key:"_sceneToCubeUV",value:function _sceneToCubeUV(e,t,n,r){var i=new ha(90,1,t,n),a=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],s=this._renderer,u=s.autoClear,l=s.toneMapping;s.getClearColor(Ra),s.toneMapping=he,s.autoClear=!1;var c=new bi({name:"PMREM.Background",side:C,depthWrite:!1,depthTest:!1}),h=new ia(new aa,c),d=!1,f=e.background;f?f.isColor&&(c.color.copy(f),e.background=null,d=!0):(c.color.copy(Ra),d=!0);for(var p=0;p<6;p++){var m=p%3;0===m?(i.up.set(0,a[p],0),i.lookAt(o[p],0,0)):1===m?(i.up.set(0,0,a[p]),i.lookAt(0,o[p],0)):(i.up.set(0,a[p],0),i.lookAt(0,0,o[p]));var v=this._cubeSize;_setViewport(r,m*v,p>2?v:0,v,v),s.setRenderTarget(r),d&&s.render(h,i),s.render(e,i)}h.geometry.dispose(),h.material.dispose(),s.toneMapping=l,s.autoClear=u,e.background=f}},{key:"_textureToCubeUV",value:function _textureToCubeUV(e,t){var n=this._renderer,r=e.mapping===ye||e.mapping===be;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=_getCubemapMaterial()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=_getEquirectMaterial());var i=r?this._cubemapMaterial:this._equirectMaterial,a=new ia(this._lodPlanes[0],i);i.uniforms.envMap.value=e;var o=this._cubeSize;_setViewport(t,0,0,3*o,2*o),n.setRenderTarget(t),n.render(a,Pa)}},{key:"_applyPMREM",value:function _applyPMREM(e){var t=this._renderer,n=t.autoClear;t.autoClear=!1;for(var r=1;rEa&&console.warn("sigmaRadians, ".concat(i,", is too large and will clip, as it requested ").concat(p," samples when the maximum is set to ").concat(Ea));for(var m=[],v=0,g=0;g_-La?r-_+La:0),4*(this._cubeSize-M),3*M,2*M),s.setRenderTarget(t),s.render(l,Pa)}}]),PMREMGenerator}();function _createRenderTarget(e,t,n){var r=new Kn(e,t,n);return r.texture.mapping=Me,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function _setViewport(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function _getEquirectMaterial(){return new la({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:P,depthTest:!1,depthWrite:!1})}function _getCubemapMaterial(){return new la({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t",fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:P,depthTest:!1,depthWrite:!1})}function WebGLCubeUVMaps(e){var t=new WeakMap,n=null;function onTextureDispose(e){var n=e.target;n.removeEventListener("dispose",onTextureDispose);var r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function get(r){if(r&&r.isTexture){var i=r.mapping,a=i===xe||i===_e,o=i===ye||i===be;if(a||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;var s=t.get(r);return null===n&&(n=new Na(e)),s=a?n.fromEquirectangular(r,s):n.fromCubemap(r,s),t.set(r,s),s.texture}if(t.has(r))return t.get(r).texture;var u=r.image;if(a&&u&&u.height>0||o&&u&&function isCubeTextureComplete(e){for(var t=0,n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(u)){null===n&&(n=new Na(e));var l=a?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,l),r.addEventListener("dispose",onTextureDispose),l.texture}return null}}return r},dispose:function dispose(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function WebGLExtensions(e){var t={};function getExtension(n){if(void 0!==t[n])return t[n];var r;switch(n){case"WEBGL_depth_texture":r=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function has(e){return null!==getExtension(e)},init:function init(e){e.isWebGL2?getExtension("EXT_color_buffer_float"):(getExtension("WEBGL_depth_texture"),getExtension("OES_texture_float"),getExtension("OES_texture_half_float"),getExtension("OES_texture_half_float_linear"),getExtension("OES_standard_derivatives"),getExtension("OES_element_index_uint"),getExtension("OES_vertex_array_object"),getExtension("ANGLE_instanced_arrays")),getExtension("OES_texture_float_linear"),getExtension("EXT_color_buffer_half_float"),getExtension("WEBGL_multisampled_render_to_texture")},get:function get(e){var t=getExtension(e);return null===t&&console.warn("THREE.WebGLRenderer: "+e+" extension not supported."),t}}}function WebGLGeometries(e,t,n,r){var i={},a=new WeakMap;function onGeometryDispose(e){var o=e.target;for(var s in null!==o.index&&t.remove(o.index),o.attributes)t.remove(o.attributes[s]);o.removeEventListener("dispose",onGeometryDispose),delete i[o.id];var u=a.get(o);u&&(t.remove(u),a.delete(o)),r.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function updateWireframeAttribute(e){var n=[],r=e.index,i=e.attributes.position,o=0;if(null!==r){var s=r.array;o=r.version;for(var u=0,l=s.length;ut.maxTextureSize&&(w=Math.ceil(S/t.maxTextureSize),S=t.maxTextureSize);var T=new Float32Array(S*w*4*p),A=new Qn(T,S,w,p);A.type=Ue,A.needsUpdate=!0;for(var O=4*M,C=0;C0)return e;var i=t*n,a=Va[i];if(void 0===a&&(a=new Float32Array(i),Va[i]=a),0!==t){r.toArray(a,0);for(var o=1,s=0;o!==t;++o)s+=n,e[o].toArray(a,s)}return a}function arraysEqual(e,t){if(e.length!==t.length)return!1;for(var n=0,r=e.length;n":" "," ").concat(s,": ").concat(n[o]))}return r.join("\n")}(e.getShaderSource(t),o)}return i}function getTexelEncodingFunction(e,t){var n=function getEncodingComponents(e){switch(e){case Ht:return["Linear","( value )"];case qt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function getToneMappingFunction(e,t){var n;switch(t){case de:n="Linear";break;case fe:n="Reinhard";break;case pe:n="OptimizedCineon";break;case me:n="ACESFilmic";break;case ve:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function filterEmptyLine(e){return""!==e}function replaceLightNums(e,t){return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function replaceClippingPlaneNums(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}var eo=/^[ \t]*#include +<([\w\d./]+)>/gm;function resolveIncludes(e){return e.replace(eo,includeReplacer)}function includeReplacer(e,t){var n=Ta[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return resolveIncludes(n)}var to=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,no=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function unrollLoops(e){return e.replace(no,loopReplacer).replace(to,deprecatedLoopReplacer)}function deprecatedLoopReplacer(e,t,n,r){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),loopReplacer(e,t,n,r)}function loopReplacer(e,t,n,r){for(var i="",a=parseInt(t);a0&&(i+="\n"),(a=[m,v].filter(filterEmptyLine).join("\n")).length>0&&(a+="\n")):(i=[generatePrecision(n),"#define SHADER_NAME "+n.shaderName,v,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(filterEmptyLine).join("\n"),a=[m,generatePrecision(n),"#define SHADER_NAME "+n.shaderName,v,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==he?"#define TONE_MAPPING":"",n.toneMapping!==he?Ta.tonemapping_pars_fragment:"",n.toneMapping!==he?getToneMappingFunction("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Ta.encodings_pars_fragment,getTexelEncodingFunction("linearToOutputTexel",n.outputEncoding),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(filterEmptyLine).join("\n")),u=replaceClippingPlaneNums(u=replaceLightNums(u=resolveIncludes(u),n),n),l=replaceClippingPlaneNums(l=replaceLightNums(l=resolveIncludes(l),n),n),u=unrollLoops(u),l=unrollLoops(l),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(y="#version 300 es\n",i=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+i,a=["#define varying in",n.glslVersion===On?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===On?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+a);var b,x,_=y+a+l,M=WebGLShader(o,35633,y+i+u),S=WebGLShader(o,35632,_);if(o.attachShader(g,M),o.attachShader(g,S),void 0!==n.index0AttributeName?o.bindAttribLocation(g,0,n.index0AttributeName):!0===n.morphTargets&&o.bindAttribLocation(g,0,"position"),o.linkProgram(g),e.debug.checkShaderErrors){var O=o.getProgramInfoLog(g).trim(),C=o.getShaderInfoLog(M).trim(),L=o.getShaderInfoLog(S).trim(),k=!0,E=!0;if(!1===o.getProgramParameter(g,35714)){k=!1;var P=getShaderErrors(o,M,"vertex"),R=getShaderErrors(o,S,"fragment");console.error("THREE.WebGLProgram: Shader Error "+o.getError()+" - VALIDATE_STATUS "+o.getProgramParameter(g,35715)+"\n\nProgram Info Log: "+O+"\n"+P+"\n"+R)}else""!==O?console.warn("THREE.WebGLProgram: Program Info Log:",O):""!==C&&""!==L||(E=!1);E&&(this.diagnostics={runnable:k,programLog:O,vertexShader:{log:C,prefix:i},fragmentShader:{log:L,prefix:a}})}return o.deleteShader(M),o.deleteShader(S),this.getUniforms=function(){return void 0===b&&(b=new Qa(o,g)),b},this.getAttributes=function(){return void 0===x&&(x=function fetchAttributeLocations(e,t){for(var n={},r=e.getProgramParameter(t,35721),i=0;i0,j=a.clearcoat>0,B=a.iridescence>0;return{isWebGL2:c,shaderID:M,shaderName:a.type,vertexShader:S,fragmentShader:w,defines:a.defines,customVertexShaderID:T,customFragmentShaderID:A,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:f,instancing:!0===v.isInstancedMesh,instancingColor:!0===v.isInstancedMesh&&null!==v.instanceColor,supportsVertexTextures:d,outputEncoding:null===I?e.outputEncoding:!0===I.isXRRenderTarget?I.texture.encoding:Ht,map:!!a.map,matcap:!!a.matcap,envMap:!!x,envMapMode:x&&x.mapping,envMapCubeUVHeight:_,lightMap:!!a.lightMap,aoMap:!!a.aoMap,emissiveMap:!!a.emissiveMap,bumpMap:!!a.bumpMap,normalMap:!!a.normalMap,objectSpaceNormalMap:a.normalMapType===Zt,tangentSpaceNormalMap:a.normalMapType===Yt,decodeVideoTexture:!!a.map&&!0===a.map.isVideoTexture&&a.map.encoding===qt,clearcoat:j,clearcoatMap:j&&!!a.clearcoatMap,clearcoatRoughnessMap:j&&!!a.clearcoatRoughnessMap,clearcoatNormalMap:j&&!!a.clearcoatNormalMap,iridescence:B,iridescenceMap:B&&!!a.iridescenceMap,iridescenceThicknessMap:B&&!!a.iridescenceThicknessMap,displacementMap:!!a.displacementMap,roughnessMap:!!a.roughnessMap,metalnessMap:!!a.metalnessMap,specularMap:!!a.specularMap,specularIntensityMap:!!a.specularIntensityMap,specularColorMap:!!a.specularColorMap,opaque:!1===a.transparent&&a.blending===R,alphaMap:!!a.alphaMap,alphaTest:D,gradientMap:!!a.gradientMap,sheen:a.sheen>0,sheenColorMap:!!a.sheenColorMap,sheenRoughnessMap:!!a.sheenRoughnessMap,transmission:a.transmission>0,transmissionMap:!!a.transmissionMap,thicknessMap:!!a.thicknessMap,combine:a.combine,vertexTangents:!!a.normalMap&&!!y.attributes.tangent,vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!y.attributes.color&&4===y.attributes.color.itemSize,vertexUvs:!!a.map||!!a.bumpMap||!!a.normalMap||!!a.specularMap||!!a.alphaMap||!!a.emissiveMap||!!a.roughnessMap||!!a.metalnessMap||!!a.clearcoatMap||!!a.clearcoatRoughnessMap||!!a.clearcoatNormalMap||!!a.iridescenceMap||!!a.iridescenceThicknessMap||!!a.displacementMap||!!a.transmissionMap||!!a.thicknessMap||!!a.specularIntensityMap||!!a.specularColorMap||!!a.sheenColorMap||!!a.sheenRoughnessMap,uvsVertexOnly:!(a.map||a.bumpMap||a.normalMap||a.specularMap||a.alphaMap||a.emissiveMap||a.roughnessMap||a.metalnessMap||a.clearcoatNormalMap||a.iridescenceMap||a.iridescenceThicknessMap||a.transmission>0||a.transmissionMap||a.thicknessMap||a.specularIntensityMap||a.specularColorMap||a.sheen>0||a.sheenColorMap||a.sheenRoughnessMap)&&!!a.displacementMap,fog:!!g,useFog:!0===a.fog,fogExp2:g&&g.isFogExp2,flatShading:!!a.flatShading,sizeAttenuation:a.sizeAttenuation,logarithmicDepthBuffer:h,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==y.morphAttributes.position,morphNormals:void 0!==y.morphAttributes.normal,morphColors:void 0!==y.morphAttributes.color,morphTargetsCount:k,morphTextureStride:E,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:a.toneMapped?e.toneMapping:he,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===L,flipSided:a.side===C,useDepthPacking:!!a.depthPacking,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:a.extensions&&a.extensions.derivatives,extensionFragDepth:a.extensions&&a.extensions.fragDepth,extensionDrawBuffers:a.extensions&&a.extensions.drawBuffers,extensionShaderTextureLOD:a.extensions&&a.extensions.shaderTextureLOD,rendererExtensionFragDepth:c||r.has("EXT_frag_depth"),rendererExtensionDrawBuffers:c||r.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:c||r.has("EXT_shader_texture_lod"),customProgramCacheKey:a.customProgramCacheKey()}},getProgramCacheKey:function getProgramCacheKey(t){var n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(var r in t.defines)n.push(r),n.push(t.defines[r]);return!1===t.isRawShaderMaterial&&(function getProgramCacheKeyParameters(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.combine),e.push(t.vertexUvs),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function getProgramCacheKeyBooleans(e,t){s.disableAll(),t.isWebGL2&&s.enable(0),t.supportsVertexTextures&&s.enable(1),t.instancing&&s.enable(2),t.instancingColor&&s.enable(3),t.map&&s.enable(4),t.matcap&&s.enable(5),t.envMap&&s.enable(6),t.lightMap&&s.enable(7),t.aoMap&&s.enable(8),t.emissiveMap&&s.enable(9),t.bumpMap&&s.enable(10),t.normalMap&&s.enable(11),t.objectSpaceNormalMap&&s.enable(12),t.tangentSpaceNormalMap&&s.enable(13),t.clearcoat&&s.enable(14),t.clearcoatMap&&s.enable(15),t.clearcoatRoughnessMap&&s.enable(16),t.clearcoatNormalMap&&s.enable(17),t.iridescence&&s.enable(18),t.iridescenceMap&&s.enable(19),t.iridescenceThicknessMap&&s.enable(20),t.displacementMap&&s.enable(21),t.specularMap&&s.enable(22),t.roughnessMap&&s.enable(23),t.metalnessMap&&s.enable(24),t.gradientMap&&s.enable(25),t.alphaMap&&s.enable(26),t.alphaTest&&s.enable(27),t.vertexColors&&s.enable(28),t.vertexAlphas&&s.enable(29),t.vertexUvs&&s.enable(30),t.vertexTangents&&s.enable(31),t.uvsVertexOnly&&s.enable(32),t.fog&&s.enable(33),e.push(s.mask),s.disableAll(),t.useFog&&s.enable(0),t.flatShading&&s.enable(1),t.logarithmicDepthBuffer&&s.enable(2),t.skinning&&s.enable(3),t.morphTargets&&s.enable(4),t.morphNormals&&s.enable(5),t.morphColors&&s.enable(6),t.premultipliedAlpha&&s.enable(7),t.shadowMapEnabled&&s.enable(8),t.physicallyCorrectLights&&s.enable(9),t.doubleSided&&s.enable(10),t.flipSided&&s.enable(11),t.useDepthPacking&&s.enable(12),t.dithering&&s.enable(13),t.specularIntensityMap&&s.enable(14),t.specularColorMap&&s.enable(15),t.transmission&&s.enable(16),t.transmissionMap&&s.enable(17),t.thicknessMap&&s.enable(18),t.sheen&&s.enable(19),t.sheenColorMap&&s.enable(20),t.sheenRoughnessMap&&s.enable(21),t.decodeVideoTexture&&s.enable(22),t.opaque&&s.enable(23),e.push(s.mask)}(n,t),n.push(e.outputEncoding)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function getUniforms(e){var t,n=p[e.type];if(n){var r=Oa[n];t=oa.clone(r.uniforms)}else t=e.uniforms;return t},acquireProgram:function acquireProgram(t,n){for(var r,i=0,o=l.length;i0?r.push(l):!0===a.transparent?i.push(l):n.push(l)},unshift:function unshift(e,t,a,o,s,u){var l=getNextRenderItem(e,t,a,o,s,u);a.transmission>0?r.unshift(l):!0===a.transparent?i.unshift(l):n.unshift(l)},finish:function finish(){for(var n=t,r=e.length;n1&&n.sort(e||painterSortStable),r.length>1&&r.sort(t||reversePainterSortStable),i.length>1&&i.sort(t||reversePainterSortStable)}}}function WebGLRenderLists(){var e=new WeakMap;return{get:function get(t,n){var r;return!1===e.has(t)?(r=new WebGLRenderList,e.set(t,[r])):n>=e.get(t).length?(r=new WebGLRenderList,e.get(t).push(r)):r=e.get(t)[n],r},dispose:function dispose(){e=new WeakMap}}}function UniformsCache(){var e={};return{get:function get(t){if(void 0!==e[t.id])return e[t.id];var n;switch(t.type){case"DirectionalLight":n={direction:new ir,color:new Hn};break;case"SpotLight":n={position:new ir,direction:new ir,color:new Hn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ir,color:new Hn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ir,skyColor:new Hn,groundColor:new Hn};break;case"RectAreaLight":n={color:new Hn,position:new ir,halfWidth:new ir,halfHeight:new ir}}return e[t.id]=n,n}}}var oo=0;function shadowCastingLightsFirst(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function WebGLLights(e,t){for(var n=new UniformsCache,r=function ShadowUniformsCache(){var e={};return{get:function get(t){if(void 0!==e[t.id])return e[t.id];var n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Dn,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]},a=0;a<9;a++)i.probe.push(new ir);var o=new ir,s=new Ir,u=new Ir;return{setup:function setup(a,o){for(var s=0,u=0,l=0,c=0;c<9;c++)i.probe[c].set(0,0,0);var h=0,d=0,f=0,p=0,m=0,v=0,g=0,y=0;a.sort(shadowCastingLightsFirst);for(var b=!0!==o?Math.PI:1,x=0,_=a.length;x<_;x++){var M=a[x],S=M.color,w=M.intensity,T=M.distance,A=M.shadow&&M.shadow.map?M.shadow.map.texture:null;if(M.isAmbientLight)s+=S.r*w*b,u+=S.g*w*b,l+=S.b*w*b;else if(M.isLightProbe)for(var O=0;O<9;O++)i.probe[O].addScaledVector(M.sh.coefficients[O],w);else if(M.isDirectionalLight){var C=n.get(M);if(C.color.copy(M.color).multiplyScalar(M.intensity*b),M.castShadow){var L=M.shadow,k=r.get(M);k.shadowBias=L.bias,k.shadowNormalBias=L.normalBias,k.shadowRadius=L.radius,k.shadowMapSize=L.mapSize,i.directionalShadow[h]=k,i.directionalShadowMap[h]=A,i.directionalShadowMatrix[h]=M.shadow.matrix,v++}i.directional[h]=C,h++}else if(M.isSpotLight){var E=n.get(M);if(E.position.setFromMatrixPosition(M.matrixWorld),E.color.copy(S).multiplyScalar(w*b),E.distance=T,E.coneCos=Math.cos(M.angle),E.penumbraCos=Math.cos(M.angle*(1-M.penumbra)),E.decay=M.decay,M.castShadow){var P=M.shadow,R=r.get(M);R.shadowBias=P.bias,R.shadowNormalBias=P.normalBias,R.shadowRadius=P.radius,R.shadowMapSize=P.mapSize,i.spotShadow[f]=R,i.spotShadowMap[f]=A,i.spotShadowMatrix[f]=M.shadow.matrix,y++}i.spot[f]=E,f++}else if(M.isRectAreaLight){var I=n.get(M);I.color.copy(S).multiplyScalar(w),I.halfWidth.set(.5*M.width,0,0),I.halfHeight.set(0,.5*M.height,0),i.rectArea[p]=I,p++}else if(M.isPointLight){var D=n.get(M);if(D.color.copy(M.color).multiplyScalar(M.intensity*b),D.distance=M.distance,D.decay=M.decay,M.castShadow){var j=M.shadow,B=r.get(M);B.shadowBias=j.bias,B.shadowNormalBias=j.normalBias,B.shadowRadius=j.radius,B.shadowMapSize=j.mapSize,B.shadowCameraNear=j.camera.near,B.shadowCameraFar=j.camera.far,i.pointShadow[d]=B,i.pointShadowMap[d]=A,i.pointShadowMatrix[d]=M.shadow.matrix,g++}i.point[d]=D,d++}else if(M.isHemisphereLight){var N=n.get(M);N.skyColor.copy(M.color).multiplyScalar(w*b),N.groundColor.copy(M.groundColor).multiplyScalar(w*b),i.hemi[m]=N,m++}}p>0&&(t.isWebGL2?(i.rectAreaLTC1=Aa.LTC_FLOAT_1,i.rectAreaLTC2=Aa.LTC_FLOAT_2):!0===e.has("OES_texture_float_linear")?(i.rectAreaLTC1=Aa.LTC_FLOAT_1,i.rectAreaLTC2=Aa.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(i.rectAreaLTC1=Aa.LTC_HALF_1,i.rectAreaLTC2=Aa.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=s,i.ambient[1]=u,i.ambient[2]=l;var z=i.hash;z.directionalLength===h&&z.pointLength===d&&z.spotLength===f&&z.rectAreaLength===p&&z.hemiLength===m&&z.numDirectionalShadows===v&&z.numPointShadows===g&&z.numSpotShadows===y||(i.directional.length=h,i.spot.length=f,i.rectArea.length=p,i.point.length=d,i.hemi.length=m,i.directionalShadow.length=v,i.directionalShadowMap.length=v,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=v,i.pointShadowMatrix.length=g,i.spotShadowMatrix.length=y,z.directionalLength=h,z.pointLength=d,z.spotLength=f,z.rectAreaLength=p,z.hemiLength=m,z.numDirectionalShadows=v,z.numPointShadows=g,z.numSpotShadows=y,i.version=oo++)},setupView:function setupView(e,t){for(var n=0,r=0,a=0,l=0,c=0,h=t.matrixWorldInverse,d=0,f=e.length;d1&&void 0!==arguments[1]?arguments[1]:0;return!1===n.has(r)?(i=new WebGLRenderState(e,t),n.set(r,[i])):a>=n.get(r).length?(i=new WebGLRenderState(e,t),n.get(r).push(i)):i=n.get(r)[a],i},dispose:function dispose(){n=new WeakMap}}}var so=function(e){function MeshDepthMaterial(e){var t;return Object(f.a)(this,MeshDepthMaterial),(t=Object(s.a)(this,Object(r.a)(MeshDepthMaterial).call(this))).isMeshDepthMaterial=!0,t.type="MeshDepthMaterial",t.depthPacking=Xt,t.map=null,t.alphaMap=null,t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.wireframe=!1,t.wireframeLinewidth=1,t.setValues(e),t}return Object(u.a)(MeshDepthMaterial,e),Object(p.a)(MeshDepthMaterial,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(MeshDepthMaterial.prototype),"copy",this).call(this,e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}]),MeshDepthMaterial}(yi),uo=function(e){function MeshDistanceMaterial(e){var t;return Object(f.a)(this,MeshDistanceMaterial),(t=Object(s.a)(this,Object(r.a)(MeshDistanceMaterial).call(this))).isMeshDistanceMaterial=!0,t.type="MeshDistanceMaterial",t.referencePosition=new ir,t.nearDistance=1,t.farDistance=1e3,t.map=null,t.alphaMap=null,t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.setValues(e),t}return Object(u.a)(MeshDistanceMaterial,e),Object(p.a)(MeshDistanceMaterial,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(MeshDistanceMaterial.prototype),"copy",this).call(this,e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}]),MeshDistanceMaterial}(yi),lo="void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",co="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}";function WebGLShadowMap(e,t,n){var r=new Sa,i=new Dn,a=new Dn,o=new Zn,s=new so({depthPacking:Jt}),u=new uo,l={},c=n.maxTextureSize,h={0:C,1:O,2:L},d=new la({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Dn},radius:{value:4}},vertexShader:lo,fragmentShader:co}),f=d.clone();f.defines.HORIZONTAL_PASS=1;var p=new Fi;p.setAttribute("position",new Mi(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var m=new ia(p,d),v=this;function VSMPass(n,r){var a=t.update(m);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,f.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Kn(i.x,i.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(r,null,a,d,m,null),f.uniforms.shadow_pass.value=n.mapPass.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(r,null,a,f,m,null)}function getDepthMaterial(t,n,r,i,a,o){var c=null,d=!0===r.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(c=void 0!==d?d:!0===r.isPointLight?u:s,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){var f=c.uuid,p=n.uuid,m=l[f];void 0===m&&(m={},l[f]=m);var v=m[p];void 0===v&&(v=c.clone(),m[p]=v),c=v}return c.visible=n.visible,c.wireframe=n.wireframe,c.side=o===A?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:h[n.side],c.alphaMap=n.alphaMap,c.alphaTest=n.alphaTest,c.clipShadows=n.clipShadows,c.clippingPlanes=n.clippingPlanes,c.clipIntersection=n.clipIntersection,c.displacementMap=n.displacementMap,c.displacementScale=n.displacementScale,c.displacementBias=n.displacementBias,c.wireframeLinewidth=n.wireframeLinewidth,c.linewidth=n.linewidth,!0===r.isPointLight&&!0===c.isMeshDistanceMaterial&&(c.referencePosition.setFromMatrixPosition(r.matrixWorld),c.nearDistance=i,c.farDistance=a),c}function renderObject(n,i,a,o,s){if(!1!==n.visible){if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===A)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);var u=t.update(n),l=n.material;if(Array.isArray(l))for(var c=u.groups,h=0,d=c.length;hc||i.y>c)&&(i.x>c&&(a.x=Math.floor(c/y.x),i.x=a.x*y.x,g.mapSize.x=a.x),i.y>c&&(a.y=Math.floor(c/y.y),i.y=a.y*y.y,g.mapSize.y=a.y)),null===g.map){var b=this.type!==A?{minFilter:Ae,magFilter:Ae}:{};g.map=new Kn(i.x,i.y,b),g.map.texture.name=m.name+".shadowMap",g.camera.updateProjectionMatrix()}e.setRenderTarget(g.map),e.clear();for(var x=g.getViewportCount(),_=0;_=1):-1!==pe.indexOf("OpenGL ES")&&(fe=parseFloat(/^OpenGL ES (\d)/.exec(pe)[1]),de=fe>=2);var me=null,ve={},ge=e.getParameter(3088),ye=e.getParameter(2978),be=(new Zn).fromArray(ge),xe=(new Zn).fromArray(ye);function createTexture(t,n,r){var i=new Uint8Array(4),a=e.createTexture();e.bindTexture(t,a),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(var o=0;or||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||!0===t){if("undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&e instanceof ImageBitmap){var a=t?floorPowerOfTwo:Math.floor,o=a(i*e.width),s=a(i*e.height);void 0===l&&(l=createCanvas(o,s));var u=n?createCanvas(o,s):l;return u.width=o,u.height=s,u.getContext("2d").drawImage(e,0,0,o,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+o+"x"+s+")."),u}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function isPowerOfTwo$1(e){return isPowerOfTwo(e.width)&&isPowerOfTwo(e.height)}function textureNeedsGenerateMipmaps(e,t){return e.generateMipmaps&&t&&e.minFilter!==Ae&&e.minFilter!==Ee}function generateMipmap(t){e.generateMipmap(t)}function getInternalFormat(n,r,i,a){var o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(!1===c)return r;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}var s=r;return 6403===r&&(5126===i&&(s=33326),5131===i&&(s=33325),5121===i&&(s=33321)),33319===r&&(5126===i&&(s=33328),5131===i&&(s=33327),5121===i&&(s=33323)),6408===r&&(5126===i&&(s=34836),5131===i&&(s=34842),5121===i&&(s=a===qt&&!1===o?35907:32856),32819===i&&(s=32854),32820===i&&(s=32855)),33325!==s&&33326!==s&&33327!==s&&33328!==s&&34842!==s&&34836!==s||t.get("EXT_color_buffer_float"),s}function getMipLevels(e,t,n){return!0===textureNeedsGenerateMipmaps(e,n)||e.isFramebufferTexture&&e.minFilter!==Ae&&e.minFilter!==Ee?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function filterFallback(e){return e===Ae||e===Oe||e===Le?9728:9729}function onTextureDispose(e){var t=e.target;t.removeEventListener("dispose",onTextureDispose),function deallocateTexture(e){var t=r.get(e);if(void 0===t.__webglInit)return;var n=e.source,i=y.get(n);if(i){var a=i[t.__cacheKey];a.usedTimes--,0===a.usedTimes&&deleteTexture(e),0===Object.keys(i).length&&y.delete(n)}r.remove(e)}(t),t.isVideoTexture&&g.delete(t)}function onRenderTargetDispose(t){var n=t.target;n.removeEventListener("dispose",onRenderTargetDispose),function deallocateRenderTarget(t){var n=t.texture,i=r.get(t),a=r.get(n);void 0!==a.__webglTexture&&(e.deleteTexture(a.__webglTexture),o.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(var s=0;s<6;s++)e.deleteFramebuffer(i.__webglFramebuffer[s]),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer[s]);else{if(e.deleteFramebuffer(i.__webglFramebuffer),i.__webglDepthbuffer&&e.deleteRenderbuffer(i.__webglDepthbuffer),i.__webglMultisampledFramebuffer&&e.deleteFramebuffer(i.__webglMultisampledFramebuffer),i.__webglColorRenderbuffer)for(var u=0;u0&&i.__version!==e.version){var a=e.image;if(null===a)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==a.complete)return void uploadTexture(i,e,t);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,i.__webglTexture)}var _=(_defineProperty(s={},Se,10497),_defineProperty(s,we,33071),_defineProperty(s,Te,33648),s),M=(_defineProperty(u={},Ae,9728),_defineProperty(u,Oe,9984),_defineProperty(u,Le,9986),_defineProperty(u,Ee,9729),_defineProperty(u,Pe,9985),_defineProperty(u,Ie,9987),u);function setTextureParameters(n,a,o){if(o?(e.texParameteri(n,10242,_[a.wrapS]),e.texParameteri(n,10243,_[a.wrapT]),32879!==n&&35866!==n||e.texParameteri(n,32882,_[a.wrapR]),e.texParameteri(n,10240,M[a.magFilter]),e.texParameteri(n,10241,M[a.minFilter])):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),32879!==n&&35866!==n||e.texParameteri(n,32882,33071),a.wrapS===we&&a.wrapT===we||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,10240,filterFallback(a.magFilter)),e.texParameteri(n,10241,filterFallback(a.minFilter)),a.minFilter!==Ae&&a.minFilter!==Ee&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){var s=t.get("EXT_texture_filter_anisotropic");if(a.type===Ue&&!1===t.has("OES_texture_float_linear"))return;if(!1===c&&a.type===Ve&&!1===t.has("OES_texture_half_float_linear"))return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function initTexture(t,n){var r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",onTextureDispose));var i=n.source,a=y.get(i);void 0===a&&(a={},y.set(i,a));var s=function getTextureCacheKey(e){var t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.encoding),t.join()}(n);if(s!==t.__cacheKey){void 0===a[s]&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;var u=a[t.__cacheKey];void 0!==u&&(a[t.__cacheKey].usedTimes--,0===u.usedTimes&&deleteTexture(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function uploadTexture(t,r,i){var o=3553;r.isDataArrayTexture&&(o=35866),r.isData3DTexture&&(o=32879);var s=initTexture(t,r),u=r.source;if(n.activeTexture(33984+i),n.bindTexture(o,t.__webglTexture),u.version!==u.__currentVersion||!0===s){e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment),e.pixelStorei(37443,0);var l,h=function textureNeedsPowerOfTwo(e){return!c&&(e.wrapS!==we||e.wrapT!==we||e.minFilter!==Ae&&e.minFilter!==Ee)}(r)&&!1===isPowerOfTwo$1(r.image),d=resizeImage(r.image,h,!1,f),p=isPowerOfTwo$1(d=verifyColorSpace(r,d))||c,m=a.convert(r.format,r.encoding),v=a.convert(r.type),g=getInternalFormat(r.internalFormat,m,v,r.encoding,r.isVideoTexture);setTextureParameters(o,r,p);var y=r.mipmaps,b=c&&!0!==r.isVideoTexture,x=void 0===u.__currentVersion||!0===s,_=getMipLevels(r,d,p);if(r.isDepthTexture)g=6402,c?g=r.type===Ue?36012:r.type===Ge?33190:r.type===qe?35056:33189:r.type===Ue&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===Qe&&6402===g&&r.type!==ze&&r.type!==Ge&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Ge,v=a.convert(r.type)),r.format===$e&&6402===g&&(g=34041,r.type!==qe&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=qe,v=a.convert(r.type))),x&&(b?n.texStorage2D(3553,1,g,d.width,d.height):n.texImage2D(3553,0,g,d.width,d.height,0,m,v,null));else if(r.isDataTexture)if(y.length>0&&p){b&&x&&n.texStorage2D(3553,_,g,y[0].width,y[0].height);for(var M=0,S=y.length;M>=1,O>>=1}else if(y.length>0&&p){b&&x&&n.texStorage2D(3553,_,g,y[0].width,y[0].height);for(var L=0,k=y.length;L0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function verifyColorSpace(e,n){var r=e.encoding,i=e.format,a=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===Cn?n:(r!==Ht&&(r===qt?!1===c?!0===t.has("EXT_sRGB")&&i===Ye?(e.format=Cn,e.minFilter=Ee,e.generateMipmaps=!1):n=qn.sRGBToLinear(n):i===Ye&&a===je||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",r)),n)}this.allocateTextureUnit=function allocateTextureUnit(){var e=x;return e>=h&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+h),x+=1,e},this.resetTextureUnits=function resetTextureUnits(){x=0},this.setTexture2D=setTexture2D,this.setTexture2DArray=function setTexture2DArray(e,t){var i=r.get(e);e.version>0&&i.__version!==e.version?uploadTexture(i,e,t):(n.activeTexture(33984+t),n.bindTexture(35866,i.__webglTexture))},this.setTexture3D=function setTexture3D(e,t){var i=r.get(e);e.version>0&&i.__version!==e.version?uploadTexture(i,e,t):(n.activeTexture(33984+t),n.bindTexture(32879,i.__webglTexture))},this.setTextureCube=function setTextureCube(t,i){var o=r.get(t);t.version>0&&o.__version!==t.version?function uploadCubeTexture(t,r,i){if(6===r.image.length){var o=initTexture(t,r),s=r.source;if(n.activeTexture(33984+i),n.bindTexture(34067,t.__webglTexture),s.version!==s.__currentVersion||!0===o){e.pixelStorei(37440,r.flipY),e.pixelStorei(37441,r.premultiplyAlpha),e.pixelStorei(3317,r.unpackAlignment),e.pixelStorei(37443,0);for(var u=r.isCompressedTexture||r.image[0].isCompressedTexture,l=r.image[0]&&r.image[0].isDataTexture,h=[],f=0;f<6;f++)h[f]=u||l?l?r.image[f].image:r.image[f]:resizeImage(r.image[f],!1,!0,d),h[f]=verifyColorSpace(r,h[f]);var p,m=h[0],v=isPowerOfTwo$1(m)||c,g=a.convert(r.format,r.encoding),y=a.convert(r.type),b=getInternalFormat(r.internalFormat,g,y,r.encoding),x=c&&!0!==r.isVideoTexture,_=void 0===s.__currentVersion||!0===o,M=getMipLevels(r,m,v);if(setTextureParameters(34067,r,v),u){x&&_&&n.texStorage2D(34067,M,b,m.width,m.height);for(var S=0;S<6;S++){p=h[S].mipmaps;for(var w=0;w0&&M++,n.texStorage2D(34067,M,b,h[0].width,h[0].height));for(var A=0;A<6;A++)if(l){x?n.texSubImage2D(34069+A,0,0,0,h[A].width,h[A].height,g,y,h[A].data):n.texImage2D(34069+A,0,b,h[A].width,h[A].height,0,g,y,h[A].data);for(var O=0;O0&&!1===useMultisampledRTT(t)){var b=d?s:[s];u.__webglMultisampledFramebuffer=e.createFramebuffer(),u.__webglColorRenderbuffer=[],n.bindFramebuffer(36160,u.__webglMultisampledFramebuffer);for(var x=0;x0&&!1===useMultisampledRTT(t)){var i=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,o=t.height,s=16384,u=[],l=t.stencilBuffer?33306:36096,h=r.get(t),d=!0===t.isWebGLMultipleRenderTargets;if(d)for(var f=0;f1&&void 0!==arguments[1]?arguments[1]:null;if(n===je)return 5121;if(n===We)return 32819;if(n===He)return 32820;if(n===Be)return 5120;if(n===Ne)return 5122;if(n===ze)return 5123;if(n===Fe)return 5124;if(n===Ge)return 5125;if(n===Ue)return 5126;if(n===Ve)return r?5131:null!==(i=t.get("OES_texture_half_float"))?i.HALF_FLOAT_OES:null;if(n===Xe)return 6406;if(n===Ye)return 6408;if(n===Ze)return 6409;if(n===Ke)return 6410;if(n===Qe)return 6402;if(n===$e)return 34041;if(n===et)return 6403;if(n===Je)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(n===Cn)return null!==(i=t.get("EXT_sRGB"))?i.SRGB_ALPHA_EXT:null;if(n===tt)return 36244;if(n===nt)return 33319;if(n===rt)return 33320;if(n===it)return 36249;if(n===at||n===ot||n===st||n===ut)if(a===qt){if(null===(i=t.get("WEBGL_compressed_texture_s3tc_srgb")))return null;if(n===at)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ot)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===st)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===ut)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(null===(i=t.get("WEBGL_compressed_texture_s3tc")))return null;if(n===at)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ot)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===st)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===ut)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===lt||n===ct||n===ht||n===dt){if(null===(i=t.get("WEBGL_compressed_texture_pvrtc")))return null;if(n===lt)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===ct)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ht)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===dt)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===ft)return null!==(i=t.get("WEBGL_compressed_texture_etc1"))?i.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===pt||n===mt){if(null===(i=t.get("WEBGL_compressed_texture_etc")))return null;if(n===pt)return a===qt?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(n===mt)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC}if(n===vt||n===gt||n===yt||n===bt||n===xt||n===_t||n===Mt||n===St||n===wt||n===Tt||n===At||n===Ot||n===Ct||n===Lt){if(null===(i=t.get("WEBGL_compressed_texture_astc")))return null;if(n===vt)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===gt)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===yt)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===bt)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===xt)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===_t)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Mt)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===St)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===wt)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Tt)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===At)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ot)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Ct)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Lt)return a===qt?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===kt){if(null===(i=t.get("EXT_texture_compression_bptc")))return null;if(n===kt)return a===qt?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT}return n===qe?r?34042:null!==(i=t.get("WEBGL_depth_texture"))?i.UNSIGNED_INT_24_8_WEBGL:null:void 0!==e[n]?e[n]:null}}}var ho=function(e){function ArrayCamera(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return Object(f.a)(this,ArrayCamera),(e=Object(s.a)(this,Object(r.a)(ArrayCamera).call(this))).isArrayCamera=!0,e.cameras=t,e}return Object(u.a)(ArrayCamera,e),ArrayCamera}(ha),fo=function(e){function Group(){var e;return Object(f.a)(this,Group),(e=Object(s.a)(this,Object(r.a)(Group).call(this))).isGroup=!0,e.type="Group",e}return Object(u.a)(Group,e),Group}(ai),po={type:"move"},mo=function(){function WebXRController(){Object(f.a)(this,WebXRController),this._targetRay=null,this._grip=null,this._hand=null}return Object(p.a)(WebXRController,[{key:"getHandSpace",value:function getHandSpace(){return null===this._hand&&(this._hand=new fo,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}},{key:"getTargetRaySpace",value:function getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new fo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ir,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ir),this._targetRay}},{key:"getGripSpace",value:function getGripSpace(){return null===this._grip&&(this._grip=new fo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ir,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ir),this._grip}},{key:"dispatchEvent",value:function dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}},{key:"disconnect",value:function disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}},{key:"update",value:function update(e,t,n){var r=null,i=null,a=null,o=this._targetRay,s=this._grip,u=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(u&&e.hand){a=!0;var l=!0,c=!1,h=void 0;try{for(var d,f=e.hand.values()[Symbol.iterator]();!(l=(d=f.next()).done);l=!0){var p=d.value,m=t.getJointPose(p,n);if(void 0===u.joints[p.jointName]){var v=new fo;v.matrixAutoUpdate=!1,v.visible=!1,u.joints[p.jointName]=v,u.add(v)}var g=u.joints[p.jointName];null!==m&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.jointRadius=m.radius),g.visible=null!==m}}catch(_){c=!0,h=_}finally{try{l||null==f.return||f.return()}finally{if(c)throw h}}var y=u.joints["index-finger-tip"],b=u.joints["thumb-tip"],x=y.position.distanceTo(b.position);u.inputState.pinching&&x>.025?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&x<=.015&&(u.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&null!==(i=t.getPose(e.gripSpace,n))&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1);null!==o&&(null===(r=t.getPose(e.targetRaySpace,n))&&null!==i&&(r=i),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(po)))}return null!==o&&(o.visible=null!==r),null!==s&&(s.visible=null!==i),null!==u&&(u.visible=null!==a),this}}]),WebXRController}(),vo=function(e){function DepthTexture(e,t,n,i,a,o,u,l,c,h){var d;if(Object(f.a)(this,DepthTexture),(h=void 0!==h?h:Qe)!==Qe&&h!==$e)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");return void 0===n&&h===Qe&&(n=Ge),void 0===n&&h===$e&&(n=qe),(d=Object(s.a)(this,Object(r.a)(DepthTexture).call(this,null,i,a,o,u,l,h,n,c))).isDepthTexture=!0,d.image={width:e,height:t},d.magFilter=void 0!==u?u:Ae,d.minFilter=void 0!==l?l:Ae,d.flipY=!1,d.generateMipmaps=!1,d}return Object(u.a)(DepthTexture,e),DepthTexture}(Yn),go=function(e){function WebXRManager(e,t){var n;Object(f.a)(this,WebXRManager),n=Object(s.a)(this,Object(r.a)(WebXRManager).call(this));var i=Object(l.a)(Object(l.a)(n)),a=null,o=1,u=null,c="local-floor",h=null,p=null,m=null,v=null,g=null,y=null,b=t.getContextAttributes(),x=null,_=null,M=[],S=[],w=new ha;w.layers.enable(1),w.viewport=new Zn;var T=new ha;T.layers.enable(2),T.viewport=new Zn;var A=[w,T],O=new ho;O.layers.enable(1),O.layers.enable(2);var C=null,L=null;function onSessionEvent(e){var t=S.indexOf(e.inputSource);if(-1!==t){var n=M[t];void 0!==n&&n.dispatchEvent({type:e.type,data:e.inputSource})}}function onSessionEnd(){a.removeEventListener("select",onSessionEvent),a.removeEventListener("selectstart",onSessionEvent),a.removeEventListener("selectend",onSessionEvent),a.removeEventListener("squeeze",onSessionEvent),a.removeEventListener("squeezestart",onSessionEvent),a.removeEventListener("squeezeend",onSessionEvent),a.removeEventListener("end",onSessionEnd),a.removeEventListener("inputsourceschange",onInputSourcesChange);for(var t=0;t=0&&(S[r]=null,M[r].dispatchEvent({type:"disconnected",data:n}))}for(var i=0;i=S.length){S.push(a),o=s;break}if(null===S[s]){S[s]=a,o=s;break}}if(-1===o)break}var u=M[o];u&&u.dispatchEvent({type:"connected",data:a})}}n.cameraAutoUpdate=!0,n.enabled=!1,n.isPresenting=!1,n.getController=function(e){var t=M[e];return void 0===t&&(t=new mo,M[e]=t),t.getTargetRaySpace()},n.getControllerGrip=function(e){var t=M[e];return void 0===t&&(t=new mo,M[e]=t),t.getGripSpace()},n.getHand=function(e){var t=M[e];return void 0===t&&(t=new mo,M[e]=t),t.getHandSpace()},n.setFramebufferScaleFactor=function(e){o=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},n.setReferenceSpaceType=function(e){c=e,!0===i.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},n.getReferenceSpace=function(){return h||u},n.setReferenceSpace=function(e){h=e},n.getBaseLayer=function(){return null!==v?v:g},n.getBinding=function(){return m},n.getFrame=function(){return y},n.getSession=function(){return a},n.setSession=function(){var n=_asyncToGenerator(d.a.mark(function _callee(n){var r,s,l,f,p;return d.a.wrap(function _callee$(d){for(;;)switch(d.prev=d.next){case 0:if(null===(a=n)){d.next=25;break}if(x=e.getRenderTarget(),a.addEventListener("select",onSessionEvent),a.addEventListener("selectstart",onSessionEvent),a.addEventListener("selectend",onSessionEvent),a.addEventListener("squeeze",onSessionEvent),a.addEventListener("squeezestart",onSessionEvent),a.addEventListener("squeezeend",onSessionEvent),a.addEventListener("end",onSessionEnd),a.addEventListener("inputsourceschange",onInputSourcesChange),!0===b.xrCompatible){d.next=14;break}return d.next=14,t.makeXRCompatible();case 14:return void 0===a.renderState.layers||!1===e.capabilities.isWebGL2?(r={antialias:void 0!==a.renderState.layers||b.antialias,alpha:b.alpha,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:o},g=new XRWebGLLayer(a,t,r),a.updateRenderState({baseLayer:g}),_=new Kn(g.framebufferWidth,g.framebufferHeight,{format:Ye,type:je,encoding:e.outputEncoding})):(s=null,l=null,f=null,b.depth&&(f=b.stencil?35056:33190,s=b.stencil?$e:Qe,l=b.stencil?qe:Ge),p={colorFormat:32856,depthFormat:f,scaleFactor:o},m=new XRWebGLBinding(a,t),v=m.createProjectionLayer(p),a.updateRenderState({layers:[v]}),_=new Kn(v.textureWidth,v.textureHeight,{format:Ye,type:je,depthTexture:new vo(v.textureWidth,v.textureHeight,l,void 0,void 0,void 0,void 0,void 0,void 0,s),stencilBuffer:b.stencil,encoding:e.outputEncoding,samples:b.antialias?4:0}),e.properties.get(_).__ignoreDepthValues=v.ignoreDepthValues),_.isXRRenderTarget=!0,this.setFoveation(1),h=null,d.next=20,a.requestReferenceSpace(c);case 20:u=d.sent,R.setContext(a),R.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"});case 25:case"end":return d.stop()}},_callee,this)}));return function(e){return n.apply(this,arguments)}}();var k=new ir,E=new ir;function updateCamera(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}n.updateCamera=function(e){if(null!==a){O.near=T.near=w.near=e.near,O.far=T.far=w.far=e.far,C===O.near&&L===O.far||(a.updateRenderState({depthNear:O.near,depthFar:O.far}),C=O.near,L=O.far);var t=e.parent,n=O.cameras;updateCamera(O,t);for(var r=0;r0&&(n.alphaTest.value=r.alphaTest);var i,a,o=t.get(r).envMap;if(o&&(n.envMap.value=o,n.flipEnvMap.value=o.isCubeTexture&&!1===o.isRenderTargetTexture?-1:1,n.reflectivity.value=r.reflectivity,n.ior.value=r.ior,n.refractionRatio.value=r.refractionRatio),r.lightMap){n.lightMap.value=r.lightMap;var s=!0!==e.physicallyCorrectLights?Math.PI:1;n.lightMapIntensity.value=r.lightMapIntensity*s}r.aoMap&&(n.aoMap.value=r.aoMap,n.aoMapIntensity.value=r.aoMapIntensity),r.map?i=r.map:r.specularMap?i=r.specularMap:r.displacementMap?i=r.displacementMap:r.normalMap?i=r.normalMap:r.bumpMap?i=r.bumpMap:r.roughnessMap?i=r.roughnessMap:r.metalnessMap?i=r.metalnessMap:r.alphaMap?i=r.alphaMap:r.emissiveMap?i=r.emissiveMap:r.clearcoatMap?i=r.clearcoatMap:r.clearcoatNormalMap?i=r.clearcoatNormalMap:r.clearcoatRoughnessMap?i=r.clearcoatRoughnessMap:r.iridescenceMap?i=r.iridescenceMap:r.iridescenceThicknessMap?i=r.iridescenceThicknessMap:r.specularIntensityMap?i=r.specularIntensityMap:r.specularColorMap?i=r.specularColorMap:r.transmissionMap?i=r.transmissionMap:r.thicknessMap?i=r.thicknessMap:r.sheenColorMap?i=r.sheenColorMap:r.sheenRoughnessMap&&(i=r.sheenRoughnessMap),void 0!==i&&(i.isWebGLRenderTarget&&(i=i.texture),!0===i.matrixAutoUpdate&&i.updateMatrix(),n.uvTransform.value.copy(i.matrix)),r.aoMap?a=r.aoMap:r.lightMap&&(a=r.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),n.uv2Transform.value.copy(a.matrix))}return{refreshFogUniforms:function refreshFogUniforms(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function refreshMaterialUniforms(e,n,r,i,a){n.isMeshBasicMaterial?refreshUniformsCommon(e,n):n.isMeshLambertMaterial?refreshUniformsCommon(e,n):n.isMeshToonMaterial?(refreshUniformsCommon(e,n),function refreshUniformsToon(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,n)):n.isMeshPhongMaterial?(refreshUniformsCommon(e,n),function refreshUniformsPhong(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,n)):n.isMeshStandardMaterial?(refreshUniformsCommon(e,n),function refreshUniformsStandard(e,n){e.roughness.value=n.roughness,e.metalness.value=n.metalness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap),t.get(n).envMap&&(e.envMapIntensity.value=n.envMapIntensity)}(e,n),n.isMeshPhysicalMaterial&&function refreshUniformsPhysical(e,t,n){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap)),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,t.side===C&&e.clearcoatNormalScale.value.negate())),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap)),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=n.texture,e.transmissionSamplerSize.value.set(n.width,n.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap)}(e,n,a)):n.isMeshMatcapMaterial?(refreshUniformsCommon(e,n),function refreshUniformsMatcap(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,n)):n.isMeshDepthMaterial?refreshUniformsCommon(e,n):n.isMeshDistanceMaterial?(refreshUniformsCommon(e,n),function refreshUniformsDistance(e,t){e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance}(e,n)):n.isMeshNormalMaterial?refreshUniformsCommon(e,n):n.isLineBasicMaterial?(function refreshUniformsLine(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,n),n.isLineDashedMaterial&&function refreshUniformsDash(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,n)):n.isPointsMaterial?function refreshUniformsPoints(e,t,n,r){var i;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*r,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest),t.map?i=t.map:t.alphaMap&&(i=t.alphaMap),void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),e.uvTransform.value.copy(i.matrix))}(e,n,r,i):n.isSpriteMaterial?function refreshUniformsSprites(e,t){var n;e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map),t.alphaMap&&(e.alphaMap.value=t.alphaMap),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest),t.map?n=t.map:t.alphaMap&&(n=t.alphaMap),void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(e,n):n.isShadowMaterial?(e.color.value.copy(n.color),e.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function WebGLUniformsGroups(e,t,n,r){var i={},a={},o=[],s=n.isWebGL2?e.getParameter(35375):0;function hasUniformChanged(e,t,n){var r=e.value;if(void 0===n[t])return n[t]="number"===typeof r?r:r.clone(),!0;if("number"===typeof r){if(n[t]!==r)return n[t]=r,!0}else{var i=n[t];if(!1===i.equals(r))return i.copy(r),!0}return!1}function getUniformSize(e){var t=e.value,n={boundary:0,storage:0};return"number"===typeof t?(n.boundary=4,n.storage=4):t.isVector2?(n.boundary=8,n.storage=8):t.isVector3||t.isColor?(n.boundary=16,n.storage=12):t.isVector4?(n.boundary=16,n.storage=16):t.isMatrix3?(n.boundary=48,n.storage=48):t.isMatrix4?(n.boundary=64,n.storage=64):t.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",t),n}function onUniformsGroupsDispose(t){var n=t.target;n.removeEventListener("dispose",onUniformsGroupsDispose);var r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}return{bind:function bind(e,t){var n=t.program;r.uniformBlockBinding(e,n)},update:function update(n,u){var l=i[n.id];void 0===l&&(function prepareUniformsGroup(e){for(var t=e.uniforms,n=0,r=0,i=0,a=t.length;i0){var u=16-(r=n%16);0!==r&&u-s.boundary<0&&(n+=16-r,o.__offset=n)}n+=s.storage}return(r=n%16)>0&&(n+=16-r),e.__size=n,e.__cache={},this}(n),l=function createBuffer(t){var n=function allocateBindingPointIndex(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:{};this.isWebGLRenderer=!0;var t,n=void 0!==e.canvas?e.canvas:function createCanvasElement(){var e=createElementNS("canvas");return e.style.display="block",e}(),r=void 0!==e.context?e.context:null,i=void 0===e.depth||e.depth,a=void 0===e.stencil||e.stencil,o=void 0!==e.antialias&&e.antialias,s=void 0===e.premultipliedAlpha||e.premultipliedAlpha,u=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,l=void 0!==e.powerPreference?e.powerPreference:"default",c=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;t=null!==r?r.getContextAttributes().alpha:void 0!==e.alpha&&e.alpha;var h=null,d=null,f=[],p=[];this.domElement=n,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=Ht,this.physicallyCorrectLights=!1,this.toneMapping=he,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function get(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function set(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});var v=this,g=!1,y=0,b=0,x=null,_=-1,M=null,S=new Zn,w=new Zn,T=null,A=n.width,k=n.height,E=1,P=null,R=null,I=new Zn(0,0,A,k),D=new Zn(0,0,A,k),j=!1,B=new Sa,N=!1,z=!1,F=null,G=new Ir,U=new Dn,V=new ir,W={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function getTargetPixelRatio(){return null===x?E:1}var H,q,X,J,Y,Z,K,Q,$,ee,te,ne,re,ie,ae,oe,se,ue,le,ce,de,fe,pe,me,ve=r;function getContext(e,t){for(var r=0;r0&&void 0!==arguments[0])||arguments[0])&&(e|=16384),(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&(e|=256),(!(arguments.length>2&&void 0!==arguments[2])||arguments[2])&&(e|=1024),ve.clear(e)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",onContextLost,!1),n.removeEventListener("webglcontextrestored",onContextRestore,!1),n.removeEventListener("webglcontextcreationerror",onContextCreationError,!1),ie.dispose(),ae.dispose(),Y.dispose(),K.dispose(),Q.dispose(),te.dispose(),pe.dispose(),me.dispose(),ne.dispose(),be.dispose(),be.removeEventListener("sessionstart",onXRSessionStart),be.removeEventListener("sessionend",onXRSessionEnd),F&&(F.dispose(),F=null),_e.stop()},this.renderBufferDirect=function(e,t,n,r,i,a){null===t&&(t=W);var o=i.isMesh&&i.matrixWorld.determinant()<0,s=function setProgram(e,t,n,r,i){!0!==t.isScene&&(t=W);Z.resetTextureUnits();var a=t.fog,o=r.isMeshStandardMaterial?t.environment:null,s=null===x?v.outputEncoding:!0===x.isXRRenderTarget?x.texture.encoding:Ht,u=(r.isMeshStandardMaterial?Q:K).get(r.envMap||o),l=!0===r.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,c=!!r.normalMap&&!!n.attributes.tangent,h=!!n.morphAttributes.position,f=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,m=r.toneMapped?v.toneMapping:he,g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,y=void 0!==g?g.length:0,b=Y.get(r),S=d.state.lights;if(!0===N&&(!0===z||e!==M)){var w=e===M&&r.id===_;oe.setState(r,e,w)}var T=!1;r.version===b.__version?b.needsLights&&b.lightsStateVersion!==S.state.version?T=!0:b.outputEncoding!==s?T=!0:i.isInstancedMesh&&!1===b.instancing?T=!0:i.isInstancedMesh||!0!==b.instancing?i.isSkinnedMesh&&!1===b.skinning?T=!0:i.isSkinnedMesh||!0!==b.skinning?b.envMap!==u?T=!0:!0===r.fog&&b.fog!==a?T=!0:void 0===b.numClippingPlanes||b.numClippingPlanes===oe.numPlanes&&b.numIntersection===oe.numIntersection?b.vertexAlphas!==l?T=!0:b.vertexTangents!==c?T=!0:b.morphTargets!==h?T=!0:b.morphNormals!==f?T=!0:b.morphColors!==p?T=!0:b.toneMapping!==m?T=!0:!0===q.isWebGL2&&b.morphTargetsCount!==y&&(T=!0):T=!0:T=!0:T=!0:(T=!0,b.__version=r.version);var A=b.currentProgram;!0===T&&(A=getProgram(r,t,i));var O=!1,C=!1,L=!1,P=A.getUniforms(),R=b.uniforms;X.useProgram(A.program)&&(O=!0,C=!0,L=!0);r.id!==_&&(_=r.id,C=!0);if(O||M!==e){if(P.setValue(ve,"projectionMatrix",e.projectionMatrix),q.logarithmicDepthBuffer&&P.setValue(ve,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),M!==e&&(M=e,C=!0,L=!0),r.isShaderMaterial||r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshStandardMaterial||r.envMap){var I=P.map.cameraPosition;void 0!==I&&I.setValue(ve,V.setFromMatrixPosition(e.matrixWorld))}(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&P.setValue(ve,"isOrthographic",!0===e.isOrthographicCamera),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial||r.isShadowMaterial||i.isSkinnedMesh)&&P.setValue(ve,"viewMatrix",e.matrixWorldInverse)}if(i.isSkinnedMesh){P.setOptional(ve,i,"bindMatrix"),P.setOptional(ve,i,"bindMatrixInverse");var D=i.skeleton;D&&(q.floatVertexTextures?(null===D.boneTexture&&D.computeBoneTexture(),P.setValue(ve,"boneTexture",D.boneTexture,Z),P.setValue(ve,"boneTextureSize",D.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}var j=n.morphAttributes;(void 0!==j.position||void 0!==j.normal||void 0!==j.color&&!0===q.isWebGL2)&&le.update(i,n,r,A);(C||b.receiveShadow!==i.receiveShadow)&&(b.receiveShadow=i.receiveShadow,P.setValue(ve,"receiveShadow",i.receiveShadow));C&&(P.setValue(ve,"toneMappingExposure",v.toneMappingExposure),b.needsLights&&function markUniformsLightsNeedsUpdate(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}(R,L),a&&!0===r.fog&&re.refreshFogUniforms(R,a),re.refreshMaterialUniforms(R,r,E,k,F),Qa.upload(ve,b.uniformsList,R,Z));r.isShaderMaterial&&!0===r.uniformsNeedUpdate&&(Qa.upload(ve,b.uniformsList,R,Z),r.uniformsNeedUpdate=!1);r.isSpriteMaterial&&P.setValue(ve,"center",i.center);if(P.setValue(ve,"modelViewMatrix",i.modelViewMatrix),P.setValue(ve,"normalMatrix",i.normalMatrix),P.setValue(ve,"modelMatrix",i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial)for(var B=r.uniformsGroups,G=0,U=B.length;G0&&function renderTransmissionPass(e,t,n){var r=q.isWebGL2;null===F&&(F=new Kn(1,1,{generateMipmaps:!0,type:H.has("EXT_color_buffer_half_float")?Ve:je,minFilter:Ie,samples:r&&!0===o?4:0}));v.getDrawingBufferSize(U),r?F.setSize(U.x,U.y):F.setSize(floorPowerOfTwo(U.x),floorPowerOfTwo(U.y));var i=v.getRenderTarget();v.setRenderTarget(F),v.clear();var a=v.toneMapping;v.toneMapping=he,renderObjects(e,t,n),v.toneMapping=a,Z.updateMultisampleRenderTarget(F),Z.updateRenderTargetMipmap(F),v.setRenderTarget(i)}(i,t,n),r&&X.viewport(S.copy(r)),i.length>0&&renderObjects(i,t,n),a.length>0&&renderObjects(a,t,n),s.length>0&&renderObjects(s,t,n),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function renderObjects(e,t,n){for(var r=!0===t.isScene?t.overrideMaterial:null,i=0,a=e.length;i0?p[p.length-1]:null,f.pop(),h=f.length>0?f[f.length-1]:null}}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return x},this.setRenderTargetTextures=function(e,t,n){Y.get(e.texture).__webglTexture=t,Y.get(e.depthTexture).__webglTexture=n;var r=Y.get(e);r.__hasExternalTextures=!0,r.__hasExternalTextures&&(r.__autoAllocateDepthBuffer=void 0===n,r.__autoAllocateDepthBuffer||!0===H.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),r.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){var n=Y.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;x=e,y=t,b=n;var r=!0;if(e){var i=Y.get(e);void 0!==i.__useDefaultFramebuffer?(X.bindFramebuffer(36160,null),r=!1):void 0===i.__webglFramebuffer?Z.setupRenderTarget(e):i.__hasExternalTextures&&Z.rebindTextures(e,Y.get(e.texture).__webglTexture,Y.get(e.depthTexture).__webglTexture)}var a=null,o=!1,s=!1;if(e){var u=e.texture;(u.isData3DTexture||u.isDataArrayTexture)&&(s=!0);var l=Y.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(a=l[t],o=!0):a=q.isWebGL2&&e.samples>0&&!1===Z.useMultisampledRTT(e)?Y.get(e).__webglMultisampledFramebuffer:l,S.copy(e.viewport),w.copy(e.scissor),T=e.scissorTest}else S.copy(I).multiplyScalar(E).floor(),w.copy(D).multiplyScalar(E).floor(),T=j;if(X.bindFramebuffer(36160,a)&&q.drawBuffers&&r&&X.drawBuffers(e,a),X.viewport(S),X.scissor(w),X.setScissorTest(T),o){var c=Y.get(e.texture);ve.framebufferTexture2D(36160,36064,34069+t,c.__webglTexture,n)}else if(s){var h=Y.get(e.texture),d=t||0;ve.framebufferTextureLayer(36160,36064,h.__webglTexture,n||0,d)}_=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o){if(e&&e.isWebGLRenderTarget){var s=Y.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==o&&(s=s[o]),s){X.bindFramebuffer(36160,s);try{var u=e.texture,l=u.format,c=u.type;if(l!==Ye&&fe.convert(l)!==ve.getParameter(35739))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");var h=c===Ve&&(H.has("EXT_color_buffer_half_float")||q.isWebGL2&&H.has("EXT_color_buffer_float"));if(c!==je&&fe.convert(c)!==ve.getParameter(35738)&&(c!==Ue||!(q.isWebGL2||H.has("OES_texture_float")||H.has("WEBGL_color_buffer_float")))&&!h)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&ve.readPixels(t,n,r,i,fe.convert(l),fe.convert(c),a)}finally{var d=null!==x?Y.get(x).__webglFramebuffer:null;X.bindFramebuffer(36160,d)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")},this.copyFramebufferToTexture=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=Math.pow(2,-n),i=Math.floor(t.image.width*r),a=Math.floor(t.image.height*r);Z.setTexture2D(t,0),ve.copyTexSubImage2D(3553,n,0,0,e.x,e.y,i,a),X.unbindTexture()},this.copyTextureToTexture=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,i=t.image.width,a=t.image.height,o=fe.convert(n.format),s=fe.convert(n.type);Z.setTexture2D(n,0),ve.pixelStorei(37440,n.flipY),ve.pixelStorei(37441,n.premultiplyAlpha),ve.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?ve.texSubImage2D(3553,r,e.x,e.y,i,a,o,s,t.image.data):t.isCompressedTexture?ve.compressedTexSubImage2D(3553,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):ve.texSubImage2D(3553,r,e.x,e.y,o,s,t.image),0===r&&n.generateMipmaps&&ve.generateMipmap(3553),X.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(v.isWebGL1Renderer)console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");else{var a,o=e.max.x-e.min.x+1,s=e.max.y-e.min.y+1,u=e.max.z-e.min.z+1,l=fe.convert(r.format),c=fe.convert(r.type);if(r.isData3DTexture)Z.setTexture3D(r,0),a=32879;else{if(!r.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Z.setTexture2DArray(r,0),a=35866}ve.pixelStorei(37440,r.flipY),ve.pixelStorei(37441,r.premultiplyAlpha),ve.pixelStorei(3317,r.unpackAlignment);var h=ve.getParameter(3314),d=ve.getParameter(32878),f=ve.getParameter(3316),p=ve.getParameter(3315),m=ve.getParameter(32877),g=n.isCompressedTexture?n.mipmaps[0]:n.image;ve.pixelStorei(3314,g.width),ve.pixelStorei(32878,g.height),ve.pixelStorei(3316,e.min.x),ve.pixelStorei(3315,e.min.y),ve.pixelStorei(32877,e.min.z),n.isDataTexture||n.isData3DTexture?ve.texSubImage3D(a,i,t.x,t.y,t.z,o,s,u,l,c,g.data):n.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ve.compressedTexSubImage3D(a,i,t.x,t.y,t.z,o,s,u,l,g.data)):ve.texSubImage3D(a,i,t.x,t.y,t.z,o,s,u,l,c,g),ve.pixelStorei(3314,h),ve.pixelStorei(32878,d),ve.pixelStorei(3316,f),ve.pixelStorei(3315,p),ve.pixelStorei(32877,m),0===i&&r.generateMipmaps&&ve.generateMipmap(a),X.unbindTexture()}},this.initTexture=function(e){e.isCubeTexture?Z.setTextureCube(e,0):e.isData3DTexture?Z.setTexture3D(e,0):e.isDataArrayTexture?Z.setTexture2DArray(e,0):Z.setTexture2D(e,0),X.unbindTexture()},this.resetState=function(){y=0,b=0,x=null,X.reset(),pe.reset()},"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}var yo=function(e){function WebGL1Renderer(){return Object(f.a)(this,WebGL1Renderer),Object(s.a)(this,Object(r.a)(WebGL1Renderer).apply(this,arguments))}return Object(u.a)(WebGL1Renderer,e),WebGL1Renderer}(WebGLRenderer);yo.prototype.isWebGL1Renderer=!0;var bo,xo=function(){function FogExp2(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:25e-5;Object(f.a)(this,FogExp2),this.isFogExp2=!0,this.name="",this.color=new Hn(e),this.density=t}return Object(p.a)(FogExp2,[{key:"clone",value:function clone(){return new FogExp2(this.color,this.density)}},{key:"toJSON",value:function toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}]),FogExp2}(),_o=function(){function Fog(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;Object(f.a)(this,Fog),this.isFog=!0,this.name="",this.color=new Hn(e),this.near=t,this.far=n}return Object(p.a)(Fog,[{key:"clone",value:function clone(){return new Fog(this.color,this.near,this.far)}},{key:"toJSON",value:function toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}]),Fog}(),Mo=function(e){function Scene(){var e;return Object(f.a)(this,Scene),(e=Object(s.a)(this,Object(r.a)(Scene).call(this))).isScene=!0,e.type="Scene",e.background=null,e.environment=null,e.fog=null,e.overrideMaterial=null,e.autoUpdate=!0,"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:Object(l.a)(Object(l.a)(e))})),e}return Object(u.a)(Scene,e),Object(p.a)(Scene,[{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(Scene.prototype),"copy",this).call(this,e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}},{key:"toJSON",value:function toJSON(e){var t=Object(o.a)(Object(r.a)(Scene.prototype),"toJSON",this).call(this,e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}}]),Scene}(ai),So=function(){function InterleavedBuffer(e,t){Object(f.a)(this,InterleavedBuffer),this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=gn,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=generateUUID()}return Object(p.a)(InterleavedBuffer,[{key:"onUploadCallback",value:function onUploadCallback(){}},{key:"setUsage",value:function setUsage(e){return this.usage=e,this}},{key:"copy",value:function copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}},{key:"copyAt",value:function copyAt(e,t,n){e*=this.stride,n*=t.stride;for(var r=0,i=this.stride;r1&&void 0!==arguments[1]?arguments[1]:0;return this.array.set(e,t),this}},{key:"clone",value:function clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);var t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}},{key:"onUpload",value:function onUpload(e){return this.onUploadCallback=e,this}},{key:"toJSON",value:function toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=generateUUID()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}},{key:"needsUpdate",set:function set(e){!0===e&&this.version++}}]),InterleavedBuffer}(),wo=new ir,To=function(){function InterleavedBufferAttribute(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Object(f.a)(this,InterleavedBufferAttribute),this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=!0===r}return Object(p.a)(InterleavedBufferAttribute,[{key:"applyMatrix4",value:function applyMatrix4(e){for(var t=0,n=this.data.count;te.far||t.push({distance:s,point:Oo.clone(),uv:vi.getUV(Oo,Ro,Io,Do,jo,Bo,No,new Dn),face:null,object:this})}}},{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(Sprite.prototype),"copy",this).call(this,e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}]),Sprite}(ai);function transformVertex(e,t,n,r,i,a){ko.subVectors(e,n).addScalar(.5).multiply(r),void 0!==i?(Eo.x=a*ko.x-i*ko.y,Eo.y=i*ko.x+a*ko.y):Eo.copy(ko),e.copy(t),e.x+=Eo.x,e.y+=Eo.y,e.applyMatrix4(Po)}var Fo=new ir,Go=new ir,Uo=function(e){function LOD(){var e;return Object(f.a)(this,LOD),(e=Object(s.a)(this,Object(r.a)(LOD).call(this)))._currentLevel=0,e.type="LOD",Object.defineProperties(Object(l.a)(Object(l.a)(e)),{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),e.autoUpdate=!0,e}return Object(u.a)(LOD,e),Object(p.a)(LOD,[{key:"copy",value:function copy(e){Object(o.a)(Object(r.a)(LOD.prototype),"copy",this).call(this,e,!1);for(var t=e.levels,n=0,i=t.length;n1&&void 0!==arguments[1]?arguments[1]:0;t=Math.abs(t);var n,r=this.levels;for(n=0;n0){var n,r;for(n=1,r=t.length;n0){Fo.setFromMatrixPosition(this.matrixWorld);var n=e.ray.origin.distanceTo(Fo);this.getObjectForDistance(n).raycast(e,t)}}},{key:"update",value:function update(e){var t=this.levels;if(t.length>1){Fo.setFromMatrixPosition(e.matrixWorld),Go.setFromMatrixPosition(this.matrixWorld);var n,r,i=Fo.distanceTo(Go)/e.zoom;for(t[0].object.visible=!0,n=1,r=t.length;n=t[n].distance;n++)t[n-1].object.visible=!1,t[n].object.visible=!0;for(this._currentLevel=n-1;n0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,u=arguments.length>5?arguments[5]:void 0,l=arguments.length>6?arguments[6]:void 0,c=arguments.length>7?arguments[7]:void 0,h=arguments.length>8&&void 0!==arguments[8]?arguments[8]:Ae,d=arguments.length>9&&void 0!==arguments[9]?arguments[9]:Ae,p=arguments.length>10?arguments[10]:void 0,m=arguments.length>11?arguments[11]:void 0;return Object(f.a)(this,DataTexture),(e=Object(s.a)(this,Object(r.a)(DataTexture).call(this,null,u,l,c,h,d,a,o,p,m))).isDataTexture=!0,e.image={data:t,width:n,height:i},e.generateMipmaps=!1,e.flipY=!1,e.unpackAlignment=1,e}return Object(u.a)(DataTexture,e),DataTexture}(Yn),Ko=new Ir,Qo=new Ir,$o=function(){function Skeleton(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];Object(f.a)(this,Skeleton),this.uuid=generateUUID(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}return Object(p.a)(Skeleton,[{key:"init",value:function init(){var e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(var n=0,r=this.bones.length;n3&&void 0!==arguments[3]?arguments[3]:1;return Object(f.a)(this,InstancedBufferAttribute),"number"===typeof n&&(a=n,n=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),(i=Object(s.a)(this,Object(r.a)(InstancedBufferAttribute).call(this,e,t,n))).isInstancedBufferAttribute=!0,i.meshPerAttribute=a,i}return Object(u.a)(InstancedBufferAttribute,e),Object(p.a)(InstancedBufferAttribute,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(InstancedBufferAttribute.prototype),"copy",this).call(this,e),this.meshPerAttribute=e.meshPerAttribute,this}},{key:"toJSON",value:function toJSON(){var e=Object(o.a)(Object(r.a)(InstancedBufferAttribute.prototype),"toJSON",this).call(this);return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}]),InstancedBufferAttribute}(Mi),ts=new Ir,ns=new Ir,rs=[],is=new ia,as=function(e){function InstancedMesh(e,t,n){var i;return Object(f.a)(this,InstancedMesh),(i=Object(s.a)(this,Object(r.a)(InstancedMesh).call(this,e,t))).isInstancedMesh=!0,i.instanceMatrix=new es(new Float32Array(16*n),16),i.instanceColor=null,i.count=n,i.frustumCulled=!1,i}return Object(u.a)(InstancedMesh,e),Object(p.a)(InstancedMesh,[{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(InstancedMesh.prototype),"copy",this).call(this,e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}},{key:"getColorAt",value:function getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}},{key:"getMatrixAt",value:function getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}},{key:"raycast",value:function raycast(e,t){var n=this.matrixWorld,r=this.count;if(is.geometry=this.geometry,is.material=this.material,void 0!==is.material)for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:new Fi,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new os;return Object(f.a)(this,Line),(e=Object(s.a)(this,Object(r.a)(Line).call(this))).isLine=!0,e.type="Line",e.geometry=t,e.material=n,e.updateMorphTargets(),e}return Object(u.a)(Line,e),Object(p.a)(Line,[{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(Line.prototype),"copy",this).call(this,e,t),this.material=e.material,this.geometry=e.geometry,this}},{key:"computeLineDistances",value:function computeLineDistances(){var e=this.geometry;if(null===e.index){for(var t=e.attributes.position,n=[0],r=1,i=t.count;rs)){h.applyMatrix4(this.matrixWorld);var b=e.ray.origin.distanceTo(h);be.far||t.push({distance:b,point:c.clone().applyMatrix4(this.matrixWorld),index:m,face:null,faceIndex:null,object:this})}}else for(var x=Math.max(0,a.start),_=Math.min(p.count,a.start+a.count)-1;x<_;x+=d){if(u.fromBufferAttribute(p,x),l.fromBufferAttribute(p,x+1),!(cs.distanceSqToSegment(u,l,h,c)>s)){h.applyMatrix4(this.matrixWorld);var M=e.ray.origin.distanceTo(h);Me.far||t.push({distance:M,point:c.clone().applyMatrix4(this.matrixWorld),index:x,face:null,faceIndex:null,object:this})}}}}},{key:"updateMorphTargets",value:function updateMorphTargets(){var e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){var n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var r=0,i=n.length;r0&&void 0!==arguments[0]?arguments[0]:new Fi,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new gs;return Object(f.a)(this,Points),(e=Object(s.a)(this,Object(r.a)(Points).call(this))).isPoints=!0,e.type="Points",e.geometry=t,e.material=n,e.updateMorphTargets(),e}return Object(u.a)(Points,e),Object(p.a)(Points,[{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(Points.prototype),"copy",this).call(this,e,t),this.material=e.material,this.geometry=e.geometry,this}},{key:"raycast",value:function raycast(e,t){var n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),xs.copy(n.boundingSphere),xs.applyMatrix4(r),xs.radius+=i,!1!==e.ray.intersectsSphere(xs)){ys.copy(r).invert(),bs.copy(e.ray).applyMatrix4(ys);var o=i/((this.scale.x+this.scale.y+this.scale.z)/3),s=o*o,u=n.index,l=n.attributes.position;if(null!==u)for(var c=Math.max(0,a.start),h=Math.min(u.count,a.start+a.count);c0){var n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var r=0,i=n.length;ri.far)return;a.push({distance:l,distanceToRay:Math.sqrt(s),point:u,index:t,face:null,object:o})}}var Ss=function(e){function VideoTexture(e,t,n,i,a,o,u,c,h){var d;Object(f.a)(this,VideoTexture),(d=Object(s.a)(this,Object(r.a)(VideoTexture).call(this,e,t,n,i,a,o,u,c,h))).isVideoTexture=!0,d.minFilter=void 0!==o?o:Ee,d.magFilter=void 0!==a?a:Ee,d.generateMipmaps=!1;var p=Object(l.a)(Object(l.a)(d));return"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(function updateVideo(){p.needsUpdate=!0,e.requestVideoFrameCallback(updateVideo)}),d}return Object(u.a)(VideoTexture,e),Object(p.a)(VideoTexture,[{key:"clone",value:function clone(){return new this.constructor(this.image).copy(this)}},{key:"update",value:function update(){var e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}]),VideoTexture}(Yn),ws=function(e){function FramebufferTexture(e,t,n){var i;return Object(f.a)(this,FramebufferTexture),(i=Object(s.a)(this,Object(r.a)(FramebufferTexture).call(this,{width:e,height:t}))).isFramebufferTexture=!0,i.format=n,i.magFilter=Ae,i.minFilter=Ae,i.generateMipmaps=!1,i.needsUpdate=!0,i}return Object(u.a)(FramebufferTexture,e),FramebufferTexture}(Yn),Ts=function(e){function CompressedTexture(e,t,n,i,a,o,u,l,c,h,d,p){var m;return Object(f.a)(this,CompressedTexture),(m=Object(s.a)(this,Object(r.a)(CompressedTexture).call(this,null,o,u,l,c,h,i,a,d,p))).isCompressedTexture=!0,m.image={width:t,height:n},m.mipmaps=e,m.flipY=!1,m.generateMipmaps=!1,m}return Object(u.a)(CompressedTexture,e),CompressedTexture}(Yn),As=function(e){function CanvasTexture(e,t,n,i,a,o,u,l,c){var h;return Object(f.a)(this,CanvasTexture),(h=Object(s.a)(this,Object(r.a)(CanvasTexture).call(this,e,t,n,i,a,o,u,l,c))).isCanvasTexture=!0,h.needsUpdate=!0,h}return Object(u.a)(CanvasTexture,e),CanvasTexture}(Yn),Os=function(){function Curve(){Object(f.a)(this,Curve),this.type="Curve",this.arcLengthDivisions=200}return Object(p.a)(Curve,[{key:"getPoint",value:function getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}},{key:"getPointAt",value:function getPointAt(e,t){var n=this.getUtoTmapping(e);return this.getPoint(n,t)}},{key:"getPoints",value:function getPoints(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=[],n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}},{key:"getSpacedPoints",value:function getSpacedPoints(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=[],n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}},{key:"getLength",value:function getLength(){var e=this.getLengths();return e[e.length-1]}},{key:"getLengths",value:function getLengths(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.arcLengthDivisions;if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var t,n=[],r=this.getPoint(0),i=0;n.push(0);for(var a=1;a<=e;a++)i+=(t=this.getPoint(a/e)).distanceTo(r),n.push(i),r=t;return this.cacheArcLengths=n,n}},{key:"updateArcLengths",value:function updateArcLengths(){this.needsUpdate=!0,this.getLengths()}},{key:"getUtoTmapping",value:function getUtoTmapping(e,t){var n,r=this.getLengths(),i=0,a=r.length;n=t||e*r[a-1];for(var o,s=0,u=a-1;s<=u;)if((o=r[i=Math.floor(s+(u-s)/2)]-n)<0)s=i+1;else{if(!(o>0)){u=i;break}u=i-1}if(r[i=u]===n)return i/(a-1);var l=r[i];return(i+(n-l)/(r[i+1]-l))/(a-1)}},{key:"getTangent",value:function getTangent(e,t){var n=e-1e-4,r=e+1e-4;n<0&&(n=0),r>1&&(r=1);var i=this.getPoint(n),a=this.getPoint(r),o=t||(i.isVector2?new Dn:new ir);return o.copy(a).sub(i).normalize(),o}},{key:"getTangentAt",value:function getTangentAt(e,t){var n=this.getUtoTmapping(e);return this.getTangent(n,t)}},{key:"computeFrenetFrames",value:function computeFrenetFrames(e,t){for(var n=new ir,r=[],i=[],a=[],o=new ir,s=new Ir,u=0;u<=e;u++){var l=u/e;r[u]=this.getTangentAt(l,new ir)}i[0]=new ir,a[0]=new ir;var c=Number.MAX_VALUE,h=Math.abs(r[0].x),d=Math.abs(r[0].y),f=Math.abs(r[0].z);h<=c&&(c=h,n.set(1,0,0)),d<=c&&(c=d,n.set(0,1,0)),f<=c&&n.set(0,0,1),o.crossVectors(r[0],n).normalize(),i[0].crossVectors(r[0],o),a[0].crossVectors(r[0],i[0]);for(var p=1;p<=e;p++){if(i[p]=i[p-1].clone(),a[p]=a[p-1].clone(),o.crossVectors(r[p-1],r[p]),o.length()>Number.EPSILON){o.normalize();var m=Math.acos(clamp(r[p-1].dot(r[p]),-1,1));i[p].applyMatrix4(s.makeRotationAxis(o,m))}a[p].crossVectors(r[p],i[p])}if(!0===t){var v=Math.acos(clamp(i[0].dot(i[e]),-1,1));v/=e,r[0].dot(o.crossVectors(i[0],i[e]))>0&&(v=-v);for(var g=1;g<=e;g++)i[g].applyMatrix4(s.makeRotationAxis(r[g],v*g)),a[g].crossVectors(r[g],i[g])}return{tangents:r,normals:i,binormals:a}}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}},{key:"copy",value:function copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}},{key:"toJSON",value:function toJSON(){var e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}},{key:"fromJSON",value:function fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}]),Curve}(),Cs=function(e){function EllipseCurve(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2*Math.PI,l=arguments.length>6&&void 0!==arguments[6]&&arguments[6],c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:0;return Object(f.a)(this,EllipseCurve),(e=Object(s.a)(this,Object(r.a)(EllipseCurve).call(this))).isEllipseCurve=!0,e.type="EllipseCurve",e.aX=t,e.aY=n,e.xRadius=i,e.yRadius=a,e.aStartAngle=o,e.aEndAngle=u,e.aClockwise=l,e.aRotation=c,e}return Object(u.a)(EllipseCurve,e),Object(p.a)(EllipseCurve,[{key:"getPoint",value:function getPoint(e,t){for(var n=t||new Dn,r=2*Math.PI,i=this.aEndAngle-this.aStartAngle,a=Math.abs(i)r;)i-=r;i0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"centripetal",a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5;return Object(f.a)(this,CatmullRomCurve3),(e=Object(s.a)(this,Object(r.a)(CatmullRomCurve3).call(this))).isCatmullRomCurve3=!0,e.type="CatmullRomCurve3",e.points=t,e.closed=n,e.curveType=i,e.tension=a,e}return Object(u.a)(CatmullRomCurve3,e),Object(p.a)(CatmullRomCurve3,[{key:"getPoint",value:function getPoint(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,i=this.points,a=i.length,o=(a-(this.closed?0:1))*e,s=Math.floor(o),u=o-s;this.closed?s+=s>0?0:(Math.floor(Math.abs(s)/a)+1)*a:0===u&&s===a-1&&(s=a-2,u=1),this.closed||s>0?t=i[(s-1)%a]:(ks.subVectors(i[0],i[1]).add(i[0]),t=ks);var l=i[s%a],c=i[(s+1)%a];if(this.closed||s+20&&void 0!==arguments[0]?arguments[0]:new Dn,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Dn,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Dn,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Dn;return Object(f.a)(this,CubicBezierCurve),(e=Object(s.a)(this,Object(r.a)(CubicBezierCurve).call(this))).isCubicBezierCurve=!0,e.type="CubicBezierCurve",e.v0=t,e.v1=n,e.v2=i,e.v3=a,e}return Object(u.a)(CubicBezierCurve,e),Object(p.a)(CubicBezierCurve,[{key:"getPoint",value:function getPoint(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Dn,n=this.v0,r=this.v1,i=this.v2,a=this.v3;return t.set(CubicBezier(e,n.x,r.x,i.x,a.x),CubicBezier(e,n.y,r.y,i.y,a.y)),t}},{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(CubicBezierCurve.prototype),"copy",this).call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}},{key:"toJSON",value:function toJSON(){var e=Object(o.a)(Object(r.a)(CubicBezierCurve.prototype),"toJSON",this).call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}},{key:"fromJSON",value:function fromJSON(e){return Object(o.a)(Object(r.a)(CubicBezierCurve.prototype),"fromJSON",this).call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}]),CubicBezierCurve}(Os),js=function(e){function CubicBezierCurve3(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ir,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new ir;return Object(f.a)(this,CubicBezierCurve3),(e=Object(s.a)(this,Object(r.a)(CubicBezierCurve3).call(this))).isCubicBezierCurve3=!0,e.type="CubicBezierCurve3",e.v0=t,e.v1=n,e.v2=i,e.v3=a,e}return Object(u.a)(CubicBezierCurve3,e),Object(p.a)(CubicBezierCurve3,[{key:"getPoint",value:function getPoint(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,n=this.v0,r=this.v1,i=this.v2,a=this.v3;return t.set(CubicBezier(e,n.x,r.x,i.x,a.x),CubicBezier(e,n.y,r.y,i.y,a.y),CubicBezier(e,n.z,r.z,i.z,a.z)),t}},{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(CubicBezierCurve3.prototype),"copy",this).call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}},{key:"toJSON",value:function toJSON(){var e=Object(o.a)(Object(r.a)(CubicBezierCurve3.prototype),"toJSON",this).call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}},{key:"fromJSON",value:function fromJSON(e){return Object(o.a)(Object(r.a)(CubicBezierCurve3.prototype),"fromJSON",this).call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}]),CubicBezierCurve3}(Os),Bs=function(e){function LineCurve(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Dn,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Dn;return Object(f.a)(this,LineCurve),(e=Object(s.a)(this,Object(r.a)(LineCurve).call(this))).isLineCurve=!0,e.type="LineCurve",e.v1=t,e.v2=n,e}return Object(u.a)(LineCurve,e),Object(p.a)(LineCurve,[{key:"getPoint",value:function getPoint(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Dn;return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}},{key:"getPointAt",value:function getPointAt(e,t){return this.getPoint(e,t)}},{key:"getTangent",value:function getTangent(e,t){var n=t||new Dn;return n.copy(this.v2).sub(this.v1).normalize(),n}},{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(LineCurve.prototype),"copy",this).call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}},{key:"toJSON",value:function toJSON(){var e=Object(o.a)(Object(r.a)(LineCurve.prototype),"toJSON",this).call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}},{key:"fromJSON",value:function fromJSON(e){return Object(o.a)(Object(r.a)(LineCurve.prototype),"fromJSON",this).call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}]),LineCurve}(Os),Ns=function(e){function LineCurve3(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir;return Object(f.a)(this,LineCurve3),(e=Object(s.a)(this,Object(r.a)(LineCurve3).call(this))).isLineCurve3=!0,e.type="LineCurve3",e.v1=t,e.v2=n,e}return Object(u.a)(LineCurve3,e),Object(p.a)(LineCurve3,[{key:"getPoint",value:function getPoint(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir;return 1===e?t.copy(this.v2):(t.copy(this.v2).sub(this.v1),t.multiplyScalar(e).add(this.v1)),t}},{key:"getPointAt",value:function getPointAt(e,t){return this.getPoint(e,t)}},{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(LineCurve3.prototype),"copy",this).call(this,e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}},{key:"toJSON",value:function toJSON(){var e=Object(o.a)(Object(r.a)(LineCurve3.prototype),"toJSON",this).call(this);return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}},{key:"fromJSON",value:function fromJSON(e){return Object(o.a)(Object(r.a)(LineCurve3.prototype),"fromJSON",this).call(this,e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}]),LineCurve3}(Os),zs=function(e){function QuadraticBezierCurve(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Dn,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Dn,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Dn;return Object(f.a)(this,QuadraticBezierCurve),(e=Object(s.a)(this,Object(r.a)(QuadraticBezierCurve).call(this))).isQuadraticBezierCurve=!0,e.type="QuadraticBezierCurve",e.v0=t,e.v1=n,e.v2=i,e}return Object(u.a)(QuadraticBezierCurve,e),Object(p.a)(QuadraticBezierCurve,[{key:"getPoint",value:function getPoint(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Dn,n=this.v0,r=this.v1,i=this.v2;return t.set(QuadraticBezier(e,n.x,r.x,i.x),QuadraticBezier(e,n.y,r.y,i.y)),t}},{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(QuadraticBezierCurve.prototype),"copy",this).call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}},{key:"toJSON",value:function toJSON(){var e=Object(o.a)(Object(r.a)(QuadraticBezierCurve.prototype),"toJSON",this).call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}},{key:"fromJSON",value:function fromJSON(e){return Object(o.a)(Object(r.a)(QuadraticBezierCurve.prototype),"fromJSON",this).call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}]),QuadraticBezierCurve}(Os),Fs=function(e){function QuadraticBezierCurve3(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new ir;return Object(f.a)(this,QuadraticBezierCurve3),(e=Object(s.a)(this,Object(r.a)(QuadraticBezierCurve3).call(this))).isQuadraticBezierCurve3=!0,e.type="QuadraticBezierCurve3",e.v0=t,e.v1=n,e.v2=i,e}return Object(u.a)(QuadraticBezierCurve3,e),Object(p.a)(QuadraticBezierCurve3,[{key:"getPoint",value:function getPoint(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir,n=this.v0,r=this.v1,i=this.v2;return t.set(QuadraticBezier(e,n.x,r.x,i.x),QuadraticBezier(e,n.y,r.y,i.y),QuadraticBezier(e,n.z,r.z,i.z)),t}},{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(QuadraticBezierCurve3.prototype),"copy",this).call(this,e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}},{key:"toJSON",value:function toJSON(){var e=Object(o.a)(Object(r.a)(QuadraticBezierCurve3.prototype),"toJSON",this).call(this);return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}},{key:"fromJSON",value:function fromJSON(e){return Object(o.a)(Object(r.a)(QuadraticBezierCurve3.prototype),"fromJSON",this).call(this,e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}]),QuadraticBezierCurve3}(Os),Gs=function(e){function SplineCurve(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return Object(f.a)(this,SplineCurve),(e=Object(s.a)(this,Object(r.a)(SplineCurve).call(this))).isSplineCurve=!0,e.type="SplineCurve",e.points=t,e}return Object(u.a)(SplineCurve,e),Object(p.a)(SplineCurve,[{key:"getPoint",value:function getPoint(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Dn,n=this.points,r=(n.length-1)*e,i=Math.floor(r),a=r-i,o=n[0===i?i:i-1],s=n[i],u=n[i>n.length-2?n.length-1:i+1],l=n[i>n.length-3?n.length-1:i+2];return t.set(CatmullRom(a,o.x,s.x,u.x,l.x),CatmullRom(a,o.y,s.y,u.y,l.y)),t}},{key:"copy",value:function copy(e){Object(o.a)(Object(r.a)(SplineCurve.prototype),"copy",this).call(this,e),this.points=[];for(var t=0,n=e.points.length;t=n){var a=r[i]-n,o=this.curves[i],s=o.getLength(),u=0===s?0:1-a/s;return o.getPointAt(u,t)}i++}return null}},{key:"getLength",value:function getLength(){var e=this.getCurveLengths();return e[e.length-1]}},{key:"updateArcLengths",value:function updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}},{key:"getCurveLengths",value:function getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var e=[],t=0,n=0,r=this.curves.length;n0&&void 0!==arguments[0]?arguments[0]:40,t=[],n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}},{key:"getPoints",value:function getPoints(){for(var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:12,n=[],r=0,i=this.curves;r1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n}},{key:"copy",value:function copy(e){Object(o.a)(Object(r.a)(CurvePath.prototype),"copy",this).call(this,e),this.curves=[];for(var t=0,n=e.curves.length;t0){var l=u.getPoint(0);l.equals(this.currentPoint)||this.lineTo(l.x,l.y)}this.curves.push(u);var c=u.getPoint(1);return this.currentPoint.copy(c),this}},{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(Path.prototype),"copy",this).call(this,e),this.currentPoint.copy(e.currentPoint),this}},{key:"toJSON",value:function toJSON(){var e=Object(o.a)(Object(r.a)(Path.prototype),"toJSON",this).call(this);return e.currentPoint=this.currentPoint.toArray(),e}},{key:"fromJSON",value:function fromJSON(e){return Object(o.a)(Object(r.a)(Path.prototype),"fromJSON",this).call(this,e),this.currentPoint.fromArray(e.currentPoint),this}}]),Path}(Vs),Hs=function(e){function LatheGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[new Dn(0,-.5),new Dn(.5,0),new Dn(0,.5)],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2*Math.PI;Object(f.a)(this,LatheGeometry),(e=Object(s.a)(this,Object(r.a)(LatheGeometry).call(this))).type="LatheGeometry",e.parameters={points:t,segments:n,phiStart:i,phiLength:a},n=Math.floor(n),a=clamp(a,0,2*Math.PI);for(var o=[],u=[],l=[],c=[],h=[],d=1/n,p=new ir,m=new Dn,v=new ir,g=new ir,y=new ir,b=0,x=0,_=0;_<=t.length-1;_++)switch(_){case 0:b=t[_+1].x-t[_].x,x=t[_+1].y-t[_].y,v.x=1*x,v.y=-b,v.z=0*x,y.copy(v),v.normalize(),c.push(v.x,v.y,v.z);break;case t.length-1:c.push(y.x,y.y,y.z);break;default:b=t[_+1].x-t[_].x,x=t[_+1].y-t[_].y,v.x=1*x,v.y=-b,v.z=0*x,g.copy(v),v.x+=y.x,v.y+=y.y,v.z+=y.z,v.normalize(),c.push(v.x,v.y,v.z),y.copy(g)}for(var M=0;M<=n;M++)for(var S=i+M*d*a,w=Math.sin(S),T=Math.cos(S),A=0;A<=t.length-1;A++){p.x=t[A].x*w,p.y=t[A].y,p.z=t[A].x*T,u.push(p.x,p.y,p.z),m.x=M/n,m.y=A/(t.length-1),l.push(m.x,m.y);var O=c[3*A+0]*w,C=c[3*A+1],L=c[3*A+0]*T;h.push(O,C,L)}for(var k=0;k0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8;Object(f.a)(this,CapsuleGeometry);var o=new Ws;return o.absarc(0,-n/2,t,1.5*Math.PI,0),o.absarc(0,n/2,t,0,.5*Math.PI),(e=Object(s.a)(this,Object(r.a)(CapsuleGeometry).call(this,o.getPoints(i),a))).type="CapsuleGeometry",e.parameters={radius:t,height:n,capSegments:i,radialSegments:a},e}return Object(u.a)(CapsuleGeometry,e),Object(p.a)(CapsuleGeometry,null,[{key:"fromJSON",value:function fromJSON(e){return new CapsuleGeometry(e.radius,e.length,e.capSegments,e.radialSegments)}}]),CapsuleGeometry}(Hs),Xs=function(e){function CircleGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2*Math.PI;Object(f.a)(this,CircleGeometry),(e=Object(s.a)(this,Object(r.a)(CircleGeometry).call(this))).type="CircleGeometry",e.parameters={radius:t,segments:n,thetaStart:i,thetaLength:a},n=Math.max(3,n);var o=[],u=[],l=[],c=[],h=new ir,d=new Dn;u.push(0,0,0),l.push(0,0,1),c.push(.5,.5);for(var p=0,m=3;p<=n;p++,m+=3){var v=i+p/n*a;h.x=t*Math.cos(v),h.y=t*Math.sin(v),u.push(h.x,h.y,h.z),l.push(0,0,1),d.x=(u[m]/t+1)/2,d.y=(u[m+1]/t+1)/2,c.push(d.x,d.y)}for(var g=1;g<=n;g++)o.push(g,g+1,0);return e.setIndex(o),e.setAttribute("position",new Ei(u,3)),e.setAttribute("normal",new Ei(l,3)),e.setAttribute("uv",new Ei(c,2)),e}return Object(u.a)(CircleGeometry,e),Object(p.a)(CircleGeometry,null,[{key:"fromJSON",value:function fromJSON(e){return new CircleGeometry(e.radius,e.segments,e.thetaStart,e.thetaLength)}}]),CircleGeometry}(Fi),Js=function(e){function CylinderGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,u=arguments.length>5&&void 0!==arguments[5]&&arguments[5],c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,h=arguments.length>7&&void 0!==arguments[7]?arguments[7]:2*Math.PI;Object(f.a)(this,CylinderGeometry),(e=Object(s.a)(this,Object(r.a)(CylinderGeometry).call(this))).type="CylinderGeometry",e.parameters={radiusTop:t,radiusBottom:n,height:i,radialSegments:a,heightSegments:o,openEnded:u,thetaStart:c,thetaLength:h};var d=Object(l.a)(Object(l.a)(e));a=Math.floor(a),o=Math.floor(o);var p=[],m=[],v=[],g=[],y=0,b=[],x=i/2,_=0;function generateCap(e){for(var r=y,i=new Dn,o=new ir,s=0,u=!0===e?t:n,l=!0===e?1:-1,f=1;f<=a;f++)m.push(0,x*l,0),v.push(0,l,0),g.push(.5,.5),y++;for(var b=y,M=0;M<=a;M++){var S=M/a*h+c,w=Math.cos(S),T=Math.sin(S);o.x=u*T,o.y=x*l,o.z=u*w,m.push(o.x,o.y,o.z),v.push(0,l,0),i.x=.5*w+.5,i.y=.5*T*l+.5,g.push(i.x,i.y),y++}for(var A=0;A0&&generateCap(!0),n>0&&generateCap(!1)),e.setIndex(p),e.setAttribute("position",new Ei(m,3)),e.setAttribute("normal",new Ei(v,3)),e.setAttribute("uv",new Ei(g,2)),e}return Object(u.a)(CylinderGeometry,e),Object(p.a)(CylinderGeometry,null,[{key:"fromJSON",value:function fromJSON(e){return new CylinderGeometry(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}]),CylinderGeometry}(Fi),Ys=function(e){function ConeGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,l=arguments.length>6&&void 0!==arguments[6]?arguments[6]:2*Math.PI;return Object(f.a)(this,ConeGeometry),(e=Object(s.a)(this,Object(r.a)(ConeGeometry).call(this,0,t,n,i,a,o,u,l))).type="ConeGeometry",e.parameters={radius:t,height:n,radialSegments:i,heightSegments:a,openEnded:o,thetaStart:u,thetaLength:l},e}return Object(u.a)(ConeGeometry,e),Object(p.a)(ConeGeometry,null,[{key:"fromJSON",value:function fromJSON(e){return new ConeGeometry(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}]),ConeGeometry}(Js),Zs=function(e){function PolyhedronGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;Object(f.a)(this,PolyhedronGeometry),(e=Object(s.a)(this,Object(r.a)(PolyhedronGeometry).call(this))).type="PolyhedronGeometry",e.parameters={vertices:t,indices:n,radius:i,detail:a};var o=[],u=[];function subdivideFace(e,t,n,r){for(var i=r+1,a=[],o=0;o<=i;o++){a[o]=[];for(var s=e.clone().lerp(n,o/i),u=t.clone().lerp(n,o/i),l=i-o,c=0;c<=l;c++)a[o][c]=0===c&&o===i?s:s.clone().lerp(u,c/l)}for(var h=0;h.9&&a<.1&&(t<.2&&(u[e+0]+=1),n<.2&&(u[e+2]+=1),r<.2&&(u[e+4]+=1))}}()}(),e.setAttribute("position",new Ei(o,3)),e.setAttribute("normal",new Ei(o.slice(),3)),e.setAttribute("uv",new Ei(u,2)),0===a?e.computeVertexNormals():e.normalizeNormals(),e}return Object(u.a)(PolyhedronGeometry,e),Object(p.a)(PolyhedronGeometry,null,[{key:"fromJSON",value:function fromJSON(e){return new PolyhedronGeometry(e.vertices,e.indices,e.radius,e.details)}}]),PolyhedronGeometry}(Fi),Ks=function(e){function DodecahedronGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Object(f.a)(this,DodecahedronGeometry);var i=(1+Math.sqrt(5))/2,a=1/i,o=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-a,-i,0,-a,i,0,a,-i,0,a,i,-a,-i,0,-a,i,0,a,-i,0,a,i,0,-i,0,-a,i,0,-a,-i,0,a,i,0,a];return(e=Object(s.a)(this,Object(r.a)(DodecahedronGeometry).call(this,o,[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,n))).type="DodecahedronGeometry",e.parameters={radius:t,detail:n},e}return Object(u.a)(DodecahedronGeometry,e),Object(p.a)(DodecahedronGeometry,null,[{key:"fromJSON",value:function fromJSON(e){return new DodecahedronGeometry(e.radius,e.detail)}}]),DodecahedronGeometry}(Zs),Qs=new ir,$s=new ir,eu=new ir,tu=new vi,nu=function(e){function EdgesGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(Object(f.a)(this,EdgesGeometry),(e=Object(s.a)(this,Object(r.a)(EdgesGeometry).call(this))).type="EdgesGeometry",e.parameters={geometry:t,thresholdAngle:n},null!==t){for(var i=Math.pow(10,4),a=Math.cos(Pn*n),o=t.getIndex(),u=t.getAttribute("position"),l=o?o.count:u.count,c=[0,0,0],h=["a","b","c"],d=new Array(3),p={},m=[],v=0;v2&&void 0!==arguments[2]?arguments[2]:2,c=t&&t.length,h=c?t[0]*l:e.length,d=linkedList(e,0,h,l,!0),f=[];if(!d||d.next===d.prev)return f;if(c&&(d=function eliminateHoles(e,t,n,r){var i,a,o,s,u,l=[];for(i=0,a=t.length;i80*l){n=i=e[0],r=a=e[1];for(var p=l;pi&&(i=o),s>a&&(a=s);u=0!==(u=Math.max(i-n,a-r))?1/u:0}return earcutLinked(d,f,l,n,r,u),f};function linkedList(e,t,n,r,i){var a,o;if(i===function signedArea(e,t,n,r){for(var i=0,a=t,o=n-r;a0)for(a=t;a=t;a-=r)o=insertNode(a,e[a],e[a+1],o);return o&&equals(o,o.next)&&(removeNode(o),o=o.next),o}function filterPoints(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!equals(r,r.next)&&0!==three_module_area(r.prev,r,r.next))r=r.next;else{if(removeNode(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function earcutLinked(e,t,n,r,i,a,o){if(e){!o&&a&&function indexCurve(e,t,n,r){var i=e;do{null===i.z&&(i.z=zOrder(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function sortLinked(e){var t,n,r,i,a,o,s,u,l=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,s=0,t=0;t0||u>0&&r;)0!==s&&(0===u||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,u--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,l*=2}while(o>1);return e}(i)}(e,r,i,a);for(var s,u,l=e;e.prev!==e.next;)if(s=e.prev,u=e.next,a?isEarHashed(e,r,i,a):isEar(e))t.push(s.i/n),t.push(e.i/n),t.push(u.i/n),removeNode(e),e=u.next,l=u.next;else if((e=u)===l){o?1===o?earcutLinked(e=cureLocalIntersections(filterPoints(e),t,n),t,n,r,i,a,2):2===o&&splitEarcut(e,t,n,r,i,a):earcutLinked(filterPoints(e),t,n,r,i,a,1);break}}}function isEar(e){var t=e.prev,n=e,r=e.next;if(three_module_area(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(pointInTriangle(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&three_module_area(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function isEarHashed(e,t,n,r){var i=e.prev,a=e,o=e.next;if(three_module_area(i,a,o)>=0)return!1;for(var s=i.xa.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,c=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,h=zOrder(s,u,t,n,r),d=zOrder(l,c,t,n,r),f=e.prevZ,p=e.nextZ;f&&f.z>=h&&p&&p.z<=d;){if(f!==e.prev&&f!==e.next&&pointInTriangle(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&three_module_area(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,p!==e.prev&&p!==e.next&&pointInTriangle(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&three_module_area(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;f&&f.z>=h;){if(f!==e.prev&&f!==e.next&&pointInTriangle(i.x,i.y,a.x,a.y,o.x,o.y,f.x,f.y)&&three_module_area(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;p&&p.z<=d;){if(p!==e.prev&&p!==e.next&&pointInTriangle(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&three_module_area(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function cureLocalIntersections(e,t,n){var r=e;do{var i=r.prev,a=r.next.next;!equals(i,a)&&intersects(i,r,r.next,a)&&locallyInside(i,a)&&locallyInside(a,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(a.i/n),removeNode(r),removeNode(r.next),r=e=a),r=r.next}while(r!==e);return filterPoints(r)}function splitEarcut(e,t,n,r,i,a){var o=e;do{for(var s=o.next.next;s!==o.prev;){if(o.i!==s.i&&isValidDiagonal(o,s)){var u=splitPolygon(o,s);return o=filterPoints(o,o.next),u=filterPoints(u,u.next),earcutLinked(o,t,n,r,i,a),void earcutLinked(u,t,n,r,i,a)}s=s.next}o=o.next}while(o!==e)}function compareX(e,t){return e.x-t.x}function eliminateHole(e,t){if(t=function findHoleBridge(e,t){var n,r=t,i=e.x,a=e.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var s=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>o){if(o=s,s===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x=r.x&&r.x>=c&&i!==r.x&&pointInTriangle(an.x||r.x===n.x&§orContainsSector(n,r)))&&(n=r,d=u)),r=r.next}while(r!==l);return n}(e,t)){var n=splitPolygon(t,e);filterPoints(t,t.next),filterPoints(n,n.next)}}function sectorContainsSector(e,t){return three_module_area(e.prev,e,t.prev)<0&&three_module_area(t.next,e,e.next)<0}function zOrder(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function getLeftmost(e){var t=e,n=e;do{(t.x=0&&(e-o)*(r-s)-(n-o)*(t-s)>=0&&(n-o)*(a-s)-(i-o)*(r-s)>=0}function isValidDiagonal(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function intersectsPolygon(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&intersects(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(locallyInside(e,t)&&locallyInside(t,e)&&function middleInside(e,t){var n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!==n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(three_module_area(e.prev,e,t.prev)||three_module_area(e,t.prev,t))||equals(e,t)&&three_module_area(e.prev,e,e.next)>0&&three_module_area(t.prev,t,t.next)>0)}function three_module_area(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function equals(e,t){return e.x===t.x&&e.y===t.y}function intersects(e,t,n,r){var i=sign(three_module_area(e,t,n)),a=sign(three_module_area(e,t,r)),o=sign(three_module_area(n,r,e)),s=sign(three_module_area(n,r,t));return i!==a&&o!==s||(!(0!==i||!onSegment(e,n,t))||(!(0!==a||!onSegment(e,r,t))||(!(0!==o||!onSegment(n,e,r))||!(0!==s||!onSegment(n,t,r)))))}function onSegment(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function sign(e){return e>0?1:e<0?-1:0}function locallyInside(e,t){return three_module_area(e.prev,e,e.next)<0?three_module_area(e,t,e.next)>=0&&three_module_area(e,e.prev,t)>=0:three_module_area(e,t,e.prev)<0||three_module_area(e,e.next,t)<0}function splitPolygon(e,t){var n=new Node(e.i,e.x,e.y),r=new Node(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function insertNode(e,t,n,r){var i=new Node(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function removeNode(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Node(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var au=function(){function ShapeUtils(){Object(f.a)(this,ShapeUtils)}return Object(p.a)(ShapeUtils,null,[{key:"area",value:function area(e){for(var t=e.length,n=0,r=t-1,i=0;i2&&e[t-1].equals(e[0])&&e.pop()}function addContour(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:new ru([new Dn(.5,.5),new Dn(-.5,.5),new Dn(-.5,-.5),new Dn(.5,-.5)]),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object(f.a)(this,ExtrudeGeometry),(e=Object(s.a)(this,Object(r.a)(ExtrudeGeometry).call(this))).type="ExtrudeGeometry",e.parameters={shapes:t,options:n},t=Array.isArray(t)?t:[t];for(var i=Object(l.a)(Object(l.a)(e)),a=[],o=[],u=0,c=t.length;uNumber.EPSILON){var d=Math.sqrt(c),f=Math.sqrt(u*u+l*l),p=t.x-s/d,m=t.y+o/d,v=((n.x-l/f-p)*l-(n.y+u/f-m)*u)/(o*l-s*u),g=(r=p+o*v-e.x)*r+(i=m+s*v-e.y)*i;if(g<=2)return new Dn(r,i);a=Math.sqrt(g/2)}else{var y=!1;o>Number.EPSILON?u>Number.EPSILON&&(y=!0):o<-Number.EPSILON?u<-Number.EPSILON&&(y=!0):Math.sign(s)===Math.sign(l)&&(y=!0),y?(r=-s,i=o,a=Math.sqrt(c)):(r=o,i=s,a=Math.sqrt(c/2))}return new Dn(r/a,i/a)}for(var j=[],B=0,N=k.length,z=N-1,F=B+1;B=0;ve--){for(var ge=ve/b,ye=m*Math.cos(ge*Math.PI/2),be=g*Math.sin(ge*Math.PI/2)+y,xe=0,_e=k.length;xe<_e;xe++){var Me=scalePt2(k[xe],j[xe],be);v(Me.x,Me.y,f+ye)}for(var Se=0,we=T.length;Se=0;){var r=n,i=n-1;i<0&&(i=e.length-1);for(var a=0,o=d+2*b;a0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Object(f.a)(this,IcosahedronGeometry);var i=(1+Math.sqrt(5))/2,a=[-1,i,0,1,i,0,-1,-i,0,1,-i,0,0,-1,i,0,1,i,0,-1,-i,0,1,-i,i,0,-1,i,0,1,-i,0,-1,-i,0,1];return(e=Object(s.a)(this,Object(r.a)(IcosahedronGeometry).call(this,a,[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],t,n))).type="IcosahedronGeometry",e.parameters={radius:t,detail:n},e}return Object(u.a)(IcosahedronGeometry,e),Object(p.a)(IcosahedronGeometry,null,[{key:"fromJSON",value:function fromJSON(e){return new IcosahedronGeometry(e.radius,e.detail)}}]),IcosahedronGeometry}(Zs),lu=function(e){function OctahedronGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Object(f.a)(this,OctahedronGeometry);return(e=Object(s.a)(this,Object(r.a)(OctahedronGeometry).call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],t,n))).type="OctahedronGeometry",e.parameters={radius:t,detail:n},e}return Object(u.a)(OctahedronGeometry,e),Object(p.a)(OctahedronGeometry,null,[{key:"fromJSON",value:function fromJSON(e){return new OctahedronGeometry(e.radius,e.detail)}}]),OctahedronGeometry}(Zs),cu=function(e){function RingGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:2*Math.PI;Object(f.a)(this,RingGeometry),(e=Object(s.a)(this,Object(r.a)(RingGeometry).call(this))).type="RingGeometry",e.parameters={innerRadius:t,outerRadius:n,thetaSegments:i,phiSegments:a,thetaStart:o,thetaLength:u},i=Math.max(3,i);for(var l=[],c=[],h=[],d=[],p=t,m=(n-t)/(a=Math.max(1,a)),v=new ir,g=new Dn,y=0;y<=a;y++){for(var b=0;b<=i;b++){var x=o+b/i*u;v.x=p*Math.cos(x),v.y=p*Math.sin(x),c.push(v.x,v.y,v.z),h.push(0,0,1),g.x=(v.x/n+1)/2,g.y=(v.y/n+1)/2,d.push(g.x,g.y)}p+=m}for(var _=0;_0&&void 0!==arguments[0]?arguments[0]:new ru([new Dn(0,.5),new Dn(-.5,-.5),new Dn(.5,-.5)]),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12;Object(f.a)(this,ShapeGeometry),(e=Object(s.a)(this,Object(r.a)(ShapeGeometry).call(this))).type="ShapeGeometry",e.parameters={shapes:t,curveSegments:n};var i=[],a=[],o=[],u=[],l=0,c=0;if(!1===Array.isArray(t))addShape(t);else for(var h=0;h0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2*Math.PI,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,l=arguments.length>6&&void 0!==arguments[6]?arguments[6]:Math.PI;Object(f.a)(this,SphereGeometry),(e=Object(s.a)(this,Object(r.a)(SphereGeometry).call(this))).type="SphereGeometry",e.parameters={radius:t,widthSegments:n,heightSegments:i,phiStart:a,phiLength:o,thetaStart:u,thetaLength:l},n=Math.max(3,Math.floor(n)),i=Math.max(2,Math.floor(i));for(var c=Math.min(u+l,Math.PI),h=0,d=[],p=new ir,m=new ir,v=[],g=[],y=[],b=[],x=0;x<=i;x++){var _=[],M=x/i,S=0;0==x&&0==u?S=.5/n:x==i&&c==Math.PI&&(S=-.5/n);for(var w=0;w<=n;w++){var T=w/n;p.x=-t*Math.cos(a+T*o)*Math.sin(u+M*l),p.y=t*Math.cos(u+M*l),p.z=t*Math.sin(a+T*o)*Math.sin(u+M*l),g.push(p.x,p.y,p.z),m.copy(p).normalize(),y.push(m.x,m.y,m.z),b.push(T+S,1-M),_.push(h++)}d.push(_)}for(var A=0;A0)&&v.push(C,L,E),(A!==i-1||c0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;Object(f.a)(this,TetrahedronGeometry);return(e=Object(s.a)(this,Object(r.a)(TetrahedronGeometry).call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],t,n))).type="TetrahedronGeometry",e.parameters={radius:t,detail:n},e}return Object(u.a)(TetrahedronGeometry,e),Object(p.a)(TetrahedronGeometry,null,[{key:"fromJSON",value:function fromJSON(e){return new TetrahedronGeometry(e.radius,e.detail)}}]),TetrahedronGeometry}(Zs),pu=function(e){function TorusGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.4,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:6,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2*Math.PI;Object(f.a)(this,TorusGeometry),(e=Object(s.a)(this,Object(r.a)(TorusGeometry).call(this))).type="TorusGeometry",e.parameters={radius:t,tube:n,radialSegments:i,tubularSegments:a,arc:o},i=Math.floor(i),a=Math.floor(a);for(var u=[],l=[],c=[],h=[],d=new ir,p=new ir,m=new ir,v=0;v<=i;v++)for(var g=0;g<=a;g++){var y=g/a*o,b=v/i*Math.PI*2;p.x=(t+n*Math.cos(b))*Math.cos(y),p.y=(t+n*Math.cos(b))*Math.sin(y),p.z=n*Math.sin(b),l.push(p.x,p.y,p.z),d.x=t*Math.cos(y),d.y=t*Math.sin(y),m.subVectors(p,d).normalize(),c.push(m.x,m.y,m.z),h.push(g/a),h.push(v/i)}for(var x=1;x<=i;x++)for(var _=1;_<=a;_++){var M=(a+1)*x+_-1,S=(a+1)*(x-1)+_-1,w=(a+1)*(x-1)+_,T=(a+1)*x+_;u.push(M,S,T),u.push(S,w,T)}return e.setIndex(u),e.setAttribute("position",new Ei(l,3)),e.setAttribute("normal",new Ei(c,3)),e.setAttribute("uv",new Ei(h,2)),e}return Object(u.a)(TorusGeometry,e),Object(p.a)(TorusGeometry,null,[{key:"fromJSON",value:function fromJSON(e){return new TorusGeometry(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}]),TorusGeometry}(Fi),mu=function(e){function TorusKnotGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.4,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:64,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:3;Object(f.a)(this,TorusKnotGeometry),(e=Object(s.a)(this,Object(r.a)(TorusKnotGeometry).call(this))).type="TorusKnotGeometry",e.parameters={radius:t,tube:n,tubularSegments:i,radialSegments:a,p:o,q:u},i=Math.floor(i),a=Math.floor(a);for(var l=[],c=[],h=[],d=[],p=new ir,m=new ir,v=new ir,g=new ir,y=new ir,b=new ir,x=new ir,_=0;_<=i;++_){var M=_/i*o*Math.PI*2;calculatePositionOnCurve(M,o,u,t,v),calculatePositionOnCurve(M+.01,o,u,t,g),b.subVectors(g,v),x.addVectors(g,v),y.crossVectors(b,x),x.crossVectors(y,b),y.normalize(),x.normalize();for(var S=0;S<=a;++S){var w=S/a*Math.PI*2,T=-n*Math.cos(w),A=n*Math.sin(w);p.x=v.x+(T*x.x+A*y.x),p.y=v.y+(T*x.y+A*y.y),p.z=v.z+(T*x.z+A*y.z),c.push(p.x,p.y,p.z),m.subVectors(p,v).normalize(),h.push(m.x,m.y,m.z),d.push(_/i),d.push(S/a)}}for(var O=1;O<=i;O++)for(var C=1;C<=a;C++){var L=(a+1)*(O-1)+(C-1),k=(a+1)*O+(C-1),E=(a+1)*O+C,P=(a+1)*(O-1)+C;l.push(L,k,P),l.push(k,E,P)}function calculatePositionOnCurve(e,t,n,r,i){var a=Math.cos(e),o=Math.sin(e),s=n/t*e,u=Math.cos(s);i.x=r*(2+u)*.5*a,i.y=r*(2+u)*o*.5,i.z=r*Math.sin(s)*.5}return e.setIndex(l),e.setAttribute("position",new Ei(c,3)),e.setAttribute("normal",new Ei(h,3)),e.setAttribute("uv",new Ei(d,2)),e}return Object(u.a)(TorusKnotGeometry,e),Object(p.a)(TorusKnotGeometry,null,[{key:"fromJSON",value:function fromJSON(e){return new TorusKnotGeometry(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}]),TorusKnotGeometry}(Fi),vu=function(e){function TubeGeometry(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Fs(new ir(-1,-1,0),new ir(-1,1,0),new ir(1,1,0)),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];Object(f.a)(this,TubeGeometry),(e=Object(s.a)(this,Object(r.a)(TubeGeometry).call(this))).type="TubeGeometry",e.parameters={path:t,tubularSegments:n,radius:i,radialSegments:a,closed:o};var u=t.computeFrenetFrames(n,o);e.tangents=u.tangents,e.normals=u.normals,e.binormals=u.binormals;var l=new ir,c=new ir,h=new Dn,d=new ir,p=[],m=[],v=[],g=[];function generateSegment(e){d=t.getPointAt(e/n,d);for(var r=u.normals[e],o=u.binormals[e],s=0;s<=a;s++){var h=s/a*Math.PI*2,f=Math.sin(h),v=-Math.cos(h);c.x=v*r.x+f*o.x,c.y=v*r.y+f*o.y,c.z=v*r.z+f*o.z,c.normalize(),m.push(c.x,c.y,c.z),l.x=d.x+i*c.x,l.y=d.y+i*c.y,l.z=d.z+i*c.z,p.push(l.x,l.y,l.z)}}return function generateBufferData(){for(var e=0;e0&&void 0!==arguments[0]?arguments[0]:null;if(Object(f.a)(this,WireframeGeometry),(e=Object(s.a)(this,Object(r.a)(WireframeGeometry).call(this))).type="WireframeGeometry",e.parameters={geometry:t},null!==t){var n=[],i=new Set,a=new ir,o=new ir;if(null!==t.index){var u=t.attributes.position,l=t.index,c=t.groups;0===c.length&&(c=[{start:0,count:l.count,materialIndex:0}]);for(var h=0,d=c.length;h0!==e>0&&this.version++,this._sheen=e}},{key:"clearcoat",get:function get(){return this._clearcoat},set:function set(e){this._clearcoat>0!==e>0&&this.version++,this._clearcoat=e}},{key:"iridescence",get:function get(){return this._iridescence},set:function set(e){this._iridescence>0!==e>0&&this.version++,this._iridescence=e}},{key:"transmission",get:function get(){return this._transmission},set:function set(e){this._transmission>0!==e>0&&this.version++,this._transmission=e}}]),MeshPhysicalMaterial}(_u),Su=function(e){function MeshPhongMaterial(e){var t;return Object(f.a)(this,MeshPhongMaterial),(t=Object(s.a)(this,Object(r.a)(MeshPhongMaterial).call(this))).isMeshPhongMaterial=!0,t.type="MeshPhongMaterial",t.color=new Hn(16777215),t.specular=new Hn(1118481),t.shininess=30,t.map=null,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=null,t.aoMapIntensity=1,t.emissive=new Hn(0),t.emissiveIntensity=1,t.emissiveMap=null,t.bumpMap=null,t.bumpScale=1,t.normalMap=null,t.normalMapType=Yt,t.normalScale=new Dn(1,1),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=null,t.alphaMap=null,t.envMap=null,t.combine=ue,t.reflectivity=1,t.refractionRatio=.98,t.wireframe=!1,t.wireframeLinewidth=1,t.wireframeLinecap="round",t.wireframeLinejoin="round",t.flatShading=!1,t.fog=!0,t.setValues(e),t}return Object(u.a)(MeshPhongMaterial,e),Object(p.a)(MeshPhongMaterial,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(MeshPhongMaterial.prototype),"copy",this).call(this,e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}]),MeshPhongMaterial}(yi),wu=function(e){function MeshToonMaterial(e){var t;return Object(f.a)(this,MeshToonMaterial),(t=Object(s.a)(this,Object(r.a)(MeshToonMaterial).call(this))).isMeshToonMaterial=!0,t.defines={TOON:""},t.type="MeshToonMaterial",t.color=new Hn(16777215),t.map=null,t.gradientMap=null,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=null,t.aoMapIntensity=1,t.emissive=new Hn(0),t.emissiveIntensity=1,t.emissiveMap=null,t.bumpMap=null,t.bumpScale=1,t.normalMap=null,t.normalMapType=Yt,t.normalScale=new Dn(1,1),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.alphaMap=null,t.wireframe=!1,t.wireframeLinewidth=1,t.wireframeLinecap="round",t.wireframeLinejoin="round",t.fog=!0,t.setValues(e),t}return Object(u.a)(MeshToonMaterial,e),Object(p.a)(MeshToonMaterial,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(MeshToonMaterial.prototype),"copy",this).call(this,e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}]),MeshToonMaterial}(yi),Tu=function(e){function MeshNormalMaterial(e){var t;return Object(f.a)(this,MeshNormalMaterial),(t=Object(s.a)(this,Object(r.a)(MeshNormalMaterial).call(this))).isMeshNormalMaterial=!0,t.type="MeshNormalMaterial",t.bumpMap=null,t.bumpScale=1,t.normalMap=null,t.normalMapType=Yt,t.normalScale=new Dn(1,1),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.wireframe=!1,t.wireframeLinewidth=1,t.flatShading=!1,t.setValues(e),t}return Object(u.a)(MeshNormalMaterial,e),Object(p.a)(MeshNormalMaterial,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(MeshNormalMaterial.prototype),"copy",this).call(this,e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}]),MeshNormalMaterial}(yi),Au=function(e){function MeshLambertMaterial(e){var t;return Object(f.a)(this,MeshLambertMaterial),(t=Object(s.a)(this,Object(r.a)(MeshLambertMaterial).call(this))).isMeshLambertMaterial=!0,t.type="MeshLambertMaterial",t.color=new Hn(16777215),t.map=null,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=null,t.aoMapIntensity=1,t.emissive=new Hn(0),t.emissiveIntensity=1,t.emissiveMap=null,t.specularMap=null,t.alphaMap=null,t.envMap=null,t.combine=ue,t.reflectivity=1,t.refractionRatio=.98,t.wireframe=!1,t.wireframeLinewidth=1,t.wireframeLinecap="round",t.wireframeLinejoin="round",t.fog=!0,t.setValues(e),t}return Object(u.a)(MeshLambertMaterial,e),Object(p.a)(MeshLambertMaterial,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(MeshLambertMaterial.prototype),"copy",this).call(this,e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}]),MeshLambertMaterial}(yi),Ou=function(e){function MeshMatcapMaterial(e){var t;return Object(f.a)(this,MeshMatcapMaterial),(t=Object(s.a)(this,Object(r.a)(MeshMatcapMaterial).call(this))).isMeshMatcapMaterial=!0,t.defines={MATCAP:""},t.type="MeshMatcapMaterial",t.color=new Hn(16777215),t.matcap=null,t.map=null,t.bumpMap=null,t.bumpScale=1,t.normalMap=null,t.normalMapType=Yt,t.normalScale=new Dn(1,1),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.alphaMap=null,t.flatShading=!1,t.fog=!0,t.setValues(e),t}return Object(u.a)(MeshMatcapMaterial,e),Object(p.a)(MeshMatcapMaterial,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(MeshMatcapMaterial.prototype),"copy",this).call(this,e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}]),MeshMatcapMaterial}(yi),Cu=function(e){function LineDashedMaterial(e){var t;return Object(f.a)(this,LineDashedMaterial),(t=Object(s.a)(this,Object(r.a)(LineDashedMaterial).call(this))).isLineDashedMaterial=!0,t.type="LineDashedMaterial",t.scale=1,t.dashSize=3,t.gapSize=1,t.setValues(e),t}return Object(u.a)(LineDashedMaterial,e),Object(p.a)(LineDashedMaterial,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(LineDashedMaterial.prototype),"copy",this).call(this,e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}]),LineDashedMaterial}(os);function arraySlice(e,t,n){return isTypedArray(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function convertArray(e,t,n){return!e||!n&&e.constructor===t?e:"number"===typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function getKeyframeOrder(e){for(var t=e.length,n=new Array(t),r=0;r!==t;++r)n[r]=r;return n.sort(function compareTime(t,n){return e[t]-e[n]}),n}function sortedArray(e,t,n){for(var r=e.length,i=new e.constructor(r),a=0,o=0;o!==r;++a)for(var s=n[a]*t,u=0;u!==t;++u)i[o++]=e[s+u];return i}function flattenJSON(e,t,n,r){for(var i=1,a=e[0];void 0!==a&&void 0===a[r];)a=e[i++];if(void 0!==a){var o=a[r];if(void 0!==o)if(Array.isArray(o))do{void 0!==(o=a[r])&&(t.push(a.time),n.push.apply(n,o)),a=e[i++]}while(void 0!==a);else if(void 0!==o.toArray)do{void 0!==(o=a[r])&&(t.push(a.time),o.toArray(n,n.length)),a=e[i++]}while(void 0!==a);else do{void 0!==(o=a[r])&&(t.push(a.time),n.push(o)),a=e[i++]}while(void 0!==a)}}var Lu=Object.freeze({__proto__:null,arraySlice:arraySlice,convertArray:convertArray,isTypedArray:isTypedArray,getKeyframeOrder:getKeyframeOrder,sortedArray:sortedArray,flattenJSON:flattenJSON,subclip:function subclip(e,t,n,r){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:30,a=e.clone();a.name=t;for(var o=[],s=0;s=r)){c.push(u.times[d]);for(var p=0;pa.tracks[v].times[0]&&(m=a.tracks[v].times[0]);for(var g=0;g1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:30;r<=0&&(r=30);for(var i=n.tracks.length,a=t/r,o=function _loop(t){var r=n.tracks[t],i=r.ValueTypeName;if("bool"===i||"string"===i)return"continue";var o=e.tracks.find(function(e){return e.name===r.name&&e.ValueTypeName===i});if(void 0===o)return"continue";var s=0,u=r.getValueSize();r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=u/3);var l=0,c=o.getValueSize();o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(l=c/3);var h=r.times.length-1,d=void 0;if(a<=r.times[0]){var f=s,p=u-s;d=arraySlice(r.values,f,p)}else if(a>=r.times[h]){var m=h*u+s,v=m+u-s;d=arraySlice(r.values,m,v)}else{var g=r.createInterpolant(),y=s,b=u-s;g.evaluate(a),d=arraySlice(g.resultBuffer,y,b)}"quaternion"===i&&(new rr).fromArray(d).normalize().conjugate().toArray(d);for(var x=o.times.length,_=0;_=i)break e;var s=t[1];e=(i=t[--n-1]))break t}a=n,n=0}for(;n>>1;et;)--a;if(++a,0!==i||a!==r){i>=a&&(i=(a=Math.max(a,1))-1);var o=this.getValueSize();this.times=arraySlice(n,i,a),this.values=arraySlice(this.values,i*o,a*o)}return this}},{key:"validate",value:function validate(){var e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);var n=this.times,r=this.values,i=n.length;0===i&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);for(var a=null,o=0;o!==i;o++){var s=n[o];if("number"===typeof s&&isNaN(s)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,s),e=!1;break}if(null!==a&&a>s){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,s,a),e=!1;break}a=s}if(void 0!==r&&isTypedArray(r))for(var u=0,l=r.length;u!==l;++u){var c=r[u];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,u,c),e=!1;break}}return e}},{key:"optimize",value:function optimize(){for(var e=arraySlice(this.times),t=arraySlice(this.values),n=this.getValueSize(),r=this.getInterpolation()===jt,i=e.length-1,a=1,o=1;o0){e[a]=e[i];for(var g=i*n,y=a*n,b=0;b!==n;++b)t[y+b]=t[g+b];++a}return a!==e.length?(this.times=arraySlice(e,0,a),this.values=arraySlice(t,0,a*n)):(this.times=e,this.values=t),this}},{key:"clone",value:function clone(){var e=arraySlice(this.times,0),t=arraySlice(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}],[{key:"toJSON",value:function toJSON(e){var t,n=e.constructor;if(n.toJSON!==this.toJSON)t=n.toJSON(e);else{t={name:e.name,times:convertArray(e.times,Array),values:convertArray(e.values,Array)};var r=e.getInterpolation();r!==e.DefaultInterpolation&&(t.interpolation=r)}return t.type=e.ValueTypeName,t}}]),KeyframeTrack}();Iu.prototype.TimeBufferType=Float32Array,Iu.prototype.ValueBufferType=Float32Array,Iu.prototype.DefaultInterpolation=Dt;var Du=function(e){function BooleanKeyframeTrack(){return Object(f.a)(this,BooleanKeyframeTrack),Object(s.a)(this,Object(r.a)(BooleanKeyframeTrack).apply(this,arguments))}return Object(u.a)(BooleanKeyframeTrack,e),BooleanKeyframeTrack}(Iu);Du.prototype.ValueTypeName="bool",Du.prototype.ValueBufferType=Array,Du.prototype.DefaultInterpolation=It,Du.prototype.InterpolantFactoryMethodLinear=void 0,Du.prototype.InterpolantFactoryMethodSmooth=void 0;var ju=function(e){function ColorKeyframeTrack(){return Object(f.a)(this,ColorKeyframeTrack),Object(s.a)(this,Object(r.a)(ColorKeyframeTrack).apply(this,arguments))}return Object(u.a)(ColorKeyframeTrack,e),ColorKeyframeTrack}(Iu);ju.prototype.ValueTypeName="color";var Bu=function(e){function NumberKeyframeTrack(){return Object(f.a)(this,NumberKeyframeTrack),Object(s.a)(this,Object(r.a)(NumberKeyframeTrack).apply(this,arguments))}return Object(u.a)(NumberKeyframeTrack,e),NumberKeyframeTrack}(Iu);Bu.prototype.ValueTypeName="number";var Nu=function(e){function QuaternionLinearInterpolant(e,t,n,i){return Object(f.a)(this,QuaternionLinearInterpolant),Object(s.a)(this,Object(r.a)(QuaternionLinearInterpolant).call(this,e,t,n,i))}return Object(u.a)(QuaternionLinearInterpolant,e),Object(p.a)(QuaternionLinearInterpolant,[{key:"interpolate_",value:function interpolate_(e,t,n,r){for(var i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),u=e*o,l=u+o;u!==l;u+=4)rr.slerpFlat(i,0,a,u-o,a,u,s);return i}}]),QuaternionLinearInterpolant}(ku),zu=function(e){function QuaternionKeyframeTrack(){return Object(f.a)(this,QuaternionKeyframeTrack),Object(s.a)(this,Object(r.a)(QuaternionKeyframeTrack).apply(this,arguments))}return Object(u.a)(QuaternionKeyframeTrack,e),Object(p.a)(QuaternionKeyframeTrack,[{key:"InterpolantFactoryMethodLinear",value:function InterpolantFactoryMethodLinear(e){return new Nu(this.times,this.values,this.getValueSize(),e)}}]),QuaternionKeyframeTrack}(Iu);zu.prototype.ValueTypeName="quaternion",zu.prototype.DefaultInterpolation=Dt,zu.prototype.InterpolantFactoryMethodSmooth=void 0;var Fu=function(e){function StringKeyframeTrack(){return Object(f.a)(this,StringKeyframeTrack),Object(s.a)(this,Object(r.a)(StringKeyframeTrack).apply(this,arguments))}return Object(u.a)(StringKeyframeTrack,e),StringKeyframeTrack}(Iu);Fu.prototype.ValueTypeName="string",Fu.prototype.ValueBufferType=Array,Fu.prototype.DefaultInterpolation=It,Fu.prototype.InterpolantFactoryMethodLinear=void 0,Fu.prototype.InterpolantFactoryMethodSmooth=void 0;var Gu=function(e){function VectorKeyframeTrack(){return Object(f.a)(this,VectorKeyframeTrack),Object(s.a)(this,Object(r.a)(VectorKeyframeTrack).apply(this,arguments))}return Object(u.a)(VectorKeyframeTrack,e),VectorKeyframeTrack}(Iu);Gu.prototype.ValueTypeName="vector";var Uu=function(){function AnimationClip(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ft;Object(f.a)(this,AnimationClip),this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=generateUUID(),this.duration<0&&this.resetDuration()}return Object(p.a)(AnimationClip,[{key:"resetDuration",value:function resetDuration(){for(var e=0,t=0,n=this.tracks.length;t!==n;++t){var r=this.tracks[t];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this}},{key:"trim",value:function trim(){for(var e=0;e1){var l=u[1],c=r[l];c||(r[l]=c=[]),c.push(s)}}var h=[];for(var d in r)h.push(this.CreateFromMorphTargetSequence(d,r[d],t,n));return h}},{key:"parseAnimation",value:function parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;for(var n=function addNonemptyTrack(e,t,n,r,i){if(0!==n.length){var a=[],o=[];flattenJSON(n,a,o,r),0!==a.length&&i.push(new e(t,a,o))}},r=[],i=e.name||"default",a=e.fps||30,o=e.blendMode,s=e.length||-1,u=e.hierarchy||[],l=0;l1&&void 0!==arguments[1]?arguments[1]:1;return Object(f.a)(this,Light),(t=Object(s.a)(this,Object(r.a)(Light).call(this))).isLight=!0,t.type="Light",t.color=new Hn(e),t.intensity=n,t}return Object(u.a)(Light,e),Object(p.a)(Light,[{key:"dispose",value:function dispose(){}},{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(Light.prototype),"copy",this).call(this,e,t),this.color.copy(e.color),this.intensity=e.intensity,this}},{key:"toJSON",value:function toJSON(e){var t=Object(o.a)(Object(r.a)(Light.prototype),"toJSON",this).call(this,e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}]),Light}(ai),il=function(e){function HemisphereLight(e,t,n){var i;return Object(f.a)(this,HemisphereLight),(i=Object(s.a)(this,Object(r.a)(HemisphereLight).call(this,e,n))).isHemisphereLight=!0,i.type="HemisphereLight",i.position.copy(ai.DefaultUp),i.updateMatrix(),i.groundColor=new Hn(t),i}return Object(u.a)(HemisphereLight,e),Object(p.a)(HemisphereLight,[{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(HemisphereLight.prototype),"copy",this).call(this,e,t),this.groundColor.copy(e.groundColor),this}}]),HemisphereLight}(rl),al=new Ir,ol=new ir,sl=new ir,ul=function(){function LightShadow(e){Object(f.a)(this,LightShadow),this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Dn(512,512),this.map=null,this.mapPass=null,this.matrix=new Ir,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Sa,this._frameExtents=new Dn(1,1),this._viewportCount=1,this._viewports=[new Zn(0,0,1,1)]}return Object(p.a)(LightShadow,[{key:"getViewportCount",value:function getViewportCount(){return this._viewportCount}},{key:"getFrustum",value:function getFrustum(){return this._frustum}},{key:"updateMatrices",value:function updateMatrices(e){var t=this.camera,n=this.matrix;ol.setFromMatrixPosition(e.matrixWorld),t.position.copy(ol),sl.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(sl),t.updateMatrixWorld(),al.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(al),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}},{key:"getViewport",value:function getViewport(e){return this._viewports[e]}},{key:"getFrameExtents",value:function getFrameExtents(){return this._frameExtents}},{key:"dispose",value:function dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}},{key:"copy",value:function copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}},{key:"toJSON",value:function toJSON(){var e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}]),LightShadow}(),ll=function(e){function SpotLightShadow(){var e;return Object(f.a)(this,SpotLightShadow),(e=Object(s.a)(this,Object(r.a)(SpotLightShadow).call(this,new ha(50,1,.5,500)))).isSpotLightShadow=!0,e.focus=1,e}return Object(u.a)(SpotLightShadow,e),Object(p.a)(SpotLightShadow,[{key:"updateMatrices",value:function updateMatrices(e){var t=this.camera,n=2*Rn*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,a=e.distance||t.far;n===t.fov&&i===t.aspect&&a===t.far||(t.fov=n,t.aspect=i,t.far=a,t.updateProjectionMatrix()),Object(o.a)(Object(r.a)(SpotLightShadow.prototype),"updateMatrices",this).call(this,e)}},{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(SpotLightShadow.prototype),"copy",this).call(this,e),this.focus=e.focus,this}}]),SpotLightShadow}(ul),cl=function(e){function SpotLight(e,t){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Math.PI/3,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:1;return Object(f.a)(this,SpotLight),(n=Object(s.a)(this,Object(r.a)(SpotLight).call(this,e,t))).isSpotLight=!0,n.type="SpotLight",n.position.copy(ai.DefaultUp),n.updateMatrix(),n.target=new ai,n.distance=i,n.angle=a,n.penumbra=o,n.decay=u,n.shadow=new ll,n}return Object(u.a)(SpotLight,e),Object(p.a)(SpotLight,[{key:"dispose",value:function dispose(){this.shadow.dispose()}},{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(SpotLight.prototype),"copy",this).call(this,e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}},{key:"power",get:function get(){return this.intensity*Math.PI},set:function set(e){this.intensity=e/Math.PI}}]),SpotLight}(rl),hl=new Ir,dl=new ir,fl=new ir,pl=function(e){function PointLightShadow(){var e;return Object(f.a)(this,PointLightShadow),(e=Object(s.a)(this,Object(r.a)(PointLightShadow).call(this,new ha(90,1,.5,500)))).isPointLightShadow=!0,e._frameExtents=new Dn(4,2),e._viewportCount=6,e._viewports=[new Zn(2,1,1,1),new Zn(0,1,1,1),new Zn(3,1,1,1),new Zn(1,1,1,1),new Zn(3,0,1,1),new Zn(1,0,1,1)],e._cubeDirections=[new ir(1,0,0),new ir(-1,0,0),new ir(0,0,1),new ir(0,0,-1),new ir(0,1,0),new ir(0,-1,0)],e._cubeUps=[new ir(0,1,0),new ir(0,1,0),new ir(0,1,0),new ir(0,1,0),new ir(0,0,1),new ir(0,0,-1)],e}return Object(u.a)(PointLightShadow,e),Object(p.a)(PointLightShadow,[{key:"updateMatrices",value:function updateMatrices(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.camera,r=this.matrix,i=e.distance||n.far;i!==n.far&&(n.far=i,n.updateProjectionMatrix()),dl.setFromMatrixPosition(e.matrixWorld),n.position.copy(dl),fl.copy(n.position),fl.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(fl),n.updateMatrixWorld(),r.makeTranslation(-dl.x,-dl.y,-dl.z),hl.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hl)}}]),PointLightShadow}(ul),ml=function(e){function PointLight(e,t){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return Object(f.a)(this,PointLight),(n=Object(s.a)(this,Object(r.a)(PointLight).call(this,e,t))).isPointLight=!0,n.type="PointLight",n.distance=i,n.decay=a,n.shadow=new pl,n}return Object(u.a)(PointLight,e),Object(p.a)(PointLight,[{key:"dispose",value:function dispose(){this.shadow.dispose()}},{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(PointLight.prototype),"copy",this).call(this,e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}},{key:"power",get:function get(){return 4*this.intensity*Math.PI},set:function set(e){this.intensity=e/(4*Math.PI)}}]),PointLight}(rl),vl=function(e){function DirectionalLightShadow(){var e;return Object(f.a)(this,DirectionalLightShadow),(e=Object(s.a)(this,Object(r.a)(DirectionalLightShadow).call(this,new Ca(-5,5,5,-5,.5,500)))).isDirectionalLightShadow=!0,e}return Object(u.a)(DirectionalLightShadow,e),DirectionalLightShadow}(ul),gl=function(e){function DirectionalLight(e,t){var n;return Object(f.a)(this,DirectionalLight),(n=Object(s.a)(this,Object(r.a)(DirectionalLight).call(this,e,t))).isDirectionalLight=!0,n.type="DirectionalLight",n.position.copy(ai.DefaultUp),n.updateMatrix(),n.target=new ai,n.shadow=new vl,n}return Object(u.a)(DirectionalLight,e),Object(p.a)(DirectionalLight,[{key:"dispose",value:function dispose(){this.shadow.dispose()}},{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(DirectionalLight.prototype),"copy",this).call(this,e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}]),DirectionalLight}(rl),yl=function(e){function AmbientLight(e,t){var n;return Object(f.a)(this,AmbientLight),(n=Object(s.a)(this,Object(r.a)(AmbientLight).call(this,e,t))).isAmbientLight=!0,n.type="AmbientLight",n}return Object(u.a)(AmbientLight,e),AmbientLight}(rl),bl=function(e){function RectAreaLight(e,t){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:10;return Object(f.a)(this,RectAreaLight),(n=Object(s.a)(this,Object(r.a)(RectAreaLight).call(this,e,t))).isRectAreaLight=!0,n.type="RectAreaLight",n.width=i,n.height=a,n}return Object(u.a)(RectAreaLight,e),Object(p.a)(RectAreaLight,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(RectAreaLight.prototype),"copy",this).call(this,e),this.width=e.width,this.height=e.height,this}},{key:"toJSON",value:function toJSON(e){var t=Object(o.a)(Object(r.a)(RectAreaLight.prototype),"toJSON",this).call(this,e);return t.object.width=this.width,t.object.height=this.height,t}},{key:"power",get:function get(){return this.intensity*this.width*this.height*Math.PI},set:function set(e){this.intensity=e/(this.width*this.height*Math.PI)}}]),RectAreaLight}(rl),xl=function(){function SphericalHarmonics3(){Object(f.a)(this,SphericalHarmonics3),this.isSphericalHarmonics3=!0,this.coefficients=[];for(var e=0;e<9;e++)this.coefficients.push(new ir)}return Object(p.a)(SphericalHarmonics3,[{key:"set",value:function set(e){for(var t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}},{key:"zero",value:function zero(){for(var e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}},{key:"getAt",value:function getAt(e,t){var n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*i),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],n*r*1.092548),t.addScaledVector(a[5],r*i*1.092548),t.addScaledVector(a[6],.315392*(3*i*i-1)),t.addScaledVector(a[7],n*i*1.092548),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}},{key:"getIrradianceAt",value:function getIrradianceAt(e,t){var n=e.x,r=e.y,i=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],1.023328*r),t.addScaledVector(a[2],1.023328*i),t.addScaledVector(a[3],1.023328*n),t.addScaledVector(a[4],.858086*n*r),t.addScaledVector(a[5],.858086*r*i),t.addScaledVector(a[6],.743125*i*i-.247708),t.addScaledVector(a[7],.858086*n*i),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}},{key:"add",value:function add(e){for(var t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}},{key:"addScaledSH",value:function addScaledSH(e,t){for(var n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}},{key:"scale",value:function scale(e){for(var t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}},{key:"lerp",value:function lerp(e,t){for(var n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}},{key:"equals",value:function equals(e){for(var t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}},{key:"copy",value:function copy(e){return this.set(e.coefficients)}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}},{key:"fromArray",value:function fromArray(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.coefficients,r=0;r<9;r++)n[r].fromArray(e,t+3*r);return this}},{key:"toArray",value:function toArray(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=this.coefficients,r=0;r<9;r++)n[r].toArray(e,t+3*r);return e}}],[{key:"getBasisAt",value:function getBasisAt(e,t){var n=e.x,r=e.y,i=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*i,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*i,t[6]=.315392*(3*i*i-1),t[7]=1.092548*n*i,t[8]=.546274*(n*n-r*r)}}]),SphericalHarmonics3}(),_l=function(e){function LightProbe(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new xl,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return Object(f.a)(this,LightProbe),(e=Object(s.a)(this,Object(r.a)(LightProbe).call(this,void 0,n))).isLightProbe=!0,e.sh=t,e}return Object(u.a)(LightProbe,e),Object(p.a)(LightProbe,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(LightProbe.prototype),"copy",this).call(this,e),this.sh.copy(e.sh),this}},{key:"fromJSON",value:function fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}},{key:"toJSON",value:function toJSON(e){var t=Object(o.a)(Object(r.a)(LightProbe.prototype),"toJSON",this).call(this,e);return t.object.sh=this.sh.toArray(),t}}]),LightProbe}(rl),Ml=function(e){function MaterialLoader(e){var t;return Object(f.a)(this,MaterialLoader),(t=Object(s.a)(this,Object(r.a)(MaterialLoader).call(this,e))).textures={},t}return Object(u.a)(MaterialLoader,e),Object(p.a)(MaterialLoader,[{key:"load",value:function load(e,t,n,r){var i=this,a=new Zu(i.manager);a.setPath(i.path),a.setRequestHeader(i.requestHeader),a.setWithCredentials(i.withCredentials),a.load(e,function(n){try{t(i.parse(JSON.parse(n)))}catch(a){r?r(a):console.error(a),i.manager.itemError(e)}},n,r)}},{key:"parse",value:function parse(e){var t=this.textures;function getTexture(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}var n=MaterialLoader.createMaterialFromType(e.type);if(void 0!==e.uuid&&(n.uuid=e.uuid),void 0!==e.name&&(n.name=e.name),void 0!==e.color&&void 0!==n.color&&n.color.setHex(e.color),void 0!==e.roughness&&(n.roughness=e.roughness),void 0!==e.metalness&&(n.metalness=e.metalness),void 0!==e.sheen&&(n.sheen=e.sheen),void 0!==e.sheenColor&&(n.sheenColor=(new Hn).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(n.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==n.emissive&&n.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==n.specular&&n.specular.setHex(e.specular),void 0!==e.specularIntensity&&(n.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==n.specularColor&&n.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(n.shininess=e.shininess),void 0!==e.clearcoat&&(n.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(n.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.iridescence&&(n.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(n.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(n.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(n.transmission=e.transmission),void 0!==e.thickness&&(n.thickness=e.thickness),void 0!==e.attenuationDistance&&(n.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==n.attenuationColor&&n.attenuationColor.setHex(e.attenuationColor),void 0!==e.fog&&(n.fog=e.fog),void 0!==e.flatShading&&(n.flatShading=e.flatShading),void 0!==e.blending&&(n.blending=e.blending),void 0!==e.combine&&(n.combine=e.combine),void 0!==e.side&&(n.side=e.side),void 0!==e.shadowSide&&(n.shadowSide=e.shadowSide),void 0!==e.opacity&&(n.opacity=e.opacity),void 0!==e.transparent&&(n.transparent=e.transparent),void 0!==e.alphaTest&&(n.alphaTest=e.alphaTest),void 0!==e.depthTest&&(n.depthTest=e.depthTest),void 0!==e.depthWrite&&(n.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(n.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(n.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(n.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(n.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(n.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(n.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(n.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(n.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(n.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(n.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(n.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(n.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(n.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(n.rotation=e.rotation),1!==e.linewidth&&(n.linewidth=e.linewidth),void 0!==e.dashSize&&(n.dashSize=e.dashSize),void 0!==e.gapSize&&(n.gapSize=e.gapSize),void 0!==e.scale&&(n.scale=e.scale),void 0!==e.polygonOffset&&(n.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(n.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(n.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(n.dithering=e.dithering),void 0!==e.alphaToCoverage&&(n.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(n.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.visible&&(n.visible=e.visible),void 0!==e.toneMapped&&(n.toneMapped=e.toneMapped),void 0!==e.userData&&(n.userData=e.userData),void 0!==e.vertexColors&&("number"===typeof e.vertexColors?n.vertexColors=e.vertexColors>0:n.vertexColors=e.vertexColors),void 0!==e.uniforms)for(var r in e.uniforms){var i=e.uniforms[r];switch(n.uniforms[r]={},i.type){case"t":n.uniforms[r].value=getTexture(i.value);break;case"c":n.uniforms[r].value=(new Hn).setHex(i.value);break;case"v2":n.uniforms[r].value=(new Dn).fromArray(i.value);break;case"v3":n.uniforms[r].value=(new ir).fromArray(i.value);break;case"v4":n.uniforms[r].value=(new Zn).fromArray(i.value);break;case"m3":n.uniforms[r].value=(new jn).fromArray(i.value);break;case"m4":n.uniforms[r].value=(new Ir).fromArray(i.value);break;default:n.uniforms[r].value=i.value}}if(void 0!==e.defines&&(n.defines=e.defines),void 0!==e.vertexShader&&(n.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(n.fragmentShader=e.fragmentShader),void 0!==e.extensions)for(var a in e.extensions)n.extensions[a]=e.extensions[a];if(void 0!==e.shading&&(n.flatShading=1===e.shading),void 0!==e.size&&(n.size=e.size),void 0!==e.sizeAttenuation&&(n.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(n.map=getTexture(e.map)),void 0!==e.matcap&&(n.matcap=getTexture(e.matcap)),void 0!==e.alphaMap&&(n.alphaMap=getTexture(e.alphaMap)),void 0!==e.bumpMap&&(n.bumpMap=getTexture(e.bumpMap)),void 0!==e.bumpScale&&(n.bumpScale=e.bumpScale),void 0!==e.normalMap&&(n.normalMap=getTexture(e.normalMap)),void 0!==e.normalMapType&&(n.normalMapType=e.normalMapType),void 0!==e.normalScale){var o=e.normalScale;!1===Array.isArray(o)&&(o=[o,o]),n.normalScale=(new Dn).fromArray(o)}return void 0!==e.displacementMap&&(n.displacementMap=getTexture(e.displacementMap)),void 0!==e.displacementScale&&(n.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(n.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(n.roughnessMap=getTexture(e.roughnessMap)),void 0!==e.metalnessMap&&(n.metalnessMap=getTexture(e.metalnessMap)),void 0!==e.emissiveMap&&(n.emissiveMap=getTexture(e.emissiveMap)),void 0!==e.emissiveIntensity&&(n.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(n.specularMap=getTexture(e.specularMap)),void 0!==e.specularIntensityMap&&(n.specularIntensityMap=getTexture(e.specularIntensityMap)),void 0!==e.specularColorMap&&(n.specularColorMap=getTexture(e.specularColorMap)),void 0!==e.envMap&&(n.envMap=getTexture(e.envMap)),void 0!==e.envMapIntensity&&(n.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(n.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(n.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(n.lightMap=getTexture(e.lightMap)),void 0!==e.lightMapIntensity&&(n.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(n.aoMap=getTexture(e.aoMap)),void 0!==e.aoMapIntensity&&(n.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(n.gradientMap=getTexture(e.gradientMap)),void 0!==e.clearcoatMap&&(n.clearcoatMap=getTexture(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=getTexture(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(n.clearcoatNormalMap=getTexture(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(n.clearcoatNormalScale=(new Dn).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(n.iridescenceMap=getTexture(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(n.iridescenceThicknessMap=getTexture(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(n.transmissionMap=getTexture(e.transmissionMap)),void 0!==e.thicknessMap&&(n.thicknessMap=getTexture(e.thicknessMap)),void 0!==e.sheenColorMap&&(n.sheenColorMap=getTexture(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(n.sheenRoughnessMap=getTexture(e.sheenRoughnessMap)),n}},{key:"setTextures",value:function setTextures(e){return this.textures=e,this}}],[{key:"createMaterialFromType",value:function createMaterialFromType(e){return new{ShadowMaterial:bu,SpriteMaterial:Ao,RawShaderMaterial:xu,ShaderMaterial:la,PointsMaterial:gs,MeshPhysicalMaterial:Mu,MeshStandardMaterial:_u,MeshPhongMaterial:Su,MeshToonMaterial:wu,MeshNormalMaterial:Tu,MeshLambertMaterial:Au,MeshDepthMaterial:so,MeshDistanceMaterial:uo,MeshBasicMaterial:bi,MeshMatcapMaterial:Ou,LineDashedMaterial:Cu,LineBasicMaterial:os,Material:yi}[e]}}]),MaterialLoader}(Xu),Sl=function(){function LoaderUtils(){Object(f.a)(this,LoaderUtils)}return Object(p.a)(LoaderUtils,null,[{key:"decodeText",value:function decodeText(e){if("undefined"!==typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",n=0,r=e.length;n0){var a=new Hu(t);(n=new $u(a)).setCrossOrigin(this.crossOrigin);for(var o=0,s=e.length;o0)){g.next=33;break}(r=new $u(this.manager)).setCrossOrigin(this.crossOrigin),o=0,s=e.length;case 8:if(!(o2&&void 0!==arguments[2]?arguments[2]:1;Object(f.a)(this,HemisphereLightProbe),(n=Object(s.a)(this,Object(r.a)(HemisphereLightProbe).call(this,void 0,i))).isHemisphereLightProbe=!0;var a=(new Hn).set(e),o=(new Hn).set(t),u=new ir(a.r,a.g,a.b),l=new ir(o.r,o.g,o.b),c=Math.sqrt(Math.PI),h=c*Math.sqrt(.75);return n.sh.coefficients[0].copy(u).add(l).multiplyScalar(c),n.sh.coefficients[1].copy(u).sub(l).multiplyScalar(h),n}return Object(u.a)(HemisphereLightProbe,e),HemisphereLightProbe}(_l),Il=function(e){function AmbientLightProbe(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;Object(f.a)(this,AmbientLightProbe),(t=Object(s.a)(this,Object(r.a)(AmbientLightProbe).call(this,void 0,n))).isAmbientLightProbe=!0;var i=(new Hn).set(e);return t.sh.coefficients[0].set(i.r,i.g,i.b).multiplyScalar(2*Math.sqrt(Math.PI)),t}return Object(u.a)(AmbientLightProbe,e),AmbientLightProbe}(_l),Dl=new Ir,jl=new Ir,Bl=new Ir,Nl=function(){function StereoCamera(){Object(f.a)(this,StereoCamera),this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ha,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ha,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}return Object(p.a)(StereoCamera,[{key:"update",value:function update(e){var t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Bl.copy(e.projectionMatrix);var n,r,i=t.eyeSep/2,a=i*t.near/t.focus,o=t.near*Math.tan(Pn*t.fov*.5)/t.zoom;jl.elements[12]=-i,Dl.elements[12]=i,n=-o*t.aspect+a,r=o*t.aspect+a,Bl.elements[0]=2*t.near/(r-n),Bl.elements[8]=(r+n)/(r-n),this.cameraL.projectionMatrix.copy(Bl),n=-o*t.aspect-a,r=o*t.aspect-a,Bl.elements[0]=2*t.near/(r-n),Bl.elements[8]=(r+n)/(r-n),this.cameraR.projectionMatrix.copy(Bl)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(jl),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(Dl)}}]),StereoCamera}(),zl=function(){function Clock(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];Object(f.a)(this,Clock),this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}return Object(p.a)(Clock,[{key:"start",value:function start(){this.startTime=now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}},{key:"stop",value:function stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}},{key:"getElapsedTime",value:function getElapsedTime(){return this.getDelta(),this.elapsedTime}},{key:"getDelta",value:function getDelta(){var e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var t=now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}]),Clock}();function now(){return("undefined"===typeof performance?Date:performance).now()}var Fl=new ir,Gl=new rr,Ul=new ir,Vl=new ir,Wl=function(e){function AudioListener(){var e;return Object(f.a)(this,AudioListener),(e=Object(s.a)(this,Object(r.a)(AudioListener).call(this))).type="AudioListener",e.context=El.getContext(),e.gain=e.context.createGain(),e.gain.connect(e.context.destination),e.filter=null,e.timeDelta=0,e._clock=new zl,e}return Object(u.a)(AudioListener,e),Object(p.a)(AudioListener,[{key:"getInput",value:function getInput(){return this.gain}},{key:"removeFilter",value:function removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}},{key:"getFilter",value:function getFilter(){return this.filter}},{key:"setFilter",value:function setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}},{key:"getMasterVolume",value:function getMasterVolume(){return this.gain.gain.value}},{key:"setMasterVolume",value:function setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}},{key:"updateMatrixWorld",value:function updateMatrixWorld(e){Object(o.a)(Object(r.a)(AudioListener.prototype),"updateMatrixWorld",this).call(this,e);var t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Fl,Gl,Ul),Vl.set(0,0,-1).applyQuaternion(Gl),t.positionX){var i=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Fl.x,i),t.positionY.linearRampToValueAtTime(Fl.y,i),t.positionZ.linearRampToValueAtTime(Fl.z,i),t.forwardX.linearRampToValueAtTime(Vl.x,i),t.forwardY.linearRampToValueAtTime(Vl.y,i),t.forwardZ.linearRampToValueAtTime(Vl.z,i),t.upX.linearRampToValueAtTime(n.x,i),t.upY.linearRampToValueAtTime(n.y,i),t.upZ.linearRampToValueAtTime(n.z,i)}else t.setPosition(Fl.x,Fl.y,Fl.z),t.setOrientation(Vl.x,Vl.y,Vl.z,n.x,n.y,n.z)}}]),AudioListener}(ai),Hl=function(e){function Audio(e){var t;return Object(f.a)(this,Audio),(t=Object(s.a)(this,Object(r.a)(Audio).call(this))).type="Audio",t.listener=e,t.context=e.context,t.gain=t.context.createGain(),t.gain.connect(e.getInput()),t.autoplay=!1,t.buffer=null,t.detune=0,t.loop=!1,t.loopStart=0,t.loopEnd=0,t.offset=0,t.duration=void 0,t.playbackRate=1,t.isPlaying=!1,t.hasPlaybackControl=!0,t.source=null,t.sourceType="empty",t._startedAt=0,t._progress=0,t._connected=!1,t.filters=[],t}return Object(u.a)(Audio,e),Object(p.a)(Audio,[{key:"getOutput",value:function getOutput(){return this.gain}},{key:"setNodeSource",value:function setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}},{key:"setMediaElementSource",value:function setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}},{key:"setMediaStreamSource",value:function setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}},{key:"setBuffer",value:function setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}},{key:"play",value:function play(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(!0!==this.isPlaying){if(!1!==this.hasPlaybackControl){this._startedAt=this.context.currentTime+e;var t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}console.warn("THREE.Audio: this Audio has no playback control.")}else console.warn("THREE.Audio: Audio is already playing.")}},{key:"pause",value:function pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}},{key:"stop",value:function stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}},{key:"connect",value:function connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(var e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(var e=1,t=this.filters.length;e1&&void 0!==arguments[1]?arguments[1]:2048;Object(f.a)(this,AudioAnalyser),this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}return Object(p.a)(AudioAnalyser,[{key:"getFrequencyData",value:function getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}},{key:"getAverageFrequency",value:function getAverageFrequency(){for(var e=0,t=this.getFrequencyData(),n=0;n0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(var u=t,l=t+t;u!==l;++u)if(n[u]!==n[u+t]){o.setValue(n,r);break}}},{key:"saveOriginalState",value:function saveOriginalState(){var e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(var i=n,a=r;i!==a;++i)t[i]=t[r+i%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}},{key:"restoreOriginalState",value:function restoreOriginalState(){var e=3*this.valueSize;this.binding.setValue(this.buffer,e)}},{key:"_setAdditiveIdentityNumeric",value:function _setAdditiveIdentityNumeric(){for(var e=this._addIndex*this.valueSize,t=e+this.valueSize,n=e;n=.5)for(var a=0;a!==i;++a)e[t+a]=e[n+a]}},{key:"_slerp",value:function _slerp(e,t,n,r){rr.slerpFlat(e,t,e,t,e,n,r)}},{key:"_slerpAdditive",value:function _slerpAdditive(e,t,n,r,i){var a=this._workIndex*i;rr.multiplyQuaternionsFlat(e,a,e,t,e,n),rr.slerpFlat(e,t,e,t,e,a,r)}},{key:"_lerp",value:function _lerp(e,t,n,r,i){for(var a=1-r,o=0;o!==i;++o){var s=t+o;e[s]=e[s]*a+e[n+o]*r}}},{key:"_lerpAdditive",value:function _lerpAdditive(e,t,n,r,i){for(var a=0;a!==i;++a){var o=t+a;e[o]=e[o]+e[n+a]*r}}}]),PropertyMixer}(),$l=new RegExp("[\\[\\]\\.:\\/]","g"),ec="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",tc=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]")+/(WCOD+)?/.source.replace("WCOD",ec)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]")+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]")+"$"),nc=["material","materials","bones"],rc=function(){function Composite(e,t,n){Object(f.a)(this,Composite);var r=n||ic.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}return Object(p.a)(Composite,[{key:"getValue",value:function getValue(e,t){this.bind();var n=this._targetGroup.nCachedObjects_,r=this._bindings[n];void 0!==r&&r.getValue(e,t)}},{key:"setValue",value:function setValue(e,t){for(var n=this._bindings,r=this._targetGroup.nCachedObjects_,i=n.length;r!==i;++r)n[r].setValue(e,t)}},{key:"bind",value:function bind(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}},{key:"unbind",value:function unbind(){for(var e=this._bindings,t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}]),Composite}(),ic=function(){function PropertyBinding(e,t,n){Object(f.a)(this,PropertyBinding),this.path=t,this.parsedPath=n||PropertyBinding.parseTrackName(t),this.node=PropertyBinding.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}return Object(p.a)(PropertyBinding,[{key:"_getValue_unavailable",value:function _getValue_unavailable(){}},{key:"_setValue_unavailable",value:function _setValue_unavailable(){}},{key:"_getValue_direct",value:function _getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}},{key:"_getValue_array",value:function _getValue_array(e,t){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)e[t++]=n[r]}},{key:"_getValue_arrayElement",value:function _getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}},{key:"_getValue_toArray",value:function _getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}},{key:"_setValue_direct",value:function _setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}},{key:"_setValue_direct_setNeedsUpdate",value:function _setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}},{key:"_setValue_direct_setMatrixWorldNeedsUpdate",value:function _setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}},{key:"_setValue_array",value:function _setValue_array(e,t){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)n[r]=e[t++]}},{key:"_setValue_array_setNeedsUpdate",value:function _setValue_array_setNeedsUpdate(e,t){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}},{key:"_setValue_array_setMatrixWorldNeedsUpdate",value:function _setValue_array_setMatrixWorldNeedsUpdate(e,t){for(var n=this.resolvedProperty,r=0,i=n.length;r!==i;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}},{key:"_setValue_arrayElement",value:function _setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}},{key:"_setValue_arrayElement_setNeedsUpdate",value:function _setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}},{key:"_setValue_arrayElement_setMatrixWorldNeedsUpdate",value:function _setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}},{key:"_setValue_fromArray",value:function _setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}},{key:"_setValue_fromArray_setNeedsUpdate",value:function _setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}},{key:"_setValue_fromArray_setMatrixWorldNeedsUpdate",value:function _setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}},{key:"_getValue_unbound",value:function _getValue_unbound(e,t){this.bind(),this.getValue(e,t)}},{key:"_setValue_unbound",value:function _setValue_unbound(e,t){this.bind(),this.setValue(e,t)}},{key:"bind",value:function bind(){var e=this.node,t=this.parsedPath,n=t.objectName,r=t.propertyName,i=t.propertyIndex;if(e||(e=PropertyBinding.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,e){if(n){var a=t.objectIndex;switch(n){case"materials":if(!e.material)return void console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(var o=0;o=i){var c=i++,h=e[c];t[h.uuid]=l,e[l]=h,t[u]=c,e[c]=s;for(var d=0,f=r;d!==f;++d){var p=n[d],m=p[c],v=p[l];p[l]=m,p[c]=v}}}this.nCachedObjects_=i}},{key:"uncache",value:function uncache(){for(var e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length,i=this.nCachedObjects_,a=e.length,o=0,s=arguments.length;o!==s;++o){var u=arguments[o].uuid,l=t[u];if(void 0!==l)if(delete t[u],l0&&(t[x.uuid]=l),e[l]=x,e.pop();for(var _=0,M=r;_!==M;++_){var S=n[_];S[l]=S[b],S.pop()}}}this.nCachedObjects_=i}},{key:"subscribe_",value:function subscribe_(e,t){var n=this._bindingsIndicesByPath,r=n[e],i=this._bindings;if(void 0!==r)return i[r];var a=this._paths,o=this._parsedPaths,s=this._objects,u=s.length,l=this.nCachedObjects_,c=new Array(u);r=i.length,n[e]=r,a.push(e),o.push(t),i.push(c);for(var h=l,d=s.length;h!==d;++h){var f=s[h];c[h]=new ic(f,e,t)}return c}},{key:"unsubscribe_",value:function unsubscribe_(e){var t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){var r=this._paths,i=this._parsedPaths,a=this._bindings,o=a.length-1,s=a[o];t[e[o]]=n,a[n]=s,a.pop(),i[n]=i[o],i.pop(),r[n]=r[o],r.pop()}}}]),AnimationObjectGroup}(),oc=function(){function AnimationAction(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.blendMode;Object(f.a)(this,AnimationAction),this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;for(var i=t.tracks,a=i.length,o=new Array(a),s={endingStart:Bt,endingEnd:Bt},u=0;u!==a;++u){var l=i[u].createInterpolant(null);o[u]=l,l.settings=s}this._interpolantSettings=s,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Pt,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}return Object(p.a)(AnimationAction,[{key:"play",value:function play(){return this._mixer._activateAction(this),this}},{key:"stop",value:function stop(){return this._mixer._deactivateAction(this),this.reset()}},{key:"reset",value:function reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}},{key:"isRunning",value:function isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}},{key:"isScheduled",value:function isScheduled(){return this._mixer._isActiveAction(this)}},{key:"startAt",value:function startAt(e){return this._startTime=e,this}},{key:"setLoop",value:function setLoop(e,t){return this.loop=e,this.repetitions=t,this}},{key:"setEffectiveWeight",value:function setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}},{key:"getEffectiveWeight",value:function getEffectiveWeight(){return this._effectiveWeight}},{key:"fadeIn",value:function fadeIn(e){return this._scheduleFading(e,0,1)}},{key:"fadeOut",value:function fadeOut(e){return this._scheduleFading(e,1,0)}},{key:"crossFadeFrom",value:function crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){var r=this._clip.duration,i=e._clip.duration,a=i/r,o=r/i;e.warp(1,a,t),this.warp(o,1,t)}return this}},{key:"crossFadeTo",value:function crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}},{key:"stopFading",value:function stopFading(){var e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}},{key:"setEffectiveTimeScale",value:function setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}},{key:"getEffectiveTimeScale",value:function getEffectiveTimeScale(){return this._effectiveTimeScale}},{key:"setDuration",value:function setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}},{key:"syncWith",value:function syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}},{key:"halt",value:function halt(e){return this.warp(this._effectiveTimeScale,0,e)}},{key:"warp",value:function warp(e,t,n){var r=this._mixer,i=r.time,a=this.timeScale,o=this._timeScaleInterpolant;null===o&&(o=r._lendControlInterpolant(),this._timeScaleInterpolant=o);var s=o.parameterPositions,u=o.sampleValues;return s[0]=i,s[1]=i+n,u[0]=e/a,u[1]=t/a,this}},{key:"stopWarping",value:function stopWarping(){var e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}},{key:"getMixer",value:function getMixer(){return this._mixer}},{key:"getClip",value:function getClip(){return this._clip}},{key:"getRoot",value:function getRoot(){return this._localRoot||this._mixer._root}},{key:"_update",value:function _update(e,t,n,r){if(this.enabled){var i=this._startTime;if(null!==i){var a=(e-i)*n;if(a<0||0===n)return;this._startTime=null,t=n*a}t*=this._updateTimeScale(e);var o=this._updateTime(t),s=this._updateWeight(e);if(s>0){var u=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case Gt:for(var c=0,h=u.length;c!==h;++c)u[c].evaluate(o),l[c].accumulateAdditive(s);break;case Ft:default:for(var d=0,f=u.length;d!==f;++d)u[d].evaluate(o),l[d].accumulate(r,s)}}}else this._updateWeight(e)}},{key:"_updateWeight",value:function _updateWeight(e){var t=0;if(this.enabled){t=this.weight;var n=this._weightInterpolant;if(null!==n){var r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),0===r&&(this.enabled=!1))}}return this._effectiveWeight=t,t}},{key:"_updateTimeScale",value:function _updateTimeScale(e){var t=0;if(!this.paused){t=this.timeScale;var n=this._timeScaleInterpolant;if(null!==n)t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}return this._effectiveTimeScale=t,t}},{key:"_updateTime",value:function _updateTime(e){var t=this._clip.duration,n=this.loop,r=this.time+e,i=this._loopCount,a=n===Rt;if(0===e)return-1===i?r:a&&1===(1&i)?t-r:r;if(n===Et){-1===i&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else{if(!(r<0)){this.time=r;break e}r=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===i&&(e>=0?(i=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),r>=t||r<0){var o=Math.floor(r/t);r-=t*o,i+=Math.abs(o);var s=this.repetitions-i;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){var u=e<0;this._setEndings(u,!u,a)}else this._setEndings(!1,!1,a);this._loopCount=i,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=r;if(a&&1===(1&i))return t-r}return r}},{key:"_setEndings",value:function _setEndings(e,t,n){var r=this._interpolantSettings;n?(r.endingStart=Nt,r.endingEnd=Nt):(r.endingStart=e?this.zeroSlopeAtStart?Nt:Bt:zt,r.endingEnd=t?this.zeroSlopeAtEnd?Nt:Bt:zt)}},{key:"_scheduleFading",value:function _scheduleFading(e,t,n){var r=this._mixer,i=r.time,a=this._weightInterpolant;null===a&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);var o=a.parameterPositions,s=a.sampleValues;return o[0]=i,s[0]=t,o[1]=i+e,s[1]=n,this}}]),AnimationAction}(),sc=new Float32Array(1),uc=function(e){function AnimationMixer(e){var t;return Object(f.a)(this,AnimationMixer),(t=Object(s.a)(this,Object(r.a)(AnimationMixer).call(this)))._root=e,t._initMemoryManager(),t._accuIndex=0,t.time=0,t.timeScale=1,t}return Object(u.a)(AnimationMixer,e),Object(p.a)(AnimationMixer,[{key:"_bindAction",value:function _bindAction(e,t){var n=e._localRoot||this._root,r=e._clip.tracks,i=r.length,a=e._propertyBindings,o=e._interpolants,s=n.uuid,u=this._bindingsByRootAndName,l=u[s];void 0===l&&(l={},u[s]=l);for(var c=0;c!==i;++c){var h=r[c],d=h.name,f=l[d];if(void 0!==f)++f.referenceCount,a[c]=f;else{if(void 0!==(f=a[c])){null===f._cacheIndex&&(++f.referenceCount,this._addInactiveBinding(f,s,d));continue}var p=t&&t._propertyBindings[c].binding.parsedPath;++(f=new Ql(ic.create(n,d,p),h.ValueTypeName,h.getValueSize())).referenceCount,this._addInactiveBinding(f,s,d),a[c]=f}o[c].resultBuffer=f.buffer}}},{key:"_activateAction",value:function _activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){var t=(e._localRoot||this._root).uuid,n=e._clip.uuid,r=this._actionsByClip[n];this._bindAction(e,r&&r.knownActions[0]),this._addInactiveAction(e,n,t)}for(var i=e._propertyBindings,a=0,o=i.length;a!==o;++a){var s=i[a];0===s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}},{key:"_deactivateAction",value:function _deactivateAction(e){if(this._isActiveAction(e)){for(var t=e._propertyBindings,n=0,r=t.length;n!==r;++n){var i=t[n];0===--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(e)}}},{key:"_initMemoryManager",value:function _initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;var e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}},{key:"_isActiveAction",value:function _isActiveAction(e){var t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}},{key:"update",value:function update(e){e*=this.timeScale;for(var t=this._actions,n=this._nActiveActions,r=this.time+=e,i=Math.sign(e),a=this._accuIndex^=1,o=0;o!==n;++o){t[o]._update(r,e,i,a)}for(var s=this._bindings,u=this._nActiveBindings,l=0;l!==u;++l)s[l].apply(a);return this}},{key:"setTime",value:function setTime(e){this.time=0;for(var t=0;t2&&void 0!==arguments[2]?arguments[2]:1;return Object(f.a)(this,InstancedInterleavedBuffer),(n=Object(s.a)(this,Object(r.a)(InstancedInterleavedBuffer).call(this,e,t))).isInstancedInterleavedBuffer=!0,n.meshPerAttribute=i,n}return Object(u.a)(InstancedInterleavedBuffer,e),Object(p.a)(InstancedInterleavedBuffer,[{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(InstancedInterleavedBuffer.prototype),"copy",this).call(this,e),this.meshPerAttribute=e.meshPerAttribute,this}},{key:"clone",value:function clone(e){var t=Object(o.a)(Object(r.a)(InstancedInterleavedBuffer.prototype),"clone",this).call(this,e);return t.meshPerAttribute=this.meshPerAttribute,t}},{key:"toJSON",value:function toJSON(e){var t=Object(o.a)(Object(r.a)(InstancedInterleavedBuffer.prototype),"toJSON",this).call(this,e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}]),InstancedInterleavedBuffer}(So),fc=function(){function GLBufferAttribute(e,t,n,r,i){Object(f.a)(this,GLBufferAttribute),this.isGLBufferAttribute=!0,this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=i,this.version=0}return Object(p.a)(GLBufferAttribute,[{key:"setBuffer",value:function setBuffer(e){return this.buffer=e,this}},{key:"setType",value:function setType(e,t){return this.type=e,this.elementSize=t,this}},{key:"setItemSize",value:function setItemSize(e){return this.itemSize=e,this}},{key:"setCount",value:function setCount(e){return this.count=e,this}},{key:"needsUpdate",set:function set(e){!0===e&&this.version++}}]),GLBufferAttribute}(),pc=function(){function Raycaster(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0;Object(f.a)(this,Raycaster),this.ray=new Rr(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Hr,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}return Object(p.a)(Raycaster,[{key:"set",value:function set(e,t){this.ray.set(e,t)}},{key:"setFromCamera",value:function setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}},{key:"intersectObject",value:function intersectObject(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return _intersectObject(e,this,n,t),n.sort(ascSort),n}},{key:"intersectObjects",value:function intersectObjects(e){for(var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],r=0,i=e.length;r0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Object(f.a)(this,Spherical),this.radius=e,this.phi=t,this.theta=n,this}return Object(p.a)(Spherical,[{key:"set",value:function set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}},{key:"copy",value:function copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}},{key:"makeSafe",value:function makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}},{key:"setFromVector3",value:function setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}},{key:"setFromCartesianCoords",value:function setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(clamp(t/this.radius,-1,1))),this}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}}]),Spherical}(),vc=function(){function Cylindrical(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Object(f.a)(this,Cylindrical),this.radius=e,this.theta=t,this.y=n,this}return Object(p.a)(Cylindrical,[{key:"set",value:function set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}},{key:"copy",value:function copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}},{key:"setFromVector3",value:function setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}},{key:"setFromCartesianCoords",value:function setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}}]),Cylindrical}(),gc=new Dn,yc=function(){function Box2(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Dn(1/0,1/0),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Dn(-1/0,-1/0);Object(f.a)(this,Box2),this.isBox2=!0,this.min=e,this.max=t}return Object(p.a)(Box2,[{key:"set",value:function set(e,t){return this.min.copy(e),this.max.copy(t),this}},{key:"setFromPoints",value:function setFromPoints(e){this.makeEmpty();for(var t=0,n=e.length;tthis.max.x||e.ythis.max.y)}},{key:"containsBox",value:function containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}},{key:"getParameter",value:function getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}},{key:"intersectsBox",value:function intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}},{key:"clampPoint",value:function clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}},{key:"distanceToPoint",value:function distanceToPoint(e){return gc.copy(e).clamp(this.min,this.max).sub(e).length()}},{key:"intersect",value:function intersect(e){return this.min.max(e.min),this.max.min(e.max),this}},{key:"union",value:function union(e){return this.min.min(e.min),this.max.max(e.max),this}},{key:"translate",value:function translate(e){return this.min.add(e),this.max.add(e),this}},{key:"equals",value:function equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}]),Box2}(),bc=new ir,xc=new ir,_c=function(){function Line3(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir;Object(f.a)(this,Line3),this.start=e,this.end=t}return Object(p.a)(Line3,[{key:"set",value:function set(e,t){return this.start.copy(e),this.end.copy(t),this}},{key:"copy",value:function copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}},{key:"getCenter",value:function getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}},{key:"delta",value:function delta(e){return e.subVectors(this.end,this.start)}},{key:"distanceSq",value:function distanceSq(){return this.start.distanceToSquared(this.end)}},{key:"distance",value:function distance(){return this.start.distanceTo(this.end)}},{key:"at",value:function at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}},{key:"closestPointToPointParameter",value:function closestPointToPointParameter(e,t){bc.subVectors(e,this.start),xc.subVectors(this.end,this.start);var n=xc.dot(xc),r=xc.dot(bc)/n;return t&&(r=clamp(r,0,1)),r}},{key:"closestPointToPoint",value:function closestPointToPoint(e,t,n){var r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}},{key:"applyMatrix4",value:function applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}},{key:"equals",value:function equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}},{key:"clone",value:function clone(){return(new this.constructor).copy(this)}}]),Line3}(),Mc=new ir,Sc=function(e){function SpotLightHelper(e,t){var n;Object(f.a)(this,SpotLightHelper),(n=Object(s.a)(this,Object(r.a)(SpotLightHelper).call(this))).light=e,n.light.updateMatrixWorld(),n.matrix=e.matrixWorld,n.matrixAutoUpdate=!1,n.color=t;for(var i=new Fi,a=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1],o=0,u=1;o<32;o++,u++){var l=o/32*Math.PI*2,c=u/32*Math.PI*2;a.push(Math.cos(l),Math.sin(l),1,Math.cos(c),Math.sin(c),1)}i.setAttribute("position",new Ei(a,3));var h=new os({fog:!1,toneMapped:!1});return n.cone=new ms(i,h),n.add(n.cone),n.update(),n}return Object(u.a)(SpotLightHelper,e),Object(p.a)(SpotLightHelper,[{key:"dispose",value:function dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}},{key:"update",value:function update(){this.light.updateMatrixWorld();var e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Mc.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Mc),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}]),SpotLightHelper}(ai),wc=new ir,Tc=new Ir,Ac=new Ir,Oc=function(e){function SkeletonHelper(e){var t;Object(f.a)(this,SkeletonHelper);for(var n=function getBoneList(e){var t=[];!0===e.isBone&&t.push(e);for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:10,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:4473924,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8947848;Object(f.a)(this,GridHelper),i=new Hn(i),a=new Hn(a);for(var o=n/2,u=t/n,l=t/2,c=[],h=[],d=0,p=0,m=-l;d<=n;d++,m+=u){c.push(-l,0,m,l,0,m),c.push(m,0,-l,m,0,l);var v=d===o?i:a;v.toArray(h,p),p+=3,v.toArray(h,p),p+=3,v.toArray(h,p),p+=3,v.toArray(h,p),p+=3}var g=new Fi;g.setAttribute("position",new Ei(c,3)),g.setAttribute("color",new Ei(h,3));var y=new os({vertexColors:!0,toneMapped:!1});return(e=Object(s.a)(this,Object(r.a)(GridHelper).call(this,g,y))).type="GridHelper",e}return Object(u.a)(GridHelper,e),GridHelper}(ms),Ic=function(e){function PolarGridHelper(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:64,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:4473924,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:8947848;Object(f.a)(this,PolarGridHelper),o=new Hn(o),u=new Hn(u);for(var l=[],c=[],h=0;h<=n;h++){var d=h/n*(2*Math.PI),p=Math.sin(d)*t,m=Math.cos(d)*t;l.push(0,0,0),l.push(p,0,m);var v=1&h?o:u;c.push(v.r,v.g,v.b),c.push(v.r,v.g,v.b)}for(var g=0;g<=i;g++)for(var y=1&g?o:u,b=t-t/i*g,x=0;x1&&void 0!==arguments[1]?arguments[1]:16776960;Object(f.a)(this,BoxHelper);var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),a=new Float32Array(24),o=new Fi;return o.setIndex(new Mi(i,1)),o.setAttribute("position",new Mi(a,3)),(t=Object(s.a)(this,Object(r.a)(BoxHelper).call(this,o,new os({color:n,toneMapped:!1})))).object=e,t.type="BoxHelper",t.matrixAutoUpdate=!1,t.update(),t}return Object(u.a)(BoxHelper,e),Object(p.a)(BoxHelper,[{key:"update",value:function update(e){if(void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&Wc.setFromObject(this.object),!Wc.isEmpty()){var t=Wc.min,n=Wc.max,r=this.geometry.attributes.position,i=r.array;i[0]=n.x,i[1]=n.y,i[2]=n.z,i[3]=t.x,i[4]=n.y,i[5]=n.z,i[6]=t.x,i[7]=t.y,i[8]=n.z,i[9]=n.x,i[10]=t.y,i[11]=n.z,i[12]=n.x,i[13]=n.y,i[14]=t.z,i[15]=t.x,i[16]=n.y,i[17]=t.z,i[18]=t.x,i[19]=t.y,i[20]=t.z,i[21]=n.x,i[22]=t.y,i[23]=t.z,r.needsUpdate=!0,this.geometry.computeBoundingSphere()}}},{key:"setFromObject",value:function setFromObject(e){return this.object=e,this.update(),this}},{key:"copy",value:function copy(e,t){return Object(o.a)(Object(r.a)(BoxHelper.prototype),"copy",this).call(this,e,t),this.object=e.object,this}}]),BoxHelper}(ms),qc=function(e){function Box3Helper(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16776960;Object(f.a)(this,Box3Helper);var i=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),a=new Fi;return a.setIndex(new Mi(i,1)),a.setAttribute("position",new Ei([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),(t=Object(s.a)(this,Object(r.a)(Box3Helper).call(this,a,new os({color:n,toneMapped:!1})))).box=e,t.type="Box3Helper",t.geometry.computeBoundingSphere(),t}return Object(u.a)(Box3Helper,e),Object(p.a)(Box3Helper,[{key:"updateMatrixWorld",value:function updateMatrixWorld(e){var t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),Object(o.a)(Object(r.a)(Box3Helper.prototype),"updateMatrixWorld",this).call(this,e))}}]),Box3Helper}(ms),Xc=function(e){function PlaneHelper(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:16776960;Object(f.a)(this,PlaneHelper);var a=i,o=new Fi;o.setAttribute("position",new Ei([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),o.computeBoundingSphere(),(t=Object(s.a)(this,Object(r.a)(PlaneHelper).call(this,o,new os({color:a,toneMapped:!1})))).type="PlaneHelper",t.plane=e,t.size=n;var u=new Fi;return u.setAttribute("position",new Ei([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),u.computeBoundingSphere(),t.add(new ia(u,new bi({color:a,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1}))),t}return Object(u.a)(PlaneHelper,e),Object(p.a)(PlaneHelper,[{key:"updateMatrixWorld",value:function updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),Object(o.a)(Object(r.a)(PlaneHelper.prototype),"updateMatrixWorld",this).call(this,e)}}]),PlaneHelper}(ds),Jc=new ir,Yc=function(e){function ArrowHelper(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ir(0,0,1),n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ir(0,0,0),i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16776960,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.2*i,u=arguments.length>5&&void 0!==arguments[5]?arguments[5]:.2*o;return Object(f.a)(this,ArrowHelper),(e=Object(s.a)(this,Object(r.a)(ArrowHelper).call(this))).type="ArrowHelper",void 0===Uc&&((Uc=new Fi).setAttribute("position",new Ei([0,0,0,0,1,0],3)),(Vc=new Js(0,.5,1,5,1)).translate(0,-.5,0)),e.position.copy(n),e.line=new ds(Uc,new os({color:a,toneMapped:!1})),e.line.matrixAutoUpdate=!1,e.add(e.line),e.cone=new ia(Vc,new bi({color:a,toneMapped:!1})),e.cone.matrixAutoUpdate=!1,e.add(e.cone),e.setDirection(t),e.setLength(i,o,u),e}return Object(u.a)(ArrowHelper,e),Object(p.a)(ArrowHelper,[{key:"setDirection",value:function setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Jc.set(e.z,0,-e.x).normalize();var t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Jc,t)}}},{key:"setLength",value:function setLength(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.2*e,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.2*t;this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}},{key:"setColor",value:function setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}},{key:"copy",value:function copy(e){return Object(o.a)(Object(r.a)(ArrowHelper.prototype),"copy",this).call(this,e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}}]),ArrowHelper}(ai),Zc=function(e){function AxesHelper(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;Object(f.a)(this,AxesHelper);var n=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],i=new Fi;i.setAttribute("position",new Ei(n,3)),i.setAttribute("color",new Ei([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));var a=new os({vertexColors:!0,toneMapped:!1});return(e=Object(s.a)(this,Object(r.a)(AxesHelper).call(this,i,a))).type="AxesHelper",e}return Object(u.a)(AxesHelper,e),Object(p.a)(AxesHelper,[{key:"setColors",value:function setColors(e,t,n){var r=new Hn,i=this.geometry.attributes.color.array;return r.set(e),r.toArray(i,0),r.toArray(i,3),r.set(t),r.toArray(i,6),r.toArray(i,9),r.set(n),r.toArray(i,12),r.toArray(i,15),this.geometry.attributes.color.needsUpdate=!0,this}},{key:"dispose",value:function dispose(){this.geometry.dispose(),this.material.dispose()}}]),AxesHelper}(ms),Kc=function(){function ShapePath(){Object(f.a)(this,ShapePath),this.type="ShapePath",this.color=new Hn,this.subPaths=[],this.currentPath=null}return Object(p.a)(ShapePath,[{key:"moveTo",value:function moveTo(e,t){return this.currentPath=new Ws,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}},{key:"lineTo",value:function lineTo(e,t){return this.currentPath.lineTo(e,t),this}},{key:"quadraticCurveTo",value:function quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}},{key:"bezierCurveTo",value:function bezierCurveTo(e,t,n,r,i,a){return this.currentPath.bezierCurveTo(e,t,n,r,i,a),this}},{key:"splineThru",value:function splineThru(e){return this.currentPath.splineThru(e),this}},{key:"toShapes",value:function toShapes(e,t){function toShapesNoHoles(e){for(var t=[],n=0,r=e.length;nNumber.EPSILON){if(l<0&&(o=t[a],u=-u,s=t[i],l=-l),e.ys.y)continue;if(e.y===o.y){if(e.x===o.x)return!0}else{var c=l*(e.x-o.x)-u*(e.y-o.y);if(0===c)return!0;if(c<0)continue;r=!r}}else{if(e.y!==o.y)continue;if(s.x<=e.x&&e.x<=o.x||o.x<=e.x&&e.x<=s.x)return!0}}return r}var n,r,i,a=au.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===t)return toShapesNoHoles(o);var s=[];if(1===o.length)return r=o[0],(i=new ru).curves=r.curves,s.push(i),s;var u=!a(o[0].getPoints());u=e?!u:u;var l,c,h=[],d=[],f=[],p=0;d[p]=void 0,f[p]=[];for(var m=0,v=o.length;m1){for(var g=!1,y=0,b=0,x=d.length;b0&&!1===g&&(f=h)}for(var C=0,L=d.length;C>-o-14,r[256|a]=1024>>-o-14|32768,i[a]=-o-1,i[256|a]=-o-1):o<=15?(r[a]=o+15<<10,r[256|a]=o+15<<10|32768,i[a]=13,i[256|a]=13):o<128?(r[a]=31744,r[256|a]=64512,i[a]=24,i[256|a]=24):(r[a]=31744,r[256|a]=64512,i[a]=13,i[256|a]=13)}for(var s=new Uint32Array(2048),u=new Uint32Array(64),l=new Uint32Array(64),c=1;c<1024;++c){for(var h=c<<13,d=0;0===(8388608&h);)h<<=1,d-=8388608;h&=-8388609,d+=947912704,s[c]=h|d}for(var f=1024;f<2048;++f)s[f]=939524096+(f-1024<<13);for(var p=1;p<31;++p)u[p]=p<<23;u[31]=1199570944,u[32]=2147483648;for(var m=33;m<63;++m)u[m]=2147483648+(m-32<<23);u[63]=3347054592;for(var v=1;v<64;++v)32!==v&&(l[v]=1024);return{floatView:t,uint32View:n,baseTable:r,shiftTable:i,mantissaTable:s,exponentTable:u,offsetTable:l}}var $c=Object.freeze({__proto__:null,toHalfFloat:function toHalfFloat(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=clamp(e,-65504,65504),Qc.floatView[0]=e;var t=Qc.uint32View[0],n=t>>23&511;return Qc.baseTable[n]+((8388607&t)>>Qc.shiftTable[n])},fromHalfFloat:function fromHalfFloat(e){var t=e>>10;return Qc.uint32View[0]=Qc.mantissaTable[Qc.offsetTable[t]+(1023&e)]+Qc.exponentTable[t],Qc.floatView[0]}}),eh=function(e){function ParametricGeometry(){return Object(f.a)(this,ParametricGeometry),console.error("THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js"),Object(s.a)(this,Object(r.a)(ParametricGeometry).call(this))}return Object(u.a)(ParametricGeometry,e),ParametricGeometry}(Fi),th=function(e){function TextGeometry(){return Object(f.a)(this,TextGeometry),console.error("THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js"),Object(s.a)(this,Object(r.a)(TextGeometry).call(this))}return Object(u.a)(TextGeometry,e),TextGeometry}(Fi);function FontLoader(){console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js")}function Font(){console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js")}function ImmediateRenderObject(){console.error("THREE.ImmediateRenderObject has been removed.")}var nh=function(e){function WebGLMultisampleRenderTarget(e,t,n){var i;return Object(f.a)(this,WebGLMultisampleRenderTarget),console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),(i=Object(s.a)(this,Object(r.a)(WebGLMultisampleRenderTarget).call(this,e,t,n))).samples=4,i}return Object(u.a)(WebGLMultisampleRenderTarget,e),WebGLMultisampleRenderTarget}(Kn),rh=function(e){function DataTexture2DArray(e,t,n,i){return Object(f.a)(this,DataTexture2DArray),console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),Object(s.a)(this,Object(r.a)(DataTexture2DArray).call(this,e,t,n,i))}return Object(u.a)(DataTexture2DArray,e),DataTexture2DArray}(Qn),ih=function(e){function DataTexture3D(e,t,n,i){return Object(f.a)(this,DataTexture3D),console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),Object(s.a)(this,Object(r.a)(DataTexture3D).call(this,e,t,n,i))}return Object(u.a)(DataTexture3D,e),DataTexture3D}(er);"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:m}})),"undefined"!==typeof window&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=m)},20:function(e,t,n){"use strict";function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf||function _setPrototypeOf(e,t){return e.__proto__=t,e})(e,t)}n.d(t,"a",function(){return _setPrototypeOf})},21:function(e,t,n){"use strict";function _slicedToArray(e,t){return function _arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArrayLimit(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done)&&(n.push(o.value),!t||n.length!==t);r=!0);}catch(u){i=!0,a=u}finally{try{r||null==s.return||s.return()}finally{if(i)throw a}}return n}(e,t)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}n.d(t,"a",function(){return _slicedToArray})},3:function(e,t,n){"use strict";function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function _getPrototypeOf(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}n.d(t,"a",function(){return _getPrototypeOf})},4:function(e,t,n){"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}n.d(t,"a",function(){return _classCallCheck})},6:function(e,t,n){"use strict";function _defineProperties(e,t){for(var n=0;n=0,a=i&&r.regeneratorRuntime;if(r.regeneratorRuntime=void 0,e.exports=n(78),i)r.regeneratorRuntime=a;else try{delete r.regeneratorRuntime}catch(o){r.regeneratorRuntime=void 0}},78:function(e,t){!function(t){"use strict";var n,r=Object.prototype,i=r.hasOwnProperty,a="function"===typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag",l="object"===typeof e,c=t.regeneratorRuntime;if(c)l&&(e.exports=c);else{(c=t.regeneratorRuntime=l?e.exports:{}).wrap=wrap;var h="suspendedStart",d="suspendedYield",f="executing",p="completed",m={},v={};v[o]=function(){return this};var g=Object.getPrototypeOf,y=g&&g(g(values([])));y&&y!==r&&i.call(y,o)&&(v=y);var b=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(v);GeneratorFunction.prototype=b.constructor=GeneratorFunctionPrototype,GeneratorFunctionPrototype.constructor=GeneratorFunction,GeneratorFunctionPrototype[u]=GeneratorFunction.displayName="GeneratorFunction",c.isGeneratorFunction=function(e){var t="function"===typeof e&&e.constructor;return!!t&&(t===GeneratorFunction||"GeneratorFunction"===(t.displayName||t.name))},c.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,GeneratorFunctionPrototype):(e.__proto__=GeneratorFunctionPrototype,u in e||(e[u]="GeneratorFunction")),e.prototype=Object.create(b),e},c.awrap=function(e){return{__await:e}},defineIteratorMethods(AsyncIterator.prototype),AsyncIterator.prototype[s]=function(){return this},c.AsyncIterator=AsyncIterator,c.async=function(e,t,n,r){var i=new AsyncIterator(wrap(e,t,n,r));return c.isGeneratorFunction(t)?i:i.next().then(function(e){return e.done?e.value:i.next()})},defineIteratorMethods(b),b[u]="Generator",b[o]=function(){return this},b.toString=function(){return"[object Generator]"},c.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function next(){for(;t.length;){var n=t.pop();if(n in e)return next.value=n,next.done=!1,next}return next.done=!0,next}},c.values=values,Context.prototype={constructor:Context,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(resetTryEntry),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=n)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function handle(r,i){return o.type="throw",o.arg=e,t.next=r,i&&(t.method="next",t.arg=n),!!i}for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r],o=a.completion;if("root"===a.tryLoc)return handle("end");if(a.tryLoc<=this.prev){var s=i.call(a,"catchLoc"),u=i.call(a,"finallyLoc");if(s&&u){if(this.prev=0;--n){var r=this.tryEntries[n];if(r.tryLoc<=this.prev&&i.call(r,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),resetTryEntry(n),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;resetTryEntry(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:values(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=n),m}}}function wrap(e,t,n,r){var i=t&&t.prototype instanceof Generator?t:Generator,a=Object.create(i.prototype),o=new Context(r||[]);return a._invoke=function makeInvokeMethod(e,t,n){var r=h;return function invoke(i,a){if(r===f)throw new Error("Generator is already running");if(r===p){if("throw"===i)throw a;return doneResult()}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var s=maybeInvokeDelegate(o,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===h)throw r=p,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=f;var u=tryCatch(e,t,n);if("normal"===u.type){if(r=n.done?p:d,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r=p,n.method="throw",n.arg=u.arg)}}}(e,n,o),a}function tryCatch(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(r){return{type:"throw",arg:r}}}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function defineIteratorMethods(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function AsyncIterator(e){var t;this._invoke=function enqueue(n,r){function callInvokeWithMethodAndArg(){return new Promise(function(t,a){!function invoke(t,n,r,a){var o=tryCatch(e[t],e,n);if("throw"!==o.type){var s=o.arg,u=s.value;return u&&"object"===typeof u&&i.call(u,"__await")?Promise.resolve(u.__await).then(function(e){invoke("next",e,r,a)},function(e){invoke("throw",e,r,a)}):Promise.resolve(u).then(function(e){s.value=e,r(s)},function(e){return invoke("throw",e,r,a)})}a(o.arg)}(n,r,t,a)})}return t=t?t.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}}function maybeInvokeDelegate(e,t){var r=e.iterator[t.method];if(r===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=n,maybeInvokeDelegate(e,t),"throw"===t.method))return m;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return m}var i=tryCatch(r,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,m;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=n),t.delegate=null,m):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,m)}function pushTryEntry(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function resetTryEntry(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function Context(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(pushTryEntry,this),this.reset(!0)}function values(e){if(e){var t=e[o];if(t)return t.call(e);if("function"===typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function next(){for(;++ro)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,Buffer.prototype),t}function Buffer(e,t,r){if("number"===typeof e){if("string"===typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return allocUnsafe(e)}return from(e,t,r)}function from(e,t,r){if("string"===typeof e)return function fromString(e,t){"string"===typeof t&&""!==t||(t="utf8");if(!Buffer.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|byteLength(e,t),n=createBuffer(r),f=n.write(e,t);f!==r&&(n=n.slice(0,f));return n}(e,t);if(ArrayBuffer.isView(e))return fromArrayLike(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(isInstance(e,ArrayBuffer)||e&&isInstance(e.buffer,ArrayBuffer))return fromArrayBuffer(e,t,r);if("undefined"!==typeof SharedArrayBuffer&&(isInstance(e,SharedArrayBuffer)||e&&isInstance(e.buffer,SharedArrayBuffer)))return fromArrayBuffer(e,t,r);if("number"===typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return Buffer.from(n,t,r);var f=function fromObject(e){if(Buffer.isBuffer(e)){var t=0|checked(e.length),r=createBuffer(t);return 0===r.length?r:(e.copy(r,0,0,t),r)}if(void 0!==e.length)return"number"!==typeof e.length||numberIsNaN(e.length)?createBuffer(0):fromArrayLike(e);if("Buffer"===e.type&&Array.isArray(e.data))return fromArrayLike(e.data)}(e);if(f)return f;if("undefined"!==typeof Symbol&&null!=Symbol.toPrimitive&&"function"===typeof e[Symbol.toPrimitive])return Buffer.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function assertSize(e){if("number"!==typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function allocUnsafe(e){return assertSize(e),createBuffer(e<0?0:0|checked(e))}function fromArrayLike(e){for(var t=e.length<0?0:0|checked(e.length),r=createBuffer(t),n=0;n=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|e}function byteLength(e,t){if(Buffer.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||isInstance(e,ArrayBuffer))return e.byteLength;if("string"!==typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var f=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(f)return n?-1:utf8ToBytes(e).length;t=(""+t).toLowerCase(),f=!0}}function swap(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function bidirectionalIndexOf(e,t,r,n,f){if(0===e.length)return-1;if("string"===typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),numberIsNaN(r=+r)&&(r=f?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(f)return-1;r=e.length-1}else if(r<0){if(!f)return-1;r=0}if("string"===typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,r,n,f);if("number"===typeof t)return t&=255,"function"===typeof Uint8Array.prototype.indexOf?f?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):arrayIndexOf(e,[t],r,n,f);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,f){var i,o=1,u=e.length,a=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,u/=2,a/=2,r/=2}function read(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(f){var s=-1;for(i=r;iu&&(r=u-a),i=r;i>=0;i--){for(var h=!0,c=0;cf&&(n=f):n=f;var i=t.length;n>i/2&&(n=i/2);for(var o=0;o>8,f=r%256,i.push(f),i.push(n);return i}(t,e.length-r),e,r,n)}function base64Slice(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function utf8Slice(e,t,r){r=Math.min(e.length,r);for(var n=[],f=t;f239?4:h>223?3:h>191?2:1;if(f+l<=r)switch(l){case 1:h<128&&(c=h);break;case 2:128===(192&(i=e[f+1]))&&(s=(31&h)<<6|63&i)>127&&(c=s);break;case 3:i=e[f+1],o=e[f+2],128===(192&i)&&128===(192&o)&&(s=(15&h)<<12|(63&i)<<6|63&o)>2047&&(s<55296||s>57343)&&(c=s);break;case 4:i=e[f+1],o=e[f+2],a=e[f+3],128===(192&i)&&128===(192&o)&&128===(192&a)&&(s=(15&h)<<18|(63&i)<<12|(63&o)<<6|63&a)>65535&&s<1114112&&(c=s)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),f+=l}return function decodeCodePointsArray(e){var t=e.length;if(t<=u)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}.apply(this,arguments)},Buffer.prototype.toLocaleString=Buffer.prototype.toString,Buffer.prototype.equals=function equals(e){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Buffer.compare(this,e)},Buffer.prototype.inspect=function inspect(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),""},i&&(Buffer.prototype[i]=Buffer.prototype.inspect),Buffer.prototype.compare=function compare(e,t,r,n,f){if(isInstance(e,Uint8Array)&&(e=Buffer.from(e,e.offset,e.byteLength)),!Buffer.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===f&&(f=this.length),t<0||r>e.length||n<0||f>this.length)throw new RangeError("out of range index");if(n>=f&&t>=r)return 0;if(n>=f)return-1;if(t>=r)return 1;if(this===e)return 0;for(var i=(f>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),u=Math.min(i,o),a=this.slice(n,f),s=e.slice(t,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var f=this.length-t;if((void 0===r||r>f)&&(r=f),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":return asciiWrite(this,e,t,r);case"latin1":case"binary":return latin1Write(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},Buffer.prototype.toJSON=function toJSON(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var u=4096;function asciiSlice(e,t,r){var n="";r=Math.min(e.length,r);for(var f=t;fn)&&(r=n);for(var f="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,r,n,f,i){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>f||te.length)throw new RangeError("Index out of range")}function checkIEEE754(e,t,r,n,f,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,i){return t=+t,r>>>=0,i||checkIEEE754(e,0,r,4),f.write(e,t,r,n,23,4),r+4}function writeDouble(e,t,r,n,i){return t=+t,r>>>=0,i||checkIEEE754(e,0,r,8),f.write(e,t,r,n,52,8),r+8}Buffer.prototype.slice=function slice(e,t){var r=this.length;(e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e+--t],f=1;t>0&&(f*=256);)n+=this[e+--t]*f;return n},Buffer.prototype.readUInt8=function readUInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function readUInt16LE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function readUInt16BE(e,t){return e>>>=0,t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function readUInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function readUInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function readIntLE(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=this[e],f=1,i=0;++i=(f*=128)&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function readIntBE(e,t,r){e>>>=0,t>>>=0,r||checkOffset(e,t,this.length);for(var n=t,f=1,i=this[e+--n];n>0&&(f*=256);)i+=this[e+--n]*f;return i>=(f*=128)&&(i-=Math.pow(2,8*t)),i},Buffer.prototype.readInt8=function readInt8(e,t){return e>>>=0,t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function readInt16LE(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function readInt16BE(e,t){e>>>=0,t||checkOffset(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function readInt32LE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function readInt32BE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function readFloatLE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),f.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function readFloatBE(e,t){return e>>>=0,t||checkOffset(e,4,this.length),f.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function readDoubleLE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),f.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function readDoubleBE(e,t){return e>>>=0,t||checkOffset(e,8,this.length),f.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function writeUIntLE(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=1,i=0;for(this[t]=255&e;++i>>=0,r>>>=0,n)||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var f=r-1,i=1;for(this[t+f]=255&e;--f>=0&&(i*=256);)this[t+f]=e/i&255;return t+r},Buffer.prototype.writeUInt8=function writeUInt8(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,255,0),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function writeUInt16LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeUInt16BE=function writeUInt16BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeUInt32LE=function writeUInt32LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},Buffer.prototype.writeUInt32BE=function writeUInt32BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeIntLE=function writeIntLE(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=0,o=1,u=0;for(this[t]=255&e;++i>0)-u&255;return t+r},Buffer.prototype.writeIntBE=function writeIntBE(e,t,r,n){if(e=+e,t>>>=0,!n){var f=Math.pow(2,8*r-1);checkInt(this,e,t,r,f-1,-f)}var i=r-1,o=1,u=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===u&&0!==this[t+i+1]&&(u=1),this[t+i]=(e/o>>0)-u&255;return t+r},Buffer.prototype.writeInt8=function writeInt8(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function writeInt16LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},Buffer.prototype.writeInt16BE=function writeInt16BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},Buffer.prototype.writeInt32LE=function writeInt32LE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},Buffer.prototype.writeInt32BE=function writeInt32BE(e,t,r){return e=+e,t>>>=0,r||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},Buffer.prototype.writeFloatLE=function writeFloatLE(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function writeFloatBE(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function writeDoubleLE(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function writeDoubleBE(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer.prototype.copy=function copy(e,t,r,n){if(!Buffer.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return f},Buffer.prototype.fill=function fill(e,t,r,n){if("string"===typeof e){if("string"===typeof t?(n=t,t=0,r=this.length):"string"===typeof r&&(n=r,r=this.length),void 0!==n&&"string"!==typeof n)throw new TypeError("encoding must be a string");if("string"===typeof n&&!Buffer.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===e.length){var f=e.charCodeAt(0);("utf8"===n&&f<128||"latin1"===n)&&(e=f)}}else"number"===typeof e?e&=255:"boolean"===typeof e&&(e=Number(e));if(t<0||this.length>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"===typeof e)for(i=t;i55295&&r<57344){if(!f){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&i.push(239,191,189);continue}f=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),f=r;continue}r=65536+(f-55296<<10|r-56320)}else f&&(t-=3)>-1&&i.push(239,191,189);if(f=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function base64ToBytes(e){return n.toByteArray(function base64clean(e){if((e=(e=e.split("=")[0]).trim().replace(a,"")).length<2)return"";for(;e.length%4!==0;)e+="=";return e}(e))}function blitBuffer(e,t,r,n){for(var f=0;f=t.length||f>=e.length);++f)t[f+r]=e[f];return f}function isInstance(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function numberIsNaN(e){return e!==e}var s=function(){for(var e=new Array(256),t=0;t<16;++t)for(var r=16*t,n=0;n<16;++n)e[r+n]="0123456789abcdef"[t]+"0123456789abcdef"[n];return e}()},80:function(e,t,r){"use strict";t.byteLength=function byteLength(e){var t=getLens(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function toByteArray(e){var t,r,n=getLens(e),o=n[0],u=n[1],a=new i(function _byteLength(e,t,r){return 3*(t+r)/4-r}(0,o,u)),s=0,h=u>0?o-4:o;for(r=0;r>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===u&&(t=f[e.charCodeAt(r)]<<2|f[e.charCodeAt(r+1)]>>4,a[s++]=255&t);1===u&&(t=f[e.charCodeAt(r)]<<10|f[e.charCodeAt(r+1)]<<4|f[e.charCodeAt(r+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return a},t.fromByteArray=function fromByteArray(e){for(var t,r=e.length,f=r%3,i=[],o=0,u=r-f;ou?u:o+16383));1===f?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===f&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return i.join("")};for(var n=[],f=[],i="undefined"!==typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,a=o.length;u0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function encodeChunk(e,t,r){for(var f,i,o=[],u=t;u>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return o.join("")}f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},81:function(e,t){t.read=function(e,t,r,n,f){var i,o,u=8*f-n-1,a=(1<>1,h=-7,c=r?f-1:0,l=r?-1:1,p=e[t+c];for(c+=l,i=p&(1<<-h)-1,p>>=-h,h+=u;h>0;i=256*i+e[t+c],c+=l,h-=8);for(o=i&(1<<-h)-1,i>>=-h,h+=n;h>0;o=256*o+e[t+c],c+=l,h-=8);if(0===i)i=1-s;else{if(i===a)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),i-=s}return(p?-1:1)*o*Math.pow(2,i-n)},t.write=function(e,t,r,n,f,i){var o,u,a,s=8*i-f-1,h=(1<>1,l=23===f?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,y=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-o))<1&&(o--,a*=2),(t+=o+c>=1?l/a:l*Math.pow(2,1-c))*a>=2&&(o++,a/=2),o+c>=h?(u=0,o=h):o+c>=1?(u=(t*a-1)*Math.pow(2,f),o+=c):(u=t*Math.pow(2,c-1)*Math.pow(2,f),o=0));f>=8;e[r+p]=255&u,p+=y,u/=256,f-=8);for(o=o<0;e[r+p]=255&o,p+=y,o/=256,s-=8);e[r+p-y]|=128*g}}})}); //# sourceMappingURL=buffer.js.map !function webpackUniversalModuleDefinition(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("three")):"function"===typeof define&&define.amd?define(["three"],t):"object"===typeof exports?exports["rogue-engine"]=t(require("three")):e["rogue-engine"]=t(e.three)}(window,function(e){return function(e){var t={};function __webpack_require__(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,__webpack_require__),i.l=!0,i.exports}return __webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.d=function(e,t,n){__webpack_require__.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},__webpack_require__.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.t=function(e,t){if(1&t&&(e=__webpack_require__(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(__webpack_require__.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)__webpack_require__.d(n,i,function(t){return e[t]}.bind(null,i));return n},__webpack_require__.n=function(e){var t=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};return __webpack_require__.d(t,"a",t),t},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.p="./",__webpack_require__(__webpack_require__.s=150)}({0:function(t,n){t.exports=e},12:function(e,t,n){"use strict";n.d(t,"a",function(){return __awaiter});function __awaiter(e,t,n,i){return new(n||(n=Promise))(function(s,o){function fulfilled(e){try{step(i.next(e))}catch(t){o(t)}}function rejected(e){try{step(i.throw(e))}catch(t){o(t)}}function step(e){e.done?s(e.value):new n(function(t){t(e.value)}).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())})}},150:function(e,t,n){"use strict";n.r(t);var i=n(0),s=n(12);class Lifecycle{}class Debug{static clear(){this.logs.splice(0,this.logs.length),this.flushOnClearLogsCallbacks()}static log(e){let t=new Log(e);this.addLog(t),this.flushOnAddLogCallbacks(t),console.log(e)}static logError(e){let t=new Debug_Error(e);this.addLog(t),this.flushOnAddLogCallbacks(t),console.error(e)}static logWarning(e){let t=new Warning(e);this.addLog(t),this.flushOnAddLogCallbacks(t),console.warn(e)}static addLog(e){this.logs.length>=this.maxLogs&&this.logs.shift(),this.logs.push(e)}static onAddLog(e){return this._onAddLogCallbacks.push(e),{stop:()=>{this._onAddLogCallbacks.splice(this._onAddLogCallbacks.indexOf(e),1)}}}static onClearLogs(e){return this._onClearLogsCallbacks.push(e),{stop:()=>{this._onClearLogsCallbacks.splice(this._onClearLogsCallbacks.indexOf(e),1)}}}static flushOnAddLogCallbacks(e){for(let t in this._onAddLogCallbacks)this._onAddLogCallbacks[t](e)}static flushOnClearLogsCallbacks(){for(let e in this._onClearLogsCallbacks)this._onClearLogsCallbacks[e]()}}Debug.maxLogs=50,Debug.logs=[],Debug._onAddLogCallbacks=[],Debug._onClearLogsCallbacks=[];class Log{constructor(e){this.message=e,this._type="Log"}get type(){return this._type}}class Debug_Error extends Log{constructor(e){super(e),this._type="Error"}}class Warning extends Log{constructor(e){super(e),this._type="Warning"}}var o=n(17),r=n.n(o);const a=[],u=[],c=(e,t,n)=>{if(0===n.length)return;const i=[];for(let s=0;s{let t=a.indexOf(e);t<0||a.splice(t,1)}}}function onObjectRemoved(e){return u.push(e),{stop:()=>{let t=u.indexOf(e);t<0||u.splice(t,1)}}}function objectAdded(e,t){c(e,t,a)}const h=[],d=[],l=[],p=(e,t,n)=>{if(0===n.length)return;const i=[];for(let s=0;s{let t=h.indexOf(e);t<0||h.splice(t,1)}}}function onComponentLoaded(e){return d.push(e),{stop:()=>{let t=d.indexOf(e);t<0||d.splice(t,1)}}}function onComponentRemoved(e){return l.push(e),{stop:()=>{let t=l.indexOf(e);t<0||l.splice(t,1)}}}function componentRemoved(e,t){p(e,t,l)}const f=[],m=[],_=[],g=[],b=(e,t)=>{if(0===t.length)return;const n=[];for(let i=0;i{let t=f.indexOf(e);t<0||f.splice(t,1)}}}function onUpdate(e){return m.push(e),{stop:()=>{let t=m.indexOf(e);t<0||m.splice(t,1)}}}function onAfterUpdate(e){return _.push(e),{stop:()=>{let t=_.indexOf(e);t<0||_.splice(t,1)}}}function onNextFrame(e){const t=n=>{e(n);let i=g.indexOf(t);i<0||g.splice(i,1)};g.push(t)}class SceneController_SceneController extends Lifecycle{constructor(){super(),this.renderFunc=(()=>this.defaultRenderFunc()),this._clock=new i.Clock,this._onPlayCallbacks=[],this._onStopCallbacks=[],this._throttledAdjustCameraAndRenderer=r()(()=>this.adjustCameraAndRenderer(),1e3,{}),this._containerId="rogue-app",this._isOffscreen=!1,this._stop=(()=>{}),this._deltaTime=0,this._pageVisibilityHandler=(()=>{this._clock.running&&this._clock.stop(),!this._clock.running&&this._clock.start()}),this.doOnResize=(e=>{this.adjustCameraAndRenderer(!0),this.onResize()}),this.onResize=(()=>{}),this.resizeObserver=new window.ResizeObserver(this.doOnResize),document.removeEventListener("visibilitychange",this._pageVisibilityHandler),document.addEventListener("visibilitychange",this._pageVisibilityHandler)}get defaultRenderFunc(){return()=>this._renderer.render(this._scene,this._camera||new i.OrthographicCamera(0,0,0,0,0,0))}get deltaTime(){return this._deltaTime||0}get height(){return this._height}get width(){return this._width}get containerId(){return this._containerId}get camera(){return this._camera}set camera(e){this._camera=e}get scene(){return this._scene}get renderer(){return this._renderer}get isRunning(){return this._isRunning}get isPaused(){return this._isPaused}get rogueDOMContainer(){return this._rogueDOMContainer}get clock(){return this._clock}onPlay(e){return this._onPlayCallbacks.push(e),{stop:()=>{let t=this._onPlayCallbacks.indexOf(e);t<0||this._onPlayCallbacks.splice(t,1)}}}onStop(e){this._onStopCallbacks.push(e);return{stop:()=>{let t=this._onStopCallbacks.indexOf(e);t<0||this._onStopCallbacks.splice(t,1)}}}loadMaterials(){const e={};App_App.currentScene.traverse(t=>{if(t.material instanceof i.Material){if(!Q.getAssetPath(t.material.uuid))return;const n=Q.getAsset(t.material.uuid);if(n)return void(t.material=n);e[t.material.uuid]?e[t.material.uuid].push(t):e[t.material.uuid]=[t]}});for(const t in e)Q.loadAsset(t).then(n=>{for(const i of e[t])i.material=n||i.material})}play(e,t,n){this.isPaused?this._isPaused=!1:(this.renderFunc=(()=>this.defaultRenderFunc()),this._scene=e,this._isRunning=!0,this.updateEventsHandler(this._onPlayCallbacks),this.loadMaterials(),this.startRenderer(t),this.resizeObserver.observe(this._rogueDOMContainer),this._renderer.setAnimationLoop(this.beginUpdateCycle.bind(this)),App_App.currentScene.traverse(e=>{if(e instanceof i.Mesh&&e.material instanceof i.Material)for(let t in e.material)e.material[t]instanceof i.Texture&&this.renderer.initTexture(e.material[t])}),D(App_App.currentScene,n),this.awake(),this.start(),this._clock.start())}stop(){this._isRunning&&(this._clock.stop(),this.updateEventsHandler(this._onStopCallbacks),this._isRunning=!1,this._stop(),this._renderer.setAnimationLoop(null),this.resizeObserver.unobserve(this._rogueDOMContainer))}updateEventsHandler(e){if(0===e.length)return;const t=[];for(let n=0;n{try{e.awake()}catch(t){Debug.logError(`${t.name} in ${e.name}: ${t.stack}`)}})}start(){this.traverseSceneComponents(e=>{try{e.isReady&&(e.start(),e.__STARTED__=!0)}catch(t){Debug.logError(`${t.name} in ${e.name}: ${t.stack}`)}})}beforeUpdate(){this.traverseSceneComponents(e=>{if(this.isRunning)try{e.isReady&&!e.__STARTED__&&(e.start(),e.__STARTED__=!0),e.isReady&&e.__STARTED__&&e.beforeUpdate()}catch(t){Debug.logError(`${t.name} in ${e.name}: ${t.stack}`)}}),function runBeforeUpdate(e){b(e,f)}(this)}update(){this.traverseSceneComponents(e=>{try{this.isRunning&&e.isReady&&e.__STARTED__&&e.update()}catch(t){Debug.logError(`${t.name} in ${e.name}: ${t.stack}`)}}),function runUpdate(e){b(e,m)}(this)}afterUpdate(){this.traverseSceneComponents(e=>{try{this.isRunning&&e.isReady&&e.__STARTED__&&e.afterUpdate()}catch(t){Debug.logError(`${t.name} in ${e.name}: ${t.stack}`)}}),function runAfterUpdate(e){b(e,_)}(this)}startRenderer(e){if(this._rogueDOMContainer=document.getElementById("rogue-app"),!document.getElementById("rogue-canvas")){const e=document.createElement("canvas");e.id="rogue-canvas",this._rogueDOMContainer.appendChild(e)}const t=document.getElementById("rogue-canvas");t.style.display="block",this._isOffscreen=!1,this._renderer||(this._renderer=new i.WebGLRenderer({canvas:t,powerPreference:"high-performance",antialias:!0,alpha:!0})),this._renderer.shadowMap.enabled=!0,this.renderer.setPixelRatio(window.devicePixelRatio),this.setSceneDimensions(this._rogueDOMContainer.clientWidth/window.devicePixelRatio,this._rogueDOMContainer.clientHeight/window.devicePixelRatio),this._width=0,this._height=0}setSceneDimensions(e,t){this._renderer.setSize(e,t),this.setCameraDimensions(e,t)}setCameraDimensions(e,t){if(this.camera instanceof i.PerspectiveCamera)this.camera.aspect=e/t,this.camera.updateProjectionMatrix();else if(this.camera instanceof i.OrthographicCamera){let n=t/e;this.camera.left=-5,this.camera.right=5,this.camera.top=10*n/2,this.camera.bottom=-10*n/2,this.camera.updateProjectionMatrix()}}adjustCameraAndRenderer(e){let{width:t,height:n}=this._rogueDOMContainer.getBoundingClientRect();t=this._isOffscreen?t/window.devicePixelRatio:t,n=this._isOffscreen?n/window.devicePixelRatio:n,(this.camera&&(t!==this._width||n!==this._height)||e)&&(this._width=t,this._height=n,this.renderer.setSize(this._width,this._height),this.setCameraDimensions(this._width,this._height))}beginUpdateCycle(){this.isRunning&&this._rogueDOMContainer&&(this._isPaused?this._deltaTime=this.clock.getDelta():(this._deltaTime=this.clock.getDelta(),function runNextFrame(e){b(e,g)}(this),this.beforeUpdate(),this.update(),this.isRunning&&(this.renderFunc(),this.afterUpdate())))}}let v=new(n(30).EventEmitter);class RuntimeController_RuntimeController extends SceneController_SceneController{constructor(){super(...arguments),this.onPlayCbsFlaggedForRemoval=[],this.onStopCbsFlaggedForRemoval=[]}play(e,t,n){this.isPaused||(v.emit("play"),this.createUIContainer()),Q.sceneController=this;let i=App_App.currentScene.getObjectByProperty("uuid",App_App.activeCamera);i||(i=App_App.currentScene.getObjectByProperty("type","PerspectiveCamera")),i||(i=App_App.currentScene.getObjectByProperty("type","OrthographicCamera")),i||Debug.logWarning("Couldn't find an active camera for this scene"),i&&(App_App.activeCamera=i.uuid,this.camera=i),super.play(e,t,n)}onPlay(e){const t=super.onPlay(e);return this.isRunning&&this.onPlayCbsFlaggedForRemoval.push(t),t}onStop(e){const t=super.onStop(e);return this.isRunning&&this.onStopCbsFlaggedForRemoval.push(t),t}stop(){this.traverseSceneComponents(e=>{for(let t in e.interface)e[t]instanceof i.Audio&&e[t].source&&e[t].stop()}),v.emit("stop"),this.isRunning&&this.removeUIContainer(),super.stop();const e=document.getElementById("rogue-canvas");e&&(e.style.display="none"),this.onPlayCbsFlaggedForRemoval.forEach(e=>{e.stop()}),this.onStopCbsFlaggedForRemoval.forEach(e=>{e.stop()}),this.onPlayCbsFlaggedForRemoval=[],this.onStopCbsFlaggedForRemoval=[]}createUIContainer(){if(!document.getElementById("rogue-ui")){const e=document.getElementById("rogue-app"),t=document.createElement("div");t.id="rogue-ui",t.style.position="absolute",t.style.width="100%",t.style.height="100%",t.style.overflow="hidden",e.insertBefore(t,e.firstChild),this.uiContainer=t}}removeUIContainer(){const e=document.getElementById("rogue-ui");e&&e.remove()}afterUpdate(){super.afterUpdate()}traverseSceneComponents(e){for(let t in P){const n=P[t];for(let t in n){const i=n[t];i.enabled&&e(i)}}}beginUpdateCycle(){this.isRunning&&this._rogueDOMContainer&&(this.camera&&App_App.activeCamera===this.camera.uuid||(this.camera=App_App.currentScene.getObjectByProperty("uuid",App_App.activeCamera),this.adjustCameraAndRenderer(!0)),super.beginUpdateCycle())}}const y=new RuntimeController_RuntimeController;var A=function Sky(){var e=Sky.SkyShader,t=new i.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:i.UniformsUtils.clone(e.uniforms),side:i.BackSide,depthWrite:!1});i.Mesh.call(this,new i.BoxBufferGeometry(1,1,1),t)},C=Object.create(i.Mesh.prototype);A.prototype=C,A.prototype.isSky=!0,A.SkyShader={uniforms:{luminance:{value:1},turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new i.Vector3},up:{value:new i.Vector3(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 = vec4( position, 1.0 );","\tvWorldPosition = worldPosition.xyz;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );"," gl_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() {"," vec3 direction = normalize( vWorldPosition - cameraPos );","\tfloat zenithAngle = acos( max( 0.0, dot( up, direction ) ) );","\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( direction, 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 ) );","\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")};let S=new class Skybox_SkyboxClass{constructor(){this._enabled=!0,this._mode="procedural",this._showSun=!1,this._inclination=.464,this._azimuth=.25,this._layers=1,this.sunSpeed=0}get layers(){return this._layers}set layers(e){this._layers=e,this._sky&&(this._sky.layers.mask=e),this._cubemapSky&&(this._cubemapSky.layers.mask=e)}get sky(){return this._sky}get cubemapSky(){return this._cubemapSky}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.init(this.toJSON())}get mode(){return this._mode}set mode(e){this._mode=e,this.init(this.toJSON())}get cubemapTop(){return this._cubemapTop}set cubemapTop(e){this._cubemapTop=e,"cubemap"===this.mode&&this.init(this.toJSON())}get cubemapBottom(){return this._cubemapBottom}set cubemapBottom(e){this._cubemapBottom=e,"cubemap"===this.mode&&this.init(this.toJSON())}get cubemapFront(){return this._cubemapFront}set cubemapFront(e){this._cubemapFront=e,"cubemap"===this.mode&&this.init(this.toJSON())}get cubemapBack(){return this._cubemapBack}set cubemapBack(e){this._cubemapBack=e,"cubemap"===this.mode&&this.init(this.toJSON())}get cubemapRight(){return this._cubemapRight}set cubemapRight(e){this._cubemapRight=e,"cubemap"===this.mode&&this.init(this.toJSON())}get cubemapLeft(){return this._cubemapLeft}set cubemapLeft(e){this._cubemapLeft=e,"cubemap"===this.mode&&this.init(this.toJSON())}get mieDirectionalG(){return"procedural"===this.mode&&this._sky?this._sky.material.uniforms.mieDirectionalG.value:0}set mieDirectionalG(e){this._sky&&"procedural"===this.mode&&(this._sky.material.uniforms.mieDirectionalG.value=e)}get mieCoefficient(){return"procedural"===this.mode&&this._sky?this._sky.material.uniforms.mieCoefficient.value:0}set mieCoefficient(e){this._sky&&"procedural"===this.mode&&(this._sky.material.uniforms.mieCoefficient.value=e)}get turbidity(){return"procedural"===this.mode&&this._sky?this._sky.material.uniforms.turbidity.value:0}set turbidity(e){this._sky&&"procedural"===this.mode&&(this._sky.material.uniforms.turbidity.value=e)}get rayleigh(){return"procedural"===this.mode&&this._sky?this._sky.material.uniforms.rayleigh.value:0}set rayleigh(e){this._sky&&"procedural"===this.mode&&(this._sky.material.uniforms.rayleigh.value=e)}get luminance(){return"procedural"===this.mode&&this._sky?this._sky.material.uniforms.luminance.value:0}set luminance(e){this._sky&&"procedural"===this.mode&&(this._sky.material.uniforms.luminance.value=e)}get inclination(){return this._inclination}set inclination(e){this._inclination=e,"procedural"===this.mode&&this.setSunPosition()}get azimuth(){return this._azimuth}set azimuth(e){this._azimuth=e,"procedural"===this.mode&&this.setSunPosition()}get showSun(){return this._showSun}set showSun(e){this._showSun=e,"procedural"===this.mode&&this._sunSphere&&(this._sunSphere.visible=e)}init(e){if(this._onPlay&&this._onPlay.stop(),this._onStop&&this._onStop.stop(),this._onUpdate&&this._onUpdate.stop(),e&&(this._enabled=e._enabled),this._sky&&this._sky.parent&&this._sky.parent.remove(this._sky),this._cubemapSky&&this._cubemapSky.parent&&this._cubemapSky.parent.remove(this._cubemapSky),!this.enabled||e&&!e._enabled)return;let t=e&&Object.keys(e).length>=1?e._mode:this.mode;"procedural"===t&&this.initProceduralSkybox(e),"cubemap"===t&&this.initCubemapSkybox(e)}initProceduralSkybox(e){this._sky=new A,this._sky.name="ROGUE_INTERNAL_SKYBOX",this._sky.scale.setScalar(100),this._sky.renderOrder=-999,this._sky.userData.isEditorObject=!0,this._sunSphere=new i.Mesh(new i.SphereBufferGeometry(3,20,8),new i.MeshStandardMaterial({color:"#000",emissive:"#fff",depthTest:!1,depthWrite:!1})),this._sunSphere.renderOrder=-100,this._sunSphere.position.y=-100,this._sunSphere.visible=this.showSun,this._sunSphere.name="Sun",this._sky.add(this._sunSphere),e&&Object.keys(e).length>=1?this.fromJSON(e):this.fromJSON(this.getDefaultJSON()),App_App.currentScene.add(this._sky),window.ROGUE_ISDEV&&(this._onPlay=y.onPlay(()=>{this._serializedSkybox=this.toJSON(),this._directionalLight=void 0}),this._onStop=y.onStop(()=>{this.fromJSON(this._serializedSkybox),this._directionalLight=void 0})),this._onUpdate=onBeforeUpdate(e=>{this._enabled&&(e.renderer.xr.enabled?e.renderer.xr.getCamera().getWorldPosition(this._sky.position):e.camera.getWorldPosition(this._sky.position),this._directionalLight||this.setSunPosition(),App_App.sceneController instanceof RuntimeController_RuntimeController&&(this.inclination<=-1&&(this.inclination=1),this.inclination>1&&(this.inclination=-1),this.inclination-=this.sunSpeed))})}initCubemapSkybox(e){e&&Object.keys(e).length>=1?this.fromJSON(e):this.fromJSON(this.getDefaultJSON());let t=new i.MeshLambertMaterial({emissive:this.cubemapRight?"#fff":"#000",color:"#000",emissiveMap:this.cubemapRight}),n=new i.MeshLambertMaterial({emissive:this.cubemapLeft?"#fff":"#000",color:"#000",emissiveMap:this.cubemapLeft}),s=new i.MeshLambertMaterial({emissive:this.cubemapTop?"#fff":"#000",color:"#000",emissiveMap:this.cubemapTop}),o=new i.MeshLambertMaterial({emissive:this.cubemapBottom?"#fff":"#000",color:"#000",emissiveMap:this.cubemapBottom}),r=new i.MeshLambertMaterial({emissive:this.cubemapFront?"#fff":"#000",color:"#000",emissiveMap:this.cubemapFront}),a=new i.MeshLambertMaterial({emissive:this.cubemapBack?"#fff":"#000",color:"#000",emissiveMap:this.cubemapBack});t.side=i.BackSide,t.depthWrite=!1,t.depthTest=!1,n.side=i.BackSide,n.depthWrite=!1,n.depthTest=!1,s.side=i.BackSide,s.depthWrite=!1,s.depthTest=!1,o.side=i.BackSide,o.depthWrite=!1,o.depthTest=!1,r.side=i.BackSide,r.depthWrite=!1,r.depthTest=!1,a.side=i.BackSide,a.depthWrite=!1,a.depthTest=!1,this._cubemapSky=new i.Mesh(new i.BoxBufferGeometry(100,100,100),[t,n,s,o,r,a]),this._cubemapSky.renderOrder=-999,this._cubemapSky.name="ROGUE_INTERNAL_SKYBOX",this._cubemapSky.userData.isEditorObject=!0,App_App.currentScene.add(this._cubemapSky),window.ROGUE_ISDEV&&(this._onPlay=y.onPlay(()=>{this._serializedSkybox=this.toJSON()}),this._onStop=y.onStop(()=>{this.fromJSON(this._serializedSkybox)})),this._onUpdate=onBeforeUpdate(e=>{this._enabled&&(e.renderer.xr.enabled?e.renderer.xr.getCamera().getWorldPosition(this._cubemapSky.position):e.camera.getWorldPosition(this._cubemapSky.position))})}toJSON(){return{_enabled:this._enabled,_mode:this._mode,layers:this._layers,_showSun:this._showSun,inclination:this._inclination,azimuth:this._azimuth,mieDirectionalG:this.mieDirectionalG,mieCoefficient:this.mieCoefficient,turbidity:this.turbidity,rayleigh:this.rayleigh,luminance:this.luminance,_sunSpeed:this.sunSpeed,_cubemapTop:this.cubemapTop instanceof i.Texture&&this.cubemapTop.toJSON(),_cubemapBottom:this.cubemapBottom instanceof i.Texture&&this.cubemapBottom.toJSON(),_cubemapFront:this.cubemapFront instanceof i.Texture&&this.cubemapFront.toJSON(),_cubemapBack:this.cubemapBack instanceof i.Texture&&this.cubemapBack.toJSON(),_cubemapRight:this.cubemapRight instanceof i.Texture&&this.cubemapRight.toJSON(),_cubemapLeft:this.cubemapLeft instanceof i.Texture&&this.cubemapLeft.toJSON()}}fromJSON(e){void 0===e._enabled&&(e._enabled=!0);for(let t in e){let n=e[t];if("object"===typeof n){const e=Q.getAsset(n.uuid);e?this[t]=e:Q.loadAsset(n.uuid).then(e=>{this[t]=e,"cubemap"===this.mode&&this.init(this.toJSON())})}else this[t]=e[t]}}initWithDefaultValues(){this._mode="procedural",this.inclination=.464,this.azimuth=.25,this.mieDirectionalG=.998,this.mieCoefficient=.004,this.turbidity=10,this.rayleigh=1.423,this.luminance=1,this._showSun=!1}getDefaultJSON(){return{_enabled:!0,_mode:"procedural",layers:1,_showSun:!1,inclination:.464,azimuth:.25,mieDirectionalG:.998,mieCoefficient:.004,turbidity:10,rayleigh:1.423,luminance:1,_sunSpeed:0,_cubemapTop:void 0,_cubemapBottom:void 0,_cubemapFront:void 0,_cubemapBack:void 0,_cubemapRight:void 0,_cubemapLeft:void 0}}setSunPosition(){var e=Math.PI*(this.inclination-.5),t=2*Math.PI*(this.azimuth-.5);this._sunSphere&&(this._sunSphere.position.x=90*Math.cos(t),this._sunSphere.position.y=90*Math.sin(t)*Math.sin(e),this._sunSphere.position.z=90*Math.sin(t)*Math.cos(e),this._sky.material.uniforms.sunPosition.value.copy(this._sunSphere.position),this._directionalLight?this._directionalLight.position.set(this._sunSphere.position.x,this._sunSphere.position.y,this._sunSphere.position.z):(this._directionalLight=App_App.currentScene.getObjectByName("SUNLIGHT"),this._directionalLight&&this._directionalLight.position.set(this._sunSphere.position.x,this._sunSphere.position.y,this._sunSphere.position.z)))}};class GamepadController_GamepadController{constructor(e){this._upButtons={},this._downButtons={},this._pressedButtons={},this.deadZone=.1,this._gamepad=e,this.update()}get gamepad(){return this._gamepad}update(){onNextFrame(()=>{this._gamepad.buttons[0].pressed,this._gamepad.buttons.forEach((e,t)=>{e.pressed&&!this._pressedButtons[t]&&(this._downButtons[t]=!0,this._pressedButtons[t]=!0,onNextFrame(()=>this._downButtons[t]=!1)),!e.pressed&&this._pressedButtons[t]&&(this._pressedButtons[t]=!1,this._upButtons[t]=!0,onNextFrame(()=>this._upButtons[t]=!1))}),this.update()})}getAxis(e){const t=this._gamepad.axes[e];if(this.deadZone>0&&Math.abs(t)>0){const n=this._gamepad.axes[e%2===0?e+1:e-1];return Math.abs(n)>this.deadZone?t:Math.abs(t)>this.deadZone?t:0}return t}getButton(e){var t;return(null===(t=this._gamepad.buttons[e])||void 0===t?void 0:t.value)||0}getButtonDown(e){return this._downButtons[e]||!1}getButtonUp(e){return this._upButtons[e]||!1}}window.addEventListener("gamepadconnected",e=>{const t=new GamepadController_GamepadController(e.gamepad);Input.gamepads.push(t)}),window.addEventListener("gamepaddisconnected",e=>{Input.gamepads.splice(e.gamepad.index,1)}),onUpdate(e=>{if(!(e instanceof RuntimeController_RuntimeController))return;const t=navigator.getGamepads?navigator.getGamepads():[];if(t)for(let n=0;n{var t,n;if(e instanceof i.Mesh&&(e.geometry.dispose&&e.geometry.dispose(),function disposeMaterial(e){if(e instanceof i.Material){const t=Q.getAssetConfig(e.uuid);if(t&&t.keepLoaded)return;for(let n in e)disposeTexture(e[n]);e.dispose&&e.dispose()}else Array.isArray(e)&&e.forEach(e=>{disposeMaterial(e)})}(e.material)),e instanceof i.SkinnedMesh&&e.skeleton&&(e.skeleton.dispose&&e.skeleton.dispose(),(null===(t=e.skeleton.boneTexture)||void 0===t?void 0:t.dispose)&&(null===(n=e.skeleton.boneTexture)||void 0===n||n.dispose())),e.parent){const t=e.parent.children.indexOf(e);t>=0&&(e.parent.children[t]=null),e.parent=null}})}Input._mouse=new class Mouse_Mouse{constructor(){this._x=0,this._y=0,this._movementX=0,this._movementY=0,this._isMoving=!1,this._isLeftButtonDown=!1,this._isLeftButtonPressed=!1,this._isLeftButtonUp=!1,this._isRightButtonDown=!1,this._isRightButtonPressed=!1,this._isRightButtonUp=!1,this._isMidButtonDown=!1,this._isMidButtonPressed=!1,this._isMidButtonUp=!1,this._wheelY=0,this._wheelX=0,this._enabled=!0,this.unlockFunction=(e=>{"Escape"===e.code&&this.unlock()})}get pointerLock(){return this._pointerLock}get x(){return this._x}get y(){return this._y}get movementX(){return this._movementX}get movementY(){return this._movementY}get isMoving(){return this._isMoving}get isLeftButtonDown(){return this._isLeftButtonDown}get isLeftButtonPressed(){return this._isLeftButtonPressed}get isLeftButtonUp(){return this._isLeftButtonUp}get isRightButtonDown(){return this._isRightButtonDown}get isRightButtonPressed(){return this._isRightButtonPressed}get isRightButtonUp(){return this._isRightButtonUp}get isMidButtonDown(){return this._isMidButtonDown}get isMidButtonPressed(){return this._isMidButtonPressed}get isMidButtonUp(){return this._isMidButtonUp}get buttonDown(){return this._buttonDown}get buttonPressed(){return this._buttonPressed}get buttonUp(){return this._buttonUp}get wheelY(){return this._wheelY}get wheelX(){return this._wheelX}get enabled(){return this._enabled}set enabled(e){this._enabled=e}init(){document.addEventListener("mousemove",this.onMouseMove.bind(this),!1);const e=document.getElementById("rogue-app");e&&(e.addEventListener("mousedown",this.onMouseDown.bind(this)),e.addEventListener("mouseup",this.onMouseUp.bind(this)),e.addEventListener("wheel",this.onWheelMove.bind(this)))}getButtonDown(e){return this._buttonDown===e}getButtonPressed(e){return this._buttonPressed===e}getButtonUp(e){return this._buttonUp===e}lock(){const e=document.getElementById("rogue-app");e&&(e&&e.requestPointerLock(),document.removeEventListener("keyup",this.unlockFunction),document.addEventListener("keyup",this.unlockFunction))}unlock(){document.exitPointerLock()}onMouseMove(e){onNextFrame(this.setMouseMovement.bind(this,e))}setMouseMovement(e){this._x=e.clientX,this._y=e.clientY,this._movementX=e.movementX,this._movementY=e.movementY,this._isMoving=!0,onNextFrame(this.resetMouseMovement.bind(this))}resetMouseMovement(){this._movementX=0,this._movementY=0,this._isMoving=!1}onMouseDown(e){!1!==this._enabled&&onNextFrame(()=>{0===e.button?(this._isLeftButtonDown=!0,this._isLeftButtonPressed=!0):2===e.button?(this._isRightButtonDown=!0,this._isRightButtonPressed=!0):1===e.button&&(this._isMidButtonDown=!0,this._isMidButtonPressed=!0),this._buttonDown=e.button,this._buttonPressed=e.button,onNextFrame(()=>{0===e.button?this._isLeftButtonDown=!1:2===e.button?this._isRightButtonDown=!1:1===e.button&&(this._isMidButtonDown=!1),this._buttonDown=void 0})})}onMouseUp(e){!1!==this._enabled&&onNextFrame((()=>{0===e.button?(this._isLeftButtonUp=!0,this._isLeftButtonPressed=!1):2===e.button?(this._isRightButtonUp=!0,this._isRightButtonPressed=!1):1===e.button&&(this._isMidButtonUp=!0,this._isMidButtonPressed=!1),this.getButtonPressed(e.button)&&(this._buttonUp=e.button,this._buttonPressed=void 0),onNextFrame((()=>{0===e.button?this._isLeftButtonUp=!1:2===e.button?this._isRightButtonUp=!1:1===e.button&&(this._isMidButtonUp=!1),this._buttonUp=void 0}).bind(this))}).bind(this))}onWheelMove(e){!1!==this._enabled&&(e.preventDefault(),clearTimeout(this._wheelTimeout),this._wheelY=e.deltaY,this._wheelX=e.deltaX,this._wheelTimeout=setTimeout(()=>{this._wheelY=0,this._wheelX=0},250))}},Input._keyboard=new class Keyboard_Keyboard{constructor(){this._upKeys={},this._downKeys={},this._pressedKeys={}}init(){document.addEventListener("keydown",e=>{this._pressedKeys[e.code]||onNextFrame(()=>{this._downKeys[e.code]=!0,this._pressedKeys[e.code]=!0,onNextFrame(()=>{this._downKeys[e.code]=!1})})}),document.addEventListener("keyup",e=>{onNextFrame(()=>{this._upKeys[e.code]=!0,this._pressedKeys[e.code]=!1,onNextFrame(()=>{this._upKeys[e.code]=!1})})})}getKeyDown(e){return this._downKeys[e]}getKeyPressed(e){return this._pressedKeys[e]}getKeyUp(e){return this._upKeys[e]}},Input._touch=new class Touch_TouchController{constructor(){this._startTouches=[],this._endTouches=[],this._touches=[],this._enabled=!0}get startTouches(){return this._startTouches}get endTouches(){return this._endTouches}get touches(){return this._touches}get enabled(){return this._enabled}set enabled(e){this._enabled=e}init(){this._touches.splice(0),this._endTouches.splice(0),this._startTouches.splice(0),this._enabled=!0;const e=document.getElementById("rogue-app");e&&(e.ontouchmove=this.onTouchMove.bind(this),e.ontouchstart=this.onTouchStart.bind(this),e.ontouchend=this.onTouchEnd.bind(this))}onTouchStart(e){e.preventDefault(),onNextFrame(()=>{for(let t=0;t{for(let t=0;t{for(let t=0;t{for(let t=0;t{for(let t=0;t=0&&this.setTouchValues(this._touches[i],n)}onNextFrame(()=>{for(const e of this._touches)e.deltaX=0,e.deltaY=0})})}getCurrentTouchIndexById(e,t){for(let n=0;n{this.loadSceneFunc(e).then(()=>{t()})})}static loadSceneFunc(e){return Object(s.a)(this,void 0,void 0,function*(){let t;if("string"===typeof e?t=this._scenes.find(t=>t.name===e):"number"===typeof e&&(t=this._scenes[e]),!t)return;let n=yield fetch(window.ROGUE_ISDEV?Q.getAssetPath(t.uuid):this.title+"_DATA/"+t.uuid+".rogueScene"),s=yield n.json();y.startRenderer(),App_App.sceneController=y,Q.sceneController=y,App_App.activeCamera=s.initialCameraId,Q.loadAssetConfigs(s.assetConfigs),yield Q.preloadAssets(),this._currentScene=(new i.ObjectLoader).parse(s.scene),this.loadAudioListeners(this._currentScene),s.skybox&&S.init(s.skybox),y.play(this._currentScene,y.renderer,s.components)})}static clone(e,t){if(!e)throw new Error("App.clone(...) => The object you are trying to clone does not seem to exist.");if(!(e instanceof i.Object3D))throw new Error("App.clone(...) => The object you are trying to clone is unavailable, try fetching the asset first. object.uuid: "+e.uuid);const n=e.animations;let s=e.clone();s.animations=n,t?(t.attach(s),s.position.set(0,0,0)):this.currentScene.add(s),this.loadAudioListeners(s),this.loadComponentsRecursive(s);let o=G(s);return y.isRunning&&o.forEach(e=>{e.awake()}),y.isRunning&&s.traverse(e=>{G(e).forEach(e=>{e.awake()})}),s}static loadComponentsRecursive(e){const t=e.userData&&e.userData.components;(()=>Object(s.a)(this,void 0,void 0,function*(){t&&T(e,t),e.userData&&delete e.userData.components}))();for(let n in e.children)this.loadComponentsRecursive(e.children[n])}static loadAudioListeners(e){const t=[];e.traverse(e=>{e instanceof i.AudioListener||!e.userData.__AUDIOLISTENER__||t.push(e)}),t.forEach(e=>{const t=new i.AudioListener;t.name=e.name,t.userData.__AUDIOLISTENER__=!0,t.position.copy(e.position),t.rotation.copy(e.rotation);const n=e.uuid;e.parent&&e.parent.add(t),e.parent&&e.parent.remove(e),t.uuid=n})}}App_App._title="Project",App_App._scenes=[],App_App._sceneController=y,App_App._lanIP="localhost";class AudioAsset_AudioAsset{constructor(e){this._uuid=e.uuid;const t=i.AudioContext.getContext().createBuffer(1,1,8e3);this._buffer=e.buffer||t,this.userData={__ASSET__:this._uuid}}get uuid(){return this._uuid}get path(){return Q.getAssetPath(this._uuid)||""}get name(){return this.path.substring(this.path.lastIndexOf("/")+1,this.path.lastIndexOf("."))}getAudio(){const e=App_App.currentScene.getObjectByProperty("type","AudioListener")||new i.AudioListener,t=new i.Audio(e);return t.setBuffer(this._buffer),t.name=this.name,t.userData.__ASSET__=this.uuid,t}getPositionalAudio(){const e=App_App.currentScene.getObjectByProperty("type","AudioListener")||new i.AudioListener,t=new i.PositionalAudio(e);return t.setBuffer(this._buffer),t.name=this.name,t.userData.__ASSET__=this.uuid,t}static fromFile(e,t=(()=>{}),n=(()=>{})){return Object(s.a)(this,void 0,void 0,function*(){let s=yield fetch(e+".meta"),o=yield s.json();return new Promise(s=>{let r=new i.AudioLoader;r.setCrossOrigin("anonymous"),r.load(e,e=>{const t=new AudioAsset_AudioAsset({uuid:o.uuid,buffer:e});s(t)},t,n)})})}}class Prefab_Prefab{constructor(e){this._uuid=e}get uuid(){return this._uuid}get path(){return Q.getAssetPath(this._uuid)||""}get name(){return this.path.substring(this.path.lastIndexOf("/")+1,this.path.lastIndexOf("."))}instantiate(e){let t=Q.getAsset(this._uuid).clone();e?(e.attach(t),t.position.set(0,0,0)):App_App.currentScene.attach(t),t.traverse(e=>{let n=e.userData.__NESTED__;onNextFrame(()=>{n&&n.forEach(n=>{n.uuid!==t.userData.__ASSET__&&onNextFrame(()=>Object(s.a)(this,void 0,void 0,function*(){if(!(yield Q.loadAsset(n.uuid)))return;const t=n.parent===e.userData.__REF__?e:e.getObjectByProperty("uuid",n.parent),i=new Prefab_Prefab(n.uuid).instantiate(t);n.position&&i.position.fromArray(n.position),n.rotation&&i.rotation.fromArray(n.rotation),n.scale&&i.scale.fromArray(n.scale)}))})}),n&&(e.userData.__NESTED__=void 0)}),function loadAudioListeners(e){const t=[];e.traverse(e=>{e instanceof i.AudioListener||!e.userData.__AUDIOLISTENER__||t.push(e)}),t.forEach(e=>{const t=new i.AudioListener;t.name=e.name,t.userData.__AUDIOLISTENER__=!0,t.position.copy(e.position),t.rotation.copy(e.rotation);const n=e.uuid;e.parent&&e.parent.add(t),e.parent&&e.parent.remove(e),t.uuid=n})}(t),function loadComponentsRecursive(e){const t=e.userData&&e.userData.components;(()=>Object(s.a)(this,void 0,void 0,function*(){t&&T(e,t),e.userData&&delete e.userData.components}))();for(let n in e.children)loadComponentsRecursive(e.children[n])}(t);let n=G(t);return y.isRunning&&n.forEach(e=>{e.awake()}),y.isRunning&&t.traverse(e=>{G(e).forEach(e=>{e.awake()})}),t}}var E=n(19),w=n.n(E);const O=new i.AnimationClip("",0,[]);class Component_Component extends Lifecycle{constructor(e,t){super(),this._name="component",this._isReady=!0,this._enabled=!0,this.interface={},this.uuid=w()(),this._object3d=t,this._name=e}get name(){return this._name}set name(e){this._name=e}get object3d(){return this._object3d}get isReady(){return this._isReady}get enabled(){return this._enabled}set enabled(e){this._enabled=e,e?(this.awake(),this.__STARTED__=!1):this.onDisabled()}toJSON(){return{uuid:this.uuid,name:this.name,componentPrototypeName:this.constructor.name,interface:this.constructor.interface||{},interfaceRefs:this.serializeInterfaceRefs(),enabled:this._enabled}}fromJSON(e){this._isReady=!1,this.uuid=e.uuid||this.uuid,this.name=e.name,this.interface=e.interface||{},this.loadInterfaceRefs(e.interfaceRefs),this._enabled="boolean"!==typeof e.enabled||e.enabled}serializePropRef(e,t,n,s){switch(s){case"Data":case"String":case"Number":case"Boolean":case"Select":case"Code":e[t]=n[t];break;case"Color":if(n[t]instanceof i.Color){const i=n[t];e[t]=i.getHex()}break;case"Vector2":if(n[t]instanceof i.Vector2){const i=n[t];e[t]=i.toArray()}break;case"Vector3":if(n[t]instanceof i.Vector3){const i=n[t];e[t]=i.toArray()}break;case"Texture":if(n[t]instanceof i.Texture){const i=n[t];e[t]=i.uuid}break;case"Material":if(n[t]instanceof i.Material){const i=n[t];e[t]=i.uuid}break;case"Object3D":if(n[t]instanceof i.Object3D){const i=n[t];e[t]=i.uuid}break;case"Prefab":if(n[t]instanceof Prefab_Prefab){const i=n[t];e[t]=i.uuid}break;case"AnimationClip":if(n[t]instanceof i.AnimationClip){const i=n[t];e[t]=i.uuid}break;case"PositionalAudio":case"Audio":if(n[t]instanceof AudioAsset_AudioAsset){const i=n[t].userData.__ASSET__;e[t]=i}}}serializeInterfaceRefs(){if(!this.constructor.interface)return{};let e={};for(let t in this.constructor.interface){let n=this.constructor.interface[t];if(Array.isArray(n)){const i=this[t];Array.isArray(i)||(this[t]=[]);const s=[],o=n[0];let r="string"===typeof o?o:o.type;if("Button"===r)continue;i.forEach((e,t)=>{this.serializePropRef(s,t,i,r)}),e[t]=s}else{let i="string"===typeof n?n:n.type;if("Button"===i)continue;this.serializePropRef(e,t,this,i)}}return e}loadInterfaceRefs(e){if(!e||0===Object.keys(e).length)return void(this._isReady=!0);const t={},n=n=>{const i=e[n];Array.isArray(i)?(t[n]=[],i.forEach((e,i)=>{t[n][i]=!1})):t[n]=!1};for(let i in this.interface)n(i);0===Object.keys(this.interface).length&&(this._isReady=!0);for(let i in this.interface){const n=this.interface[i];if(Array.isArray(n)){this[i]=[];const s=n[0];let o="string"===typeof s?s:s.type;Array.isArray(e[i])||(e[i]=[]);const r=e[i];r.forEach((e,n)=>{this.loadPropRef(r,n,this[i],t,o,i)}),0===r.length&&this.readyNotifier(t,i)}else{let s="string"===typeof n?n:n.type;this.loadPropRef(e,i,this,t,s)}}}readyNotifier(e,t,n){n?e[n][t]=!0:e[t]=!0;for(const i in e){const t=e[i];if(!1===t)return!1;if(Array.isArray(t))for(let e=0;e{n.userData.__REF__===e[t]&&(u=n)}),u||(u=App_App.currentScene.getObjectByProperty("uuid",e[t])),n[t]=u,this.readyNotifier(s,t,r);break;case"Prefab":if(!e[t]){this.readyNotifier(s,t,r);break}let c="",h=!1;if(e[t]&&(c=e[t],n[t]=App_App.currentScene.getObjectByProperty("uuid",e[t])),e[t]&&!n[t]){c=e[t];let i=Q.getAsset(c);n[t]=new Prefab_Prefab(c),!i&&y.isRunning?(h=!0,Q.loadAsset(c).then(e=>{this.readyNotifier(s,t,r)})):this.readyNotifier(s,t,r)}n[t]||!e[t]||h||Debug.logError("Component => object reference could not be found for "+this.constructor.name+"."+t+" in Object3D with uuid: "+c);break;case"AnimationClip":if(!e[t]){this.readyNotifier(s,t,r);break}let d=!1;if(e[t]&&!n[t]){const i=e[t],o=Q.getAsset(i);n[t]=O,o?(n[t]=o,this.readyNotifier(s,t,r)):(d=!0,Q.loadAsset(i).then(e=>{n[t]=e,this.readyNotifier(s,t,r)}))}break;case"Audio":case"PositionalAudio":if(!e[t]){this.readyNotifier(s,t,r);break}let l="";const p=e=>{const i="Audio"===o?e.getAudio():e.getPositionalAudio();n[t]=i,this.object3d.add(i)};if(e[t]&&!n[t]){l=e[t];let i=Q.getAsset(l);if(!y.isRunning){n[t]=new AudioAsset_AudioAsset({uuid:l});break}if(!i){Q.loadAsset(l).then(e=>{p(e),this.readyNotifier(s,t,r)});break}i instanceof AudioAsset_AudioAsset&&(p(i),this.readyNotifier(s,t,r))}break;case"Texture":if(!e[t]){this.readyNotifier(s,t,r);break}let f=!1;if(e[t]&&!n[t]){const i=e[t],o=Q.getAsset(i);o?(n[t]=o,this.readyNotifier(s,t,r)):(f=!0,Q.loadAsset(i).then(e=>{n[t]=e,this.readyNotifier(s,t,r)}))}break;case"Material":if(!e[t]){this.readyNotifier(s,t,r);break}let m=!1;if(e[t]&&!n[t]){const i=e[t],o=Q.getAsset(i);o?(n[t]=o,this.readyNotifier(s,t,r)):(m=!0,Q.loadAsset(i).then(e=>{n[t]=e,this.readyNotifier(s,t,r)}))}}}awake(){}start(){}beforeUpdate(){}update(){}afterUpdate(){}onBeforeRemoved(){}onRemoved(){}onBeforeObjectRemoved(){}onObjectRemoved(){}onDisabled(){}}let x={},k={},P={},R={},L={};function getComponentPrototypes(){return x}function clearComponents(){x={};for(let e in L)x[e]=L[e]}function registerComponent(e){if(e.prototype instanceof Component_Component){const t=e.isInternalComponent,n=e.isEditorComponent;if(n||t||(x[e.name]=e),n){const n="Editor_"+e.name,i=getComponentByName(n);window["rogue-editor"].editorRuntime.editorObjectsContainer&&(i&&N(i),t?(L[e.name]=e,x[e.name]=e):x[e.name]=e,M(new e(n,window["rogue-editor"].editorRuntime.editorObjectsContainer)))}}else Debug.logWarning(e+" is not a Component")}const D=(e,t)=>{P={},t&&(k=t);for(let n in k){const t=k[n];P[n]=[];let i=e.getObjectByProperty("uuid",n);t.forEach((e,t)=>{e?x[e.componentPrototypeName]?(P[n][t]=new x[e.componentPrototypeName](e.name,i),P[n][t].fromJSON(e)):Debug.logError("Component "+e.componentPrototypeName+" does not exist"):Debug.logError("Component does not exist")})}},j=e=>{if(!App_App.sceneController.editorObjectsContainer)return;const t={};for(let n in R){const e=R[n];t[n]=[],e.forEach((e,i)=>{e&&e.onRemoved(),e&&t[n].push(e.toJSON())})}for(let n in t){const e=t[n];R[n]=[];let i=App_App.sceneController.editorObjectsContainer.getObjectByProperty("uuid",n);e.forEach((e,t)=>{e?x[e.componentPrototypeName]?(R[n][t]=new x[e.componentPrototypeName](e.name,i),R[n][t].fromJSON(e)):Debug.logError("Component "+e.componentPrototypeName+" does not exist"):Debug.logError("Component does not exist")})}};function traverseComponents(e){for(let t in P){P[t].forEach((n,i)=>{e(n,t,i)})}}const T=(e,t)=>{let n=e.uuid;P[e.uuid]=[],t.forEach((t,i)=>{t?x[t.componentPrototypeName]?(P[n][i]=new x[t.componentPrototypeName](t.name,e),P[n][i].fromJSON(t),function componentLoaded(e,t){p(e,t,d)}(P[n][i],e)):Debug.logError("Component "+t.componentPrototypeName+" does not exist"):Debug.logError("Component does not exist")})},B=()=>{k={};for(let e in P){const t=P[e];k[e]=[],t.forEach((t,n)=>{t&&k[e].push(t.toJSON())})}return k},M=e=>{var t,n;if(!e.object3d)return;if(e.constructor.isEditorComponent&&(null===(n=null===(t=window["rogue-editor"])||void 0===t?void 0:t.editorRuntime)||void 0===n?void 0:n.editorObjectsContainer)!==e.object3d)throw`Failed adding component ${e.constructor.name}. Editor Components cannot be added to scene objects`;const i=e.object3d;if(i.userData.isEditorObject||e.constructor.isEditorComponent)return R[i.uuid]||(R[i.uuid]=[]),void R[i.uuid].push(e);P[i.uuid]||(P[i.uuid]=[]),P[i.uuid].push(e),function componentAdded(e,t){p(e,t,h)}(e,i),y.isRunning&&e.awake()};function copyObjectComponents(e,t){const n=G(e);let i=[];n.forEach(e=>{const t=e.toJSON();delete t.uuid,i.push(t)}),i.forEach(e=>{if(e)if(x[e.componentPrototypeName]){const n=new x[e.componentPrototypeName](e.name,t);n.fromJSON(e),M(n)}else Debug.logError("Component "+e.componentPrototypeName+" does not exist");else Debug.logError("Component does not exist")})}const N=e=>{const t=e.object3d;return!!t&&(R[t.uuid]?(!y.isRunning&&e.onBeforeRemoved(),R[t.uuid].splice(R[t.uuid].indexOf(e),1),!y.isRunning&&e.onRemoved(),componentRemoved(e,t),!0):void 0)},F=e=>{const t=e.object3d;return!!t&&(P[t.uuid]?(y.isRunning&&e.onBeforeRemoved(),P[t.uuid].splice(P[t.uuid].indexOf(e),1),y.isRunning&&e.onRemoved(),componentRemoved(e,t),!0):void 0)},I=(e,t)=>{for(let n in P[e.uuid])F(P[e.uuid][n]);if(delete P[e.uuid],t)for(let n in e.children){let t=e.children[n];I(t,!0)}};function getObjectComponentByName(e,t){return P[t]?P[t].find((t,n,i)=>t.name===e):R[t]?R[t].find((t,n,i)=>t.name===e):void 0}function getComponentByName(e,t){if(t)return getObjectComponentByName(e,t.uuid);for(let n in P){const t=getObjectComponentByName(e,n);if(t)return t}for(let n in R){const t=getObjectComponentByName(e,n);if(t)return t}}const U=(e,t)=>{if(t&&P[t.uuid])return P[t.uuid].find((t,n,i)=>t instanceof e);if(t&&R[t.uuid])return R[t.uuid].find((t,n,i)=>t instanceof e);if(!t)for(let n in P){const t=P[n];for(let n=0;n{const t=[];for(let n in P){P[n].forEach(n=>{n instanceof e&&t.push(n)})}return t},G=e=>P[e.uuid]||[],J=i.Object3D.prototype.add,W=i.Object3D.prototype.attach,V=i.Object3D.prototype.remove,$=i.Object3D.prototype.clone;let K=!1;function addObject(e){if(e.material instanceof i.Material){let t=Q.getAsset(e.material.uuid);const n=e.userData.__MATERIAL__;!t&&n&&((t=Q.getAsset(n))instanceof i.Material?e.material=t:!t&&n&&Q.loadAsset(n).then(t=>{t?e.material=t:Debug.logWarning(`Material not found. uuid: ${n}`)}))}Array.isArray(e.userData.__MATERIAL__)&&e.userData.__MATERIAL__.forEach((t,n)=>{if(!t)return;let s=Q.getAsset(t);s instanceof i.Material?e.material[n]=s:!s&&t&&Q.loadAsset(t).then(i=>{i?e.material[n]=i:Debug.logWarning(`Material not found. uuid: ${t}`)})})}i.Object3D.prototype.clone=function(e){K=!0;const t=$.bind(this)(e);return K=!1,t},i.Object3D.prototype.add=function(...e){!this.userData.isEditorObject&&e.forEach(e=>{addObject(e),e.userData.__IS_ADDING__=!0});const t=J.bind(this)(...e);return!this.userData.isEditorObject&&e.forEach(e=>{e.userData.__IS_ADDING__=!1,K||objectAdded(e,this)}),t},i.Object3D.prototype.attach=function(e){!this.userData.isEditorObject&&addObject(e),e.userData.__IS_ADDING__=!0;const t=W.bind(this)(e);return e.userData.__IS_ADDING__=!1,!this.userData.isEditorObject&&!K&&objectAdded(e,this),t};let X=(e,t)=>{if(function objectRemoved(e,t){c(e,t,u)}(e,t),P[e.uuid]){const t=P[e.uuid].slice(0);for(let e in t)F(t[e]);delete P[e.uuid]}for(let n in e.children){let t=e.children[n];X(t,e)}};i.Object3D.prototype.remove=function(e){const t=this===e.parent,n=P[e.uuid];t&&!e.userData.__IS_ADDING__&&n&&y.isRunning&&!this.userData.isEditorObject&&n.forEach(e=>{e.onBeforeObjectRemoved()});const i=V.bind(this)(e);return!t||e.userData.__IS_ADDING__||this.userData.isEditorObject||(y.isRunning&&n&&n.forEach(e=>{e.onObjectRemoved()}),X(e,this)),i};const q=i.Object3D.prototype.toJSON;i.Object3D.prototype.toJSON=function(e){const t=this.children.filter(e=>e.userData.isEditorObject);t.forEach(e=>{this.remove(e)});const n=q.bind(this)(e);if(t.forEach(e=>{this.attach(e)}),window.__IS_LOADING_MODEL__)return n;if(n.object.userData&&n.object.userData.__IS_MATERIAL__){n.images=[];for(let e in n.textures){const t=n.textures[e];n.textures[e]=t.uuid}}else{const e=[],t=[];n.textures&&n.textures.forEach(n=>{Q.getAssetPath(n.uuid)&&(t.push(n),e.push(n.image))}),e.forEach(e=>{const t=n.images.find(t=>t.uuid===e);n.images.splice(n.images.indexOf(t),1)}),t.forEach(e=>{n.textures.splice(n.textures.indexOf(e),1)});const i=[];n.materials&&n.materials.forEach(e=>{Q.getAssetPath(e.uuid)&&i.push(e)}),i.forEach(e=>{n.materials.splice(n.materials.indexOf(e),1)})}return n};const Y=["Prefab","Material","Aduio","PositionalAudio","AnimationClip"],H=["png","PNG","jpg","JPG","jpeg","JPEG","gif","GIF","webp","WEBP","tga","TGA","tif","tiff","TIF","TIFF"],Z=["mp3","MP3","ogg","OGG","mkv","MKV","wav","WAV"];let Q=new class AssetManager_AssetManagerClass{constructor(){this._assets={},this._assetConfigs={},this._assetPaths={},this._loadingAssets={},this._objectLoader=new i.ObjectLoader,this.textureLoader=new i.TextureLoader}get assets(){return this._assets}get assetConfigs(){return this._assetConfigs}get assetPaths(){return this._assetPaths}get totalLoadingAssets(){return Object.keys(this._loadingAssets).length}onRegisterAsset(e){return v.on("onRegisterAsset",e),{stop:()=>{v.removeListener("onRegisterAsset",e)}}}onRemoveAsset(e){return v.on("onRemoveAsset",e),{stop:()=>{v.removeListener("onRemoveAsset",e)}}}onClearAssets(e){return v.on("onClearAssets",e),{stop:()=>{v.removeListener("onClearAssets",e)}}}onSetAssetConfig(e){return v.on("onSetAssetConfig",e),{stop:()=>{v.removeListener("onSetAssetConfig",e)}}}onRemoveAssetConfig(e){return v.on("onRemoveAssetConfig",e),{stop:()=>{v.removeListener("onRemoveAssetConfig",e)}}}onLoadAssetConfigs(e){return v.on("onLoadAssetConfigs",e),{stop:()=>{v.removeListener("onLoadAssetConfigs",e)}}}onSetAssetPath(e){return v.on("onSetAssetPath",e),{stop:()=>{v.removeListener("onSetAssetPath",e)}}}onSetAssetPaths(e){return v.on("onSetAssetPaths",e),{stop:()=>{v.removeListener("onSetAssetPaths",e)}}}onRemoveAssetPath(e){return v.on("onRemoveAssetPath",e),{stop:()=>{v.removeListener("onRemoveAssetPath",e)}}}setAssetConfig(e,t){this._assetConfigs[e]=t,t.preload||t.keepLoaded||t.override||delete this._assetConfigs[e],v.emit("onSetAssetConfig",e,t)}getAssetConfig(e){return this._assetConfigs[e]}removeAssetConfig(e){const t=this._assetConfigs[e];delete this._assetConfigs[e],v.emit("onRemoveAssetConfig",e,t)}setAssetPath(e,t){this._assetPaths[e]=t,v.emit("onSetAssetPath",e,t)}removeAssetPath(e){const t=this._assetPaths[e];delete this._assetPaths[e],v.emit("onRemoveAssetPath",e,t)}setAssetPaths(e){this._assetPaths=Object.assign({},e),v.emit("onSetAssetPaths",e)}getAssetPath(e){let t;return this._assetPaths[e]&&(t=this._assetPaths[e]),t}registerAsset(e){this._assets[e.uuid]=e,v.emit("onRegisterAsset",e)}loadAsset(e){return Object(s.a)(this,void 0,void 0,function*(){const t=this.getAsset(e);if(t)return t;const n=this.getAssetPath(e);if(!n)return;const i=this.getExtension(n);return"roguePrefab"===i?yield this.loadObject(n):"rogueAnimation"===i?yield this.loadAnimation(n):Z.indexOf(i)>=0?yield this.loadAudio(n):"rogueMaterial"===i?yield this.loadMaterial(n):H.indexOf(i)>=0?yield this.loadTexture(n):void 0})}getExtension(e){return e.substr(e.lastIndexOf(".")+1)}getAsset(e){return this._assets[e]}loadObject(e){if(this._loadingAssets[e])return this._loadingAssets[e];const t=this.loadObjectFunction(e);return this.addLoadingAsset(e,t),t}loadObjectFunction(e){return Object(s.a)(this,void 0,void 0,function*(){let t=yield fetch(e),n=yield t.json();const i=this._objectLoader.parse(n);return i.uuid=n.object.uuid,this.registerAsset(i),yield this.loadNestedPrefabs(i),this.removeLoadingAsset(e),i})}loadNestedPrefabs(e){return Object(s.a)(this,void 0,void 0,function*(){const t=e.userData.__NESTED__;if(t)for(let e=0;e{n===t[e]&&(s[e]=n)})}const o=n.textures;n.textures=[];const r=this._objectLoader.parse(n).material;n.textures=o;for(let e in s){const t=s[e];r[e]=this.getAsset(t)}return this.registerAsset(r),this.removeLoadingAsset(e),r})}loadTexture(e){if(this._loadingAssets[e])return this._loadingAssets[e];const t=this.loadTextureFunction(e);return this.addLoadingAsset(e,t),t}loadTextureFunction(e){return Object(s.a)(this,void 0,void 0,function*(){let t=yield fetch(e+".meta"),n=yield t.json();const i=yield this.loadTextureFile(e,n);return this.registerAsset(i),this.removeLoadingAsset(e),i})}loadTextureFile(e,t){return new Promise(n=>{this.textureLoader.load(e,e=>{Object.keys(t.object).forEach(n=>{"repeat"===n||"center"===n||"offset"===n?(e[n].x=t.object[n][0],e[n].y=t.object[n][1]):"wrap"===n?(e.wrapS=t.object[n][0],e.wrapT=t.object[n][1]):"image"===n||(e[n]=t.object[n])}),this.sceneController&&this.sceneController.renderer.initTexture(e),n(e)})})}addLoadingAsset(e,t){this._loadingAssets[e]=t}removeLoadingAsset(e){delete this._loadingAssets[e]}removeAsset(e){const t=this._assets[e];delete this._assets[e],v.emit("onRemoveAsset",e,t)}clear(){for(const e in this._assets)delete this._assets[e];v.emit("onClearAssets")}assetIsOrphan(e){const t=this.getAsset(e);if(!t)return!1;let n=!0;return traverseComponents(e=>{for(const i in e.interface)Y.indexOf(i)>=0&&e[i]===t&&(n=!1)}),t instanceof i.Material&&App_App.currentScene.traverse(e=>{e&&e.material===t&&(n=!1)}),t instanceof i.Texture&&App_App.currentScene.traverse(e=>{if(e&&e.material instanceof i.Material)for(let s in e.material)e.material[s]instanceof i.Texture&&e.material[s]===t&&(n=!1)}),n}loadAssetConfigs(e={}){const t=this._assetConfigs,n=Object.keys(this._assets);for(const i in t){const n=e[i]&&e[i].override;t[i].override&&!n&&(e[i]=t[i])}n.forEach(n=>{const i=!!t[n]&&t[n].keepLoaded,s=!!e[n]&&e[n].preload;i||s||this.removeAsset(n)}),this._assetConfigs=e,v.emit("onLoadAssetConfigs")}preloadAssets(){return Object(s.a)(this,void 0,void 0,function*(){for(let e in this._assetConfigs)!this._assets[e]&&this._assetConfigs[e].preload&&(yield this.loadAsset(e))})}};function Prop(e){return function(t,n){t.constructor.interface||(t.constructor.interface={}),t.constructor.interface[n]=e}}function PropList(e){return function(t,n){t.constructor.interface||(t.constructor.interface={}),t.constructor.interface[n]=[e]}}let ee,te="",ne=!1,ie={};function decoratorFunc(e,t){if("button"===te&&"function"!==typeof e[t])return Decorators_reset();e.constructor.interface||(e.constructor.interface={}),e.constructor.interface=Object.assign({},e.constructor.interface);const n={type:te,group:ee,options:ie};e.constructor.interface[t]=ne?[n]:n,Decorators_reset()}function Decorators_reset(){ne=!1,ee=void 0,ie={}}class Decorators{num(e,t){return te="Number",ie.min=e,ie.max=t,decoratorFunc}checkbox(){return te="Boolean",decoratorFunc}text(e){return te="String",ie.isTextArea=e,decoratorFunc}code(e){return te="Code","json"===e?ie.lang="application/json":"html"===e?ie.lang="text/html":"glsl"===e&&(ie.lang=e),decoratorFunc}select(){return te="Select",decoratorFunc}vector2(){return te="Vector2",decoratorFunc}vector3(){return te="Vector3",decoratorFunc}prefab(){return te="Prefab",decoratorFunc}material(){return te="Material",decoratorFunc}texture(){return te="Texture",decoratorFunc}object3d(){return te="Object3D",decoratorFunc}audio(e){return te=e?"PositionalAudio":"Audio",decoratorFunc}color(){return te="Color",decoratorFunc}animation(){return te="AnimationClip",decoratorFunc}button(){return te="Button",decoratorFunc}}class ListProp extends Decorators{}const se=new class Props extends Decorators{constructor(){super(...arguments),this._list=new ListProp}get list(){return ne=!0,this._list}data(){return te="Data",decoratorFunc}};function resetClonedSkinnedMeshes(e,t){const n=[],i={},s={};!function parallelTraverse(e,t,n){n(e,t);for(var i=0;i=t||n<0||g&&e-m>=d}function timerExpired(){var e=s();if(shouldInvoke(e))return trailingEdge(e);p=setTimeout(timerExpired,function remainingWait(e){var n=t-(e-f);return g?u(n,d-(e-m)):n}(e))}function trailingEdge(e){return p=void 0,b&&c?invokeFunc(e):(c=h=void 0,l)}function debounced(){var e=s(),n=shouldInvoke(e);if(c=arguments,h=this,f=e,n){if(void 0===p)return function leadingEdge(e){return m=e,p=setTimeout(timerExpired,t),_?invokeFunc(e):l}(f);if(g)return clearTimeout(p),p=setTimeout(timerExpired,t),invokeFunc(f)}return void 0===p&&(p=setTimeout(timerExpired,t)),l}return t=o(t)||0,i(n)&&(_=!!n.leading,d=(g="maxWait"in n)?a(o(n.maxWait)||0,t):d,b="trailing"in n?!!n.trailing:b),debounced.cancel=function cancel(){void 0!==p&&clearTimeout(p),m=0,c=f=h=p=void 0},debounced.flush=function flush(){return void 0===p?l:trailingEdge(s())},debounced}},19:function(e,t,n){var i=n(28),s=n(29);e.exports=function v4(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var r=(e=e||{}).random||(e.rng||i)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t)for(var a=0;a<16;++a)t[o+a]=r[a];return t||s(r)}},24:function(e,t){e.exports=function isObject(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},26:function(e,t,n){var i=n(38),s="object"==typeof self&&self&&self.Object===Object&&self,o=i||s||Function("return this")();e.exports=o},27:function(e,t,n){var i=n(26).Symbol;e.exports=i},28:function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var i=new Uint8Array(16);e.exports=function whatwgRNG(){return n(i),i}}else{var s=new Array(16);e.exports=function mathRNG(){for(var e,t=0;t<16;t++)0===(3&t)&&(e=4294967296*Math.random()),s[t]=e>>>((3&t)<<3)&255;return s}}},29:function(e,t){for(var n=[],i=0;i<256;++i)n[i]=(i+256).toString(16).substr(1);e.exports=function bytesToUuid(e,t){var i=t||0,s=n;return[s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],"-",s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]],s[e[i++]]].join("")}},30:function(e,t,n){"use strict";var i,s="object"===typeof Reflect?Reflect:null,o=s&&"function"===typeof s.apply?s.apply:function ReflectApply(e,t,n){return Function.prototype.apply.call(e,t,n)};i=s&&"function"===typeof s.ownKeys?s.ownKeys:Object.getOwnPropertySymbols?function ReflectOwnKeys(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function ReflectOwnKeys(e){return Object.getOwnPropertyNames(e)};var r=Number.isNaN||function NumberIsNaN(e){return e!==e};function EventEmitter(){EventEmitter.init.call(this)}e.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._eventsCount=0,EventEmitter.prototype._maxListeners=void 0;var a=10;function $getMaxListeners(e){return void 0===e._maxListeners?EventEmitter.defaultMaxListeners:e._maxListeners}function _addListener(e,t,n,i){var s,o,r;if("function"!==typeof n)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n);if(void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),r=o[t]),void 0===r)r=o[t]=n,++e._eventsCount;else if("function"===typeof r?r=o[t]=i?[n,r]:[r,n]:i?r.unshift(n):r.push(n),(s=$getMaxListeners(e))>0&&r.length>s&&!r.warned){r.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=r.length,function ProcessEmitWarning(e){console&&console.warn&&console.warn(e)}(a)}return e}function _onceWrap(e,t,n){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},s=function onceWrapper(){for(var e=[],t=0;t0&&(r=t[0]),r instanceof Error)throw r;var a=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw a.context=r,a}var u=s[e];if(void 0===u)return!1;if("function"===typeof u)o(u,this,t);else{var c=u.length,h=arrayClone(u,c);for(n=0;n=0;o--)if(n[o]===t||n[o].listener===t){r=n[o].listener,s=o;break}if(s<0)return this;0===s?n.shift():function spliceOne(e,t){for(;t+1=0;i--)this.removeListener(e,t[i]);return this},EventEmitter.prototype.listeners=function listeners(e){return _listeners(this,e,!0)},EventEmitter.prototype.rawListeners=function rawListeners(e){return _listeners(this,e,!1)},EventEmitter.listenerCount=function(e,t){return"function"===typeof e.listenerCount?e.listenerCount(t):listenerCount.call(e,t)},EventEmitter.prototype.listenerCount=listenerCount,EventEmitter.prototype.eventNames=function eventNames(){return this._eventsCount>0?i(this._events):[]}},37:function(e,t,n){var i=n(26);e.exports=function now(){return i.Date.now()}},38:function(e,t){var n="object"==typeof global&&global&&global.Object===Object&&global;e.exports=n},39:function(e,t,n){var i=n(24),s=n(40),o=NaN,r=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,c=/^0o[0-7]+$/i,h=parseInt;e.exports=function toNumber(e){if("number"==typeof e)return e;if(s(e))return o;if(i(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(r,"");var n=u.test(e);return n||c.test(e)?h(e.slice(2),n?2:8):a.test(e)?o:+e}},40:function(e,t,n){var i=n(41),s=n(44),o="[object Symbol]";e.exports=function isSymbol(e){return"symbol"==typeof e||s(e)&&i(e)==o}},41:function(e,t,n){var i=n(27),s=n(42),o=n(43),r="[object Null]",a="[object Undefined]",u=i?i.toStringTag:void 0;e.exports=function baseGetTag(e){return null==e?void 0===e?a:r:u&&u in Object(e)?s(e):o(e)}},42:function(e,t,n){var i=n(27),s=Object.prototype,o=s.hasOwnProperty,r=s.toString,a=i?i.toStringTag:void 0;e.exports=function getRawTag(e){var t=o.call(e,a),n=e[a];try{e[a]=void 0;var i=!0}catch(u){}var s=r.call(e);return i&&(t?e[a]=n:delete e[a]),s}},43:function(e,t){var n=Object.prototype.toString;e.exports=function objectToString(e){return n.call(e)}},44:function(e,t){e.exports=function isObjectLike(e){return null!=e&&"object"==typeof e}}})}); //# sourceMappingURL=rogue-engine.js.map