-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
1 lines (1 loc) · 544 KB
/
bundle.js
File metadata and controls
1 lines (1 loc) · 544 KB
1
!function o(a,s,h){function l(r,t){if(!s[r]){if(!a[r]){var e="function"==typeof require&&require;if(!t&&e)return e(r,!0);if(u)return u(r,!0);var i=new Error("Cannot find module '"+r+"'");throw i.code="MODULE_NOT_FOUND",i}var n=s[r]={exports:{}};a[r][0].call(n.exports,function(t){var e=a[r][1][t];return l(e||t)},n,n.exports,o,a,s,h)}return s[r].exports}for(var u="function"==typeof require&&require,t=0;t<h.length;t++)l(h[t]);return l}({1:[function(t,e,r){"use strict";var d=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var r=[],i=!0,n=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);i=!0);}catch(t){n=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(n)throw o}}return r}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")};function i(t){return t&&t.__esModule?t:{default:t}}var m=i(t("three")),n=i(t("load-svg")),o=i(t("tweenr")),h=t("extract-svg-path"),v=i(t("gl-vec3/random")),g=i(t("triangle-centroid")),l=i(t("mesh-reindex")),u=i(t("unindex-mesh")),c=i(t("../")),f=t("three-simplicial-complex")(m.default),p=(0,o.default)({defaultEase:"expoOut"}),y="attribute vec3 direction;\nattribute vec3 centroid;\n\nuniform float animate;\nuniform float opacity;\nuniform float scale;\n\n#define PI 3.14\n\nvoid main() {\n // rotate the triangles\n // each half rotates the opposite direction\n float theta = (1.0 - animate) * (PI * 1.5) * sign(centroid.x);\n mat3 rotMat = mat3(\n vec3(cos(theta), 0.0, sin(theta)),\n vec3(0.0, 1.0, 0.0),\n vec3(-sin(theta), 0.0, cos(theta))\n );\n \n // push outward\n vec3 offset = mix(vec3(0.0), direction.xyz * rotMat, 1.0 - animate);\n \n // scale triangles to their centroids\n vec3 tPos = mix(centroid.xyz, position.xyz, scale) + offset;\n \n gl_Position = projectionMatrix *\n modelViewMatrix *\n vec4(tPos, 1.0);\n}",x="uniform float animate;\nuniform float opacity;\n\nvoid main() {\n gl_FragColor = vec4(vec3(1.0), opacity);\n}",a=[".DS_Store","stringify-anim.svg"].filter(function(t){return/\.svg$/.test(t)}),s=document.querySelector("canvas");s.addEventListener("touchstart",function(t){return t.preventDefault()}),s.addEventListener("contextmenu",function(t){return t.preventDefault()});var w=new m.default.WebGLRenderer({canvas:s,antialias:!0});w.setClearColor(7919871,1);var b=new m.default.Scene,M=new m.default.PerspectiveCamera(50,1,.01,100);M.position.set(0,0,5);var _=0;!function(){function t(){var t=window.innerWidth,e=window.innerHeight;M.aspect=t/e,w.setSize(t,e,!1),M.updateProjectionMatrix(),function t(){w.render(b,M);setTimeout(function(){return t()},100)}()}window.addEventListener("resize",t),t()}(),function(r){r=r||0;var t=a[_++%a.length];(0,n.default)("demo/svg/"+t,function(t,e){if(t)throw t;!function(t,e){e=e||0;var r=(0,h.parse)(t),i=(0,c.default)(r,{scale:10,simplify:.01,randomization:800}),n=function(t,e){for(var r=[],i=[],n=0;n<e.length;n++){var o=d(e[n],3),a=o[0],s=o[1],h=o[2],l=[t[a],t[s],t[h]],u=(0,g.default)(l),c=(new m.default.Vector3).fromArray(u);i.push(c,c,c);var f=(0,v.default)([],Math.random()),p=(new m.default.Vector3).fromArray(f);r.push(p,p,p)}return{direction:{type:"v3",value:r},centroid:{type:"v3",value:i}}}((i=(0,l.default)((0,u.default)(i.positions,i.cells))).positions,i.cells),o=new f(i),a=new m.default.ShaderMaterial({color:16777215,side:m.default.DoubleSide,vertexShader:y,fragmentShader:x,wireframe:!0,transparent:!0,attributes:n,uniforms:{opacity:{type:"f",value:1},scale:{type:"f",value:0},animate:{type:"f",value:0}}}),s=new m.default.Mesh(o,a);b.add(s);p.to(a.uniforms.animate,{value:1,duration:1.5,delay:e,ease:"expoInOut"}),p.to(a.uniforms.scale,{value:1,duration:1,delay:e})}(e,r)})}()},{"../":2,"extract-svg-path":75,"gl-vec3/random":77,"load-svg":83,"mesh-reindex":84,three:113,"three-simplicial-complex":112,"triangle-centroid":114,tweenr:122,"unindex-mesh":127}],2:[function(t,e,r){"use strict";var d=t("parse-svg-path"),m=t("svg-path-contours"),v=t("cdt2d"),g=t("clean-pslg"),y=t("bound-points"),x=t("normalize-path-scale"),w=t("random-float"),b=t("object-assign"),M=t("simplify-path");e.exports=function(t,e){if("string"!=typeof t)throw new TypeError("must provide a string as first parameter");var r;e=b({delaunay:!0,clean:!0,exterior:!1,randomization:0,simplify:0,scale:1},e);var i=d(t),n=m(i,e.scale);if(0<e.simplify&&"number"==typeof e.simplify)for(r=0;r<n.length;r++)n[r]=M(n[r],e.simplify);var o=function(t){for(var e=[],r=[],i=0;i<t.length;i++){for(var n=t[i],o=[],a=0;a<n.length;a++){var s=n[a],h=e.indexOf(s);-1===h&&(e.push(s),h=e.length-1),o.push(h)}r.push(o)}return{positions:e,edges:r}}(n),a=o.positions,s=y(a),h=e.randomization;"number"==typeof h&&0<h&&function(t,e,r){for(var i=e[0],n=e[1],o=0;o<r;o++)t.push([w(i[0],n[0]),w(i[1],n[1])])}(a,s,h);var l=o.edges,u=[];for(r=0;r<l.length;++r)for(var c=l[r],f=0;f<c.length;++f)u.push([c[f],c[(f+1)%c.length]]);!1!==e.clean&&g(a,u);var p=v(a,u,e);!1!==e.normalize&&x(a,s);return function(t){for(var e=0;e<t.length;e++){var r=t[e];r[1]*=-1,r[2]=r[2]||0}}(a),{positions:a,cells:p}}},{"bound-points":26,cdt2d:34,"clean-pslg":39,"normalize-path-scale":87,"object-assign":89,"parse-svg-path":92,"random-float":96,"simplify-path":109,"svg-path-contours":111}],3:[function(t,e,r){e.exports=function(t){var n=0,o=0,a=0,s=0;return t.map(function(t){var e=(t=t.slice())[0],r=e.toUpperCase();if(e!=r)switch(t[0]=r,e){case"a":t[6]+=a,t[7]+=s;break;case"v":t[1]+=s;break;case"h":t[1]+=a;break;default:for(var i=1;i<t.length;)t[i++]+=a,t[i++]+=s}switch(r){case"Z":a=n,s=o;break;case"H":a=t[1];break;case"V":s=t[1];break;case"M":a=n=t[1],s=o=t[2];break;default:a=t[t.length-2],s=t[t.length-1]}return t})}},{}],4:[function(t,e,r){function d(t){return[t[0],t[1]]}function z(t,e){return[t,e]}e.exports=function(t){var F="number"==typeof(t=t||{}).recursion?t.recursion:8,D="number"==typeof t.epsilon?t.epsilon:1.1920929e-7,s="number"==typeof t.pathEpsilon?t.pathEpsilon:1,U="number"==typeof t.angleEpsilon?t.angleEpsilon:.01,B=t.angleTolerance||0,k=t.cuspLimit||0;return function(t,e,r,i,n,o){o||(o=[]);var a=s/(n="number"==typeof n?n:1);return function(t,e,r,i,n,o){n.push(d(t));var a=t[0],s=t[1],h=e[0],l=e[1],u=r[0],c=r[1],f=i[0],p=i[1];(function t(e,r,i,n,o,a,s,h,l,u,c){if(F<c)return;var f=Math.PI;var p=(e+i)/2;var d=(r+n)/2;var m=(i+o)/2;var v=(n+a)/2;var g=(o+s)/2;var y=(a+h)/2;var x=(p+m)/2;var w=(d+v)/2;var b=(m+g)/2;var M=(v+y)/2;var _=(x+b)/2;var S=(w+M)/2;if(0<c){var T,A,C=s-e,E=h-r,L=Math.abs((i-s)*E-(n-h)*C),P=Math.abs((o-s)*E-(a-h)*C);if(D<L&&D<P){if((L+P)*(L+P)<=u*(C*C+E*E)){if(B<U)return void l.push(z(_,S));var R=Math.atan2(a-n,o-i);if(T=Math.abs(R-Math.atan2(n-r,i-e)),A=Math.abs(Math.atan2(h-a,s-o)-R),f<=T&&(T=2*f-T),f<=A&&(A=2*f-A),T+A<B)return void l.push(z(_,S));if(0!==k){if(k<T)return void l.push(z(i,n));if(k<A)return void l.push(z(o,a))}}}else if(D<L){if(L*L<=u*(C*C+E*E)){if(B<U)return void l.push(z(_,S));if(T=Math.abs(Math.atan2(a-n,o-i)-Math.atan2(n-r,i-e)),f<=T&&(T=2*f-T),T<B)return l.push(z(i,n)),void l.push(z(o,a));if(0!==k&&k<T)return void l.push(z(i,n))}}else if(D<P){if(P*P<=u*(C*C+E*E)){if(B<U)return void l.push(z(_,S));if(T=Math.abs(Math.atan2(h-a,s-o)-Math.atan2(a-n,o-i)),f<=T&&(T=2*f-T),T<B)return l.push(z(i,n)),void l.push(z(o,a));if(0!==k&&k<T)return void l.push(z(o,a))}}else if((C=_-(e+s)/2)*C+(E=S-(r+h)/2)*E<=u)return void l.push(z(_,S))}t(e,r,p,d,x,w,_,S,l,u,c+1);t(_,S,b,M,g,y,s,h,l,u,c+1)})(a,s,h,l,u,c,f,p,n,o,0),n.push(d(i))}(t,e,r,i,o,a*=a),o}}},{}],5:[function(t,e,r){e.exports=t("./function")()},{"./function":4}],6:[function(t,e,r){var i=Object.prototype.toString;e.exports=function(t){return t.BYTES_PER_ELEMENT&&"[object ArrayBuffer]"===i.call(t.buffer)||Array.isArray(t)}},{}],7:[function(t,e,r){"use strict";var i=t("./lib/rationalize");e.exports=function(t,e){return i(t[0].mul(e[1]).add(e[0].mul(t[1])),t[1].mul(e[1]))}},{"./lib/rationalize":17}],8:[function(t,e,r){"use strict";e.exports=function(t,e){return t[0].mul(e[1]).cmp(e[0].mul(t[1]))}},{}],9:[function(t,e,r){"use strict";var i=t("./lib/rationalize");e.exports=function(t,e){return i(t[0].mul(e[1]),t[1].mul(e[0]))}},{"./lib/rationalize":17}],10:[function(t,e,r){"use strict";var a=t("./is-rat"),s=t("./lib/is-bn"),h=t("./lib/num-to-bn"),l=t("./lib/str-to-bn"),u=t("./lib/rationalize"),c=t("./div");e.exports=function t(e,r){if(a(e))return r?c(e,t(r)):[e[0].clone(),e[1].clone()];var i=0;var n,o;if(s(e))n=e.clone();else if("string"==typeof e)n=l(e);else{if(0===e)return[h(0),h(1)];if(e===Math.floor(e))n=h(e);else{for(;e!==Math.floor(e);)e*=Math.pow(2,256),i-=256;n=h(e)}}if(a(r))n.mul(r[1]),o=r[0].clone();else if(s(r))o=r.clone();else if("string"==typeof r)o=l(r);else if(r)if(r===Math.floor(r))o=h(r);else{for(;r!==Math.floor(r);)r*=Math.pow(2,256),i+=256;o=h(r)}else o=h(1);0<i?n=n.ushln(i):i<0&&(o=o.ushln(-i));return u(n,o)}},{"./div":9,"./is-rat":11,"./lib/is-bn":15,"./lib/num-to-bn":16,"./lib/rationalize":17,"./lib/str-to-bn":18}],11:[function(t,e,r){"use strict";var i=t("./lib/is-bn");e.exports=function(t){return Array.isArray(t)&&2===t.length&&i(t[0])&&i(t[1])}},{"./lib/is-bn":15}],12:[function(t,e,r){"use strict";var i=t("bn.js");e.exports=function(t){return t.cmp(new i(0))}},{"bn.js":25}],13:[function(t,e,r){"use strict";var a=t("./bn-sign");e.exports=function(t){var e=t.length,r=t.words,i=0;if(1===e)i=r[0];else if(2===e)i=r[0]+67108864*r[1];else for(var n=0;n<e;n++){var o=r[n];i+=o*Math.pow(67108864,n)}return a(t)*i}},{"./bn-sign":12}],14:[function(t,e,r){"use strict";var i=t("double-bits"),n=t("bit-twiddle").countTrailingZeros;e.exports=function(t){var e=n(i.lo(t));if(e<32)return e;var r=n(i.hi(t));if(20<r)return 52;return r+32}},{"bit-twiddle":24,"double-bits":41}],15:[function(t,e,r){"use strict";t("bn.js");e.exports=function(t){return t&&"object"==typeof t&&Boolean(t.words)}},{"bn.js":25}],16:[function(t,e,r){"use strict";var i=t("bn.js"),n=t("double-bits");e.exports=function(t){var e=n.exponent(t);return e<52?new i(t):new i(t*Math.pow(2,52-e)).ushln(e-52)}},{"bn.js":25,"double-bits":41}],17:[function(t,e,r){"use strict";var o=t("./num-to-bn"),a=t("./bn-sign");e.exports=function(t,e){var r=a(t),i=a(e);if(0===r)return[o(0),o(1)];if(0===i)return[o(0),o(0)];i<0&&(t=t.neg(),e=e.neg());var n=t.gcd(e);if(n.cmpn(1))return[t.div(n),e.div(n)];return[t,e]}},{"./bn-sign":12,"./num-to-bn":16}],18:[function(t,e,r){"use strict";var i=t("bn.js");e.exports=function(t){return new i(t)}},{"bn.js":25}],19:[function(t,e,r){"use strict";var i=t("./lib/rationalize");e.exports=function(t,e){return i(t[0].mul(e[0]),t[1].mul(e[1]))}},{"./lib/rationalize":17}],20:[function(t,e,r){"use strict";var i=t("./lib/bn-sign");e.exports=function(t){return i(t[0])*i(t[1])}},{"./lib/bn-sign":12}],21:[function(t,e,r){"use strict";var i=t("./lib/rationalize");e.exports=function(t,e){return i(t[0].mul(e[1]).sub(t[1].mul(e[0])),t[1].mul(e[1]))}},{"./lib/rationalize":17}],22:[function(t,e,r){"use strict";var c=t("./lib/bn-to-num"),f=t("./lib/ctz");e.exports=function(t){var e=t[0],r=t[1];if(0===e.cmpn(0))return 0;var i=e.abs().divmod(r.abs()),n=i.div,o=c(n),a=i.mod,s=e.negative!==r.negative?-1:1;if(0===a.cmpn(0))return s*o;{if(o){var h=f(o)+4,l=c(a.ushln(h).divRound(r));return s*(o+l*Math.pow(2,-h))}var u=r.bitLength()-a.bitLength()+53,l=c(a.ushln(u).divRound(r));return u<1023?s*l*Math.pow(2,-u):(l*=Math.pow(2,-1023),s*l*Math.pow(2,1023-u))}}},{"./lib/bn-to-num":13,"./lib/ctz":14}],23:[function(t,e,r){"use strict";function n(t,e,r,i,n){var o=["function ",t,"(a,l,h,",i.join(","),"){",n?"":"var i=",r?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a[m]"];return n?e.indexOf("c")<0?o.push(";if(x===y){return m}else if(x<=y){"):o.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){"):o.push(";if(",e,"){i=m;"),r?o.push("l=m+1}else{h=m-1}"):o.push("h=m-1}else{l=m+1}"),o.push("}"),n?o.push("return -1};"):o.push("return i};"),o.join("")}function i(t,e,r,i){return new Function([n("A","x"+t+"y",e,["y"],i),n("P","c(x,y)"+t+"0",e,["y","c"],i),"function dispatchBsearch",r,"(a,y,c,l,h){if(typeof(c)==='function'){return P(a,(l===void 0)?0:l|0,(h===void 0)?a.length-1:h|0,y,c)}else{return A(a,(c===void 0)?0:c|0,(l===void 0)?a.length-1:l|0,y)}}return dispatchBsearch",r].join(""))()}e.exports={ge:i(">=",!1,"GE"),gt:i(">",!1,"GT"),lt:i("<",!0,"LT"),le:i("<=",!0,"LE"),eq:i("-",!0,"EQ",!0)}},{}],24:[function(t,e,r){"use strict";"use restrict";function i(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}r.INT_BITS=32,r.INT_MAX=2147483647,r.INT_MIN=-1<<31,r.sign=function(t){return(0<t)-(t<0)},r.abs=function(t){var e=t>>31;return(t^e)-e},r.min=function(t,e){return e^(t^e)&-(t<e)},r.max=function(t,e){return t^(t^e)&-(t<e)},r.isPow2=function(t){return!(t&t-1||!t)},r.log2=function(t){var e,r;return e=(65535<t)<<4,e|=r=(255<(t>>>=e))<<3,e|=r=(15<(t>>>=r))<<2,(e|=r=(3<(t>>>=r))<<1)|(t>>>=r)>>1},r.log10=function(t){return 1e9<=t?9:1e8<=t?8:1e7<=t?7:1e6<=t?6:1e5<=t?5:1e4<=t?4:1e3<=t?3:100<=t?2:10<=t?1:0},r.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},r.countTrailingZeros=i,r.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},r.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},r.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var n=new Array(256);!function(t){for(var e=0;e<256;++e){var r=e,i=e,n=7;for(r>>>=1;r;r>>>=1)i<<=1,i|=1&r,--n;t[e]=i<<n&255}}(n),r.reverse=function(t){return n[255&t]<<24|n[t>>>8&255]<<16|n[t>>>16&255]<<8|n[t>>>24&255]},r.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},r.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},r.interleave3=function(t,e,r){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(r=1227133513&((r=3272356035&((r=251719695&((r=4278190335&((r&=1023)|r<<16))|r<<8))|r<<4))|r<<2))<<2},r.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},r.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>i(t)+1}},{}],25:[function(_,t,e){!function(t,e){"use strict";function v(t,e){if(!t)throw new Error(e||"Assertion failed")}function r(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function g(t,e,r){if(g.isBN(t))return t;this.negative=0,this.words=null,this.length=0,(this.red=null)!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var i;"object"==typeof t?t.exports=g:e.BN=g,(g.BN=g).wordSize=26;try{i=_("buffer").Buffer}catch(t){}function a(t,e,r){for(var i=0,n=Math.min(t.length,r),o=e;o<n;o++){var a=t.charCodeAt(o)-48;i<<=4,i|=49<=a&&a<=54?a-49+10:17<=a&&a<=22?a-17+10:15&a}return i}function c(t,e,r,i){for(var n=0,o=Math.min(t.length,r),a=e;a<o;a++){var s=t.charCodeAt(a)-48;n*=i,n+=49<=s?s-49+10:17<=s?s-17+10:s}return n}g.isBN=function(t){return t instanceof g||null!==t&&"object"==typeof t&&t.constructor.wordSize===g.wordSize&&Array.isArray(t.words)},g.max=function(t,e){return 0<t.cmp(e)?t:e},g.min=function(t,e){return t.cmp(e)<0?t:e},g.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),v(e===(0|e)&&2<=e&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),e,r)},g.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(v(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},g.prototype._initArray=function(t,e,r){if(v("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o,a=0;if("be"===r)for(i=t.length-1,n=0;0<=i;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[n]|=o<<a&67108863,this.words[n+1]=o>>>26-a&67108863,26<=(a+=24)&&(a-=26,n++);else if("le"===r)for(n=i=0;i<t.length;i+=3)o=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[n]|=o<<a&67108863,this.words[n+1]=o>>>26-a&67108863,26<=(a+=24)&&(a-=26,n++);return this.strip()},g.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var i,n,o=0;for(r=t.length-6,i=0;e<=r;r-=6)n=a(t,r,r+6),this.words[i]|=n<<o&67108863,this.words[i+1]|=n>>>26-o&4194303,26<=(o+=24)&&(o-=26,i++);r+6!==e&&(n=a(t,e,r+6),this.words[i]|=n<<o&67108863,this.words[i+1]|=n>>>26-o&4194303),this.strip()},g.prototype._parseBase=function(t,e,r){this.words=[0];for(var i=0,n=this.length=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,h=0,l=r;l<s;l+=i)h=c(t,l,l+i,e),this.imuln(n),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==a){var u=1;for(h=c(t,l,t.length,e),l=0;l<a;l++)u*=e;this.imuln(u),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}},g.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},g.prototype.clone=function(){var t=new g(null);return this.copy(t),t},g.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},g.prototype.strip=function(){for(;1<this.length&&0===this.words[this.length-1];)this.length--;return this._normSign()},g.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},g.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],p=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],d=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function n(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;i=(r.length=i)-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var l=1;l<i;l++){for(var u=h>>>26,c=67108863&h,f=Math.min(l,e.length-1),p=Math.max(0,l-t.length+1);p<=f;p++){var d=l-p|0;u+=(a=(n=0|t.words[d])*(o=0|e.words[p])+c)/67108864|0,c=67108863&a}r.words[l]=0|c,h=0|u}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}g.prototype.toString=function(t,e){var r;if(e=0|e||1,16===(t=t||10)||"hex"===t){r="";for(var i=0,n=0,o=0;o<this.length;o++){var a=this.words[o],s=(16777215&(a<<i|n)).toString(16);r=0!==(n=a>>>24-i&16777215)||o!==this.length-1?f[6-s.length]+s+r:s+r,26<=(i+=2)&&(i-=26,o--)}for(0!==n&&(r=n.toString(16)+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&2<=t&&t<=36){var h=p[t],l=d[t];r="";var u=this.clone();for(u.negative=0;!u.isZero();){var c=u.modn(l).toString(t);r=(u=u.idivn(l)).isZero()?c+r:f[h-c.length]+c+r}for(this.isZero()&&(r="0"+r);r.length%e!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}v(!1,"Base should be between 2 and 36")},g.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:2<this.length&&v(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},g.prototype.toJSON=function(){return this.toString(16)},g.prototype.toBuffer=function(t,e){return v(void 0!==i),this.toArrayLike(i,t,e)},g.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},g.prototype.toArrayLike=function(t,e,r){var i=this.byteLength(),n=r||Math.max(1,i);v(i<=n,"byte array longer than desired length"),v(0<n,"Requested array length <= 0"),this.strip();var o,a,s="le"===e,h=new t(n),l=this.clone();if(s){for(a=0;!l.isZero();a++)o=l.andln(255),l.iushrn(8),h[a]=o;for(;a<n;a++)h[a]=0}else{for(a=0;a<n-i;a++)h[a]=0;for(a=0;!l.isZero();a++)o=l.andln(255),l.iushrn(8),h[n-a-1]=o}return h},g.prototype._countBits=Math.clz32?function(t){return 32-Math.clz32(t)}:function(t){var e=t,r=0;return 4096<=e&&(r+=13,e>>>=13),64<=e&&(r+=7,e>>>=7),8<=e&&(r+=4,e>>>=4),2<=e&&(r+=2,e>>>=2),r+e},g.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},g.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},g.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},g.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},g.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},g.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},g.prototype.isNeg=function(){return 0!==this.negative},g.prototype.neg=function(){return this.clone().ineg()},g.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},g.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},g.prototype.ior=function(t){return v(0==(this.negative|t.negative)),this.iuor(t)},g.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},g.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},g.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},g.prototype.iand=function(t){return v(0==(this.negative|t.negative)),this.iuand(t)},g.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},g.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},g.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this.strip()},g.prototype.ixor=function(t){return v(0==(this.negative|t.negative)),this.iuxor(t)},g.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},g.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},g.prototype.inotn=function(t){v("number"==typeof t&&0<=t);var e=0|Math.ceil(t/26),r=t%26;this._expand(e),0<r&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return 0<r&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},g.prototype.notn=function(t){return this.clone().inotn(t)},g.prototype.setn=function(t,e){v("number"==typeof t&&0<=t);var r=t/26|0,i=t%26;return this._expand(r+1),this.words[r]=e?this.words[r]|1<<i:this.words[r]&~(1<<i),this.strip()},g.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},g.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},g.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;0<n?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this.strip()},g.prototype.sub=function(t){return this.clone().isub(t)};var o=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,l=0,u=0|a[0],c=8191&u,f=u>>>13,p=0|a[1],d=8191&p,m=p>>>13,v=0|a[2],g=8191&v,y=v>>>13,x=0|a[3],w=8191&x,b=x>>>13,M=0|a[4],_=8191&M,S=M>>>13,T=0|a[5],A=8191&T,C=T>>>13,E=0|a[6],L=8191&E,P=E>>>13,R=0|a[7],F=8191&R,D=R>>>13,U=0|a[8],B=8191&U,k=U>>>13,z=0|a[9],V=8191&z,N=z>>>13,O=0|s[0],I=8191&O,G=O>>>13,H=0|s[1],W=8191&H,j=H>>>13,X=0|s[2],q=8191&X,Y=X>>>13,K=0|s[3],Z=8191&K,Q=K>>>13,J=0|s[4],$=8191&J,tt=J>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,lt=st>>>13,ut=0|s[8],ct=8191&ut,ft=ut>>>13,pt=0|s[9],dt=8191&pt,mt=pt>>>13;r.negative=t.negative^e.negative,r.length=19;var vt=(l+(i=Math.imul(c,I))|0)+((8191&(n=(n=Math.imul(c,G))+Math.imul(f,I)|0))<<13)|0;l=((o=Math.imul(f,G))+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(d,I),n=(n=Math.imul(d,G))+Math.imul(m,I)|0,o=Math.imul(m,G);var gt=(l+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,j)|0)+Math.imul(f,W)|0))<<13)|0;l=((o=o+Math.imul(f,j)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(g,I),n=(n=Math.imul(g,G))+Math.imul(y,I)|0,o=Math.imul(y,G),i=i+Math.imul(d,W)|0,n=(n=n+Math.imul(d,j)|0)+Math.imul(m,W)|0,o=o+Math.imul(m,j)|0;var yt=(l+(i=i+Math.imul(c,q)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(f,q)|0))<<13)|0;l=((o=o+Math.imul(f,Y)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(w,I),n=(n=Math.imul(w,G))+Math.imul(b,I)|0,o=Math.imul(b,G),i=i+Math.imul(g,W)|0,n=(n=n+Math.imul(g,j)|0)+Math.imul(y,W)|0,o=o+Math.imul(y,j)|0,i=i+Math.imul(d,q)|0,n=(n=n+Math.imul(d,Y)|0)+Math.imul(m,q)|0,o=o+Math.imul(m,Y)|0;var xt=(l+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,Q)|0)+Math.imul(f,Z)|0))<<13)|0;l=((o=o+Math.imul(f,Q)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(_,I),n=(n=Math.imul(_,G))+Math.imul(S,I)|0,o=Math.imul(S,G),i=i+Math.imul(w,W)|0,n=(n=n+Math.imul(w,j)|0)+Math.imul(b,W)|0,o=o+Math.imul(b,j)|0,i=i+Math.imul(g,q)|0,n=(n=n+Math.imul(g,Y)|0)+Math.imul(y,q)|0,o=o+Math.imul(y,Y)|0,i=i+Math.imul(d,Z)|0,n=(n=n+Math.imul(d,Q)|0)+Math.imul(m,Z)|0,o=o+Math.imul(m,Q)|0;var wt=(l+(i=i+Math.imul(c,$)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(f,$)|0))<<13)|0;l=((o=o+Math.imul(f,tt)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(A,I),n=(n=Math.imul(A,G))+Math.imul(C,I)|0,o=Math.imul(C,G),i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,j)|0)+Math.imul(S,W)|0,o=o+Math.imul(S,j)|0,i=i+Math.imul(w,q)|0,n=(n=n+Math.imul(w,Y)|0)+Math.imul(b,q)|0,o=o+Math.imul(b,Y)|0,i=i+Math.imul(g,Z)|0,n=(n=n+Math.imul(g,Q)|0)+Math.imul(y,Z)|0,o=o+Math.imul(y,Q)|0,i=i+Math.imul(d,$)|0,n=(n=n+Math.imul(d,tt)|0)+Math.imul(m,$)|0,o=o+Math.imul(m,tt)|0;var bt=(l+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(f,rt)|0))<<13)|0;l=((o=o+Math.imul(f,it)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(L,I),n=(n=Math.imul(L,G))+Math.imul(P,I)|0,o=Math.imul(P,G),i=i+Math.imul(A,W)|0,n=(n=n+Math.imul(A,j)|0)+Math.imul(C,W)|0,o=o+Math.imul(C,j)|0,i=i+Math.imul(_,q)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(S,q)|0,o=o+Math.imul(S,Y)|0,i=i+Math.imul(w,Z)|0,n=(n=n+Math.imul(w,Q)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,Q)|0,i=i+Math.imul(g,$)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,tt)|0,i=i+Math.imul(d,rt)|0,n=(n=n+Math.imul(d,it)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,it)|0;var Mt=(l+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(f,ot)|0))<<13)|0;l=((o=o+Math.imul(f,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(F,I),n=(n=Math.imul(F,G))+Math.imul(D,I)|0,o=Math.imul(D,G),i=i+Math.imul(L,W)|0,n=(n=n+Math.imul(L,j)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,j)|0,i=i+Math.imul(A,q)|0,n=(n=n+Math.imul(A,Y)|0)+Math.imul(C,q)|0,o=o+Math.imul(C,Y)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,Q)|0)+Math.imul(S,Z)|0,o=o+Math.imul(S,Q)|0,i=i+Math.imul(w,$)|0,n=(n=n+Math.imul(w,tt)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,tt)|0,i=i+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,it)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,it)|0,i=i+Math.imul(d,ot)|0,n=(n=n+Math.imul(d,at)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,at)|0;var _t=(l+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,lt)|0)+Math.imul(f,ht)|0))<<13)|0;l=((o=o+Math.imul(f,lt)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(B,I),n=(n=Math.imul(B,G))+Math.imul(k,I)|0,o=Math.imul(k,G),i=i+Math.imul(F,W)|0,n=(n=n+Math.imul(F,j)|0)+Math.imul(D,W)|0,o=o+Math.imul(D,j)|0,i=i+Math.imul(L,q)|0,n=(n=n+Math.imul(L,Y)|0)+Math.imul(P,q)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(A,Z)|0,n=(n=n+Math.imul(A,Q)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,Q)|0,i=i+Math.imul(_,$)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(S,$)|0,o=o+Math.imul(S,tt)|0,i=i+Math.imul(w,rt)|0,n=(n=n+Math.imul(w,it)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,it)|0,i=i+Math.imul(g,ot)|0,n=(n=n+Math.imul(g,at)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,at)|0,i=i+Math.imul(d,ht)|0,n=(n=n+Math.imul(d,lt)|0)+Math.imul(m,ht)|0,o=o+Math.imul(m,lt)|0;var St=(l+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,ft)|0)+Math.imul(f,ct)|0))<<13)|0;l=((o=o+Math.imul(f,ft)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(V,I),n=(n=Math.imul(V,G))+Math.imul(N,I)|0,o=Math.imul(N,G),i=i+Math.imul(B,W)|0,n=(n=n+Math.imul(B,j)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,j)|0,i=i+Math.imul(F,q)|0,n=(n=n+Math.imul(F,Y)|0)+Math.imul(D,q)|0,o=o+Math.imul(D,Y)|0,i=i+Math.imul(L,Z)|0,n=(n=n+Math.imul(L,Q)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,Q)|0,i=i+Math.imul(A,$)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(S,rt)|0,o=o+Math.imul(S,it)|0,i=i+Math.imul(w,ot)|0,n=(n=n+Math.imul(w,at)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,at)|0,i=i+Math.imul(g,ht)|0,n=(n=n+Math.imul(g,lt)|0)+Math.imul(y,ht)|0,o=o+Math.imul(y,lt)|0,i=i+Math.imul(d,ct)|0,n=(n=n+Math.imul(d,ft)|0)+Math.imul(m,ct)|0,o=o+Math.imul(m,ft)|0;var Tt=(l+(i=i+Math.imul(c,dt)|0)|0)+((8191&(n=(n=n+Math.imul(c,mt)|0)+Math.imul(f,dt)|0))<<13)|0;l=((o=o+Math.imul(f,mt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(V,W),n=(n=Math.imul(V,j))+Math.imul(N,W)|0,o=Math.imul(N,j),i=i+Math.imul(B,q)|0,n=(n=n+Math.imul(B,Y)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(F,Z)|0,n=(n=n+Math.imul(F,Q)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,Q)|0,i=i+Math.imul(L,$)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(A,rt)|0,n=(n=n+Math.imul(A,it)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,at)|0,i=i+Math.imul(w,ht)|0,n=(n=n+Math.imul(w,lt)|0)+Math.imul(b,ht)|0,o=o+Math.imul(b,lt)|0,i=i+Math.imul(g,ct)|0,n=(n=n+Math.imul(g,ft)|0)+Math.imul(y,ct)|0,o=o+Math.imul(y,ft)|0;var At=(l+(i=i+Math.imul(d,dt)|0)|0)+((8191&(n=(n=n+Math.imul(d,mt)|0)+Math.imul(m,dt)|0))<<13)|0;l=((o=o+Math.imul(m,mt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(V,q),n=(n=Math.imul(V,Y))+Math.imul(N,q)|0,o=Math.imul(N,Y),i=i+Math.imul(B,Z)|0,n=(n=n+Math.imul(B,Q)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,Q)|0,i=i+Math.imul(F,$)|0,n=(n=n+Math.imul(F,tt)|0)+Math.imul(D,$)|0,o=o+Math.imul(D,tt)|0,i=i+Math.imul(L,rt)|0,n=(n=n+Math.imul(L,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(A,ot)|0,n=(n=n+Math.imul(A,at)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,lt)|0)+Math.imul(S,ht)|0,o=o+Math.imul(S,lt)|0,i=i+Math.imul(w,ct)|0,n=(n=n+Math.imul(w,ft)|0)+Math.imul(b,ct)|0,o=o+Math.imul(b,ft)|0;var Ct=(l+(i=i+Math.imul(g,dt)|0)|0)+((8191&(n=(n=n+Math.imul(g,mt)|0)+Math.imul(y,dt)|0))<<13)|0;l=((o=o+Math.imul(y,mt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(V,Z),n=(n=Math.imul(V,Q))+Math.imul(N,Z)|0,o=Math.imul(N,Q),i=i+Math.imul(B,$)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(F,rt)|0,n=(n=n+Math.imul(F,it)|0)+Math.imul(D,rt)|0,o=o+Math.imul(D,it)|0,i=i+Math.imul(L,ot)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(A,ht)|0,n=(n=n+Math.imul(A,lt)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,lt)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,ft)|0)+Math.imul(S,ct)|0,o=o+Math.imul(S,ft)|0;var Et=(l+(i=i+Math.imul(w,dt)|0)|0)+((8191&(n=(n=n+Math.imul(w,mt)|0)+Math.imul(b,dt)|0))<<13)|0;l=((o=o+Math.imul(b,mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(V,$),n=(n=Math.imul(V,tt))+Math.imul(N,$)|0,o=Math.imul(N,tt),i=i+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(F,ot)|0,n=(n=n+Math.imul(F,at)|0)+Math.imul(D,ot)|0,o=o+Math.imul(D,at)|0,i=i+Math.imul(L,ht)|0,n=(n=n+Math.imul(L,lt)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,lt)|0,i=i+Math.imul(A,ct)|0,n=(n=n+Math.imul(A,ft)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,ft)|0;var Lt=(l+(i=i+Math.imul(_,dt)|0)|0)+((8191&(n=(n=n+Math.imul(_,mt)|0)+Math.imul(S,dt)|0))<<13)|0;l=((o=o+Math.imul(S,mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,i=Math.imul(V,rt),n=(n=Math.imul(V,it))+Math.imul(N,rt)|0,o=Math.imul(N,it),i=i+Math.imul(B,ot)|0,n=(n=n+Math.imul(B,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(F,ht)|0,n=(n=n+Math.imul(F,lt)|0)+Math.imul(D,ht)|0,o=o+Math.imul(D,lt)|0,i=i+Math.imul(L,ct)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,ft)|0;var Pt=(l+(i=i+Math.imul(A,dt)|0)|0)+((8191&(n=(n=n+Math.imul(A,mt)|0)+Math.imul(C,dt)|0))<<13)|0;l=((o=o+Math.imul(C,mt)|0)+(n>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(V,ot),n=(n=Math.imul(V,at))+Math.imul(N,ot)|0,o=Math.imul(N,at),i=i+Math.imul(B,ht)|0,n=(n=n+Math.imul(B,lt)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,lt)|0,i=i+Math.imul(F,ct)|0,n=(n=n+Math.imul(F,ft)|0)+Math.imul(D,ct)|0,o=o+Math.imul(D,ft)|0;var Rt=(l+(i=i+Math.imul(L,dt)|0)|0)+((8191&(n=(n=n+Math.imul(L,mt)|0)+Math.imul(P,dt)|0))<<13)|0;l=((o=o+Math.imul(P,mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(V,ht),n=(n=Math.imul(V,lt))+Math.imul(N,ht)|0,o=Math.imul(N,lt),i=i+Math.imul(B,ct)|0,n=(n=n+Math.imul(B,ft)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,ft)|0;var Ft=(l+(i=i+Math.imul(F,dt)|0)|0)+((8191&(n=(n=n+Math.imul(F,mt)|0)+Math.imul(D,dt)|0))<<13)|0;l=((o=o+Math.imul(D,mt)|0)+(n>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,i=Math.imul(V,ct),n=(n=Math.imul(V,ft))+Math.imul(N,ct)|0,o=Math.imul(N,ft);var Dt=(l+(i=i+Math.imul(B,dt)|0)|0)+((8191&(n=(n=n+Math.imul(B,mt)|0)+Math.imul(k,dt)|0))<<13)|0;l=((o=o+Math.imul(k,mt)|0)+(n>>>13)|0)+(Dt>>>26)|0,Dt&=67108863;var Ut=(l+(i=Math.imul(V,dt))|0)+((8191&(n=(n=Math.imul(V,mt))+Math.imul(N,dt)|0))<<13)|0;return l=((o=Math.imul(N,mt))+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,h[0]=vt,h[1]=gt,h[2]=yt,h[3]=xt,h[4]=wt,h[5]=bt,h[6]=Mt,h[7]=_t,h[8]=St,h[9]=Tt,h[10]=At,h[11]=Ct,h[12]=Et,h[13]=Lt,h[14]=Pt,h[15]=Rt,h[16]=Ft,h[17]=Dt,h[18]=Ut,0!==l&&(h[19]=l,r.length++),r};function s(t,e,r){return(new h).mulp(t,e,r)}function h(t,e){this.x=t,this.y=e}Math.imul||(o=n),g.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?o(this,t,e):r<63?n(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),l=Math.max(0,o-t.length+1);l<=h;l++){var u=o-l,c=(0|t.words[u])*(0|e.words[l]),f=67108863&c;s=67108863&(f=f+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(f>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r.strip()}(this,t,e):s(this,t,e)},h.prototype.makeRBT=function(t){for(var e=new Array(t),r=g.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,r,t);return e},h.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var i=0,n=0;n<e;n++)i|=(1&t)<<e-n-1,t>>=1;return i},h.prototype.permute=function(t,e,r,i,n,o){for(var a=0;a<o;a++)i[a]=e[t[a]],n[a]=r[t[a]]},h.prototype.transform=function(t,e,r,i,n,o){this.permute(o,t,e,r,i,n);for(var a=1;a<n;a<<=1)for(var s=a<<1,h=Math.cos(2*Math.PI/s),l=Math.sin(2*Math.PI/s),u=0;u<n;u+=s)for(var c=h,f=l,p=0;p<a;p++){var d=r[u+p],m=i[u+p],v=r[u+p+a],g=i[u+p+a],y=c*v-f*g;g=c*g+f*v,v=y,r[u+p]=d+v,i[u+p]=m+g,r[u+p+a]=d-v,i[u+p+a]=m-g,p!==s&&(y=h*c-l*f,f=h*f+l*c,c=y)}},h.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),i=1&r,n=0;for(r=r/2|0;r;r>>>=1)n++;return 1<<n+1+i},h.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var i=0;i<r/2;i++){var n=t[i];t[i]=t[r-i-1],t[r-i-1]=n,n=e[i],e[i]=-e[r-i-1],e[r-i-1]=-n}},h.prototype.normalize13b=function(t,e){for(var r=0,i=0;i<e/2;i++){var n=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+r;t[i]=67108863&n,r=n<67108864?0:n/67108864|0}return t},h.prototype.convert13b=function(t,e,r,i){for(var n=0,o=0;o<e;o++)n+=0|t[o],r[2*o]=8191&n,n>>>=13,r[2*o+1]=8191&n,n>>>=13;for(o=2*e;o<i;++o)r[o]=0;v(0===n),v(0==(-8192&n))},h.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},h.prototype.mulp=function(t,e,r){var i=2*this.guessLen13b(t.length,e.length),n=this.makeRBT(i),o=this.stub(i),a=new Array(i),s=new Array(i),h=new Array(i),l=new Array(i),u=new Array(i),c=new Array(i),f=r.words;f.length=i,this.convert13b(t.words,t.length,a,i),this.convert13b(e.words,e.length,l,i),this.transform(a,o,s,h,i,n),this.transform(l,o,u,c,i,n);for(var p=0;p<i;p++){var d=s[p]*u[p]-h[p]*c[p];h[p]=s[p]*c[p]+h[p]*u[p],s[p]=d}return this.conjugate(s,h,i),this.transform(s,h,f,o,i,n),this.conjugate(f,o,i),this.normalize13b(f,i),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},g.prototype.mul=function(t){var e=new g(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},g.prototype.mulf=function(t){var e=new g(null);return e.words=new Array(this.length+t.length),s(this,t,e)},g.prototype.imul=function(t){return this.clone().mulTo(t,this)},g.prototype.imuln=function(t){v("number"==typeof t),v(t<67108864);for(var e=0,r=0;r<this.length;r++){var i=(0|this.words[r])*t,n=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=n>>>26,this.words[r]=67108863&n}return 0!==e&&(this.words[r]=e,this.length++),this},g.prototype.muln=function(t){return this.clone().imuln(t)},g.prototype.sqr=function(){return this.mul(this)},g.prototype.isqr=function(){return this.imul(this.clone())},g.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=(t.words[i]&1<<n)>>>n}return e}(t);if(0===e.length)return new g(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var n=r.sqr();i<e.length;i++,n=n.sqr())0!==e[i]&&(r=r.mul(n));return r},g.prototype.iushln=function(t){v("number"==typeof t&&0<=t);var e,r=t%26,i=(t-r)/26,n=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&n,s=(0|this.words[e])-a<<r;this.words[e]=s|o,o=a>>>26-r}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;0<=e;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this.strip()},g.prototype.ishln=function(t){return v(0===this.negative),this.iushln(t)},g.prototype.iushrn=function(t,e,r){var i;v("number"==typeof t&&0<=t),i=e?(e-e%26)/26:0;var n=t%26,o=Math.min((t-n)/26,this.length),a=67108863^67108863>>>n<<n,s=r;if(i-=o,i=Math.max(0,i),s){for(var h=0;h<o;h++)s.words[h]=this.words[h];s.length=o}if(0===o);else if(this.length>o)for(this.length-=o,h=0;h<this.length;h++)this.words[h]=this.words[h+o];else this.words[0]=0,this.length=1;var l=0;for(h=this.length-1;0<=h&&(0!==l||i<=h);h--){var u=0|this.words[h];this.words[h]=l<<26-n|u>>>n,l=u&a}return s&&0!==l&&(s.words[s.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},g.prototype.ishrn=function(t,e,r){return v(0===this.negative),this.iushrn(t,e,r)},g.prototype.shln=function(t){return this.clone().ishln(t)},g.prototype.ushln=function(t){return this.clone().iushln(t)},g.prototype.shrn=function(t){return this.clone().ishrn(t)},g.prototype.ushrn=function(t){return this.clone().iushrn(t)},g.prototype.testn=function(t){v("number"==typeof t&&0<=t);var e=t%26,r=(t-e)/26,i=1<<e;return!(this.length<=r)&&!!(this.words[r]&i)},g.prototype.imaskn=function(t){v("number"==typeof t&&0<=t);var e=t%26,r=(t-e)/26;if(v(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==e&&r++,this.length=Math.min(r,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this.strip()},g.prototype.maskn=function(t){return this.clone().imaskn(t)},g.prototype.iaddn=function(t){return v("number"==typeof t),v(t<67108864),t<0?this.isubn(-t):0!==this.negative?(1===this.length&&(0|this.words[0])<t?(this.words[0]=t-(0|this.words[0]),this.negative=0):(this.negative=0,this.isubn(t),this.negative=1),this):this._iaddn(t)},g.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&67108864<=this.words[e];e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},g.prototype.isubn=function(t){if(v("number"==typeof t),v(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},g.prototype.addn=function(t){return this.clone().iaddn(t)},g.prototype.subn=function(t){return this.clone().isubn(t)},g.prototype.iabs=function(){return this.negative=0,this},g.prototype.abs=function(){return this.clone().iabs()},g.prototype._ishlnsubmul=function(t,e,r){var i,n,o=t.length+r;this._expand(o);var a=0;for(i=0;i<t.length;i++){n=(0|this.words[i+r])+a;var s=(0|t.words[i])*e;a=((n-=67108863&s)>>26)-(s/67108864|0),this.words[i+r]=67108863&n}for(;i<this.length-r;i++)a=(n=(0|this.words[i+r])+a)>>26,this.words[i+r]=67108863&n;if(0===a)return this.strip();for(v(-1===a),i=a=0;i<this.length;i++)a=(n=-(0|this.words[i])+a)>>26,this.words[i]=67108863&n;return this.negative=1,this.strip()},g.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),n=t,o=0|n.words[n.length-1];0!==(r=26-this._countBits(o))&&(n=n.ushln(r),i.iushln(r),o=0|n.words[n.length-1]);var a,s=i.length-n.length;if("mod"!==e){(a=new g(null)).length=s+1,a.words=new Array(a.length);for(var h=0;h<a.length;h++)a.words[h]=0}var l=i.clone()._ishlnsubmul(n,1,s);0===l.negative&&(i=l,a&&(a.words[s]=1));for(var u=s-1;0<=u;u--){var c=67108864*(0|i.words[n.length+u])+(0|i.words[n.length+u-1]);for(c=Math.min(c/o|0,67108863),i._ishlnsubmul(n,c,u);0!==i.negative;)c--,i.negative=0,i._ishlnsubmul(n,1,u),i.isZero()||(i.negative^=1);a&&(a.words[u]=c)}return a&&a.strip(),i.strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:a||null,mod:i}},g.prototype.divmod=function(t,e,r){return v(!t.isZero()),this.isZero()?{div:new g(0),mod:new g(0)}:0!==this.negative&&0===t.negative?(o=this.neg().divmod(t,e),"mod"!==e&&(i=o.div.neg()),"div"!==e&&(n=o.mod.neg(),r&&0!==n.negative&&n.iadd(t)),{div:i,mod:n}):0===this.negative&&0!==t.negative?(o=this.divmod(t.neg(),e),"mod"!==e&&(i=o.div.neg()),{div:i,mod:o.mod}):0!=(this.negative&t.negative)?(o=this.neg().divmod(t.neg(),e),"div"!==e&&(n=o.mod.neg(),r&&0!==n.negative&&n.isub(t)),{div:o.div,mod:n}):t.length>this.length||this.cmp(t)<0?{div:new g(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new g(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new g(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,n,o},g.prototype.div=function(t){return this.divmod(t,"div",!1).div},g.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},g.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},g.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},g.prototype.modn=function(t){v(t<=67108863);for(var e=(1<<26)%t,r=0,i=this.length-1;0<=i;i--)r=(e*r+(0|this.words[i]))%t;return r},g.prototype.idivn=function(t){v(t<=67108863);for(var e=0,r=this.length-1;0<=r;r--){var i=(0|this.words[r])+67108864*e;this.words[r]=i/t|0,e=i%t}return this.strip()},g.prototype.divn=function(t){return this.clone().idivn(t)},g.prototype.egcd=function(t){v(0===t.negative),v(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new g(1),n=new g(0),o=new g(0),a=new g(1),s=0;e.isEven()&&r.isEven();)e.iushrn(1),r.iushrn(1),++s;for(var h=r.clone(),l=e.clone();!e.isZero();){for(var u=0,c=1;0==(e.words[0]&c)&&u<26;++u,c<<=1);if(0<u)for(e.iushrn(u);0<u--;)(i.isOdd()||n.isOdd())&&(i.iadd(h),n.isub(l)),i.iushrn(1),n.iushrn(1);for(var f=0,p=1;0==(r.words[0]&p)&&f<26;++f,p<<=1);if(0<f)for(r.iushrn(f);0<f--;)(o.isOdd()||a.isOdd())&&(o.iadd(h),a.isub(l)),o.iushrn(1),a.iushrn(1);0<=e.cmp(r)?(e.isub(r),i.isub(o),n.isub(a)):(r.isub(e),o.isub(i),a.isub(n))}return{a:o,b:a,gcd:r.iushln(s)}},g.prototype._invmp=function(t){v(0===t.negative),v(!t.isZero());var e=this,r=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,n=new g(1),o=new g(0),a=r.clone();0<e.cmpn(1)&&0<r.cmpn(1);){for(var s=0,h=1;0==(e.words[0]&h)&&s<26;++s,h<<=1);if(0<s)for(e.iushrn(s);0<s--;)n.isOdd()&&n.iadd(a),n.iushrn(1);for(var l=0,u=1;0==(r.words[0]&u)&&l<26;++l,u<<=1);if(0<l)for(r.iushrn(l);0<l--;)o.isOdd()&&o.iadd(a),o.iushrn(1);0<=e.cmp(r)?(e.isub(r),n.isub(o)):(r.isub(e),o.isub(n))}return(i=0===e.cmpn(1)?n:o).cmpn(0)<0&&i.iadd(t),i},g.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0;for(var i=r.negative=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},g.prototype.invm=function(t){return this.egcd(t).a.umod(t)},g.prototype.isEven=function(){return 0==(1&this.words[0])},g.prototype.isOdd=function(){return 1==(1&this.words[0])},g.prototype.andln=function(t){return this.words[0]&t},g.prototype.bincn=function(t){v("number"==typeof t);var e=t%26,r=(t-e)/26,i=1<<e;if(this.length<=r)return this._expand(r+1),this.words[r]|=i,this;for(var n=i,o=r;0!==n&&o<this.length;o++){var a=0|this.words[o];n=(a+=n)>>>26,a&=67108863,this.words[o]=a}return 0!==n&&(this.words[o]=n,this.length++),this},g.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},g.prototype.cmpn=function(t){var e,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),1<this.length)e=1;else{r&&(t=-t),v(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},g.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},g.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;0<=r;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:n<i&&(e=1);break}}return e},g.prototype.gtn=function(t){return 1===this.cmpn(t)},g.prototype.gt=function(t){return 1===this.cmp(t)},g.prototype.gten=function(t){return 0<=this.cmpn(t)},g.prototype.gte=function(t){return 0<=this.cmp(t)},g.prototype.ltn=function(t){return-1===this.cmpn(t)},g.prototype.lt=function(t){return-1===this.cmp(t)},g.prototype.lten=function(t){return this.cmpn(t)<=0},g.prototype.lte=function(t){return this.cmp(t)<=0},g.prototype.eqn=function(t){return 0===this.cmpn(t)},g.prototype.eq=function(t){return 0===this.cmp(t)},g.red=function(t){return new b(t)},g.prototype.toRed=function(t){return v(!this.red,"Already a number in reduction context"),v(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},g.prototype.fromRed=function(){return v(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},g.prototype._forceRed=function(t){return this.red=t,this},g.prototype.forceRed=function(t){return v(!this.red,"Already a number in reduction context"),this._forceRed(t)},g.prototype.redAdd=function(t){return v(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},g.prototype.redIAdd=function(t){return v(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},g.prototype.redSub=function(t){return v(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},g.prototype.redISub=function(t){return v(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},g.prototype.redShl=function(t){return v(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},g.prototype.redMul=function(t){return v(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},g.prototype.redIMul=function(t){return v(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},g.prototype.redSqr=function(){return v(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},g.prototype.redISqr=function(){return v(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},g.prototype.redSqrt=function(){return v(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},g.prototype.redInvm=function(){return v(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},g.prototype.redNeg=function(){return v(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},g.prototype.redPow=function(t){return v(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var l={k256:null,p224:null,p192:null,p25519:null};function u(t,e){this.name=t,this.p=new g(e,16),this.n=this.p.bitLength(),this.k=new g(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function m(){u.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function y(){u.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function x(){u.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){u.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function b(t){if("string"==typeof t){var e=g._prime(t);this.m=e.p,this.prime=e}else v(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function M(t){b.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new g(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}u.prototype._tmp=function(){var t=new g(null);return t.words=new Array(Math.ceil(this.n/13)),t},u.prototype.ireduce=function(t){for(var e,r=t;this.split(r,this.tmp),(e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength())>this.n;);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):0<i?r.isub(this.p):r.strip(),r},u.prototype.split=function(t,e){t.iushrn(this.n,0,e)},u.prototype.imulK=function(t){return t.imul(this.k)},r(m,u),m.prototype.split=function(t,e){for(var r=Math.min(t.length,9),i=0;i<r;i++)e.words[i]=t.words[i];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var n=t.words[9];for(e.words[e.length++]=4194303&n,i=10;i<t.length;i++){var o=0|t.words[i];t.words[i-10]=(4194303&o)<<4|n>>>22,n=o}n>>>=22,0===(t.words[i-10]=n)&&10<t.length?t.length-=10:t.length-=9},m.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},r(y,u),r(x,u),r(w,u),w.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},g._prime=function(t){if(l[t])return l[t];var e;if("k256"===t)e=new m;else if("p224"===t)e=new y;else if("p192"===t)e=new x;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new w}return l[t]=e},b.prototype._verify1=function(t){v(0===t.negative,"red works only with positives"),v(t.red,"red works only with red numbers")},b.prototype._verify2=function(t,e){v(0==(t.negative|e.negative),"red works only with positives"),v(t.red&&t.red===e.red,"red works only with red numbers")},b.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},b.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},b.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return 0<=r.cmp(this.m)&&r.isub(this.m),r._forceRed(this)},b.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return 0<=r.cmp(this.m)&&r.isub(this.m),r},b.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},b.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},b.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},b.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},b.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},b.prototype.isqr=function(t){return this.imul(t,t.clone())},b.prototype.sqr=function(t){return this.mul(t,t)},b.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(v(e%2==1),3===e){var r=this.m.add(new g(1)).iushrn(2);return this.pow(t,r)}for(var i=this.m.subn(1),n=0;!i.isZero()&&0===i.andln(1);)n++,i.iushrn(1);v(!i.isZero());var o=new g(1).toRed(this),a=o.redNeg(),s=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new g(2*h*h).toRed(this);0!==this.pow(h,s).cmp(a);)h.redIAdd(a);for(var l=this.pow(h,i),u=this.pow(t,i.addn(1).iushrn(1)),c=this.pow(t,i),f=n;0!==c.cmp(o);){for(var p=c,d=0;0!==p.cmp(o);d++)p=p.redSqr();v(d<f);var m=this.pow(l,new g(1).iushln(f-d-1));u=u.redMul(m),l=m.redSqr(),c=c.redMul(l),f=d}return u},b.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},b.prototype.pow=function(t,e){if(e.isZero())return new g(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new g(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var n=r[0],o=0,a=0,s=e.bitLength()%26;for(0===s&&(s=26),i=e.length-1;0<=i;i--){for(var h=e.words[i],l=s-1;0<=l;l--){var u=h>>l&1;n!==r[0]&&(n=this.sqr(n)),0!==u||0!==o?(o<<=1,o|=u,(4===++a||0===i&&0===l)&&(n=this.mul(n,r[o]),o=a=0)):a=0}s=26}return n},b.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},b.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},g.mont=function(t){return new M(t)},r(M,b),M.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},M.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},M.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return 0<=n.cmp(this.m)?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},M.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new g(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return 0<=n.cmp(this.m)?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},M.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:136}],26:[function(t,e,r){"use strict";e.exports=function(t){var e=t.length;if(0===e)return[[],[]];for(var r=t[0].length,i=t[0].slice(),n=t[0].slice(),o=1;o<e;++o)for(var a=t[o],s=0;s<r;++s){var h=a[s];i[s]=Math.min(i[s],h),n[s]=Math.max(n[s],h)}return[i,n]}},{}],27:[function(t,e,r){"use strict";e.exports=function(t,e,r){switch(arguments.length){case 1:return n=[],o(i=t,i,a,!0),n;case 2:return"function"==typeof e?o(t,t,e,!0):(o(t,e,a,!(n=[])),n);case 3:return o(t,e,r,!1);default:throw new Error("box-intersect: Invalid arguments")}var i};var n,f=t("typedarray-pool"),p=t("./lib/sweep"),d=t("./lib/intersect");function u(t,e){for(var r=0;r<t;++r)if(!(e[r]<=e[r+t]))return!0;return!1}function m(t,e,r,i){for(var n=0,o=0,a=0,s=t.length;a<s;++a){var h=t[a];if(!u(e,h)){for(var l=0;l<2*e;++l)r[n++]=h[l];i[o++]=a}}return o}function o(t,e,r,i){var n=t.length,o=e.length;if(!(n<=0||o<=0)){var a=t[0].length>>>1;if(!(a<=0)){var s,h=f.mallocDouble(2*a*n),l=f.mallocInt32(n);if(0<(n=m(t,a,h,l))){if(1===a&&i)p.init(n),s=p.sweepComplete(a,r,0,n,h,l,0,n,h,l);else{var u=f.mallocDouble(2*a*o),c=f.mallocInt32(o);0<(o=m(e,a,u,c))&&(p.init(n+o),s=1===a?p.sweepBipartite(a,r,0,n,h,l,0,o,u,c):d(a,r,i,n,h,l,o,u,c),f.free(u),f.free(c))}f.free(h),f.free(l)}return s}}}function a(t,e){n.push([t,e])}},{"./lib/intersect":29,"./lib/sweep":33,"typedarray-pool":126}],28:[function(t,e,r){"use strict";var p="d",d="ax",m="vv",n="fp",v="es",g="rs",y="re",x="rb",w="ri",b="rp",M="bs",_="be",S="bb",T="bi",A="bp",C="rv",E="Q",L=[p,d,m,g,y,x,w,M,_,S,T];function i(u){var t="bruteForce"+(u?"Full":"Partial"),c=[],e=L.slice();u||e.splice(3,0,n);var f=["function "+t+"("+e.join()+"){"];function r(t,e){var r,i,n,o,a,s,h,l=(a=["function ",o="bruteForce"+((r=t)?"Red":"Blue")+((i=e)?"Flip":"")+((n=u)?"Full":""),"(",L.join(),"){","var ",v,"=2*",p,";"],s="for(var i="+g+","+b+"="+v+"*"+g+";i<"+y+";++i,"+b+"+="+v+"){var x0="+x+"["+d+"+"+b+"],x1="+x+"["+d+"+"+b+"+"+p+"],xi="+w+"[i];",h="for(var j="+M+","+A+"="+v+"*"+M+";j<"+_+";++j,"+A+"+="+v+"){var y0="+S+"["+d+"+"+A+"],"+(n?"y1="+S+"["+d+"+"+A+"+"+p+"],":"")+"yi="+T+"[j];",r?a.push(s,E,":",h):a.push(h,E,":",s),n?a.push("if(y1<x0||x1<y0)continue;"):i?a.push("if(y0<=x0||x1<y0)continue;"):a.push("if(y0<x0||x1<y0)continue;"),a.push("for(var k="+d+"+1;k<"+p+";++k){var r0="+x+"[k+"+b+"],r1="+x+"[k+"+p+"+"+b+"],b0="+S+"[k+"+A+"],b1="+S+"[k+"+p+"+"+A+"];if(r1<b0||b1<r0)continue "+E+";}var "+C+"="+m+"("),i?a.push("yi,xi"):a.push("xi,yi"),a.push(");if("+C+"!==void 0)return "+C+";}}}"),{name:o,code:a.join("")});c.push(l.code),f.push("return "+l.name+"("+L.join()+");")}f.push("if("+y+"-"+g+">"+_+"-"+M+"){"),u?(r(!0,!1),f.push("}else{"),r(!1,!1)):(f.push("if("+n+"){"),r(!0,!0),f.push("}else{"),r(!0,!1),f.push("}}else{if("+n+"){"),r(!1,!0),f.push("}else{"),r(!1,!1),f.push("}")),f.push("}}return "+t);var i=c.join("")+f.join("");return new Function(i)()}r.partial=i(!1),r.full=i(!0)},{}],29:[function(t,e,r){"use strict";e.exports=function(t,e,r,i,n,o,a,s,h){!function(t,e){var r=8*z.log2(e+1)*(t+1)|0,i=z.nextPow2(Q*r);$.length<i&&(k.free($),$=k.mallocInt32(i));var n=z.nextPow2(J*r);tt<n&&(k.free(tt),tt=k.mallocDouble(n))}(t,i+a);var l,u=0,c=2*t;et(u++,0,0,i,0,a,r?16:0,-1/0,1/0),r||et(u++,0,0,a,0,i,1,-1/0,1/0);for(;0<u;){var f=(u-=1)*Q,p=$[f],d=$[f+1],m=$[f+2],v=$[f+3],g=$[f+4],y=$[f+5],x=u*J,w=tt[x],b=tt[x+1],M=1&y,_=!!(16&y),S=n,T=o,A=s,C=h;if(M&&(S=s,T=h,A=n,C=o),!(2&y&&(m=q(t,p,d,m,S,T,b))<=d||4&y&&(d=Y(t,p,d,m,S,T,w),m<=d))){var E=m-d,L=g-v;if(_){if(t*E*(E+L)<W){if(void 0!==(l=O.scanComplete(t,p,e,d,m,S,T,v,g,A,C)))return l;continue}}else{if(t*Math.min(E,L)<G){if(void 0!==(l=V(t,p,e,M,d,m,S,T,v,g,A,C)))return l;continue}if(t*E*L<H){if(void 0!==(l=O.scanBipartite(t,p,e,M,d,m,S,T,v,g,A,C)))return l;continue}}var P=j(t,p,d,m,S,T,w,b);if(d<P)if(t*(P-d)<G){if(void 0!==(l=N(t,p+1,e,d,P,S,T,v,g,A,C)))return l}else if(p===t-2){if(void 0!==(l=M?O.sweepBipartite(t,e,v,g,A,C,d,P,S,T):O.sweepBipartite(t,e,d,P,S,T,v,g,A,C)))return l}else et(u++,p+1,d,P,v,g,M,-1/0,1/0),et(u++,p+1,v,g,d,P,1^M,-1/0,1/0);if(P<m){var R=I(t,p,v,g,A,C),F=A[c*R+p],D=X(t,p,R,g,A,C,F);if(D<g&&et(u++,p,P,m,D,g,(4|M)+(_?16:0),F,b),v<R&&et(u++,p,P,m,v,R,(2|M)+(_?16:0),w,F),R+1===D){if(void 0!==(l=_?it(t,p,e,P,m,S,T,R,A,C[R]):rt(t,p,e,M,P,m,S,T,R,A,C[R])))return l}else if(R<D){var U;if(_){if(U=K(t,p,P,m,S,T,F),P<U){var B=X(t,p,P,U,S,T,F);if(p===t-2){if(P<B&&void 0!==(l=O.sweepComplete(t,e,P,B,S,T,R,D,A,C)))return l;if(B<U&&void 0!==(l=O.sweepBipartite(t,e,B,U,S,T,R,D,A,C)))return l}else P<B&&et(u++,p+1,P,B,R,D,16,-1/0,1/0),B<U&&(et(u++,p+1,B,U,R,D,0,-1/0,1/0),et(u++,p+1,R,D,B,U,1,-1/0,1/0))}}else U=M?Z(t,p,P,m,S,T,F):K(t,p,P,m,S,T,F),P<U&&(p===t-2?l=M?O.sweepBipartite(t,e,R,D,A,C,P,U,S,T):O.sweepBipartite(t,e,P,U,S,T,R,D,A,C):(et(u++,p+1,P,U,R,D,M,-1/0,1/0),et(u++,p+1,R,D,P,U,1^M,-1/0,1/0)))}}}}};var k=t("typedarray-pool"),z=t("bit-twiddle"),i=t("./brute"),V=i.partial,N=i.full,O=t("./sweep"),I=t("./median"),n=t("./partition"),G=128,H=1<<22,W=1<<22,j=n("!(lo>=p0)&&!(p1>=hi)",["p0","p1"]),X=n("lo===p0",["p0"]),q=n("lo<p0",["p0"]),Y=n("hi<=p0",["p0"]),K=n("lo<=p0&&p0<=hi",["p0"]),Z=n("lo<p0&&p0<=hi",["p0"]),Q=6,J=2,$=k.mallocInt32(1024),tt=k.mallocDouble(1024);function et(t,e,r,i,n,o,a,s,h){var l=Q*t;$[l]=e,$[l+1]=r,$[l+2]=i,$[l+3]=n,$[l+4]=o,$[l+5]=a;var u=J*t;tt[u]=s,tt[u+1]=h}function rt(t,e,r,i,n,o,a,s,h,l,u){var c=2*t,f=h*c,p=l[f+e];t:for(var d=n,m=n*c;d<o;++d,m+=c){var v=a[m+e],g=a[m+e+t];if(!(p<v||g<p)&&(!i||p!==v)){for(var y,x=s[d],w=e+1;w<t;++w){v=a[m+w],g=a[m+w+t];var b=l[f+w],M=l[f+w+t];if(g<b||M<v)continue t}if(void 0!==(y=i?r(u,x):r(x,u)))return y}}}function it(t,e,r,i,n,o,a,s,h,l){var u=2*t,c=s*u,f=h[c+e];t:for(var p=i,d=i*u;p<n;++p,d+=u){var m=a[p];if(m!==l){var v=o[d+e],g=o[d+e+t];if(!(f<v||g<f)){for(var y=e+1;y<t;++y){v=o[d+y],g=o[d+y+t];var x=h[c+y],w=h[c+y+t];if(g<x||w<v)continue t}var b=r(m,l);if(void 0!==b)return b}}}}},{"./brute":28,"./median":30,"./partition":31,"./sweep":33,"bit-twiddle":24,"typedarray-pool":126}],30:[function(t,e,r){"use strict";e.exports=function(t,e,r,i,n,o){if(i<=r+1)return r;var a=r,s=i,h=i+r>>>1,l=2*t,u=h,c=n[l*h+e];for(;a<s;){if(s-a<T){A(t,e,a,s,n,o),c=n[l*h+e];break}var f=s-a,p=Math.random()*f+a|0,d=n[l*p+e],m=Math.random()*f+a|0,v=n[l*m+e],g=Math.random()*f+a|0,y=n[l*g+e];d<=v?v<=y?(u=m,c=v):y<=d?(u=p,c=d):(u=g,c=y):y<=v?(u=m,c=v):d<=y?(u=p,c=d):(u=g,c=y);for(var x=l*(s-1),w=l*u,b=0;b<l;++b,++x,++w){var M=n[x];n[x]=n[w],n[w]=M}var _=o[s-1];o[s-1]=o[u],o[u]=_,u=S(t,e,a,s-1,n,o,c);for(var x=l*(s-1),w=l*u,b=0;b<l;++b,++x,++w){var M=n[x];n[x]=n[w],n[w]=M}var _=o[s-1];if(o[s-1]=o[u],o[u]=_,h<u){for(s=u-1;a<s&&n[l*(s-1)+e]===c;)s-=1;s+=1}else{if(!(u<h))break;for(a=u+1;a<s&&n[l*a+e]===c;)a+=1}}return S(t,e,r,h,n,o,n[l*h+e])};var S=t("./partition")("lo<p0",["p0"]),T=8;function A(t,e,r,i,n,o){for(var a=2*t,s=a*(r+1)+e,h=r+1;h<i;++h,s+=a)for(var l=n[s],u=h,c=a*(h-1);r<u&&n[c+e]>l;--u,c-=a){for(var f=c,p=c+a,d=0;d<a;++d,++f,++p){var m=n[f];n[f]=n[p],n[p]=m}var v=o[u];o[u]=o[u-1],o[u-1]=v}}},{"./partition":31}],31:[function(t,e,r){"use strict";e.exports=function(t,e){var r="abcdef".split("").concat(e),i=[];0<=t.indexOf("lo")&&i.push("lo=e[k+n]");0<=t.indexOf("hi")&&i.push("hi=e[k+o]");return r.push(n.replace("_",i.join()).replace("$",t)),Function.apply(void 0,r)};var n="for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m"},{}],32:[function(t,e,r){"use strict";e.exports=function(t,e){e<=4*D?U(0,e-1,t):function t(e,r,i){var n=(r-e+1)/6|0,o=e+n,a=r-n,s=e+r>>1,h=s-n,l=s+n,u=o,c=h,f=s,p=l,d=a,m=e+1,v=r-1,g=0;N(u,c,i)&&(g=u,u=c,c=g);N(p,d,i)&&(g=p,p=d,d=g);N(u,f,i)&&(g=u,u=f,f=g);N(c,f,i)&&(g=c,c=f,f=g);N(u,p,i)&&(g=u,u=p,p=g);N(f,p,i)&&(g=f,f=p,p=g);N(c,d,i)&&(g=c,c=d,d=g);N(c,f,i)&&(g=c,c=f,f=g);N(p,d,i)&&(g=p,p=d,d=g);var y=i[2*c];var x=i[2*c+1];var w=i[2*p];var b=i[2*p+1];var M=2*u;var _=2*f;var S=2*d;var T=2*o;var A=2*s;var C=2*a;for(var E=0;E<2;++E){var L=i[M+E],P=i[_+E],R=i[S+E];i[T+E]=L,i[A+E]=P,i[C+E]=R}k(h,e,i);k(l,r,i);for(var F=m;F<=v;++F)if(O(F,y,x,i))F!==m&&B(F,m,i),++m;else if(!O(F,w,b,i))for(;;){if(O(v,w,b,i)){O(v,y,x,i)?(z(F,m,v,i),++m):B(F,v,i),--v;break}if(--v<F)break}V(e,m-1,y,x,i);V(r,v+1,w,b,i);m-2-e<=D?U(e,m-2,i):t(e,m-2,i);r-(v+2)<=D?U(v+2,r,i):t(v+2,r,i);v-m<=D?U(m,v,i):t(m,v,i)}(0,e-1,t)};var D=32;function U(t,e,r){for(var i=2*(t+1),n=t+1;n<=e;++n){for(var o=r[i++],a=r[i++],s=n,h=i-2;s-- >t;){var l=r[h-2],u=r[h-1];if(l<o)break;if(l===o&&u<a)break;r[h]=l,r[h+1]=u,h-=2}r[h]=o,r[h+1]=a}}function B(t,e,r){e*=2;var i=r[t*=2],n=r[t+1];r[t]=r[e],r[t+1]=r[e+1],r[e]=i,r[e+1]=n}function k(t,e,r){e*=2,r[t*=2]=r[e],r[t+1]=r[e+1]}function z(t,e,r,i){e*=2,r*=2;var n=i[t*=2],o=i[t+1];i[t]=i[e],i[t+1]=i[e+1],i[e]=i[r],i[e+1]=i[r+1],i[r]=n,i[r+1]=o}function V(t,e,r,i,n){e*=2,n[t*=2]=n[e],n[e]=r,n[t+1]=n[e+1],n[e+1]=i}function N(t,e,r){e*=2;var i=r[t*=2],n=r[e];return!(i<n)&&(i!==n||r[t+1]>r[e+1])}function O(t,e,r,i){var n=i[t*=2];return n<e||n===e&&i[t+1]<r}},{}],33:[function(t,e,r){"use strict";e.exports={init:function(t){var e=n.nextPow2(t);V.length<e&&(i.free(V),V=i.mallocInt32(e));N.length<e&&(i.free(N),N=i.mallocInt32(e));C.length<e&&(i.free(C),C=i.mallocInt32(e));E.length<e&&(i.free(E),E=i.mallocInt32(e));L.length<e&&(i.free(L),L=i.mallocInt32(e));P.length<e&&(i.free(P),P=i.mallocInt32(e));var r=8*e;O.length<r&&(i.free(O),O=i.mallocDouble(r))},sweepBipartite:function(t,e,r,i,n,o,a,s,h,l){for(var u=0,c=2*t,f=t-1,p=c-1,d=r;d<i;++d){var m=o[d],v=c*d;O[u++]=n[v+f],O[u++]=-(m+1),O[u++]=n[v+p],O[u++]=m}for(var d=a;d<s;++d){var m=l[d]+z,g=c*d;O[u++]=h[g+f],O[u++]=-m,O[u++]=h[g+p],O[u++]=m}var y=u>>>1;k(O,y);for(var x=0,w=0,d=0;d<y;++d){var b=0|O[2*d+1];if(z<=b)I(C,E,w--,b=b-z|0);else if(0<=b)I(V,N,x--,b);else if(b<=-z){b=-b-z|0;for(var M=0;M<x;++M){var _=e(V[M],b);if(void 0!==_)return _}G(C,E,w++,b)}else{b=-b-1|0;for(var M=0;M<w;++M){var _=e(b,C[M]);if(void 0!==_)return _}G(V,N,x++,b)}}},sweepComplete:function(t,e,r,i,n,o,a,s,h,l){for(var u=0,c=2*t,f=t-1,p=c-1,d=r;d<i;++d){var m=o[d]+1<<1,v=c*d;O[u++]=n[v+f],O[u++]=-m,O[u++]=n[v+p],O[u++]=m}for(var d=a;d<s;++d){var m=l[d]+1<<1,g=c*d;O[u++]=h[g+f],O[u++]=1|-m,O[u++]=h[g+p],O[u++]=1|m}var y=u>>>1;k(O,y);for(var x=0,w=0,b=0,d=0;d<y;++d){var M=0|O[2*d+1],_=1&M;if(d<y-1&&M>>1==O[2*d+3]>>1&&(_=2,d+=1),M<0){for(var S=-(M>>1)-1,T=0;T<b;++T){var A=e(L[T],S);if(void 0!==A)return A}if(0!==_)for(var T=0;T<x;++T){var A=e(V[T],S);if(void 0!==A)return A}if(1!==_)for(var T=0;T<w;++T){var A=e(C[T],S);if(void 0!==A)return A}0===_?G(V,N,x++,S):1===_?G(C,E,w++,S):2===_&&G(L,P,b++,S)}else{var S=(M>>1)-1;0===_?I(V,N,x--,S):1===_?I(C,E,w--,S):2===_&&I(L,P,b--,S)}}},scanBipartite:function(t,e,r,i,n,o,a,s,h,l,u,c){var f=0,p=2*t,d=e,m=e+t,v=1,g=1;i?g=z:v=z;for(var y=n;y<o;++y){var x=y+v,w=p*y;O[f++]=a[w+d],O[f++]=-x,O[f++]=a[w+m],O[f++]=x}for(var y=h;y<l;++y){var x=y+g,b=p*y;O[f++]=u[b+d],O[f++]=-x}var M=f>>>1;k(O,M);for(var _=0,y=0;y<M;++y){var S=0|O[2*y+1];if(S<0){var x=-S,T=!1;if(z<=x?(T=!i,x-=z):(T=!!i,x-=1),T)G(V,N,_++,x);else{var A=c[x],C=p*x,E=u[C+e+1],L=u[C+e+1+t];t:for(var P=0;P<_;++P){var R=V[P],F=p*R;if(!(L<a[F+e+1]||a[F+e+1+t]<E)){for(var D=e+2;D<t;++D)if(u[C+D+t]<a[F+D]||a[F+D+t]<u[C+D])continue t;var U,B=s[R];if(void 0!==(U=i?r(A,B):r(B,A)))return U}}}}else I(V,N,_--,S-v)}},scanComplete:function(t,e,r,i,n,o,a,s,h,l,u){for(var c=0,f=2*t,p=e,d=e+t,m=i;m<n;++m){var v=m+z,g=f*m;O[c++]=o[g+p],O[c++]=-v,O[c++]=o[g+d],O[c++]=v}for(var m=s;m<h;++m){var v=m+1,y=f*m;O[c++]=l[y+p],O[c++]=-v}var x=c>>>1;k(O,x);for(var w=0,m=0;m<x;++m){var b=0|O[2*m+1];if(b<0){var v=-b;if(z<=v)V[w++]=v-z;else{var M=u[v-=1],_=f*v,S=l[_+e+1],T=l[_+e+1+t];t:for(var A=0;A<w;++A){var C=V[A],E=a[C];if(E===M)break;var L=f*C;if(!(T<o[L+e+1]||o[L+e+1+t]<S)){for(var P=e+2;P<t;++P)if(l[_+P+t]<o[L+P]||o[L+P+t]<l[_+P])continue t;var R=r(E,M);if(void 0!==R)return R}}}}else{for(var v=b-z,A=w-1;0<=A;--A)if(V[A]===v){for(var P=A+1;P<w;++P)V[P-1]=V[P];break}--w}}}};var i=t("typedarray-pool"),n=t("bit-twiddle"),k=t("./sort"),z=1<<28,o=1024,V=i.mallocInt32(o),N=i.mallocInt32(o),C=i.mallocInt32(o),E=i.mallocInt32(o),L=i.mallocInt32(o),P=i.mallocInt32(o),O=i.mallocDouble(8192);function I(t,e,r,i){var n=e[i],o=t[r-1];e[t[n]=o]=n}function G(t,e,r,i){e[t[r]=i]=r}},{"./sort":32,"bit-twiddle":24,"typedarray-pool":126}],34:[function(t,e,r){"use strict";var c=t("./lib/monotone"),f=t("./lib/triangulation"),p=t("./lib/delaunay"),d=t("./lib/filter");function m(t){return[Math.min(t[0],t[1]),Math.max(t[0],t[1])]}function v(t,e){return t[0]-e[0]||t[1]-e[1]}function g(t,e,r){return e in t?t[e]:r}e.exports=function(t,e,r){Array.isArray(e)?(r=r||{},e=e||[]):(r=e||{},e=[]);var i=!!g(r,"delaunay",!0),n=!!g(r,"interior",!0),o=!!g(r,"exterior",!0),a=!!g(r,"infinity",!1);if(!n&&!o||0===t.length)return[];var s=c(t,e);{if(i||n!==o||a){for(var h=f(t.length,e.map(m).sort(v)),l=0;l<s.length;++l){var u=s[l];h.addTriangle(u[0],u[1],u[2])}return i&&p(t,h),o?n?a?d(h,0,a):h.cells():d(h,1,a):d(h,-1)}return s}}},{"./lib/delaunay":35,"./lib/filter":36,"./lib/monotone":37,"./lib/triangulation":38}],35:[function(t,e,r){"use strict";var m=t("robust-in-sphere")[4];t("binary-search-bounds");function v(t,e,r,i,n,o){var a=e.opposite(i,n);if(!(a<0)){if(n<i){var s=i;i=n,n=s,s=o,o=a,a=s}e.isConstraint(i,n)||m(t[i],t[n],t[o],t[a])<0&&r.push(i,n)}}e.exports=function(t,e){for(var r=[],i=t.length,n=e.stars,o=0;o<i;++o)for(var a=n[o],s=1;s<a.length;s+=2){var h=a[s];if(!(h<o)&&!e.isConstraint(o,h)){for(var l=a[s-1],u=-1,c=1;c<a.length;c+=2)if(a[c-1]===h){u=a[c];break}u<0||m(t[o],t[h],t[l],t[u])<0&&r.push(o,h)}}for(;0<r.length;){for(var h=r.pop(),o=r.pop(),l=-1,u=-1,a=n[o],f=1;f<a.length;f+=2){var p=a[f-1],d=a[f];p===h?u=d:d===h&&(l=p)}l<0||u<0||(0<=m(t[o],t[h],t[l],t[u])||(e.flip(o,h),v(t,e,r,l,o,u),v(t,e,r,o,u,l),v(t,e,r,u,h,l),v(t,e,r,h,l,u)))}}},{"binary-search-bounds":23,"robust-in-sphere":102}],36:[function(t,e,r){"use strict";var a,s=t("binary-search-bounds");function x(t,e,r,i,n,o,a){this.cells=t,this.neighbor=e,this.flags=i,this.constraint=r,this.active=n,this.next=o,this.boundary=a}function w(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}e.exports=function(t,e,r){var i=function(t,e){for(var r=t.cells(),i=r.length,n=0;n<i;++n){var o=r[n],a=o[0],s=o[1],h=o[2];s<h?s<a&&(o[0]=s,o[1]=h,o[2]=a):h<a&&(o[0]=h,o[1]=a,o[2]=s)}r.sort(w);for(var l=new Array(i),n=0;n<l.length;++n)l[n]=0;var u=[],c=[],f=new Array(3*i),p=new Array(3*i),d=null;e&&(d=[]);for(var m=new x(r,f,p,l,u,c,d),n=0;n<i;++n)for(var o=r[n],v=0;v<3;++v){var a=o[v],s=o[(v+1)%3],g=f[3*n+v]=m.locate(s,a,t.opposite(s,a)),y=p[3*n+v]=t.isConstraint(a,s);g<0&&(y?c.push(n):(u.push(n),l[n]=1),e&&d.push([s,a,-1]))}return m}(t,r);if(0===e)return r?i.cells.concat(i.boundary):i.cells;var n=1,o=i.active,a=i.next,s=i.flags,h=i.cells,l=i.constraint,u=i.neighbor;for(;0<o.length||0<a.length;){for(;0<o.length;){var c=o.pop();if(s[c]!==-n){s[c]=n;h[c];for(var f=0;f<3;++f){var p=u[3*c+f];0<=p&&0===s[p]&&(l[3*c+f]?a.push(p):(o.push(p),s[p]=n))}}}var d=a;a=o,o=d,a.length=0,n=-n}var m=function(t,e,r){for(var i=0,n=0;n<t.length;++n)e[n]===r&&(t[i++]=t[n]);return t.length=i,t}(h,s,e);if(r)return m.concat(i.boundary);return m},x.prototype.locate=(a=[0,0,0],function(t,e,r){var i=t,n=e,o=r;return e<r?e<t&&(i=e,n=r,o=t):r<t&&(i=r,n=t,o=e),i<0?-1:(a[0]=i,a[1]=n,a[2]=o,s.eq(this.cells,a,w))})},{"binary-search-bounds":23}],37:[function(t,e,r){"use strict";var f=t("binary-search-bounds"),p=t("robust-orientation")[3],m=0,v=1,g=2;function y(t,e,r,i,n){this.a=t,this.b=e,this.idx=r,this.lowerIds=i,this.upperIds=n}function x(t,e,r,i){this.a=t,this.b=e,this.type=r,this.idx=i}function w(t,e){var r=t.a[0]-e.a[0]||t.a[1]-e.a[1]||t.type-e.type;return r||(t.type!==m&&(r=p(t.a,t.b,e.b))?r:t.idx-e.idx)}function d(t,e){return p(t.a,t.b,e)}function b(t,e,r,i,n){for(var o=f.lt(e,i,d),a=f.gt(e,i,d),s=o;s<a;++s){for(var h=e[s],l=h.lowerIds,u=l.length;1<u&&0<p(r[l[u-2]],r[l[u-1]],i);)t.push([l[u-1],l[u-2],n]),u-=1;l.length=u,l.push(n);var c=h.upperIds;for(u=c.length;1<u&&p(r[c[u-2]],r[c[u-1]],i)<0;)t.push([c[u-2],c[u-1],n]),u-=1;c.length=u,c.push(n)}}function s(t,e){var r;return(r=t.a[0]<e.a[0]?p(t.a,t.b,e.a):p(e.b,e.a,t.a))?r:(r=e.b[0]<t.b[0]?p(t.a,t.b,e.b):p(e.b,e.a,t.b))||t.idx-e.idx}function M(t,e,r){var i=f.le(t,r,s),n=t[i],o=n.upperIds,a=o[o.length-1];n.upperIds=[a],t.splice(i+1,0,new y(r.a,r.b,r.idx,[a],o))}function _(t,e,r){var i=r.a;r.a=r.b,r.b=i;var n=f.eq(t,r,s),o=t[n];t[n-1].upperIds=o.upperIds,t.splice(n,1)}e.exports=function(t,e){for(var r=t.length,i=e.length,n=[],o=0;o<r;++o)n.push(new x(t[o],null,m,o));for(var o=0;o<i;++o){var a=e[o],s=t[a[0]],h=t[a[1]];s[0]<h[0]?n.push(new x(s,h,g,o),new x(h,s,v,o)):s[0]>h[0]&&n.push(new x(h,s,g,o),new x(s,h,v,o))}n.sort(w);for(var l=n[0].a[0]-(1+Math.abs(n[0].a[0]))*Math.pow(2,-52),u=[new y([l,1],[l,0],-1,[],[],[],[])],c=[],o=0,f=n.length;o<f;++o){var p=n[o],d=p.type;d===m?b(c,u,t,p.a,p.idx):d===g?M(u,t,p):_(u,t,p)}return c}},{"binary-search-bounds":23,"robust-orientation":103}],38:[function(t,e,r){"use strict";var n=t("binary-search-bounds");function o(t,e){this.stars=t,this.edges=e}e.exports=function(t,e){for(var r=new Array(t),i=0;i<t;++i)r[i]=[];return new o(r,e)};var i=o.prototype;function a(t,e,r){for(var i=1,n=t.length;i<n;i+=2)if(t[i-1]===e&&t[i]===r)return t[i-1]=t[n-2],t[i]=t[n-1],void(t.length=n-2)}i.isConstraint=function(){var r=[0,0];function i(t,e){return t[0]-e[0]||t[1]-e[1]}return function(t,e){return r[0]=Math.min(t,e),r[1]=Math.max(t,e),0<=n.eq(this.edges,r,i)}}(),i.removeTriangle=function(t,e,r){var i=this.stars;a(i[t],e,r),a(i[e],r,t),a(i[r],t,e)},i.addTriangle=function(t,e,r){var i=this.stars;i[t].push(e,r),i[e].push(r,t),i[r].push(t,e)},i.opposite=function(t,e){for(var r=this.stars[e],i=1,n=r.length;i<n;i+=2)if(r[i]===t)return r[i-1];return-1},i.flip=function(t,e){var r=this.opposite(t,e),i=this.opposite(e,t);this.removeTriangle(t,e,r),this.removeTriangle(e,t,i),this.addTriangle(t,i,r),this.addTriangle(e,r,i)},i.edges=function(){for(var t=this.stars,e=[],r=0,i=t.length;r<i;++r)for(var n=t[r],o=0,a=n.length;o<a;o+=2)e.push([n[o],n[o+1]]);return e},i.cells=function(){for(var t=this.stars,e=[],r=0,i=t.length;r<i;++r)for(var n=t[r],o=0,a=n.length;o<a;o+=2){var s=n[o],h=n[o+1];r<Math.min(s,h)&&e.push([r,s,h])}return e}},{"binary-search-bounds":23}],39:[function(t,e,r){"use strict";e.exports=function(t,e,r){var i;if(r){i=e;for(var n=new Array(e.length),o=0;o<e.length;++o){var a=e[o];n[o]=[a[0],a[1],r[o]]}e=n}var s=(h=t,l=e,u=!!r,c=w(h,[],x(h)),b(l,c,u),!!c);var h,l,u,c;for(;f(t,e,!!r);)s=!0;if(r&&s){i.length=0;for(var o=r.length=0;o<e.length;++o){var a=e[o];i.push([a[0],a[1]]),r.push(a[2])}}return s};var d=t("union-find"),m=t("box-intersect"),v=t("robust-segment-intersect"),S=t("big-rat"),T=t("big-rat/cmp"),A=t("big-rat/to-float"),C=t("rat-vec"),g=t("nextafter"),E=t("./lib/rat-seg-intersect");function y(t){var e=A(t);return[g(e,-1/0),g(e,1/0)]}function x(t){for(var e=new Array(t.length),r=0;r<t.length;++r){var i=t[r];e[r]=[g(i[0],-1/0),g(i[1],-1/0),g(i[0],1/0),g(i[1],1/0)]}return e}function w(t,e,r){for(var i=e.length,n=new d(i),o=[],a=0;a<e.length;++a){var s=e[a],h=y(s[0]),l=y(s[1]);o.push([g(h[0],-1/0),g(l[0],-1/0),g(h[1],1/0),g(l[1],1/0)])}m(o,function(t,e){n.link(t,e)});var u=!0,c=new Array(i);for(a=0;a<i;++a){(p=n.find(a))!==a&&(u=!1,t[p]=[Math.min(t[a][0],t[p][0]),Math.min(t[a][1],t[p][1])])}if(u)return null;var f=0;for(a=0;a<i;++a){var p;(p=n.find(a))===a?(c[a]=f,t[f++]=t[a]):c[a]=-1}t.length=f;for(a=0;a<i;++a)c[a]<0&&(c[a]=c[n.find(a)]);return c}function u(t,e){return t[0]-e[0]||t[1]-e[1]}function c(t,e){var r=t[0]-e[0]||t[1]-e[1];return r||(t[2]<e[2]?-1:t[2]>e[2]?1:0)}function b(t,e,r){if(0!==t.length){if(e)for(var i=0;i<t.length;++i){var n=e[(a=t[i])[0]],o=e[a[1]];a[0]=Math.min(n,o),a[1]=Math.max(n,o)}else for(i=0;i<t.length;++i){var a;n=(a=t[i])[0],o=a[1];a[0]=Math.min(n,o),a[1]=Math.max(n,o)}r?t.sort(c):t.sort(u);var s=1;for(i=1;i<t.length;++i){var h=t[i-1],l=t[i];(l[0]!==h[0]||l[1]!==h[1]||r&&l[2]!==h[2])&&(t[s++]=l)}t.length=s}}function f(t,e,r){var h,l,u,a,s,c,i=function(t,e){for(var r=new Array(e.length),i=0;i<e.length;++i){var n=e[i],o=t[n[0]],a=t[n[1]];r[i]=[g(Math.min(o[0],a[0]),-1/0),g(Math.min(o[1],a[1]),-1/0),g(Math.max(o[0],a[0]),1/0),g(Math.max(o[1],a[1]),1/0)]}return r}(t,e),n=(h=t,l=e,u=[],m(i,function(t,e){var r=l[t],i=l[e];if(r[0]!==i[0]&&r[0]!==i[1]&&r[1]!==i[0]&&r[1]!==i[1]){var n=h[r[0]],o=h[r[1]],a=h[i[0]],s=h[i[1]];v(n,o,a,s)&&u.push([t,e])}}),u),o=x(t),f=(a=t,s=e,c=[],m(i,o,function(t,e){var r=s[t];if(r[0]!==e&&r[1]!==e){var i=a[e],n=a[r[0]],o=a[r[1]];v(n,o,i,i)&&c.push([t,e])}}),c),p=w(t,function(t,e,r,i,n){var o,a,s=t.map(function(t){return[S(t[0]),S(t[1])]});for(o=0;o<r.length;++o){var h=r[o];a=h[0];var l=h[1],u=e[a],c=e[l],f=E(C(t[u[0]]),C(t[u[1]]),C(t[c[0]]),C(t[c[1]]));if(f){var p=t.length;t.push([A(f[0]),A(f[1])]),s.push(f),i.push([a,p],[l,p])}}for(i.sort(function(t,e){if(t[0]!==e[0])return t[0]-e[0];var r=s[t[1]],i=s[e[1]];return T(r[0],i[0])||T(r[1],i[1])}),o=i.length-1;0<=o;--o){var d=e[a=(M=i[o])[0]],m=d[0],v=d[1],g=t[m],y=t[v];if((g[0]-y[0]||g[1]-y[1])<0){var x=m;m=v,v=x}d[0]=m;var w,b=d[1]=M[1];for(n&&(w=d[2]);0<o&&i[o-1][0]===a;){var M,_=(M=i[--o])[1];n?e.push([b,_,w]):e.push([b,_]),b=_}n?e.push([b,v,w]):e.push([b,v])}return s}(t,e,n,f,r));return b(e,p,r),!!p||(0<n.length||0<f.length)}},{"./lib/rat-seg-intersect":40,"big-rat":10,"big-rat/cmp":8,"big-rat/to-float":22,"box-intersect":27,nextafter:86,"rat-vec":98,"robust-segment-intersect":105,"union-find":128}],40:[function(t,e,r){"use strict";e.exports=function(t,e,r,i){var n=p(e,t),o=p(i,r),a=v(n,o);if(0===f(a))return null;var s=p(t,r),h=v(o,s),l=c(h,a),u=m(n,l);return d(t,u)};var i=t("big-rat/mul"),c=t("big-rat/div"),n=t("big-rat/sub"),f=t("big-rat/sign"),p=t("rat-vec/sub"),d=t("rat-vec/add"),m=t("rat-vec/muls");function v(t,e){return n(i(t[0],e[1]),i(t[1],e[0]))}},{"big-rat/div":9,"big-rat/mul":19,"big-rat/sign":20,"big-rat/sub":21,"rat-vec/add":97,"rat-vec/muls":99,"rat-vec/sub":100}],41:[function(t,o,e){(function(t){var e=!1;if("undefined"!=typeof Float64Array){var r=new Float64Array(1),i=new Uint32Array(r.buffer);if(r[0]=1,e=!0,1072693248===i[1]){o.exports=function(t){return r[0]=t,[i[0],i[1]]},o.exports.pack=function(t,e){return i[0]=t,i[1]=e,r[0]},o.exports.lo=function(t){return r[0]=t,i[0]},o.exports.hi=function(t){return r[0]=t,i[1]}}else if(1072693248===i[0]){o.exports=function(t){return r[0]=t,[i[1],i[0]]},o.exports.pack=function(t,e){return i[1]=t,i[0]=e,r[0]},o.exports.lo=function(t){return r[0]=t,i[1]},o.exports.hi=function(t){return r[0]=t,i[0]}}else e=!1}if(!e){var n=new t(8);o.exports=function(t){return n.writeDoubleLE(t,0,!0),[n.readUInt32LE(0,!0),n.readUInt32LE(4,!0)]},o.exports.pack=function(t,e){return n.writeUInt32LE(t,0,!0),n.writeUInt32LE(e,4,!0),n.readDoubleLE(0,!0)},o.exports.lo=function(t){return n.writeDoubleLE(t,0,!0),n.readUInt32LE(0,!0)},o.exports.hi=function(t){return n.writeDoubleLE(t,0,!0),n.readUInt32LE(4,!0)}}o.exports.sign=function(t){return o.exports.hi(t)>>>31},o.exports.exponent=function(t){return(o.exports.hi(t)<<1>>>21)-1023},o.exports.fraction=function(t){var e=o.exports.lo(t),r=o.exports.hi(t),i=1048575&r;return 2146435072&r&&(i+=1<<20),[e,i]},o.exports.denormalized=function(t){return!(2146435072&o.exports.hi(t))}}).call(this,t("buffer").Buffer)},{buffer:137}],42:[function(t,e,r){"use strict";e.exports=function(t,e){switch(void 0===e&&(e=0),typeof t){case"number":if(0<t)return function(t,e){var r,i;for(r=new Array(t),i=0;i<t;++i)r[i]=e;return r}(0|t,e);break;case"object":if("number"==typeof t.length)return function t(e,r,i){var n=0|e[i];if(n<=0)return[];var o,a=new Array(n);if(i===e.length-1)for(o=0;o<n;++o)a[o]=r;else for(o=0;o<n;++o)a[o]=t(e,r,i+1);return a}(t,e,0)}return[]}},{}],43:[function(t,e,r){e.exports=function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}},{}],44:[function(t,e,r){e.exports=function(t){return t*t*(2.70158*t-1.70158)}},{}],45:[function(t,e,r){e.exports=function(t){return--t*t*(2.70158*t+1.70158)+1}},{}],46:[function(t,e,r){var i=t("./bounce-out");e.exports=function(t){return t<.5?.5*(1-i(1-2*t)):.5*i(2*t-1)+.5}},{"./bounce-out":48}],47:[function(t,e,r){var i=t("./bounce-out");e.exports=function(t){return 1-i(1-t)}},{"./bounce-out":48}],48:[function(t,e,r){e.exports=function(t){var e=t*t;return t<4/11?7.5625*e:t<8/11?9.075*e-9.9*t+3.4:t<.9?4356/361*e-35442/1805*t+16061/1805:10.8*t*t-20.52*t+10.72}},{}],49:[function(t,e,r){e.exports=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}},{}],50:[function(t,e,r){e.exports=function(t){return 1-Math.sqrt(1-t*t)}},{}],51:[function(t,e,r){e.exports=function(t){return Math.sqrt(1- --t*t)}},{}],52:[function(t,e,r){e.exports=function(t){return t<.5?4*t*t*t:.5*Math.pow(2*t-2,3)+1}},{}],53:[function(t,e,r){e.exports=function(t){return t*t*t}},{}],54:[function(t,e,r){e.exports=function(t){var e=t-1;return e*e*e+1}},{}],55:[function(t,e,r){e.exports=function(t){return t<.5?.5*Math.sin(13*Math.PI/2*2*t)*Math.pow(2,10*(2*t-1)):.5*Math.sin(-13*Math.PI/2*(2*t-1+1))*Math.pow(2,-10*(2*t-1))+1}},{}],56:[function(t,e,r){e.exports=function(t){return Math.sin(13*t*Math.PI/2)*Math.pow(2,10*(t-1))}},{}],57:[function(t,e,r){e.exports=function(t){return Math.sin(-13*(t+1)*Math.PI/2)*Math.pow(2,-10*t)+1}},{}],58:[function(t,e,r){e.exports=function(t){return 0===t||1===t?t:t<.5?.5*Math.pow(2,20*t-10):-.5*Math.pow(2,10-20*t)+1}},{}],59:[function(t,e,r){e.exports=function(t){return 0===t?t:Math.pow(2,10*(t-1))}},{}],60:[function(t,e,r){e.exports=function(t){return 1===t?t:1-Math.pow(2,-10*t)}},{}],61:[function(t,e,r){e.exports={backInOut:t("./back-in-out"),backIn:t("./back-in"),backOut:t("./back-out"),bounceInOut:t("./bounce-in-out"),bounceIn:t("./bounce-in"),bounceOut:t("./bounce-out"),circInOut:t("./circ-in-out"),circIn:t("./circ-in"),circOut:t("./circ-out"),cubicInOut:t("./cubic-in-out"),cubicIn:t("./cubic-in"),cubicOut:t("./cubic-out"),elasticInOut:t("./elastic-in-out"),elasticIn:t("./elastic-in"),elasticOut:t("./elastic-out"),expoInOut:t("./expo-in-out"),expoIn:t("./expo-in"),expoOut:t("./expo-out"),linear:t("./linear"),quadInOut:t("./quad-in-out"),quadIn:t("./quad-in"),quadOut:t("./quad-out"),quartInOut:t("./quart-in-out"),quartIn:t("./quart-in"),quartOut:t("./quart-out"),quintInOut:t("./quint-in-out"),quintIn:t("./quint-in"),quintOut:t("./quint-out"),sineInOut:t("./sine-in-out"),sineIn:t("./sine-in"),sineOut:t("./sine-out")}},{"./back-in":44,"./back-in-out":43,"./back-out":45,"./bounce-in":47,"./bounce-in-out":46,"./bounce-out":48,"./circ-in":50,"./circ-in-out":49,"./circ-out":51,"./cubic-in":53,"./cubic-in-out":52,"./cubic-out":54,"./elastic-in":56,"./elastic-in-out":55,"./elastic-out":57,"./expo-in":59,"./expo-in-out":58,"./expo-out":60,"./linear":62,"./quad-in":64,"./quad-in-out":63,"./quad-out":65,"./quart-in":67,"./quart-in-out":66,"./quart-out":68,"./quint-in":70,"./quint-in-out":69,"./quint-out":71,"./sine-in":73,"./sine-in-out":72,"./sine-out":74}],62:[function(t,e,r){e.exports=function(t){return t}},{}],63:[function(t,e,r){e.exports=function(t){return(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1)}},{}],64:[function(t,e,r){e.exports=function(t){return t*t}},{}],65:[function(t,e,r){e.exports=function(t){return-t*(t-2)}},{}],66:[function(t,e,r){e.exports=function(t){return t<.5?8*Math.pow(t,4):-8*Math.pow(t-1,4)+1}},{}],67:[function(t,e,r){e.exports=function(t){return Math.pow(t,4)}},{}],68:[function(t,e,r){e.exports=function(t){return Math.pow(t-1,3)*(1-t)+1}},{}],69:[function(t,e,r){e.exports=function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}},{}],70:[function(t,e,r){e.exports=function(t){return t*t*t*t*t}},{}],71:[function(t,e,r){e.exports=function(t){return--t*t*t*t*t+1}},{}],72:[function(t,e,r){e.exports=function(t){return-.5*(Math.cos(Math.PI*t)-1)}},{}],73:[function(t,e,r){e.exports=function(t){var e=Math.cos(t*Math.PI*.5);return Math.abs(e)<1e-14?1:1-e}},{}],74:[function(t,e,r){e.exports=function(t){return Math.sin(t*Math.PI/2)}},{}],75:[function(t,e,r){var i=t("xml-parse-from-string");function n(t){if("string"==typeof t&&(t=i(t)),!t||"function"!=typeof t.getElementsByTagName)throw new Error("could not get an XML document from the specified SVG contents");return Array.prototype.slice.call(t.getElementsByTagName("path")).reduce(function(t,e){return t+" "+(e.getAttribute("d")||"").replace(/\s+/g," ").trim()},"").trim()}e.exports=function(){throw new Error("use extract-svg-path/transform to inline SVG contents into your bundle")},e.exports.parse=n,e.exports.fromString=n},{"xml-parse-from-string":133}],76:[function(t,e,r){var i=t("is-function");e.exports=function(t,e,r){if(!i(e))throw new TypeError("iterator must be a function");arguments.length<3&&(r=this);"[object Array]"===n.call(t)?function(t,e,r){for(var i=0,n=t.length;i<n;i++)o.call(t,i)&&e.call(r,t[i],i,t)}(t,e,r):"string"==typeof t?function(t,e,r){for(var i=0,n=t.length;i<n;i++)e.call(r,t.charAt(i),i,t)}(t,e,r):function(t,e,r){for(var i in t)o.call(t,i)&&e.call(r,t[i],i,t)}(t,e,r)};var n=Object.prototype.toString,o=Object.prototype.hasOwnProperty},{"is-function":80}],77:[function(t,e,r){e.exports=function(t,e){e=e||1;var r=2*Math.random()*Math.PI,i=2*Math.random()-1,n=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*n,t[1]=Math.sin(r)*n,t[2]=i*e,t}},{}],78:[function(t,r,e){(function(t){var e;e="undefined"!=typeof window?window:void 0!==t?t:"undefined"!=typeof self?self:{},r.exports=e}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],79:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],80:[function(t,e,r){e.exports=function(t){var e=i.call(t);return"[object Function]"===e||"function"==typeof t&&"[object RegExp]"!==e||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)};var i=Object.prototype.toString},{}],81:[function(t,e,r){var a=t("lerp");e.exports=function(t,e,r,i){if("number"==typeof t&&"number"==typeof e)return a(t,e,r);var n=Math.min(t.length,e.length);i=i||new Array(n);for(var o=0;o<n;o++)i[o]=a(t[o],e[o],r);return i}},{lerp:82}],82:[function(t,e,r){e.exports=function(t,e,r){return t*(1-r)+e*r}},{}],83:[function(t,e,r){var i=t("xhr");e.exports=function(t,o){"string"==typeof t&&(t={uri:t}),i(t,function(t,e,r){if(t)return o(t);if(!/^2/.test(e.statusCode))return o(new Error("http status code: "+e.statusCode));var i=document.createElement("div");i.innerHTML=r;var n=i.querySelector("svg");if(!n)return o(new Error("svg not present in resource"));o(null,n)})}},{xhr:131}],84:[function(t,e,r){e.exports=function(t){var e=[],r=[],i=0,n=0;for(;i<t.length;)r.push([n++,n++,n++]),e.push([t[i++],t[i++],t[i++]],[t[i++],t[i++],t[i++]],[t[i++],t[i++],t[i++]]);return{positions:e,cells:r}}},{}],85:[function(t,e,r){var o=t("xtend"),a={enumerable:!0,configurable:!0};function i(t,e){for(var r in e)if(e.hasOwnProperty(r)){var i=e[r];if("function"==typeof i)t[r]=i;else if(i&&"object"==typeof i){var n=o(a,i);Object.defineProperty(t,r,n)}}}e.exports=function(t,e){i(t.prototype,e)},e.exports.mix=i},{xtend:134}],86:[function(t,e,r){"use strict";var n=t("double-bits"),o=Math.pow(2,-1074),a=-1>>>0;e.exports=function(t,e){if(isNaN(t)||isNaN(e))return NaN;if(t===e)return t;if(0===t)return e<0?-o:o;var r=n.hi(t),i=n.lo(t);t<e==0<t?i===a?(r+=1,i=0):i+=1:0===i?(i=a,r-=1):i-=1;return n.pack(i,r)}},{"double-bits":41}],87:[function(t,e,r){var u=t("bound-points"),c=t("unlerp");e.exports=function(t,e){if(!Array.isArray(t))throw new TypeError("must specify positions as first argument");Array.isArray(e)||(e=u(t));var r=e[0],i=e[1],n=i[0]-r[0],o=i[1]-r[1],a=o<n?1:o/n,s=o<n?n/o:1;if(i[0]-r[0]==0||i[1]-r[1]==0)return t;for(var h=0;h<t.length;h++){var l=t[h];l[0]=(2*c(r[0],i[0],l[0])-1)/a,l[1]=(2*c(r[1],i[1],l[1])-1)/s}return t}},{"bound-points":26,unlerp:129}],88:[function(t,e,r){var R=Math.PI,F=x(120);function g(t,e,r,i){return["C",t,e,r,i,r,i]}function y(t,e,r,i,n,o){return["C",t/3+2/3*r,e/3+2/3*i,n/3+2/3*r,o/3+2/3*i,n,o]}function D(t,e,r,i,n,o,a,s,h,l){if(l)x=l[0],w=l[1],g=l[2],y=l[3];else{var u=U(t,e,-n);t=u.x,e=u.y;var c=(t-(s=(u=U(s,h,-n)).x))/2,f=(e-(h=u.y))/2,p=c*c/(r*r)+f*f/(i*i);1<p&&(r*=p=Math.sqrt(p),i*=p);var d=r*r,m=i*i,v=(o==a?-1:1)*Math.sqrt(Math.abs((d*m-d*f*f-m*c*c)/(d*f*f+m*c*c)));v==1/0&&(v=1);var g=v*r*f/i+(t+s)/2,y=v*-i*c/r+(e+h)/2,x=Math.asin(((e-y)/i).toFixed(9)),w=Math.asin(((h-y)/i).toFixed(9));(x=t<g?R-x:x)<0&&(x=2*R+x),(w=s<g?R-w:w)<0&&(w=2*R+w),a&&w<x&&(x-=2*R),!a&&x<w&&(w-=2*R)}if(Math.abs(w-x)>F){var b=w,M=s,_=h;w=x+F*(a&&x<w?1:-1);var S=D(s=g+r*Math.cos(w),h=y+i*Math.sin(w),r,i,n,0,a,M,_,[w,b,g,y])}var T=Math.tan((w-x)/4),A=4/3*r*T,C=4/3*i*T,E=[2*t-(t+A*Math.sin(x)),2*e-(e-C*Math.cos(x)),s+A*Math.sin(w),h-C*Math.cos(w),s,h];if(l)return E;S&&(E=E.concat(S));for(var L=0;L<E.length;){var P=U(E[L],E[L+1],n);E[L++]=P.x,E[L++]=P.y}return E}function U(t,e,r){return{x:t*Math.cos(r)-e*Math.sin(r),y:t*Math.sin(r)+e*Math.cos(r)}}function x(t){return t*(R/180)}e.exports=function(t){for(var e,r=[],i=0,n=0,o=0,a=0,s=null,h=null,l=0,u=0,c=0,f=t.length;c<f;c++){var p=t[c],d=p[0];switch(d){case"M":o=p[1],a=p[2];break;case"A":(p=D(l,u,p[1],p[2],x(p[3]),p[4],p[5],p[6],p[7])).unshift("C"),7<p.length&&(r.push(p.splice(0,7)),p.unshift("C"));break;case"S":var m=l,v=u;"C"!=e&&"S"!=e||(m+=m-i,v+=v-n),p=["C",m,v,p[1],p[2],p[3],p[4]];break;case"T":"Q"==e||"T"==e?(s=2*l-s,h=2*u-h):(s=l,h=u),p=y(l,u,s,h,p[1],p[2]);break;case"Q":s=p[1],h=p[2],p=y(l,u,p[1],p[2],p[3],p[4]);break;case"L":p=g(l,u,p[1],p[2]);break;case"H":p=g(l,u,p[1],u);break;case"V":p=g(l,u,l,p[1]);break;case"Z":p=g(l,u,o,a)}e=d,l=p[p.length-2],u=p[p.length-1],4<p.length?(i=p[p.length-4],n=p[p.length-3]):(i=l,n=u),r.push(p)}return r}},{}],89:[function(t,e,r){"use strict";var h=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(t){i[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var r,i,n=function(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),o=1;o<arguments.length;o++){for(var a in r=Object(arguments[o]))l.call(r,a)&&(n[a]=r[a]);if(h){i=h(r);for(var s=0;s<i.length;s++)u.call(r,i[s])&&(n[i[s]]=r[i[s]])}}return n}},{}],90:[function(t,e,r){var i=Object.prototype.propertyIsEnumerable;e.exports=function(e){var t=Object.getOwnPropertyNames(e);Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(e)));return t.filter(function(t){return i.call(e,t)})}},{}],91:[function(t,e,r){var a=t("trim"),i=t("for-each");e.exports=function(t){if(!t)return{};var o={};return i(a(t).split("\n"),function(t){var e,r=t.indexOf(":"),i=a(t.slice(0,r)).toLowerCase(),n=a(t.slice(r+1));void 0===o[i]?o[i]=n:(e=o[i],"[object Array]"===Object.prototype.toString.call(e)?o[i].push(n):o[i]=[o[i],n])}),o}},{"for-each":76,trim:115}],92:[function(t,e,r){e.exports=function(t){var o=[];return t.replace(i,function(t,e,r){var i,n=e.toLowerCase();for(r=(i=r.match(s))?i.map(Number):[],"m"==n&&2<r.length&&(o.push([e].concat(r.splice(0,2))),n="l",e="m"==e?"l":"L");;){if(r.length==a[n])return r.unshift(e),o.push(r);if(r.length<a[n])throw new Error("malformed path data");o.push([e].concat(r.splice(0,a[n])))}}),o};var a={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},i=/([astvzqmhlc])([^astvzqmhlc]*)/gi;var s=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi},{}],93:[function(t,s,e){(function(a){(function(){var t,e,r,i,n,o;"undefined"!=typeof performance&&null!==performance&&performance.now?s.exports=function(){return performance.now()}:null!=a&&a.hrtime?(s.exports=function(){return(t()-n)/1e6},e=a.hrtime,i=(t=function(){var t;return 1e9*(t=e())[0]+t[1]})(),o=1e9*a.uptime(),n=i-o):Date.now?(s.exports=function(){return Date.now()-r},r=Date.now()):(s.exports=function(){return(new Date).getTime()-r},r=(new Date).getTime())}).call(this)}).call(this,t("_process"))},{_process:140}],94:[function(t,e,r){var i=t("inherits"),n=t("events").EventEmitter,o=t("right-now"),a=t("raf");function s(t){if(!(this instanceof s))return new s(t);this.running=!1,this.last=o(),this._frame=0,this._tick=this.tick.bind(this),t&&this.on("tick",t)}i(e.exports=s,n),s.prototype.start=function(){if(!this.running)return this.running=!0,this.last=o(),this._frame=a(this._tick),this},s.prototype.stop=function(){return this.running=!1,0!==this._frame&&a.cancel(this._frame),this._frame=0,this},s.prototype.tick=function(){this._frame=a(this._tick);var t=o(),e=t-this.last;this.emit("tick",e),this.last=t}},{events:138,inherits:79,raf:95,"right-now":101}],95:[function(c,f,t){(function(t){for(var i=c("performance-now"),e="undefined"==typeof window?t:window,r=["moz","webkit"],n="AnimationFrame",o=e["request"+n],a=e["cancel"+n]||e["cancelRequest"+n],s=0;!o&&s<r.length;s++)o=e[r[s]+"Request"+n],a=e[r[s]+"Cancel"+n]||e[r[s]+"CancelRequest"+n];if(!o||!a){var h=0,l=0,u=[];o=function(t){if(0===u.length){var e=i(),r=Math.max(0,1e3/60-(e-h));h=r+e,setTimeout(function(){for(var t=u.slice(0),e=u.length=0;e<t.length;e++)if(!t[e].cancelled)try{t[e].callback(h)}catch(t){setTimeout(function(){throw t},0)}},Math.round(r))}return u.push({handle:++l,callback:t,cancelled:!1}),l},a=function(t){for(var e=0;e<u.length;e++)u[e].handle===t&&(u[e].cancelled=!0)}}f.exports=function(t){return o.call(e,t)},f.exports.cancel=function(){a.apply(e,arguments)},f.exports.polyfill=function(t){t||(t=e),t.requestAnimationFrame=o,t.cancelAnimationFrame=a}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"performance-now":93}],96:[function(t,e,r){"use strict";e.exports=function(t,e){if(void 0===e&&(e=t,t=0),"number"!=typeof t||"number"!=typeof e)throw new TypeError("Expected all arguments to be numbers");return Math.random()*(e-t)+t}},{}],97:[function(t,e,r){"use strict";var o=t("big-rat/add");e.exports=function(t,e){for(var r=t.length,i=new Array(r),n=0;n<r;++n)i[n]=o(t[n],e[n]);return i}},{"big-rat/add":7}],98:[function(t,e,r){"use strict";e.exports=function(t){for(var e=new Array(t.length),r=0;r<t.length;++r)e[r]=i(t[r]);return e};var i=t("big-rat")},{"big-rat":10}],99:[function(t,e,r){"use strict";var a=t("big-rat"),s=t("big-rat/mul");e.exports=function(t,e){for(var r=a(e),i=t.length,n=new Array(i),o=0;o<i;++o)n[o]=s(t[o],r);return n}},{"big-rat":10,"big-rat/mul":19}],100:[function(t,e,r){"use strict";var o=t("big-rat/sub");e.exports=function(t,e){for(var r=t.length,i=new Array(r),n=0;n<r;++n)i[n]=o(t[n],e[n]);return i}},{"big-rat/sub":21}],101:[function(t,e,r){(function(t){e.exports=t.performance&&t.performance.now?function(){return performance.now()}:Date.now||function(){return+new Date}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],102:[function(t,o,e){"use strict";var c=t("two-product"),f=t("robust-sum"),p=t("robust-subtract"),d=t("robust-scale"),a=6;function m(t,e){for(var r=new Array(t.length-1),i=1;i<t.length;++i)for(var n=r[i-1]=new Array(t.length-1),o=0,a=0;o<t.length;++o)o!==e&&(n[a++]=t[i][o]);return r}function v(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",v(t.slice(0,e)),",",v(t.slice(e)),")"].join("")}function n(t,e){if("m"===t.charAt(0)){if("w"===e.charAt(0)){var r=t.split("[");return["w",e.substr(1),"m",r[0].substr(1)].join("")}return["prod(",t,",",e,")"].join("")}return n(e,t)}function g(t){if(2===t.length)return[["diff(",n(t[0][0],t[1][1]),",",n(t[1][0],t[0][1]),")"].join("")];for(var e=[],r=0;r<t.length;++r)e.push(["scale(",v(g(m(t,r))),",",(i=r,!0&i?"-":""),t[0][r],")"].join(""));return e;var i}function y(t,e){for(var r=[],i=0;i<e-2;++i)r.push(["prod(m",t,"[",i,"],m",t,"[",i,"])"].join(""));return v(r)}function s(t){for(var e=[],r=[],i=function(t){for(var e=new Array(t),r=0;r<t;++r){e[r]=new Array(t);for(var i=0;i<t;++i)e[r][i]=["m",i,"[",t-r-2,"]"].join("")}return e}(t),n=0;n<t;++n)i[0][n]="1",i[t-1][n]="w"+n;for(n=0;n<t;++n)0==(1&n)?e.push.apply(e,g(m(i,n))):r.push.apply(r,g(m(i,n)));var o=v(e),a=v(r),s="exactInSphere"+t,h=[];for(n=0;n<t;++n)h.push("m"+n);var l=["function ",s,"(",h.join(),"){"];for(n=0;n<t;++n){l.push("var w",n,"=",y(n,t),";");for(var u=0;u<t;++u)u!==n&&l.push("var w",n,"m",u,"=scale(w",n,",m",u,"[0]);")}return l.push("var p=",o,",n=",a,",d=diff(p,n);return d[d.length-1];}return ",s),new Function("sum","diff","prod","scale",l.join(""))(f,p,c,d)}var h=[function(){return 0},function(){return 0},function(){return 0}];!function(){for(;h.length<=a;)h.push(s(h.length));for(var t=[],e=["slow"],r=0;r<=a;++r)t.push("a"+r),e.push("o"+r);var i=["function testInSphere(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(r=2;r<=a;++r)i.push("case ",r,":return o",r,"(",t.slice(0,r).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i<arguments.length;++i){s[i]=arguments[i]};return slow(s);}return testInSphere"),e.push(i.join(""));var n=Function.apply(void 0,e);for(o.exports=n.apply(void 0,[function(t){var e=h[t.length];return e||(e=h[t.length]=s(t.length)),e.apply(void 0,t)}].concat(h)),r=0;r<=a;++r)o.exports[r]=h[r]}()},{"robust-scale":104,"robust-subtract":106,"robust-sum":107,"two-product":124}],103:[function(t,o,e){"use strict";var u=t("two-product"),c=t("robust-sum"),f=t("robust-scale"),p=t("robust-subtract"),a=5;function d(t,e){for(var r=new Array(t.length-1),i=1;i<t.length;++i)for(var n=r[i-1]=new Array(t.length-1),o=0,a=0;o<t.length;++o)o!==e&&(n[a++]=t[i][o]);return r}function m(t){if(1===t.length)return t[0];if(2===t.length)return["sum(",t[0],",",t[1],")"].join("");var e=t.length>>1;return["sum(",m(t.slice(0,e)),",",m(t.slice(e)),")"].join("")}function v(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],r=0;r<t.length;++r)e.push(["scale(",m(v(d(t,r))),",",(i=r,1&i?"-":""),t[0][r],")"].join(""));return e;var i}function s(t){for(var e=[],r=[],i=function(t){for(var e=new Array(t),r=0;r<t;++r){e[r]=new Array(t);for(var i=0;i<t;++i)e[r][i]=["m",i,"[",t-r-1,"]"].join("")}return e}(t),n=[],o=0;o<t;++o)0==(1&o)?e.push.apply(e,v(d(i,o))):r.push.apply(r,v(d(i,o))),n.push("m"+o);var a=m(e),s=m(r),h="orientation"+t+"Exact",l=["function ",h,"(",n.join(),"){var p=",a,",n=",s,",d=sub(p,n);return d[d.length-1];};return ",h].join("");return new Function("sum","prod","scale","sub",l)(c,u,f,p)}var h=s(3),b=s(4),l=[function(){return 0},function(){return 0},function(t,e){return e[0]-t[0]},function(t,e,r){var i,n=(t[1]-r[1])*(e[0]-r[0]),o=(t[0]-r[0])*(e[1]-r[1]),a=n-o;if(0<n){if(o<=0)return a;i=n+o}else{if(!(n<0))return a;if(0<=o)return a;i=-(n+o)}var s=3.3306690738754716e-16*i;return s<=a||a<=-s?a:h(t,e,r)},function(t,e,r,i){var n=t[0]-i[0],o=e[0]-i[0],a=r[0]-i[0],s=t[1]-i[1],h=e[1]-i[1],l=r[1]-i[1],u=t[2]-i[2],c=e[2]-i[2],f=r[2]-i[2],p=o*l,d=a*h,m=a*s,v=n*l,g=n*h,y=o*s,x=u*(p-d)+c*(m-v)+f*(g-y),w=7.771561172376103e-16*((Math.abs(p)+Math.abs(d))*Math.abs(u)+(Math.abs(m)+Math.abs(v))*Math.abs(c)+(Math.abs(g)+Math.abs(y))*Math.abs(f));return w<x||w<-x?x:b(t,e,r,i)}];!function(){for(;l.length<=a;)l.push(s(l.length));for(var t=[],e=["slow"],r=0;r<=a;++r)t.push("a"+r),e.push("o"+r);var i=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(r=2;r<=a;++r)i.push("case ",r,":return o",r,"(",t.slice(0,r).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i<arguments.length;++i){s[i]=arguments[i]};return slow(s);}return getOrientation"),e.push(i.join(""));var n=Function.apply(void 0,e);for(o.exports=n.apply(void 0,[function(t){var e=l[t.length];return e||(e=l[t.length]=s(t.length)),e.apply(void 0,t)}].concat(l)),r=0;r<=a;++r)o.exports[r]=l[r]}()},{"robust-scale":104,"robust-subtract":106,"robust-sum":107,"two-product":124}],104:[function(t,e,r){"use strict";var m=t("two-product"),v=t("two-sum");e.exports=function(t,e){var r=t.length;if(1===r){var i=m(t[0],e);return i[0]?i:[i[1]]}var n=new Array(2*r),o=[.1,.1],a=[.1,.1],s=0;m(t[0],e,o),o[0]&&(n[s++]=o[0]);for(var h=1;h<r;++h){m(t[h],e,a);var l=o[1];v(l,a[0],o),o[0]&&(n[s++]=o[0]);var u=a[1],c=o[1],f=u+c,p=f-u,d=c-p;o[1]=f,d&&(n[s++]=d)}o[1]&&(n[s++]=o[1]);0===s&&(n[s++]=0);return n.length=s,n}},{"two-product":124,"two-sum":125}],105:[function(t,e,r){"use strict";e.exports=function(t,e,r,i){var n=h(t,r,i),o=h(e,r,i);if(0<n&&0<o||n<0&&o<0)return!1;var a=h(r,t,e),s=h(i,t,e);if(0<a&&0<s||a<0&&s<0)return!1;if(0===n&&0===o&&0===a&&0===s)return function(t,e,r,i){for(var n=0;n<2;++n){var o=t[n],a=e[n],s=Math.min(o,a),h=Math.max(o,a),l=r[n],u=i[n],c=Math.min(l,u),f=Math.max(l,u);if(f<s||h<c)return!1}return!0}(t,e,r,i);return!0};var h=t("robust-orientation")[3]},{"robust-orientation":103}],106:[function(t,e,r){"use strict";e.exports=function(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return function(t,e){var r=t+e,i=r-t,n=t-(r-i)+(e-i);if(n)return[n,r];return[r]}(t[0],-e[0]);var n,o,a=new Array(r+i),s=0,h=0,l=0,u=Math.abs,c=t[h],f=u(c),p=-e[l],d=u(p);f<d?(o=c,(h+=1)<r&&(c=t[h],f=u(c))):(o=p,(l+=1)<i&&(p=-e[l],d=u(p)));h<r&&f<d||i<=l?(n=c,(h+=1)<r&&(c=t[h],f=u(c))):(n=p,(l+=1)<i&&(p=-e[l],d=u(p)));var m,v,g=n+o,y=g-n,x=o-y,w=x,b=g;for(;h<r&&l<i;)f<d?(n=c,(h+=1)<r&&(c=t[h],f=u(c))):(n=p,(l+=1)<i&&(p=-e[l],d=u(p))),(x=(o=w)-(y=(g=n+o)-n))&&(a[s++]=x),w=b-((m=b+g)-(v=m-b))+(g-v),b=m;for(;h<r;)(x=(o=w)-(y=(g=(n=c)+o)-n))&&(a[s++]=x),w=b-((m=b+g)-(v=m-b))+(g-v),b=m,(h+=1)<r&&(c=t[h]);for(;l<i;)(x=(o=w)-(y=(g=(n=p)+o)-n))&&(a[s++]=x),w=b-((m=b+g)-(v=m-b))+(g-v),b=m,(l+=1)<i&&(p=-e[l]);w&&(a[s++]=w);b&&(a[s++]=b);s||(a[s++]=0);return a.length=s,a}},{}],107:[function(t,e,r){"use strict";e.exports=function(t,e){var r=0|t.length,i=0|e.length;if(1===r&&1===i)return function(t,e){var r=t+e,i=r-t,n=t-(r-i)+(e-i);if(n)return[n,r];return[r]}(t[0],e[0]);var n,o,a=new Array(r+i),s=0,h=0,l=0,u=Math.abs,c=t[h],f=u(c),p=e[l],d=u(p);f<d?(o=c,(h+=1)<r&&(c=t[h],f=u(c))):(o=p,(l+=1)<i&&(p=e[l],d=u(p)));h<r&&f<d||i<=l?(n=c,(h+=1)<r&&(c=t[h],f=u(c))):(n=p,(l+=1)<i&&(p=e[l],d=u(p)));var m,v,g=n+o,y=g-n,x=o-y,w=x,b=g;for(;h<r&&l<i;)f<d?(n=c,(h+=1)<r&&(c=t[h],f=u(c))):(n=p,(l+=1)<i&&(p=e[l],d=u(p))),(x=(o=w)-(y=(g=n+o)-n))&&(a[s++]=x),w=b-((m=b+g)-(v=m-b))+(g-v),b=m;for(;h<r;)(x=(o=w)-(y=(g=(n=c)+o)-n))&&(a[s++]=x),w=b-((m=b+g)-(v=m-b))+(g-v),b=m,(h+=1)<r&&(c=t[h]);for(;l<i;)(x=(o=w)-(y=(g=(n=p)+o)-n))&&(a[s++]=x),w=b-((m=b+g)-(v=m-b))+(g-v),b=m,(l+=1)<i&&(p=e[l]);w&&(a[s++]=w);b&&(a[s++]=b);s||(a[s++]=0);return a.length=s,a}},{}],108:[function(t,e,r){function u(t,e,r){var i=e[0],n=e[1],o=r[0]-i,a=r[1]-n;if(0!==o||0!==a){var s=((t[0]-i)*o+(t[1]-n)*a)/(o*o+a*a);1<s?(i=r[0],n=r[1]):0<s&&(i+=o*s,n+=a*s)}return(o=t[0]-i)*o+(a=t[1]-n)*a}e.exports=function(t,e){if(t.length<=1)return t;var r=(e="number"==typeof e?e:1)*e,i=t.length-1,n=[t[0]];return function t(e,r,i,n,o){for(var a,s=n,h=r+1;h<i;h++){var l=u(e[h],e[r],e[i]);s<l&&(a=h,s=l)}n<s&&(1<a-r&&t(e,r,a,n,o),o.push(e[a]),1<i-a&&t(e,a,i,n,o))}(t,0,i,r,n),n.push(t[i]),n}},{}],109:[function(t,e,r){var i=t("./radial-distance"),n=t("./douglas-peucker");e.exports=function(t,e){return t=i(t,e),t=n(t,e)},e.exports.radialDistance=i,e.exports.douglasPeucker=n},{"./douglas-peucker":108,"./radial-distance":110}],110:[function(t,e,r){e.exports=function(t,e){if(t.length<=1)return t;for(var r,i,n,o,a,s=(e="number"==typeof e?e:1)*e,h=t[0],l=[h],u=1,c=t.length;u<c;u++)r=t[u],n=h,void 0,o=(i=r)[0]-n[0],a=i[1]-n[1],s<o*o+a*a&&(l.push(r),h=r);return h!==r&&l.push(r),l}},{}],111:[function(t,e,r){var u=t("adaptive-bezier-curve"),i=t("abs-svg-path"),n=t("normalize-svg-path"),c=t("vec2-copy");function f(t,e,r){return t[0]=e,t[1]=r,t}var p=[0,0],d=[0,0],m=[0,0];e.exports=function(t,a){var s=[],h=[],l=[0,0];return n(i(t)).forEach(function(t,e,r){if("M"===t[0])c(l,t.slice(1)),0<h.length&&(s.push(h),h=[]);else{if("C"!==t[0])throw new Error("illegal type in SVG: "+t[0]);i=h,n=a,u(l,f(p,(o=t)[1],o[2]),f(d,o[3],o[4]),f(m,o[5],o[6]),n,i),f(l,t[5],t[6])}var i,n,o}),0<h.length&&s.push(h),s}},{"abs-svg-path":3,"adaptive-bezier-curve":5,"normalize-svg-path":88,"vec2-copy":130}],112:[function(t,e,r){var i=t("inherits");e.exports=function(n){function e(t){if(!(this instanceof e))return new e(t);n.Geometry.call(this),this.dynamic=!0,t&&this.update(t)}return i(e,n.Geometry),e.prototype._updatePositions=function(t){for(var e=0;e<t.length;e++){var r=t[e];e>this.vertices.length-1?this.vertices.push((new n.Vector3).fromArray(r)):this.vertices[e].fromArray(r)}this.vertices.length=t.length,this.verticesNeedUpdate=!0},e.prototype._updateCells=function(t){for(var e=0;e<t.length;e++){var r=t[e];if(e>this.faces.length-1)this.faces.push(new n.Face3(r[0],r[1],r[2]));else{var i=this.faces[e];i.a=r[0],i.b=r[1],i.c=r[2]}}this.faces.length=t.length,this.elementsNeedUpdate=!0},e.prototype.update=function(t){this._updatePositions(t.positions),this._updateCells(t.cells)},e}},{inherits:79}],113:[function(t,e,r){var i,n,o,a,s,h,l,u,c,f,p,d,m,v,g,y,x,w,b,M,_,S,T,A,C,E,L,P,R,F,D,U,B,k,z,V,N,O,I,G,H,W,j,X,q,Y,K,Z,Q,J,$,tt,et,rt,it,nt,ot,at,st,ht,lt,ut,ct,ft,pt,dt,mt,vt,gt,yt,xt,wt,bt,Mt,_t,St,Tt,At,Ct,Et,Lt,Pt,Rt,Ft,Dt,Ut,Bt,kt,zt,Vt,Nt,Ot,It,Gt,Ht,Wt,jt,Xt,qt,Yt,Kt,Zt,Qt,Jt,$t,te,ee,re,ie,ne,oe,ae,se,he,le,ue,ce,fe,pe,de,me,ve,ge,ye,xe,we,be,Me,_e,Se,Te,Ae,Ce,Ee,Le,Pe,Re,Fe,De,Ue,Be,ke,ze,Ve,Ne,Oe,Ie,Ge,He=He||{},We={REVISION:"69"};"object"==typeof e&&(e.exports=We),void 0===Math.sign&&(Math.sign=function(t){return t<0?-1:0<t?1:0}),We.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2},We.CullFaceNone=0,We.CullFaceBack=1,We.CullFaceFront=2,We.CullFaceFrontBack=3,We.FrontFaceDirectionCW=0,We.FrontFaceDirectionCCW=1,We.BasicShadowMap=0,We.PCFShadowMap=1,We.PCFSoftShadowMap=2,We.FrontSide=0,We.BackSide=1,We.DoubleSide=2,We.NoShading=0,We.FlatShading=1,We.SmoothShading=2,We.NoColors=0,We.FaceColors=1,We.VertexColors=2,We.NoBlending=0,We.NormalBlending=1,We.AdditiveBlending=2,We.SubtractiveBlending=3,We.MultiplyBlending=4,We.CustomBlending=5,We.AddEquation=100,We.SubtractEquation=101,We.ReverseSubtractEquation=102,We.MinEquation=103,We.MaxEquation=104,We.ZeroFactor=200,We.OneFactor=201,We.SrcColorFactor=202,We.OneMinusSrcColorFactor=203,We.SrcAlphaFactor=204,We.OneMinusSrcAlphaFactor=205,We.DstAlphaFactor=206,We.OneMinusDstAlphaFactor=207,We.DstColorFactor=208,We.OneMinusDstColorFactor=209,We.SrcAlphaSaturateFactor=210,We.MultiplyOperation=0,We.MixOperation=1,We.AddOperation=2,We.UVMapping=function(){},We.CubeReflectionMapping=function(){},We.CubeRefractionMapping=function(){},We.SphericalReflectionMapping=function(){},We.SphericalRefractionMapping=function(){},We.RepeatWrapping=1e3,We.ClampToEdgeWrapping=1001,We.MirroredRepeatWrapping=1002,We.NearestFilter=1003,We.NearestMipMapNearestFilter=1004,We.NearestMipMapLinearFilter=1005,We.LinearFilter=1006,We.LinearMipMapNearestFilter=1007,We.LinearMipMapLinearFilter=1008,We.UnsignedByteType=1009,We.ByteType=1010,We.ShortType=1011,We.UnsignedShortType=1012,We.IntType=1013,We.UnsignedIntType=1014,We.FloatType=1015,We.UnsignedShort4444Type=1016,We.UnsignedShort5551Type=1017,We.UnsignedShort565Type=1018,We.AlphaFormat=1019,We.RGBFormat=1020,We.RGBAFormat=1021,We.LuminanceFormat=1022,We.LuminanceAlphaFormat=1023,We.RGB_S3TC_DXT1_Format=2001,We.RGBA_S3TC_DXT1_Format=2002,We.RGBA_S3TC_DXT3_Format=2003,We.RGBA_S3TC_DXT5_Format=2004,We.RGB_PVRTC_4BPPV1_Format=2100,We.RGB_PVRTC_2BPPV1_Format=2101,We.RGBA_PVRTC_4BPPV1_Format=2102,We.RGBA_PVRTC_2BPPV1_Format=2103,We.Color=function(t){return 3===arguments.length?this.setRGB(t,arguments[1],arguments[2]):this.set(t)},We.Color.prototype={constructor:We.Color,r:1,g:1,b:1,set:function(t){return t instanceof We.Color?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t),this},setHex:function(t){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,this},setRGB:function(t,e,r){return this.r=t,this.g=e,this.b=r,this},setHSL:function(t,e,r){if(0===e)this.r=this.g=this.b=r;else{var i=function(t,e,r){return r<0&&(r+=1),1<r&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+6*(e-t)*(2/3-r):t},n=r<=.5?r*(1+e):r+e-r*e,o=2*r-n;this.r=i(o,n,t+1/3),this.g=i(o,n,t),this.b=i(o,n,t-1/3)}return this},setStyle:function(t){if(/^rgb\((\d+), ?(\d+), ?(\d+)\)$/i.test(t)){var e=/^rgb\((\d+), ?(\d+), ?(\d+)\)$/i.exec(t);return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,this}if(/^rgb\((\d+)\%, ?(\d+)\%, ?(\d+)\%\)$/i.test(t)){e=/^rgb\((\d+)\%, ?(\d+)\%, ?(\d+)\%\)$/i.exec(t);return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,this}if(/^\#([0-9a-f]{6})$/i.test(t)){e=/^\#([0-9a-f]{6})$/i.exec(t);return this.setHex(parseInt(e[1],16)),this}if(/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.test(t)){e=/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(t);return this.setHex(parseInt(e[1]+e[1]+e[2]+e[2]+e[3]+e[3],16)),this}if(/^(\w+)$/i.test(t))return this.setHex(We.ColorKeywords[t]),this},copy:function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},copyGammaToLinear:function(t){return this.r=t.r*t.r,this.g=t.g*t.g,this.b=t.b*t.b,this},copyLinearToGamma:function(t){return this.r=Math.sqrt(t.r),this.g=Math.sqrt(t.g),this.b=Math.sqrt(t.b),this},convertGammaToLinear:function(){var t=this.r,e=this.g,r=this.b;return this.r=t*t,this.g=e*e,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(t){var e,r,i=t||{h:0,s:0,l:0},n=this.r,o=this.g,a=this.b,s=Math.max(n,o,a),h=Math.min(n,o,a),l=(h+s)/2;if(h===s)r=e=0;else{var u=s-h;switch(r=l<=.5?u/(s+h):u/(2-s-h),s){case n:e=(o-a)/u+(o<a?6:0);break;case o:e=(a-n)/u+2;break;case a:e=(n-o)/u+4}e/=6}return i.h=e,i.s=r,i.l=l,i},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(t,e,r){var i=this.getHSL();return i.h+=t,i.s+=e,i.l+=r,this.setHSL(i.h,i.s,i.l),this},add:function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this},addColors:function(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this},addScalar:function(t){return this.r+=t,this.g+=t,this.b+=t,this},multiply:function(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this},multiplyScalar:function(t){return this.r*=t,this.g*=t,this.b*=t,this},lerp:function(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this},equals:function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b},fromArray:function(t){return this.r=t[0],this.g=t[1],this.b=t[2],this},toArray:function(){return[this.r,this.g,this.b]},clone:function(){return(new We.Color).setRGB(this.r,this.g,this.b)}},We.ColorKeywords={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,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},We.Quaternion=function(t,e,r,i){this._x=t||0,this._y=e||0,this._z=r||0,this._w=void 0!==i?i:1},We.Quaternion.prototype={constructor:We.Quaternion,_x:0,_y:0,_z:0,_w:0,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get w(){return this._w},set w(t){this._w=t,this.onChangeCallback()},set:function(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._w=i,this.onChangeCallback(),this},copy:function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this.onChangeCallback(),this},setFromEuler:function(t,e){if(t instanceof We.Euler==!1)throw new Error("THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var r=Math.cos(t._x/2),i=Math.cos(t._y/2),n=Math.cos(t._z/2),o=Math.sin(t._x/2),a=Math.sin(t._y/2),s=Math.sin(t._z/2);return"XYZ"===t.order?(this._x=o*i*n+r*a*s,this._y=r*a*n-o*i*s,this._z=r*i*s+o*a*n,this._w=r*i*n-o*a*s):"YXZ"===t.order?(this._x=o*i*n+r*a*s,this._y=r*a*n-o*i*s,this._z=r*i*s-o*a*n,this._w=r*i*n+o*a*s):"ZXY"===t.order?(this._x=o*i*n-r*a*s,this._y=r*a*n+o*i*s,this._z=r*i*s+o*a*n,this._w=r*i*n-o*a*s):"ZYX"===t.order?(this._x=o*i*n-r*a*s,this._y=r*a*n+o*i*s,this._z=r*i*s-o*a*n,this._w=r*i*n+o*a*s):"YZX"===t.order?(this._x=o*i*n+r*a*s,this._y=r*a*n+o*i*s,this._z=r*i*s-o*a*n,this._w=r*i*n-o*a*s):"XZY"===t.order&&(this._x=o*i*n-r*a*s,this._y=r*a*n-o*i*s,this._z=r*i*s+o*a*n,this._w=r*i*n+o*a*s),!1!==e&&this.onChangeCallback(),this},setFromAxisAngle:function(t,e){var r=e/2,i=Math.sin(r);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(r),this.onChangeCallback(),this},setFromRotationMatrix:function(t){var e,r=t.elements,i=r[0],n=r[4],o=r[8],a=r[1],s=r[5],h=r[9],l=r[2],u=r[6],c=r[10],f=i+s+c;return 0<f?(e=.5/Math.sqrt(f+1),this._w=.25/e,this._x=(u-h)*e,this._y=(o-l)*e,this._z=(a-n)*e):s<i&&c<i?(e=2*Math.sqrt(1+i-s-c),this._w=(u-h)/e,this._x=.25*e,this._y=(n+a)/e,this._z=(o+l)/e):c<s?(e=2*Math.sqrt(1+s-i-c),this._w=(o-l)/e,this._x=(n+a)/e,this._y=.25*e,this._z=(h+u)/e):(e=2*Math.sqrt(1+c-i-s),this._w=(a-n)/e,this._x=(o+l)/e,this._y=(h+u)/e,this._z=.25*e),this.onChangeCallback(),this},setFromUnitVectors:function(t,e){return void 0===i&&(i=new We.Vector3),(n=t.dot(e)+1)<1e-6?(n=0,Math.abs(t.x)>Math.abs(t.z)?i.set(-t.y,t.x,0):i.set(0,-t.z,t.y)):i.crossVectors(t,e),this._x=i.x,this._y=i.y,this._z=i.z,this._w=n,this.normalize(),this},inverse:function(){return this.conjugate().normalize(),this},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this.onChangeCallback(),this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(t,e)):this.multiplyQuaternions(this,t)},multiplyQuaternions:function(t,e){var r=t._x,i=t._y,n=t._z,o=t._w,a=e._x,s=e._y,h=e._z,l=e._w;return this._x=r*l+o*a+i*h-n*s,this._y=i*l+o*s+n*a-r*h,this._z=n*l+o*h+r*s-i*a,this._w=o*l-r*a-i*s-n*h,this.onChangeCallback(),this},multiplyVector3:function(t){return console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead."),t.applyQuaternion(this)},slerp:function(t,e){if(0===e)return this;if(1===e)return this.copy(t);var r=this._x,i=this._y,n=this._z,o=this._w,a=o*t._w+r*t._x+i*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),1<=a)return this._w=o,this._x=r,this._y=i,this._z=n,this;var s=Math.acos(a),h=Math.sqrt(1-a*a);if(Math.abs(h)<.001)return this._w=.5*(o+this._w),this._x=.5*(r+this._x),this._y=.5*(i+this._y),this._z=.5*(n+this._z),this;var l=Math.sin((1-e)*s)/h,u=Math.sin(e*s)/h;return this._w=o*l+this._w*u,this._x=r*l+this._x*u,this._y=i*l+this._y*u,this._z=n*l+this._z*u,this.onChangeCallback(),this},equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},fromArray:function(t,e){return void 0===e&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback(),this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){},clone:function(){return new We.Quaternion(this._x,this._y,this._z,this._w)}},We.Quaternion.slerp=function(t,e,r,i){return r.copy(t).slerp(e,i)},We.Vector2=function(t,e){this.x=t||0,this.y=e||0},We.Vector2.prototype={constructor:We.Vector2,set:function(t,e){return this.x=t,this.y=e,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},copy:function(t){return this.x=t.x,this.y=t.y,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this)},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},addScalar:function(t){return this.x+=t,this.y+=t,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this)},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},multiply:function(t){return this.x*=t.x,this.y*=t.y,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this},divide:function(t){return this.x/=t.x,this.y/=t.y,this},divideScalar:function(t){if(0!==t){var e=1/t;this.x*=e,this.y*=e}else this.x=0,this.y=0;return this},min:function(t){return this.x>t.x&&(this.x=t.x),this.y>t.y&&(this.y=t.y),this},max:function(t){return this.x<t.x&&(this.x=t.x),this.y<t.y&&(this.y=t.y),this},clamp:function(t,e){return this.x<t.x?this.x=t.x:this.x>e.x&&(this.x=e.x),this.y<t.y?this.y=t.y:this.y>e.y&&(this.y=e.y),this},clampScalar:function(t,e){return void 0===o&&(o=new We.Vector2,a=new We.Vector2),o.set(t,t),a.set(e,e),this.clamp(o,a)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(t){return this.x*t.x+this.y*t.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},setLength:function(t){var e=this.length();return 0!==e&&t!==e&&this.multiplyScalar(t/e),this},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},equals:function(t){return t.x===this.x&&t.y===this.y},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t},clone:function(){return new We.Vector2(this.x,this.y)}},We.Vector3=function(t,e,r){this.x=t||0,this.y=e||0,this.z=r||0},We.Vector3.prototype={constructor:We.Vector3,set:function(t,e,r){return this.x=t,this.y=e,this.z=r,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this)},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},multiply:function(t,e){return void 0!==e?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(t,e)):(this.x*=t.x,this.y*=t.y,this.z*=t.z,this)},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this},multiplyVectors:function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},applyEuler:function(t){return t instanceof We.Euler==0&&console.error("THREE.Vector3: .applyEuler() now expects a Euler rotation rather than a Vector3 and order."),void 0===v&&(v=new We.Quaternion),this.applyQuaternion(v.setFromEuler(t)),this},applyAxisAngle:function(t,e){return void 0===m&&(m=new We.Quaternion),this.applyQuaternion(m.setFromAxisAngle(t,e)),this},applyMatrix3:function(t){var e=this.x,r=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[3]*r+n[6]*i,this.y=n[1]*e+n[4]*r+n[7]*i,this.z=n[2]*e+n[5]*r+n[8]*i,this},applyMatrix4:function(t){var e=this.x,r=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*r+n[8]*i+n[12],this.y=n[1]*e+n[5]*r+n[9]*i+n[13],this.z=n[2]*e+n[6]*r+n[10]*i+n[14],this},applyProjection:function(t){var e=this.x,r=this.y,i=this.z,n=t.elements,o=1/(n[3]*e+n[7]*r+n[11]*i+n[15]);return this.x=(n[0]*e+n[4]*r+n[8]*i+n[12])*o,this.y=(n[1]*e+n[5]*r+n[9]*i+n[13])*o,this.z=(n[2]*e+n[6]*r+n[10]*i+n[14])*o,this},applyQuaternion:function(t){var e=this.x,r=this.y,i=this.z,n=t.x,o=t.y,a=t.z,s=t.w,h=s*e+o*i-a*r,l=s*r+a*e-n*i,u=s*i+n*r-o*e,c=-n*e-o*r-a*i;return this.x=h*s+c*-n+l*-a-u*-o,this.y=l*s+c*-o+u*-n-h*-a,this.z=u*s+c*-a+h*-o-l*-n,this},project:function(t){return void 0===d&&(d=new We.Matrix4),d.multiplyMatrices(t.projectionMatrix,d.getInverse(t.matrixWorld)),this.applyProjection(d)},unproject:function(t){return void 0===p&&(p=new We.Matrix4),p.multiplyMatrices(t.matrixWorld,p.getInverse(t.projectionMatrix)),this.applyProjection(p)},transformDirection:function(t){var e=this.x,r=this.y,i=this.z,n=t.elements;return this.x=n[0]*e+n[4]*r+n[8]*i,this.y=n[1]*e+n[5]*r+n[9]*i,this.z=n[2]*e+n[6]*r+n[10]*i,this.normalize(),this},divide:function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},divideScalar:function(t){if(0!==t){var e=1/t;this.x*=e,this.y*=e,this.z*=e}else this.x=0,this.y=0,this.z=0;return this},min:function(t){return this.x>t.x&&(this.x=t.x),this.y>t.y&&(this.y=t.y),this.z>t.z&&(this.z=t.z),this},max:function(t){return this.x<t.x&&(this.x=t.x),this.y<t.y&&(this.y=t.y),this.z<t.z&&(this.z=t.z),this},clamp:function(t,e){return this.x<t.x?this.x=t.x:this.x>e.x&&(this.x=e.x),this.y<t.y?this.y=t.y:this.y>e.y&&(this.y=e.y),this.z<t.z?this.z=t.z:this.z>e.z&&(this.z=e.z),this},clampScalar:function(t,e){return void 0===c&&(c=new We.Vector3,f=new We.Vector3),c.set(t,t,t),f.set(e,e,e),this.clamp(c,f)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(t){var e=this.length();return 0!==e&&t!==e&&this.multiplyScalar(t/e),this},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this},cross:function(t,e){if(void 0!==e)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(t,e);var r=this.x,i=this.y,n=this.z;return this.x=i*t.z-n*t.y,this.y=n*t.x-r*t.z,this.z=r*t.y-i*t.x,this},crossVectors:function(t,e){var r=t.x,i=t.y,n=t.z,o=e.x,a=e.y,s=e.z;return this.x=i*s-n*a,this.y=n*o-r*s,this.z=r*a-i*o,this},projectOnVector:function(t){return void 0===l&&(l=new We.Vector3),l.copy(t).normalize(),u=this.dot(l),this.copy(l).multiplyScalar(u)},projectOnPlane:function(t){return void 0===h&&(h=new We.Vector3),h.copy(this).projectOnVector(t),this.sub(h)},reflect:function(t){return void 0===s&&(s=new We.Vector3),this.sub(s.copy(t).multiplyScalar(2*this.dot(t)))},angleTo:function(t){var e=this.dot(t)/(this.length()*t.length());return Math.acos(We.Math.clamp(e,-1,1))},distanceTo:function(t){return Math.sqrt(this.distanceToSquared(t))},distanceToSquared:function(t){var e=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return e*e+r*r+i*i},setEulerFromRotationMatrix:function(t,e){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(t,e){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(t){return console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."),this.setFromMatrixPosition(t)},getScaleFromMatrix:function(t){return console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."),this.setFromMatrixScale(t)},getColumnFromMatrix:function(t,e){return console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn()."),this.setFromMatrixColumn(t,e)},setFromMatrixPosition:function(t){return this.x=t.elements[12],this.y=t.elements[13],this.z=t.elements[14],this},setFromMatrixScale:function(t){var e=this.set(t.elements[0],t.elements[1],t.elements[2]).length(),r=this.set(t.elements[4],t.elements[5],t.elements[6]).length(),i=this.set(t.elements[8],t.elements[9],t.elements[10]).length();return this.x=e,this.y=r,this.z=i,this},setFromMatrixColumn:function(t,e){var r=4*t,i=e.elements;return this.x=i[r],this.y=i[r+1],this.z=i[r+2],this},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},clone:function(){return new We.Vector3(this.x,this.y,this.z)}},We.Vector4=function(t,e,r,i){this.x=t||0,this.y=e||0,this.z=r||0,this.w=void 0!==i?i:1},We.Vector4.prototype={constructor:We.Vector4,set:function(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this},setX:function(t){return this.x=t,this},setY:function(t){return this.y=t,this},setZ:function(t){return this.z=t,this},setW:function(t){return this.w=t,this},setComponent:function(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}},getComponent:function(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}},copy:function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this},add:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(t,e)):(this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this)},addScalar:function(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this},addVectors:function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this},sub:function(t,e){return void 0!==e?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(t,e)):(this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this)},subVectors:function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this},multiplyScalar:function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},applyMatrix4:function(t){var e=this.x,r=this.y,i=this.z,n=this.w,o=t.elements;return this.x=o[0]*e+o[4]*r+o[8]*i+o[12]*n,this.y=o[1]*e+o[5]*r+o[9]*i+o[13]*n,this.z=o[2]*e+o[6]*r+o[10]*i+o[14]*n,this.w=o[3]*e+o[7]*r+o[11]*i+o[15]*n,this},divideScalar:function(t){if(0!==t){var e=1/t;this.x*=e,this.y*=e,this.z*=e,this.w*=e}else this.x=0,this.y=0,this.z=0,this.w=1;return this},setAxisAngleFromQuaternion:function(t){this.w=2*Math.acos(t.w);var e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this},setAxisAngleFromRotationMatrix:function(t){var e,r,i,n,o=t.elements,a=o[0],s=o[4],h=o[8],l=o[1],u=o[5],c=o[9],f=o[2],p=o[6],d=o[10];if(Math.abs(s-l)<.01&&Math.abs(h-f)<.01&&Math.abs(c-p)<.01){if(Math.abs(s+l)<.1&&Math.abs(h+f)<.1&&Math.abs(c+p)<.1&&Math.abs(a+u+d-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;var m=(a+1)/2,v=(u+1)/2,g=(d+1)/2,y=(s+l)/4,x=(h+f)/4,w=(c+p)/4;return v<m&&g<m?m<.01?(r=0,n=i=.707106781):(i=y/(r=Math.sqrt(m)),n=x/r):g<v?v<.01?(i=0,n=r=.707106781):(r=y/(i=Math.sqrt(v)),n=w/i):g<.01?(i=r=.707106781,n=0):(r=x/(n=Math.sqrt(g)),i=w/n),this.set(r,i,n,e),this}var b=Math.sqrt((p-c)*(p-c)+(h-f)*(h-f)+(l-s)*(l-s));return Math.abs(b)<.001&&(b=1),this.x=(p-c)/b,this.y=(h-f)/b,this.z=(l-s)/b,this.w=Math.acos((a+u+d-1)/2),this},min:function(t){return this.x>t.x&&(this.x=t.x),this.y>t.y&&(this.y=t.y),this.z>t.z&&(this.z=t.z),this.w>t.w&&(this.w=t.w),this},max:function(t){return this.x<t.x&&(this.x=t.x),this.y<t.y&&(this.y=t.y),this.z<t.z&&(this.z=t.z),this.w<t.w&&(this.w=t.w),this},clamp:function(t,e){return this.x<t.x?this.x=t.x:this.x>e.x&&(this.x=e.x),this.y<t.y?this.y=t.y:this.y>e.y&&(this.y=e.y),this.z<t.z?this.z=t.z:this.z>e.z&&(this.z=e.z),this.w<t.w?this.w=t.w:this.w>e.w&&(this.w=e.w),this},clampScalar:function(t,e){return void 0===g&&(g=new We.Vector4,y=new We.Vector4),g.set(t,t,t,t),y.set(e,e,e,e),this.clamp(g,y)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(t){var e=this.length();return 0!==e&&t!==e&&this.multiplyScalar(t/e),this},lerp:function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this},equals:function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},fromArray:function(t,e){return void 0===e&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this},toArray:function(t,e){return void 0===t&&(t=[]),void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t},clone:function(){return new We.Vector4(this.x,this.y,this.z,this.w)}},We.Euler=function(t,e,r,i){this._x=t||0,this._y=e||0,this._z=r||0,this._order=i||We.Euler.DefaultOrder},We.Euler.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],We.Euler.DefaultOrder="XYZ",We.Euler.prototype={constructor:We.Euler,_x:0,_y:0,_z:0,_order:We.Euler.DefaultOrder,get x(){return this._x},set x(t){this._x=t,this.onChangeCallback()},get y(){return this._y},set y(t){this._y=t,this.onChangeCallback()},get z(){return this._z},set z(t){this._z=t,this.onChangeCallback()},get order(){return this._order},set order(t){this._order=t,this.onChangeCallback()},set:function(t,e,r,i){return this._x=t,this._y=e,this._z=r,this._order=i||this._order,this.onChangeCallback(),this},copy:function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback(),this},setFromRotationMatrix:function(t,e){var r=We.Math.clamp,i=t.elements,n=i[0],o=i[4],a=i[8],s=i[1],h=i[5],l=i[9],u=i[2],c=i[6],f=i[10];return"XYZ"===(e=e||this._order)?(this._y=Math.asin(r(a,-1,1)),Math.abs(a)<.99999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-o,n)):(this._x=Math.atan2(c,h),this._z=0)):"YXZ"===e?(this._x=Math.asin(-r(l,-1,1)),Math.abs(l)<.99999?(this._y=Math.atan2(a,f),this._z=Math.atan2(s,h)):(this._y=Math.atan2(-u,n),this._z=0)):"ZXY"===e?(this._x=Math.asin(r(c,-1,1)),Math.abs(c)<.99999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(s,n))):"ZYX"===e?(this._y=Math.asin(-r(u,-1,1)),Math.abs(u)<.99999?(this._x=Math.atan2(c,f),this._z=Math.atan2(s,n)):(this._x=0,this._z=Math.atan2(-o,h))):"YZX"===e?(this._z=Math.asin(r(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(a,f))):"XZY"===e?(this._z=Math.asin(-r(o,-1,1)),Math.abs(o)<.99999?(this._x=Math.atan2(c,h),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-l,f),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+e),this._order=e,this.onChangeCallback(),this},setFromQuaternion:function(t,e,r){var i=We.Math.clamp,n=t.x*t.x,o=t.y*t.y,a=t.z*t.z,s=t.w*t.w;return"XYZ"===(e=e||this._order)?(this._x=Math.atan2(2*(t.x*t.w-t.y*t.z),s-n-o+a),this._y=Math.asin(i(2*(t.x*t.z+t.y*t.w),-1,1)),this._z=Math.atan2(2*(t.z*t.w-t.x*t.y),s+n-o-a)):"YXZ"===e?(this._x=Math.asin(i(2*(t.x*t.w-t.y*t.z),-1,1)),this._y=Math.atan2(2*(t.x*t.z+t.y*t.w),s-n-o+a),this._z=Math.atan2(2*(t.x*t.y+t.z*t.w),s-n+o-a)):"ZXY"===e?(this._x=Math.asin(i(2*(t.x*t.w+t.y*t.z),-1,1)),this._y=Math.atan2(2*(t.y*t.w-t.z*t.x),s-n-o+a),this._z=Math.atan2(2*(t.z*t.w-t.x*t.y),s-n+o-a)):"ZYX"===e?(this._x=Math.atan2(2*(t.x*t.w+t.z*t.y),s-n-o+a),this._y=Math.asin(i(2*(t.y*t.w-t.x*t.z),-1,1)),this._z=Math.atan2(2*(t.x*t.y+t.z*t.w),s+n-o-a)):"YZX"===e?(this._x=Math.atan2(2*(t.x*t.w-t.z*t.y),s-n+o-a),this._y=Math.atan2(2*(t.y*t.w-t.x*t.z),s+n-o-a),this._z=Math.asin(i(2*(t.x*t.y+t.z*t.w),-1,1))):"XZY"===e?(this._x=Math.atan2(2*(t.x*t.w+t.y*t.z),s-n+o-a),this._y=Math.atan2(2*(t.x*t.z+t.y*t.w),s+n-o-a),this._z=Math.asin(i(2*(t.z*t.w-t.x*t.y),-1,1))):console.warn("THREE.Euler: .setFromQuaternion() given unsupported order: "+e),this._order=e,!1!==r&&this.onChangeCallback(),this},reorder:(x=new We.Quaternion,function(t){x.setFromEuler(this),this.setFromQuaternion(x,t)}),equals:function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},fromArray:function(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this.onChangeCallback(),this},toArray:function(){return[this._x,this._y,this._z,this._order]},onChange:function(t){return this.onChangeCallback=t,this},onChangeCallback:function(){},clone:function(){return new We.Euler(this._x,this._y,this._z,this._order)}},We.Line3=function(t,e){this.start=void 0!==t?t:new We.Vector3,this.end=void 0!==e?e:new We.Vector3},We.Line3.prototype={constructor:We.Line3,set:function(t,e){return this.start.copy(t),this.end.copy(e),this},copy:function(t){return this.start.copy(t.start),this.end.copy(t.end),this},center:function(t){return(t||new We.Vector3).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(t){return(t||new We.Vector3).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(t,e){var r=e||new We.Vector3;return this.delta(r).multiplyScalar(t).add(this.start)},closestPointToPointParameter:(w=new We.Vector3,b=new We.Vector3,function(t,e){w.subVectors(t,this.start),b.subVectors(this.end,this.start);var r=b.dot(b),i=b.dot(w)/r;return e&&(i=We.Math.clamp(i,0,1)),i}),closestPointToPoint:function(t,e,r){var i=this.closestPointToPointParameter(t,e),n=r||new We.Vector3;return this.delta(n).multiplyScalar(i).add(this.start)},applyMatrix4:function(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this},equals:function(t){return t.start.equals(this.start)&&t.end.equals(this.end)},clone:function(){return(new We.Line3).copy(this)}},We.Box2=function(t,e){this.min=void 0!==t?t:new We.Vector2(1/0,1/0),this.max=void 0!==e?e:new We.Vector2(-1/0,-1/0)},We.Box2.prototype={constructor:We.Box2,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:(_=new We.Vector2,function(t,e){var r=_.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}),copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},empty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},center:function(t){return(t||new We.Vector2).addVectors(this.min,this.max).multiplyScalar(.5)},size:function(t){return(t||new We.Vector2).subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y},getParameter:function(t,e){return(e||new We.Vector2).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))},isIntersectionBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)},clampPoint:function(t,e){return(e||new We.Vector2).copy(t).clamp(this.min,this.max)},distanceToPoint:(M=new We.Vector2,function(t){return M.copy(t).clamp(this.min,this.max).sub(t).length()}),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},clone:function(){return(new We.Box2).copy(this)}},We.Box3=function(t,e){this.min=void 0!==t?t:new We.Vector3(1/0,1/0,1/0),this.max=void 0!==e?e:new We.Vector3(-1/0,-1/0,-1/0)},We.Box3.prototype={constructor:We.Box3,set:function(t,e){return this.min.copy(t),this.max.copy(e),this},setFromPoints:function(t){this.makeEmpty();for(var e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this},setFromCenterAndSize:(E=new We.Vector3,function(t,e){var r=E.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(r),this.max.copy(t).add(r),this}),setFromObject:(C=new We.Vector3,function(t){var a=this;return t.updateMatrixWorld(!0),this.makeEmpty(),t.traverse(function(t){var e=t.geometry;if(void 0!==e)if(e instanceof We.Geometry)for(var r=e.vertices,i=0,n=r.length;i<n;i++)C.copy(r[i]),C.applyMatrix4(t.matrixWorld),a.expandByPoint(C);else if(e instanceof We.BufferGeometry&&void 0!==e.attributes.position){var o=e.attributes.position.array;for(i=0,n=o.length;i<n;i+=3)C.set(o[i],o[i+1],o[i+2]),C.applyMatrix4(t.matrixWorld),a.expandByPoint(C)}}),this}),copy:function(t){return this.min.copy(t.min),this.max.copy(t.max),this},makeEmpty:function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},empty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},center:function(t){return(t||new We.Vector3).addVectors(this.min,this.max).multiplyScalar(.5)},size:function(t){return(t||new We.Vector3).subVectors(this.max,this.min)},expandByPoint:function(t){return this.min.min(t),this.max.max(t),this},expandByVector:function(t){return this.min.sub(t),this.max.add(t),this},expandByScalar:function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},containsPoint:function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)},containsBox:function(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z},getParameter:function(t,e){return(e||new We.Vector3).set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))},isIntersectionBox:function(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)},clampPoint:function(t,e){return(e||new We.Vector3).copy(t).clamp(this.min,this.max)},distanceToPoint:(A=new We.Vector3,function(t){return A.copy(t).clamp(this.min,this.max).sub(t).length()}),getBoundingSphere:(T=new We.Vector3,function(t){var e=t||new We.Sphere;return e.center=this.center(),e.radius=.5*this.size(T).length(),e}),intersect:function(t){return this.min.max(t.min),this.max.min(t.max),this},union:function(t){return this.min.min(t.min),this.max.max(t.max),this},applyMatrix4:(S=[new We.Vector3,new We.Vector3,new We.Vector3,new We.Vector3,new We.Vector3,new We.Vector3,new We.Vector3,new We.Vector3],function(t){return S[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),S[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),S[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),S[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),S[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),S[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),S[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),S[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.makeEmpty(),this.setFromPoints(S),this}),translate:function(t){return this.min.add(t),this.max.add(t),this},equals:function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},clone:function(){return(new We.Box3).copy(this)}},We.Matrix3=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]),0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")},We.Matrix3.prototype={constructor:We.Matrix3,set:function(t,e,r,i,n,o,a,s,h){var l=this.elements;return l[0]=t,l[3]=e,l[6]=r,l[1]=i,l[4]=n,l[7]=o,l[2]=a,l[5]=s,l[8]=h,this},identity:function(){return this.set(1,0,0,0,1,0,0,0,1),this},copy:function(t){var e=t.elements;return this.set(e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]),this},multiplyVector3:function(t){return console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."),t.applyMatrix3(this)},multiplyVector3Array:function(t){return console.warn("THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead."),this.applyToVector3Array(t)},applyToVector3Array:(L=new We.Vector3,function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=t.length);for(var i=0,n=e;i<r;i+=3,n+=3)L.x=t[n],L.y=t[n+1],L.z=t[n+2],L.applyMatrix3(this),t[n]=L.x,t[n+1]=L.y,t[n+2]=L.z;return t}),multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this},determinant:function(){var t=this.elements,e=t[0],r=t[1],i=t[2],n=t[3],o=t[4],a=t[5],s=t[6],h=t[7],l=t[8];return e*o*l-e*a*h-r*n*l+r*a*s+i*n*h-i*o*s},getInverse:function(t,e){var r=t.elements,i=this.elements;i[0]=r[10]*r[5]-r[6]*r[9],i[1]=-r[10]*r[1]+r[2]*r[9],i[2]=r[6]*r[1]-r[2]*r[5],i[3]=-r[10]*r[4]+r[6]*r[8],i[4]=r[10]*r[0]-r[2]*r[8],i[5]=-r[6]*r[0]+r[2]*r[4],i[6]=r[9]*r[4]-r[5]*r[8],i[7]=-r[9]*r[0]+r[1]*r[8],i[8]=r[5]*r[0]-r[1]*r[4];var n=r[0]*i[0]+r[1]*i[3]+r[2]*i[6];if(0===n){var o="Matrix3.getInverse(): can't invert matrix, determinant is 0";if(e)throw new Error(o);return console.warn(o),this.identity(),this}return this.multiplyScalar(1/n),this},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this},flattenToArrayOffset:function(t,e){var r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t},getNormalMatrix:function(t){return this.getInverse(t).transpose(),this},transposeIntoArray:function(t){var e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this},fromArray:function(t){return this.elements.set(t),this},toArray:function(){var t=this.elements;return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8]]},clone:function(){return(new We.Matrix3).fromArray(this.elements)}},We.Matrix4=function(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")},We.Matrix4.prototype={constructor:We.Matrix4,set:function(t,e,r,i,n,o,a,s,h,l,u,c,f,p,d,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=r,v[12]=i,v[1]=n,v[5]=o,v[9]=a,v[13]=s,v[2]=h,v[6]=l,v[10]=u,v[14]=c,v[3]=f,v[7]=p,v[11]=d,v[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},copy:function(t){return this.elements.set(t.elements),this},extractPosition:function(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)},copyPosition:function(t){var e=this.elements,r=t.elements;return e[12]=r[12],e[13]=r[13],e[14]=r[14],this},extractRotation:(z=new We.Vector3,function(t){var e=this.elements,r=t.elements,i=1/z.set(r[0],r[1],r[2]).length(),n=1/z.set(r[4],r[5],r[6]).length(),o=1/z.set(r[8],r[9],r[10]).length();return e[0]=r[0]*i,e[1]=r[1]*i,e[2]=r[2]*i,e[4]=r[4]*n,e[5]=r[5]*n,e[6]=r[6]*n,e[8]=r[8]*o,e[9]=r[9]*o,e[10]=r[10]*o,this}),makeRotationFromEuler:function(t){t instanceof We.Euler==!1&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var e=this.elements,r=t.x,i=t.y,n=t.z,o=Math.cos(r),a=Math.sin(r),s=Math.cos(i),h=Math.sin(i),l=Math.cos(n),u=Math.sin(n);if("XYZ"===t.order){var c=o*l,f=o*u,p=a*l,d=a*u;e[0]=s*l,e[4]=-s*u,e[8]=h,e[1]=f+p*h,e[5]=c-d*h,e[9]=-a*s,e[2]=d-c*h,e[6]=p+f*h,e[10]=o*s}else if("YXZ"===t.order){var m=s*l,v=s*u,g=h*l,y=h*u;e[0]=m+y*a,e[4]=g*a-v,e[8]=o*h,e[1]=o*u,e[5]=o*l,e[9]=-a,e[2]=v*a-g,e[6]=y+m*a,e[10]=o*s}else if("ZXY"===t.order){m=s*l,v=s*u,g=h*l,y=h*u;e[0]=m-y*a,e[4]=-o*u,e[8]=g+v*a,e[1]=v+g*a,e[5]=o*l,e[9]=y-m*a,e[2]=-o*h,e[6]=a,e[10]=o*s}else if("ZYX"===t.order){c=o*l,f=o*u,p=a*l,d=a*u;e[0]=s*l,e[4]=p*h-f,e[8]=c*h+d,e[1]=s*u,e[5]=d*h+c,e[9]=f*h-p,e[2]=-h,e[6]=a*s,e[10]=o*s}else if("YZX"===t.order){var x=o*s,w=o*h,b=a*s,M=a*h;e[0]=s*l,e[4]=M-x*u,e[8]=b*u+w,e[1]=u,e[5]=o*l,e[9]=-a*l,e[2]=-h*l,e[6]=w*u+b,e[10]=x-M*u}else if("XZY"===t.order){x=o*s,w=o*h,b=a*s,M=a*h;e[0]=s*l,e[4]=-u,e[8]=h*l,e[1]=x*u+M,e[5]=o*l,e[9]=w*u-b,e[2]=b*u-w,e[6]=a*l,e[10]=M*u+x}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},setRotationFromQuaternion:function(t){return console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion()."),this.makeRotationFromQuaternion(t)},makeRotationFromQuaternion:function(t){var e=this.elements,r=t.x,i=t.y,n=t.z,o=t.w,a=r+r,s=i+i,h=n+n,l=r*a,u=r*s,c=r*h,f=i*s,p=i*h,d=n*h,m=o*a,v=o*s,g=o*h;return e[0]=1-(f+d),e[4]=u-g,e[8]=c+v,e[1]=u+g,e[5]=1-(l+d),e[9]=p-m,e[2]=c-v,e[6]=p+m,e[10]=1-(l+f),e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},lookAt:(U=new We.Vector3,B=new We.Vector3,k=new We.Vector3,function(t,e,r){var i=this.elements;return k.subVectors(t,e).normalize(),0===k.length()&&(k.z=1),U.crossVectors(r,k).normalize(),0===U.length()&&(k.x+=1e-4,U.crossVectors(r,k).normalize()),B.crossVectors(k,U),i[0]=U.x,i[4]=B.x,i[8]=k.x,i[1]=U.y,i[5]=B.y,i[9]=k.y,i[2]=U.z,i[6]=B.z,i[10]=k.z,this}),multiply:function(t,e){return void 0!==e?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(t,e)):this.multiplyMatrices(this,t)},multiplyMatrices:function(t,e){var r=t.elements,i=e.elements,n=this.elements,o=r[0],a=r[4],s=r[8],h=r[12],l=r[1],u=r[5],c=r[9],f=r[13],p=r[2],d=r[6],m=r[10],v=r[14],g=r[3],y=r[7],x=r[11],w=r[15],b=i[0],M=i[4],_=i[8],S=i[12],T=i[1],A=i[5],C=i[9],E=i[13],L=i[2],P=i[6],R=i[10],F=i[14],D=i[3],U=i[7],B=i[11],k=i[15];return n[0]=o*b+a*T+s*L+h*D,n[4]=o*M+a*A+s*P+h*U,n[8]=o*_+a*C+s*R+h*B,n[12]=o*S+a*E+s*F+h*k,n[1]=l*b+u*T+c*L+f*D,n[5]=l*M+u*A+c*P+f*U,n[9]=l*_+u*C+c*R+f*B,n[13]=l*S+u*E+c*F+f*k,n[2]=p*b+d*T+m*L+v*D,n[6]=p*M+d*A+m*P+v*U,n[10]=p*_+d*C+m*R+v*B,n[14]=p*S+d*E+m*F+v*k,n[3]=g*b+y*T+x*L+w*D,n[7]=g*M+y*A+x*P+w*U,n[11]=g*_+y*C+x*R+w*B,n[15]=g*S+y*E+x*F+w*k,this},multiplyToArray:function(t,e,r){var i=this.elements;return this.multiplyMatrices(t,e),r[0]=i[0],r[1]=i[1],r[2]=i[2],r[3]=i[3],r[4]=i[4],r[5]=i[5],r[6]=i[6],r[7]=i[7],r[8]=i[8],r[9]=i[9],r[10]=i[10],r[11]=i[11],r[12]=i[12],r[13]=i[13],r[14]=i[14],r[15]=i[15],this},multiplyScalar:function(t){var e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this},multiplyVector3:function(t){return console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead."),t.applyProjection(this)},multiplyVector4:function(t){return console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},multiplyVector3Array:function(t){return console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead."),this.applyToVector3Array(t)},applyToVector3Array:(D=new We.Vector3,function(t,e,r){void 0===e&&(e=0),void 0===r&&(r=t.length);for(var i=0,n=e;i<r;i+=3,n+=3)D.x=t[n],D.y=t[n+1],D.z=t[n+2],D.applyMatrix4(this),t[n]=D.x,t[n+1]=D.y,t[n+2]=D.z;return t}),rotateAxis:function(t){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."),t.transformDirection(this)},crossVector:function(t){return console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."),t.applyMatrix4(this)},determinant:function(){var t=this.elements,e=t[0],r=t[4],i=t[8],n=t[12],o=t[1],a=t[5],s=t[9],h=t[13],l=t[2],u=t[6],c=t[10],f=t[14];return t[3]*(+n*s*u-i*h*u-n*a*c+r*h*c+i*a*f-r*s*f)+t[7]*(+e*s*f-e*h*c+n*o*c-i*o*f+i*h*l-n*s*l)+t[11]*(+e*h*u-e*a*f-n*o*u+r*o*f+n*a*l-r*h*l)+t[15]*(-i*a*l-e*s*u+e*a*c+i*o*u-r*o*c+r*s*l)},transpose:function(){var t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this},flattenToArrayOffset:function(t,e){var r=this.elements;return t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[15],t},getPosition:(F=new We.Vector3,function(){console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");var t=this.elements;return F.set(t[12],t[13],t[14])}),setPosition:function(t){var e=this.elements;return e[12]=t.x,e[13]=t.y,e[14]=t.z,this},getInverse:function(t,e){var r=this.elements,i=t.elements,n=i[0],o=i[4],a=i[8],s=i[12],h=i[1],l=i[5],u=i[9],c=i[13],f=i[2],p=i[6],d=i[10],m=i[14],v=i[3],g=i[7],y=i[11],x=i[15];r[0]=u*m*g-c*d*g+c*p*y-l*m*y-u*p*x+l*d*x,r[4]=s*d*g-a*m*g-s*p*y+o*m*y+a*p*x-o*d*x,r[8]=a*c*g-s*u*g+s*l*y-o*c*y-a*l*x+o*u*x,r[12]=s*u*p-a*c*p-s*l*d+o*c*d+a*l*m-o*u*m,r[1]=c*d*v-u*m*v-c*f*y+h*m*y+u*f*x-h*d*x,r[5]=a*m*v-s*d*v+s*f*y-n*m*y-a*f*x+n*d*x,r[9]=s*u*v-a*c*v-s*h*y+n*c*y+a*h*x-n*u*x,r[13]=a*c*f-s*u*f+s*h*d-n*c*d-a*h*m+n*u*m,r[2]=l*m*v-c*p*v+c*f*g-h*m*g-l*f*x+h*p*x,r[6]=s*p*v-o*m*v-s*f*g+n*m*g+o*f*x-n*p*x,r[10]=o*c*v-s*l*v+s*h*g-n*c*g-o*h*x+n*l*x,r[14]=s*l*f-o*c*f-s*h*p+n*c*p+o*h*m-n*l*m,r[3]=u*p*v-l*d*v-u*f*g+h*d*g+l*f*y-h*p*y,r[7]=o*d*v-a*p*v+a*f*g-n*d*g-o*f*y+n*p*y,r[11]=a*l*v-o*u*v-a*h*g+n*u*g+o*h*y-n*l*y,r[15]=o*u*f-a*l*f+a*h*p-n*u*p-o*h*d+n*l*d;var w=n*r[0]+h*r[4]+f*r[8]+v*r[12];if(0==w){var b="Matrix4.getInverse(): can't invert matrix, determinant is 0";if(e)throw new Error(b);return console.warn(b),this.identity(),this}return this.multiplyScalar(1/w),this},translate:function(t){console.warn("THREE.Matrix4: .translate() has been removed.")},rotateX:function(t){console.warn("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(t){console.warn("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(t){console.warn("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(t,e){console.warn("THREE.Matrix4: .rotateByAxis() has been removed.")},scale:function(t){var e=this.elements,r=t.x,i=t.y,n=t.z;return e[0]*=r,e[4]*=i,e[8]*=n,e[1]*=r,e[5]*=i,e[9]*=n,e[2]*=r,e[6]*=i,e[10]*=n,e[3]*=r,e[7]*=i,e[11]*=n,this},getMaxScaleOnAxis:function(){var t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],r=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,Math.max(r,i)))},makeTranslation:function(t,e,r){return this.set(1,0,0,t,0,1,0,e,0,0,1,r,0,0,0,1),this},makeRotationX:function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,-r,0,0,r,e,0,0,0,0,1),this},makeRotationY:function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(e,0,r,0,0,1,0,0,-r,0,e,0,0,0,0,1),this},makeRotationZ:function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(e,-r,0,0,r,e,0,0,0,0,1,0,0,0,0,1),this},makeRotationAxis:function(t,e){var r=Math.cos(e),i=Math.sin(e),n=1-r,o=t.x,a=t.y,s=t.z,h=n*o,l=n*a;return this.set(h*o+r,h*a-i*s,h*s+i*a,0,h*a+i*s,l*a+r,l*s-i*o,0,h*s-i*a,l*s+i*o,n*s*s+r,0,0,0,0,1),this},makeScale:function(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1),this},compose:function(t,e,r){return this.makeRotationFromQuaternion(e),this.scale(r),this.setPosition(t),this},decompose:(P=new We.Vector3,R=new We.Matrix4,function(t,e,r){var i=this.elements,n=P.set(i[0],i[1],i[2]).length(),o=P.set(i[4],i[5],i[6]).length(),a=P.set(i[8],i[9],i[10]).length();this.determinant()<0&&(n=-n),t.x=i[12],t.y=i[13],t.z=i[14],R.elements.set(this.elements);var s=1/n,h=1/o,l=1/a;return R.elements[0]*=s,R.elements[1]*=s,R.elements[2]*=s,R.elements[4]*=h,R.elements[5]*=h,R.elements[6]*=h,R.elements[8]*=l,R.elements[9]*=l,R.elements[10]*=l,e.setFromRotationMatrix(R),r.x=n,r.y=o,r.z=a,this}),makeFrustum:function(t,e,r,i,n,o){var a=this.elements,s=2*n/(e-t),h=2*n/(i-r),l=(e+t)/(e-t),u=(i+r)/(i-r),c=-(o+n)/(o-n),f=-2*o*n/(o-n);return a[0]=s,a[4]=0,a[8]=l,a[12]=0,a[1]=0,a[5]=h,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=c,a[14]=f,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this},makePerspective:function(t,e,r,i){var n=r*Math.tan(We.Math.degToRad(.5*t)),o=-n,a=o*e,s=n*e;return this.makeFrustum(a,s,o,n,r,i)},makeOrthographic:function(t,e,r,i,n,o){var a=this.elements,s=e-t,h=r-i,l=o-n,u=(e+t)/s,c=(r+i)/h,f=(o+n)/l;return a[0]=2/s,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2/h,a[9]=0,a[13]=-c,a[2]=0,a[6]=0,a[10]=-2/l,a[14]=-f,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this},fromArray:function(t){return this.elements.set(t),this},toArray:function(){var t=this.elements;return[t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]]},clone:function(){return(new We.Matrix4).fromArray(this.elements)}},We.Ray=function(t,e){this.origin=void 0!==t?t:new We.Vector3,this.direction=void 0!==e?e:new We.Vector3},We.Ray.prototype={constructor:We.Ray,set:function(t,e){return this.origin.copy(t),this.direction.copy(e),this},copy:function(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this},at:function(t,e){return(e||new We.Vector3).copy(this.direction).multiplyScalar(t).add(this.origin)},recast:(j=new We.Vector3,function(t){return this.origin.copy(this.at(t,j)),this}),closestPointToPoint:function(t,e){var r=e||new We.Vector3;r.subVectors(t,this.origin);var i=r.dot(this.direction);return i<0?r.copy(this.origin):r.copy(this.direction).multiplyScalar(i).add(this.origin)},distanceToPoint:(W=new We.Vector3,function(t){var e=W.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceTo(t):(W.copy(this.direction).multiplyScalar(e).add(this.origin),W.distanceTo(t))}),distanceSqToSegment:function(t,e,r,i){var n,o,a,s,h=t.clone().add(e).multiplyScalar(.5),l=e.clone().sub(t).normalize(),u=.5*t.distanceTo(e),c=this.origin.clone().sub(h),f=-this.direction.dot(l),p=c.dot(this.direction),d=-c.dot(l),m=c.lengthSq(),v=Math.abs(1-f*f);if(0<=v)if(o=f*p-d,s=u*v,0<=(n=f*d-p))if(-s<=o)if(o<=s){var g=1/v;a=(n*=g)*(n+f*(o*=g)+2*p)+o*(f*n+o+2*d)+m}else o=u,a=-(n=Math.max(0,-(f*o+p)))*n+o*(o+2*d)+m;else o=-u,a=-(n=Math.max(0,-(f*o+p)))*n+o*(o+2*d)+m;else o<=-s?a=-(n=Math.max(0,-(-f*u+p)))*n+(o=0<n?-u:Math.min(Math.max(-u,-d),u))*(o+2*d)+m:o<=s?(n=0,a=(o=Math.min(Math.max(-u,-d),u))*(o+2*d)+m):a=-(n=Math.max(0,-(f*u+p)))*n+(o=0<n?u:Math.min(Math.max(-u,-d),u))*(o+2*d)+m;else o=0<f?-u:u,a=-(n=Math.max(0,-(f*o+p)))*n+o*(o+2*d)+m;return r&&r.copy(this.direction.clone().multiplyScalar(n).add(this.origin)),i&&i.copy(l.clone().multiplyScalar(o).add(h)),a},isIntersectionSphere:function(t){return this.distanceToPoint(t.center)<=t.radius},intersectSphere:(H=new We.Vector3,function(t,e){H.subVectors(t.center,this.origin);var r=H.dot(this.direction),i=H.dot(H)-r*r,n=t.radius*t.radius;if(n<i)return null;var o=Math.sqrt(n-i),a=r-o,s=r+o;return a<0&&s<0?null:a<0?this.at(s,e):this.at(a,e)}),isIntersectionPlane:function(t){var e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0},distanceToPlane:function(t){var e=t.normal.dot(this.direction);if(0==e)return 0==t.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(t.normal)+t.constant)/e;return 0<=r?r:null},intersectPlane:function(t,e){var r=this.distanceToPlane(t);return null===r?null:this.at(r,e)},isIntersectionBox:(G=new We.Vector3,function(t){return null!==this.intersectBox(t,G)}),intersectBox:function(t,e){var r,i,n,o,a,s,h=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,c=this.origin;return 0<=h?(r=(t.min.x-c.x)*h,i=(t.max.x-c.x)*h):(r=(t.max.x-c.x)*h,i=(t.min.x-c.x)*h),0<=l?(n=(t.min.y-c.y)*l,o=(t.max.y-c.y)*l):(n=(t.max.y-c.y)*l,o=(t.min.y-c.y)*l),o<r||i<n?null:((r<n||r!=r)&&(r=n),(o<i||i!=i)&&(i=o),0<=u?(a=(t.min.z-c.z)*u,s=(t.max.z-c.z)*u):(a=(t.max.z-c.z)*u,s=(t.min.z-c.z)*u),s<r||i<a?null:((r<a||r!=r)&&(r=a),(s<i||i!=i)&&(i=s),i<0?null:this.at(0<=r?r:i,e)))},intersectTriangle:(V=new We.Vector3,N=new We.Vector3,O=new We.Vector3,I=new We.Vector3,function(t,e,r,i,n){N.subVectors(e,t),O.subVectors(r,t),I.crossVectors(N,O);var o,a=this.direction.dot(I);if(0<a){if(i)return null;o=1}else{if(!(a<0))return null;o=-1,a=-a}V.subVectors(this.origin,t);var s=o*this.direction.dot(O.crossVectors(V,O));if(s<0)return null;var h=o*this.direction.dot(N.cross(V));if(h<0)return null;if(a<s+h)return null;var l=-o*V.dot(I);return l<0?null:this.at(l/a,n)}),applyMatrix4:function(t){return this.direction.add(this.origin).applyMatrix4(t),this.origin.applyMatrix4(t),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)},clone:function(){return(new We.Ray).copy(this)}},We.Sphere=function(t,e){this.center=void 0!==t?t:new We.Vector3,this.radius=void 0!==e?e:0},We.Sphere.prototype={constructor:We.Sphere,set:function(t,e){return this.center.copy(t),this.radius=e,this},setFromPoints:(X=new We.Box3,function(t,e){var r=this.center;void 0!==e?r.copy(e):X.setFromPoints(t).center(r);for(var i=0,n=0,o=t.length;n<o;n++)i=Math.max(i,r.distanceToSquared(t[n]));return this.radius=Math.sqrt(i),this}),copy:function(t){return this.center.copy(t.center),this.radius=t.radius,this},empty:function(){return this.radius<=0},containsPoint:function(t){return t.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(t){return t.distanceTo(this.center)-this.radius},intersectsSphere:function(t){var e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e},clampPoint:function(t,e){var r=this.center.distanceToSquared(t),i=e||new We.Vector3;return i.copy(t),r>this.radius*this.radius&&(i.sub(this.center).normalize(),i.multiplyScalar(this.radius).add(this.center)),i},getBoundingBox:function(t){var e=t||new We.Box3;return e.set(this.center,this.center),e.expandByScalar(this.radius),e},applyMatrix4:function(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this},translate:function(t){return this.center.add(t),this},equals:function(t){return t.center.equals(this.center)&&t.radius===this.radius},clone:function(){return(new We.Sphere).copy(this)}},We.Frustum=function(t,e,r,i,n,o){this.planes=[void 0!==t?t:new We.Plane,void 0!==e?e:new We.Plane,void 0!==r?r:new We.Plane,void 0!==i?i:new We.Plane,void 0!==n?n:new We.Plane,void 0!==o?o:new We.Plane]},We.Frustum.prototype={constructor:We.Frustum,set:function(t,e,r,i,n,o){var a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(r),a[3].copy(i),a[4].copy(n),a[5].copy(o),this},copy:function(t){for(var e=this.planes,r=0;r<6;r++)e[r].copy(t.planes[r]);return this},setFromMatrix:function(t){var e=this.planes,r=t.elements,i=r[0],n=r[1],o=r[2],a=r[3],s=r[4],h=r[5],l=r[6],u=r[7],c=r[8],f=r[9],p=r[10],d=r[11],m=r[12],v=r[13],g=r[14],y=r[15];return e[0].setComponents(a-i,u-s,d-c,y-m).normalize(),e[1].setComponents(a+i,u+s,d+c,y+m).normalize(),e[2].setComponents(a+n,u+h,d+f,y+v).normalize(),e[3].setComponents(a-n,u-h,d-f,y-v).normalize(),e[4].setComponents(a-o,u-l,d-p,y-g).normalize(),e[5].setComponents(a+o,u+l,d+p,y+g).normalize(),this},intersectsObject:(K=new We.Sphere,function(t){var e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),K.copy(e.boundingSphere),K.applyMatrix4(t.matrixWorld),this.intersectsSphere(K)}),intersectsSphere:function(t){for(var e=this.planes,r=t.center,i=-t.radius,n=0;n<6;n++){if(e[n].distanceToPoint(r)<i)return!1}return!0},intersectsBox:(q=new We.Vector3,Y=new We.Vector3,function(t){for(var e=this.planes,r=0;r<6;r++){var i=e[r];q.x=0<i.normal.x?t.min.x:t.max.x,Y.x=0<i.normal.x?t.max.x:t.min.x,q.y=0<i.normal.y?t.min.y:t.max.y,Y.y=0<i.normal.y?t.max.y:t.min.y,q.z=0<i.normal.z?t.min.z:t.max.z,Y.z=0<i.normal.z?t.max.z:t.min.z;var n=i.distanceToPoint(q),o=i.distanceToPoint(Y);if(n<0&&o<0)return!1}return!0}),containsPoint:function(t){for(var e=this.planes,r=0;r<6;r++)if(e[r].distanceToPoint(t)<0)return!1;return!0},clone:function(){return(new We.Frustum).copy(this)}},We.Plane=function(t,e){this.normal=void 0!==t?t:new We.Vector3(1,0,0),this.constant=void 0!==e?e:0},We.Plane.prototype={constructor:We.Plane,set:function(t,e){return this.normal.copy(t),this.constant=e,this},setComponents:function(t,e,r,i){return this.normal.set(t,e,r),this.constant=i,this},setFromNormalAndCoplanarPoint:function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},setFromCoplanarPoints:(tt=new We.Vector3,et=new We.Vector3,function(t,e,r){var i=tt.subVectors(r,e).cross(et.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}),copy:function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},normalize:function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},negate:function(){return this.constant*=-1,this.normal.negate(),this},distanceToPoint:function(t){return this.normal.dot(t)+this.constant},distanceToSphere:function(t){return this.distanceToPoint(t.center)-t.radius},projectPoint:function(t,e){return this.orthoPoint(t,e).sub(t).negate()},orthoPoint:function(t,e){var r=this.distanceToPoint(t);return(e||new We.Vector3).copy(this.normal).multiplyScalar(r)},isIntersectionLine:function(t){var e=this.distanceToPoint(t.start),r=this.distanceToPoint(t.end);return e<0&&0<r||r<0&&0<e},intersectLine:($=new We.Vector3,function(t,e){var r=e||new We.Vector3,i=t.delta($),n=this.normal.dot(i);if(0==n)return 0==this.distanceToPoint(t.start)?r.copy(t.start):void 0;var o=-(t.start.dot(this.normal)+this.constant)/n;return o<0||1<o?void 0:r.copy(i).multiplyScalar(o).add(t.start)}),coplanarPoint:function(t){return(t||new We.Vector3).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:(Z=new We.Vector3,Q=new We.Vector3,J=new We.Matrix3,function(t,e){var r=e||J.getNormalMatrix(t),i=Z.copy(this.normal).applyMatrix3(r),n=this.coplanarPoint(Q);return n.applyMatrix4(t),this.setFromNormalAndCoplanarPoint(i,n),this}),translate:function(t){return this.constant=this.constant-t.dot(this.normal),this},equals:function(t){return t.normal.equals(this.normal)&&t.constant==this.constant},clone:function(){return(new We.Plane).copy(this)}},We.Math={generateUUID:(ot="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),at=new Array(36),st=0,function(){for(var t=0;t<36;t++)8==t||13==t||18==t||23==t?at[t]="-":14==t?at[t]="4":(st<=2&&(st=33554432+16777216*Math.random()|0),nt=15&st,st>>=4,at[t]=ot[19==t?3&nt|8:nt]);return at.join("")}),clamp:function(t,e,r){return t<e?e:r<t?r:t},clampBottom:function(t,e){return t<e?e:t},mapLinear:function(t,e,r,i,n){return i+(t-e)*(n-i)/(r-e)},smoothstep:function(t,e,r){return t<=e?0:r<=t?1:(t=(t-e)/(r-e))*t*(3-2*t)},smootherstep:function(t,e,r){return t<=e?0:r<=t?1:(t=(t-e)/(r-e))*t*t*(t*(6*t-15)+10)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},degToRad:(it=Math.PI/180,function(t){return t*it}),radToDeg:(rt=180/Math.PI,function(t){return t*rt}),isPowerOfTwo:function(t){return 0==(t&t-1)&&0!==t}},We.Spline=function(t){this.points=t;var e,r,i,n,o,a,s,h,l,u=[],c={x:0,y:0,z:0};function f(t,e,r,i,n,o,a){var s=.5*(r-t),h=.5*(i-e);return(2*(e-r)+s+h)*a+(-3*(e-r)-2*s-h)*o+s*n+e}this.initFromArray=function(t){this.points=[];for(var e=0;e<t.length;e++)this.points[e]={x:t[e][0],y:t[e][1],z:t[e][2]}},this.getPoint=function(t){return e=(this.points.length-1)*t,r=Math.floor(e),i=e-r,u[0]=0===r?r:r-1,u[1]=r,u[2]=r>this.points.length-2?this.points.length-1:r+1,u[3]=r>this.points.length-3?this.points.length-1:r+2,a=this.points[u[0]],s=this.points[u[1]],h=this.points[u[2]],l=this.points[u[3]],o=i*(n=i*i),c.x=f(a.x,s.x,h.x,l.x,i,n,o),c.y=f(a.y,s.y,h.y,l.y,i,n,o),c.z=f(a.z,s.z,h.z,l.z,i,n,o),c},this.getControlPointsArray=function(){var t,e,r=this.points.length,i=[];for(t=0;t<r;t++)e=this.points[t],i[t]=[e.x,e.y,e.z];return i},this.getLength=function(t){var e,r,i,n,o=0,a=0,s=0,h=new We.Vector3,l=new We.Vector3,u=[],c=0;for(u[0]=0,t||(t=100),i=this.points.length*t,h.copy(this.points[0]),e=1;e<i;e++)r=e/i,n=this.getPoint(r),l.copy(n),c+=l.distanceTo(h),h.copy(n),o=(this.points.length-1)*r,(a=Math.floor(o))!=s&&(u[a]=c,s=a);return u[u.length]=c,{chunks:u,total:c}},this.reparametrizeByArcLength=function(t){var e,r,i,n,o,a,s,h,l=[],u=new We.Vector3,c=this.getLength();for(l.push(u.copy(this.points[0]).clone()),e=1;e<this.points.length;e++){for(a=c.chunks[e]-c.chunks[e-1],s=Math.ceil(t*a/c.total),n=(e-1)/(this.points.length-1),o=e/(this.points.length-1),r=1;r<s-1;r++)i=n+r*(1/s)*(o-n),h=this.getPoint(i),l.push(u.copy(h).clone());l.push(u.copy(this.points[e]).clone())}this.points=l}},We.Triangle=function(t,e,r){this.a=void 0!==t?t:new We.Vector3,this.b=void 0!==e?e:new We.Vector3,this.c=void 0!==r?r:new We.Vector3},We.Triangle.normal=(ht=new We.Vector3,function(t,e,r,i){var n=i||new We.Vector3;n.subVectors(r,e),ht.subVectors(t,e),n.cross(ht);var o=n.lengthSq();return 0<o?n.multiplyScalar(1/Math.sqrt(o)):n.set(0,0,0)}),We.Triangle.barycoordFromPoint=(lt=new We.Vector3,ut=new We.Vector3,ct=new We.Vector3,function(t,e,r,i,n){lt.subVectors(i,e),ut.subVectors(r,e),ct.subVectors(t,e);var o=lt.dot(lt),a=lt.dot(ut),s=lt.dot(ct),h=ut.dot(ut),l=ut.dot(ct),u=o*h-a*a,c=n||new We.Vector3;if(0==u)return c.set(-2,-1,-1);var f=1/u,p=(h*s-a*l)*f,d=(o*l-a*s)*f;return c.set(1-p-d,d,p)}),We.Triangle.containsPoint=(ft=new We.Vector3,function(t,e,r,i){var n=We.Triangle.barycoordFromPoint(t,e,r,i,ft);return 0<=n.x&&0<=n.y&&n.x+n.y<=1}),We.Triangle.prototype={constructor:We.Triangle,set:function(t,e,r){return this.a.copy(t),this.b.copy(e),this.c.copy(r),this},setFromPointsAndIndices:function(t,e,r,i){return this.a.copy(t[e]),this.b.copy(t[r]),this.c.copy(t[i]),this},copy:function(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this},area:(pt=new We.Vector3,dt=new We.Vector3,function(){return pt.subVectors(this.c,this.b),dt.subVectors(this.a,this.b),.5*pt.cross(dt).length()}),midpoint:function(t){return(t||new We.Vector3).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(t){return We.Triangle.normal(this.a,this.b,this.c,t)},plane:function(t){return(t||new We.Plane).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(t,e){return We.Triangle.barycoordFromPoint(t,this.a,this.b,this.c,e)},containsPoint:function(t){return We.Triangle.containsPoint(t,this.a,this.b,this.c)},equals:function(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)},clone:function(){return(new We.Triangle).copy(this)}},We.Clock=function(t){this.autoStart=void 0===t||t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1},We.Clock.prototype={constructor:We.Clock,start:function(){this.startTime=void 0!==He.performance&&void 0!==He.performance.now?He.performance.now():Date.now(),this.oldTime=this.startTime,this.running=!0},stop:function(){this.getElapsedTime(),this.running=!1},getElapsedTime:function(){return this.getDelta(),this.elapsedTime},getDelta:function(){var t=0;if(this.autoStart&&!this.running&&this.start(),this.running){var e=void 0!==He.performance&&void 0!==He.performance.now?He.performance.now():Date.now();t=.001*(e-this.oldTime),this.oldTime=e,this.elapsedTime+=t}return t}},We.EventDispatcher=function(){},We.EventDispatcher.prototype={constructor:We.EventDispatcher,apply:function(t){t.addEventListener=We.EventDispatcher.prototype.addEventListener,t.hasEventListener=We.EventDispatcher.prototype.hasEventListener,t.removeEventListener=We.EventDispatcher.prototype.removeEventListener,t.dispatchEvent=We.EventDispatcher.prototype.dispatchEvent},addEventListener:function(t,e){void 0===this._listeners&&(this._listeners={});var r=this._listeners;void 0===r[t]&&(r[t]=[]),-1===r[t].indexOf(e)&&r[t].push(e)},hasEventListener:function(t,e){if(void 0===this._listeners)return!1;var r=this._listeners;return void 0!==r[t]&&-1!==r[t].indexOf(e)},removeEventListener:function(t,e){if(void 0!==this._listeners){var r=this._listeners[t];if(void 0!==r){var i=r.indexOf(e);-1!==i&&r.splice(i,1)}}},dispatchEvent:function(t){if(void 0!==this._listeners){var e=this._listeners[t.type];if(void 0!==e){t.target=this;for(var r=[],i=e.length,n=0;n<i;n++)r[n]=e[n];for(n=0;n<i;n++)r[n].call(this,t)}}}},function(n){n.Raycaster=function(t,e,r,i){this.ray=new n.Ray(t,e),this.near=r||0,this.far=i||1/0,this.params={Sprite:{},Mesh:{},PointCloud:{threshold:1},LOD:{},Line:{}}};var o=function(t,e){return t.distance-e.distance},s=function(t,e,r,i){if(t.raycast(e,r),!0===i)for(var n=t.children,o=0,a=n.length;o<a;o++)s(n[o],e,r,!0)};n.Raycaster.prototype={constructor:n.Raycaster,precision:1e-4,linePrecision:1,set:function(t,e){this.ray.set(t,e)},intersectObject:function(t,e){var r=[];return s(t,this,r,e),r.sort(o),r},intersectObjects:function(t,e){var r=[];if(t instanceof Array==!1)return console.log("THREE.Raycaster.intersectObjects: objects is not an Array."),r;for(var i=0,n=t.length;i<n;i++)s(t[i],this,r,e);return r.sort(o),r}}}(We),We.Object3D=function(){Object.defineProperty(this,"id",{value:We.Object3DIdCount++}),this.uuid=We.Math.generateUUID(),this.name="",this.type="Object3D",this.parent=void 0,this.children=[],this.up=We.Object3D.DefaultUp.clone();var t=new We.Vector3,e=new We.Euler,r=new We.Quaternion,i=new We.Vector3(1,1,1);e.onChange(function(){r.setFromEuler(e,!1)}),r.onChange(function(){e.setFromQuaternion(r,void 0,!1)}),Object.defineProperties(this,{position:{enumerable:!0,value:t},rotation:{enumerable:!0,value:e},quaternion:{enumerable:!0,value:r},scale:{enumerable:!0,value:i}}),this.renderDepth=null,this.rotationAutoUpdate=!0,this.matrix=new We.Matrix4,this.matrixWorld=new We.Matrix4,this.matrixAutoUpdate=!0,this.matrixWorldNeedsUpdate=!1,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.userData={}},We.Object3D.DefaultUp=new We.Vector3(0,1,0),We.Object3D.prototype={constructor:We.Object3D,get eulerOrder(){return console.warn("THREE.Object3D: .eulerOrder has been moved to .rotation.order."),this.rotation.order},set eulerOrder(t){console.warn("THREE.Object3D: .eulerOrder has been moved to .rotation.order."),this.rotation.order=t},get useQuaternion(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set useQuaternion(t){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},applyMatrix:function(t){this.matrix.multiplyMatrices(t,this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(t,e){this.quaternion.setFromAxisAngle(t,e)},setRotationFromEuler:function(t){this.quaternion.setFromEuler(t,!0)},setRotationFromMatrix:function(t){this.quaternion.setFromRotationMatrix(t)},setRotationFromQuaternion:function(t){this.quaternion.copy(t)},rotateOnAxis:(Pt=new We.Quaternion,function(t,e){return Pt.setFromAxisAngle(t,e),this.quaternion.multiply(Pt),this}),rotateX:(Lt=new We.Vector3(1,0,0),function(t){return this.rotateOnAxis(Lt,t)}),rotateY:(Et=new We.Vector3(0,1,0),function(t){return this.rotateOnAxis(Et,t)}),rotateZ:(Ct=new We.Vector3(0,0,1),function(t){return this.rotateOnAxis(Ct,t)}),translateOnAxis:(At=new We.Vector3,function(t,e){return At.copy(t).applyQuaternion(this.quaternion),this.position.add(At.multiplyScalar(e)),this}),translate:function(t,e){return console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead."),this.translateOnAxis(e,t)},translateX:(Tt=new We.Vector3(1,0,0),function(t){return this.translateOnAxis(Tt,t)}),translateY:(St=new We.Vector3(0,1,0),function(t){return this.translateOnAxis(St,t)}),translateZ:(_t=new We.Vector3(0,0,1),function(t){return this.translateOnAxis(_t,t)}),localToWorld:function(t){return t.applyMatrix4(this.matrixWorld)},worldToLocal:(Mt=new We.Matrix4,function(t){return t.applyMatrix4(Mt.getInverse(this.matrixWorld))}),lookAt:(bt=new We.Matrix4,function(t){bt.lookAt(t,this.position,this.up),this.quaternion.setFromRotationMatrix(bt)}),add:function(t){if(1<arguments.length){for(var e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?console.error("THREE.Object3D.add:",t,"can't be added as a child of itself."):t instanceof We.Object3D?(void 0!==t.parent&&t.parent.remove(t),t.parent=this,t.dispatchEvent({type:"added"}),this.children.push(t)):console.error("THREE.Object3D.add:",t,"is not an instance of THREE.Object3D."),this},remove:function(t){if(1<arguments.length)for(var e=0;e<arguments.length;e++)this.remove(arguments[e]);var r=this.children.indexOf(t);-1!==r&&(t.parent=void 0,t.dispatchEvent({type:"removed"}),this.children.splice(r,1))},getChildByName:function(t,e){return console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName()."),this.getObjectByName(t,e)},getObjectById:function(t,e){if(this.id===t)return this;for(var r=0,i=this.children.length;r<i;r++){var n=this.children[r].getObjectById(t,e);if(void 0!==n)return n}},getObjectByName:function(t,e){if(this.name===t)return this;for(var r=0,i=this.children.length;r<i;r++){var n=this.children[r].getObjectByName(t,e);if(void 0!==n)return n}},getWorldPosition:function(t){var e=t||new We.Vector3;return this.updateMatrixWorld(!0),e.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:(xt=new We.Vector3,wt=new We.Vector3,function(t){var e=t||new We.Quaternion;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(xt,e,wt),e}),getWorldRotation:(yt=new We.Quaternion,function(t){var e=t||new We.Euler;return this.getWorldQuaternion(yt),e.setFromQuaternion(yt,this.rotation.order,!1)}),getWorldScale:(vt=new We.Vector3,gt=new We.Quaternion,function(t){var e=t||new We.Vector3;return this.updateMatrixWorld(!0),this.matrixWorld.decompose(vt,gt,e),e}),getWorldDirection:(mt=new We.Quaternion,function(t){var e=t||new We.Vector3;return this.getWorldQuaternion(mt),e.set(0,0,1).applyQuaternion(mt)}),raycast:function(){},traverse:function(t){t(this);for(var e=0,r=this.children.length;e<r;e++)this.children[e].traverse(t)},traverseVisible:function(t){if(!1!==this.visible){t(this);for(var e=0,r=this.children.length;e<r;e++)this.children[e].traverseVisible(t)}},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(t){!0===this.matrixAutoUpdate&&this.updateMatrix(),!0!==this.matrixWorldNeedsUpdate&&!0!==t||(void 0===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),t=!(this.matrixWorldNeedsUpdate=!1));for(var e=0,r=this.children.length;e<r;e++)this.children[e].updateMatrixWorld(t)},toJSON:function(){var r={metadata:{version:4.3,type:"Object",generator:"ObjectExporter"}},i={},n=function(t){if(void 0===r.geometries&&(r.geometries=[]),void 0===i[t.uuid]){var e=t.toJSON();delete e.metadata,i[t.uuid]=e,r.geometries.push(e)}return t.uuid},o={},a=function(t){if(void 0===r.materials&&(r.materials=[]),void 0===o[t.uuid]){var e=t.toJSON();delete e.metadata,o[t.uuid]=e,r.materials.push(e)}return t.uuid},s=function(t){var e={};if(e.uuid=t.uuid,e.type=t.type,""!==t.name&&(e.name=t.name),"{}"!==JSON.stringify(t.userData)&&(e.userData=t.userData),!0!==t.visible&&(e.visible=t.visible),t instanceof We.PerspectiveCamera?(e.fov=t.fov,e.aspect=t.aspect,e.near=t.near,e.far=t.far):t instanceof We.OrthographicCamera?(e.left=t.left,e.right=t.right,e.top=t.top,e.bottom=t.bottom,e.near=t.near,e.far=t.far):t instanceof We.AmbientLight?e.color=t.color.getHex():t instanceof We.DirectionalLight?(e.color=t.color.getHex(),e.intensity=t.intensity):t instanceof We.PointLight?(e.color=t.color.getHex(),e.intensity=t.intensity,e.distance=t.distance):t instanceof We.SpotLight?(e.color=t.color.getHex(),e.intensity=t.intensity,e.distance=t.distance,e.angle=t.angle,e.exponent=t.exponent):t instanceof We.HemisphereLight?(e.color=t.color.getHex(),e.groundColor=t.groundColor.getHex()):t instanceof We.Mesh?(e.geometry=n(t.geometry),e.material=a(t.material)):t instanceof We.Line?(e.geometry=n(t.geometry),e.material=a(t.material)):t instanceof We.Sprite&&(e.material=a(t.material)),e.matrix=t.matrix.toArray(),0<t.children.length){e.children=[];for(var r=0;r<t.children.length;r++)e.children.push(s(t.children[r]))}return e};return r.object=s(this),r},clone:function(t,e){if(void 0===t&&(t=new We.Object3D),void 0===e&&(e=!0),t.name=this.name,t.up.copy(this.up),t.position.copy(this.position),t.quaternion.copy(this.quaternion),t.scale.copy(this.scale),t.renderDepth=this.renderDepth,t.rotationAutoUpdate=this.rotationAutoUpdate,t.matrix.copy(this.matrix),t.matrixWorld.copy(this.matrixWorld),t.matrixAutoUpdate=this.matrixAutoUpdate,t.matrixWorldNeedsUpdate=this.matrixWorldNeedsUpdate,t.visible=this.visible,t.castShadow=this.castShadow,t.receiveShadow=this.receiveShadow,t.frustumCulled=this.frustumCulled,t.userData=JSON.parse(JSON.stringify(this.userData)),!0===e)for(var r=0;r<this.children.length;r++){var i=this.children[r];t.add(i.clone())}return t}},We.EventDispatcher.prototype.apply(We.Object3D.prototype),We.Object3DIdCount=0,We.Projector=function(){console.warn("THREE.Projector has been moved to /examples/renderers/Projector.js."),this.projectVector=function(t,e){console.warn("THREE.Projector: .projectVector() is now vector.project()."),t.project(e)},this.unprojectVector=function(t,e){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject()."),t.unproject(e)},this.pickingRay=function(t,e){console.error("THREE.Projector: .pickingRay() has been removed.")}},We.Face3=function(t,e,r,i,n,o){this.a=t,this.b=e,this.c=r,this.normal=i instanceof We.Vector3?i:new We.Vector3,this.vertexNormals=i instanceof Array?i:[],this.color=n instanceof We.Color?n:new We.Color,this.vertexColors=n instanceof Array?n:[],this.vertexTangents=[],this.materialIndex=void 0!==o?o:0},We.Face3.prototype={constructor:We.Face3,clone:function(){var t=new We.Face3(this.a,this.b,this.c);t.normal.copy(this.normal),t.color.copy(this.color),t.materialIndex=this.materialIndex;for(var e=0,r=this.vertexNormals.length;e<r;e++)t.vertexNormals[e]=this.vertexNormals[e].clone();for(e=0,r=this.vertexColors.length;e<r;e++)t.vertexColors[e]=this.vertexColors[e].clone();for(e=0,r=this.vertexTangents.length;e<r;e++)t.vertexTangents[e]=this.vertexTangents[e].clone();return t}},We.Face4=function(t,e,r,i,n,o,a){return console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead."),new We.Face3(t,e,r,n,o,a)},We.BufferAttribute=function(t,e){this.array=t,this.itemSize=e,this.needsUpdate=!1},We.BufferAttribute.prototype={constructor:We.BufferAttribute,get length(){return this.array.length},copyAt:function(t,e,r){t*=this.itemSize,r*=e.itemSize;for(var i=0,n=this.itemSize;i<n;i++)this.array[t+i]=e.array[r+i]},set:function(t){return this.array.set(t),this},setX:function(t,e){return this.array[t*this.itemSize]=e,this},setY:function(t,e){return this.array[t*this.itemSize+1]=e,this},setZ:function(t,e){return this.array[t*this.itemSize+2]=e,this},setXY:function(t,e,r){return t*=this.itemSize,this.array[t]=e,this.array[t+1]=r,this},setXYZ:function(t,e,r,i){return t*=this.itemSize,this.array[t]=e,this.array[t+1]=r,this.array[t+2]=i,this},setXYZW:function(t,e,r,i,n){return t*=this.itemSize,this.array[t]=e,this.array[t+1]=r,this.array[t+2]=i,this.array[t+3]=n,this},clone:function(){return new We.BufferAttribute(new this.array.constructor(this.array),this.itemSize)}},We.Int8Attribute=function(t,e){return console.warn("THREE.Int8Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new We.BufferAttribute(t,e)},We.Uint8Attribute=function(t,e){return console.warn("THREE.Uint8Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new We.BufferAttribute(t,e)},We.Uint8ClampedAttribute=function(t,e){return console.warn("THREE.Uint8ClampedAttribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new We.BufferAttribute(t,e)},We.Int16Attribute=function(t,e){return console.warn("THREE.Int16Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new We.BufferAttribute(t,e)},We.Uint16Attribute=function(t,e){return console.warn("THREE.Uint16Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new We.BufferAttribute(t,e)},We.Int32Attribute=function(t,e){return console.warn("THREE.Int32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new We.BufferAttribute(t,e)},We.Uint32Attribute=function(t,e){return console.warn("THREE.Uint32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new We.BufferAttribute(t,e)},We.Float32Attribute=function(t,e){return console.warn("THREE.Float32Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new We.BufferAttribute(t,e)},We.Float64Attribute=function(t,e){return console.warn("THREE.Float64Attribute has been removed. Use THREE.BufferAttribute( array, itemSize ) instead."),new We.BufferAttribute(t,e)},We.BufferGeometry=function(){Object.defineProperty(this,"id",{value:We.GeometryIdCount++}),this.uuid=We.Math.generateUUID(),this.name="",this.type="BufferGeometry",this.attributes={},this.attributesKeys=[],this.drawcalls=[],this.offsets=this.drawcalls,this.boundingBox=null,this.boundingSphere=null},We.BufferGeometry.prototype={constructor:We.BufferGeometry,addAttribute:function(t,e){if(e instanceof We.BufferAttribute==!1)return console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),void(this.attributes[t]={array:e,itemSize:arguments[2]});this.attributes[t]=e,this.attributesKeys=Object.keys(this.attributes)},getAttribute:function(t){return this.attributes[t]},addDrawCall:function(t,e,r){this.drawcalls.push({start:t,count:e,index:void 0!==r?r:0})},applyMatrix:function(t){var e=this.attributes.position;void 0!==e&&(t.applyToVector3Array(e.array),e.needsUpdate=!0);var r=this.attributes.normal;void 0!==r&&((new We.Matrix3).getNormalMatrix(t).applyToVector3Array(r.array),r.needsUpdate=!0)},center:function(){},fromGeometry:function(t,e){e=e||{vertexColors:We.NoColors};var r=t.vertices,i=t.faces,n=t.faceVertexUvs,o=e.vertexColors,a=0<n[0].length,s=3==i[0].vertexNormals.length,h=new Float32Array(3*i.length*3);this.addAttribute("position",new We.BufferAttribute(h,3));var l=new Float32Array(3*i.length*3);if(this.addAttribute("normal",new We.BufferAttribute(l,3)),o!==We.NoColors){var u=new Float32Array(3*i.length*3);this.addAttribute("color",new We.BufferAttribute(u,3))}if(!0===a){var c=new Float32Array(3*i.length*2);this.addAttribute("uv",new We.BufferAttribute(c,2))}for(var f=0,p=0,d=0;f<i.length;f++,p+=6,d+=9){var m=i[f],v=r[m.a],g=r[m.b],y=r[m.c];if(h[d]=v.x,h[d+1]=v.y,h[d+2]=v.z,h[d+3]=g.x,h[d+4]=g.y,h[d+5]=g.z,h[d+6]=y.x,h[d+7]=y.y,h[d+8]=y.z,!0===s){var x=m.vertexNormals[0],w=m.vertexNormals[1],b=m.vertexNormals[2];l[d]=x.x,l[d+1]=x.y,l[d+2]=x.z,l[d+3]=w.x,l[d+4]=w.y,l[d+5]=w.z,l[d+6]=b.x,l[d+7]=b.y,l[d+8]=b.z}else{var M=m.normal;l[d]=M.x,l[d+1]=M.y,l[d+2]=M.z,l[d+3]=M.x,l[d+4]=M.y,l[d+5]=M.z,l[d+6]=M.x,l[d+7]=M.y,l[d+8]=M.z}if(o===We.FaceColors){var _=m.color;u[d]=_.r,u[d+1]=_.g,u[d+2]=_.b,u[d+3]=_.r,u[d+4]=_.g,u[d+5]=_.b,u[d+6]=_.r,u[d+7]=_.g,u[d+8]=_.b}else if(o===We.VertexColors){var S=m.vertexColors[0],T=m.vertexColors[1],A=m.vertexColors[2];u[d]=S.r,u[d+1]=S.g,u[d+2]=S.b,u[d+3]=T.r,u[d+4]=T.g,u[d+5]=T.b,u[d+6]=A.r,u[d+7]=A.g,u[d+8]=A.b}if(!0===a){var C=n[0][f][0],E=n[0][f][1],L=n[0][f][2];c[p]=C.x,c[p+1]=C.y,c[p+2]=E.x,c[p+3]=E.y,c[p+4]=L.x,c[p+5]=L.y}}return this.computeBoundingSphere(),this},computeBoundingBox:(Dt=new We.Vector3,function(){null===this.boundingBox&&(this.boundingBox=new We.Box3);var t=this.attributes.position.array;if(t){var e=this.boundingBox;e.makeEmpty();for(var r=0,i=t.length;r<i;r+=3)Dt.set(t[r],t[r+1],t[r+2]),e.expandByPoint(Dt)}void 0!==t&&0!==t.length||(this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)),(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.')}),computeBoundingSphere:(Rt=new We.Box3,Ft=new We.Vector3,function(){null===this.boundingSphere&&(this.boundingSphere=new We.Sphere);var t=this.attributes.position.array;if(t){Rt.makeEmpty();for(var e=this.boundingSphere.center,r=0,i=t.length;r<i;r+=3)Ft.set(t[r],t[r+1],t[r+2]),Rt.expandByPoint(Ft);Rt.center(e);var n=0;for(r=0,i=t.length;r<i;r+=3)Ft.set(t[r],t[r+1],t[r+2]),n=Math.max(n,e.distanceToSquared(Ft));this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.')}}),computeFaceNormals:function(){},computeVertexNormals:function(){var t=this.attributes;if(t.position){var e=t.position.array;if(void 0===t.normal)this.addAttribute("normal",new We.BufferAttribute(new Float32Array(e.length),3));else for(var r=0,i=(s=t.normal.array).length;r<i;r++)s[r]=0;var n,o,a,s=t.normal.array,h=new We.Vector3,l=new We.Vector3,u=new We.Vector3,c=new We.Vector3,f=new We.Vector3;if(t.index)for(var p=t.index.array,d=0<this.offsets.length?this.offsets:[{start:0,count:p.length,index:0}],m=0,v=d.length;m<v;++m){var g=d[m].start,y=d[m].count,x=d[m].index;for(r=g,i=g+y;r<i;r+=3)n=3*(x+p[r]),o=3*(x+p[r+1]),a=3*(x+p[r+2]),h.fromArray(e,n),l.fromArray(e,o),u.fromArray(e,a),c.subVectors(u,l),f.subVectors(h,l),c.cross(f),s[n]+=c.x,s[n+1]+=c.y,s[n+2]+=c.z,s[o]+=c.x,s[o+1]+=c.y,s[o+2]+=c.z,s[a]+=c.x,s[a+1]+=c.y,s[a+2]+=c.z}else for(r=0,i=e.length;r<i;r+=9)h.fromArray(e,r),l.fromArray(e,r+3),u.fromArray(e,r+6),c.subVectors(u,l),f.subVectors(h,l),c.cross(f),s[r]=c.x,s[r+1]=c.y,s[r+2]=c.z,s[r+3]=c.x,s[r+4]=c.y,s[r+5]=c.z,s[r+6]=c.x,s[r+7]=c.y,s[r+8]=c.z;this.normalizeNormals(),t.normal.needsUpdate=!0}},computeTangents:function(){if(void 0!==this.attributes.index&&void 0!==this.attributes.position&&void 0!==this.attributes.normal&&void 0!==this.attributes.uv){var t=this.attributes.index.array,e=this.attributes.position.array,r=this.attributes.normal.array,i=this.attributes.uv.array,n=e.length/3;void 0===this.attributes.tangent&&this.addAttribute("tangent",new We.BufferAttribute(new Float32Array(4*n),4));for(var o=this.attributes.tangent.array,a=[],s=[],h=0;h<n;h++)a[h]=new We.Vector3,s[h]=new We.Vector3;var l,u,c,f,p,d,m,v,g,y,x,w,b,M,_,S,T,A,C=new We.Vector3,E=new We.Vector3,L=new We.Vector3,P=new We.Vector2,R=new We.Vector2,F=new We.Vector2,D=new We.Vector3,U=new We.Vector3;0===this.drawcalls.length&&this.addDrawCall(0,t.length,0);var B,k,z,V=this.drawcalls;for(M=0,_=V.length;M<_;++M){var N=V[M].start,O=V[M].count,I=V[M].index;for(b=(w=N)+O;w<b;w+=3)S=I+t[w],T=I+t[w+1],A=I+t[w+2],B=S,k=T,z=A,C.fromArray(e,3*B),E.fromArray(e,3*k),L.fromArray(e,3*z),P.fromArray(i,2*B),R.fromArray(i,2*k),F.fromArray(i,2*z),l=E.x-C.x,u=L.x-C.x,c=E.y-C.y,f=L.y-C.y,p=E.z-C.z,d=L.z-C.z,m=R.x-P.x,v=F.x-P.x,g=R.y-P.y,y=F.y-P.y,x=1/(m*y-v*g),D.set((y*l-g*u)*x,(y*c-g*f)*x,(y*p-g*d)*x),U.set((m*u-v*l)*x,(m*f-v*c)*x,(m*d-v*p)*x),a[B].add(D),a[k].add(D),a[z].add(D),s[B].add(U),s[k].add(U),s[z].add(U)}var G,H,W,j=new We.Vector3,X=new We.Vector3,q=new We.Vector3,Y=new We.Vector3;for(M=0,_=V.length;M<_;++M){N=V[M].start,O=V[M].count,I=V[M].index;for(b=(w=N)+O;w<b;w+=3)S=I+t[w],T=I+t[w+1],A=I+t[w+2],K(S),K(T),K(A)}}else console.warn("Missing required attributes (index, position, normal or uv) in BufferGeometry.computeTangents()");function K(t){q.fromArray(r,3*t),Y.copy(q),H=a[t],j.copy(H),j.sub(q.multiplyScalar(q.dot(H))).normalize(),X.crossVectors(Y,H),W=X.dot(s[t]),G=W<0?-1:1,o[4*t]=j.x,o[4*t+1]=j.y,o[4*t+2]=j.z,o[4*t+3]=G}},computeOffsets:function(t){var e=t;void 0===t&&(e=65535);Date.now();for(var r=this.attributes.index.array,i=this.attributes.position.array,n=(i.length,r.length/3),o=new Uint16Array(r.length),a=0,s=0,h=[{start:0,count:0,index:0}],l=h[0],u=0,c=new Int32Array(6),f=new Int32Array(i.length),p=new Int32Array(i.length),d=0;d<i.length;d++)f[d]=-1,p[d]=-1;for(var m=0;m<n;m++){for(var v=u=0;v<3;v++){-1==f[w=r[3*m+v]]?(c[2*v]=w,c[2*v+1]=-1,u++):f[w]<l.index?(c[2*v]=w,c[2*v+1]=-1,0):(c[2*v]=w,c[2*v+1]=f[w])}if(s+u>l.index+e){var g={start:a,count:0,index:s};h.push(g),l=g;for(var y=0;y<6;y+=2){-1<(x=c[y+1])&&x<l.index&&(c[y+1]=-1)}}for(y=0;y<6;y+=2){var x,w=c[y];-1===(x=c[y+1])&&(x=s++),p[f[w]=x]=w,o[a++]=x-l.index,l.count++}}return this.reorderBuffers(o,p,s),this.offsets=h},merge:function(){console.log("BufferGeometry.merge(): TODO")},normalizeNormals:function(){for(var t,e,r,i,n=this.attributes.normal.array,o=0,a=n.length;o<a;o+=3)t=n[o],e=n[o+1],r=n[o+2],i=1/Math.sqrt(t*t+e*e+r*r),n[o]*=i,n[o+1]*=i,n[o+2]*=i},reorderBuffers:function(t,e,r){var i={};for(var n in this.attributes)if("index"!=n){var o=this.attributes[n].array;i[n]=new o.constructor(this.attributes[n].itemSize*r)}for(var a=0;a<r;a++){var s=e[a];for(var n in this.attributes)if("index"!=n)for(var h=this.attributes[n].array,l=this.attributes[n].itemSize,u=i[n],c=0;c<l;c++)u[a*l+c]=h[s*l+c]}for(var n in this.attributes.index.array=t,this.attributes)"index"!=n&&(this.attributes[n].array=i[n],this.attributes[n].numItems=this.attributes[n].itemSize*r)},toJSON:function(){var t={metadata:{version:4,type:"BufferGeometry",generator:"BufferGeometryExporter"},uuid:this.uuid,type:this.type,data:{attributes:{}}},e=this.attributes,r=this.offsets,i=this.boundingSphere;for(var n in e){for(var o=e[n],a=[],s=o.array,h=0,l=s.length;h<l;h++)a[h]=s[h];t.data.attributes[n]={itemSize:o.itemSize,type:o.array.constructor.name,array:a}}return 0<r.length&&(t.data.offsets=JSON.parse(JSON.stringify(r))),null!==i&&(t.data.boundingSphere={center:i.center.toArray(),radius:i.radius}),t},clone:function(){var t=new We.BufferGeometry;for(var e in this.attributes){var r=this.attributes[e];t.addAttribute(e,r.clone())}for(var i=0,n=this.offsets.length;i<n;i++){var o=this.offsets[i];t.offsets.push({start:o.start,index:o.index,count:o.count})}return t},dispose:function(){this.dispatchEvent({type:"dispose"})}},We.EventDispatcher.prototype.apply(We.BufferGeometry.prototype),We.Geometry=function(){Object.defineProperty(this,"id",{value:We.GeometryIdCount++}),this.uuid=We.Math.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphColors=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.hasTangents=!1,this.dynamic=!0,this.verticesNeedUpdate=!1,this.elementsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.tangentsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1},We.Geometry.prototype={constructor:We.Geometry,applyMatrix:function(t){for(var e=(new We.Matrix3).getNormalMatrix(t),r=0,i=this.vertices.length;r<i;r++){this.vertices[r].applyMatrix4(t)}for(r=0,i=this.faces.length;r<i;r++){var n=this.faces[r];n.normal.applyMatrix3(e).normalize();for(var o=0,a=n.vertexNormals.length;o<a;o++)n.vertexNormals[o].applyMatrix3(e).normalize()}this.boundingBox instanceof We.Box3&&this.computeBoundingBox(),this.boundingSphere instanceof We.Sphere&&this.computeBoundingSphere()},fromBufferGeometry:function(t){for(var o=this,e=t.attributes,r=e.position.array,i=void 0!==e.index?e.index.array:void 0,a=void 0!==e.normal?e.normal.array:void 0,s=void 0!==e.color?e.color.array:void 0,n=void 0!==e.uv?e.uv.array:void 0,h=[],l=[],u=0,c=0;u<r.length;u+=3,c+=2)o.vertices.push(new We.Vector3(r[u],r[u+1],r[u+2])),void 0!==a&&h.push(new We.Vector3(a[u],a[u+1],a[u+2])),void 0!==s&&o.colors.push(new We.Color(s[u],s[u+1],s[u+2])),void 0!==n&&l.push(new We.Vector2(n[c],n[c+1]));var f=function(t,e,r){var i=void 0!==a?[h[t].clone(),h[e].clone(),h[r].clone()]:[],n=void 0!==s?[o.colors[t].clone(),o.colors[e].clone(),o.colors[r].clone()]:[];o.faces.push(new We.Face3(t,e,r,i,n)),o.faceVertexUvs[0].push([l[t],l[e],l[r]])};if(void 0!==i)for(u=0;u<i.length;u+=3)f(i[u],i[u+1],i[u+2]);else for(u=0;u<r.length/3;u+=3)f(u,u+1,u+2);return this.computeFaceNormals(),null!==t.boundingBox&&(this.boundingBox=t.boundingBox.clone()),null!==t.boundingSphere&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){this.computeBoundingBox();var t=new We.Vector3;return t.addVectors(this.boundingBox.min,this.boundingBox.max),t.multiplyScalar(-.5),this.applyMatrix((new We.Matrix4).makeTranslation(t.x,t.y,t.z)),this.computeBoundingBox(),t},computeFaceNormals:function(){for(var t=new We.Vector3,e=new We.Vector3,r=0,i=this.faces.length;r<i;r++){var n=this.faces[r],o=this.vertices[n.a],a=this.vertices[n.b],s=this.vertices[n.c];t.subVectors(s,a),e.subVectors(o,a),t.cross(e),t.normalize(),n.normal.copy(t)}},computeVertexNormals:function(t){var e,r,i,n,o,a;for(a=new Array(this.vertices.length),e=0,r=this.vertices.length;e<r;e++)a[e]=new We.Vector3;if(t){var s,h,l,u=new We.Vector3,c=new We.Vector3;new We.Vector3,new We.Vector3,new We.Vector3;for(i=0,n=this.faces.length;i<n;i++)o=this.faces[i],s=this.vertices[o.a],h=this.vertices[o.b],l=this.vertices[o.c],u.subVectors(l,h),c.subVectors(s,h),u.cross(c),a[o.a].add(u),a[o.b].add(u),a[o.c].add(u)}else for(i=0,n=this.faces.length;i<n;i++)a[(o=this.faces[i]).a].add(o.normal),a[o.b].add(o.normal),a[o.c].add(o.normal);for(e=0,r=this.vertices.length;e<r;e++)a[e].normalize();for(i=0,n=this.faces.length;i<n;i++)(o=this.faces[i]).vertexNormals[0]=a[o.a].clone(),o.vertexNormals[1]=a[o.b].clone(),o.vertexNormals[2]=a[o.c].clone()},computeMorphNormals:function(){var t,e,r,i,n;for(r=0,i=this.faces.length;r<i;r++)for((n=this.faces[r]).__originalFaceNormal?n.__originalFaceNormal.copy(n.normal):n.__originalFaceNormal=n.normal.clone(),n.__originalVertexNormals||(n.__originalVertexNormals=[]),t=0,e=n.vertexNormals.length;t<e;t++)n.__originalVertexNormals[t]?n.__originalVertexNormals[t].copy(n.vertexNormals[t]):n.__originalVertexNormals[t]=n.vertexNormals[t].clone();var o=new We.Geometry;for(o.faces=this.faces,t=0,e=this.morphTargets.length;t<e;t++){if(!this.morphNormals[t]){this.morphNormals[t]={},this.morphNormals[t].faceNormals=[],this.morphNormals[t].vertexNormals=[];var a=this.morphNormals[t].faceNormals,s=this.morphNormals[t].vertexNormals;for(r=0,i=this.faces.length;r<i;r++)h=new We.Vector3,l={a:new We.Vector3,b:new We.Vector3,c:new We.Vector3},a.push(h),s.push(l)}var h,l,u=this.morphNormals[t];for(o.vertices=this.morphTargets[t].vertices,o.computeFaceNormals(),o.computeVertexNormals(),r=0,i=this.faces.length;r<i;r++)n=this.faces[r],h=u.faceNormals[r],l=u.vertexNormals[r],h.copy(n.normal),l.a.copy(n.vertexNormals[0]),l.b.copy(n.vertexNormals[1]),l.c.copy(n.vertexNormals[2])}for(r=0,i=this.faces.length;r<i;r++)(n=this.faces[r]).normal=n.__originalFaceNormal,n.vertexNormals=n.__originalVertexNormals},computeTangents:function(){var t,e,r,i,n,o,a,s,h,l,u,c,f,p,d,m,v,g,y,x,w,b,M,_,S,T,A,C,E,L,P,R,F,D,U=[],B=[],k=new We.Vector3,z=new We.Vector3,V=new We.Vector3,N=new We.Vector3,O=new We.Vector3;for(r=0,i=this.vertices.length;r<i;r++)U[r]=new We.Vector3,B[r]=new We.Vector3;for(t=0,e=this.faces.length;t<e;t++)a=this.faces[t],s=this.faceVertexUvs[0][t],C=this,E=a.a,L=a.b,P=a.c,R=0,F=1,D=2,h=C.vertices[E],l=C.vertices[L],u=C.vertices[P],c=s[R],f=s[F],p=s[D],d=l.x-h.x,m=u.x-h.x,v=l.y-h.y,g=u.y-h.y,y=l.z-h.z,x=u.z-h.z,w=f.x-c.x,b=p.x-c.x,M=f.y-c.y,_=p.y-c.y,S=1/(w*_-b*M),k.set((_*d-M*m)*S,(_*v-M*g)*S,(_*y-M*x)*S),z.set((w*m-b*d)*S,(w*g-b*v)*S,(w*x-b*y)*S),U[E].add(k),U[L].add(k),U[P].add(k),B[E].add(z),B[L].add(z),B[P].add(z);var I=["a","b","c","d"];for(t=0,e=this.faces.length;t<e;t++)for(a=this.faces[t],n=0;n<Math.min(a.vertexNormals.length,3);n++)O.copy(a.vertexNormals[n]),o=a[I[n]],T=U[o],V.copy(T),V.sub(O.multiplyScalar(O.dot(T))).normalize(),N.crossVectors(a.vertexNormals[n],T),A=N.dot(B[o])<0?-1:1,a.vertexTangents[n]=new We.Vector4(V.x,V.y,V.z,A);this.hasTangents=!0},computeLineDistances:function(){for(var t=0,e=this.vertices,r=0,i=e.length;r<i;r++)0<r&&(t+=e[r].distanceTo(e[r-1])),this.lineDistances[r]=t},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new We.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new We.Sphere),this.boundingSphere.setFromPoints(this.vertices)},merge:function(t,e,r){if(t instanceof We.Geometry!=!1){var i,n=this.vertices.length,o=this.vertices,a=t.vertices,s=this.faces,h=t.faces,l=this.faceVertexUvs[0],u=t.faceVertexUvs[0];void 0===r&&(r=0),void 0!==e&&(i=(new We.Matrix3).getNormalMatrix(e));for(var c=0,f=a.length;c<f;c++){var p=a[c].clone();void 0!==e&&p.applyMatrix4(e),o.push(p)}for(c=0,f=h.length;c<f;c++){var d,m,v,g=h[c],y=g.vertexNormals,x=g.vertexColors;(d=new We.Face3(g.a+n,g.b+n,g.c+n)).normal.copy(g.normal),void 0!==i&&d.normal.applyMatrix3(i).normalize();for(var w=0,b=y.length;w<b;w++)m=y[w].clone(),void 0!==i&&m.applyMatrix3(i).normalize(),d.vertexNormals.push(m);d.color.copy(g.color);for(w=0,b=x.length;w<b;w++)v=x[w],d.vertexColors.push(v.clone());d.materialIndex=g.materialIndex+r,s.push(d)}for(c=0,f=u.length;c<f;c++){var M=u[c],_=[];if(void 0!==M){for(w=0,b=M.length;w<b;w++)_.push(new We.Vector2(M[w].x,M[w].y));l.push(_)}}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",t)},mergeVertices:function(){var t,e,r,i,n,o,a,s,h={},l=[],u=[],c=Math.pow(10,4);for(r=0,i=this.vertices.length;r<i;r++)t=this.vertices[r],void 0===h[e=Math.round(t.x*c)+"_"+Math.round(t.y*c)+"_"+Math.round(t.z*c)]?(h[e]=r,l.push(this.vertices[r]),u[r]=l.length-1):u[r]=u[h[e]];var f=[];for(r=0,i=this.faces.length;r<i;r++){(n=this.faces[r]).a=u[n.a],n.b=u[n.b],n.c=u[n.c],o=[n.a,n.b,n.c];for(var p=0;p<3;p++)if(o[p]==o[(p+1)%3]){p,f.push(r);break}}for(r=f.length-1;0<=r;r--){var d=f[r];for(this.faces.splice(d,1),a=0,s=this.faceVertexUvs.length;a<s;a++)this.faceVertexUvs[a].splice(d,1)}var m=this.vertices.length-l.length;return this.vertices=l,m},toJSON:function(){var t={metadata:{version:4,type:"BufferGeometry",generator:"BufferGeometryExporter"},uuid:this.uuid,type:this.type};if(""!==this.name&&(t.name=this.name),void 0!==this.parameters){var e=this.parameters;for(var r in e)void 0!==e[r]&&(t[r]=e[r]);return t}for(var i=[],n=0;n<this.vertices.length;n++){var o=this.vertices[n];i.push(o.x,o.y,o.z)}var a=[],s=[],h={},l=[],u={},c=[],f={};for(n=0;n<this.faces.length;n++){var p=this.faces[n],d=void 0!==this.faceVertexUvs[0][n],m=0<p.normal.length(),v=0<p.vertexNormals.length,g=1!==p.color.r||1!==p.color.g||1!==p.color.b,y=0<p.vertexColors.length,x=0;if(x=_(x=_(x=_(x=_(x=_(x=_(x=_(x=_(x,0,0),1,!1),2,!1),3,d),4,m),5,v),6,g),7,y),a.push(x),a.push(p.a,p.b,p.c),d){var w=this.faceVertexUvs[0][n];a.push(A(w[0]),A(w[1]),A(w[2]))}if(m&&a.push(S(p.normal)),v){var b=p.vertexNormals;a.push(S(b[0]),S(b[1]),S(b[2]))}if(g&&a.push(T(p.color)),y){var M=p.vertexColors;a.push(T(M[0]),T(M[1]),T(M[2]))}}function _(t,e,r){return r?t|1<<e:t&~(1<<e)}function S(t){var e=t.x.toString()+t.y.toString()+t.z.toString();return void 0!==h[e]||(h[e]=s.length/3,s.push(t.x,t.y,t.z)),h[e]}function T(t){var e=t.r.toString()+t.g.toString()+t.b.toString();return void 0!==u[e]||(u[e]=l.length,l.push(t.getHex())),u[e]}function A(t){var e=t.x.toString()+t.y.toString();return void 0!==f[e]||(f[e]=c.length/2,c.push(t.x,t.y)),f[e]}return t.data={},t.data.vertices=i,t.data.normals=s,0<l.length&&(t.data.colors=l),0<c.length&&(t.data.uvs=[c]),t.data.faces=a,t},clone:function(){for(var t=new We.Geometry,e=this.vertices,r=0,i=e.length;r<i;r++)t.vertices.push(e[r].clone());var n=this.faces;for(r=0,i=n.length;r<i;r++)t.faces.push(n[r].clone());var o=this.faceVertexUvs[0];for(r=0,i=o.length;r<i;r++){for(var a=o[r],s=[],h=0,l=a.length;h<l;h++)s.push(new We.Vector2(a[h].x,a[h].y));t.faceVertexUvs[0].push(s)}return t},dispose:function(){this.dispatchEvent({type:"dispose"})}},We.EventDispatcher.prototype.apply(We.Geometry.prototype),We.GeometryIdCount=0,We.Camera=function(){We.Object3D.call(this),this.type="Camera",this.matrixWorldInverse=new We.Matrix4,this.projectionMatrix=new We.Matrix4},We.Camera.prototype=Object.create(We.Object3D.prototype),We.Camera.prototype.getWorldDirection=(Ut=new We.Quaternion,function(t){var e=t||new We.Vector3;return this.getWorldQuaternion(Ut),e.set(0,0,-1).applyQuaternion(Ut)}),We.Camera.prototype.lookAt=(Bt=new We.Matrix4,function(t){Bt.lookAt(this.position,t,this.up),this.quaternion.setFromRotationMatrix(Bt)}),We.Camera.prototype.clone=function(t){return void 0===t&&(t=new We.Camera),We.Object3D.prototype.clone.call(this,t),t.matrixWorldInverse.copy(this.matrixWorldInverse),t.projectionMatrix.copy(this.projectionMatrix),t},We.CubeCamera=function(t,e,r){We.Object3D.call(this),this.type="CubeCamera";var n=new We.PerspectiveCamera(90,1,t,e);n.up.set(0,-1,0),n.lookAt(new We.Vector3(1,0,0)),this.add(n);var o=new We.PerspectiveCamera(90,1,t,e);o.up.set(0,-1,0),o.lookAt(new We.Vector3(-1,0,0)),this.add(o);var a=new We.PerspectiveCamera(90,1,t,e);a.up.set(0,0,1),a.lookAt(new We.Vector3(0,1,0)),this.add(a);var s=new We.PerspectiveCamera(90,1,t,e);s.up.set(0,0,-1),s.lookAt(new We.Vector3(0,-1,0)),this.add(s);var h=new We.PerspectiveCamera(90,1,t,e);h.up.set(0,-1,0),h.lookAt(new We.Vector3(0,0,1)),this.add(h);var l=new We.PerspectiveCamera(90,1,t,e);l.up.set(0,-1,0),l.lookAt(new We.Vector3(0,0,-1)),this.add(l),this.renderTarget=new We.WebGLRenderTargetCube(r,r,{format:We.RGBFormat,magFilter:We.LinearFilter,minFilter:We.LinearFilter}),this.updateCubeMap=function(t,e){var r=this.renderTarget,i=r.generateMipmaps;r.generateMipmaps=!1,r.activeCubeFace=0,t.render(e,n,r),r.activeCubeFace=1,t.render(e,o,r),r.activeCubeFace=2,t.render(e,a,r),r.activeCubeFace=3,t.render(e,s,r),r.activeCubeFace=4,t.render(e,h,r),r.generateMipmaps=i,r.activeCubeFace=5,t.render(e,l,r)}},We.CubeCamera.prototype=Object.create(We.Object3D.prototype),We.OrthographicCamera=function(t,e,r,i,n,o){We.Camera.call(this),this.type="OrthographicCamera",this.zoom=1,this.left=t,this.right=e,this.top=r,this.bottom=i,this.near=void 0!==n?n:.1,this.far=void 0!==o?o:2e3,this.updateProjectionMatrix()},We.OrthographicCamera.prototype=Object.create(We.Camera.prototype),We.OrthographicCamera.prototype.updateProjectionMatrix=function(){var t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),r=(this.right+this.left)/2,i=(this.top+this.bottom)/2;this.projectionMatrix.makeOrthographic(r-t,r+t,i+e,i-e,this.near,this.far)},We.OrthographicCamera.prototype.clone=function(){var t=new We.OrthographicCamera;return We.Camera.prototype.clone.call(this,t),t.zoom=this.zoom,t.left=this.left,t.right=this.right,t.top=this.top,t.bottom=this.bottom,t.near=this.near,t.far=this.far,t.projectionMatrix.copy(this.projectionMatrix),t},We.PerspectiveCamera=function(t,e,r,i){We.Camera.call(this),this.type="PerspectiveCamera",this.zoom=1,this.fov=void 0!==t?t:50,this.aspect=void 0!==e?e:1,this.near=void 0!==r?r:.1,this.far=void 0!==i?i:2e3,this.updateProjectionMatrix()},We.PerspectiveCamera.prototype=Object.create(We.Camera.prototype),We.PerspectiveCamera.prototype.setLens=function(t,e){void 0===e&&(e=24),this.fov=2*We.Math.radToDeg(Math.atan(e/(2*t))),this.updateProjectionMatrix()},We.PerspectiveCamera.prototype.setViewOffset=function(t,e,r,i,n,o){this.fullWidth=t,this.fullHeight=e,this.x=r,this.y=i,this.width=n,this.height=o,this.updateProjectionMatrix()},We.PerspectiveCamera.prototype.updateProjectionMatrix=function(){var t=We.Math.radToDeg(2*Math.atan(Math.tan(.5*We.Math.degToRad(this.fov))/this.zoom));if(this.fullWidth){var e=this.fullWidth/this.fullHeight,r=Math.tan(We.Math.degToRad(.5*t))*this.near,i=-r,n=e*i,o=e*r,a=Math.abs(o-n),s=Math.abs(r-i);this.projectionMatrix.makeFrustum(n+this.x*a/this.fullWidth,n+(this.x+this.width)*a/this.fullWidth,r-(this.y+this.height)*s/this.fullHeight,r-this.y*s/this.fullHeight,this.near,this.far)}else this.projectionMatrix.makePerspective(t,this.aspect,this.near,this.far)},We.PerspectiveCamera.prototype.clone=function(){var t=new We.PerspectiveCamera;return We.Camera.prototype.clone.call(this,t),t.zoom=this.zoom,t.fov=this.fov,t.aspect=this.aspect,t.near=this.near,t.far=this.far,t.projectionMatrix.copy(this.projectionMatrix),t},We.Light=function(t){We.Object3D.call(this),this.type="Light",this.color=new We.Color(t)},We.Light.prototype=Object.create(We.Object3D.prototype),We.Light.prototype.clone=function(t){return void 0===t&&(t=new We.Light),We.Object3D.prototype.clone.call(this,t),t.color.copy(this.color),t},We.AmbientLight=function(t){We.Light.call(this,t),this.type="AmbientLight"},We.AmbientLight.prototype=Object.create(We.Light.prototype),We.AmbientLight.prototype.clone=function(){var t=new We.AmbientLight;return We.Light.prototype.clone.call(this,t),t},We.AreaLight=function(t,e){We.Light.call(this,t),this.type="AreaLight",this.normal=new We.Vector3(0,-1,0),this.right=new We.Vector3(1,0,0),this.intensity=void 0!==e?e:1,this.width=1,this.height=1,this.constantAttenuation=1.5,this.linearAttenuation=.5,this.quadraticAttenuation=.1},We.AreaLight.prototype=Object.create(We.Light.prototype),We.DirectionalLight=function(t,e){We.Light.call(this,t),this.type="DirectionalLight",this.position.set(0,1,0),this.target=new We.Object3D,this.intensity=void 0!==e?e:1,this.castShadow=!1,this.onlyShadow=!1,this.shadowCameraNear=50,this.shadowCameraFar=5e3,this.shadowCameraLeft=-500,this.shadowCameraRight=500,this.shadowCameraTop=500,this.shadowCameraBottom=-500,this.shadowCameraVisible=!1,this.shadowBias=0,this.shadowDarkness=.5,this.shadowMapWidth=512,this.shadowMapHeight=512,this.shadowCascade=!1,this.shadowCascadeOffset=new We.Vector3(0,0,-1e3),this.shadowCascadeCount=2,this.shadowCascadeBias=[0,0,0],this.shadowCascadeWidth=[512,512,512],this.shadowCascadeHeight=[512,512,512],this.shadowCascadeNearZ=[-1,.99,.998],this.shadowCascadeFarZ=[.99,.998,1],this.shadowCascadeArray=[],this.shadowMap=null,this.shadowMapSize=null,this.shadowCamera=null,this.shadowMatrix=null},We.DirectionalLight.prototype=Object.create(We.Light.prototype),We.DirectionalLight.prototype.clone=function(){var t=new We.DirectionalLight;return We.Light.prototype.clone.call(this,t),t.target=this.target.clone(),t.intensity=this.intensity,t.castShadow=this.castShadow,t.onlyShadow=this.onlyShadow,t.shadowCameraNear=this.shadowCameraNear,t.shadowCameraFar=this.shadowCameraFar,t.shadowCameraLeft=this.shadowCameraLeft,t.shadowCameraRight=this.shadowCameraRight,t.shadowCameraTop=this.shadowCameraTop,t.shadowCameraBottom=this.shadowCameraBottom,t.shadowCameraVisible=this.shadowCameraVisible,t.shadowBias=this.shadowBias,t.shadowDarkness=this.shadowDarkness,t.shadowMapWidth=this.shadowMapWidth,t.shadowMapHeight=this.shadowMapHeight,t.shadowCascade=this.shadowCascade,t.shadowCascadeOffset.copy(this.shadowCascadeOffset),t.shadowCascadeCount=this.shadowCascadeCount,t.shadowCascadeBias=this.shadowCascadeBias.slice(0),t.shadowCascadeWidth=this.shadowCascadeWidth.slice(0),t.shadowCascadeHeight=this.shadowCascadeHeight.slice(0),t.shadowCascadeNearZ=this.shadowCascadeNearZ.slice(0),t.shadowCascadeFarZ=this.shadowCascadeFarZ.slice(0),t},We.HemisphereLight=function(t,e,r){We.Light.call(this,t),this.type="HemisphereLight",this.position.set(0,100,0),this.groundColor=new We.Color(e),this.intensity=void 0!==r?r:1},We.HemisphereLight.prototype=Object.create(We.Light.prototype),We.HemisphereLight.prototype.clone=function(){var t=new We.HemisphereLight;return We.Light.prototype.clone.call(this,t),t.groundColor.copy(this.groundColor),t.intensity=this.intensity,t},We.PointLight=function(t,e,r){We.Light.call(this,t),this.type="PointLight",this.intensity=void 0!==e?e:1,this.distance=void 0!==r?r:0},We.PointLight.prototype=Object.create(We.Light.prototype),We.PointLight.prototype.clone=function(){var t=new We.PointLight;return We.Light.prototype.clone.call(this,t),t.intensity=this.intensity,t.distance=this.distance,t},We.SpotLight=function(t,e,r,i,n){We.Light.call(this,t),this.type="SpotLight",this.position.set(0,1,0),this.target=new We.Object3D,this.intensity=void 0!==e?e:1,this.distance=void 0!==r?r:0,this.angle=void 0!==i?i:Math.PI/3,this.exponent=void 0!==n?n:10,this.castShadow=!1,this.onlyShadow=!1,this.shadowCameraNear=50,this.shadowCameraFar=5e3,this.shadowCameraFov=50,this.shadowCameraVisible=!1,this.shadowBias=0,this.shadowDarkness=.5,this.shadowMapWidth=512,this.shadowMapHeight=512,this.shadowMap=null,this.shadowMapSize=null,this.shadowCamera=null,this.shadowMatrix=null},We.SpotLight.prototype=Object.create(We.Light.prototype),We.SpotLight.prototype.clone=function(){var t=new We.SpotLight;return We.Light.prototype.clone.call(this,t),t.target=this.target.clone(),t.intensity=this.intensity,t.distance=this.distance,t.angle=this.angle,t.exponent=this.exponent,t.castShadow=this.castShadow,t.onlyShadow=this.onlyShadow,t.shadowCameraNear=this.shadowCameraNear,t.shadowCameraFar=this.shadowCameraFar,t.shadowCameraFov=this.shadowCameraFov,t.shadowCameraVisible=this.shadowCameraVisible,t.shadowBias=this.shadowBias,t.shadowDarkness=this.shadowDarkness,t.shadowMapWidth=this.shadowMapWidth,t.shadowMapHeight=this.shadowMapHeight,t},We.Cache=function(){this.files={}},We.Cache.prototype={constructor:We.Cache,add:function(t,e){this.files[t]=e},get:function(t){return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}},We.Loader=function(t){this.showStatus=t,this.statusDomElement=t?We.Loader.prototype.addStatusElement():null,this.imageLoader=new We.ImageLoader,this.onLoadStart=function(){},this.onLoadProgress=function(){},this.onLoadComplete=function(){}},We.Loader.prototype={constructor:We.Loader,crossOrigin:void 0,addStatusElement:function(){var t=document.createElement("div");return t.style.position="absolute",t.style.right="0px",t.style.top="0px",t.style.fontSize="0.8em",t.style.textAlign="left",t.style.background="rgba(0,0,0,0.25)",t.style.color="#fff",t.style.width="120px",t.style.padding="0.5em 0.5em 0.5em 0.5em",t.style.zIndex=1e3,t.innerHTML="Loading ...",t},updateProgress:function(t){var e="Loaded ";t.total?e+=(100*t.loaded/t.total).toFixed(0)+"%":e+=(t.loaded/1024).toFixed(2)+" KB",this.statusDomElement.innerHTML=e},extractUrlBase:function(t){var e=t.split("/");return 1===e.length?"./":(e.pop(),e.join("/")+"/")},initMaterials:function(t,e){for(var r=[],i=0;i<t.length;++i)r[i]=this.createMaterial(t[i],e);return r},needsTangents:function(t){for(var e=0,r=t.length;e<r;e++){if(t[e]instanceof We.ShaderMaterial)return!0}return!1},createMaterial:function(t,c){var f=this;function p(t){var e=Math.log(t)/Math.LN2;return Math.pow(2,Math.round(e))}function e(t,e,r,i,n,o,a){var s,h=c+r,l=We.Loader.Handlers.get(h);if(null!==l?s=l.load(h):(s=new We.Texture,(l=f.imageLoader).crossOrigin=f.crossOrigin,l.load(h,function(t){if(!1===We.Math.isPowerOfTwo(t.width)||!1===We.Math.isPowerOfTwo(t.height)){var e=p(t.width),r=p(t.height),i=document.createElement("canvas");i.width=e,i.height=r,i.getContext("2d").drawImage(t,0,0,e,r),s.image=i}else s.image=t;s.needsUpdate=!0})),s.sourceFile=r,i&&(s.repeat.set(i[0],i[1]),1!==i[0]&&(s.wrapS=We.RepeatWrapping),1!==i[1]&&(s.wrapT=We.RepeatWrapping)),n&&s.offset.set(n[0],n[1]),o){var u={repeat:We.RepeatWrapping,mirror:We.MirroredRepeatWrapping};void 0!==u[o[0]]&&(s.wrapS=u[o[0]]),void 0!==u[o[1]]&&(s.wrapT=u[o[1]])}a&&(s.anisotropy=a),t[e]=s}function r(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]}var i="MeshLambertMaterial",n={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,bumpMap:null,wireframe:!1};if(t.shading){var o=t.shading.toLowerCase();"phong"===o?i="MeshPhongMaterial":"basic"===o&&(i="MeshBasicMaterial")}if(void 0!==t.blending&&void 0!==We[t.blending]&&(n.blending=We[t.blending]),(void 0!==t.transparent||t.opacity<1)&&(n.transparent=t.transparent),void 0!==t.depthTest&&(n.depthTest=t.depthTest),void 0!==t.depthWrite&&(n.depthWrite=t.depthWrite),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.flipSided&&(n.side=We.BackSide),void 0!==t.doubleSided&&(n.side=We.DoubleSide),void 0!==t.wireframe&&(n.wireframe=t.wireframe),void 0!==t.vertexColors&&("face"===t.vertexColors?n.vertexColors=We.FaceColors:t.vertexColors&&(n.vertexColors=We.VertexColors)),t.colorDiffuse?n.color=r(t.colorDiffuse):t.DbgColor&&(n.color=t.DbgColor),t.colorSpecular&&(n.specular=r(t.colorSpecular)),t.colorAmbient&&(n.ambient=r(t.colorAmbient)),t.colorEmissive&&(n.emissive=r(t.colorEmissive)),t.transparency&&(n.opacity=t.transparency),t.specularCoef&&(n.shininess=t.specularCoef),t.mapDiffuse&&c&&e(n,"map",t.mapDiffuse,t.mapDiffuseRepeat,t.mapDiffuseOffset,t.mapDiffuseWrap,t.mapDiffuseAnisotropy),t.mapLight&&c&&e(n,"lightMap",t.mapLight,t.mapLightRepeat,t.mapLightOffset,t.mapLightWrap,t.mapLightAnisotropy),t.mapBump&&c&&e(n,"bumpMap",t.mapBump,t.mapBumpRepeat,t.mapBumpOffset,t.mapBumpWrap,t.mapBumpAnisotropy),t.mapNormal&&c&&e(n,"normalMap",t.mapNormal,t.mapNormalRepeat,t.mapNormalOffset,t.mapNormalWrap,t.mapNormalAnisotropy),t.mapSpecular&&c&&e(n,"specularMap",t.mapSpecular,t.mapSpecularRepeat,t.mapSpecularOffset,t.mapSpecularWrap,t.mapSpecularAnisotropy),t.mapAlpha&&c&&e(n,"alphaMap",t.mapAlpha,t.mapAlphaRepeat,t.mapAlphaOffset,t.mapAlphaWrap,t.mapAlphaAnisotropy),t.mapBumpScale&&(n.bumpScale=t.mapBumpScale),t.mapNormal){var a=We.ShaderLib.normalmap,s=We.UniformsUtils.clone(a.uniforms);s.tNormal.value=n.normalMap,t.mapNormalFactor&&s.uNormalScale.value.set(t.mapNormalFactor,t.mapNormalFactor),n.map&&(s.tDiffuse.value=n.map,s.enableDiffuse.value=!0),n.specularMap&&(s.tSpecular.value=n.specularMap,s.enableSpecular.value=!0),n.lightMap&&(s.tAO.value=n.lightMap,s.enableAO.value=!0),s.diffuse.value.setHex(n.color),s.specular.value.setHex(n.specular),s.ambient.value.setHex(n.ambient),s.shininess.value=n.shininess,void 0!==n.opacity&&(s.opacity.value=n.opacity);var h={fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:s,lights:!0,fog:!0},l=new We.ShaderMaterial(h);n.transparent&&(l.transparent=!0)}else l=new We[i](n);return void 0!==t.DbgName&&(l.name=t.DbgName),l}},We.Loader.Handlers={handlers:[],add:function(t,e){this.handlers.push(t,e)},get:function(t){for(var e=0,r=this.handlers.length;e<r;e+=2){var i=this.handlers[e],n=this.handlers[e+1];if(i.test(t))return n}return null}},We.XHRLoader=function(t){this.cache=new We.Cache,this.manager=void 0!==t?t:We.DefaultLoadingManager},We.XHRLoader.prototype={constructor:We.XHRLoader,load:function(e,r,i,n){var o=this,t=o.cache.get(e);if(void 0===t){var a=new XMLHttpRequest;a.open("GET",e,!0),a.addEventListener("load",function(t){o.cache.add(e,this.response),r&&r(this.response),o.manager.itemEnd(e)},!1),void 0!==i&&a.addEventListener("progress",function(t){i(t)},!1),void 0!==n&&a.addEventListener("error",function(t){n(t)},!1),void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),void 0!==this.responseType&&(a.responseType=this.responseType),a.send(null),o.manager.itemStart(e)}else r&&r(t)},setResponseType:function(t){this.responseType=t},setCrossOrigin:function(t){this.crossOrigin=t}},We.ImageLoader=function(t){this.cache=new We.Cache,this.manager=void 0!==t?t:We.DefaultLoadingManager},We.ImageLoader.prototype={constructor:We.ImageLoader,load:function(e,r,i,n){var o=this,t=o.cache.get(e);if(void 0===t){var a=document.createElement("img");return void 0!==r&&a.addEventListener("load",function(t){o.cache.add(e,this),r(this),o.manager.itemEnd(e)},!1),void 0!==i&&a.addEventListener("progress",function(t){i(t)},!1),void 0!==n&&a.addEventListener("error",function(t){n(t)},!1),void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),a.src=e,o.manager.itemStart(e),a}r(t)},setCrossOrigin:function(t){this.crossOrigin=t}},We.JSONLoader=function(t){We.Loader.call(this,t),this.withCredentials=!1},We.JSONLoader.prototype=Object.create(We.Loader.prototype),We.JSONLoader.prototype.load=function(t,e,r){r=r&&"string"==typeof r?r:this.extractUrlBase(t),this.onLoadStart(),this.loadAjaxJSON(this,t,e,r)},We.JSONLoader.prototype.loadAjaxJSON=function(r,i,n,o,a){var s=new XMLHttpRequest,h=0;s.onreadystatechange=function(){if(s.readyState===s.DONE)if(200===s.status||0===s.status){if(s.responseText){var t=JSON.parse(s.responseText);if(void 0!==t.metadata&&"scene"===t.metadata.type)return void console.error('THREE.JSONLoader: "'+i+'" seems to be a Scene. Use THREE.SceneLoader instead.');var e=r.parse(t,o);n(e.geometry,e.materials)}else console.error('THREE.JSONLoader: "'+i+'" seems to be unreachable or the file is empty.');r.onLoadComplete()}else console.error("THREE.JSONLoader: Couldn't load \""+i+'" ('+s.status+")");else s.readyState===s.LOADING?a&&(0===h&&(h=s.getResponseHeader("Content-Length")),a({total:h,loaded:s.responseText.length})):s.readyState===s.HEADERS_RECEIVED&&void 0!==a&&(h=s.getResponseHeader("Content-Length"))},s.open("GET",i,!0),s.withCredentials=this.withCredentials,s.send(null)},We.JSONLoader.prototype.parse=function(U,t){var B=new We.Geometry,e=void 0!==U.scale?1/U.scale:1;if(function(t){function e(t,e){return t&1<<e}var r,i,n,o,a,s,h,l,u,c,f,p,d,m,v,g,y,x,w,b,M,_,S,T,A,C,E,L=U.faces,P=U.vertices,R=U.normals,F=U.colors,D=0;if(void 0!==U.uvs){for(r=0;r<U.uvs.length;r++)U.uvs[r].length&&D++;for(r=0;r<D;r++)B.faceVertexUvs[r]=[]}o=0,a=P.length;for(;o<a;)(x=new We.Vector3).x=P[o++]*t,x.y=P[o++]*t,x.z=P[o++]*t,B.vertices.push(x);o=0,a=L.length;for(;o<a;)if(c=L[o++],f=e(c,0),p=e(c,1),d=e(c,3),m=e(c,4),v=e(c,5),g=e(c,6),y=e(c,7),f){if((b=new We.Face3).a=L[o],b.b=L[o+1],b.c=L[o+3],(M=new We.Face3).a=L[o+1],M.b=L[o+2],M.c=L[o+3],o+=4,p&&(u=L[o++],b.materialIndex=u,M.materialIndex=u),n=B.faces.length,d)for(r=0;r<D;r++)for(T=U.uvs[r],B.faceVertexUvs[r][n]=[],B.faceVertexUvs[r][n+1]=[],i=0;i<4;i++)l=L[o++],C=T[2*l],E=T[2*l+1],A=new We.Vector2(C,E),2!==i&&B.faceVertexUvs[r][n].push(A),0!==i&&B.faceVertexUvs[r][n+1].push(A);if(m&&(h=3*L[o++],b.normal.set(R[h++],R[h++],R[h]),M.normal.copy(b.normal)),v)for(r=0;r<4;r++)h=3*L[o++],S=new We.Vector3(R[h++],R[h++],R[h]),2!==r&&b.vertexNormals.push(S),0!==r&&M.vertexNormals.push(S);if(g&&(s=L[o++],_=F[s],b.color.setHex(_),M.color.setHex(_)),y)for(r=0;r<4;r++)s=L[o++],_=F[s],2!==r&&b.vertexColors.push(new We.Color(_)),0!==r&&M.vertexColors.push(new We.Color(_));B.faces.push(b),B.faces.push(M)}else{if((w=new We.Face3).a=L[o++],w.b=L[o++],w.c=L[o++],p&&(u=L[o++],w.materialIndex=u),n=B.faces.length,d)for(r=0;r<D;r++)for(T=U.uvs[r],B.faceVertexUvs[r][n]=[],i=0;i<3;i++)l=L[o++],C=T[2*l],E=T[2*l+1],A=new We.Vector2(C,E),B.faceVertexUvs[r][n].push(A);if(m&&(h=3*L[o++],w.normal.set(R[h++],R[h++],R[h])),v)for(r=0;r<3;r++)h=3*L[o++],S=new We.Vector3(R[h++],R[h++],R[h]),w.vertexNormals.push(S);if(g&&(s=L[o++],w.color.setHex(F[s])),y)for(r=0;r<3;r++)s=L[o++],w.vertexColors.push(new We.Color(F[s]));B.faces.push(w)}}(e),function(){var t=void 0!==U.influencesPerVertex?U.influencesPerVertex:2;if(U.skinWeights)for(var e=0,r=U.skinWeights.length;e<r;e+=t){var i=U.skinWeights[e],n=1<t?U.skinWeights[e+1]:0,o=2<t?U.skinWeights[e+2]:0,a=3<t?U.skinWeights[e+3]:0;B.skinWeights.push(new We.Vector4(i,n,o,a))}if(U.skinIndices)for(var e=0,r=U.skinIndices.length;e<r;e+=t){var s=U.skinIndices[e],h=1<t?U.skinIndices[e+1]:0,l=2<t?U.skinIndices[e+2]:0,u=3<t?U.skinIndices[e+3]:0;B.skinIndices.push(new We.Vector4(s,h,l,u))}B.bones=U.bones,B.bones&&0<B.bones.length&&(B.skinWeights.length!==B.skinIndices.length||B.skinIndices.length!==B.vertices.length)&&console.warn("When skinning, number of vertices ("+B.vertices.length+"), skinIndices ("+B.skinIndices.length+"), and skinWeights ("+B.skinWeights.length+") should match.");B.animation=U.animation,B.animations=U.animations}(),function(t){var e,r,i,n,o,a,s,h,l,u,c;if(void 0!==U.morphTargets)for(o=0,a=U.morphTargets.length;o<a;o++)for(B.morphTargets[o]={},B.morphTargets[o].name=U.morphTargets[o].name,B.morphTargets[o].vertices=[],i=B.morphTargets[o].vertices,n=U.morphTargets[o].vertices,e=0,r=n.length;e<r;e+=3){var f=new We.Vector3;f.x=n[e]*t,f.y=n[e+1]*t,f.z=n[e+2]*t,i.push(f)}if(void 0!==U.morphColors)for(o=0,a=U.morphColors.length;o<a;o++)for(B.morphColors[o]={},B.morphColors[o].name=U.morphColors[o].name,B.morphColors[o].colors=[],l=B.morphColors[o].colors,u=U.morphColors[o].colors,s=0,h=u.length;s<h;s+=3)(c=new We.Color(16755200)).setRGB(u[s],u[s+1],u[s+2]),l.push(c)}(e),B.computeFaceNormals(),B.computeBoundingSphere(),void 0===U.materials||0===U.materials.length)return{geometry:B};var r=this.initMaterials(U.materials,t);return this.needsTangents(r)&&B.computeTangents(),{geometry:B,materials:r}},We.LoadingManager=function(t,e,r){var i=this,n=0,o=0;this.onLoad=t,this.onProgress=e,this.onError=r,this.itemStart=function(t){o++},this.itemEnd=function(t){n++,void 0!==i.onProgress&&i.onProgress(t,n,o),n===o&&void 0!==i.onLoad&&i.onLoad()}},We.DefaultLoadingManager=new We.LoadingManager,We.BufferGeometryLoader=function(t){this.manager=void 0!==t?t:We.DefaultLoadingManager},We.BufferGeometryLoader.prototype={constructor:We.BufferGeometryLoader,load:function(t,e,r,i){var n=this,o=new We.XHRLoader;o.setCrossOrigin(this.crossOrigin),o.load(t,function(t){e(n.parse(JSON.parse(t)))},r,i)},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t){var e=new We.BufferGeometry,r=t.attributes;for(var i in r){var n=r[i],o=new He[n.type](n.array);e.addAttribute(i,new We.BufferAttribute(o,n.itemSize))}var a=t.offsets;void 0!==a&&(e.offsets=JSON.parse(JSON.stringify(a)));var s=t.boundingSphere;if(void 0!==s){var h=new We.Vector3;void 0!==s.center&&h.fromArray(s.center),e.boundingSphere=new We.Sphere(h,s.radius)}return e}},We.MaterialLoader=function(t){this.manager=void 0!==t?t:We.DefaultLoadingManager},We.MaterialLoader.prototype={constructor:We.MaterialLoader,load:function(t,e,r,i){var n=this,o=new We.XHRLoader;o.setCrossOrigin(this.crossOrigin),o.load(t,function(t){e(n.parse(JSON.parse(t)))},r,i)},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t){var e=new We[t.type];if(void 0!==t.color&&e.color.setHex(t.color),void 0!==t.ambient&&e.ambient.setHex(t.ambient),void 0!==t.emissive&&e.emissive.setHex(t.emissive),void 0!==t.specular&&e.specular.setHex(t.specular),void 0!==t.shininess&&(e.shininess=t.shininess),void 0!==t.uniforms&&(e.uniforms=t.uniforms),void 0!==t.vertexShader&&(e.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(e.fragmentShader=t.fragmentShader),void 0!==t.vertexColors&&(e.vertexColors=t.vertexColors),void 0!==t.shading&&(e.shading=t.shading),void 0!==t.blending&&(e.blending=t.blending),void 0!==t.side&&(e.side=t.side),void 0!==t.opacity&&(e.opacity=t.opacity),void 0!==t.transparent&&(e.transparent=t.transparent),void 0!==t.wireframe&&(e.wireframe=t.wireframe),void 0!==t.materials)for(var r=0,i=t.materials.length;r<i;r++)e.materials.push(this.parse(t.materials[r]));return e}},We.ObjectLoader=function(t){this.manager=void 0!==t?t:We.DefaultLoadingManager},We.ObjectLoader.prototype={constructor:We.ObjectLoader,load:function(t,e,r,i){var n=this,o=new We.XHRLoader(n.manager);o.setCrossOrigin(this.crossOrigin),o.load(t,function(t){e(n.parse(JSON.parse(t)))},r,i)},setCrossOrigin:function(t){this.crossOrigin=t},parse:function(t){var e=this.parseGeometries(t.geometries),r=this.parseMaterials(t.materials);return this.parseObject(t.object,e,r)},parseGeometries:function(t){var e={};if(void 0!==t)for(var r=new We.JSONLoader,i=new We.BufferGeometryLoader,n=0,o=t.length;n<o;n++){var a,s=t[n];switch(s.type){case"PlaneGeometry":a=new We.PlaneGeometry(s.width,s.height,s.widthSegments,s.heightSegments);break;case"BoxGeometry":case"CubeGeometry":a=new We.BoxGeometry(s.width,s.height,s.depth,s.widthSegments,s.heightSegments,s.depthSegments);break;case"CircleGeometry":a=new We.CircleGeometry(s.radius,s.segments);break;case"CylinderGeometry":a=new We.CylinderGeometry(s.radiusTop,s.radiusBottom,s.height,s.radialSegments,s.heightSegments,s.openEnded);break;case"SphereGeometry":a=new We.SphereGeometry(s.radius,s.widthSegments,s.heightSegments,s.phiStart,s.phiLength,s.thetaStart,s.thetaLength);break;case"IcosahedronGeometry":a=new We.IcosahedronGeometry(s.radius,s.detail);break;case"TorusGeometry":a=new We.TorusGeometry(s.radius,s.tube,s.radialSegments,s.tubularSegments,s.arc);break;case"TorusKnotGeometry":a=new We.TorusKnotGeometry(s.radius,s.tube,s.radialSegments,s.tubularSegments,s.p,s.q,s.heightScale);break;case"BufferGeometry":a=i.parse(s.data);break;case"Geometry":a=r.parse(s.data).geometry}a.uuid=s.uuid,void 0!==s.name&&(a.name=s.name),e[s.uuid]=a}return e},parseMaterials:function(t){var e={};if(void 0!==t)for(var r=new We.MaterialLoader,i=0,n=t.length;i<n;i++){var o=t[i],a=r.parse(o);a.uuid=o.uuid,void 0!==o.name&&(a.name=o.name),e[o.uuid]=a}return e},parseObject:(kt=new We.Matrix4,function(t,e,r){var i;switch(t.type){case"Scene":i=new We.Scene;break;case"PerspectiveCamera":i=new We.PerspectiveCamera(t.fov,t.aspect,t.near,t.far);break;case"OrthographicCamera":i=new We.OrthographicCamera(t.left,t.right,t.top,t.bottom,t.near,t.far);break;case"AmbientLight":i=new We.AmbientLight(t.color);break;case"DirectionalLight":i=new We.DirectionalLight(t.color,t.intensity);break;case"PointLight":i=new We.PointLight(t.color,t.intensity,t.distance);break;case"SpotLight":i=new We.SpotLight(t.color,t.intensity,t.distance,t.angle,t.exponent);break;case"HemisphereLight":i=new We.HemisphereLight(t.color,t.groundColor,t.intensity);break;case"Mesh":var n=e[t.geometry],o=r[t.material];void 0===n&&console.warn("THREE.ObjectLoader: Undefined geometry",t.geometry),void 0===o&&console.warn("THREE.ObjectLoader: Undefined material",t.material),i=new We.Mesh(n,o);break;case"Line":n=e[t.geometry],o=r[t.material],void 0===n&&console.warn("THREE.ObjectLoader: Undefined geometry",t.geometry),void 0===o&&console.warn("THREE.ObjectLoader: Undefined material",t.material),i=new We.Line(n,o);break;case"Sprite":void 0===(o=r[t.material])&&console.warn("THREE.ObjectLoader: Undefined material",t.material),i=new We.Sprite(o);break;case"Group":i=new We.Group;break;default:i=new We.Object3D}if(i.uuid=t.uuid,void 0!==t.name&&(i.name=t.name),void 0!==t.matrix?(kt.fromArray(t.matrix),kt.decompose(i.position,i.quaternion,i.scale)):(void 0!==t.position&&i.position.fromArray(t.position),void 0!==t.rotation&&i.rotation.fromArray(t.rotation),void 0!==t.scale&&i.scale.fromArray(t.scale)),void 0!==t.visible&&(i.visible=t.visible),void 0!==t.userData&&(i.userData=t.userData),void 0!==t.children)for(var a in t.children)i.add(this.parseObject(t.children[a],e,r));return i})},We.TextureLoader=function(t){this.manager=void 0!==t?t:We.DefaultLoadingManager},We.TextureLoader.prototype={constructor:We.TextureLoader,load:function(t,r,e,i){var n=new We.ImageLoader(this.manager);n.setCrossOrigin(this.crossOrigin),n.load(t,function(t){var e=new We.Texture(t);e.needsUpdate=!0,void 0!==r&&r(e)},e,i)},setCrossOrigin:function(t){this.crossOrigin=t}},We.CompressedTextureLoader=function(){this._parser=null},We.CompressedTextureLoader.prototype={constructor:We.CompressedTextureLoader,load:function(t,o,e){var a=this,s=[],h=new We.CompressedTexture;h.image=s;var i=new We.XHRLoader;if(i.setResponseType("arraybuffer"),t instanceof Array)for(var n=0,r=function(r){i.load(t[r],function(t){var e=a._parser(t,!0);s[r]={width:e.width,height:e.height,format:e.format,mipmaps:e.mipmaps},6===(n+=1)&&(1==e.mipmapCount&&(h.minFilter=We.LinearFilter),h.format=e.format,h.needsUpdate=!0,o&&o(h))})},l=0,u=t.length;l<u;++l)r(l);else i.load(t,function(t){var e=a._parser(t,!0);if(e.isCubemap)for(var r=e.mipmaps.length/e.mipmapCount,i=0;i<r;i++){s[i]={mipmaps:[]};for(var n=0;n<e.mipmapCount;n++)s[i].mipmaps.push(e.mipmaps[i*e.mipmapCount+n]),s[i].format=e.format,s[i].width=e.width,s[i].height=e.height}else h.image.width=e.width,h.image.height=e.height,h.mipmaps=e.mipmaps;1===e.mipmapCount&&(h.minFilter=We.LinearFilter),h.format=e.format,h.needsUpdate=!0,o&&o(h)});return h}},We.Material=function(){Object.defineProperty(this,"id",{value:We.MaterialIdCount++}),this.uuid=We.Math.generateUUID(),this.name="",this.type="Material",this.side=We.FrontSide,this.opacity=1,this.transparent=!1,this.blending=We.NormalBlending,this.blendSrc=We.SrcAlphaFactor,this.blendDst=We.OneMinusSrcAlphaFactor,this.blendEquation=We.AddEquation,this.depthTest=!0,this.depthWrite=!0,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.alphaTest=0,this.overdraw=0,this.visible=!0,this.needsUpdate=!0},We.Material.prototype={constructor:We.Material,setValues:function(t){if(void 0!==t)for(var e in t){var r=t[e];if(void 0!==r){if(e in this){var i=this[e];i instanceof We.Color?i.set(r):i instanceof We.Vector3&&r instanceof We.Vector3?i.copy(r):this[e]="overdraw"==e?Number(r):r}}else console.warn("THREE.Material: '"+e+"' parameter is undefined.")}},toJSON:function(){var t={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type};return""!==this.name&&(t.name=this.name),this instanceof We.MeshBasicMaterial?(t.color=this.color.getHex(),this.vertexColors!==We.NoColors&&(t.vertexColors=this.vertexColors),this.blending!==We.NormalBlending&&(t.blending=this.blending),this.side!==We.FrontSide&&(t.side=this.side)):this instanceof We.MeshLambertMaterial?(t.color=this.color.getHex(),t.ambient=this.ambient.getHex(),t.emissive=this.emissive.getHex(),this.vertexColors!==We.NoColors&&(t.vertexColors=this.vertexColors),this.blending!==We.NormalBlending&&(t.blending=this.blending),this.side!==We.FrontSide&&(t.side=this.side)):this instanceof We.MeshPhongMaterial?(t.color=this.color.getHex(),t.ambient=this.ambient.getHex(),t.emissive=this.emissive.getHex(),t.specular=this.specular.getHex(),t.shininess=this.shininess,this.vertexColors!==We.NoColors&&(t.vertexColors=this.vertexColors),this.blending!==We.NormalBlending&&(t.blending=this.blending),this.side!==We.FrontSide&&(t.side=this.side)):this instanceof We.MeshNormalMaterial?(this.shading!==We.FlatShading&&(t.shading=this.shading),this.blending!==We.NormalBlending&&(t.blending=this.blending),this.side!==We.FrontSide&&(t.side=this.side)):this instanceof We.MeshDepthMaterial?(this.blending!==We.NormalBlending&&(t.blending=this.blending),this.side!==We.FrontSide&&(t.side=this.side)):this instanceof We.ShaderMaterial?(t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader):this instanceof We.SpriteMaterial&&(t.color=this.color.getHex()),this.opacity<1&&(t.opacity=this.opacity),!1!==this.transparent&&(t.transparent=this.transparent),!1!==this.wireframe&&(t.wireframe=this.wireframe),t},clone:function(t){return void 0===t&&(t=new We.Material),t.name=this.name,t.side=this.side,t.opacity=this.opacity,t.transparent=this.transparent,t.blending=this.blending,t.blendSrc=this.blendSrc,t.blendDst=this.blendDst,t.blendEquation=this.blendEquation,t.depthTest=this.depthTest,t.depthWrite=this.depthWrite,t.polygonOffset=this.polygonOffset,t.polygonOffsetFactor=this.polygonOffsetFactor,t.polygonOffsetUnits=this.polygonOffsetUnits,t.alphaTest=this.alphaTest,t.overdraw=this.overdraw,t.visible=this.visible,t},dispose:function(){this.dispatchEvent({type:"dispose"})}},We.EventDispatcher.prototype.apply(We.Material.prototype),We.MaterialIdCount=0,We.LineBasicMaterial=function(t){We.Material.call(this),this.type="LineBasicMaterial",this.color=new We.Color(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.vertexColors=We.NoColors,this.fog=!0,this.setValues(t)},We.LineBasicMaterial.prototype=Object.create(We.Material.prototype),We.LineBasicMaterial.prototype.clone=function(){var t=new We.LineBasicMaterial;return We.Material.prototype.clone.call(this,t),t.color.copy(this.color),t.linewidth=this.linewidth,t.linecap=this.linecap,t.linejoin=this.linejoin,t.vertexColors=this.vertexColors,t.fog=this.fog,t},We.LineDashedMaterial=function(t){We.Material.call(this),this.type="LineDashedMaterial",this.color=new We.Color(16777215),this.linewidth=1,this.scale=1,this.dashSize=3,this.gapSize=1,this.vertexColors=!1,this.fog=!0,this.setValues(t)},We.LineDashedMaterial.prototype=Object.create(We.Material.prototype),We.LineDashedMaterial.prototype.clone=function(){var t=new We.LineDashedMaterial;return We.Material.prototype.clone.call(this,t),t.color.copy(this.color),t.linewidth=this.linewidth,t.scale=this.scale,t.dashSize=this.dashSize,t.gapSize=this.gapSize,t.vertexColors=this.vertexColors,t.fog=this.fog,t},We.MeshBasicMaterial=function(t){We.Material.call(this),this.type="MeshBasicMaterial",this.color=new We.Color(16777215),this.map=null,this.lightMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=We.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=We.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=We.NoColors,this.skinning=!1,this.morphTargets=!1,this.setValues(t)},We.MeshBasicMaterial.prototype=Object.create(We.Material.prototype),We.MeshBasicMaterial.prototype.clone=function(){var t=new We.MeshBasicMaterial;return We.Material.prototype.clone.call(this,t),t.color.copy(this.color),t.map=this.map,t.lightMap=this.lightMap,t.specularMap=this.specularMap,t.alphaMap=this.alphaMap,t.envMap=this.envMap,t.combine=this.combine,t.reflectivity=this.reflectivity,t.refractionRatio=this.refractionRatio,t.fog=this.fog,t.shading=this.shading,t.wireframe=this.wireframe,t.wireframeLinewidth=this.wireframeLinewidth,t.wireframeLinecap=this.wireframeLinecap,t.wireframeLinejoin=this.wireframeLinejoin,t.vertexColors=this.vertexColors,t.skinning=this.skinning,t.morphTargets=this.morphTargets,t},We.MeshLambertMaterial=function(t){We.Material.call(this),this.type="MeshLambertMaterial",this.color=new We.Color(16777215),this.ambient=new We.Color(16777215),this.emissive=new We.Color(0),this.wrapAround=!1,this.wrapRGB=new We.Vector3(1,1,1),this.map=null,this.lightMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=We.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=We.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=We.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)},We.MeshLambertMaterial.prototype=Object.create(We.Material.prototype),We.MeshLambertMaterial.prototype.clone=function(){var t=new We.MeshLambertMaterial;return We.Material.prototype.clone.call(this,t),t.color.copy(this.color),t.ambient.copy(this.ambient),t.emissive.copy(this.emissive),t.wrapAround=this.wrapAround,t.wrapRGB.copy(this.wrapRGB),t.map=this.map,t.lightMap=this.lightMap,t.specularMap=this.specularMap,t.alphaMap=this.alphaMap,t.envMap=this.envMap,t.combine=this.combine,t.reflectivity=this.reflectivity,t.refractionRatio=this.refractionRatio,t.fog=this.fog,t.shading=this.shading,t.wireframe=this.wireframe,t.wireframeLinewidth=this.wireframeLinewidth,t.wireframeLinecap=this.wireframeLinecap,t.wireframeLinejoin=this.wireframeLinejoin,t.vertexColors=this.vertexColors,t.skinning=this.skinning,t.morphTargets=this.morphTargets,t.morphNormals=this.morphNormals,t},We.MeshPhongMaterial=function(t){We.Material.call(this),this.type="MeshPhongMaterial",this.color=new We.Color(16777215),this.ambient=new We.Color(16777215),this.emissive=new We.Color(0),this.specular=new We.Color(1118481),this.shininess=30,this.metal=!1,this.wrapAround=!1,this.wrapRGB=new We.Vector3(1,1,1),this.map=null,this.lightMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalScale=new We.Vector2(1,1),this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=We.MultiplyOperation,this.reflectivity=1,this.refractionRatio=.98,this.fog=!0,this.shading=We.SmoothShading,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.vertexColors=We.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.setValues(t)},We.MeshPhongMaterial.prototype=Object.create(We.Material.prototype),We.MeshPhongMaterial.prototype.clone=function(){var t=new We.MeshPhongMaterial;return We.Material.prototype.clone.call(this,t),t.color.copy(this.color),t.ambient.copy(this.ambient),t.emissive.copy(this.emissive),t.specular.copy(this.specular),t.shininess=this.shininess,t.metal=this.metal,t.wrapAround=this.wrapAround,t.wrapRGB.copy(this.wrapRGB),t.map=this.map,t.lightMap=this.lightMap,t.bumpMap=this.bumpMap,t.bumpScale=this.bumpScale,t.normalMap=this.normalMap,t.normalScale.copy(this.normalScale),t.specularMap=this.specularMap,t.alphaMap=this.alphaMap,t.envMap=this.envMap,t.combine=this.combine,t.reflectivity=this.reflectivity,t.refractionRatio=this.refractionRatio,t.fog=this.fog,t.shading=this.shading,t.wireframe=this.wireframe,t.wireframeLinewidth=this.wireframeLinewidth,t.wireframeLinecap=this.wireframeLinecap,t.wireframeLinejoin=this.wireframeLinejoin,t.vertexColors=this.vertexColors,t.skinning=this.skinning,t.morphTargets=this.morphTargets,t.morphNormals=this.morphNormals,t},We.MeshDepthMaterial=function(t){We.Material.call(this),this.type="MeshDepthMaterial",this.morphTargets=!1,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)},We.MeshDepthMaterial.prototype=Object.create(We.Material.prototype),We.MeshDepthMaterial.prototype.clone=function(){var t=new We.MeshDepthMaterial;return We.Material.prototype.clone.call(this,t),t.wireframe=this.wireframe,t.wireframeLinewidth=this.wireframeLinewidth,t},We.MeshNormalMaterial=function(t){We.Material.call(this,t),this.type="MeshNormalMaterial",this.shading=We.FlatShading,this.wireframe=!1,this.wireframeLinewidth=1,this.morphTargets=!1,this.setValues(t)},We.MeshNormalMaterial.prototype=Object.create(We.Material.prototype),We.MeshNormalMaterial.prototype.clone=function(){var t=new We.MeshNormalMaterial;return We.Material.prototype.clone.call(this,t),t.shading=this.shading,t.wireframe=this.wireframe,t.wireframeLinewidth=this.wireframeLinewidth,t},We.MeshFaceMaterial=function(t){this.uuid=We.Math.generateUUID(),this.type="MeshFaceMaterial",this.materials=t instanceof Array?t:[]},We.MeshFaceMaterial.prototype={constructor:We.MeshFaceMaterial,toJSON:function(){for(var t={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type,materials:[]},e=0,r=this.materials.length;e<r;e++)t.materials.push(this.materials[e].toJSON());return t},clone:function(){for(var t=new We.MeshFaceMaterial,e=0;e<this.materials.length;e++)t.materials.push(this.materials[e].clone());return t}},We.PointCloudMaterial=function(t){We.Material.call(this),this.type="PointCloudMaterial",this.color=new We.Color(16777215),this.map=null,this.size=1,this.sizeAttenuation=!0,this.vertexColors=We.NoColors,this.fog=!0,this.setValues(t)},We.PointCloudMaterial.prototype=Object.create(We.Material.prototype),We.PointCloudMaterial.prototype.clone=function(){var t=new We.PointCloudMaterial;return We.Material.prototype.clone.call(this,t),t.color.copy(this.color),t.map=this.map,t.size=this.size,t.sizeAttenuation=this.sizeAttenuation,t.vertexColors=this.vertexColors,t.fog=this.fog,t},We.ParticleBasicMaterial=function(t){return console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointCloudMaterial."),new We.PointCloudMaterial(t)},We.ParticleSystemMaterial=function(t){return console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointCloudMaterial."),new We.PointCloudMaterial(t)},We.ShaderMaterial=function(t){We.Material.call(this),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.attributes=null,this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}",this.shading=We.SmoothShading,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.vertexColors=We.NoColors,this.skinning=!1,this.morphTargets=!1,this.morphNormals=!1,this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.setValues(t)},We.ShaderMaterial.prototype=Object.create(We.Material.prototype),We.ShaderMaterial.prototype.clone=function(){var t=new We.ShaderMaterial;return We.Material.prototype.clone.call(this,t),t.fragmentShader=this.fragmentShader,t.vertexShader=this.vertexShader,t.uniforms=We.UniformsUtils.clone(this.uniforms),t.attributes=this.attributes,t.defines=this.defines,t.shading=this.shading,t.wireframe=this.wireframe,t.wireframeLinewidth=this.wireframeLinewidth,t.fog=this.fog,t.lights=this.lights,t.vertexColors=this.vertexColors,t.skinning=this.skinning,t.morphTargets=this.morphTargets,t.morphNormals=this.morphNormals,t},We.RawShaderMaterial=function(t){We.ShaderMaterial.call(this,t),this.type="RawShaderMaterial"},We.RawShaderMaterial.prototype=Object.create(We.ShaderMaterial.prototype),We.RawShaderMaterial.prototype.clone=function(){var t=new We.RawShaderMaterial;return We.ShaderMaterial.prototype.clone.call(this,t),t},We.SpriteMaterial=function(t){We.Material.call(this),this.type="SpriteMaterial",this.color=new We.Color(16777215),this.map=null,this.rotation=0,this.fog=!1,this.setValues(t)},We.SpriteMaterial.prototype=Object.create(We.Material.prototype),We.SpriteMaterial.prototype.clone=function(){var t=new We.SpriteMaterial;return We.Material.prototype.clone.call(this,t),t.color.copy(this.color),t.map=this.map,t.rotation=this.rotation,t.fog=this.fog,t},We.Texture=function(t,e,r,i,n,o,a,s,h){Object.defineProperty(this,"id",{value:We.TextureIdCount++}),this.uuid=We.Math.generateUUID(),this.name="",this.image=void 0!==t?t:We.Texture.DEFAULT_IMAGE,this.mipmaps=[],this.mapping=void 0!==e?e:We.Texture.DEFAULT_MAPPING,this.wrapS=void 0!==r?r:We.ClampToEdgeWrapping,this.wrapT=void 0!==i?i:We.ClampToEdgeWrapping,this.magFilter=void 0!==n?n:We.LinearFilter,this.minFilter=void 0!==o?o:We.LinearMipMapLinearFilter,this.anisotropy=void 0!==h?h:1,this.format=void 0!==a?a:We.RGBAFormat,this.type=void 0!==s?s:We.UnsignedByteType,this.offset=new We.Vector2(0,0),this.repeat=new We.Vector2(1,1),this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this._needsUpdate=!1,this.onUpdate=null},We.Texture.DEFAULT_IMAGE=void 0,We.Texture.DEFAULT_MAPPING=new We.UVMapping,We.Texture.prototype={constructor:We.Texture,get needsUpdate(){return this._needsUpdate},set needsUpdate(t){!0===t&&this.update(),this._needsUpdate=t},clone:function(t){return void 0===t&&(t=new We.Texture),t.image=this.image,t.mipmaps=this.mipmaps.slice(0),t.mapping=this.mapping,t.wrapS=this.wrapS,t.wrapT=this.wrapT,t.magFilter=this.magFilter,t.minFilter=this.minFilter,t.anisotropy=this.anisotropy,t.format=this.format,t.type=this.type,t.offset.copy(this.offset),t.repeat.copy(this.repeat),t.generateMipmaps=this.generateMipmaps,t.premultiplyAlpha=this.premultiplyAlpha,t.flipY=this.flipY,t.unpackAlignment=this.unpackAlignment,t},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}},We.EventDispatcher.prototype.apply(We.Texture.prototype),We.TextureIdCount=0,We.CubeTexture=function(t,e,r,i,n,o,a,s,h){We.Texture.call(this,t,e,r,i,n,o,a,s,h),this.images=t},We.CubeTexture.prototype=Object.create(We.Texture.prototype),We.CubeTexture.clone=function(t){return void 0===t&&(t=new We.CubeTexture),We.Texture.prototype.clone.call(this,t),t.images=this.images,t},We.CompressedTexture=function(t,e,r,i,n,o,a,s,h,l,u){We.Texture.call(this,null,o,a,s,h,l,i,n,u),this.image={width:e,height:r},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1},We.CompressedTexture.prototype=Object.create(We.Texture.prototype),We.CompressedTexture.prototype.clone=function(){var t=new We.CompressedTexture;return We.Texture.prototype.clone.call(this,t),t},We.DataTexture=function(t,e,r,i,n,o,a,s,h,l,u){We.Texture.call(this,null,o,a,s,h,l,i,n,u),this.image={data:t,width:e,height:r}},We.DataTexture.prototype=Object.create(We.Texture.prototype),We.DataTexture.prototype.clone=function(){var t=new We.DataTexture;return We.Texture.prototype.clone.call(this,t),t},We.VideoTexture=function(t,e,r,i,n,o,a,s,h){We.Texture.call(this,t,e,r,i,n,o,a,s,h),this.generateMipmaps=!1;var l=this,u=function(){requestAnimationFrame(u),t.readyState===t.HAVE_ENOUGH_DATA&&(l.needsUpdate=!0)};u()},We.VideoTexture.prototype=Object.create(We.Texture.prototype),We.Group=function(){We.Object3D.call(this),this.type="Group"},We.Group.prototype=Object.create(We.Object3D.prototype),We.PointCloud=function(t,e){We.Object3D.call(this),this.type="PointCloud",this.geometry=void 0!==t?t:new We.Geometry,this.material=void 0!==e?e:new We.PointCloudMaterial({color:16777215*Math.random()}),this.sortParticles=!1},We.PointCloud.prototype=Object.create(We.Object3D.prototype),We.PointCloud.prototype.raycast=(zt=new We.Matrix4,Vt=new We.Ray,function(o,a){var s=this,t=s.geometry,e=o.params.PointCloud.threshold;if(zt.getInverse(this.matrixWorld),Vt.copy(o.ray).applyMatrix4(zt),null===t.boundingBox||!1!==Vt.isIntersectionBox(t.boundingBox)){var h=e/((this.scale.x+this.scale.y+this.scale.z)/3),r=new We.Vector3,i=function(t,e){var r=Vt.distanceToPoint(t);if(r<h){var i=Vt.closestPointToPoint(t);i.applyMatrix4(s.matrixWorld);var n=o.ray.origin.distanceTo(i);a.push({distance:n,distanceToRay:r,point:i.clone(),index:e,face:null,object:s})}};if(t instanceof We.BufferGeometry){var n=t.attributes,l=n.position.array;if(void 0!==n.index){var u=n.index.array,c=t.offsets;0===c.length&&(c=[{start:0,count:u.length,index:0}]);for(var f=0,p=c.length;f<p;++f)for(var d=c[f].start,m=c[f].count,v=c[f].index,g=d,y=d+m;g<y;g++){var x=v+u[g];r.fromArray(l,3*x),i(r,x)}}else{var w=l.length/3;for(g=0;g<w;g++)r.set(l[3*g],l[3*g+1],l[3*g+2]),i(r,g)}}else{var b=this.geometry.vertices;for(g=0;g<b.length;g++)i(b[g],g)}}}),We.PointCloud.prototype.clone=function(t){return void 0===t&&(t=new We.PointCloud(this.geometry,this.material)),t.sortParticles=this.sortParticles,We.Object3D.prototype.clone.call(this,t),t},We.ParticleSystem=function(t,e){return console.warn("THREE.ParticleSystem has been renamed to THREE.PointCloud."),new We.PointCloud(t,e)},We.Line=function(t,e,r){We.Object3D.call(this),this.type="Line",this.geometry=void 0!==t?t:new We.Geometry,this.material=void 0!==e?e:new We.LineBasicMaterial({color:16777215*Math.random()}),this.mode=void 0!==r?r:We.LineStrip},We.LineStrip=0,We.LinePieces=1,We.Line.prototype=Object.create(We.Object3D.prototype),We.Line.prototype.raycast=(Nt=new We.Matrix4,Ot=new We.Ray,It=new We.Sphere,function(t,e){var r=t.linePrecision,i=r*r,n=this.geometry;if(null===n.boundingSphere&&n.computeBoundingSphere(),It.copy(n.boundingSphere),It.applyMatrix4(this.matrixWorld),!1!==t.ray.isIntersectionSphere(It)&&(Nt.getInverse(this.matrixWorld),Ot.copy(t.ray).applyMatrix4(Nt),n instanceof We.Geometry))for(var o=n.vertices,a=o.length,s=new We.Vector3,h=new We.Vector3,l=this.mode===We.LineStrip?1:2,u=0;u<a-1;u+=l)if(!(i<Ot.distanceSqToSegment(o[u],o[u+1],h,s))){var c=Ot.origin.distanceTo(h);c<t.near||c>t.far||e.push({distance:c,point:s.clone().applyMatrix4(this.matrixWorld),face:null,faceIndex:null,object:this})}}),We.Line.prototype.clone=function(t){return void 0===t&&(t=new We.Line(this.geometry,this.material,this.mode)),We.Object3D.prototype.clone.call(this,t),t},We.Mesh=function(t,e){We.Object3D.call(this),this.type="Mesh",this.geometry=void 0!==t?t:new We.Geometry,this.material=void 0!==e?e:new We.MeshBasicMaterial({color:16777215*Math.random()}),this.updateMorphTargets()},We.Mesh.prototype=Object.create(We.Object3D.prototype),We.Mesh.prototype.updateMorphTargets=function(){if(void 0!==this.geometry.morphTargets&&0<this.geometry.morphTargets.length){this.morphTargetBase=-1,this.morphTargetForcedOrder=[],this.morphTargetInfluences=[],this.morphTargetDictionary={};for(var t=0,e=this.geometry.morphTargets.length;t<e;t++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[t].name]=t}},We.Mesh.prototype.getMorphTargetIndexByName=function(t){return void 0!==this.morphTargetDictionary[t]?this.morphTargetDictionary[t]:(console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+t+" does not exist. Returning 0."),0)},We.Mesh.prototype.raycast=(Gt=new We.Matrix4,Ht=new We.Ray,Wt=new We.Sphere,jt=new We.Vector3,Xt=new We.Vector3,qt=new We.Vector3,function(t,e){var r=this.geometry;if(null===r.boundingSphere&&r.computeBoundingSphere(),Wt.copy(r.boundingSphere),Wt.applyMatrix4(this.matrixWorld),!1!==t.ray.isIntersectionSphere(Wt)&&(Gt.getInverse(this.matrixWorld),Ht.copy(t.ray).applyMatrix4(Gt),null===r.boundingBox||!1!==Ht.isIntersectionBox(r.boundingBox)))if(r instanceof We.BufferGeometry){if(void 0===(T=this.material))return;var i=r.attributes,n=t.precision;if(void 0!==i.index){var o=i.index.array,a=i.position.array,s=r.offsets;0===s.length&&(s=[{start:0,count:o.length,index:0}]);for(var h=0,l=s.length;h<l;++h)for(var u=s[h].start,c=s[h].count,f=s[h].index,p=u,d=u+c;p<d;p+=3){if(g=f+o[p],y=f+o[p+1],x=f+o[p+2],jt.fromArray(a,3*g),Xt.fromArray(a,3*y),qt.fromArray(a,3*x),T.side===We.BackSide)var m=Ht.intersectTriangle(qt,Xt,jt,!0);else m=Ht.intersectTriangle(jt,Xt,qt,T.side!==We.DoubleSide);null!==m&&(m.applyMatrix4(this.matrixWorld),(D=t.ray.origin.distanceTo(m))<n||D<t.near||D>t.far||e.push({distance:D,point:m,face:new We.Face3(g,y,x,We.Triangle.normal(jt,Xt,qt)),faceIndex:null,object:this}))}}else{var v=p=0;for(d=(a=i.position.array).length;p<d;p+=3,v+=9)y=(g=p)+1,x=p+2,jt.fromArray(a,v),Xt.fromArray(a,v+3),qt.fromArray(a,v+6),null!==(m=T.side===We.BackSide?Ht.intersectTriangle(qt,Xt,jt,!0):Ht.intersectTriangle(jt,Xt,qt,T.side!==We.DoubleSide))&&(m.applyMatrix4(this.matrixWorld),(D=t.ray.origin.distanceTo(m))<n||D<t.near||D>t.far||e.push({distance:D,point:m,face:new We.Face3(g,y,x,We.Triangle.normal(jt,Xt,qt)),faceIndex:null,object:this}))}}else if(r instanceof We.Geometry)for(var g,y,x,w=this.material instanceof We.MeshFaceMaterial,b=!0===w?this.material.materials:null,M=(n=t.precision,r.vertices),_=0,S=r.faces.length;_<S;_++){var T,A=r.faces[_];if(void 0!==(T=!0===w?b[A.materialIndex]:this.material)){if(g=M[A.a],y=M[A.b],x=M[A.c],!0===T.morphTargets){var C=r.morphTargets,E=this.morphTargetInfluences;jt.set(0,0,0),Xt.set(0,0,0),qt.set(0,0,0);for(var L=0,P=C.length;L<P;L++){var R=E[L];if(0!==R){var F=C[L].vertices;jt.x+=(F[A.a].x-g.x)*R,jt.y+=(F[A.a].y-g.y)*R,jt.z+=(F[A.a].z-g.z)*R,Xt.x+=(F[A.b].x-y.x)*R,Xt.y+=(F[A.b].y-y.y)*R,Xt.z+=(F[A.b].z-y.z)*R,qt.x+=(F[A.c].x-x.x)*R,qt.y+=(F[A.c].y-x.y)*R,qt.z+=(F[A.c].z-x.z)*R}}jt.add(g),Xt.add(y),qt.add(x),g=jt,y=Xt,x=qt}var D;null!==(m=T.side===We.BackSide?Ht.intersectTriangle(x,y,g,!0):Ht.intersectTriangle(g,y,x,T.side!==We.DoubleSide))&&(m.applyMatrix4(this.matrixWorld),(D=t.ray.origin.distanceTo(m))<n||D<t.near||D>t.far||e.push({distance:D,point:m,face:A,faceIndex:_,object:this}))}}}),We.Mesh.prototype.clone=function(t,e){return void 0===t&&(t=new We.Mesh(this.geometry,this.material)),We.Object3D.prototype.clone.call(this,t,e),t},We.Bone=function(t){We.Object3D.call(this),this.skin=t},We.Bone.prototype=Object.create(We.Object3D.prototype),We.Skeleton=function(t,e,r){var i;(this.useVertexTexture=void 0===r||r,this.identityMatrix=new We.Matrix4,t=t||[],this.bones=t.slice(0),this.useVertexTexture)?(i=256<this.bones.length?64:64<this.bones.length?32:16<this.bones.length?16:8,this.boneTextureWidth=i,this.boneTextureHeight=i,this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new We.DataTexture(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,We.RGBAFormat,We.FloatType),this.boneTexture.minFilter=We.NearestFilter,this.boneTexture.magFilter=We.NearestFilter,this.boneTexture.generateMipmaps=!1,this.boneTexture.flipY=!1):this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===e)this.calculateInverses();else if(this.bones.length===e.length)this.boneInverses=e.slice(0);else{console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[];for(var n=0,o=this.bones.length;n<o;n++)this.boneInverses.push(new We.Matrix4)}},We.Skeleton.prototype.calculateInverses=function(){this.boneInverses=[];for(var t=0,e=this.bones.length;t<e;t++){var r=new We.Matrix4;this.bones[t]&&r.getInverse(this.bones[t].matrixWorld),this.boneInverses.push(r)}},We.Skeleton.prototype.pose=function(){for(var t,e=0,r=this.bones.length;e<r;e++)(t=this.bones[e])&&t.matrixWorld.getInverse(this.boneInverses[e]);for(e=0,r=this.bones.length;e<r;e++)(t=this.bones[e])&&(t.parent?(t.matrix.getInverse(t.parent.matrixWorld),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))},We.Skeleton.prototype.update=(Yt=new We.Matrix4,function(){for(var t=0,e=this.bones.length;t<e;t++){var r=this.bones[t]?this.bones[t].matrixWorld:this.identityMatrix;Yt.multiplyMatrices(r,this.boneInverses[t]),Yt.flattenToArrayOffset(this.boneMatrices,16*t)}this.useVertexTexture&&(this.boneTexture.needsUpdate=!0)}),We.SkinnedMesh=function(t,e,r){We.Mesh.call(this,t,e),this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new We.Matrix4,this.bindMatrixInverse=new We.Matrix4;var i=[];if(this.geometry&&void 0!==this.geometry.bones){for(var n,o,a,s,h,l=0,u=this.geometry.bones.length;l<u;++l)a=(o=this.geometry.bones[l]).pos,s=o.rotq,h=o.scl,n=new We.Bone(this),i.push(n),n.name=o.name,n.position.set(a[0],a[1],a[2]),n.quaternion.set(s[0],s[1],s[2],s[3]),void 0!==h?n.scale.set(h[0],h[1],h[2]):n.scale.set(1,1,1);for(l=0,u=this.geometry.bones.length;l<u;++l)-1!==(o=this.geometry.bones[l]).parent?i[o.parent].add(i[l]):this.add(i[l])}this.normalizeSkinWeights(),this.updateMatrixWorld(!0),this.bind(new We.Skeleton(i,void 0,r))},We.SkinnedMesh.prototype=Object.create(We.Mesh.prototype),We.SkinnedMesh.prototype.bind=function(t,e){this.skeleton=t,void 0===e&&(this.updateMatrixWorld(!0),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.getInverse(e)},We.SkinnedMesh.prototype.pose=function(){this.skeleton.pose()},We.SkinnedMesh.prototype.normalizeSkinWeights=function(){if(this.geometry instanceof We.Geometry)for(var t=0;t<this.geometry.skinIndices.length;t++){var e=this.geometry.skinWeights[t],r=1/e.lengthManhattan();r!==1/0?e.multiplyScalar(r):e.set(1)}},We.SkinnedMesh.prototype.updateMatrixWorld=function(t){We.Mesh.prototype.updateMatrixWorld.call(this,!0),"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh unreckognized bindMode: "+this.bindMode)},We.SkinnedMesh.prototype.clone=function(t){return void 0===t&&(t=new We.SkinnedMesh(this.geometry,this.material,this.useVertexTexture)),We.Mesh.prototype.clone.call(this,t),t},We.MorphAnimMesh=function(t,e){We.Mesh.call(this,t,e),this.type="MorphAnimMesh",this.duration=1e3,this.mirroredLoop=!1,this.time=0,this.lastKeyframe=0,this.currentKeyframe=0,this.direction=1,this.directionBackwards=!1,this.setFrameRange(0,this.geometry.morphTargets.length-1)},We.MorphAnimMesh.prototype=Object.create(We.Mesh.prototype),We.MorphAnimMesh.prototype.setFrameRange=function(t,e){this.startKeyframe=t,this.endKeyframe=e,this.length=this.endKeyframe-this.startKeyframe+1},We.MorphAnimMesh.prototype.setDirectionForward=function(){this.direction=1,this.directionBackwards=!1},We.MorphAnimMesh.prototype.setDirectionBackward=function(){this.direction=-1,this.directionBackwards=!0},We.MorphAnimMesh.prototype.parseAnimations=function(){var t=this.geometry;t.animations||(t.animations={});for(var e,r=t.animations,i=/([a-z]+)_?(\d+)/,n=0,o=t.morphTargets.length;n<o;n++){var a=t.morphTargets[n].name.match(i);if(a&&1<a.length){var s=a[1];a[2];r[s]||(r[s]={start:1/0,end:-1/0});var h=r[s];n<h.start&&(h.start=n),n>h.end&&(h.end=n),e||(e=s)}}t.firstAnimation=e},We.MorphAnimMesh.prototype.setAnimationLabel=function(t,e,r){this.geometry.animations||(this.geometry.animations={}),this.geometry.animations[t]={start:e,end:r}},We.MorphAnimMesh.prototype.playAnimation=function(t,e){var r=this.geometry.animations[t];r?(this.setFrameRange(r.start,r.end),this.duration=(r.end-r.start)/e*1e3,this.time=0):console.warn("animation["+t+"] undefined")},We.MorphAnimMesh.prototype.updateAnimation=function(t){var e=this.duration/this.length;this.time+=this.direction*t,this.mirroredLoop?(this.time>this.duration||this.time<0)&&(this.direction*=-1,this.time>this.duration&&(this.time=this.duration,this.directionBackwards=!0),this.time<0&&(this.time=0,this.directionBackwards=!1)):(this.time=this.time%this.duration,this.time<0&&(this.time+=this.duration));var r=this.startKeyframe+We.Math.clamp(Math.floor(this.time/e),0,this.length-1);r!==this.currentKeyframe&&(this.morphTargetInfluences[this.lastKeyframe]=0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[r]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=r);var i=this.time%e/e;this.directionBackwards&&(i=1-i),this.morphTargetInfluences[this.currentKeyframe]=i,this.morphTargetInfluences[this.lastKeyframe]=1-i},We.MorphAnimMesh.prototype.interpolateTargets=function(t,e,r){for(var i=this.morphTargetInfluences,n=0,o=i.length;n<o;n++)i[n]=0;-1<t&&(i[t]=1-r),-1<e&&(i[e]=r)},We.MorphAnimMesh.prototype.clone=function(t){return void 0===t&&(t=new We.MorphAnimMesh(this.geometry,this.material)),t.duration=this.duration,t.mirroredLoop=this.mirroredLoop,t.time=this.time,t.lastKeyframe=this.lastKeyframe,t.currentKeyframe=this.currentKeyframe,t.direction=this.direction,t.directionBackwards=this.directionBackwards,We.Mesh.prototype.clone.call(this,t),t},We.LOD=function(){We.Object3D.call(this),this.objects=[]},We.LOD.prototype=Object.create(We.Object3D.prototype),We.LOD.prototype.addLevel=function(t,e){void 0===e&&(e=0),e=Math.abs(e);for(var r=0;r<this.objects.length&&!(e<this.objects[r].distance);r++);this.objects.splice(r,0,{distance:e,object:t}),this.add(t)},We.LOD.prototype.getObjectForDistance=function(t){for(var e=1,r=this.objects.length;e<r&&!(t<this.objects[e].distance);e++);return this.objects[e-1].object},We.LOD.prototype.raycast=(Kt=new We.Vector3,function(t,e){Kt.setFromMatrixPosition(this.matrixWorld);var r=t.ray.origin.distanceTo(Kt);this.getObjectForDistance(r).raycast(t,e)}),We.LOD.prototype.update=(Zt=new We.Vector3,Qt=new We.Vector3,function(t){if(1<this.objects.length){Zt.setFromMatrixPosition(t.matrixWorld),Qt.setFromMatrixPosition(this.matrixWorld);var e=Zt.distanceTo(Qt);this.objects[0].object.visible=!0;for(var r=1,i=this.objects.length;r<i&&e>=this.objects[r].distance;r++)this.objects[r-1].object.visible=!1,this.objects[r].object.visible=!0;for(;r<i;r++)this.objects[r].object.visible=!1}}),We.LOD.prototype.clone=function(t){void 0===t&&(t=new We.LOD),We.Object3D.prototype.clone.call(this,t);for(var e=0,r=this.objects.length;e<r;e++){var i=this.objects[e].object.clone();i.visible=0===e,t.addLevel(i,this.objects[e].distance)}return t},We.Sprite=(Jt=new Uint16Array([0,1,2,0,2,3]),$t=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),te=new Float32Array([0,0,1,0,1,1,0,1]),(ee=new We.BufferGeometry).addAttribute("index",new We.BufferAttribute(Jt,1)),ee.addAttribute("position",new We.BufferAttribute($t,3)),ee.addAttribute("uv",new We.BufferAttribute(te,2)),function(t){We.Object3D.call(this),this.type="Sprite",this.geometry=ee,this.material=void 0!==t?t:new We.SpriteMaterial}),We.Sprite.prototype=Object.create(We.Object3D.prototype),We.Sprite.prototype.raycast=(re=new We.Vector3,function(t,e){re.setFromMatrixPosition(this.matrixWorld);var r=t.ray.distanceToPoint(re);r>this.scale.x||e.push({distance:r,point:this.position,face:null,object:this})}),We.Sprite.prototype.clone=function(t){return void 0===t&&(t=new We.Sprite(this.material)),We.Object3D.prototype.clone.call(this,t),t},We.Particle=We.Sprite,We.LensFlare=function(t,e,r,i,n){We.Object3D.call(this),this.lensFlares=[],this.positionScreen=new We.Vector3,(this.customUpdateCallback=void 0)!==t&&this.add(t,e,r,i,n)},We.LensFlare.prototype=Object.create(We.Object3D.prototype),We.LensFlare.prototype.add=function(t,e,r,i,n,o){void 0===e&&(e=-1),void 0===r&&(r=0),void 0===o&&(o=1),void 0===n&&(n=new We.Color(16777215)),void 0===i&&(i=We.NormalBlending),r=Math.min(r,Math.max(0,r)),this.lensFlares.push({texture:t,size:e,distance:r,x:0,y:0,z:0,scale:1,rotation:1,opacity:o,color:n,blending:i})},We.LensFlare.prototype.updateLensFlares=function(){var t,e,r=this.lensFlares.length,i=2*-this.positionScreen.x,n=2*-this.positionScreen.y;for(t=0;t<r;t++)(e=this.lensFlares[t]).x=this.positionScreen.x+i*e.distance,e.y=this.positionScreen.y+n*e.distance,e.wantedRotation=e.x*Math.PI*.25,e.rotation+=.25*(e.wantedRotation-e.rotation)},We.Scene=function(){We.Object3D.call(this),this.type="Scene",this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0},We.Scene.prototype=Object.create(We.Object3D.prototype),We.Scene.prototype.clone=function(t){return void 0===t&&(t=new We.Scene),We.Object3D.prototype.clone.call(this,t),null!==this.fog&&(t.fog=this.fog.clone()),null!==this.overrideMaterial&&(t.overrideMaterial=this.overrideMaterial.clone()),t.autoUpdate=this.autoUpdate,t.matrixAutoUpdate=this.matrixAutoUpdate,t},We.Fog=function(t,e,r){this.name="",this.color=new We.Color(t),this.near=void 0!==e?e:1,this.far=void 0!==r?r:1e3},We.Fog.prototype.clone=function(){return new We.Fog(this.color.getHex(),this.near,this.far)},We.FogExp2=function(t,e){this.name="",this.color=new We.Color(t),this.density=void 0!==e?e:25e-5},We.FogExp2.prototype.clone=function(){return new We.FogExp2(this.color.getHex(),this.density)},We.ShaderChunk={},We.ShaderChunk.alphatest_fragment="#ifdef ALPHATEST\n\n\tif ( gl_FragColor.a < ALPHATEST ) discard;\n\n#endif\n",We.ShaderChunk.lights_lambert_vertex="vLightFront = vec3( 0.0 );\n\n#ifdef DOUBLE_SIDED\n\n\tvLightBack = vec3( 0.0 );\n\n#endif\n\ntransformedNormal = normalize( transformedNormal );\n\n#if MAX_DIR_LIGHTS > 0\n\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\n\n\tvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\n\tvec3 dirVector = normalize( lDirection.xyz );\n\n\tfloat dotProduct = dot( transformedNormal, dirVector );\n\tvec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tvec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\n\t\t#ifdef WRAP_AROUND\n\n\t\t\tvec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\n\t\t#endif\n\n\t#endif\n\n\t#ifdef WRAP_AROUND\n\n\t\tvec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n\t\tdirectionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tdirectionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );\n\n\t\t#endif\n\n\t#endif\n\n\tvLightFront += directionalLightColor[ i ] * directionalLightWeighting;\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tvLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;\n\n\t#endif\n\n}\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n\tfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n\n\t\tvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz - mvPosition.xyz;\n\n\t\tfloat lDistance = 1.0;\n\t\tif ( pointLightDistance[ i ] > 0.0 )\n\t\t\tlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\n\n\t\tlVector = normalize( lVector );\n\t\tfloat dotProduct = dot( transformedNormal, lVector );\n\n\t\tvec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\n\t\t\t#ifdef WRAP_AROUND\n\n\t\t\t\tvec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\n\t\t\t#endif\n\n\t\t#endif\n\n\t\t#ifdef WRAP_AROUND\n\n\t\t\tvec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n\t\t\tpointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );\n\n\t\t\t#ifdef DOUBLE_SIDED\n\n\t\t\t\tpointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );\n\n\t\t\t#endif\n\n\t\t#endif\n\n\t\tvLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;\n\n\t\t#endif\n\n\t}\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n\tfor( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n\n\t\tvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz - mvPosition.xyz;\n\n\t\tfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - worldPosition.xyz ) );\n\n\t\tif ( spotEffect > spotLightAngleCos[ i ] ) {\n\n\t\t\tspotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );\n\n\t\t\tfloat lDistance = 1.0;\n\t\t\tif ( spotLightDistance[ i ] > 0.0 )\n\t\t\t\tlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\n\n\t\t\tlVector = normalize( lVector );\n\n\t\t\tfloat dotProduct = dot( transformedNormal, lVector );\n\t\t\tvec3 spotLightWeighting = vec3( max( dotProduct, 0.0 ) );\n\n\t\t\t#ifdef DOUBLE_SIDED\n\n\t\t\t\tvec3 spotLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n\n\t\t\t\t#ifdef WRAP_AROUND\n\n\t\t\t\t\tvec3 spotLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\t#ifdef WRAP_AROUND\n\n\t\t\t\tvec3 spotLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\n\t\t\t\tspotLightWeighting = mix( spotLightWeighting, spotLightWeightingHalf, wrapRGB );\n\n\t\t\t\t#ifdef DOUBLE_SIDED\n\n\t\t\t\t\tspotLightWeightingBack = mix( spotLightWeightingBack, spotLightWeightingHalfBack, wrapRGB );\n\n\t\t\t\t#endif\n\n\t\t\t#endif\n\n\t\t\tvLightFront += spotLightColor[ i ] * spotLightWeighting * lDistance * spotEffect;\n\n\t\t\t#ifdef DOUBLE_SIDED\n\n\t\t\t\tvLightBack += spotLightColor[ i ] * spotLightWeightingBack * lDistance * spotEffect;\n\n\t\t\t#endif\n\n\t\t}\n\n\t}\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n\tfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\n\n\t\tvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );\n\t\tvec3 lVector = normalize( lDirection.xyz );\n\n\t\tfloat dotProduct = dot( transformedNormal, lVector );\n\n\t\tfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\n\t\tfloat hemiDiffuseWeightBack = -0.5 * dotProduct + 0.5;\n\n\t\tvLightFront += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeightBack );\n\n\t\t#endif\n\n\t}\n\n#endif\n\nvLightFront = vLightFront * diffuse + ambient * ambientLightColor + emissive;\n\n#ifdef DOUBLE_SIDED\n\n\tvLightBack = vLightBack * diffuse + ambient * ambientLightColor + emissive;\n\n#endif",We.ShaderChunk.map_particle_pars_fragment="#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif",We.ShaderChunk.default_vertex="vec4 mvPosition;\n\n#ifdef USE_SKINNING\n\n\tmvPosition = modelViewMatrix * skinned;\n\n#endif\n\n#if !defined( USE_SKINNING ) && defined( USE_MORPHTARGETS )\n\n\tmvPosition = modelViewMatrix * vec4( morphed, 1.0 );\n\n#endif\n\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHTARGETS )\n\n\tmvPosition = modelViewMatrix * vec4( position, 1.0 );\n\n#endif\n\ngl_Position = projectionMatrix * mvPosition;",We.ShaderChunk.map_pars_fragment="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )\n\n\tvarying vec2 vUv;\n\n#endif\n\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif",We.ShaderChunk.skinnormal_vertex="#ifdef USE_SKINNING\n\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\n\t#ifdef USE_MORPHNORMALS\n\n\tvec4 skinnedNormal = skinMatrix * vec4( morphedNormal, 0.0 );\n\n\t#else\n\n\tvec4 skinnedNormal = skinMatrix * vec4( normal, 0.0 );\n\n\t#endif\n\n#endif\n",We.ShaderChunk.logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvarying float vFragDepth;\n\n\t#endif\n\n\tuniform float logDepthBufFC;\n\n#endif",We.ShaderChunk.lightmap_pars_vertex="#ifdef USE_LIGHTMAP\n\n\tvarying vec2 vUv2;\n\n#endif",We.ShaderChunk.lights_phong_fragment="vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n\n#ifdef DOUBLE_SIDED\n\n\tnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n\n#endif\n\n#ifdef USE_NORMALMAP\n\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n\n#elif defined( USE_BUMPMAP )\n\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n\tvec3 pointDiffuse = vec3( 0.0 );\n\tvec3 pointSpecular = vec3( 0.0 );\n\n\tfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n\n\t\tvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz + vViewPosition.xyz;\n\n\t\tfloat lDistance = 1.0;\n\t\tif ( pointLightDistance[ i ] > 0.0 )\n\t\t\tlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\n\n\t\tlVector = normalize( lVector );\n\n\t\t\t\t// diffuse\n\n\t\tfloat dotProduct = dot( normal, lVector );\n\n\t\t#ifdef WRAP_AROUND\n\n\t\t\tfloat pointDiffuseWeightFull = max( dotProduct, 0.0 );\n\t\t\tfloat pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\n\t\t\tvec3 pointDiffuseWeight = mix( vec3( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n\n\t\t#else\n\n\t\t\tfloat pointDiffuseWeight = max( dotProduct, 0.0 );\n\n\t\t#endif\n\n\t\tpointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;\n\n\t\t\t\t// specular\n\n\t\tvec3 pointHalfVector = normalize( lVector + viewPosition );\n\t\tfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\n\t\tfloat pointSpecularWeight = specularStrength * max( pow( pointDotNormalHalf, shininess ), 0.0 );\n\n\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, pointHalfVector ), 0.0 ), 5.0 );\n\t\tpointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance * specularNormalization;\n\n\t}\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n\tvec3 spotDiffuse = vec3( 0.0 );\n\tvec3 spotSpecular = vec3( 0.0 );\n\n\tfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {\n\n\t\tvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );\n\t\tvec3 lVector = lPosition.xyz + vViewPosition.xyz;\n\n\t\tfloat lDistance = 1.0;\n\t\tif ( spotLightDistance[ i ] > 0.0 )\n\t\t\tlDistance = 1.0 - min( ( length( lVector ) / spotLightDistance[ i ] ), 1.0 );\n\n\t\tlVector = normalize( lVector );\n\n\t\tfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );\n\n\t\tif ( spotEffect > spotLightAngleCos[ i ] ) {\n\n\t\t\tspotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );\n\n\t\t\t\t\t// diffuse\n\n\t\t\tfloat dotProduct = dot( normal, lVector );\n\n\t\t\t#ifdef WRAP_AROUND\n\n\t\t\t\tfloat spotDiffuseWeightFull = max( dotProduct, 0.0 );\n\t\t\t\tfloat spotDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\n\t\t\t\tvec3 spotDiffuseWeight = mix( vec3( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );\n\n\t\t\t#else\n\n\t\t\t\tfloat spotDiffuseWeight = max( dotProduct, 0.0 );\n\n\t\t\t#endif\n\n\t\t\tspotDiffuse += diffuse * spotLightColor[ i ] * spotDiffuseWeight * lDistance * spotEffect;\n\n\t\t\t\t\t// specular\n\n\t\t\tvec3 spotHalfVector = normalize( lVector + viewPosition );\n\t\t\tfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );\n\t\t\tfloat spotSpecularWeight = specularStrength * max( pow( spotDotNormalHalf, shininess ), 0.0 );\n\n\t\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, spotHalfVector ), 0.0 ), 5.0 );\n\t\t\tspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * lDistance * specularNormalization * spotEffect;\n\n\t\t}\n\n\t}\n\n#endif\n\n#if MAX_DIR_LIGHTS > 0\n\n\tvec3 dirDiffuse = vec3( 0.0 );\n\tvec3 dirSpecular = vec3( 0.0 );\n\n\tfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\n\n\t\tvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\n\t\tvec3 dirVector = normalize( lDirection.xyz );\n\n\t\t\t\t// diffuse\n\n\t\tfloat dotProduct = dot( normal, dirVector );\n\n\t\t#ifdef WRAP_AROUND\n\n\t\t\tfloat dirDiffuseWeightFull = max( dotProduct, 0.0 );\n\t\t\tfloat dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\n\n\t\t\tvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n\n\t\t#else\n\n\t\t\tfloat dirDiffuseWeight = max( dotProduct, 0.0 );\n\n\t\t#endif\n\n\t\tdirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\n\n\t\t// specular\n\n\t\tvec3 dirHalfVector = normalize( dirVector + viewPosition );\n\t\tfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\n\t\tfloat dirSpecularWeight = specularStrength * max( pow( dirDotNormalHalf, shininess ), 0.0 );\n\n\t\t/*\n\t\t// fresnel term from skin shader\n\t\tconst float F0 = 0.128;\n\n\t\tfloat base = 1.0 - dot( viewPosition, dirHalfVector );\n\t\tfloat exponential = pow( base, 5.0 );\n\n\t\tfloat fresnel = exponential + F0 * ( 1.0 - exponential );\n\t\t*/\n\n\t\t/*\n\t\t// fresnel term from fresnel shader\n\t\tconst float mFresnelBias = 0.08;\n\t\tconst float mFresnelScale = 0.3;\n\t\tconst float mFresnelPower = 5.0;\n\n\t\tfloat fresnel = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( -viewPosition ), normal ), mFresnelPower );\n\t\t*/\n\n\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n\t\t// \t\tdirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization * fresnel;\n\n\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( dirVector, dirHalfVector ), 0.0 ), 5.0 );\n\t\tdirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;\n\n\n\t}\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n\tvec3 hemiDiffuse = vec3( 0.0 );\n\tvec3 hemiSpecular = vec3( 0.0 );\n\n\tfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {\n\n\t\tvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );\n\t\tvec3 lVector = normalize( lDirection.xyz );\n\n\t\t// diffuse\n\n\t\tfloat dotProduct = dot( normal, lVector );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;\n\n\t\tvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );\n\n\t\themiDiffuse += diffuse * hemiColor;\n\n\t\t// specular (sky light)\n\n\t\tvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );\n\t\tfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;\n\t\tfloat hemiSpecularWeightSky = specularStrength * max( pow( max( hemiDotNormalHalfSky, 0.0 ), shininess ), 0.0 );\n\n\t\t// specular (ground light)\n\n\t\tvec3 lVectorGround = -lVector;\n\n\t\tvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );\n\t\tfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;\n\t\tfloat hemiSpecularWeightGround = specularStrength * max( pow( max( hemiDotNormalHalfGround, 0.0 ), shininess ), 0.0 );\n\n\t\tfloat dotProductGround = dot( normal, lVectorGround );\n\n\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;\n\n\t\tvec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, hemiHalfVectorSky ), 0.0 ), 5.0 );\n\t\tvec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 0.0 ), 5.0 );\n\t\themiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );\n\n\t}\n\n#endif\n\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n\n#if MAX_DIR_LIGHTS > 0\n\n\ttotalDiffuse += dirDiffuse;\n\ttotalSpecular += dirSpecular;\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n\ttotalDiffuse += hemiDiffuse;\n\ttotalSpecular += hemiSpecular;\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n\ttotalDiffuse += pointDiffuse;\n\ttotalSpecular += pointSpecular;\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n\ttotalDiffuse += spotDiffuse;\n\ttotalSpecular += spotSpecular;\n\n#endif\n\n#ifdef METAL\n\n\tgl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient + totalSpecular );\n\n#else\n\n\tgl_FragColor.xyz = gl_FragColor.xyz * ( emissive + totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n\n#endif",We.ShaderChunk.fog_pars_fragment="#ifdef USE_FOG\n\n\tuniform vec3 fogColor;\n\n\t#ifdef FOG_EXP2\n\n\t\tuniform float fogDensity;\n\n\t#else\n\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n\n#endif",We.ShaderChunk.morphnormal_vertex="#ifdef USE_MORPHNORMALS\n\n\tvec3 morphedNormal = vec3( 0.0 );\n\n\tmorphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tmorphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tmorphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tmorphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n\n\tmorphedNormal += normal;\n\n#endif",We.ShaderChunk.envmap_pars_fragment="#ifdef USE_ENVMAP\n\n\tuniform float reflectivity;\n\tuniform samplerCube envMap;\n\tuniform float flipEnvMap;\n\tuniform int combine;\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\tuniform bool useRefract;\n\t\tuniform float refractionRatio;\n\n\t#else\n\n\t\tvarying vec3 vReflect;\n\n\t#endif\n\n#endif",We.ShaderChunk.logdepthbuf_fragment="#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n\n#endif",We.ShaderChunk.normalmap_pars_fragment="#ifdef USE_NORMALMAP\n\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\n\t\t\t// Per-Pixel Tangent Space Normal Mapping\n\t\t\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\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\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\n\t}\n\n#endif\n",We.ShaderChunk.lights_phong_pars_vertex="#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n\tvarying vec3 vWorldPosition;\n\n#endif\n",We.ShaderChunk.lightmap_pars_fragment="#ifdef USE_LIGHTMAP\n\n\tvarying vec2 vUv2;\n\tuniform sampler2D lightMap;\n\n#endif",We.ShaderChunk.shadowmap_vertex="#ifdef USE_SHADOWMAP\n\n\tfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\n\n\t\tvShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;\n\n\t}\n\n#endif",We.ShaderChunk.lights_phong_vertex="#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n\tvWorldPosition = worldPosition.xyz;\n\n#endif",We.ShaderChunk.map_fragment="#ifdef USE_MAP\n\n\tvec4 texelColor = texture2D( map, vUv );\n\n\t#ifdef GAMMA_INPUT\n\n\t\ttexelColor.xyz *= texelColor.xyz;\n\n\t#endif\n\n\tgl_FragColor = gl_FragColor * texelColor;\n\n#endif",We.ShaderChunk.lightmap_vertex="#ifdef USE_LIGHTMAP\n\n\tvUv2 = uv2;\n\n#endif",We.ShaderChunk.map_particle_fragment="#ifdef USE_MAP\n\n\tgl_FragColor = gl_FragColor * texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) );\n\n#endif",We.ShaderChunk.color_pars_fragment="#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n",We.ShaderChunk.color_vertex="#ifdef USE_COLOR\n\n\t#ifdef GAMMA_INPUT\n\n\t\tvColor = color * color;\n\n\t#else\n\n\t\tvColor = color;\n\n\t#endif\n\n#endif",We.ShaderChunk.skinning_vertex="#ifdef USE_SKINNING\n\n\t#ifdef USE_MORPHTARGETS\n\n\tvec4 skinVertex = bindMatrix * vec4( morphed, 1.0 );\n\n\t#else\n\n\tvec4 skinVertex = bindMatrix * vec4( position, 1.0 );\n\n\t#endif\n\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n\n#endif\n",We.ShaderChunk.envmap_pars_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )\n\n\tvarying vec3 vReflect;\n\n\tuniform float refractionRatio;\n\tuniform bool useRefract;\n\n#endif\n",We.ShaderChunk.linear_to_gamma_fragment="#ifdef GAMMA_OUTPUT\n\n\tgl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n\n#endif",We.ShaderChunk.color_pars_vertex="#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif",We.ShaderChunk.lights_lambert_pars_vertex="uniform vec3 ambient;\nuniform vec3 diffuse;\nuniform vec3 emissive;\n\nuniform vec3 ambientLightColor;\n\n#if MAX_DIR_LIGHTS > 0\n\n\tuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n\tuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n\tuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n\tuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n\tuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n\tuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n\tuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n\n#endif\n\n#ifdef WRAP_AROUND\n\n\tuniform vec3 wrapRGB;\n\n#endif\n",We.ShaderChunk.map_pars_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )\n\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n\n#endif\n",We.ShaderChunk.envmap_fragment="#ifdef USE_ENVMAP\n\n\tvec3 reflectVec;\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\n\t\t// http://en.wikibooks.org/wiki/GLSL_Programming/Applying_Matrix_Transformations\n\t\t// Transforming Normal Vectors with the Inverse Transformation\n\n\t\tvec3 worldNormal = normalize( vec3( vec4( normal, 0.0 ) * viewMatrix ) );\n\n\t\tif ( useRefract ) {\n\n\t\t\treflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t\t} else { \n\n\t\t\treflectVec = reflect( cameraToVertex, worldNormal );\n\n\t\t}\n\n\t#else\n\n\t\treflectVec = vReflect;\n\n\t#endif\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tfloat flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n\t\tvec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n\t#else\n\n\t\tvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n\t#endif\n\n\t#ifdef GAMMA_INPUT\n\n\t\tcubeColor.xyz *= cubeColor.xyz;\n\n\t#endif\n\n\tif ( combine == 1 ) {\n\n\t\tgl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularStrength * reflectivity );\n\n\t} else if ( combine == 2 ) {\n\n\t\tgl_FragColor.xyz += cubeColor.xyz * specularStrength * reflectivity;\n\n\t} else {\n\n\t\tgl_FragColor.xyz = mix( gl_FragColor.xyz, gl_FragColor.xyz * cubeColor.xyz, specularStrength * reflectivity );\n\n\t}\n\n#endif",We.ShaderChunk.specularmap_pars_fragment="#ifdef USE_SPECULARMAP\n\n\tuniform sampler2D specularMap;\n\n#endif",We.ShaderChunk.logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\n\n\tgl_Position.z = log2(max(1e-6, gl_Position.w + 1.0)) * logDepthBufFC;\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\n#else\n\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\n\t#endif\n\n#endif",We.ShaderChunk.morphtarget_pars_vertex="#ifdef USE_MORPHTARGETS\n\n\t#ifndef USE_MORPHNORMALS\n\n\tuniform float morphTargetInfluences[ 8 ];\n\n\t#else\n\n\tuniform float morphTargetInfluences[ 4 ];\n\n\t#endif\n\n#endif",We.ShaderChunk.specularmap_fragment="float specularStrength;\n\n#ifdef USE_SPECULARMAP\n\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n\n#else\n\n\tspecularStrength = 1.0;\n\n#endif",We.ShaderChunk.fog_fragment="#ifdef USE_FOG\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\n\t#else\n\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\n\t#endif\n\n\t#ifdef FOG_EXP2\n\n\t\tconst float LOG2 = 1.442695;\n\t\tfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\n\t\tfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n\n\t#else\n\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n\n\t#endif\n\t\n\tgl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n\n#endif",We.ShaderChunk.bumpmap_pars_fragment="#ifdef USE_BUMPMAP\n\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\n\t\t\t// Derivative maps - bump mapping unparametrized surfaces by Morten Mikkelsen\n\t\t\t//\thttp://mmikkelsen3d.blogspot.sk/2011/07/derivative-maps.html\n\n\t\t\t// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\n\n\tvec2 dHdxy_fwd() {\n\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\n\t\treturn vec2( dBx, dBy );\n\n\t}\n\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\t\t// normalized\n\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\n\t}\n\n#endif",We.ShaderChunk.defaultnormal_vertex="vec3 objectNormal;\n\n#ifdef USE_SKINNING\n\n\tobjectNormal = skinnedNormal.xyz;\n\n#endif\n\n#if !defined( USE_SKINNING ) && defined( USE_MORPHNORMALS )\n\n\tobjectNormal = morphedNormal;\n\n#endif\n\n#if !defined( USE_SKINNING ) && ! defined( USE_MORPHNORMALS )\n\n\tobjectNormal = normal;\n\n#endif\n\n#ifdef FLIP_SIDED\n\n\tobjectNormal = -objectNormal;\n\n#endif\n\nvec3 transformedNormal = normalMatrix * objectNormal;",We.ShaderChunk.lights_phong_pars_fragment="uniform vec3 ambientLightColor;\n\n#if MAX_DIR_LIGHTS > 0\n\n\tuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\n\tuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n\n#endif\n\n#if MAX_HEMI_LIGHTS > 0\n\n\tuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];\n\tuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];\n\n#endif\n\n#if MAX_POINT_LIGHTS > 0\n\n\tuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n\n\tuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n\tuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0\n\n\tuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];\n\tuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];\n\tuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];\n\n\tuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];\n\n#endif\n\n#if MAX_SPOT_LIGHTS > 0 || defined( USE_BUMPMAP ) || defined( USE_ENVMAP )\n\n\tvarying vec3 vWorldPosition;\n\n#endif\n\n#ifdef WRAP_AROUND\n\n\tuniform vec3 wrapRGB;\n\n#endif\n\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",We.ShaderChunk.skinbase_vertex="#ifdef USE_SKINNING\n\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n\n#endif",We.ShaderChunk.map_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP )\n\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n\n#endif",We.ShaderChunk.lightmap_fragment="#ifdef USE_LIGHTMAP\n\n\tgl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n\n#endif",We.ShaderChunk.shadowmap_pars_vertex="#ifdef USE_SHADOWMAP\n\n\tvarying vec4 vShadowCoord[ MAX_SHADOWS ];\n\tuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n\n#endif",We.ShaderChunk.color_fragment="#ifdef USE_COLOR\n\n\tgl_FragColor = gl_FragColor * vec4( vColor, 1.0 );\n\n#endif",We.ShaderChunk.morphtarget_vertex="#ifdef USE_MORPHTARGETS\n\n\tvec3 morphed = vec3( 0.0 );\n\tmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\tmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\tmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\tmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\n\t#ifndef USE_MORPHNORMALS\n\n\tmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\tmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\tmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\tmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\n\t#endif\n\n\tmorphed += position;\n\n#endif",We.ShaderChunk.envmap_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG )\n\n\tvec3 worldNormal = mat3( modelMatrix[ 0 ].xyz, modelMatrix[ 1 ].xyz, modelMatrix[ 2 ].xyz ) * objectNormal;\n\tworldNormal = normalize( worldNormal );\n\n\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\n\tif ( useRefract ) {\n\n\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t} else {\n\n\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\n\t}\n\n#endif",We.ShaderChunk.shadowmap_fragment="#ifdef USE_SHADOWMAP\n\n\t#ifdef SHADOWMAP_DEBUG\n\n\t\tvec3 frustumColors[3];\n\t\tfrustumColors[0] = vec3( 1.0, 0.5, 0.0 );\n\t\tfrustumColors[1] = vec3( 0.0, 1.0, 0.8 );\n\t\tfrustumColors[2] = vec3( 0.0, 0.5, 1.0 );\n\n\t#endif\n\n\t#ifdef SHADOWMAP_CASCADE\n\n\t\tint inFrustumCount = 0;\n\n\t#endif\n\n\tfloat fDepth;\n\tvec3 shadowColor = vec3( 1.0 );\n\n\tfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\n\n\t\tvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\n\n\t\t\t\t// if ( something && something ) breaks ATI OpenGL shader compiler\n\t\t\t\t// if ( all( something, something ) ) using this instead\n\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\n\t\t\t\t// don't shadow pixels outside of light frustum\n\t\t\t\t// use just first frustum (for cascades)\n\t\t\t\t// don't shadow pixels behind far plane of light frustum\n\n\t\t#ifdef SHADOWMAP_CASCADE\n\n\t\t\tinFrustumCount += int( inFrustum );\n\t\t\tbvec3 frustumTestVec = bvec3( inFrustum, inFrustumCount == 1, shadowCoord.z <= 1.0 );\n\n\t\t#else\n\n\t\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n\t\t#endif\n\n\t\tbool frustumTest = all( frustumTestVec );\n\n\t\tif ( frustumTest ) {\n\n\t\t\tshadowCoord.z += shadowBias[ i ];\n\n\t\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\n\t\t\t\t\t\t// Percentage-close filtering\n\t\t\t\t\t\t// (9 pixel kernel)\n\t\t\t\t\t\t// http://fabiensanglard.net/shadowmappingPCF/\n\n\t\t\t\tfloat shadow = 0.0;\n\n\t\t/*\n\t\t\t\t\t\t// nested loops breaks shader compiler / validator on some ATI cards when using OpenGL\n\t\t\t\t\t\t// must enroll loop manually\n\n\t\t\t\tfor ( float y = -1.25; y <= 1.25; y += 1.25 )\n\t\t\t\t\tfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\n\n\t\t\t\t\t\tvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\n\n\t\t\t\t\t\t\t\t// doesn't seem to produce any noticeable visual difference compared to simple texture2D lookup\n\t\t\t\t\t\t\t\t//vec4 rgbaDepth = texture2DProj( shadowMap[ i ], vec4( vShadowCoord[ i ].w * ( vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy ), 0.05, vShadowCoord[ i ].w ) );\n\n\t\t\t\t\t\tfloat fDepth = unpackDepth( rgbaDepth );\n\n\t\t\t\t\t\tif ( fDepth < shadowCoord.z )\n\t\t\t\t\t\t\tshadow += 1.0;\n\n\t\t\t\t}\n\n\t\t\t\tshadow /= 9.0;\n\n\t\t*/\n\n\t\t\t\tconst float shadowDelta = 1.0 / 9.0;\n\n\t\t\t\tfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\n\t\t\t\tfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\n\n\t\t\t\tfloat dx0 = -1.25 * xPixelOffset;\n\t\t\t\tfloat dy0 = -1.25 * yPixelOffset;\n\t\t\t\tfloat dx1 = 1.25 * xPixelOffset;\n\t\t\t\tfloat dy1 = 1.25 * yPixelOffset;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\n\t\t\t\tif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\n\n\t\t\t\tshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n\n\t\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n\t\t\t\t\t\t// Percentage-close filtering\n\t\t\t\t\t\t// (9 pixel kernel)\n\t\t\t\t\t\t// http://fabiensanglard.net/shadowmappingPCF/\n\n\t\t\t\tfloat shadow = 0.0;\n\n\t\t\t\tfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\n\t\t\t\tfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\n\n\t\t\t\tfloat dx0 = -1.0 * xPixelOffset;\n\t\t\t\tfloat dy0 = -1.0 * yPixelOffset;\n\t\t\t\tfloat dx1 = 1.0 * xPixelOffset;\n\t\t\t\tfloat dy1 = 1.0 * yPixelOffset;\n\n\t\t\t\tmat3 shadowKernel;\n\t\t\t\tmat3 depthKernel;\n\n\t\t\t\tdepthKernel[0][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\n\t\t\t\tdepthKernel[0][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\n\t\t\t\tdepthKernel[0][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\n\t\t\t\tdepthKernel[1][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\n\t\t\t\tdepthKernel[1][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\n\t\t\t\tdepthKernel[1][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\n\t\t\t\tdepthKernel[2][0] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\n\t\t\t\tdepthKernel[2][1] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\n\t\t\t\tdepthKernel[2][2] = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\n\n\t\t\t\tvec3 shadowZ = vec3( shadowCoord.z );\n\t\t\t\tshadowKernel[0] = vec3(lessThan(depthKernel[0], shadowZ ));\n\t\t\t\tshadowKernel[0] *= vec3(0.25);\n\n\t\t\t\tshadowKernel[1] = vec3(lessThan(depthKernel[1], shadowZ ));\n\t\t\t\tshadowKernel[1] *= vec3(0.25);\n\n\t\t\t\tshadowKernel[2] = vec3(lessThan(depthKernel[2], shadowZ ));\n\t\t\t\tshadowKernel[2] *= vec3(0.25);\n\n\t\t\t\tvec2 fractionalCoord = 1.0 - fract( shadowCoord.xy * shadowMapSize[i].xy );\n\n\t\t\t\tshadowKernel[0] = mix( shadowKernel[1], shadowKernel[0], fractionalCoord.x );\n\t\t\t\tshadowKernel[1] = mix( shadowKernel[2], shadowKernel[1], fractionalCoord.x );\n\n\t\t\t\tvec4 shadowValues;\n\t\t\t\tshadowValues.x = mix( shadowKernel[0][1], shadowKernel[0][0], fractionalCoord.y );\n\t\t\t\tshadowValues.y = mix( shadowKernel[0][2], shadowKernel[0][1], fractionalCoord.y );\n\t\t\t\tshadowValues.z = mix( shadowKernel[1][1], shadowKernel[1][0], fractionalCoord.y );\n\t\t\t\tshadowValues.w = mix( shadowKernel[1][2], shadowKernel[1][1], fractionalCoord.y );\n\n\t\t\t\tshadow = dot( shadowValues, vec4( 1.0 ) );\n\n\t\t\t\tshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n\n\t\t\t#else\n\n\t\t\t\tvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\n\t\t\t\tfloat fDepth = unpackDepth( rgbaDepth );\n\n\t\t\t\tif ( fDepth < shadowCoord.z )\n\n\t\t// spot with multiple shadows is darker\n\n\t\t\t\t\tshadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n\n\t\t// spot with multiple shadows has the same color as single shadow spot\n\n\t\t// \t\t\t\t\tshadowColor = min( shadowColor, vec3( shadowDarkness[ i ] ) );\n\n\t\t\t#endif\n\n\t\t}\n\n\n\t\t#ifdef SHADOWMAP_DEBUG\n\n\t\t\t#ifdef SHADOWMAP_CASCADE\n\n\t\t\t\tif ( inFrustum && inFrustumCount == 1 ) gl_FragColor.xyz *= frustumColors[ i ];\n\n\t\t\t#else\n\n\t\t\t\tif ( inFrustum ) gl_FragColor.xyz *= frustumColors[ i ];\n\n\t\t\t#endif\n\n\t\t#endif\n\n\t}\n\n\t#ifdef GAMMA_OUTPUT\n\n\t\tshadowColor *= shadowColor;\n\n\t#endif\n\n\tgl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n\n#endif\n",We.ShaderChunk.worldpos_vertex="#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\n\t#ifdef USE_SKINNING\n\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\n\t#endif\n\n\t#if defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\n\n\t\tvec4 worldPosition = modelMatrix * vec4( morphed, 1.0 );\n\n\t#endif\n\n\t#if ! defined( USE_MORPHTARGETS ) && ! defined( USE_SKINNING )\n\n\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\n\n\t#endif\n\n#endif",We.ShaderChunk.shadowmap_pars_fragment="#ifdef USE_SHADOWMAP\n\n\tuniform sampler2D shadowMap[ MAX_SHADOWS ];\n\tuniform vec2 shadowMapSize[ MAX_SHADOWS ];\n\n\tuniform float shadowDarkness[ MAX_SHADOWS ];\n\tuniform float shadowBias[ MAX_SHADOWS ];\n\n\tvarying vec4 vShadowCoord[ MAX_SHADOWS ];\n\n\tfloat unpackDepth( const in vec4 rgba_depth ) {\n\n\t\tconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n\t\tfloat depth = dot( rgba_depth, bit_shift );\n\t\treturn depth;\n\n\t}\n\n#endif",We.ShaderChunk.skinning_pars_vertex="#ifdef USE_SKINNING\n\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\n\t#ifdef BONE_TEXTURE\n\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\n\t\t\ty = dy * ( y + 0.5 );\n\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\n\t\t\treturn bone;\n\n\t\t}\n\n\t#else\n\n\t\tuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tmat4 bone = boneGlobalMatrices[ int(i) ];\n\t\t\treturn bone;\n\n\t\t}\n\n\t#endif\n\n#endif\n",We.ShaderChunk.logdepthbuf_pars_fragment="#ifdef USE_LOGDEPTHBUF\n\n\tuniform float logDepthBufFC;\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\t#extension GL_EXT_frag_depth : enable\n\t\tvarying float vFragDepth;\n\n\t#endif\n\n#endif",We.ShaderChunk.alphamap_fragment="#ifdef USE_ALPHAMAP\n\n\tgl_FragColor.a *= texture2D( alphaMap, vUv ).g;\n\n#endif\n",We.ShaderChunk.alphamap_pars_fragment="#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n",We.UniformsUtils={merge:function(t){for(var e={},r=0;r<t.length;r++){var i=this.clone(t[r]);for(var n in i)e[n]=i[n]}return e},clone:function(t){var e={};for(var r in t)for(var i in e[r]={},t[r]){var n=t[r][i];n instanceof We.Color||n instanceof We.Vector2||n instanceof We.Vector3||n instanceof We.Vector4||n instanceof We.Matrix4||n instanceof We.Texture?e[r][i]=n.clone():n instanceof Array?e[r][i]=n.slice():e[r][i]=n}return e}},We.UniformsLib={common:{diffuse:{type:"c",value:new We.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new We.Vector4(0,0,1,1)},lightMap:{type:"t",value:null},specularMap:{type:"t",value:null},alphaMap:{type:"t",value:null},envMap:{type:"t",value:null},flipEnvMap:{type:"f",value:-1},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:.98},combine:{type:"i",value:0},morphTargetInfluences:{type:"f",value:0}},bump:{bumpMap:{type:"t",value:null},bumpScale:{type:"f",value:1}},normalmap:{normalMap:{type:"t",value:null},normalScale:{type:"v2",value:new We.Vector2(1,1)}},fog:{fogDensity:{type:"f",value:25e-5},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},fogColor:{type:"c",value:new We.Color(16777215)}},lights:{ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},hemisphereLightDirection:{type:"fv",value:[]},hemisphereLightSkyColor:{type:"fv",value:[]},hemisphereLightGroundColor:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightDistance:{type:"fv1",value:[]},spotLightColor:{type:"fv",value:[]},spotLightPosition:{type:"fv",value:[]},spotLightDirection:{type:"fv",value:[]},spotLightDistance:{type:"fv1",value:[]},spotLightAngleCos:{type:"fv1",value:[]},spotLightExponent:{type:"fv1",value:[]}},particle:{psColor:{type:"c",value:new We.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:null},fogDensity:{type:"f",value:25e-5},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2e3},fogColor:{type:"c",value:new We.Color(16777215)}},shadowmap:{shadowMap:{type:"tv",value:[]},shadowMapSize:{type:"v2v",value:[]},shadowBias:{type:"fv1",value:[]},shadowDarkness:{type:"fv1",value:[]},shadowMatrix:{type:"m4v",value:[]}}},We.ShaderLib={basic:{uniforms:We.UniformsUtils.merge([We.UniformsLib.common,We.UniformsLib.fog,We.UniformsLib.shadowmap]),vertexShader:[We.ShaderChunk.map_pars_vertex,We.ShaderChunk.lightmap_pars_vertex,We.ShaderChunk.envmap_pars_vertex,We.ShaderChunk.color_pars_vertex,We.ShaderChunk.morphtarget_pars_vertex,We.ShaderChunk.skinning_pars_vertex,We.ShaderChunk.shadowmap_pars_vertex,We.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",We.ShaderChunk.map_vertex,We.ShaderChunk.lightmap_vertex,We.ShaderChunk.color_vertex,We.ShaderChunk.skinbase_vertex,"\t#ifdef USE_ENVMAP",We.ShaderChunk.morphnormal_vertex,We.ShaderChunk.skinnormal_vertex,We.ShaderChunk.defaultnormal_vertex,"\t#endif",We.ShaderChunk.morphtarget_vertex,We.ShaderChunk.skinning_vertex,We.ShaderChunk.default_vertex,We.ShaderChunk.logdepthbuf_vertex,We.ShaderChunk.worldpos_vertex,We.ShaderChunk.envmap_vertex,We.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;","uniform float opacity;",We.ShaderChunk.color_pars_fragment,We.ShaderChunk.map_pars_fragment,We.ShaderChunk.alphamap_pars_fragment,We.ShaderChunk.lightmap_pars_fragment,We.ShaderChunk.envmap_pars_fragment,We.ShaderChunk.fog_pars_fragment,We.ShaderChunk.shadowmap_pars_fragment,We.ShaderChunk.specularmap_pars_fragment,We.ShaderChunk.logdepthbuf_pars_fragment,"void main() {","\tgl_FragColor = vec4( diffuse, opacity );",We.ShaderChunk.logdepthbuf_fragment,We.ShaderChunk.map_fragment,We.ShaderChunk.alphamap_fragment,We.ShaderChunk.alphatest_fragment,We.ShaderChunk.specularmap_fragment,We.ShaderChunk.lightmap_fragment,We.ShaderChunk.color_fragment,We.ShaderChunk.envmap_fragment,We.ShaderChunk.shadowmap_fragment,We.ShaderChunk.linear_to_gamma_fragment,We.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:We.UniformsUtils.merge([We.UniformsLib.common,We.UniformsLib.fog,We.UniformsLib.lights,We.UniformsLib.shadowmap,{ambient:{type:"c",value:new We.Color(16777215)},emissive:{type:"c",value:new We.Color(0)},wrapRGB:{type:"v3",value:new We.Vector3(1,1,1)}}]),vertexShader:["#define LAMBERT","varying vec3 vLightFront;","#ifdef DOUBLE_SIDED","\tvarying vec3 vLightBack;","#endif",We.ShaderChunk.map_pars_vertex,We.ShaderChunk.lightmap_pars_vertex,We.ShaderChunk.envmap_pars_vertex,We.ShaderChunk.lights_lambert_pars_vertex,We.ShaderChunk.color_pars_vertex,We.ShaderChunk.morphtarget_pars_vertex,We.ShaderChunk.skinning_pars_vertex,We.ShaderChunk.shadowmap_pars_vertex,We.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",We.ShaderChunk.map_vertex,We.ShaderChunk.lightmap_vertex,We.ShaderChunk.color_vertex,We.ShaderChunk.morphnormal_vertex,We.ShaderChunk.skinbase_vertex,We.ShaderChunk.skinnormal_vertex,We.ShaderChunk.defaultnormal_vertex,We.ShaderChunk.morphtarget_vertex,We.ShaderChunk.skinning_vertex,We.ShaderChunk.default_vertex,We.ShaderChunk.logdepthbuf_vertex,We.ShaderChunk.worldpos_vertex,We.ShaderChunk.envmap_vertex,We.ShaderChunk.lights_lambert_vertex,We.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;","varying vec3 vLightFront;","#ifdef DOUBLE_SIDED","\tvarying vec3 vLightBack;","#endif",We.ShaderChunk.color_pars_fragment,We.ShaderChunk.map_pars_fragment,We.ShaderChunk.alphamap_pars_fragment,We.ShaderChunk.lightmap_pars_fragment,We.ShaderChunk.envmap_pars_fragment,We.ShaderChunk.fog_pars_fragment,We.ShaderChunk.shadowmap_pars_fragment,We.ShaderChunk.specularmap_pars_fragment,We.ShaderChunk.logdepthbuf_pars_fragment,"void main() {","\tgl_FragColor = vec4( vec3( 1.0 ), opacity );",We.ShaderChunk.logdepthbuf_fragment,We.ShaderChunk.map_fragment,We.ShaderChunk.alphamap_fragment,We.ShaderChunk.alphatest_fragment,We.ShaderChunk.specularmap_fragment,"\t#ifdef DOUBLE_SIDED","\t\tif ( gl_FrontFacing )","\t\t\tgl_FragColor.xyz *= vLightFront;","\t\telse","\t\t\tgl_FragColor.xyz *= vLightBack;","\t#else","\t\tgl_FragColor.xyz *= vLightFront;","\t#endif",We.ShaderChunk.lightmap_fragment,We.ShaderChunk.color_fragment,We.ShaderChunk.envmap_fragment,We.ShaderChunk.shadowmap_fragment,We.ShaderChunk.linear_to_gamma_fragment,We.ShaderChunk.fog_fragment,"}"].join("\n")},phong:{uniforms:We.UniformsUtils.merge([We.UniformsLib.common,We.UniformsLib.bump,We.UniformsLib.normalmap,We.UniformsLib.fog,We.UniformsLib.lights,We.UniformsLib.shadowmap,{ambient:{type:"c",value:new We.Color(16777215)},emissive:{type:"c",value:new We.Color(0)},specular:{type:"c",value:new We.Color(1118481)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",value:new We.Vector3(1,1,1)}}]),vertexShader:["#define PHONG","varying vec3 vViewPosition;","varying vec3 vNormal;",We.ShaderChunk.map_pars_vertex,We.ShaderChunk.lightmap_pars_vertex,We.ShaderChunk.envmap_pars_vertex,We.ShaderChunk.lights_phong_pars_vertex,We.ShaderChunk.color_pars_vertex,We.ShaderChunk.morphtarget_pars_vertex,We.ShaderChunk.skinning_pars_vertex,We.ShaderChunk.shadowmap_pars_vertex,We.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",We.ShaderChunk.map_vertex,We.ShaderChunk.lightmap_vertex,We.ShaderChunk.color_vertex,We.ShaderChunk.morphnormal_vertex,We.ShaderChunk.skinbase_vertex,We.ShaderChunk.skinnormal_vertex,We.ShaderChunk.defaultnormal_vertex,"\tvNormal = normalize( transformedNormal );",We.ShaderChunk.morphtarget_vertex,We.ShaderChunk.skinning_vertex,We.ShaderChunk.default_vertex,We.ShaderChunk.logdepthbuf_vertex,"\tvViewPosition = -mvPosition.xyz;",We.ShaderChunk.worldpos_vertex,We.ShaderChunk.envmap_vertex,We.ShaderChunk.lights_phong_vertex,We.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["#define PHONG","uniform vec3 diffuse;","uniform float opacity;","uniform vec3 ambient;","uniform vec3 emissive;","uniform vec3 specular;","uniform float shininess;",We.ShaderChunk.color_pars_fragment,We.ShaderChunk.map_pars_fragment,We.ShaderChunk.alphamap_pars_fragment,We.ShaderChunk.lightmap_pars_fragment,We.ShaderChunk.envmap_pars_fragment,We.ShaderChunk.fog_pars_fragment,We.ShaderChunk.lights_phong_pars_fragment,We.ShaderChunk.shadowmap_pars_fragment,We.ShaderChunk.bumpmap_pars_fragment,We.ShaderChunk.normalmap_pars_fragment,We.ShaderChunk.specularmap_pars_fragment,We.ShaderChunk.logdepthbuf_pars_fragment,"void main() {","\tgl_FragColor = vec4( vec3( 1.0 ), opacity );",We.ShaderChunk.logdepthbuf_fragment,We.ShaderChunk.map_fragment,We.ShaderChunk.alphamap_fragment,We.ShaderChunk.alphatest_fragment,We.ShaderChunk.specularmap_fragment,We.ShaderChunk.lights_phong_fragment,We.ShaderChunk.lightmap_fragment,We.ShaderChunk.color_fragment,We.ShaderChunk.envmap_fragment,We.ShaderChunk.shadowmap_fragment,We.ShaderChunk.linear_to_gamma_fragment,We.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:We.UniformsUtils.merge([We.UniformsLib.particle,We.UniformsLib.shadowmap]),vertexShader:["uniform float size;","uniform float scale;",We.ShaderChunk.color_pars_vertex,We.ShaderChunk.shadowmap_pars_vertex,We.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",We.ShaderChunk.color_vertex,"\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","\t#ifdef USE_SIZEATTENUATION","\t\tgl_PointSize = size * ( scale / length( mvPosition.xyz ) );","\t#else","\t\tgl_PointSize = size;","\t#endif","\tgl_Position = projectionMatrix * mvPosition;",We.ShaderChunk.logdepthbuf_vertex,We.ShaderChunk.worldpos_vertex,We.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;","uniform float opacity;",We.ShaderChunk.color_pars_fragment,We.ShaderChunk.map_particle_pars_fragment,We.ShaderChunk.fog_pars_fragment,We.ShaderChunk.shadowmap_pars_fragment,We.ShaderChunk.logdepthbuf_pars_fragment,"void main() {","\tgl_FragColor = vec4( psColor, opacity );",We.ShaderChunk.logdepthbuf_fragment,We.ShaderChunk.map_particle_fragment,We.ShaderChunk.alphatest_fragment,We.ShaderChunk.color_fragment,We.ShaderChunk.shadowmap_fragment,We.ShaderChunk.fog_fragment,"}"].join("\n")},dashed:{uniforms:We.UniformsUtils.merge([We.UniformsLib.common,We.UniformsLib.fog,{scale:{type:"f",value:1},dashSize:{type:"f",value:1},totalSize:{type:"f",value:2}}]),vertexShader:["uniform float scale;","attribute float lineDistance;","varying float vLineDistance;",We.ShaderChunk.color_pars_vertex,We.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",We.ShaderChunk.color_vertex,"\tvLineDistance = scale * lineDistance;","\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","\tgl_Position = projectionMatrix * mvPosition;",We.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;","uniform float opacity;","uniform float dashSize;","uniform float totalSize;","varying float vLineDistance;",We.ShaderChunk.color_pars_fragment,We.ShaderChunk.fog_pars_fragment,We.ShaderChunk.logdepthbuf_pars_fragment,"void main() {","\tif ( mod( vLineDistance, totalSize ) > dashSize ) {","\t\tdiscard;","\t}","\tgl_FragColor = vec4( diffuse, opacity );",We.ShaderChunk.logdepthbuf_fragment,We.ShaderChunk.color_fragment,We.ShaderChunk.fog_fragment,"}"].join("\n")},depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2e3},opacity:{type:"f",value:1}},vertexShader:[We.ShaderChunk.morphtarget_pars_vertex,We.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",We.ShaderChunk.morphtarget_vertex,We.ShaderChunk.default_vertex,We.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float mNear;","uniform float mFar;","uniform float opacity;",We.ShaderChunk.logdepthbuf_pars_fragment,"void main() {",We.ShaderChunk.logdepthbuf_fragment,"\t#ifdef USE_LOGDEPTHBUF_EXT","\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;","\t#else","\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;","\t#endif","\tfloat color = 1.0 - smoothstep( mNear, mFar, depth );","\tgl_FragColor = vec4( vec3( color ), opacity );","}"].join("\n")},normal:{uniforms:{opacity:{type:"f",value:1}},vertexShader:["varying vec3 vNormal;",We.ShaderChunk.morphtarget_pars_vertex,We.ShaderChunk.logdepthbuf_pars_vertex,"void main() {","\tvNormal = normalize( normalMatrix * normal );",We.ShaderChunk.morphtarget_vertex,We.ShaderChunk.default_vertex,We.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;","varying vec3 vNormal;",We.ShaderChunk.logdepthbuf_pars_fragment,"void main() {","\tgl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );",We.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},normalmap:{uniforms:We.UniformsUtils.merge([We.UniformsLib.fog,We.UniformsLib.lights,We.UniformsLib.shadowmap,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},enableReflection:{type:"i",value:0},enableDisplacement:{type:"i",value:0},tDisplacement:{type:"t",value:null},tDiffuse:{type:"t",value:null},tCube:{type:"t",value:null},tNormal:{type:"t",value:null},tSpecular:{type:"t",value:null},tAO:{type:"t",value:null},uNormalScale:{type:"v2",value:new We.Vector2(1,1)},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},diffuse:{type:"c",value:new We.Color(16777215)},specular:{type:"c",value:new We.Color(1118481)},ambient:{type:"c",value:new We.Color(16777215)},shininess:{type:"f",value:30},opacity:{type:"f",value:1},useRefract:{type:"i",value:0},refractionRatio:{type:"f",value:.98},reflectivity:{type:"f",value:.5},uOffset:{type:"v2",value:new We.Vector2(0,0)},uRepeat:{type:"v2",value:new We.Vector2(1,1)},wrapRGB:{type:"v3",value:new We.Vector3(1,1,1)}}]),fragmentShader:["uniform vec3 ambient;","uniform vec3 diffuse;","uniform vec3 specular;","uniform float shininess;","uniform float opacity;","uniform bool enableDiffuse;","uniform bool enableSpecular;","uniform bool enableAO;","uniform bool enableReflection;","uniform sampler2D tDiffuse;","uniform sampler2D tNormal;","uniform sampler2D tSpecular;","uniform sampler2D tAO;","uniform samplerCube tCube;","uniform vec2 uNormalScale;","uniform bool useRefract;","uniform float refractionRatio;","uniform float reflectivity;","varying vec3 vTangent;","varying vec3 vBinormal;","varying vec3 vNormal;","varying vec2 vUv;","uniform vec3 ambientLightColor;","#if MAX_DIR_LIGHTS > 0","\tuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];","\tuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];","#endif","#if MAX_HEMI_LIGHTS > 0","\tuniform vec3 hemisphereLightSkyColor[ MAX_HEMI_LIGHTS ];","\tuniform vec3 hemisphereLightGroundColor[ MAX_HEMI_LIGHTS ];","\tuniform vec3 hemisphereLightDirection[ MAX_HEMI_LIGHTS ];","#endif","#if MAX_POINT_LIGHTS > 0","\tuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];","\tuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];","\tuniform float pointLightDistance[ MAX_POINT_LIGHTS ];","#endif","#if MAX_SPOT_LIGHTS > 0","\tuniform vec3 spotLightColor[ MAX_SPOT_LIGHTS ];","\tuniform vec3 spotLightPosition[ MAX_SPOT_LIGHTS ];","\tuniform vec3 spotLightDirection[ MAX_SPOT_LIGHTS ];","\tuniform float spotLightAngleCos[ MAX_SPOT_LIGHTS ];","\tuniform float spotLightExponent[ MAX_SPOT_LIGHTS ];","\tuniform float spotLightDistance[ MAX_SPOT_LIGHTS ];","#endif","#ifdef WRAP_AROUND","\tuniform vec3 wrapRGB;","#endif","varying vec3 vWorldPosition;","varying vec3 vViewPosition;",We.ShaderChunk.shadowmap_pars_fragment,We.ShaderChunk.fog_pars_fragment,We.ShaderChunk.logdepthbuf_pars_fragment,"void main() {",We.ShaderChunk.logdepthbuf_fragment,"\tgl_FragColor = vec4( vec3( 1.0 ), opacity );","\tvec3 specularTex = vec3( 1.0 );","\tvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;","\tnormalTex.xy *= uNormalScale;","\tnormalTex = normalize( normalTex );","\tif( enableDiffuse ) {","\t\t#ifdef GAMMA_INPUT","\t\t\tvec4 texelColor = texture2D( tDiffuse, vUv );","\t\t\ttexelColor.xyz *= texelColor.xyz;","\t\t\tgl_FragColor = gl_FragColor * texelColor;","\t\t#else","\t\t\tgl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );","\t\t#endif","\t}","\tif( enableAO ) {","\t\t#ifdef GAMMA_INPUT","\t\t\tvec4 aoColor = texture2D( tAO, vUv );","\t\t\taoColor.xyz *= aoColor.xyz;","\t\t\tgl_FragColor.xyz = gl_FragColor.xyz * aoColor.xyz;","\t\t#else","\t\t\tgl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;","\t\t#endif","\t}",We.ShaderChunk.alphatest_fragment,"\tif( enableSpecular )","\t\tspecularTex = texture2D( tSpecular, vUv ).xyz;","\tmat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( vNormal ) );","\tvec3 finalNormal = tsb * normalTex;","\t#ifdef FLIP_SIDED","\t\tfinalNormal = -finalNormal;","\t#endif","\tvec3 normal = normalize( finalNormal );","\tvec3 viewPosition = normalize( vViewPosition );","\t#if MAX_POINT_LIGHTS > 0","\t\tvec3 pointDiffuse = vec3( 0.0 );","\t\tvec3 pointSpecular = vec3( 0.0 );","\t\tfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {","\t\t\tvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );","\t\t\tvec3 pointVector = lPosition.xyz + vViewPosition.xyz;","\t\t\tfloat pointDistance = 1.0;","\t\t\tif ( pointLightDistance[ i ] > 0.0 )","\t\t\t\tpointDistance = 1.0 - min( ( length( pointVector ) / pointLightDistance[ i ] ), 1.0 );","\t\t\tpointVector = normalize( pointVector );","\t\t\t#ifdef WRAP_AROUND","\t\t\t\tfloat pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );","\t\t\t\tfloat pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );","\t\t\t\tvec3 pointDiffuseWeight = mix( vec3( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );","\t\t\t#else","\t\t\t\tfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );","\t\t\t#endif","\t\t\tpointDiffuse += pointDistance * pointLightColor[ i ] * diffuse * pointDiffuseWeight;","\t\t\tvec3 pointHalfVector = normalize( pointVector + viewPosition );","\t\t\tfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );","\t\t\tfloat pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, shininess ), 0.0 );","\t\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;","\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( pointVector, pointHalfVector ), 0.0 ), 5.0 );","\t\t\tpointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance * specularNormalization;","\t\t}","\t#endif","\t#if MAX_SPOT_LIGHTS > 0","\t\tvec3 spotDiffuse = vec3( 0.0 );","\t\tvec3 spotSpecular = vec3( 0.0 );","\t\tfor ( int i = 0; i < MAX_SPOT_LIGHTS; i ++ ) {","\t\t\tvec4 lPosition = viewMatrix * vec4( spotLightPosition[ i ], 1.0 );","\t\t\tvec3 spotVector = lPosition.xyz + vViewPosition.xyz;","\t\t\tfloat spotDistance = 1.0;","\t\t\tif ( spotLightDistance[ i ] > 0.0 )","\t\t\t\tspotDistance = 1.0 - min( ( length( spotVector ) / spotLightDistance[ i ] ), 1.0 );","\t\t\tspotVector = normalize( spotVector );","\t\t\tfloat spotEffect = dot( spotLightDirection[ i ], normalize( spotLightPosition[ i ] - vWorldPosition ) );","\t\t\tif ( spotEffect > spotLightAngleCos[ i ] ) {","\t\t\t\tspotEffect = max( pow( max( spotEffect, 0.0 ), spotLightExponent[ i ] ), 0.0 );","\t\t\t\t#ifdef WRAP_AROUND","\t\t\t\t\tfloat spotDiffuseWeightFull = max( dot( normal, spotVector ), 0.0 );","\t\t\t\t\tfloat spotDiffuseWeightHalf = max( 0.5 * dot( normal, spotVector ) + 0.5, 0.0 );","\t\t\t\t\tvec3 spotDiffuseWeight = mix( vec3( spotDiffuseWeightFull ), vec3( spotDiffuseWeightHalf ), wrapRGB );","\t\t\t\t#else","\t\t\t\t\tfloat spotDiffuseWeight = max( dot( normal, spotVector ), 0.0 );","\t\t\t\t#endif","\t\t\t\tspotDiffuse += spotDistance * spotLightColor[ i ] * diffuse * spotDiffuseWeight * spotEffect;","\t\t\t\tvec3 spotHalfVector = normalize( spotVector + viewPosition );","\t\t\t\tfloat spotDotNormalHalf = max( dot( normal, spotHalfVector ), 0.0 );","\t\t\t\tfloat spotSpecularWeight = specularTex.r * max( pow( spotDotNormalHalf, shininess ), 0.0 );","\t\t\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;","\t\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( spotVector, spotHalfVector ), 0.0 ), 5.0 );","\t\t\t\tspotSpecular += schlick * spotLightColor[ i ] * spotSpecularWeight * spotDiffuseWeight * spotDistance * specularNormalization * spotEffect;","\t\t\t}","\t\t}","\t#endif","\t#if MAX_DIR_LIGHTS > 0","\t\tvec3 dirDiffuse = vec3( 0.0 );","\t\tvec3 dirSpecular = vec3( 0.0 );","\t\tfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {","\t\t\tvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );","\t\t\tvec3 dirVector = normalize( lDirection.xyz );","\t\t\t#ifdef WRAP_AROUND","\t\t\t\tfloat directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );","\t\t\t\tfloat directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );","\t\t\t\tvec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );","\t\t\t#else","\t\t\t\tfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );","\t\t\t#endif","\t\t\tdirDiffuse += directionalLightColor[ i ] * diffuse * dirDiffuseWeight;","\t\t\tvec3 dirHalfVector = normalize( dirVector + viewPosition );","\t\t\tfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );","\t\t\tfloat dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, shininess ), 0.0 );","\t\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;","\t\t\tvec3 schlick = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( dirVector, dirHalfVector ), 0.0 ), 5.0 );","\t\t\tdirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight * specularNormalization;","\t\t}","\t#endif","\t#if MAX_HEMI_LIGHTS > 0","\t\tvec3 hemiDiffuse = vec3( 0.0 );","\t\tvec3 hemiSpecular = vec3( 0.0 );","\t\tfor( int i = 0; i < MAX_HEMI_LIGHTS; i ++ ) {","\t\t\tvec4 lDirection = viewMatrix * vec4( hemisphereLightDirection[ i ], 0.0 );","\t\t\tvec3 lVector = normalize( lDirection.xyz );","\t\t\tfloat dotProduct = dot( normal, lVector );","\t\t\tfloat hemiDiffuseWeight = 0.5 * dotProduct + 0.5;","\t\t\tvec3 hemiColor = mix( hemisphereLightGroundColor[ i ], hemisphereLightSkyColor[ i ], hemiDiffuseWeight );","\t\t\themiDiffuse += diffuse * hemiColor;","\t\t\tvec3 hemiHalfVectorSky = normalize( lVector + viewPosition );","\t\t\tfloat hemiDotNormalHalfSky = 0.5 * dot( normal, hemiHalfVectorSky ) + 0.5;","\t\t\tfloat hemiSpecularWeightSky = specularTex.r * max( pow( max( hemiDotNormalHalfSky, 0.0 ), shininess ), 0.0 );","\t\t\tvec3 lVectorGround = -lVector;","\t\t\tvec3 hemiHalfVectorGround = normalize( lVectorGround + viewPosition );","\t\t\tfloat hemiDotNormalHalfGround = 0.5 * dot( normal, hemiHalfVectorGround ) + 0.5;","\t\t\tfloat hemiSpecularWeightGround = specularTex.r * max( pow( max( hemiDotNormalHalfGround, 0.0 ), shininess ), 0.0 );","\t\t\tfloat dotProductGround = dot( normal, lVectorGround );","\t\t\tfloat specularNormalization = ( shininess + 2.0 ) / 8.0;","\t\t\tvec3 schlickSky = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVector, hemiHalfVectorSky ), 0.0 ), 5.0 );","\t\t\tvec3 schlickGround = specular + vec3( 1.0 - specular ) * pow( max( 1.0 - dot( lVectorGround, hemiHalfVectorGround ), 0.0 ), 5.0 );","\t\t\themiSpecular += hemiColor * specularNormalization * ( schlickSky * hemiSpecularWeightSky * max( dotProduct, 0.0 ) + schlickGround * hemiSpecularWeightGround * max( dotProductGround, 0.0 ) );","\t\t}","\t#endif","\tvec3 totalDiffuse = vec3( 0.0 );","\tvec3 totalSpecular = vec3( 0.0 );","\t#if MAX_DIR_LIGHTS > 0","\t\ttotalDiffuse += dirDiffuse;","\t\ttotalSpecular += dirSpecular;","\t#endif","\t#if MAX_HEMI_LIGHTS > 0","\t\ttotalDiffuse += hemiDiffuse;","\t\ttotalSpecular += hemiSpecular;","\t#endif","\t#if MAX_POINT_LIGHTS > 0","\t\ttotalDiffuse += pointDiffuse;","\t\ttotalSpecular += pointSpecular;","\t#endif","\t#if MAX_SPOT_LIGHTS > 0","\t\ttotalDiffuse += spotDiffuse;","\t\ttotalSpecular += spotSpecular;","\t#endif","\t#ifdef METAL","\t\tgl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );","\t#else","\t\tgl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;","\t#endif","\tif ( enableReflection ) {","\t\tvec3 vReflect;","\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );","\t\tif ( useRefract ) {","\t\t\tvReflect = refract( cameraToVertex, normal, refractionRatio );","\t\t} else {","\t\t\tvReflect = reflect( cameraToVertex, normal );","\t\t}","\t\tvec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );","\t\t#ifdef GAMMA_INPUT","\t\t\tcubeColor.xyz *= cubeColor.xyz;","\t\t#endif","\t\tgl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularTex.r * reflectivity );","\t}",We.ShaderChunk.shadowmap_fragment,We.ShaderChunk.linear_to_gamma_fragment,We.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;","uniform vec2 uOffset;","uniform vec2 uRepeat;","uniform bool enableDisplacement;","#ifdef VERTEX_TEXTURES","\tuniform sampler2D tDisplacement;","\tuniform float uDisplacementScale;","\tuniform float uDisplacementBias;","#endif","varying vec3 vTangent;","varying vec3 vBinormal;","varying vec3 vNormal;","varying vec2 vUv;","varying vec3 vWorldPosition;","varying vec3 vViewPosition;",We.ShaderChunk.skinning_pars_vertex,We.ShaderChunk.shadowmap_pars_vertex,We.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",We.ShaderChunk.skinbase_vertex,We.ShaderChunk.skinnormal_vertex,"\t#ifdef USE_SKINNING","\t\tvNormal = normalize( normalMatrix * skinnedNormal.xyz );","\t\tvec4 skinnedTangent = skinMatrix * vec4( tangent.xyz, 0.0 );","\t\tvTangent = normalize( normalMatrix * skinnedTangent.xyz );","\t#else","\t\tvNormal = normalize( normalMatrix * normal );","\t\tvTangent = normalize( normalMatrix * tangent.xyz );","\t#endif","\tvBinormal = normalize( cross( vNormal, vTangent ) * tangent.w );","\tvUv = uv * uRepeat + uOffset;","\tvec3 displacedPosition;","\t#ifdef VERTEX_TEXTURES","\t\tif ( enableDisplacement ) {","\t\t\tvec3 dv = texture2D( tDisplacement, uv ).xyz;","\t\t\tfloat df = uDisplacementScale * dv.x + uDisplacementBias;","\t\t\tdisplacedPosition = position + normalize( normal ) * df;","\t\t} else {","\t\t\t#ifdef USE_SKINNING","\t\t\t\tvec4 skinVertex = bindMatrix * vec4( position, 1.0 );","\t\t\t\tvec4 skinned = vec4( 0.0 );","\t\t\t\tskinned += boneMatX * skinVertex * skinWeight.x;","\t\t\t\tskinned += boneMatY * skinVertex * skinWeight.y;","\t\t\t\tskinned += boneMatZ * skinVertex * skinWeight.z;","\t\t\t\tskinned += boneMatW * skinVertex * skinWeight.w;","\t\t\t\tskinned = bindMatrixInverse * skinned;","\t\t\t\tdisplacedPosition = skinned.xyz;","\t\t\t#else","\t\t\t\tdisplacedPosition = position;","\t\t\t#endif","\t\t}","\t#else","\t\t#ifdef USE_SKINNING","\t\t\tvec4 skinVertex = bindMatrix * vec4( position, 1.0 );","\t\t\tvec4 skinned = vec4( 0.0 );","\t\t\tskinned += boneMatX * skinVertex * skinWeight.x;","\t\t\tskinned += boneMatY * skinVertex * skinWeight.y;","\t\t\tskinned += boneMatZ * skinVertex * skinWeight.z;","\t\t\tskinned += boneMatW * skinVertex * skinWeight.w;","\t\t\tskinned = bindMatrixInverse * skinned;","\t\t\tdisplacedPosition = skinned.xyz;","\t\t#else","\t\t\tdisplacedPosition = position;","\t\t#endif","\t#endif","\tvec4 mvPosition = modelViewMatrix * vec4( displacedPosition, 1.0 );","\tvec4 worldPosition = modelMatrix * vec4( displacedPosition, 1.0 );","\tgl_Position = projectionMatrix * mvPosition;",We.ShaderChunk.logdepthbuf_vertex,"\tvWorldPosition = worldPosition.xyz;","\tvViewPosition = -mvPosition.xyz;","\t#ifdef USE_SHADOWMAP","\t\tfor( int i = 0; i < MAX_SHADOWS; i ++ ) {","\t\t\tvShadowCoord[ i ] = shadowMatrix[ i ] * worldPosition;","\t\t}","\t#endif","}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vWorldPosition;",We.ShaderChunk.logdepthbuf_pars_vertex,"void main() {","\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );","\tvWorldPosition = worldPosition.xyz;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",We.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform samplerCube tCube;","uniform float tFlip;","varying vec3 vWorldPosition;",We.ShaderChunk.logdepthbuf_pars_fragment,"void main() {","\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );",We.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[We.ShaderChunk.morphtarget_pars_vertex,We.ShaderChunk.skinning_pars_vertex,We.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",We.ShaderChunk.skinbase_vertex,We.ShaderChunk.morphtarget_vertex,We.ShaderChunk.skinning_vertex,We.ShaderChunk.default_vertex,We.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:[We.ShaderChunk.logdepthbuf_pars_fragment,"vec4 pack_depth( const in float depth ) {","\tconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );","\tconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );","\tvec4 res = mod( depth * bit_shift * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );","\tres -= res.xxyz * bit_mask;","\treturn res;","}","void main() {",We.ShaderChunk.logdepthbuf_fragment,"\t#ifdef USE_LOGDEPTHBUF_EXT","\t\tgl_FragData[ 0 ] = pack_depth( gl_FragDepthEXT );","\t#else","\t\tgl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );","\t#endif","}"].join("\n")}},We.WebGLRenderer=function(t){console.log("THREE.WebGLRenderer",We.REVISION);var M=void 0!==(t=t||{}).canvas?t.canvas:document.createElement("canvas"),e=void 0!==t.context?t.context:null,_=void 0!==t.precision?t.precision:"highp",r=void 0!==t.alpha&&t.alpha,i=void 0===t.depth||t.depth,n=void 0===t.stencil||t.stencil,o=void 0!==t.antialias&&t.antialias,a=void 0===t.premultipliedAlpha||t.premultipliedAlpha,s=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,S=void 0!==t.logarithmicDepthBuffer&&t.logarithmicDepthBuffer,h=new We.Color(0),l=0,c=[],m={},v=[],f=[],p=[],d=[],g=[];this.domElement=M,this.context=null,this.devicePixelRatio=void 0!==t.devicePixelRatio?t.devicePixelRatio:void 0!==He.devicePixelRatio?He.devicePixelRatio:1,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.gammaInput=!1,this.gammaOutput=!1,this.shadowMapEnabled=!1,this.shadowMapType=We.PCFShadowMap,this.shadowMapCullFace=We.CullFaceFront,this.shadowMapDebug=!1,this.shadowMapCascade=!1,this.maxMorphTargets=8,this.maxMorphNormals=4,this.autoScaleCubemaps=!0,this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var zt,O=this,T=[],A=null,y=null,C=-1,x=-1,E=null,L=0,u=-1,w=-1,b=-1,P=-1,R=-1,F=-1,D=-1,U=-1,B=null,k=null,z=null,V=null,N=0,I=0,G=M.width,H=M.height,W=0,j=0,X=new Uint8Array(16),q=new Uint8Array(16),Y=new We.Frustum,K=new We.Matrix4,Z=new We.Matrix4,Q=new We.Vector3,J=new We.Vector3,$=!0,tt={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],anglesCos:[],exponents:[]},hemi:{length:0,skyColors:[],groundColors:[],positions:[]}};try{var et={alpha:r,depth:i,stencil:n,antialias:o,premultipliedAlpha:a,preserveDrawingBuffer:s};if(null===(zt=e||M.getContext("webgl",et)||M.getContext("experimental-webgl",et)))throw null!==M.getContext("webgl")?"Error creating WebGL context with your selected attributes.":"Error creating WebGL context."}catch(t){console.error(t)}void 0===zt.getShaderPrecisionFormat&&(zt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}});var rt=new We.WebGLExtensions(zt);rt.get("OES_texture_float"),rt.get("OES_texture_float_linear"),rt.get("OES_standard_derivatives"),S&&rt.get("EXT_frag_depth"),zt.clearColor(0,0,0,1),zt.clearDepth(1),zt.clearStencil(0),zt.enable(zt.DEPTH_TEST),zt.depthFunc(zt.LEQUAL),zt.frontFace(zt.CCW),zt.cullFace(zt.BACK),zt.enable(zt.CULL_FACE),zt.enable(zt.BLEND),zt.blendEquation(zt.FUNC_ADD),zt.blendFunc(zt.SRC_ALPHA,zt.ONE_MINUS_SRC_ALPHA),zt.viewport(N,I,G,H),zt.clearColor(h.r,h.g,h.b,l);var it,nt=(this.context=zt).getParameter(zt.MAX_TEXTURE_IMAGE_UNITS),ot=zt.getParameter(zt.MAX_VERTEX_TEXTURE_IMAGE_UNITS),at=zt.getParameter(zt.MAX_TEXTURE_SIZE),st=zt.getParameter(zt.MAX_CUBE_MAP_TEXTURE_SIZE),ht=0<ot,lt=ht&&rt.get("OES_texture_float"),ut=zt.getShaderPrecisionFormat(zt.VERTEX_SHADER,zt.HIGH_FLOAT),ct=zt.getShaderPrecisionFormat(zt.VERTEX_SHADER,zt.MEDIUM_FLOAT),ft=(zt.getShaderPrecisionFormat(zt.VERTEX_SHADER,zt.LOW_FLOAT),zt.getShaderPrecisionFormat(zt.FRAGMENT_SHADER,zt.HIGH_FLOAT)),pt=zt.getShaderPrecisionFormat(zt.FRAGMENT_SHADER,zt.MEDIUM_FLOAT),dt=(zt.getShaderPrecisionFormat(zt.FRAGMENT_SHADER,zt.LOW_FLOAT),function(){if(void 0!==it)return it;if(it=[],rt.get("WEBGL_compressed_texture_pvrtc")||rt.get("WEBGL_compressed_texture_s3tc"))for(var t=zt.getParameter(zt.COMPRESSED_TEXTURE_FORMATS),e=0;e<t.length;e++)it.push(t[e]);return it}),mt=0<ut.precision&&0<ft.precision,vt=0<ct.precision&&0<pt.precision;"highp"!==_||mt||(vt?(_="mediump",console.warn("THREE.WebGLRenderer: highp not supported, using mediump.")):(_="lowp",console.warn("THREE.WebGLRenderer: highp and mediump not supported, using lowp."))),"mediump"!==_||vt||(_="lowp",console.warn("THREE.WebGLRenderer: mediump not supported, using lowp."));var gt,yt=new We.ShadowMapPlugin(this,c,m,v),xt=new We.SpritePlugin(this,d),wt=new We.LensFlarePlugin(this,g);function bt(t){var e,r;if(t.__webglVertexBuffer=zt.createBuffer(),t.__webglNormalBuffer=zt.createBuffer(),t.__webglTangentBuffer=zt.createBuffer(),t.__webglColorBuffer=zt.createBuffer(),t.__webglUVBuffer=zt.createBuffer(),t.__webglUV2Buffer=zt.createBuffer(),t.__webglSkinIndicesBuffer=zt.createBuffer(),t.__webglSkinWeightsBuffer=zt.createBuffer(),t.__webglFaceBuffer=zt.createBuffer(),t.__webglLineBuffer=zt.createBuffer(),t.numMorphTargets)for(t.__webglMorphTargetsBuffers=[],e=0,r=t.numMorphTargets;e<r;e++)t.__webglMorphTargetsBuffers.push(zt.createBuffer());if(t.numMorphNormals)for(t.__webglMorphNormalsBuffers=[],e=0,r=t.numMorphNormals;e<r;e++)t.__webglMorphNormalsBuffers.push(zt.createBuffer());O.info.memory.geometries++}this.getContext=function(){return zt},this.supportsVertexTextures=function(){return ht},this.supportsFloatTextures=function(){return rt.get("OES_texture_float")},this.supportsStandardDerivatives=function(){return rt.get("OES_standard_derivatives")},this.supportsCompressedTextureS3TC=function(){return rt.get("WEBGL_compressed_texture_s3tc")},this.supportsCompressedTexturePVRTC=function(){return rt.get("WEBGL_compressed_texture_pvrtc")},this.supportsBlendMinMax=function(){return rt.get("EXT_blend_minmax")},this.getMaxAnisotropy=function(){if(void 0!==gt)return gt;var t=rt.get("EXT_texture_filter_anisotropic");return gt=null!==t?zt.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},this.getPrecision=function(){return _},this.setSize=function(t,e,r){M.width=t*this.devicePixelRatio,M.height=e*this.devicePixelRatio,!1!==r&&(M.style.width=t+"px",M.style.height=e+"px"),this.setViewport(0,0,t,e)},this.setViewport=function(t,e,r,i){N=t*this.devicePixelRatio,I=e*this.devicePixelRatio,G=r*this.devicePixelRatio,H=i*this.devicePixelRatio,zt.viewport(N,I,G,H)},this.setScissor=function(t,e,r,i){zt.scissor(t*this.devicePixelRatio,e*this.devicePixelRatio,r*this.devicePixelRatio,i*this.devicePixelRatio)},this.enableScissorTest=function(t){t?zt.enable(zt.SCISSOR_TEST):zt.disable(zt.SCISSOR_TEST)},this.setClearColor=function(t,e){h.set(t),l=void 0!==e?e:1,zt.clearColor(h.r,h.g,h.b,l)},this.setClearColorHex=function(t,e){console.warn("THREE.WebGLRenderer: .setClearColorHex() is being removed. Use .setClearColor() instead."),this.setClearColor(t,e)},this.getClearColor=function(){return h},this.getClearAlpha=function(){return l},this.clear=function(t,e,r){var i=0;(void 0===t||t)&&(i|=zt.COLOR_BUFFER_BIT),(void 0===e||e)&&(i|=zt.DEPTH_BUFFER_BIT),(void 0===r||r)&&(i|=zt.STENCIL_BUFFER_BIT),zt.clear(i)},this.clearColor=function(){zt.clear(zt.COLOR_BUFFER_BIT)},this.clearDepth=function(){zt.clear(zt.DEPTH_BUFFER_BIT)},this.clearStencil=function(){zt.clear(zt.STENCIL_BUFFER_BIT)},this.clearTarget=function(t,e,r,i){this.setRenderTarget(t),this.clear(e,r,i)},this.resetGLState=function(){C=x=w=u=U=D=b=-1,$=!(E=A=null)};var Mt=function(t){t.target.traverse(function(t){t.removeEventListener("remove",Mt),function(t){t instanceof We.Mesh||t instanceof We.PointCloud||t instanceof We.Line?delete m[t.id]:(t instanceof We.ImmediateRenderObject||t.immediateRenderCallback)&&function(t,e){for(var r=t.length-1;0<=r;r--)t[r].object===e&&t.splice(r,1)}(v,t);delete t.__webglInit,delete t._modelViewMatrix,delete t._normalMatrix,delete t.__webglActive}(t)})},_t=function(t){var e=t.target;e.removeEventListener("dispose",_t),Et(e)},St=function(t){var e=t.target;e.removeEventListener("dispose",St),Lt(e),O.info.memory.textures--},Tt=function(t){var e=t.target;e.removeEventListener("dispose",Tt),Pt(e),O.info.memory.textures--},At=function(t){var e=t.target;e.removeEventListener("dispose",At),Rt(e)},Ct=function(t){for(var e=["__webglVertexBuffer","__webglNormalBuffer","__webglTangentBuffer","__webglColorBuffer","__webglUVBuffer","__webglUV2Buffer","__webglSkinIndicesBuffer","__webglSkinWeightsBuffer","__webglFaceBuffer","__webglLineBuffer","__webglLineDistanceBuffer"],r=0,i=e.length;r<i;r++){void 0!==t[n=e[r]]&&(zt.deleteBuffer(t[n]),delete t[n])}if(void 0!==t.__webglCustomAttributesList){for(var n in t.__webglCustomAttributesList)zt.deleteBuffer(t.__webglCustomAttributesList[n].buffer);delete t.__webglCustomAttributesList}O.info.memory.geometries--},Et=function(t){if(delete t.__webglInit,t instanceof We.BufferGeometry){for(var e in t.attributes){var r=t.attributes[e];void 0!==r.buffer&&(zt.deleteBuffer(r.buffer),delete r.buffer)}O.info.memory.geometries--}else{var i=Yt[t.id];if(void 0!==i){for(var n=0,o=i.length;n<o;n++){var a=i[n];if(void 0!==a.numMorphTargets){for(var s=0,h=a.numMorphTargets;s<h;s++)zt.deleteBuffer(a.__webglMorphTargetsBuffers[s]);delete a.__webglMorphTargetsBuffers}if(void 0!==a.numMorphNormals){for(s=0,h=a.numMorphNormals;s<h;s++)zt.deleteBuffer(a.__webglMorphNormalsBuffers[s]);delete a.__webglMorphNormalsBuffers}Ct(a)}delete Yt[t.id]}else Ct(t)}x=-1},Lt=function(t){if(t.image&&t.image.__webglTextureCube)zt.deleteTexture(t.image.__webglTextureCube),delete t.image.__webglTextureCube;else{if(void 0===t.__webglInit)return;zt.deleteTexture(t.__webglTexture),delete t.__webglTexture,delete t.__webglInit}},Pt=function(t){if(t&&void 0!==t.__webglTexture){if(zt.deleteTexture(t.__webglTexture),delete t.__webglTexture,t instanceof We.WebGLRenderTargetCube)for(var e=0;e<6;e++)zt.deleteFramebuffer(t.__webglFramebuffer[e]),zt.deleteRenderbuffer(t.__webglRenderbuffer[e]);else zt.deleteFramebuffer(t.__webglFramebuffer),zt.deleteRenderbuffer(t.__webglRenderbuffer);delete t.__webglFramebuffer,delete t.__webglRenderbuffer}},Rt=function(t){var e=t.program.program;if(void 0!==e){var r,i,n;t.program=void 0;var o=!1;for(r=0,i=T.length;r<i;r++)if((n=T[r]).program===e){n.usedTimes--,0===n.usedTimes&&(o=!0);break}if(!0===o){var a=[];for(r=0,i=T.length;r<i;r++)(n=T[r]).program!==e&&a.push(n);T=a,zt.deleteProgram(e),O.info.memory.programs--}}};function Ft(t){var e=t.geometry,r=t.material,i=e.vertices.length;if(r.attributes)for(var n in void 0===e.__webglCustomAttributesList&&(e.__webglCustomAttributesList=[]),r.attributes){var o=r.attributes[n];if(!o.__webglInitialized||o.createUniqueBuffers){o.__webglInitialized=!0;var a=1;"v2"===o.type?a=2:"v3"===o.type?a=3:"v4"===o.type?a=4:"c"===o.type&&(a=3),o.size=a,o.array=new Float32Array(i*a),o.buffer=zt.createBuffer(),o.buffer.belongsToAttribute=n,o.needsUpdate=!0}e.__webglCustomAttributesList.push(o)}}function Dt(t,e){var r=e.geometry,i=t.faces3,n=3*i.length,o=1*i.length,a=3*i.length,s=Ut(e,t);t.__vertexArray=new Float32Array(3*n),t.__normalArray=new Float32Array(3*n),t.__colorArray=new Float32Array(3*n),t.__uvArray=new Float32Array(2*n),1<r.faceVertexUvs.length&&(t.__uv2Array=new Float32Array(2*n)),r.hasTangents&&(t.__tangentArray=new Float32Array(4*n)),e.geometry.skinWeights.length&&e.geometry.skinIndices.length&&(t.__skinIndexArray=new Float32Array(4*n),t.__skinWeightArray=new Float32Array(4*n));var h,l,u=null!==rt.get("OES_element_index_uint")&&21845<o?Uint32Array:Uint16Array;if(t.__typeArray=u,t.__faceArray=new u(3*o),t.__lineArray=new u(2*a),t.numMorphTargets)for(t.__morphTargetsArrays=[],h=0,l=t.numMorphTargets;h<l;h++)t.__morphTargetsArrays.push(new Float32Array(3*n));if(t.numMorphNormals)for(t.__morphNormalsArrays=[],h=0,l=t.numMorphNormals;h<l;h++)t.__morphNormalsArrays.push(new Float32Array(3*n));if(t.__webglFaceCount=3*o,t.__webglLineCount=2*a,s.attributes)for(var c in void 0===t.__webglCustomAttributesList&&(t.__webglCustomAttributesList=[]),s.attributes){var f=s.attributes[c],p={};for(var d in f)p[d]=f[d];if(!p.__webglInitialized||p.createUniqueBuffers){p.__webglInitialized=!0;var m=1;"v2"===p.type?m=2:"v3"===p.type?m=3:"v4"===p.type?m=4:"c"===p.type&&(m=3),p.size=m,p.array=new Float32Array(n*m),p.buffer=zt.createBuffer(),p.buffer.belongsToAttribute=c,f.needsUpdate=!0,p.__original=f}t.__webglCustomAttributesList.push(p)}t.__inittedArrays=!0}function Ut(t,e){return t.material instanceof We.MeshFaceMaterial?t.material.materials[e.materialIndex]:t.material}function Bt(t,e,r,i,n){if(t.__inittedArrays){var o,a,s,h,l,u,c,f,p,d,m,v,g,y,x,w,b,M,_,S,T,A,C,E,L,P,R,F,D,U,B,k,z,V,N,O,I,G,H,W,j,X,q=(o=n)&&void 0!==o.shading&&o.shading===We.SmoothShading,Y=0,K=0,Z=0,Q=0,J=0,$=0,tt=0,et=0,rt=0,it=0,nt=0,ot=0,at=t.__vertexArray,st=t.__uvArray,ht=t.__uv2Array,lt=t.__normalArray,ut=t.__tangentArray,ct=t.__colorArray,ft=t.__skinIndexArray,pt=t.__skinWeightArray,dt=t.__morphTargetsArrays,mt=t.__morphNormalsArrays,vt=t.__webglCustomAttributesList,gt=t.__faceArray,yt=t.__lineArray,xt=e.geometry,wt=xt.verticesNeedUpdate,bt=xt.elementsNeedUpdate,Mt=xt.uvsNeedUpdate,_t=xt.normalsNeedUpdate,St=xt.tangentsNeedUpdate,Tt=xt.colorsNeedUpdate,At=xt.morphTargetsNeedUpdate,Ct=xt.vertices,Et=t.faces3,Lt=xt.faces,Pt=xt.faceVertexUvs[0],Rt=xt.faceVertexUvs[1],Ft=(xt.colors,xt.skinIndices),Dt=xt.skinWeights,Ut=xt.morphTargets,Bt=xt.morphNormals;if(wt){for(a=0,s=Et.length;a<s;a++)v=Ct[(h=Lt[Et[a]]).a],g=Ct[h.b],y=Ct[h.c],at[K]=v.x,at[K+1]=v.y,at[K+2]=v.z,at[K+3]=g.x,at[K+4]=g.y,at[K+5]=g.z,at[K+6]=y.x,at[K+7]=y.y,at[K+8]=y.z,K+=9;zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglVertexBuffer),zt.bufferData(zt.ARRAY_BUFFER,at,r)}if(At)for(N=0,O=Ut.length;N<O;N++){for(a=nt=0,s=Et.length;a<s;a++)h=Lt[H=Et[a]],v=Ut[N].vertices[h.a],g=Ut[N].vertices[h.b],y=Ut[N].vertices[h.c],(I=dt[N])[nt]=v.x,I[nt+1]=v.y,I[nt+2]=v.z,I[nt+3]=g.x,I[nt+4]=g.y,I[nt+5]=g.z,I[nt+6]=y.x,I[nt+7]=y.y,I[nt+8]=y.z,n.morphNormals&&(q?(M=(W=Bt[N].vertexNormals[H]).a,_=W.b,S=W.c):S=_=M=Bt[N].faceNormals[H],(G=mt[N])[nt]=M.x,G[nt+1]=M.y,G[nt+2]=M.z,G[nt+3]=_.x,G[nt+4]=_.y,G[nt+5]=_.z,G[nt+6]=S.x,G[nt+7]=S.y,G[nt+8]=S.z),nt+=9;zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglMorphTargetsBuffers[N]),zt.bufferData(zt.ARRAY_BUFFER,dt[N],r),n.morphNormals&&(zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglMorphNormalsBuffers[N]),zt.bufferData(zt.ARRAY_BUFFER,mt[N],r))}if(Dt.length){for(a=0,s=Et.length;a<s;a++)E=Dt[(h=Lt[Et[a]]).a],L=Dt[h.b],P=Dt[h.c],pt[it]=E.x,pt[it+1]=E.y,pt[it+2]=E.z,pt[it+3]=E.w,pt[it+4]=L.x,pt[it+5]=L.y,pt[it+6]=L.z,pt[it+7]=L.w,pt[it+8]=P.x,pt[it+9]=P.y,pt[it+10]=P.z,pt[it+11]=P.w,R=Ft[h.a],F=Ft[h.b],D=Ft[h.c],ft[it]=R.x,ft[it+1]=R.y,ft[it+2]=R.z,ft[it+3]=R.w,ft[it+4]=F.x,ft[it+5]=F.y,ft[it+6]=F.z,ft[it+7]=F.w,ft[it+8]=D.x,ft[it+9]=D.y,ft[it+10]=D.z,ft[it+11]=D.w,it+=12;0<it&&(zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglSkinIndicesBuffer),zt.bufferData(zt.ARRAY_BUFFER,ft,r),zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglSkinWeightsBuffer),zt.bufferData(zt.ARRAY_BUFFER,pt,r))}if(Tt){for(a=0,s=Et.length;a<s;a++)c=(h=Lt[Et[a]]).vertexColors,f=h.color,3===c.length&&n.vertexColors===We.VertexColors?(T=c[0],A=c[1],C=c[2]):C=A=T=f,ct[rt]=T.r,ct[rt+1]=T.g,ct[rt+2]=T.b,ct[rt+3]=A.r,ct[rt+4]=A.g,ct[rt+5]=A.b,ct[rt+6]=C.r,ct[rt+7]=C.g,ct[rt+8]=C.b,rt+=9;0<rt&&(zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglColorBuffer),zt.bufferData(zt.ARRAY_BUFFER,ct,r))}if(St&&xt.hasTangents){for(a=0,s=Et.length;a<s;a++)x=(p=(h=Lt[Et[a]]).vertexTangents)[0],w=p[1],b=p[2],ut[tt]=x.x,ut[tt+1]=x.y,ut[tt+2]=x.z,ut[tt+3]=x.w,ut[tt+4]=w.x,ut[tt+5]=w.y,ut[tt+6]=w.z,ut[tt+7]=w.w,ut[tt+8]=b.x,ut[tt+9]=b.y,ut[tt+10]=b.z,ut[tt+11]=b.w,tt+=12;zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglTangentBuffer),zt.bufferData(zt.ARRAY_BUFFER,ut,r)}if(_t){for(a=0,s=Et.length;a<s;a++)if(l=(h=Lt[Et[a]]).vertexNormals,u=h.normal,3===l.length&&q)for(U=0;U<3;U++)k=l[U],lt[$]=k.x,lt[$+1]=k.y,lt[$+2]=k.z,$+=3;else for(U=0;U<3;U++)lt[$]=u.x,lt[$+1]=u.y,lt[$+2]=u.z,$+=3;zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglNormalBuffer),zt.bufferData(zt.ARRAY_BUFFER,lt,r)}if(Mt&&Pt){for(a=0,s=Et.length;a<s;a++)if(void 0!==(d=Pt[Et[a]]))for(U=0;U<3;U++)z=d[U],st[Z]=z.x,st[Z+1]=z.y,Z+=2;0<Z&&(zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglUVBuffer),zt.bufferData(zt.ARRAY_BUFFER,st,r))}if(Mt&&Rt){for(a=0,s=Et.length;a<s;a++)if(void 0!==(m=Rt[Et[a]]))for(U=0;U<3;U++)V=m[U],ht[Q]=V.x,ht[Q+1]=V.y,Q+=2;0<Q&&(zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglUV2Buffer),zt.bufferData(zt.ARRAY_BUFFER,ht,r))}if(bt){for(a=0,s=Et.length;a<s;a++)gt[J]=Y,gt[J+1]=Y+1,gt[J+2]=Y+2,J+=3,yt[et]=Y,yt[et+1]=Y+1,yt[et+2]=Y,yt[et+3]=Y+2,yt[et+4]=Y+1,yt[et+5]=Y+2,et+=6,Y+=3;zt.bindBuffer(zt.ELEMENT_ARRAY_BUFFER,t.__webglFaceBuffer),zt.bufferData(zt.ELEMENT_ARRAY_BUFFER,gt,r),zt.bindBuffer(zt.ELEMENT_ARRAY_BUFFER,t.__webglLineBuffer),zt.bufferData(zt.ELEMENT_ARRAY_BUFFER,yt,r)}if(vt)for(U=0,B=vt.length;U<B;U++)if((X=vt[U]).__original.needsUpdate){if(ot=0,1===X.size){if(void 0===X.boundTo||"vertices"===X.boundTo)for(a=0,s=Et.length;a<s;a++)h=Lt[Et[a]],X.array[ot]=X.value[h.a],X.array[ot+1]=X.value[h.b],X.array[ot+2]=X.value[h.c],ot+=3;else if("faces"===X.boundTo)for(a=0,s=Et.length;a<s;a++)j=X.value[Et[a]],X.array[ot]=j,X.array[ot+1]=j,X.array[ot+2]=j,ot+=3}else if(2===X.size){if(void 0===X.boundTo||"vertices"===X.boundTo)for(a=0,s=Et.length;a<s;a++)h=Lt[Et[a]],v=X.value[h.a],g=X.value[h.b],y=X.value[h.c],X.array[ot]=v.x,X.array[ot+1]=v.y,X.array[ot+2]=g.x,X.array[ot+3]=g.y,X.array[ot+4]=y.x,X.array[ot+5]=y.y,ot+=6;else if("faces"===X.boundTo)for(a=0,s=Et.length;a<s;a++)y=g=v=j=X.value[Et[a]],X.array[ot]=v.x,X.array[ot+1]=v.y,X.array[ot+2]=g.x,X.array[ot+3]=g.y,X.array[ot+4]=y.x,X.array[ot+5]=y.y,ot+=6}else if(3===X.size){var kt;if(kt="c"===X.type?["r","g","b"]:["x","y","z"],void 0===X.boundTo||"vertices"===X.boundTo)for(a=0,s=Et.length;a<s;a++)h=Lt[Et[a]],v=X.value[h.a],g=X.value[h.b],y=X.value[h.c],X.array[ot]=v[kt[0]],X.array[ot+1]=v[kt[1]],X.array[ot+2]=v[kt[2]],X.array[ot+3]=g[kt[0]],X.array[ot+4]=g[kt[1]],X.array[ot+5]=g[kt[2]],X.array[ot+6]=y[kt[0]],X.array[ot+7]=y[kt[1]],X.array[ot+8]=y[kt[2]],ot+=9;else if("faces"===X.boundTo)for(a=0,s=Et.length;a<s;a++)y=g=v=j=X.value[Et[a]],X.array[ot]=v[kt[0]],X.array[ot+1]=v[kt[1]],X.array[ot+2]=v[kt[2]],X.array[ot+3]=g[kt[0]],X.array[ot+4]=g[kt[1]],X.array[ot+5]=g[kt[2]],X.array[ot+6]=y[kt[0]],X.array[ot+7]=y[kt[1]],X.array[ot+8]=y[kt[2]],ot+=9;else if("faceVertices"===X.boundTo)for(a=0,s=Et.length;a<s;a++)v=(j=X.value[Et[a]])[0],g=j[1],y=j[2],X.array[ot]=v[kt[0]],X.array[ot+1]=v[kt[1]],X.array[ot+2]=v[kt[2]],X.array[ot+3]=g[kt[0]],X.array[ot+4]=g[kt[1]],X.array[ot+5]=g[kt[2]],X.array[ot+6]=y[kt[0]],X.array[ot+7]=y[kt[1]],X.array[ot+8]=y[kt[2]],ot+=9}else if(4===X.size)if(void 0===X.boundTo||"vertices"===X.boundTo)for(a=0,s=Et.length;a<s;a++)h=Lt[Et[a]],v=X.value[h.a],g=X.value[h.b],y=X.value[h.c],X.array[ot]=v.x,X.array[ot+1]=v.y,X.array[ot+2]=v.z,X.array[ot+3]=v.w,X.array[ot+4]=g.x,X.array[ot+5]=g.y,X.array[ot+6]=g.z,X.array[ot+7]=g.w,X.array[ot+8]=y.x,X.array[ot+9]=y.y,X.array[ot+10]=y.z,X.array[ot+11]=y.w,ot+=12;else if("faces"===X.boundTo)for(a=0,s=Et.length;a<s;a++)y=g=v=j=X.value[Et[a]],X.array[ot]=v.x,X.array[ot+1]=v.y,X.array[ot+2]=v.z,X.array[ot+3]=v.w,X.array[ot+4]=g.x,X.array[ot+5]=g.y,X.array[ot+6]=g.z,X.array[ot+7]=g.w,X.array[ot+8]=y.x,X.array[ot+9]=y.y,X.array[ot+10]=y.z,X.array[ot+11]=y.w,ot+=12;else if("faceVertices"===X.boundTo)for(a=0,s=Et.length;a<s;a++)v=(j=X.value[Et[a]])[0],g=j[1],y=j[2],X.array[ot]=v.x,X.array[ot+1]=v.y,X.array[ot+2]=v.z,X.array[ot+3]=v.w,X.array[ot+4]=g.x,X.array[ot+5]=g.y,X.array[ot+6]=g.z,X.array[ot+7]=g.w,X.array[ot+8]=y.x,X.array[ot+9]=y.y,X.array[ot+10]=y.z,X.array[ot+11]=y.w,ot+=12;zt.bindBuffer(zt.ARRAY_BUFFER,X.buffer),zt.bufferData(zt.ARRAY_BUFFER,X.array,r)}i&&(delete t.__inittedArrays,delete t.__colorArray,delete t.__normalArray,delete t.__tangentArray,delete t.__uvArray,delete t.__uv2Array,delete t.__faceArray,delete t.__vertexArray,delete t.__lineArray,delete t.__skinIndexArray,delete t.__skinWeightArray)}}function kt(t,e,r,i){for(var n=r.attributes,o=e.attributes,a=e.attributesKeys,s=0,h=a.length;s<h;s++){var l=a[s],u=o[l];if(0<=u){var c=n[l];if(void 0!==c){var f=c.itemSize;zt.bindBuffer(zt.ARRAY_BUFFER,c.buffer),Nt(u),zt.vertexAttribPointer(u,f,zt.FLOAT,!1,0,i*f*4)}else void 0!==t.defaultAttributeValues&&(2===t.defaultAttributeValues[l].length?zt.vertexAttrib2fv(u,t.defaultAttributeValues[l]):3===t.defaultAttributeValues[l].length&&zt.vertexAttrib3fv(u,t.defaultAttributeValues[l]))}}Ot()}function Vt(){for(var t=0,e=X.length;t<e;t++)X[t]=0}function Nt(t){X[t]=1,0===q[t]&&(zt.enableVertexAttribArray(t),q[t]=1)}function Ot(){for(var t=0,e=q.length;t<e;t++)q[t]!==X[t]&&(zt.disableVertexAttribArray(t),q[t]=0)}function It(t,e){return t.material.id!==e.material.id?e.material.id-t.material.id:t.z!==e.z?e.z-t.z:t.id-e.id}function Gt(t,e){return t.z!==e.z?t.z-e.z:t.id-e.id}function Ht(t,e){return e[0]-t[0]}function Wt(t,e,r,i,n,o){for(var a,s=t.length-1;-1!==s;s--){var h=t[s],l=h.object,u=h.buffer;if(oe(l,e),o)a=o;else{if(!(a=h.material))continue;n&&O.setBlending(a.blending,a.blendEquation,a.blendSrc,a.blendDst),O.setDepthTest(a.depthTest),O.setDepthWrite(a.depthWrite),le(a.polygonOffset,a.polygonOffsetFactor,a.polygonOffsetUnits)}O.setMaterialFaces(a),u instanceof We.BufferGeometry?O.renderBufferDirect(e,r,i,a,u,l):O.renderBuffer(e,r,i,a,u,l)}}function jt(t,e,r,i,n,o,a){for(var s,h=0,l=t.length;h<l;h++){var u=t[h],c=u.object;if(c.visible){if(a)s=a;else{if(!(s=u[e]))continue;o&&O.setBlending(s.blending,s.blendEquation,s.blendSrc,s.blendDst),O.setDepthTest(s.depthTest),O.setDepthWrite(s.depthWrite),le(s.polygonOffset,s.polygonOffsetFactor,s.polygonOffsetUnits)}O.renderImmediateObject(r,i,n,s,c)}}}function Xt(t){var e=t.object.material;e.transparent?(t.transparent=e,t.opaque=null):(t.opaque=e,t.transparent=null)}function qt(t){var e=t.object,r=t.buffer,i=e.geometry,n=e.material;if(n instanceof We.MeshFaceMaterial){var o=i instanceof We.BufferGeometry?0:r.materialIndex;n=n.materials[o],(t.material=n).transparent?p.push(t):f.push(t)}else n&&((t.material=n).transparent?p.push(t):f.push(t))}this.renderBufferImmediate=function(t,e,r){if(Vt(),t.hasPositions&&!t.__webglVertexBuffer&&(t.__webglVertexBuffer=zt.createBuffer()),t.hasNormals&&!t.__webglNormalBuffer&&(t.__webglNormalBuffer=zt.createBuffer()),t.hasUvs&&!t.__webglUvBuffer&&(t.__webglUvBuffer=zt.createBuffer()),t.hasColors&&!t.__webglColorBuffer&&(t.__webglColorBuffer=zt.createBuffer()),t.hasPositions&&(zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglVertexBuffer),zt.bufferData(zt.ARRAY_BUFFER,t.positionArray,zt.DYNAMIC_DRAW),Nt(e.attributes.position),zt.vertexAttribPointer(e.attributes.position,3,zt.FLOAT,!1,0,0)),t.hasNormals){if(zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglNormalBuffer),r.shading===We.FlatShading){var i,n,o,a,s,h,l,u,c,f,p,d=3*t.count;for(p=0;p<d;p+=9)a=(f=t.normalArray)[p],h=f[p+1],u=f[p+2],s=f[p+3],l=f[p+4],c=f[p+5],i=(a+s+f[p+6])/3,n=(h+l+f[p+7])/3,o=(u+c+f[p+8])/3,f[p]=i,f[p+1]=n,f[p+2]=o,f[p+3]=i,f[p+4]=n,f[p+5]=o,f[p+6]=i,f[p+7]=n,f[p+8]=o}zt.bufferData(zt.ARRAY_BUFFER,t.normalArray,zt.DYNAMIC_DRAW),Nt(e.attributes.normal),zt.vertexAttribPointer(e.attributes.normal,3,zt.FLOAT,!1,0,0)}t.hasUvs&&r.map&&(zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglUvBuffer),zt.bufferData(zt.ARRAY_BUFFER,t.uvArray,zt.DYNAMIC_DRAW),Nt(e.attributes.uv),zt.vertexAttribPointer(e.attributes.uv,2,zt.FLOAT,!1,0,0)),t.hasColors&&r.vertexColors!==We.NoColors&&(zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglColorBuffer),zt.bufferData(zt.ARRAY_BUFFER,t.colorArray,zt.DYNAMIC_DRAW),Nt(e.attributes.color),zt.vertexAttribPointer(e.attributes.color,3,zt.FLOAT,!1,0,0)),Ot(),zt.drawArrays(zt.TRIANGLES,0,t.count),t.count=0},this.renderBufferDirect=function(t,e,r,i,n,o){if(!1!==i.visible){var a=ee(t,e,r,i,o),s=!1,h=i.wireframe?1:0,l=16777215*n.id+2*a.id+h;if(l!==x&&(x=l,s=!0),s&&Vt(),o instanceof We.Mesh){var u=!0===i.wireframe?zt.LINES:zt.TRIANGLES;if(m=n.attributes.index){if(m.array instanceof Uint32Array&&rt.get("OES_element_index_uint")?(v=zt.UNSIGNED_INT,g=4):(v=zt.UNSIGNED_SHORT,g=2),0===(y=n.offsets).length)s&&(kt(i,a,n,0),zt.bindBuffer(zt.ELEMENT_ARRAY_BUFFER,m.buffer)),zt.drawElements(u,m.array.length,v,0),O.info.render.calls++,O.info.render.vertices+=m.array.length,O.info.render.faces+=m.array.length/3;else{s=!0;for(var c=0,f=y.length;c<f;c++){var p=y[c].index;s&&(kt(i,a,n,p),zt.bindBuffer(zt.ELEMENT_ARRAY_BUFFER,m.buffer)),zt.drawElements(u,y[c].count,v,y[c].start*g),O.info.render.calls++,O.info.render.vertices+=y[c].count,O.info.render.faces+=y[c].count/3}}}else{s&&kt(i,a,n,0);var d=n.attributes.position;zt.drawArrays(u,0,d.array.length/3),O.info.render.calls++,O.info.render.vertices+=d.array.length/3,O.info.render.faces+=d.array.length/9}}else if(o instanceof We.PointCloud){s&&kt(i,a,n,0);d=n.attributes.position;zt.drawArrays(zt.POINTS,0,d.array.length/3),O.info.render.calls++,O.info.render.points+=d.array.length/3}else if(o instanceof We.Line){var m;u=o.mode===We.LineStrip?zt.LINE_STRIP:zt.LINES;if(he(i.linewidth),m=n.attributes.index){var v,g,y;if(m.array instanceof Uint32Array?(v=zt.UNSIGNED_INT,g=4):(v=zt.UNSIGNED_SHORT,g=2),0===(y=n.offsets).length)s&&(kt(i,a,n,0),zt.bindBuffer(zt.ELEMENT_ARRAY_BUFFER,m.buffer)),zt.drawElements(u,m.array.length,v,0),O.info.render.calls++,O.info.render.vertices+=m.array.length;else{1<y.length&&(s=!0);for(c=0,f=y.length;c<f;c++){p=y[c].index;s&&(kt(i,a,n,p),zt.bindBuffer(zt.ELEMENT_ARRAY_BUFFER,m.buffer)),zt.drawElements(u,y[c].count,v,y[c].start*g),O.info.render.calls++,O.info.render.vertices+=y[c].count}}}else{s&&kt(i,a,n,0);d=n.attributes.position;zt.drawArrays(u,0,d.array.length/3),O.info.render.calls++,O.info.render.points+=d.array.length/3}}}},this.renderBuffer=function(t,e,r,i,n,o){if(!1!==i.visible){var a=ee(t,e,r,i,o),s=a.attributes,h=!1,l=i.wireframe?1:0,u=16777215*n.id+2*a.id+l;if(u!==x&&(x=u,h=!0),h&&Vt(),!i.morphTargets&&0<=s.position?h&&(zt.bindBuffer(zt.ARRAY_BUFFER,n.__webglVertexBuffer),Nt(s.position),zt.vertexAttribPointer(s.position,3,zt.FLOAT,!1,0,0)):o.morphTargetBase&&function(t,e,r){var i=t.program.attributes;-1!==r.morphTargetBase&&0<=i.position?(zt.bindBuffer(zt.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[r.morphTargetBase]),Nt(i.position),zt.vertexAttribPointer(i.position,3,zt.FLOAT,!1,0,0)):0<=i.position&&(zt.bindBuffer(zt.ARRAY_BUFFER,e.__webglVertexBuffer),Nt(i.position),zt.vertexAttribPointer(i.position,3,zt.FLOAT,!1,0,0));if(r.morphTargetForcedOrder.length)for(var n=0,o=r.morphTargetForcedOrder,a=r.morphTargetInfluences;n<t.numSupportedMorphTargets&&n<o.length;)0<=i["morphTarget"+n]&&(zt.bindBuffer(zt.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[o[n]]),Nt(i["morphTarget"+n]),zt.vertexAttribPointer(i["morphTarget"+n],3,zt.FLOAT,!1,0,0)),0<=i["morphNormal"+n]&&t.morphNormals&&(zt.bindBuffer(zt.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[o[n]]),Nt(i["morphNormal"+n]),zt.vertexAttribPointer(i["morphNormal"+n],3,zt.FLOAT,!1,0,0)),r.__webglMorphTargetInfluences[n]=a[o[n]],n++;else{var s,h,l=[],a=r.morphTargetInfluences,u=a.length;for(h=0;h<u;h++)0<(s=a[h])&&l.push([s,h]);l.length>t.numSupportedMorphTargets?(l.sort(Ht),l.length=t.numSupportedMorphTargets):l.length>t.numSupportedMorphNormals?l.sort(Ht):0===l.length&&l.push([0,0]);for(var c,n=0;n<t.numSupportedMorphTargets;)l[n]?(c=l[n][1],0<=i["morphTarget"+n]&&(zt.bindBuffer(zt.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[c]),Nt(i["morphTarget"+n]),zt.vertexAttribPointer(i["morphTarget"+n],3,zt.FLOAT,!1,0,0)),0<=i["morphNormal"+n]&&t.morphNormals&&(zt.bindBuffer(zt.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[c]),Nt(i["morphNormal"+n]),zt.vertexAttribPointer(i["morphNormal"+n],3,zt.FLOAT,!1,0,0)),r.__webglMorphTargetInfluences[n]=a[c]):r.__webglMorphTargetInfluences[n]=0,n++}null!==t.program.uniforms.morphTargetInfluences&&zt.uniform1fv(t.program.uniforms.morphTargetInfluences,r.__webglMorphTargetInfluences)}(i,n,o),h){if(n.__webglCustomAttributesList)for(var c=0,f=n.__webglCustomAttributesList.length;c<f;c++){var p=n.__webglCustomAttributesList[c];0<=s[p.buffer.belongsToAttribute]&&(zt.bindBuffer(zt.ARRAY_BUFFER,p.buffer),Nt(s[p.buffer.belongsToAttribute]),zt.vertexAttribPointer(s[p.buffer.belongsToAttribute],p.size,zt.FLOAT,!1,0,0))}0<=s.color&&(0<o.geometry.colors.length||0<o.geometry.faces.length?(zt.bindBuffer(zt.ARRAY_BUFFER,n.__webglColorBuffer),Nt(s.color),zt.vertexAttribPointer(s.color,3,zt.FLOAT,!1,0,0)):void 0!==i.defaultAttributeValues&&zt.vertexAttrib3fv(s.color,i.defaultAttributeValues.color)),0<=s.normal&&(zt.bindBuffer(zt.ARRAY_BUFFER,n.__webglNormalBuffer),Nt(s.normal),zt.vertexAttribPointer(s.normal,3,zt.FLOAT,!1,0,0)),0<=s.tangent&&(zt.bindBuffer(zt.ARRAY_BUFFER,n.__webglTangentBuffer),Nt(s.tangent),zt.vertexAttribPointer(s.tangent,4,zt.FLOAT,!1,0,0)),0<=s.uv&&(o.geometry.faceVertexUvs[0]?(zt.bindBuffer(zt.ARRAY_BUFFER,n.__webglUVBuffer),Nt(s.uv),zt.vertexAttribPointer(s.uv,2,zt.FLOAT,!1,0,0)):void 0!==i.defaultAttributeValues&&zt.vertexAttrib2fv(s.uv,i.defaultAttributeValues.uv)),0<=s.uv2&&(o.geometry.faceVertexUvs[1]?(zt.bindBuffer(zt.ARRAY_BUFFER,n.__webglUV2Buffer),Nt(s.uv2),zt.vertexAttribPointer(s.uv2,2,zt.FLOAT,!1,0,0)):void 0!==i.defaultAttributeValues&&zt.vertexAttrib2fv(s.uv2,i.defaultAttributeValues.uv2)),i.skinning&&0<=s.skinIndex&&0<=s.skinWeight&&(zt.bindBuffer(zt.ARRAY_BUFFER,n.__webglSkinIndicesBuffer),Nt(s.skinIndex),zt.vertexAttribPointer(s.skinIndex,4,zt.FLOAT,!1,0,0),zt.bindBuffer(zt.ARRAY_BUFFER,n.__webglSkinWeightsBuffer),Nt(s.skinWeight),zt.vertexAttribPointer(s.skinWeight,4,zt.FLOAT,!1,0,0)),0<=s.lineDistance&&(zt.bindBuffer(zt.ARRAY_BUFFER,n.__webglLineDistanceBuffer),Nt(s.lineDistance),zt.vertexAttribPointer(s.lineDistance,1,zt.FLOAT,!1,0,0))}if(Ot(),o instanceof We.Mesh){var d=n.__typeArray===Uint32Array?zt.UNSIGNED_INT:zt.UNSIGNED_SHORT;i.wireframe?(he(i.wireframeLinewidth),h&&zt.bindBuffer(zt.ELEMENT_ARRAY_BUFFER,n.__webglLineBuffer),zt.drawElements(zt.LINES,n.__webglLineCount,d,0)):(h&&zt.bindBuffer(zt.ELEMENT_ARRAY_BUFFER,n.__webglFaceBuffer),zt.drawElements(zt.TRIANGLES,n.__webglFaceCount,d,0)),O.info.render.calls++,O.info.render.vertices+=n.__webglFaceCount,O.info.render.faces+=n.__webglFaceCount/3}else if(o instanceof We.Line){var m=o.mode===We.LineStrip?zt.LINE_STRIP:zt.LINES;he(i.linewidth),zt.drawArrays(m,0,n.__webglLineCount),O.info.render.calls++}else o instanceof We.PointCloud&&(zt.drawArrays(zt.POINTS,0,n.__webglParticleCount),O.info.render.calls++,O.info.render.points+=n.__webglParticleCount)}},this.render=function(t,e,r,i){if(e instanceof We.Camera!=!1){var n,o=t.fog;C=x=-1,($=!(E=null))===t.autoUpdate&&t.updateMatrixWorld(),void 0===e.parent&&e.updateMatrixWorld(),t.traverse(function(t){t instanceof We.SkinnedMesh&&t.skeleton.update()}),e.matrixWorldInverse.getInverse(e.matrixWorld),K.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),Y.setFromMatrix(K),c.length=0,f.length=0,p.length=0,d.length=0,g.length=0,function t(e,r){if(!1===r.visible)return;if(r instanceof We.Scene||r instanceof We.Group);else if(function(t,e){void 0===t.__webglInit&&(t.__webglInit=!0,t._modelViewMatrix=new We.Matrix4,t._normalMatrix=new We.Matrix3,t.addEventListener("removed",Mt));var r=t.geometry;void 0===r||void 0===r.__webglInit&&(r.__webglInit=!0,r.addEventListener("dispose",_t),r instanceof We.BufferGeometry||(t instanceof We.Mesh?Zt(e,t,r):t instanceof We.Line?void 0===r.__webglVertexBuffer&&((u=r).__webglVertexBuffer=zt.createBuffer(),u.__webglColorBuffer=zt.createBuffer(),u.__webglLineDistanceBuffer=zt.createBuffer(),O.info.memory.geometries++,h=t,l=(s=r).vertices.length,s.__vertexArray=new Float32Array(3*l),s.__colorArray=new Float32Array(3*l),s.__lineDistanceArray=new Float32Array(1*l),s.__webglLineCount=l,Ft(h),r.verticesNeedUpdate=!0,r.colorsNeedUpdate=!0,r.lineDistancesNeedUpdate=!0):t instanceof We.PointCloud&&void 0===r.__webglVertexBuffer&&((a=r).__webglVertexBuffer=zt.createBuffer(),a.__webglColorBuffer=zt.createBuffer(),O.info.memory.geometries++,n=t,o=(i=r).vertices.length,i.__vertexArray=new Float32Array(3*o),i.__colorArray=new Float32Array(3*o),i.__sortArray=[],i.__webglParticleCount=o,Ft(n),r.verticesNeedUpdate=!0,r.colorsNeedUpdate=!0)));var i,n,o;var a;var s,h,l;var u;if(void 0===t.__webglActive)if(t.__webglActive=!0,t instanceof We.Mesh){if(r instanceof We.BufferGeometry)Qt(m,r,t);else if(r instanceof We.Geometry)for(var c=Yt[r.id],f=0,p=c.length;f<p;f++)Qt(m,c[f],t)}else t instanceof We.Line||t instanceof We.PointCloud?Qt(m,r,t):(t instanceof We.ImmediateRenderObject||t.immediateRenderCallback)&&(d=t,v.push({id:null,object:d,opaque:null,transparent:null,z:0}));var d}(r,e),r instanceof We.Light)c.push(r);else if(r instanceof We.Sprite)d.push(r);else if(r instanceof We.LensFlare)g.push(r);else{var i=m[r.id];if(i&&(!1===r.frustumCulled||!0===Y.intersectsObject(r))){!function(t,e){var r,i,n=t.geometry;if(n instanceof We.BufferGeometry)!function(t){for(var e=t.attributes,r=t.attributesKeys,i=0,n=r.length;i<n;i++){var o=r[i],a=e[o];if(void 0===a.buffer&&(a.buffer=zt.createBuffer(),a.needsUpdate=!0),!0===a.needsUpdate){var s="index"===o?zt.ELEMENT_ARRAY_BUFFER:zt.ARRAY_BUFFER;zt.bindBuffer(s,a.buffer),zt.bufferData(s,a.array,zt.STATIC_DRAW),a.needsUpdate=!1}}}(n);else if(t instanceof We.Mesh){!0===n.groupsNeedUpdate&&Zt(e,t,n);for(var o=Yt[n.id],a=0,s=o.length;a<s;a++){var h=o[a];i=Ut(t,h),!0===n.groupsNeedUpdate&&Dt(h,t),r=i.attributes&&Jt(i),(n.verticesNeedUpdate||n.morphTargetsNeedUpdate||n.elementsNeedUpdate||n.uvsNeedUpdate||n.normalsNeedUpdate||n.colorsNeedUpdate||n.tangentsNeedUpdate||r)&&Bt(h,t,zt.DYNAMIC_DRAW,!n.dynamic,i)}n.verticesNeedUpdate=!1,n.morphTargetsNeedUpdate=!1,n.elementsNeedUpdate=!1,n.uvsNeedUpdate=!1,n.normalsNeedUpdate=!1,n.colorsNeedUpdate=!1,n.tangentsNeedUpdate=!1,i.attributes&&$t(i)}else t instanceof We.Line?(i=Ut(t,n),r=i.attributes&&Jt(i),(n.verticesNeedUpdate||n.colorsNeedUpdate||n.lineDistancesNeedUpdate||r)&&function(t,e){var r,i,n,o,a,s,h,l,u,c,f,p,d=t.vertices,m=t.colors,v=t.lineDistances,g=d.length,y=m.length,x=v.length,w=t.__vertexArray,b=t.__colorArray,M=t.__lineDistanceArray,_=t.verticesNeedUpdate,S=t.colorsNeedUpdate,T=t.lineDistancesNeedUpdate,A=t.__webglCustomAttributesList;if(_){for(r=0;r<g;r++)o=d[r],w[a=3*r]=o.x,w[a+1]=o.y,w[a+2]=o.z;zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglVertexBuffer),zt.bufferData(zt.ARRAY_BUFFER,w,e)}if(S){for(i=0;i<y;i++)s=m[i],b[a=3*i]=s.r,b[a+1]=s.g,b[a+2]=s.b;zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglColorBuffer),zt.bufferData(zt.ARRAY_BUFFER,b,e)}if(T){for(n=0;n<x;n++)M[n]=v[n];zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglLineDistanceBuffer),zt.bufferData(zt.ARRAY_BUFFER,M,e)}if(A)for(h=0,l=A.length;h<l;h++)if((p=A[h]).needsUpdate&&(void 0===p.boundTo||"vertices"===p.boundTo)){if(a=0,c=p.value.length,1===p.size)for(u=0;u<c;u++)p.array[u]=p.value[u];else if(2===p.size)for(u=0;u<c;u++)f=p.value[u],p.array[a]=f.x,p.array[a+1]=f.y,a+=2;else if(3===p.size)if("c"===p.type)for(u=0;u<c;u++)f=p.value[u],p.array[a]=f.r,p.array[a+1]=f.g,p.array[a+2]=f.b,a+=3;else for(u=0;u<c;u++)f=p.value[u],p.array[a]=f.x,p.array[a+1]=f.y,p.array[a+2]=f.z,a+=3;else if(4===p.size)for(u=0;u<c;u++)f=p.value[u],p.array[a]=f.x,p.array[a+1]=f.y,p.array[a+2]=f.z,p.array[a+3]=f.w,a+=4;zt.bindBuffer(zt.ARRAY_BUFFER,p.buffer),zt.bufferData(zt.ARRAY_BUFFER,p.array,e)}}(n,zt.DYNAMIC_DRAW),n.verticesNeedUpdate=!1,n.colorsNeedUpdate=!1,n.lineDistancesNeedUpdate=!1,i.attributes&&$t(i)):t instanceof We.PointCloud&&(i=Ut(t,n),r=i.attributes&&Jt(i),(n.verticesNeedUpdate||n.colorsNeedUpdate||t.sortParticles||r)&&function(t,e,r){var i,n,o,a,s,h,l,u,c,f,p,d,m=t.vertices,v=m.length,g=t.colors,y=g.length,x=t.__vertexArray,w=t.__colorArray,b=t.__sortArray,M=t.verticesNeedUpdate,_=(t.elementsNeedUpdate,t.colorsNeedUpdate),S=t.__webglCustomAttributesList;if(r.sortParticles){for(Z.copy(K),Z.multiply(r.matrixWorld),i=0;i<v;i++)o=m[i],Q.copy(o),Q.applyProjection(Z),b[i]=[Q.z,i];for(b.sort(Ht),i=0;i<v;i++)o=m[b[i][1]],x[a=3*i]=o.x,x[a+1]=o.y,x[a+2]=o.z;for(n=0;n<y;n++)a=3*n,h=g[b[n][1]],w[a]=h.r,w[a+1]=h.g,w[a+2]=h.b;if(S)for(l=0,u=S.length;l<u;l++)if(void 0===(d=S[l]).boundTo||"vertices"===d.boundTo)if(a=0,f=d.value.length,1===d.size)for(c=0;c<f;c++)s=b[c][1],d.array[c]=d.value[s];else if(2===d.size)for(c=0;c<f;c++)s=b[c][1],p=d.value[s],d.array[a]=p.x,d.array[a+1]=p.y,a+=2;else if(3===d.size)if("c"===d.type)for(c=0;c<f;c++)s=b[c][1],p=d.value[s],d.array[a]=p.r,d.array[a+1]=p.g,d.array[a+2]=p.b,a+=3;else for(c=0;c<f;c++)s=b[c][1],p=d.value[s],d.array[a]=p.x,d.array[a+1]=p.y,d.array[a+2]=p.z,a+=3;else if(4===d.size)for(c=0;c<f;c++)s=b[c][1],p=d.value[s],d.array[a]=p.x,d.array[a+1]=p.y,d.array[a+2]=p.z,d.array[a+3]=p.w,a+=4}else{if(M)for(i=0;i<v;i++)o=m[i],x[a=3*i]=o.x,x[a+1]=o.y,x[a+2]=o.z;if(_)for(n=0;n<y;n++)h=g[n],w[a=3*n]=h.r,w[a+1]=h.g,w[a+2]=h.b;if(S)for(l=0,u=S.length;l<u;l++)if((d=S[l]).needsUpdate&&(void 0===d.boundTo||"vertices"===d.boundTo))if(f=d.value.length,a=0,1===d.size)for(c=0;c<f;c++)d.array[c]=d.value[c];else if(2===d.size)for(c=0;c<f;c++)p=d.value[c],d.array[a]=p.x,d.array[a+1]=p.y,a+=2;else if(3===d.size)if("c"===d.type)for(c=0;c<f;c++)p=d.value[c],d.array[a]=p.r,d.array[a+1]=p.g,d.array[a+2]=p.b,a+=3;else for(c=0;c<f;c++)p=d.value[c],d.array[a]=p.x,d.array[a+1]=p.y,d.array[a+2]=p.z,a+=3;else if(4===d.size)for(c=0;c<f;c++)p=d.value[c],d.array[a]=p.x,d.array[a+1]=p.y,d.array[a+2]=p.z,d.array[a+3]=p.w,a+=4}if((M||r.sortParticles)&&(zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglVertexBuffer),zt.bufferData(zt.ARRAY_BUFFER,x,e)),(_||r.sortParticles)&&(zt.bindBuffer(zt.ARRAY_BUFFER,t.__webglColorBuffer),zt.bufferData(zt.ARRAY_BUFFER,w,e)),S)for(l=0,u=S.length;l<u;l++)((d=S[l]).needsUpdate||r.sortParticles)&&(zt.bindBuffer(zt.ARRAY_BUFFER,d.buffer),zt.bufferData(zt.ARRAY_BUFFER,d.array,e))}(n,zt.DYNAMIC_DRAW,t),n.verticesNeedUpdate=!1,n.colorsNeedUpdate=!1,i.attributes&&$t(i))}(r,e);for(var n=0,o=i.length;n<o;n++){var a=i[n];qt(a),(a.render=!0)===O.sortObjects&&(null!==r.renderDepth?a.z=r.renderDepth:(Q.setFromMatrixPosition(r.matrixWorld),Q.applyProjection(K),a.z=Q.z))}}}for(var n=0,o=r.children.length;n<o;n++)t(e,r.children[n])}(t,t),!0===O.sortObjects&&(f.sort(It),p.sort(Gt)),yt.render(t,e),O.info.render.calls=0,O.info.render.vertices=0,O.info.render.faces=0,O.info.render.points=0,this.setRenderTarget(r),(this.autoClear||i)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);for(var a=0,s=v.length;a<s;a++){var h=v[a],l=h.object;l.visible&&(oe(l,e),Xt(h))}if(t.overrideMaterial){var u=t.overrideMaterial;this.setBlending(u.blending,u.blendEquation,u.blendSrc,u.blendDst),this.setDepthTest(u.depthTest),this.setDepthWrite(u.depthWrite),le(u.polygonOffset,u.polygonOffsetFactor,u.polygonOffsetUnits),Wt(f,e,c,o,!0,u),Wt(p,e,c,o,!0,u),jt(v,"",e,c,o,!1,u)}else{u=null;this.setBlending(We.NoBlending),Wt(f,e,c,o,!1,u),jt(v,"opaque",e,c,o,!1,u),Wt(p,e,c,o,!0,u),jt(v,"transparent",e,c,o,!0,u)}xt.render(t,e),wt.render(t,e,W,j),r&&r.generateMipmaps&&r.minFilter!==We.NearestFilter&&r.minFilter!==We.LinearFilter&&((n=r)instanceof We.WebGLRenderTargetCube?(zt.bindTexture(zt.TEXTURE_CUBE_MAP,n.__webglTexture),zt.generateMipmap(zt.TEXTURE_CUBE_MAP),zt.bindTexture(zt.TEXTURE_CUBE_MAP,null)):(zt.bindTexture(zt.TEXTURE_2D,n.__webglTexture),zt.generateMipmap(zt.TEXTURE_2D),zt.bindTexture(zt.TEXTURE_2D,null))),this.setDepthTest(!0),this.setDepthWrite(!0)}else console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")},this.renderImmediateObject=function(t,e,r,i,n){var o=ee(t,e,r,i,n);x=-1,O.setMaterialFaces(i),n.immediateRenderCallback?n.immediateRenderCallback(o,zt,Y):n.render(function(t){O.renderBufferImmediate(t,o,i)})};var Yt={},Kt=0;function Zt(t,e,r){var i=e.material,n=!1;void 0!==Yt[r.id]&&!0!==r.groupsNeedUpdate||(delete m[e.id],Yt[r.id]=function(t,e){for(var r,i,n=rt.get("OES_element_index_uint")?4294967296:65535,o={},a=t.morphTargets.length,s=t.morphNormals.length,h={},l=[],u=0,c=t.faces.length;u<c;u++){var f=t.faces[u],p=e?f.materialIndex:0;p in o||(o[p]={hash:p,counter:0}),(r=o[p].hash+"_"+o[p].counter)in h||(i={id:Kt++,faces3:[],materialIndex:p,vertices:0,numMorphTargets:a,numMorphNormals:s},h[r]=i,l.push(i)),h[r].vertices+3>n&&(o[p].counter+=1,(r=o[p].hash+"_"+o[p].counter)in h||(i={id:Kt++,faces3:[],materialIndex:p,vertices:0,numMorphTargets:a,numMorphNormals:s},h[r]=i,l.push(i))),h[r].faces3.push(u),h[r].vertices+=3}return l}(r,i instanceof We.MeshFaceMaterial),r.groupsNeedUpdate=!1);for(var o=Yt[r.id],a=0,s=o.length;a<s;a++){var h=o[a];void 0===h.__webglVertexBuffer?(bt(h),Dt(h,e),r.verticesNeedUpdate=!0,r.morphTargetsNeedUpdate=!0,r.elementsNeedUpdate=!0,r.uvsNeedUpdate=!0,r.normalsNeedUpdate=!0,r.tangentsNeedUpdate=!0,n=r.colorsNeedUpdate=!0):n=!1,(n||void 0===e.__webglActive)&&Qt(m,h,e)}e.__webglActive=!0}function Qt(t,e,r){var i=r.id;t[i]=t[i]||[],t[i].push({id:i,buffer:e,object:r,material:null,z:0})}function Jt(t){for(var e in t.attributes)if(t.attributes[e].needsUpdate)return!0;return!1}function $t(t){for(var e in t.attributes)t.attributes[e].needsUpdate=!1}function te(t,e,r,i){var n;if(t.addEventListener("dispose",At),t instanceof We.MeshDepthMaterial?n="depth":t instanceof We.MeshNormalMaterial?n="normal":t instanceof We.MeshBasicMaterial?n="basic":t instanceof We.MeshLambertMaterial?n="lambert":t instanceof We.MeshPhongMaterial?n="phong":t instanceof We.LineBasicMaterial?n="basic":t instanceof We.LineDashedMaterial?n="dashed":t instanceof We.PointCloudMaterial&&(n="particle_basic"),n){var o=We.ShaderLib[n];t.__webglShader={uniforms:We.UniformsUtils.clone(o.uniforms),vertexShader:o.vertexShader,fragmentShader:o.fragmentShader}}else t.__webglShader={uniforms:t.uniforms,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader};var a=function(t){for(var e=0,r=0,i=0,n=0,o=0,a=t.length;o<a;o++){var s=t[o];s.onlyShadow||!1===s.visible||(s instanceof We.DirectionalLight&&e++,s instanceof We.PointLight&&r++,s instanceof We.SpotLight&&i++,s instanceof We.HemisphereLight&&n++)}return{directional:e,point:r,spot:i,hemi:n}}(e),s=function(t){for(var e=0,r=0,i=t.length;r<i;r++){var n=t[r];n.castShadow&&(n instanceof We.SpotLight&&e++,n instanceof We.DirectionalLight&&!n.shadowCascade&&e++)}return e}(e),h=function(t){{if(lt&&t&&t.skeleton&&t.skeleton.useVertexTexture)return 1024;var e=zt.getParameter(zt.MAX_VERTEX_UNIFORM_VECTORS),r=Math.floor((e-20)/4),i=r;return void 0!==t&&t instanceof We.SkinnedMesh&&(i=Math.min(t.skeleton.bones.length,i))<t.skeleton.bones.length&&console.warn("WebGLRenderer: too many bones - "+t.skeleton.bones.length+", this GPU supports just "+i+" (try OpenGL instead of ANGLE)"),i}}(i),l={precision:_,supportsVertexTextures:ht,map:!!t.map,envMap:!!t.envMap,lightMap:!!t.lightMap,bumpMap:!!t.bumpMap,normalMap:!!t.normalMap,specularMap:!!t.specularMap,alphaMap:!!t.alphaMap,vertexColors:t.vertexColors,fog:r,useFog:t.fog,fogExp:r instanceof We.FogExp2,sizeAttenuation:t.sizeAttenuation,logarithmicDepthBuffer:S,skinning:t.skinning,maxBones:h,useVertexTexture:lt&&i&&i.skeleton&&i.skeleton.useVertexTexture,morphTargets:t.morphTargets,morphNormals:t.morphNormals,maxMorphTargets:O.maxMorphTargets,maxMorphNormals:O.maxMorphNormals,maxDirLights:a.directional,maxPointLights:a.point,maxSpotLights:a.spot,maxHemiLights:a.hemi,maxShadows:s,shadowMapEnabled:O.shadowMapEnabled&&i.receiveShadow&&0<s,shadowMapType:O.shadowMapType,shadowMapDebug:O.shadowMapDebug,shadowMapCascade:O.shadowMapCascade,alphaTest:t.alphaTest,metal:t.metal,wrapAround:t.wrapAround,doubleSided:t.side===We.DoubleSide,flipSided:t.side===We.BackSide},u=[];if(n?u.push(n):(u.push(t.fragmentShader),u.push(t.vertexShader)),void 0!==t.defines)for(var c in t.defines)u.push(c),u.push(t.defines[c]);for(var c in l)u.push(c),u.push(l[c]);for(var f,p=u.join(),d=0,m=T.length;d<m;d++){var v=T[d];if(v.code===p){(f=v).usedTimes++;break}}void 0===f&&(f=new We.WebGLProgram(O,p,t,l),T.push(f),O.info.memory.programs=T.length);var g=(t.program=f).attributes;if(t.morphTargets)for(var y="morphTarget",x=t.numSupportedMorphTargets=0;x<O.maxMorphTargets;x++)0<=g[y+x]&&t.numSupportedMorphTargets++;if(t.morphNormals){y="morphNormal";for(x=t.numSupportedMorphNormals=0;x<O.maxMorphNormals;x++)0<=g[y+x]&&t.numSupportedMorphNormals++}for(var w in t.uniformsList=[],t.__webglShader.uniforms){var b=t.program.uniforms[w];b&&t.uniformsList.push([t.__webglShader.uniforms[w],b])}}function ee(t,e,r,i,n){L=0,i.needsUpdate&&(i.program&&Rt(i),te(i,e,r,n),i.needsUpdate=!1),i.morphTargets&&(n.__webglMorphTargetInfluences||(n.__webglMorphTargetInfluences=new Float32Array(O.maxMorphTargets)));var o,a,s,h,l,u,c,f,p,d,m=!1,v=!1,g=!1,y=i.program,x=y.uniforms,w=i.__webglShader.uniforms;if(y.id!==A&&(zt.useProgram(y.program),A=y.id,g=v=m=!0),i.id!==C&&(-1===C&&(g=!0),C=i.id,v=!0),(m||t!==E)&&(zt.uniformMatrix4fv(x.projectionMatrix,!1,t.projectionMatrix.elements),S&&zt.uniform1f(x.logDepthBufFC,2/(Math.log(t.far+1)/Math.LN2)),t!==E&&(E=t),(i instanceof We.ShaderMaterial||i instanceof We.MeshPhongMaterial||i.envMap)&&null!==x.cameraPosition&&(Q.setFromMatrixPosition(t.matrixWorld),zt.uniform3f(x.cameraPosition,Q.x,Q.y,Q.z)),(i instanceof We.MeshPhongMaterial||i instanceof We.MeshLambertMaterial||i instanceof We.ShaderMaterial||i.skinning)&&null!==x.viewMatrix&&zt.uniformMatrix4fv(x.viewMatrix,!1,t.matrixWorldInverse.elements)),i.skinning)if(n.bindMatrix&&null!==x.bindMatrix&&zt.uniformMatrix4fv(x.bindMatrix,!1,n.bindMatrix.elements),n.bindMatrixInverse&&null!==x.bindMatrixInverse&&zt.uniformMatrix4fv(x.bindMatrixInverse,!1,n.bindMatrixInverse.elements),lt&&n.skeleton&&n.skeleton.useVertexTexture){if(null!==x.boneTexture){var b=ne();zt.uniform1i(x.boneTexture,b),O.setTexture(n.skeleton.boneTexture,b)}null!==x.boneTextureWidth&&zt.uniform1i(x.boneTextureWidth,n.skeleton.boneTextureWidth),null!==x.boneTextureHeight&&zt.uniform1i(x.boneTextureHeight,n.skeleton.boneTextureHeight)}else n.skeleton&&n.skeleton.boneMatrices&&null!==x.boneGlobalMatrices&&zt.uniformMatrix4fv(x.boneGlobalMatrices,!1,n.skeleton.boneMatrices);return v&&(r&&i.fog&&(f=r,(c=w).fogColor.value=f.color,f instanceof We.Fog?(c.fogNear.value=f.near,c.fogFar.value=f.far):f instanceof We.FogExp2&&(c.fogDensity.value=f.density)),(i instanceof We.MeshPhongMaterial||i instanceof We.MeshLambertMaterial||i.lights)&&($&&(g=!0,function(t){var e,r,i,n,o,a,s,h,l,u=0,c=0,f=0,p=tt,d=p.directional.colors,m=p.directional.positions,v=p.point.colors,g=p.point.positions,y=p.point.distances,x=p.spot.colors,w=p.spot.positions,b=p.spot.distances,M=p.spot.directions,_=p.spot.anglesCos,S=p.spot.exponents,T=p.hemi.skyColors,A=p.hemi.groundColors,C=p.hemi.positions,E=0,L=0,P=0,R=0,F=0,D=0,U=0,B=0,k=0,z=0,V=0,N=0;for(e=0,r=t.length;e<r;e++)if(!(i=t[e]).onlyShadow)if(n=i.color,s=i.intensity,l=i.distance,i instanceof We.AmbientLight){if(!i.visible)continue;O.gammaInput?(u+=n.r*n.r,c+=n.g*n.g,f+=n.b*n.b):(u+=n.r,c+=n.g,f+=n.b)}else if(i instanceof We.DirectionalLight){if(F+=1,!i.visible)continue;J.setFromMatrixPosition(i.matrixWorld),Q.setFromMatrixPosition(i.target.matrixWorld),J.sub(Q),J.normalize(),m[k=3*E]=J.x,m[k+1]=J.y,m[k+2]=J.z,O.gammaInput?ae(d,k,n,s*s):se(d,k,n,s),E+=1}else if(i instanceof We.PointLight){if(D+=1,!i.visible)continue;z=3*L,O.gammaInput?ae(v,z,n,s*s):se(v,z,n,s),Q.setFromMatrixPosition(i.matrixWorld),g[z]=Q.x,g[z+1]=Q.y,g[z+2]=Q.z,y[L]=l,L+=1}else if(i instanceof We.SpotLight){if(U+=1,!i.visible)continue;V=3*P,O.gammaInput?ae(x,V,n,s*s):se(x,V,n,s),J.setFromMatrixPosition(i.matrixWorld),w[V]=J.x,w[V+1]=J.y,w[V+2]=J.z,b[P]=l,Q.setFromMatrixPosition(i.target.matrixWorld),J.sub(Q),J.normalize(),M[V]=J.x,M[V+1]=J.y,M[V+2]=J.z,_[P]=Math.cos(i.angle),S[P]=i.exponent,P+=1}else if(i instanceof We.HemisphereLight){if(B+=1,!i.visible)continue;J.setFromMatrixPosition(i.matrixWorld),J.normalize(),C[N=3*R]=J.x,C[N+1]=J.y,C[N+2]=J.z,o=i.color,a=i.groundColor,O.gammaInput?(ae(T,N,o,h=s*s),ae(A,N,a,h)):(se(T,N,o,s),se(A,N,a,s)),R+=1}for(e=3*E,r=Math.max(d.length,3*F);e<r;e++)d[e]=0;for(e=3*L,r=Math.max(v.length,3*D);e<r;e++)v[e]=0;for(e=3*P,r=Math.max(x.length,3*U);e<r;e++)x[e]=0;for(e=3*R,r=Math.max(T.length,3*B);e<r;e++)T[e]=0;for(e=3*R,r=Math.max(A.length,3*B);e<r;e++)A[e]=0;p.directional.length=E,p.point.length=L,p.spot.length=P,p.hemi.length=R,p.ambient[0]=u,p.ambient[1]=c,p.ambient[2]=f}(e),$=!1),g?(u=tt,(l=w).ambientLightColor.value=u.ambient,l.directionalLightColor.value=u.directional.colors,l.directionalLightDirection.value=u.directional.positions,l.pointLightColor.value=u.point.colors,l.pointLightPosition.value=u.point.positions,l.pointLightDistance.value=u.point.distances,l.spotLightColor.value=u.spot.colors,l.spotLightPosition.value=u.spot.positions,l.spotLightDistance.value=u.spot.distances,l.spotLightDirection.value=u.spot.directions,l.spotLightAngleCos.value=u.spot.anglesCos,l.spotLightExponent.value=u.spot.exponents,l.hemisphereLightSkyColor.value=u.hemi.skyColors,l.hemisphereLightGroundColor.value=u.hemi.groundColors,l.hemisphereLightDirection.value=u.hemi.positions,ie(w,!0)):ie(w,!1)),(i instanceof We.MeshBasicMaterial||i instanceof We.MeshLambertMaterial||i instanceof We.MeshPhongMaterial)&&function(t,e){t.opacity.value=e.opacity,O.gammaInput?t.diffuse.value.copyGammaToLinear(e.color):t.diffuse.value=e.color;t.map.value=e.map,t.lightMap.value=e.lightMap,t.specularMap.value=e.specularMap,t.alphaMap.value=e.alphaMap,e.bumpMap&&(t.bumpMap.value=e.bumpMap,t.bumpScale.value=e.bumpScale);e.normalMap&&(t.normalMap.value=e.normalMap,t.normalScale.value.copy(e.normalScale));var r;e.map?r=e.map:e.specularMap?r=e.specularMap:e.normalMap?r=e.normalMap:e.bumpMap?r=e.bumpMap:e.alphaMap&&(r=e.alphaMap);if(void 0!==r){var i=r.offset,n=r.repeat;t.offsetRepeat.value.set(i.x,i.y,n.x,n.y)}t.envMap.value=e.envMap,t.flipEnvMap.value=e.envMap instanceof We.WebGLRenderTargetCube?1:-1,O.gammaInput,t.reflectivity.value=e.reflectivity;t.refractionRatio.value=e.refractionRatio,t.combine.value=e.combine,t.useRefract.value=e.envMap&&e.envMap.mapping instanceof We.CubeRefractionMapping}(w,i),i instanceof We.LineBasicMaterial?re(w,i):i instanceof We.LineDashedMaterial?(re(w,i),h=i,(s=w).dashSize.value=h.dashSize,s.totalSize.value=h.dashSize+h.gapSize,s.scale.value=h.scale):i instanceof We.PointCloudMaterial?(a=i,(o=w).psColor.value=a.color,o.opacity.value=a.opacity,o.size.value=a.size,o.scale.value=M.height/2,o.map.value=a.map):i instanceof We.MeshPhongMaterial?function(t,e){t.shininess.value=e.shininess,O.gammaInput?(t.ambient.value.copyGammaToLinear(e.ambient),t.emissive.value.copyGammaToLinear(e.emissive),t.specular.value.copyGammaToLinear(e.specular)):(t.ambient.value=e.ambient,t.emissive.value=e.emissive,t.specular.value=e.specular);e.wrapAround&&t.wrapRGB.value.copy(e.wrapRGB)}(w,i):i instanceof We.MeshLambertMaterial?function(t,e){O.gammaInput?(t.ambient.value.copyGammaToLinear(e.ambient),t.emissive.value.copyGammaToLinear(e.emissive)):(t.ambient.value=e.ambient,t.emissive.value=e.emissive);e.wrapAround&&t.wrapRGB.value.copy(e.wrapRGB)}(w,i):i instanceof We.MeshDepthMaterial?(w.mNear.value=t.near,w.mFar.value=t.far,w.opacity.value=i.opacity):i instanceof We.MeshNormalMaterial&&(w.opacity.value=i.opacity),n.receiveShadow&&!i._shadowPass&&function(t,e){if(t.shadowMatrix)for(var r=0,i=0,n=e.length;i<n;i++){var o=e[i];o.castShadow&&((o instanceof We.SpotLight||o instanceof We.DirectionalLight&&!o.shadowCascade)&&(t.shadowMap.value[r]=o.shadowMap,t.shadowMapSize.value[r]=o.shadowMapSize,t.shadowMatrix.value[r]=o.shadowMatrix,t.shadowDarkness.value[r]=o.shadowDarkness,t.shadowBias.value[r]=o.shadowBias,r++))}}(w,e),function(t){for(var e,r,i,n=0,o=t.length;n<o;n++){var a=t[n][0];if(!1!==a.needsUpdate){var s=a.type,h=a.value,l=t[n][1];switch(s){case"1i":zt.uniform1i(l,h);break;case"1f":zt.uniform1f(l,h);break;case"2f":zt.uniform2f(l,h[0],h[1]);break;case"3f":zt.uniform3f(l,h[0],h[1],h[2]);break;case"4f":zt.uniform4f(l,h[0],h[1],h[2],h[3]);break;case"1iv":zt.uniform1iv(l,h);break;case"3iv":zt.uniform3iv(l,h);break;case"1fv":zt.uniform1fv(l,h);break;case"2fv":zt.uniform2fv(l,h);break;case"3fv":zt.uniform3fv(l,h);break;case"4fv":zt.uniform4fv(l,h);break;case"Matrix3fv":zt.uniformMatrix3fv(l,!1,h);break;case"Matrix4fv":zt.uniformMatrix4fv(l,!1,h);break;case"i":zt.uniform1i(l,h);break;case"f":zt.uniform1f(l,h);break;case"v2":zt.uniform2f(l,h.x,h.y);break;case"v3":zt.uniform3f(l,h.x,h.y,h.z);break;case"v4":zt.uniform4f(l,h.x,h.y,h.z,h.w);break;case"c":zt.uniform3f(l,h.r,h.g,h.b);break;case"iv1":zt.uniform1iv(l,h);break;case"iv":zt.uniform3iv(l,h);break;case"fv1":zt.uniform1fv(l,h);break;case"fv":zt.uniform3fv(l,h);break;case"v2v":void 0===a._array&&(a._array=new Float32Array(2*h.length));for(var u=0,c=h.length;u<c;u++)i=2*u,a._array[i]=h[u].x,a._array[i+1]=h[u].y;zt.uniform2fv(l,a._array);break;case"v3v":void 0===a._array&&(a._array=new Float32Array(3*h.length));for(var u=0,c=h.length;u<c;u++)i=3*u,a._array[i]=h[u].x,a._array[i+1]=h[u].y,a._array[i+2]=h[u].z;zt.uniform3fv(l,a._array);break;case"v4v":void 0===a._array&&(a._array=new Float32Array(4*h.length));for(var u=0,c=h.length;u<c;u++)i=4*u,a._array[i]=h[u].x,a._array[i+1]=h[u].y,a._array[i+2]=h[u].z,a._array[i+3]=h[u].w;zt.uniform4fv(l,a._array);break;case"m3":zt.uniformMatrix3fv(l,!1,h.elements);break;case"m3v":void 0===a._array&&(a._array=new Float32Array(9*h.length));for(var u=0,c=h.length;u<c;u++)h[u].flattenToArrayOffset(a._array,9*u);zt.uniformMatrix3fv(l,!1,a._array);break;case"m4":zt.uniformMatrix4fv(l,!1,h.elements);break;case"m4v":void 0===a._array&&(a._array=new Float32Array(16*h.length));for(var u=0,c=h.length;u<c;u++)h[u].flattenToArrayOffset(a._array,16*u);zt.uniformMatrix4fv(l,!1,a._array);break;case"t":if(e=h,r=ne(),zt.uniform1i(l,r),!e)continue;e instanceof We.CubeTexture||e.image instanceof Array&&6===e.image.length?fe(e,r):e instanceof We.WebGLRenderTargetCube?pe(e,r):O.setTexture(e,r);break;case"tv":void 0===a._array&&(a._array=[]);for(var u=0,c=a.value.length;u<c;u++)a._array[u]=ne();zt.uniform1iv(l,a._array);for(var u=0,c=a.value.length;u<c;u++)e=a.value[u],r=a._array[u],e&&O.setTexture(e,r);break;default:console.warn("THREE.WebGLRenderer: Unknown uniform type: "+s)}}}}(i.uniformsList)),p=x,d=n,zt.uniformMatrix4fv(p.modelViewMatrix,!1,d._modelViewMatrix.elements),p.normalMatrix&&zt.uniformMatrix3fv(p.normalMatrix,!1,d._normalMatrix.elements),null!==x.modelMatrix&&zt.uniformMatrix4fv(x.modelMatrix,!1,n.matrixWorld.elements),y}function re(t,e){t.diffuse.value=e.color,t.opacity.value=e.opacity}function ie(t,e){t.ambientLightColor.needsUpdate=e,t.directionalLightColor.needsUpdate=e,t.directionalLightDirection.needsUpdate=e,t.pointLightColor.needsUpdate=e,t.pointLightPosition.needsUpdate=e,t.pointLightDistance.needsUpdate=e,t.spotLightColor.needsUpdate=e,t.spotLightPosition.needsUpdate=e,t.spotLightDistance.needsUpdate=e,t.spotLightDirection.needsUpdate=e,t.spotLightAngleCos.needsUpdate=e,t.spotLightExponent.needsUpdate=e,t.hemisphereLightSkyColor.needsUpdate=e,t.hemisphereLightGroundColor.needsUpdate=e,t.hemisphereLightDirection.needsUpdate=e}function ne(){var t=L;return nt<=t&&console.warn("WebGLRenderer: trying to use "+t+" texture units while this GPU supports only "+nt),L+=1,t}function oe(t,e){t._modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),t._normalMatrix.getNormalMatrix(t._modelViewMatrix)}function ae(t,e,r,i){t[e]=r.r*r.r*i,t[e+1]=r.g*r.g*i,t[e+2]=r.b*r.b*i}function se(t,e,r,i){t[e]=r.r*i,t[e+1]=r.g*i,t[e+2]=r.b*i}function he(t){t!==V&&(zt.lineWidth(t),V=t)}function le(t,e,r){B!==t&&(t?zt.enable(zt.POLYGON_OFFSET_FILL):zt.disable(zt.POLYGON_OFFSET_FILL),B=t),!t||k===e&&z===r||(zt.polygonOffset(e,r),k=e,z=r)}function ue(t,e,r){var i;r?(zt.texParameteri(t,zt.TEXTURE_WRAP_S,ge(e.wrapS)),zt.texParameteri(t,zt.TEXTURE_WRAP_T,ge(e.wrapT)),zt.texParameteri(t,zt.TEXTURE_MAG_FILTER,ge(e.magFilter)),zt.texParameteri(t,zt.TEXTURE_MIN_FILTER,ge(e.minFilter))):(zt.texParameteri(t,zt.TEXTURE_WRAP_S,zt.CLAMP_TO_EDGE),zt.texParameteri(t,zt.TEXTURE_WRAP_T,zt.CLAMP_TO_EDGE),zt.texParameteri(t,zt.TEXTURE_MAG_FILTER,ve(e.magFilter)),zt.texParameteri(t,zt.TEXTURE_MIN_FILTER,ve(e.minFilter))),(i=rt.get("EXT_texture_filter_anisotropic"))&&e.type!==We.FloatType&&(1<e.anisotropy||e.__oldAnisotropy)&&(zt.texParameterf(t,i.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(e.anisotropy,O.getMaxAnisotropy())),e.__oldAnisotropy=e.anisotropy)}function ce(t,e){if(t.width>e||t.height>e){var r=e/Math.max(t.width,t.height),i=document.createElement("canvas");return i.width=Math.floor(t.width*r),i.height=Math.floor(t.height*r),i.getContext("2d").drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),console.log("THREE.WebGLRenderer:",t,"is too big ("+t.width+"x"+t.height+"). Resized to "+i.width+"x"+i.height+"."),i}return t}function fe(t,e){if(6===t.image.length)if(t.needsUpdate){t.image.__webglTextureCube||(t.addEventListener("dispose",St),t.image.__webglTextureCube=zt.createTexture(),O.info.memory.textures++),zt.activeTexture(zt.TEXTURE0+e),zt.bindTexture(zt.TEXTURE_CUBE_MAP,t.image.__webglTextureCube),zt.pixelStorei(zt.UNPACK_FLIP_Y_WEBGL,t.flipY);for(var r=t instanceof We.CompressedTexture,i=t.image[0]instanceof We.DataTexture,n=[],o=0;o<6;o++)!O.autoScaleCubemaps||r||i?n[o]=i?t.image[o].image:t.image[o]:n[o]=ce(t.image[o],st);var a=n[0],s=We.Math.isPowerOfTwo(a.width)&&We.Math.isPowerOfTwo(a.height),h=ge(t.format),l=ge(t.type);ue(zt.TEXTURE_CUBE_MAP,t,s);for(o=0;o<6;o++)if(r)for(var u,c=n[o].mipmaps,f=0,p=c.length;f<p;f++)u=c[f],t.format!==We.RGBAFormat&&t.format!==We.RGBFormat?-1<dt().indexOf(h)?zt.compressedTexImage2D(zt.TEXTURE_CUBE_MAP_POSITIVE_X+o,f,h,u.width,u.height,0,u.data):console.warn("Attempt to load unsupported compressed texture format"):zt.texImage2D(zt.TEXTURE_CUBE_MAP_POSITIVE_X+o,f,h,u.width,u.height,0,h,l,u.data);else i?zt.texImage2D(zt.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,h,n[o].width,n[o].height,0,h,l,n[o].data):zt.texImage2D(zt.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,h,h,l,n[o]);t.generateMipmaps&&s&&zt.generateMipmap(zt.TEXTURE_CUBE_MAP),t.needsUpdate=!1,t.onUpdate&&t.onUpdate()}else zt.activeTexture(zt.TEXTURE0+e),zt.bindTexture(zt.TEXTURE_CUBE_MAP,t.image.__webglTextureCube)}function pe(t,e){zt.activeTexture(zt.TEXTURE0+e),zt.bindTexture(zt.TEXTURE_CUBE_MAP,t.__webglTexture)}function de(t,e,r){zt.bindFramebuffer(zt.FRAMEBUFFER,t),zt.framebufferTexture2D(zt.FRAMEBUFFER,zt.COLOR_ATTACHMENT0,r,e.__webglTexture,0)}function me(t,e){zt.bindRenderbuffer(zt.RENDERBUFFER,t),e.depthBuffer&&!e.stencilBuffer?(zt.renderbufferStorage(zt.RENDERBUFFER,zt.DEPTH_COMPONENT16,e.width,e.height),zt.framebufferRenderbuffer(zt.FRAMEBUFFER,zt.DEPTH_ATTACHMENT,zt.RENDERBUFFER,t)):e.depthBuffer&&e.stencilBuffer?(zt.renderbufferStorage(zt.RENDERBUFFER,zt.DEPTH_STENCIL,e.width,e.height),zt.framebufferRenderbuffer(zt.FRAMEBUFFER,zt.DEPTH_STENCIL_ATTACHMENT,zt.RENDERBUFFER,t)):zt.renderbufferStorage(zt.RENDERBUFFER,zt.RGBA4,e.width,e.height)}function ve(t){return t===We.NearestFilter||t===We.NearestMipMapNearestFilter||t===We.NearestMipMapLinearFilter?zt.NEAREST:zt.LINEAR}function ge(t){var e;if(t===We.RepeatWrapping)return zt.REPEAT;if(t===We.ClampToEdgeWrapping)return zt.CLAMP_TO_EDGE;if(t===We.MirroredRepeatWrapping)return zt.MIRRORED_REPEAT;if(t===We.NearestFilter)return zt.NEAREST;if(t===We.NearestMipMapNearestFilter)return zt.NEAREST_MIPMAP_NEAREST;if(t===We.NearestMipMapLinearFilter)return zt.NEAREST_MIPMAP_LINEAR;if(t===We.LinearFilter)return zt.LINEAR;if(t===We.LinearMipMapNearestFilter)return zt.LINEAR_MIPMAP_NEAREST;if(t===We.LinearMipMapLinearFilter)return zt.LINEAR_MIPMAP_LINEAR;if(t===We.UnsignedByteType)return zt.UNSIGNED_BYTE;if(t===We.UnsignedShort4444Type)return zt.UNSIGNED_SHORT_4_4_4_4;if(t===We.UnsignedShort5551Type)return zt.UNSIGNED_SHORT_5_5_5_1;if(t===We.UnsignedShort565Type)return zt.UNSIGNED_SHORT_5_6_5;if(t===We.ByteType)return zt.BYTE;if(t===We.ShortType)return zt.SHORT;if(t===We.UnsignedShortType)return zt.UNSIGNED_SHORT;if(t===We.IntType)return zt.INT;if(t===We.UnsignedIntType)return zt.UNSIGNED_INT;if(t===We.FloatType)return zt.FLOAT;if(t===We.AlphaFormat)return zt.ALPHA;if(t===We.RGBFormat)return zt.RGB;if(t===We.RGBAFormat)return zt.RGBA;if(t===We.LuminanceFormat)return zt.LUMINANCE;if(t===We.LuminanceAlphaFormat)return zt.LUMINANCE_ALPHA;if(t===We.AddEquation)return zt.FUNC_ADD;if(t===We.SubtractEquation)return zt.FUNC_SUBTRACT;if(t===We.ReverseSubtractEquation)return zt.FUNC_REVERSE_SUBTRACT;if(t===We.ZeroFactor)return zt.ZERO;if(t===We.OneFactor)return zt.ONE;if(t===We.SrcColorFactor)return zt.SRC_COLOR;if(t===We.OneMinusSrcColorFactor)return zt.ONE_MINUS_SRC_COLOR;if(t===We.SrcAlphaFactor)return zt.SRC_ALPHA;if(t===We.OneMinusSrcAlphaFactor)return zt.ONE_MINUS_SRC_ALPHA;if(t===We.DstAlphaFactor)return zt.DST_ALPHA;if(t===We.OneMinusDstAlphaFactor)return zt.ONE_MINUS_DST_ALPHA;if(t===We.DstColorFactor)return zt.DST_COLOR;if(t===We.OneMinusDstColorFactor)return zt.ONE_MINUS_DST_COLOR;if(t===We.SrcAlphaSaturateFactor)return zt.SRC_ALPHA_SATURATE;if(null!==(e=rt.get("WEBGL_compressed_texture_s3tc"))){if(t===We.RGB_S3TC_DXT1_Format)return e.COMPRESSED_RGB_S3TC_DXT1_EXT;if(t===We.RGBA_S3TC_DXT1_Format)return e.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(t===We.RGBA_S3TC_DXT3_Format)return e.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(t===We.RGBA_S3TC_DXT5_Format)return e.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(null!==(e=rt.get("WEBGL_compressed_texture_pvrtc"))){if(t===We.RGB_PVRTC_4BPPV1_Format)return e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(t===We.RGB_PVRTC_2BPPV1_Format)return e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(t===We.RGBA_PVRTC_4BPPV1_Format)return e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(t===We.RGBA_PVRTC_2BPPV1_Format)return e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(null!==(e=rt.get("EXT_blend_minmax"))){if(t===We.MinEquation)return e.MIN_EXT;if(t===We.MaxEquation)return e.MAX_EXT}return 0}this.setFaceCulling=function(t,e){t===We.CullFaceNone?zt.disable(zt.CULL_FACE):(e===We.FrontFaceDirectionCW?zt.frontFace(zt.CW):zt.frontFace(zt.CCW),t===We.CullFaceBack?zt.cullFace(zt.BACK):t===We.CullFaceFront?zt.cullFace(zt.FRONT):zt.cullFace(zt.FRONT_AND_BACK),zt.enable(zt.CULL_FACE))},this.setMaterialFaces=function(t){var e=t.side===We.DoubleSide,r=t.side===We.BackSide;u!==e&&(e?zt.disable(zt.CULL_FACE):zt.enable(zt.CULL_FACE),u=e),w!==r&&(r?zt.frontFace(zt.CW):zt.frontFace(zt.CCW),w=r)},this.setDepthTest=function(t){D!==t&&(t?zt.enable(zt.DEPTH_TEST):zt.disable(zt.DEPTH_TEST),D=t)},this.setDepthWrite=function(t){U!==t&&(zt.depthMask(t),U=t)},this.setBlending=function(t,e,r,i){t!==b&&(t===We.NoBlending?zt.disable(zt.BLEND):t===We.AdditiveBlending?(zt.enable(zt.BLEND),zt.blendEquation(zt.FUNC_ADD),zt.blendFunc(zt.SRC_ALPHA,zt.ONE)):t===We.SubtractiveBlending?(zt.enable(zt.BLEND),zt.blendEquation(zt.FUNC_ADD),zt.blendFunc(zt.ZERO,zt.ONE_MINUS_SRC_COLOR)):t===We.MultiplyBlending?(zt.enable(zt.BLEND),zt.blendEquation(zt.FUNC_ADD),zt.blendFunc(zt.ZERO,zt.SRC_COLOR)):t===We.CustomBlending?zt.enable(zt.BLEND):(zt.enable(zt.BLEND),zt.blendEquationSeparate(zt.FUNC_ADD,zt.FUNC_ADD),zt.blendFuncSeparate(zt.SRC_ALPHA,zt.ONE_MINUS_SRC_ALPHA,zt.ONE,zt.ONE_MINUS_SRC_ALPHA)),b=t),t===We.CustomBlending?(e!==P&&(zt.blendEquation(ge(e)),P=e),r===R&&i===F||(zt.blendFunc(ge(r),ge(i)),R=r,F=i)):F=R=P=null},this.uploadTexture=function(t){void 0===t.__webglInit&&(t.__webglInit=!0,t.addEventListener("dispose",St),t.__webglTexture=zt.createTexture(),O.info.memory.textures++),zt.bindTexture(zt.TEXTURE_2D,t.__webglTexture),zt.pixelStorei(zt.UNPACK_FLIP_Y_WEBGL,t.flipY),zt.pixelStorei(zt.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),zt.pixelStorei(zt.UNPACK_ALIGNMENT,t.unpackAlignment),t.image=ce(t.image,at);var e=t.image,r=We.Math.isPowerOfTwo(e.width)&&We.Math.isPowerOfTwo(e.height),i=ge(t.format),n=ge(t.type);ue(zt.TEXTURE_2D,t,r);var o,a=t.mipmaps;if(t instanceof We.DataTexture)if(0<a.length&&r){for(var s=0,h=a.length;s<h;s++)o=a[s],zt.texImage2D(zt.TEXTURE_2D,s,i,o.width,o.height,0,i,n,o.data);t.generateMipmaps=!1}else zt.texImage2D(zt.TEXTURE_2D,0,i,e.width,e.height,0,i,n,e.data);else if(t instanceof We.CompressedTexture)for(s=0,h=a.length;s<h;s++)o=a[s],t.format!==We.RGBAFormat&&t.format!==We.RGBFormat?-1<dt().indexOf(i)?zt.compressedTexImage2D(zt.TEXTURE_2D,s,i,o.width,o.height,0,o.data):console.warn("Attempt to load unsupported compressed texture format"):zt.texImage2D(zt.TEXTURE_2D,s,i,o.width,o.height,0,i,n,o.data);else if(0<a.length&&r){for(s=0,h=a.length;s<h;s++)o=a[s],zt.texImage2D(zt.TEXTURE_2D,s,i,i,n,o);t.generateMipmaps=!1}else zt.texImage2D(zt.TEXTURE_2D,0,i,i,n,t.image);t.generateMipmaps&&r&&zt.generateMipmap(zt.TEXTURE_2D),t.needsUpdate=!1,t.onUpdate&&t.onUpdate()},this.setTexture=function(t,e){zt.activeTexture(zt.TEXTURE0+e),t.needsUpdate?O.uploadTexture(t):zt.bindTexture(zt.TEXTURE_2D,t.__webglTexture)},this.setRenderTarget=function(t){var e,r,i,n,o,a=t instanceof We.WebGLRenderTargetCube;if(t&&void 0===t.__webglFramebuffer){void 0===t.depthBuffer&&(t.depthBuffer=!0),void 0===t.stencilBuffer&&(t.stencilBuffer=!0),t.addEventListener("dispose",Tt),t.__webglTexture=zt.createTexture(),O.info.memory.textures++;var s=We.Math.isPowerOfTwo(t.width)&&We.Math.isPowerOfTwo(t.height),h=ge(t.format),l=ge(t.type);if(a){t.__webglFramebuffer=[],t.__webglRenderbuffer=[],zt.bindTexture(zt.TEXTURE_CUBE_MAP,t.__webglTexture),ue(zt.TEXTURE_CUBE_MAP,t,s);for(var u=0;u<6;u++)t.__webglFramebuffer[u]=zt.createFramebuffer(),t.__webglRenderbuffer[u]=zt.createRenderbuffer(),zt.texImage2D(zt.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,h,t.width,t.height,0,h,l,null),de(t.__webglFramebuffer[u],t,zt.TEXTURE_CUBE_MAP_POSITIVE_X+u),me(t.__webglRenderbuffer[u],t);s&&zt.generateMipmap(zt.TEXTURE_CUBE_MAP)}else t.__webglFramebuffer=zt.createFramebuffer(),t.shareDepthFrom?t.__webglRenderbuffer=t.shareDepthFrom.__webglRenderbuffer:t.__webglRenderbuffer=zt.createRenderbuffer(),zt.bindTexture(zt.TEXTURE_2D,t.__webglTexture),ue(zt.TEXTURE_2D,t,s),zt.texImage2D(zt.TEXTURE_2D,0,h,t.width,t.height,0,h,l,null),de(t.__webglFramebuffer,t,zt.TEXTURE_2D),t.shareDepthFrom?t.depthBuffer&&!t.stencilBuffer?zt.framebufferRenderbuffer(zt.FRAMEBUFFER,zt.DEPTH_ATTACHMENT,zt.RENDERBUFFER,t.__webglRenderbuffer):t.depthBuffer&&t.stencilBuffer&&zt.framebufferRenderbuffer(zt.FRAMEBUFFER,zt.DEPTH_STENCIL_ATTACHMENT,zt.RENDERBUFFER,t.__webglRenderbuffer):me(t.__webglRenderbuffer,t),s&&zt.generateMipmap(zt.TEXTURE_2D);a?zt.bindTexture(zt.TEXTURE_CUBE_MAP,null):zt.bindTexture(zt.TEXTURE_2D,null),zt.bindRenderbuffer(zt.RENDERBUFFER,null),zt.bindFramebuffer(zt.FRAMEBUFFER,null)}t?(e=a?t.__webglFramebuffer[t.activeCubeFace]:t.__webglFramebuffer,r=t.width,i=t.height,o=n=0):(e=null,r=G,i=H,n=N,o=I),e!==y&&(zt.bindFramebuffer(zt.FRAMEBUFFER,e),zt.viewport(n,o,r,i),y=e),W=r,j=i},this.initMaterial=function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},this.addPrePlugin=function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},this.addPostPlugin=function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},this.updateShadowMap=function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}},We.WebGLRenderTarget=function(t,e,r){this.width=t,this.height=e,r=r||{},this.wrapS=void 0!==r.wrapS?r.wrapS:We.ClampToEdgeWrapping,this.wrapT=void 0!==r.wrapT?r.wrapT:We.ClampToEdgeWrapping,this.magFilter=void 0!==r.magFilter?r.magFilter:We.LinearFilter,this.minFilter=void 0!==r.minFilter?r.minFilter:We.LinearMipMapLinearFilter,this.anisotropy=void 0!==r.anisotropy?r.anisotropy:1,this.offset=new We.Vector2(0,0),this.repeat=new We.Vector2(1,1),this.format=void 0!==r.format?r.format:We.RGBAFormat,this.type=void 0!==r.type?r.type:We.UnsignedByteType,this.depthBuffer=void 0===r.depthBuffer||r.depthBuffer,this.stencilBuffer=void 0===r.stencilBuffer||r.stencilBuffer,this.generateMipmaps=!0,this.shareDepthFrom=null},We.WebGLRenderTarget.prototype={constructor:We.WebGLRenderTarget,setSize:function(t,e){this.width=t,this.height=e},clone:function(){var t=new We.WebGLRenderTarget(this.width,this.height);return t.wrapS=this.wrapS,t.wrapT=this.wrapT,t.magFilter=this.magFilter,t.minFilter=this.minFilter,t.anisotropy=this.anisotropy,t.offset.copy(this.offset),t.repeat.copy(this.repeat),t.format=this.format,t.type=this.type,t.depthBuffer=this.depthBuffer,t.stencilBuffer=this.stencilBuffer,t.generateMipmaps=this.generateMipmaps,t.shareDepthFrom=this.shareDepthFrom,t},dispose:function(){this.dispatchEvent({type:"dispose"})}},We.EventDispatcher.prototype.apply(We.WebGLRenderTarget.prototype),We.WebGLRenderTargetCube=function(t,e,r){We.WebGLRenderTarget.call(this,t,e,r),this.activeCubeFace=0},We.WebGLRenderTargetCube.prototype=Object.create(We.WebGLRenderTarget.prototype),We.WebGLExtensions=function(r){var i={};this.get=function(t){if(void 0!==i[t])return i[t];var e;switch(t){case"OES_texture_float":e=r.getExtension("OES_texture_float");break;case"OES_texture_float_linear":e=r.getExtension("OES_texture_float_linear");break;case"OES_standard_derivatives":e=r.getExtension("OES_standard_derivatives");break;case"EXT_texture_filter_anisotropic":e=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":e=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":e=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case"OES_element_index_uint":e=r.getExtension("OES_element_index_uint");break;case"EXT_blend_minmax":e=r.getExtension("EXT_blend_minmax");break;case"EXT_frag_depth":e=r.getExtension("EXT_frag_depth")}return null===e&&console.log("THREE.WebGLRenderer: "+t+" extension not supported."),i[t]=e}},We.WebGLProgram=(ie=0,function(t,e,r,i){var n=t,o=n.context,a=r.defines,s=r.__webglShader.uniforms,h=r.attributes,l=r.__webglShader.vertexShader,u=r.__webglShader.fragmentShader,c=r.index0AttributeName;void 0===c&&!0===i.morphTargets&&(c="position");var f="SHADOWMAP_TYPE_BASIC";i.shadowMapType===We.PCFShadowMap?f="SHADOWMAP_TYPE_PCF":i.shadowMapType===We.PCFSoftShadowMap&&(f="SHADOWMAP_TYPE_PCF_SOFT");var p,d,m=function(t){var e,r,i=[];for(var n in t)!1!==(e=t[n])&&(r="#define "+n+" "+e,i.push(r));return i.join("\n")}(a),v=o.createProgram();r instanceof We.RawShaderMaterial?d=p="":(p=["precision "+i.precision+" float;","precision "+i.precision+" int;",m,i.supportsVertexTextures?"#define VERTEX_TEXTURES":"",n.gammaInput?"#define GAMMA_INPUT":"",n.gammaOutput?"#define GAMMA_OUTPUT":"","#define MAX_DIR_LIGHTS "+i.maxDirLights,"#define MAX_POINT_LIGHTS "+i.maxPointLights,"#define MAX_SPOT_LIGHTS "+i.maxSpotLights,"#define MAX_HEMI_LIGHTS "+i.maxHemiLights,"#define MAX_SHADOWS "+i.maxShadows,"#define MAX_BONES "+i.maxBones,i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.lightMap?"#define USE_LIGHTMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.vertexColors?"#define USE_COLOR":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals?"#define USE_MORPHNORMALS":"",i.wrapAround?"#define WRAP_AROUND":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+f:"",i.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",i.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","attribute vec2 uv2;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\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",""].join("\n"),d=["precision "+i.precision+" float;","precision "+i.precision+" int;",i.bumpMap||i.normalMap?"#extension GL_OES_standard_derivatives : enable":"",m,"#define MAX_DIR_LIGHTS "+i.maxDirLights,"#define MAX_POINT_LIGHTS "+i.maxPointLights,"#define MAX_SPOT_LIGHTS "+i.maxSpotLights,"#define MAX_HEMI_LIGHTS "+i.maxHemiLights,"#define MAX_SHADOWS "+i.maxShadows,i.alphaTest?"#define ALPHATEST "+i.alphaTest:"",n.gammaInput?"#define GAMMA_INPUT":"",n.gammaOutput?"#define GAMMA_OUTPUT":"",i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.lightMap?"#define USE_LIGHTMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.vertexColors?"#define USE_COLOR":"",i.metal?"#define METAL":"",i.wrapAround?"#define WRAP_AROUND":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+f:"",i.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",i.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",""].join("\n"));var g=new We.WebGLShader(o,o.VERTEX_SHADER,p+l),y=new We.WebGLShader(o,o.FRAGMENT_SHADER,d+u);o.attachShader(v,g),o.attachShader(v,y),void 0!==c&&o.bindAttribLocation(v,0,c),o.linkProgram(v),!1===o.getProgramParameter(v,o.LINK_STATUS)&&(console.error("THREE.WebGLProgram: Could not initialise shader."),console.error("gl.VALIDATE_STATUS",o.getProgramParameter(v,o.VALIDATE_STATUS)),console.error("gl.getError()",o.getError())),""!==o.getProgramInfoLog(v)&&console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",o.getProgramInfoLog(v)),o.deleteShader(g),o.deleteShader(y);var x=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","modelMatrix","cameraPosition","morphTargetInfluences","bindMatrix","bindMatrixInverse"];for(var w in i.useVertexTexture?(x.push("boneTexture"),x.push("boneTextureWidth"),x.push("boneTextureHeight")):x.push("boneGlobalMatrices"),i.logarithmicDepthBuffer&&x.push("logDepthBufFC"),s)x.push(w);this.uniforms=function(t,e,r){for(var i={},n=0,o=r.length;n<o;n++){var a=r[n];i[a]=t.getUniformLocation(e,a)}return i}(o,v,x),x=["position","normal","uv","uv2","tangent","color","skinIndex","skinWeight","lineDistance"];for(var b=0;b<i.maxMorphTargets;b++)x.push("morphTarget"+b);for(b=0;b<i.maxMorphNormals;b++)x.push("morphNormal"+b);for(var M in h)x.push(M);return this.attributes=function(t,e,r){for(var i={},n=0,o=r.length;n<o;n++){var a=r[n];i[a]=t.getAttribLocation(e,a)}return i}(o,v,x),this.attributesKeys=Object.keys(this.attributes),this.id=ie++,this.code=e,this.usedTimes=1,this.program=v,this.vertexShader=g,this.fragmentShader=y,this}),We.WebGLShader=function(t,e,r){var i=t.createShader(e);return t.shaderSource(i,r),t.compileShader(i),!1===t.getShaderParameter(i,t.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile."),""!==t.getShaderInfoLog(i)&&(console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",t.getShaderInfoLog(i)),console.warn(function(t){for(var e=t.split("\n"),r=0;r<e.length;r++)e[r]=r+1+": "+e[r];return e.join("\n")}(r))),i},We.LensFlarePlugin=function(y,x){var w,b,M,_,S,T,A,C,E=y.context,L=function(){var t,e,r,i,n,o,a=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),s=new Uint16Array([0,1,2,0,2,3]);w=E.createBuffer(),b=E.createBuffer(),E.bindBuffer(E.ARRAY_BUFFER,w),E.bufferData(E.ARRAY_BUFFER,a,E.STATIC_DRAW),E.bindBuffer(E.ELEMENT_ARRAY_BUFFER,b),E.bufferData(E.ELEMENT_ARRAY_BUFFER,s,E.STATIC_DRAW),A=E.createTexture(),C=E.createTexture(),E.bindTexture(E.TEXTURE_2D,A),E.texImage2D(E.TEXTURE_2D,0,E.RGB,16,16,0,E.RGB,E.UNSIGNED_BYTE,null),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_S,E.CLAMP_TO_EDGE),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_T,E.CLAMP_TO_EDGE),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MAG_FILTER,E.NEAREST),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MIN_FILTER,E.NEAREST),E.bindTexture(E.TEXTURE_2D,C),E.texImage2D(E.TEXTURE_2D,0,E.RGBA,16,16,0,E.RGBA,E.UNSIGNED_BYTE,null),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_S,E.CLAMP_TO_EDGE),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_WRAP_T,E.CLAMP_TO_EDGE),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MAG_FILTER,E.NEAREST),E.texParameteri(E.TEXTURE_2D,E.TEXTURE_MIN_FILTER,E.NEAREST),t=(T=0<E.getParameter(E.MAX_VERTEX_TEXTURE_IMAGE_UNITS))?{vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","uniform sampler2D occlusionMap;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","varying float vVisibility;","void main() {","vUV = uv;","vec2 pos = position;","if( renderType == 2 ) {","vec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );","visibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );","vVisibility = visibility.r / 9.0;","vVisibility *= 1.0 - visibility.g / 9.0;","vVisibility *= visibility.b / 9.0;","vVisibility *= 1.0 - visibility.a / 9.0;","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["uniform lowp int renderType;","uniform sampler2D map;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","varying float vVisibility;","void main() {","if( renderType == 0 ) {","gl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );","} else if( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * vVisibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")}:{vertexShader:["uniform lowp int renderType;","uniform vec3 screenPosition;","uniform vec2 scale;","uniform float rotation;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uv;","vec2 pos = position;","if( renderType == 2 ) {","pos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;","pos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;","}","gl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );","}"].join("\n"),fragmentShader:["precision mediump float;","uniform lowp int renderType;","uniform sampler2D map;","uniform sampler2D occlusionMap;","uniform float opacity;","uniform vec3 color;","varying vec2 vUV;","void main() {","if( renderType == 0 ) {","gl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );","} else if( renderType == 1 ) {","gl_FragColor = texture2D( map, vUV );","} else {","float visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a;","visibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a;","visibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a;","visibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;","visibility = ( 1.0 - visibility / 4.0 );","vec4 texture = texture2D( map, vUV );","texture.a *= opacity * visibility;","gl_FragColor = texture;","gl_FragColor.rgb *= color;","}","}"].join("\n")},e=t,r=E.createProgram(),i=E.createShader(E.FRAGMENT_SHADER),n=E.createShader(E.VERTEX_SHADER),o="precision "+y.getPrecision()+" float;\n",E.shaderSource(i,o+e.fragmentShader),E.shaderSource(n,o+e.vertexShader),E.compileShader(i),E.compileShader(n),E.attachShader(r,i),E.attachShader(r,n),E.linkProgram(r),M=r,_={vertex:E.getAttribLocation(M,"position"),uv:E.getAttribLocation(M,"uv")},S={renderType:E.getUniformLocation(M,"renderType"),map:E.getUniformLocation(M,"map"),occlusionMap:E.getUniformLocation(M,"occlusionMap"),opacity:E.getUniformLocation(M,"opacity"),color:E.getUniformLocation(M,"color"),scale:E.getUniformLocation(M,"scale"),rotation:E.getUniformLocation(M,"rotation"),screenPosition:E.getUniformLocation(M,"screenPosition")}};this.render=function(t,e,r,i){if(0!==x.length){var n=new We.Vector3,o=i/r,a=.5*r,s=.5*i,h=16/i,l=new We.Vector2(h*o,h),u=new We.Vector3(1,1,0),c=new We.Vector2(1,1);void 0===M&&L(),E.useProgram(M),E.enableVertexAttribArray(_.vertex),E.enableVertexAttribArray(_.uv),E.uniform1i(S.occlusionMap,0),E.uniform1i(S.map,1),E.bindBuffer(E.ARRAY_BUFFER,w),E.vertexAttribPointer(_.vertex,2,E.FLOAT,!1,16,0),E.vertexAttribPointer(_.uv,2,E.FLOAT,!1,16,8),E.bindBuffer(E.ELEMENT_ARRAY_BUFFER,b),E.disable(E.CULL_FACE),E.depthMask(!1);for(var f=0,p=x.length;f<p;f++){h=16/i,l.set(h*o,h);var d=x[f];if(n.set(d.matrixWorld.elements[12],d.matrixWorld.elements[13],d.matrixWorld.elements[14]),n.applyMatrix4(e.matrixWorldInverse),n.applyProjection(e.projectionMatrix),u.copy(n),c.x=u.x*a+a,c.y=u.y*s+s,T||0<c.x&&c.x<r&&0<c.y&&c.y<i){E.activeTexture(E.TEXTURE1),E.bindTexture(E.TEXTURE_2D,A),E.copyTexImage2D(E.TEXTURE_2D,0,E.RGB,c.x-8,c.y-8,16,16,0),E.uniform1i(S.renderType,0),E.uniform2f(S.scale,l.x,l.y),E.uniform3f(S.screenPosition,u.x,u.y,u.z),E.disable(E.BLEND),E.enable(E.DEPTH_TEST),E.drawElements(E.TRIANGLES,6,E.UNSIGNED_SHORT,0),E.activeTexture(E.TEXTURE0),E.bindTexture(E.TEXTURE_2D,C),E.copyTexImage2D(E.TEXTURE_2D,0,E.RGBA,c.x-8,c.y-8,16,16,0),E.uniform1i(S.renderType,1),E.disable(E.DEPTH_TEST),E.activeTexture(E.TEXTURE1),E.bindTexture(E.TEXTURE_2D,A),E.drawElements(E.TRIANGLES,6,E.UNSIGNED_SHORT,0),d.positionScreen.copy(u),d.customUpdateCallback?d.customUpdateCallback(d):d.updateLensFlares(),E.uniform1i(S.renderType,2),E.enable(E.BLEND);for(var m=0,v=d.lensFlares.length;m<v;m++){var g=d.lensFlares[m];.001<g.opacity&&.001<g.scale&&(u.x=g.x,u.y=g.y,u.z=g.z,h=g.size*g.scale/i,l.x=h*o,l.y=h,E.uniform3f(S.screenPosition,u.x,u.y,u.z),E.uniform2f(S.scale,l.x,l.y),E.uniform1f(S.rotation,g.rotation),E.uniform1f(S.opacity,g.opacity),E.uniform3f(S.color,g.color.r,g.color.g,g.color.b),y.setBlending(g.blending,g.blendEquation,g.blendSrc,g.blendDst),y.setTexture(g.texture,1),E.drawElements(E.TRIANGLES,6,E.UNSIGNED_SHORT,0))}}}E.enable(E.CULL_FACE),E.enable(E.DEPTH_TEST),E.depthMask(!0),y.resetGLState()}}},We.ShadowMapPlugin=function(C,E,s,L){var P,R,F,D,U=C.context,B=new We.Frustum,k=new We.Matrix4,h=new We.Vector3,l=new We.Vector3,z=new We.Vector3,V=[],t=We.ShaderLib.depthRGBA,e=We.UniformsUtils.clone(t.uniforms);function N(t,e,r){if(e.visible){var i=s[e.id];if(i&&e.castShadow&&(!1===e.frustumCulled||!0===B.intersectsObject(e)))for(var n=0,o=i.length;n<o;n++){var a=i[n];e._modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,e.matrixWorld),V.push(a)}for(n=0,o=e.children.length;n<o;n++)N(t,e.children[n],r)}}function O(t,e){var r=new We.DirectionalLight;r.isVirtual=!0,r.onlyShadow=!0,r.castShadow=!0,r.shadowCameraNear=t.shadowCameraNear,r.shadowCameraFar=t.shadowCameraFar,r.shadowCameraLeft=t.shadowCameraLeft,r.shadowCameraRight=t.shadowCameraRight,r.shadowCameraBottom=t.shadowCameraBottom,r.shadowCameraTop=t.shadowCameraTop,r.shadowCameraVisible=t.shadowCameraVisible,r.shadowDarkness=t.shadowDarkness,r.shadowBias=t.shadowCascadeBias[e],r.shadowMapWidth=t.shadowCascadeWidth[e],r.shadowMapHeight=t.shadowCascadeHeight[e],r.pointsWorld=[],r.pointsFrustum=[];for(var i=r.pointsWorld,n=r.pointsFrustum,o=0;o<8;o++)i[o]=new We.Vector3,n[o]=new We.Vector3;var a=t.shadowCascadeNearZ[e],s=t.shadowCascadeFarZ[e];return n[0].set(-1,-1,a),n[1].set(1,-1,a),n[2].set(-1,1,a),n[3].set(1,1,a),n[4].set(-1,-1,s),n[5].set(1,-1,s),n[6].set(-1,1,s),n[7].set(1,1,s),r}function I(t,e){var r=t.shadowCascadeArray[e];r.position.copy(t.position),r.target.position.copy(t.target.position),r.lookAt(r.target),r.shadowCameraVisible=t.shadowCameraVisible,r.shadowDarkness=t.shadowDarkness,r.shadowBias=t.shadowCascadeBias[e];var i=t.shadowCascadeNearZ[e],n=t.shadowCascadeFarZ[e],o=r.pointsFrustum;o[0].z=i,o[1].z=i,o[2].z=i,o[3].z=i,o[4].z=n,o[5].z=n,o[6].z=n,o[7].z=n}function G(t,e){var r=e.shadowCamera,i=e.pointsFrustum,n=e.pointsWorld;h.set(1/0,1/0,1/0),l.set(-1/0,-1/0,-1/0);for(var o=0;o<8;o++){var a=n[o];a.copy(i[o]),a.unproject(t),a.applyMatrix4(r.matrixWorldInverse),a.x<h.x&&(h.x=a.x),a.x>l.x&&(l.x=a.x),a.y<h.y&&(h.y=a.y),a.y>l.y&&(l.y=a.y),a.z<h.z&&(h.z=a.z),a.z>l.z&&(l.z=a.z)}r.left=h.x,r.right=l.x,r.top=l.y,r.bottom=h.y,r.updateProjectionMatrix()}P=new We.ShaderMaterial({uniforms:e,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader}),R=new We.ShaderMaterial({uniforms:e,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,morphTargets:!0}),F=new We.ShaderMaterial({uniforms:e,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,skinning:!0}),D=new We.ShaderMaterial({uniforms:e,vertexShader:t.vertexShader,fragmentShader:t.fragmentShader,morphTargets:!0,skinning:!0}),P._shadowPass=!0,R._shadowPass=!0,F._shadowPass=!0,D._shadowPass=!0,this.render=function(t,e){if(!1!==C.shadowMapEnabled){var r,i,n,o,a,s,h,l,u,c,f,p,d,m,v=[],g=0;for(U.clearColor(1,1,1,1),U.disable(U.BLEND),U.enable(U.CULL_FACE),U.frontFace(U.CCW),C.shadowMapCullFace===We.CullFaceFront?U.cullFace(U.FRONT):U.cullFace(U.BACK),C.setDepthTest(!0),r=0,i=E.length;r<i;r++)if((d=E[r]).castShadow)if(d instanceof We.DirectionalLight&&d.shadowCascade)for(a=0;a<d.shadowCascadeCount;a++){var y;if(d.shadowCascadeArray[a])y=d.shadowCascadeArray[a];else{(y=O(d,a)).originalCamera=e;var x=new We.Gyroscope;x.position.copy(d.shadowCascadeOffset),x.add(y),x.add(y.target),e.add(x),d.shadowCascadeArray[a]=y,console.log("Created virtualLight",y)}I(d,a),v[g]=y,g++}else v[g]=d,g++;for(r=0,i=v.length;r<i;r++){if(!(d=v[r]).shadowMap){var w=We.LinearFilter;C.shadowMapType===We.PCFSoftShadowMap&&(w=We.NearestFilter);var b={minFilter:w,magFilter:w,format:We.RGBAFormat};d.shadowMap=new We.WebGLRenderTarget(d.shadowMapWidth,d.shadowMapHeight,b),d.shadowMapSize=new We.Vector2(d.shadowMapWidth,d.shadowMapHeight),d.shadowMatrix=new We.Matrix4}if(!d.shadowCamera){if(d instanceof We.SpotLight)d.shadowCamera=new We.PerspectiveCamera(d.shadowCameraFov,d.shadowMapWidth/d.shadowMapHeight,d.shadowCameraNear,d.shadowCameraFar);else{if(!(d instanceof We.DirectionalLight)){console.error("Unsupported light type for shadow");continue}d.shadowCamera=new We.OrthographicCamera(d.shadowCameraLeft,d.shadowCameraRight,d.shadowCameraTop,d.shadowCameraBottom,d.shadowCameraNear,d.shadowCameraFar)}t.add(d.shadowCamera),!0===t.autoUpdate&&t.updateMatrixWorld()}var M,_,S;for(d.shadowCameraVisible&&!d.cameraHelper&&(d.cameraHelper=new We.CameraHelper(d.shadowCamera),t.add(d.cameraHelper)),d.isVirtual&&y.originalCamera==e&&G(e,d),s=d.shadowMap,h=d.shadowMatrix,(l=d.shadowCamera).position.setFromMatrixPosition(d.matrixWorld),z.setFromMatrixPosition(d.target.matrixWorld),l.lookAt(z),l.updateMatrixWorld(),l.matrixWorldInverse.getInverse(l.matrixWorld),d.cameraHelper&&(d.cameraHelper.visible=d.shadowCameraVisible),d.shadowCameraVisible&&d.cameraHelper.update(),h.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),h.multiply(l.projectionMatrix),h.multiply(l.matrixWorldInverse),k.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse),B.setFromMatrix(k),C.setRenderTarget(s),C.clear(),V.length=0,N(t,t,l),n=0,o=V.length;n<o;n++)p=(f=V[n]).object,u=f.buffer,M=(m=p).material instanceof We.MeshFaceMaterial?m.material.materials[0]:m.material,_=void 0!==p.geometry.morphTargets&&0<p.geometry.morphTargets.length&&M.morphTargets,S=p instanceof We.SkinnedMesh&&M.skinning,c=p.customDepthMaterial?p.customDepthMaterial:S?_?D:F:_?R:P,C.setMaterialFaces(M),u instanceof We.BufferGeometry?C.renderBufferDirect(l,E,null,c,u,p):C.renderBuffer(l,E,null,c,u,p);for(n=0,o=L.length;n<o;n++)(p=(f=L[n]).object).visible&&p.castShadow&&(p._modelViewMatrix.multiplyMatrices(l.matrixWorldInverse,p.matrixWorld),C.renderImmediateObject(l,E,null,P,p))}var T=C.getClearColor(),A=C.getClearAlpha();U.clearColor(T.r,T.g,T.b,A),U.enable(U.BLEND),C.shadowMapCullFace===We.CullFaceFront&&U.cullFace(U.BACK),C.resetGLState()}}},We.SpritePlugin=function(c,f){var p,d,m,v,g,y,x=c.context,w=function(){var t,e,r,i=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),n=new Uint16Array([0,1,2,0,2,3]);p=x.createBuffer(),d=x.createBuffer(),x.bindBuffer(x.ARRAY_BUFFER,p),x.bufferData(x.ARRAY_BUFFER,i,x.STATIC_DRAW),x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,d),x.bufferData(x.ELEMENT_ARRAY_BUFFER,n,x.STATIC_DRAW),t=x.createProgram(),e=x.createShader(x.VERTEX_SHADER),r=x.createShader(x.FRAGMENT_SHADER),x.shaderSource(e,["precision "+c.getPrecision()+" float;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float rotation;","uniform vec2 scale;","uniform vec2 uvOffset;","uniform vec2 uvScale;","attribute vec2 position;","attribute vec2 uv;","varying vec2 vUV;","void main() {","vUV = uvOffset + uv * uvScale;","vec2 alignedPosition = position * scale;","vec2 rotatedPosition;","rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;","rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;","vec4 finalPosition;","finalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );","finalPosition.xy += rotatedPosition;","finalPosition = projectionMatrix * finalPosition;","gl_Position = finalPosition;","}"].join("\n")),x.shaderSource(r,["precision "+c.getPrecision()+" float;","uniform vec3 color;","uniform sampler2D map;","uniform float opacity;","uniform int fogType;","uniform vec3 fogColor;","uniform float fogDensity;","uniform float fogNear;","uniform float fogFar;","uniform float alphaTest;","varying vec2 vUV;","void main() {","vec4 texture = texture2D( map, vUV );","if ( texture.a < alphaTest ) discard;","gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );","if ( fogType > 0 ) {","float depth = gl_FragCoord.z / gl_FragCoord.w;","float fogFactor = 0.0;","if ( fogType == 1 ) {","fogFactor = smoothstep( fogNear, fogFar, depth );","} else {","const float LOG2 = 1.442695;","float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );","fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );","}","gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );","}","}"].join("\n")),x.compileShader(e),x.compileShader(r),x.attachShader(t,e),x.attachShader(t,r),x.linkProgram(t),m=t,v={position:x.getAttribLocation(m,"position"),uv:x.getAttribLocation(m,"uv")},g={uvOffset:x.getUniformLocation(m,"uvOffset"),uvScale:x.getUniformLocation(m,"uvScale"),rotation:x.getUniformLocation(m,"rotation"),scale:x.getUniformLocation(m,"scale"),color:x.getUniformLocation(m,"color"),map:x.getUniformLocation(m,"map"),opacity:x.getUniformLocation(m,"opacity"),modelViewMatrix:x.getUniformLocation(m,"modelViewMatrix"),projectionMatrix:x.getUniformLocation(m,"projectionMatrix"),fogType:x.getUniformLocation(m,"fogType"),fogDensity:x.getUniformLocation(m,"fogDensity"),fogNear:x.getUniformLocation(m,"fogNear"),fogFar:x.getUniformLocation(m,"fogFar"),fogColor:x.getUniformLocation(m,"fogColor"),alphaTest:x.getUniformLocation(m,"alphaTest")};var o=document.createElement("canvas");o.width=8,o.height=8;var a=o.getContext("2d");a.fillStyle="white",a.fillRect(0,0,8,8),(y=new We.Texture(o)).needsUpdate=!0};function b(t,e){return t.z!==e.z?e.z-t.z:e.id-t.id}this.render=function(t,e){if(0!==f.length){void 0===m&&w(),x.useProgram(m),x.enableVertexAttribArray(v.position),x.enableVertexAttribArray(v.uv),x.disable(x.CULL_FACE),x.enable(x.BLEND),x.bindBuffer(x.ARRAY_BUFFER,p),x.vertexAttribPointer(v.position,2,x.FLOAT,!1,16,0),x.vertexAttribPointer(v.uv,2,x.FLOAT,!1,16,8),x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,d),x.uniformMatrix4fv(g.projectionMatrix,!1,e.projectionMatrix.elements),x.activeTexture(x.TEXTURE0),x.uniform1i(g.map,0);var r=0,i=0,n=t.fog;n?(x.uniform3f(g.fogColor,n.color.r,n.color.g,n.color.b),n instanceof We.Fog?(x.uniform1f(g.fogNear,n.near),x.uniform1f(g.fogFar,n.far),x.uniform1i(g.fogType,1),i=r=1):n instanceof We.FogExp2&&(x.uniform1f(g.fogDensity,n.density),x.uniform1i(g.fogType,2),i=r=2)):(x.uniform1i(g.fogType,0),i=r=0);for(var o=0,a=f.length;o<a;o++){(h=f[o])._modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,h.matrixWorld),null===h.renderDepth?h.z=-h._modelViewMatrix.elements[14]:h.z=h.renderDepth}f.sort(b);var s=[];for(o=0,a=f.length;o<a;o++){var h,l=(h=f[o]).material;x.uniform1f(g.alphaTest,l.alphaTest),x.uniformMatrix4fv(g.modelViewMatrix,!1,h._modelViewMatrix.elements),s[0]=h.scale.x,s[1]=h.scale.y;var u=0;t.fog&&l.fog&&(u=i),r!==u&&(x.uniform1i(g.fogType,u),r=u),null!==l.map?(x.uniform2f(g.uvOffset,l.map.offset.x,l.map.offset.y),x.uniform2f(g.uvScale,l.map.repeat.x,l.map.repeat.y)):(x.uniform2f(g.uvOffset,0,0),x.uniform2f(g.uvScale,1,1)),x.uniform1f(g.opacity,l.opacity),x.uniform3f(g.color,l.color.r,l.color.g,l.color.b),x.uniform1f(g.rotation,l.rotation),x.uniform2fv(g.scale,s),c.setBlending(l.blending,l.blendEquation,l.blendSrc,l.blendDst),c.setDepthTest(l.depthTest),c.setDepthWrite(l.depthWrite),l.map&&l.map.image&&l.map.image.width?c.setTexture(l.map,0):c.setTexture(y,0),x.drawElements(x.TRIANGLES,6,x.UNSIGNED_SHORT,0)}x.enable(x.CULL_FACE),c.resetGLState()}}},We.GeometryUtils={merge:function(t,e,r){var i;console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead."),e instanceof We.Mesh&&(e.matrixAutoUpdate&&e.updateMatrix(),i=e.matrix,e=e.geometry),t.merge(e,i,r)},center:function(t){return console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead."),t.center()}},We.ImageUtils={crossOrigin:void 0,loadTexture:function(t,e,r,i){var n=new We.ImageLoader;n.crossOrigin=this.crossOrigin;var o=new We.Texture(void 0,e);return n.load(t,function(t){o.image=t,o.needsUpdate=!0,r&&r(o)},void 0,function(t){i&&i(t)}),o.sourceFile=t,o},loadTextureCube:function(t,e,r,i){var n=new We.ImageLoader;n.crossOrigin=this.crossOrigin;var o=new We.CubeTexture([],e);o.flipY=!1;for(var a=0,s=function(e){n.load(t[e],function(t){o.images[e]=t,6===(a+=1)&&(o.needsUpdate=!0,r&&r(o))})},h=0,l=t.length;h<l;++h)s(h);return o},loadCompressedTexture:function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},loadCompressedTextureCube:function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")},getNormalMap:function(t,e){var r=function(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]};e|=1;var i=t.width,n=t.height,o=document.createElement("canvas");o.width=i,o.height=n;var a=o.getContext("2d");a.drawImage(t,0,0);for(var s,h,l,u,c=a.getImageData(0,0,i,n).data,f=a.createImageData(i,n),p=f.data,d=0;d<i;d++)for(var m=0;m<n;m++){var v=m-1<0?0:m-1,g=n-1<m+1?n-1:m+1,y=d-1<0?0:d-1,x=i-1<d+1?i-1:d+1,w=[],b=[0,0,c[4*(m*i+d)]/255*e];w.push([-1,0,c[4*(m*i+y)]/255*e]),w.push([-1,-1,c[4*(v*i+y)]/255*e]),w.push([0,-1,c[4*(v*i+d)]/255*e]),w.push([1,-1,c[4*(v*i+x)]/255*e]),w.push([1,0,c[4*(m*i+x)]/255*e]),w.push([1,1,c[4*(g*i+x)]/255*e]),w.push([0,1,c[4*(g*i+d)]/255*e]),w.push([-1,1,c[4*(g*i+y)]/255*e]);for(var M=[],_=w.length,S=0;S<_;S++){var T=w[S],A=w[(S+1)%_];T=r(T,b),A=r(A,b),M.push((u=A,s=[(l=T)[1]*u[2]-l[2]*u[1],l[2]*u[0]-l[0]*u[2],l[0]*u[1]-l[1]*u[0]],void 0,h=Math.sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2]),[s[0]/h,s[1]/h,s[2]/h]))}var C=[0,0,0];for(S=0;S<M.length;S++)C[0]+=M[S][0],C[1]+=M[S][1],C[2]+=M[S][2];C[0]/=M.length,C[1]/=M.length,C[2]/=M.length;var E=4*(m*i+d);p[E]=(C[0]+1)/2*255|0,p[E+1]=(C[1]+1)/2*255|0,p[E+2]=255*C[2]|0,p[E+3]=255}return a.putImageData(f,0,0),o},generateDataTexture:function(t,e,r){for(var i=t*e,n=new Uint8Array(3*i),o=Math.floor(255*r.r),a=Math.floor(255*r.g),s=Math.floor(255*r.b),h=0;h<i;h++)n[3*h]=o,n[3*h+1]=a,n[3*h+2]=s;var l=new We.DataTexture(n,t,e,We.RGBFormat);return l.needsUpdate=!0,l}},We.SceneUtils={createMultiMaterialObject:function(t,e){for(var r=new We.Object3D,i=0,n=e.length;i<n;i++)r.add(new We.Mesh(t,e[i]));return r},detach:function(t,e,r){t.applyMatrix(e.matrixWorld),e.remove(t),r.add(t)},attach:function(t,e,r){var i=new We.Matrix4;i.getInverse(r.matrixWorld),t.applyMatrix(i),e.remove(t),r.add(t)}},We.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){try{return this.faces[this.face][this.weight][this.style]}catch(t){throw"The font "+this.face+" with "+this.weight+" weight and "+this.style+" style is missing."}},loadFace:function(t){var e=t.familyName.toLowerCase();this.faces[e]=this.faces[e]||{},this.faces[e][t.cssFontWeight]=this.faces[e][t.cssFontWeight]||{},this.faces[e][t.cssFontWeight][t.cssFontStyle]=t;this.faces[e][t.cssFontWeight][t.cssFontStyle]=t;return t},drawText:function(t){var e,r=this.getFace(),i=this.size/r.resolution,n=0,o=String(t).split(""),a=o.length,s=[];for(e=0;e<a;e++){var h=new We.Path,l=this.extractGlyphPoints(o[e],r,i,n,h);n+=l.offset,s.push(l.path)}return{paths:s,offset:n/2}},extractGlyphPoints:function(t,e,r,i,n){var o,a,s,h,l,u,c,f,p,d,m,v,g,y,x,w,b,M,_=[],S=e.glyphs[t]||e.glyphs["?"];if(S){if(S.o)for(l=(h=S._cachedOutline||(S._cachedOutline=S.o.split(" "))).length,c=u=r,o=0;o<l;)switch(h[o++]){case"m":f=h[o++]*u+i,p=h[o++]*c,n.moveTo(f,p);break;case"l":f=h[o++]*u+i,p=h[o++]*c,n.lineTo(f,p);break;case"q":if(d=h[o++]*u+i,m=h[o++]*c,y=h[o++]*u+i,x=h[o++]*c,n.quadraticCurveTo(y,x,d,m),M=_[_.length-1])for(v=M.x,g=M.y,a=1,s=this.divisions;a<=s;a++){var T=a/s;We.Shape.Utils.b2(T,v,y,d),We.Shape.Utils.b2(T,g,x,m)}break;case"b":if(d=h[o++]*u+i,m=h[o++]*c,y=h[o++]*u+i,x=h[o++]*c,w=h[o++]*u+i,b=h[o++]*c,n.bezierCurveTo(y,x,w,b,d,m),M=_[_.length-1])for(v=M.x,g=M.y,a=1,s=this.divisions;a<=s;a++)T=a/s,We.Shape.Utils.b3(T,v,y,w,d),We.Shape.Utils.b3(T,g,x,b,m)}return{offset:S.ha*r,path:n}}}},We.FontUtils.generateShapes=function(t,e){var r=void 0!==(e=e||{}).size?e.size:100,i=void 0!==e.curveSegments?e.curveSegments:4,n=void 0!==e.font?e.font:"helvetiker",o=void 0!==e.weight?e.weight:"normal",a=void 0!==e.style?e.style:"normal";We.FontUtils.size=r,We.FontUtils.divisions=i,We.FontUtils.face=n,We.FontUtils.weight=o,We.FontUtils.style=a;for(var s=We.FontUtils.drawText(t).paths,h=[],l=0,u=s.length;l<u;l++)Array.prototype.push.apply(h,s[l].toShapes());return h},ne=We.FontUtils,oe=function(t){for(var e=t.length,r=0,i=e-1,n=0;n<e;i=n++)r+=t[i].x*t[n].y-t[n].x*t[i].y;return.5*r},ae=function(t,e,r,i,n,o){var a,s,h,l,u,c,f,p,d,m,v,g,y,x,w;if(s=t[o[e]].x,h=t[o[e]].y,l=t[o[r]].x,u=t[o[r]].y,c=t[o[i]].x,(l-s)*((f=t[o[i]].y)-h)-(u-h)*(c-s)<1e-10)return!1;for(m=c-l,v=f-u,g=s-c,y=h-f,x=l-s,w=u-h,a=0;a<n;a++)if(p=t[o[a]].x,d=t[o[a]].y,!(p===s&&d===h||p===l&&d===u||p===c&&d===f)&&-1e-10<=m*(d-u)-v*(p-l)&&-1e-10<=g*(d-f)-y*(p-c)&&-1e-10<=x*(d-h)-w*(p-s))return!1;return!0},ne.Triangulate=function(t,e){var r=t.length;if(r<3)return null;var i,n,o,a=[],s=[],h=[];if(0<oe(t))for(n=0;n<r;n++)s[n]=n;else for(n=0;n<r;n++)s[n]=r-1-n;var l=r,u=2*l;for(n=l-1;2<l;){if(u--<=0)return console.log("Warning, unable to triangulate polygon!"),e?h:a;if(l<=(i=n)&&(i=0),l<=(n=i+1)&&(n=0),l<=(o=n+1)&&(o=0),ae(t,i,n,o,l,s)){var c,f,p,d,m;for(c=s[i],f=s[n],p=s[o],a.push([t[c],t[f],t[p]]),h.push([s[i],s[n],s[o]]),m=(d=n)+1;m<l;d++,m++)s[d]=s[m];u=2*--l}}return e?h:a},ne.Triangulate.area=oe,He._typeface_js={faces:We.FontUtils.faces,loadFace:We.FontUtils.loadFace},We.typeface_js=He._typeface_js,We.Audio=function(t){We.Object3D.call(this),this.type="Audio",this.context=t.context,this.source=this.context.createBufferSource(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.panner=this.context.createPanner(),this.panner.connect(this.gain)},We.Audio.prototype=Object.create(We.Object3D.prototype),We.Audio.prototype.load=function(t){var e=this,r=new XMLHttpRequest;return r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=function(t){e.context.decodeAudioData(this.response,function(t){e.source.buffer=t,e.source.connect(e.panner),e.source.start(0)})},r.send(),this},We.Audio.prototype.setLoop=function(t){this.source.loop=t},We.Audio.prototype.setRefDistance=function(t){this.panner.refDistance=t},We.Audio.prototype.setRolloffFactor=function(t){this.panner.rolloffFactor=t},We.Audio.prototype.updateMatrixWorld=(se=new We.Vector3,function(t){We.Object3D.prototype.updateMatrixWorld.call(this,t),se.setFromMatrixPosition(this.matrixWorld),this.panner.setPosition(se.x,se.y,se.z)}),We.AudioListener=function(){We.Object3D.call(this),this.type="AudioListener",this.context=new(window.AudioContext||window.webkitAudioContext)},We.AudioListener.prototype=Object.create(We.Object3D.prototype),We.AudioListener.prototype.updateMatrixWorld=(he=new We.Vector3,le=new We.Quaternion,ue=new We.Vector3,ce=new We.Vector3,fe=new We.Vector3,pe=new We.Vector3,function(t){We.Object3D.prototype.updateMatrixWorld.call(this,t);var e=this.context.listener;this.matrixWorld.decompose(he,le,ue),ce.set(0,0,-1).applyQuaternion(le),fe.subVectors(he,pe),e.setPosition(he.x,he.y,he.z),e.setOrientation(ce.x,ce.y,ce.z,this.up.x,this.up.y,this.up.z),e.setVelocity(fe.x,fe.y,fe.z),pe.copy(he)}),We.Curve=function(){},We.Curve.prototype.getPoint=function(t){return console.log("Warning, getPoint() not implemented!"),null},We.Curve.prototype.getPointAt=function(t){var e=this.getUtoTmapping(t);return this.getPoint(e)},We.Curve.prototype.getPoints=function(t){t||(t=5);var e,r=[];for(e=0;e<=t;e++)r.push(this.getPoint(e/t));return r},We.Curve.prototype.getSpacedPoints=function(t){t||(t=5);var e,r=[];for(e=0;e<=t;e++)r.push(this.getPointAt(e/t));return r},We.Curve.prototype.getLength=function(){var t=this.getLengths();return t[t.length-1]},We.Curve.prototype.getLengths=function(t){if(t||(t=this.__arcLengthDivisions?this.__arcLengthDivisions:200),this.cacheArcLengths&&this.cacheArcLengths.length==t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var e,r,i=[],n=this.getPoint(0),o=0;for(i.push(0),r=1;r<=t;r++)o+=(e=this.getPoint(r/t)).distanceTo(n),i.push(o),n=e;return this.cacheArcLengths=i},We.Curve.prototype.updateArcLengths=function(){this.needsUpdate=!0,this.getLengths()},We.Curve.prototype.getUtoTmapping=function(t,e){var r,i=this.getLengths(),n=0,o=i.length;r=e||t*i[o-1];for(var a,s=0,h=o-1;s<=h;)if((a=i[n=Math.floor(s+(h-s)/2)]-r)<0)s=n+1;else{if(!(0<a)){h=n;break}h=n-1}if(i[n=h]==r)return n/(o-1);var l=i[n];return(n+(r-l)/(i[n+1]-l))/(o-1)},We.Curve.prototype.getTangent=function(t){var e=t-1e-4,r=t+1e-4;e<0&&(e=0),1<r&&(r=1);var i=this.getPoint(e);return this.getPoint(r).clone().sub(i).normalize()},We.Curve.prototype.getTangentAt=function(t){var e=this.getUtoTmapping(t);return this.getTangent(e)},We.Curve.Utils={tangentQuadraticBezier:function(t,e,r,i){return 2*(1-t)*(r-e)+2*t*(i-r)},tangentCubicBezier:function(t,e,r,i,n){return-3*e*(1-t)*(1-t)+3*r*(1-t)*(1-t)-6*t*r*(1-t)+6*t*i*(1-t)-3*t*t*i+3*t*t*n},tangentSpline:function(t,e,r,i,n){return 6*t*t-6*t+(3*t*t-4*t+1)+(-6*t*t+6*t)+(3*t*t-2*t)},interpolate:function(t,e,r,i,n){var o=.5*(r-t),a=.5*(i-e),s=n*n;return(2*e-2*r+o+a)*(n*s)+(-3*e+3*r-2*o-a)*s+o*n+e}},We.Curve.create=function(t,e){return t.prototype=Object.create(We.Curve.prototype),t.prototype.getPoint=e,t},We.CurvePath=function(){this.curves=[],this.bends=[],this.autoClose=!1},We.CurvePath.prototype=Object.create(We.Curve.prototype),We.CurvePath.prototype.add=function(t){this.curves.push(t)},We.CurvePath.prototype.checkConnection=function(){},We.CurvePath.prototype.closePath=function(){var t=this.curves[0].getPoint(0),e=this.curves[this.curves.length-1].getPoint(1);t.equals(e)||this.curves.push(new We.LineCurve(e,t))},We.CurvePath.prototype.getPoint=function(t){for(var e,r=t*this.getLength(),i=this.getCurveLengths(),n=0;n<i.length;){if(i[n]>=r){var o=1-(i[n]-r)/(e=this.curves[n]).getLength();return e.getPointAt(o)}n++}return null},We.CurvePath.prototype.getLength=function(){var t=this.getCurveLengths();return t[t.length-1]},We.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var t,e=[],r=0,i=this.curves.length;for(t=0;t<i;t++)r+=this.curves[t].getLength(),e.push(r);return this.cacheLengths=e},We.CurvePath.prototype.getBoundingBox=function(){var t,e,r,i,n,o,a,s,h,l,u=this.getPoints();t=e=Number.NEGATIVE_INFINITY,i=n=Number.POSITIVE_INFINITY;var c=u[0]instanceof We.Vector3;for(l=c?new We.Vector3:new We.Vector2,s=0,h=u.length;s<h;s++)(a=u[s]).x>t?t=a.x:a.x<i&&(i=a.x),a.y>e?e=a.y:a.y<n&&(n=a.y),c&&(a.z>r?r=a.z:a.z<o&&(o=a.z)),l.add(a);var f={minX:i,minY:n,maxX:t,maxY:e};return c&&(f.maxZ=r,f.minZ=o),f},We.CurvePath.prototype.createPointsGeometry=function(t){var e=this.getPoints(t,!0);return this.createGeometry(e)},We.CurvePath.prototype.createSpacedPointsGeometry=function(t){var e=this.getSpacedPoints(t,!0);return this.createGeometry(e)},We.CurvePath.prototype.createGeometry=function(t){for(var e=new We.Geometry,r=0;r<t.length;r++)e.vertices.push(new We.Vector3(t[r].x,t[r].y,t[r].z||0));return e},We.CurvePath.prototype.addWrapPath=function(t){this.bends.push(t)},We.CurvePath.prototype.getTransformedPoints=function(t,e){var r,i,n=this.getPoints(t);for(e||(e=this.bends),r=0,i=e.length;r<i;r++)n=this.getWrapPoints(n,e[r]);return n},We.CurvePath.prototype.getTransformedSpacedPoints=function(t,e){var r,i,n=this.getSpacedPoints(t);for(e||(e=this.bends),r=0,i=e.length;r<i;r++)n=this.getWrapPoints(n,e[r]);return n},We.CurvePath.prototype.getWrapPoints=function(t,e){var r,i,n,o,a,s,h=this.getBoundingBox();for(r=0,i=t.length;r<i;r++){o=(n=t[r]).x,a=n.y,s=o/h.maxX,s=e.getUtoTmapping(s,o);var l=e.getPoint(s),u=e.getTangent(s);u.set(-u.y,u.x).multiplyScalar(a),n.x=l.x+u.x,n.y=l.y+u.y}return t},We.Gyroscope=function(){We.Object3D.call(this)},We.Gyroscope.prototype=Object.create(We.Object3D.prototype),We.Gyroscope.prototype.updateMatrixWorld=(de=new We.Vector3,me=new We.Quaternion,ve=new We.Vector3,ge=new We.Vector3,ye=new We.Quaternion,xe=new We.Vector3,function(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent?(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.decompose(ge,ye,xe),this.matrix.decompose(de,me,ve),this.matrixWorld.compose(ge,me,xe)):this.matrixWorld.copy(this.matrix),t=!(this.matrixWorldNeedsUpdate=!1));for(var e=0,r=this.children.length;e<r;e++)this.children[e].updateMatrixWorld(t)}),We.Path=function(t){We.CurvePath.call(this),this.actions=[],t&&this.fromPoints(t)},We.Path.prototype=Object.create(We.CurvePath.prototype),We.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc",ELLIPSE:"ellipse"},We.Path.prototype.fromPoints=function(t){this.moveTo(t[0].x,t[0].y);for(var e=1,r=t.length;e<r;e++)this.lineTo(t[e].x,t[e].y)},We.Path.prototype.moveTo=function(t,e){var r=Array.prototype.slice.call(arguments);this.actions.push({action:We.PathActions.MOVE_TO,args:r})},We.Path.prototype.lineTo=function(t,e){var r=Array.prototype.slice.call(arguments),i=this.actions[this.actions.length-1].args,n=i[i.length-2],o=i[i.length-1],a=new We.LineCurve(new We.Vector2(n,o),new We.Vector2(t,e));this.curves.push(a),this.actions.push({action:We.PathActions.LINE_TO,args:r})},We.Path.prototype.quadraticCurveTo=function(t,e,r,i){var n=Array.prototype.slice.call(arguments),o=this.actions[this.actions.length-1].args,a=o[o.length-2],s=o[o.length-1],h=new We.QuadraticBezierCurve(new We.Vector2(a,s),new We.Vector2(t,e),new We.Vector2(r,i));this.curves.push(h),this.actions.push({action:We.PathActions.QUADRATIC_CURVE_TO,args:n})},We.Path.prototype.bezierCurveTo=function(t,e,r,i,n,o){var a=Array.prototype.slice.call(arguments),s=this.actions[this.actions.length-1].args,h=s[s.length-2],l=s[s.length-1],u=new We.CubicBezierCurve(new We.Vector2(h,l),new We.Vector2(t,e),new We.Vector2(r,i),new We.Vector2(n,o));this.curves.push(u),this.actions.push({action:We.PathActions.BEZIER_CURVE_TO,args:a})},We.Path.prototype.splineThru=function(t){var e=Array.prototype.slice.call(arguments),r=this.actions[this.actions.length-1].args,i=r[r.length-2],n=r[r.length-1],o=[new We.Vector2(i,n)];Array.prototype.push.apply(o,t);var a=new We.SplineCurve(o);this.curves.push(a),this.actions.push({action:We.PathActions.CSPLINE_THRU,args:e})},We.Path.prototype.arc=function(t,e,r,i,n,o){var a=this.actions[this.actions.length-1].args,s=a[a.length-2],h=a[a.length-1];this.absarc(t+s,e+h,r,i,n,o)},We.Path.prototype.absarc=function(t,e,r,i,n,o){this.absellipse(t,e,r,r,i,n,o)},We.Path.prototype.ellipse=function(t,e,r,i,n,o,a){var s=this.actions[this.actions.length-1].args,h=s[s.length-2],l=s[s.length-1];this.absellipse(t+h,e+l,r,i,n,o,a)},We.Path.prototype.absellipse=function(t,e,r,i,n,o,a){var s=Array.prototype.slice.call(arguments),h=new We.EllipseCurve(t,e,r,i,n,o,a);this.curves.push(h);var l=h.getPoint(1);s.push(l.x),s.push(l.y),this.actions.push({action:We.PathActions.ELLIPSE,args:s})},We.Path.prototype.getSpacedPoints=function(t,e){t||(t=40);for(var r=[],i=0;i<t;i++)r.push(this.getPoint(i/t));return r},We.Path.prototype.getPoints=function(t,e){if(this.useSpacedPoints)return console.log("tata"),this.getSpacedPoints(t,e);t=t||12;var r,i,n,o,a,s,h,l,u,c,f,p,d,m,v,g,y,x,w=[];for(r=0,i=this.actions.length;r<i;r++)switch(o=(n=this.actions[r]).action,a=n.args,o){case We.PathActions.MOVE_TO:case We.PathActions.LINE_TO:w.push(new We.Vector2(a[0],a[1]));break;case We.PathActions.QUADRATIC_CURVE_TO:for(s=a[2],h=a[3],c=a[0],f=a[1],0<w.length?(p=(m=w[w.length-1]).x,d=m.y):(p=(m=this.actions[r-1].args)[m.length-2],d=m[m.length-1]),v=1;v<=t;v++)g=v/t,y=We.Shape.Utils.b2(g,p,c,s),x=We.Shape.Utils.b2(g,d,f,h),w.push(new We.Vector2(y,x));break;case We.PathActions.BEZIER_CURVE_TO:for(s=a[4],h=a[5],c=a[0],f=a[1],l=a[2],u=a[3],0<w.length?(p=(m=w[w.length-1]).x,d=m.y):(p=(m=this.actions[r-1].args)[m.length-2],d=m[m.length-1]),v=1;v<=t;v++)g=v/t,y=We.Shape.Utils.b3(g,p,c,l,s),x=We.Shape.Utils.b3(g,d,f,u,h),w.push(new We.Vector2(y,x));break;case We.PathActions.CSPLINE_THRU:m=this.actions[r-1].args;var b=[new We.Vector2(m[m.length-2],m[m.length-1])],M=t*a[0].length;b=b.concat(a[0]);var _=new We.SplineCurve(b);for(v=1;v<=M;v++)w.push(_.getPointAt(v/M));break;case We.PathActions.ARC:var S=a[0],T=a[1],A=a[2],C=a[3],E=a[4],L=!!a[5],P=E-C,R=2*t;for(v=1;v<=R;v++)g=v/R,L||(g=1-g),F=C+g*P,y=S+A*Math.cos(F),x=T+A*Math.sin(F),w.push(new We.Vector2(y,x));break;case We.PathActions.ELLIPSE:S=a[0],T=a[1];var F,D=a[2],U=a[3];C=a[4],E=a[5],L=!!a[6],P=E-C,R=2*t;for(v=1;v<=R;v++)g=v/R,L||(g=1-g),F=C+g*P,y=S+D*Math.cos(F),x=T+U*Math.sin(F),w.push(new We.Vector2(y,x))}var B=w[w.length-1];return Math.abs(B.x-w[0].x)<1e-10&&Math.abs(B.y-w[0].y)<1e-10&&w.splice(w.length-1,1),e&&w.push(w[0]),w},We.Path.prototype.toShapes=function(t,e){function r(t){for(var e=[],r=0,i=t.length;r<i;r++){var n=t[r],o=new We.Shape;o.actions=n.actions,o.curves=n.curves,e.push(o)}return e}function i(t,e){for(var r=e.length,i=!1,n=r-1,o=0;o<r;n=o++){var a=e[n],s=e[o],h=s.x-a.x,l=s.y-a.y;if(1e-10<Math.abs(l)){if(l<0&&(a=e[o],h=-h,s=e[n],l=-l),t.y<a.y||t.y>s.y)continue;if(t.y==a.y){if(t.x==a.x)return!0}else{var u=l*(t.x-a.x)-h*(t.y-a.y);if(0==u)return!0;if(u<0)continue;i=!i}}else{if(t.y!=a.y)continue;if(s.x<=t.x&&t.x<=a.x||a.x<=t.x&&t.x<=s.x)return!0}}return i}var n=function(t){var e,r,i,n,o,a=[],s=new We.Path;for(e=0,r=t.length;e<r;e++)o=(i=t[e]).args,(n=i.action)==We.PathActions.MOVE_TO&&0!=s.actions.length&&(a.push(s),s=new We.Path),s[n].apply(s,o);return 0!=s.actions.length&&a.push(s),a}(this.actions);if(0==n.length)return[];if(!0===e)return r(n);var o,a,s,h=[];if(1==n.length)return a=n[0],(s=new We.Shape).actions=a.actions,s.curves=a.curves,h.push(s),h;var l=!We.Shape.Utils.isClockWise(n[0].getPoints());l=t?!l:l;var u,c,f,p,d,m,v=[],g=[],y=[],x=0;for(g[x]=void 0,y[x]=[],c=0,f=n.length;c<f;c++)u=(a=n[c]).getPoints(),o=We.Shape.Utils.isClockWise(u),(o=t?!o:o)?(!l&&g[x]&&x++,g[x]={s:new We.Shape,p:u},g[x].s.actions=a.actions,g[x].s.curves=a.curves,l&&x++,y[x]=[]):y[x].push({h:a,p:u[0]});if(!g[0])return r(n);if(1<g.length){for(var w=!1,b=[],M=0,_=g.length;M<_;M++)v[M]=[];for(M=0,_=g.length;M<_;M++){g[M];for(var S=y[M],T=0;T<S.length;T++){for(var A=S[T],C=!0,E=0;E<g.length;E++)i(A.p,g[E].p)&&(M!=E&&b.push({froms:M,tos:E,hole:T}),C?(C=!1,v[E].push(A)):w=!0);C&&v[M].push(A)}}0<b.length&&(w||(y=v))}for(c=0,f=g.length;c<f;c++)for(s=g[c].s,h.push(s),d=0,m=(p=y[c]).length;d<m;d++)s.holes.push(p[d].h);return h},We.Shape=function(){We.Path.apply(this,arguments),this.holes=[]},We.Shape.prototype=Object.create(We.Path.prototype),We.Shape.prototype.extrude=function(t){return new We.ExtrudeGeometry(this,t)},We.Shape.prototype.makeGeometry=function(t){return new We.ShapeGeometry(this,t)},We.Shape.prototype.getPointsHoles=function(t){var e,r=this.holes.length,i=[];for(e=0;e<r;e++)i[e]=this.holes[e].getTransformedPoints(t,this.bends);return i},We.Shape.prototype.getSpacedPointsHoles=function(t){var e,r=this.holes.length,i=[];for(e=0;e<r;e++)i[e]=this.holes[e].getTransformedSpacedPoints(t,this.bends);return i},We.Shape.prototype.extractAllPoints=function(t){return{shape:this.getTransformedPoints(t),holes:this.getPointsHoles(t)}},We.Shape.prototype.extractPoints=function(t){return this.useSpacedPoints?this.extractAllSpacedPoints(t):this.extractAllPoints(t)},We.Shape.prototype.extractAllSpacedPoints=function(t){return{shape:this.getTransformedSpacedPoints(t),holes:this.getSpacedPointsHoles(t)}},We.Shape.Utils={triangulateShape:function(t,e){function T(t,e,r){return t.x!=e.x?t.x<e.x?t.x<=r.x&&r.x<=e.x:e.x<=r.x&&r.x<=t.x:t.y<e.y?t.y<=r.y&&r.y<=e.y:e.y<=r.y&&r.y<=t.y}function S(t,e,r,i,n){var o=e.x-t.x,a=e.y-t.y,s=i.x-r.x,h=i.y-r.y,l=t.x-r.x,u=t.y-r.y,c=a*s-o*h,f=a*l-o*u;if(1e-10<Math.abs(c)){var p;if(0<c){if(f<0||c<f)return[];if((p=h*l-s*u)<0||c<p)return[]}else{if(0<f||f<c)return[];if(0<(p=h*l-s*u)||p<c)return[]}if(0==p)return!n||0!=f&&f!=c?[t]:[];if(p==c)return!n||0!=f&&f!=c?[e]:[];if(0==f)return[r];if(f==c)return[i];var d=p/c;return[{x:t.x+d*o,y:t.y+d*a}]}if(0!=f||h*l!=s*u)return[];var m,v,g,y,x,w,b,M,_=0==o&&0==a,S=0==s&&0==h;return _&&S?t.x!=r.x||t.y!=r.y?[]:[t]:_?T(r,i,t)?[t]:[]:S?T(t,e,r)?[r]:[]:(0!=o?(t.x<e.x?(g=(m=t).x,y=(v=e).x):(g=(m=e).x,y=(v=t).x),r.x<i.x?(b=(x=r).x,M=(w=i).x):(b=(x=i).x,M=(w=r).x)):(t.y<e.y?(g=(m=t).y,y=(v=e).y):(g=(m=e).y,y=(v=t).y),r.y<i.y?(b=(x=r).y,M=(w=i).y):(b=(x=i).y,M=(w=r).y)),g<=b?y<b?[]:y==b?n?[]:[x]:y<=M?[x,v]:[x,w]:M<g?[]:g==M?n?[]:[m]:y<=M?[m,v]:[m,w])}function A(t,e,r,i){var n=e.x-t.x,o=e.y-t.y,a=r.x-t.x,s=r.y-t.y,h=i.x-t.x,l=i.y-t.y,u=n*s-o*a,c=n*l-o*h;if(1e-10<Math.abs(u)){var f=h*s-l*a;return 0<u?0<=c&&0<=f:0<=c||0<=f}return 0<c}for(var r,i,n,o,a,s,h={},l=t.concat(),u=0,c=e.length;u<c;u++)Array.prototype.push.apply(l,e[u]);for(r=0,i=l.length;r<i;r++)void 0!==h[a=l[r].x+":"+l[r].y]&&console.log("Duplicate point",a),h[a]=r;var f=function(t,a){var l,u=t.concat();function e(t,e){var r=u.length-1,i=t-1;i<0&&(i=r);var n=t+1;r<n&&(n=0);var o=A(u[t],u[i],u[n],l[e]);if(!o)return!1;var a=l.length-1,s=e-1;s<0&&(s=a);var h=e+1;return a<h&&(h=0),!!(o=A(l[e],l[s],l[h],u[t]))}function r(t,e){var r,i;for(r=0;r<u.length;r++)if(i=r+1,i%=u.length,0<S(t,e,u[r],u[i],!0).length)return!0;return!1}var s=[];function i(t,e){var r,i,n,o;for(r=0;r<s.length;r++)for(i=a[s[r]],n=0;n<i.length;n++)if(o=n+1,o%=i.length,0<S(t,e,i[n],i[o],!0).length)return!0;return!1}for(var n,o,h,c,f,p,d,m,v,g,y=[],x=0,w=a.length;x<w;x++)s.push(x);for(var b=0,M=2*s.length;0<s.length;){if(--M<0){console.log("Infinite Loop! Holes left:"+s.length+", Probably Hole outside Shape!");break}for(o=b;o<u.length;o++){for(h=u[o],n=-1,x=0;x<s.length;x++)if(f=s[x],void 0===y[p=h.x+":"+h.y+":"+f]){l=a[f];for(var _=0;_<l.length;_++)if(c=l[_],e(o,_)&&!r(h,c)&&!i(h,c)){n=_,s.splice(x,1),d=u.slice(0,o+1),m=u.slice(o),v=l.slice(n),g=l.slice(0,n+1),u=d.concat(v).concat(g).concat(m),b=o;break}if(0<=n)break;y[p]=!0}if(0<=n)break}}return u}(t,e),p=We.FontUtils.Triangulate(f,!1);for(r=0,i=p.length;r<i;r++)for(o=p[r],n=0;n<3;n++)void 0!==(s=h[a=o[n].x+":"+o[n].y])&&(o[n]=s);return p.concat()},isClockWise:function(t){return We.FontUtils.Triangulate.area(t)<0},b2p0:function(t,e){var r=1-t;return r*r*e},b2p1:function(t,e){return 2*(1-t)*t*e},b2p2:function(t,e){return t*t*e},b2:function(t,e,r,i){return this.b2p0(t,e)+this.b2p1(t,r)+this.b2p2(t,i)},b3p0:function(t,e){var r=1-t;return r*r*r*e},b3p1:function(t,e){var r=1-t;return 3*r*r*t*e},b3p2:function(t,e){return 3*(1-t)*t*t*e},b3p3:function(t,e){return t*t*t*e},b3:function(t,e,r,i,n){return this.b3p0(t,e)+this.b3p1(t,r)+this.b3p2(t,i)+this.b3p3(t,n)}},We.LineCurve=function(t,e){this.v1=t,this.v2=e},We.LineCurve.prototype=Object.create(We.Curve.prototype),We.LineCurve.prototype.getPoint=function(t){var e=this.v2.clone().sub(this.v1);return e.multiplyScalar(t).add(this.v1),e},We.LineCurve.prototype.getPointAt=function(t){return this.getPoint(t)},We.LineCurve.prototype.getTangent=function(t){return this.v2.clone().sub(this.v1).normalize()},We.QuadraticBezierCurve=function(t,e,r){this.v0=t,this.v1=e,this.v2=r},We.QuadraticBezierCurve.prototype=Object.create(We.Curve.prototype),We.QuadraticBezierCurve.prototype.getPoint=function(t){var e=new We.Vector2;return e.x=We.Shape.Utils.b2(t,this.v0.x,this.v1.x,this.v2.x),e.y=We.Shape.Utils.b2(t,this.v0.y,this.v1.y,this.v2.y),e},We.QuadraticBezierCurve.prototype.getTangent=function(t){var e=new We.Vector2;return e.x=We.Curve.Utils.tangentQuadraticBezier(t,this.v0.x,this.v1.x,this.v2.x),e.y=We.Curve.Utils.tangentQuadraticBezier(t,this.v0.y,this.v1.y,this.v2.y),e.normalize()},We.CubicBezierCurve=function(t,e,r,i){this.v0=t,this.v1=e,this.v2=r,this.v3=i},We.CubicBezierCurve.prototype=Object.create(We.Curve.prototype),We.CubicBezierCurve.prototype.getPoint=function(t){var e,r;return e=We.Shape.Utils.b3(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),r=We.Shape.Utils.b3(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y),new We.Vector2(e,r)},We.CubicBezierCurve.prototype.getTangent=function(t){var e,r;e=We.Curve.Utils.tangentCubicBezier(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),r=We.Curve.Utils.tangentCubicBezier(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y);var i=new We.Vector2(e,r);return i.normalize(),i},We.SplineCurve=function(t){this.points=null==t?[]:t},We.SplineCurve.prototype=Object.create(We.Curve.prototype),We.SplineCurve.prototype.getPoint=function(t){var e=this.points,r=(e.length-1)*t,i=Math.floor(r),n=r-i,o=e[0==i?i:i-1],a=e[i],s=e[i>e.length-2?e.length-1:i+1],h=e[i>e.length-3?e.length-1:i+2],l=new We.Vector2;return l.x=We.Curve.Utils.interpolate(o.x,a.x,s.x,h.x,n),l.y=We.Curve.Utils.interpolate(o.y,a.y,s.y,h.y,n),l},We.EllipseCurve=function(t,e,r,i,n,o,a){this.aX=t,this.aY=e,this.xRadius=r,this.yRadius=i,this.aStartAngle=n,this.aEndAngle=o,this.aClockwise=a},We.EllipseCurve.prototype=Object.create(We.Curve.prototype),We.EllipseCurve.prototype.getPoint=function(t){var e,r=this.aEndAngle-this.aStartAngle;r<0&&(r+=2*Math.PI),r>2*Math.PI&&(r-=2*Math.PI),e=!0===this.aClockwise?this.aEndAngle+(1-t)*(2*Math.PI-r):this.aStartAngle+t*r;var i=new We.Vector2;return i.x=this.aX+this.xRadius*Math.cos(e),i.y=this.aY+this.yRadius*Math.sin(e),i},We.ArcCurve=function(t,e,r,i,n,o){We.EllipseCurve.call(this,t,e,r,r,i,n,o)},We.ArcCurve.prototype=Object.create(We.EllipseCurve.prototype),We.LineCurve3=We.Curve.create(function(t,e){this.v1=t,this.v2=e},function(t){var e=new We.Vector3;return e.subVectors(this.v2,this.v1),e.multiplyScalar(t),e.add(this.v1),e}),We.QuadraticBezierCurve3=We.Curve.create(function(t,e,r){this.v0=t,this.v1=e,this.v2=r},function(t){var e=new We.Vector3;return e.x=We.Shape.Utils.b2(t,this.v0.x,this.v1.x,this.v2.x),e.y=We.Shape.Utils.b2(t,this.v0.y,this.v1.y,this.v2.y),e.z=We.Shape.Utils.b2(t,this.v0.z,this.v1.z,this.v2.z),e}),We.CubicBezierCurve3=We.Curve.create(function(t,e,r,i){this.v0=t,this.v1=e,this.v2=r,this.v3=i},function(t){var e=new We.Vector3;return e.x=We.Shape.Utils.b3(t,this.v0.x,this.v1.x,this.v2.x,this.v3.x),e.y=We.Shape.Utils.b3(t,this.v0.y,this.v1.y,this.v2.y,this.v3.y),e.z=We.Shape.Utils.b3(t,this.v0.z,this.v1.z,this.v2.z,this.v3.z),e}),We.SplineCurve3=We.Curve.create(function(t){this.points=null==t?[]:t},function(t){var e=this.points,r=(e.length-1)*t,i=Math.floor(r),n=r-i,o=e[0==i?i:i-1],a=e[i],s=e[i>e.length-2?e.length-1:i+1],h=e[i>e.length-3?e.length-1:i+2],l=new We.Vector3;return l.x=We.Curve.Utils.interpolate(o.x,a.x,s.x,h.x,n),l.y=We.Curve.Utils.interpolate(o.y,a.y,s.y,h.y,n),l.z=We.Curve.Utils.interpolate(o.z,a.z,s.z,h.z,n),l}),We.ClosedSplineCurve3=We.Curve.create(function(t){this.points=null==t?[]:t},function(t){var e=this.points,r=(e.length-0)*t,i=Math.floor(r),n=r-i,o=e[((i+=0<i?0:(Math.floor(Math.abs(i)/e.length)+1)*e.length)-1)%e.length],a=e[i%e.length],s=e[(i+1)%e.length],h=e[(i+2)%e.length],l=new We.Vector3;return l.x=We.Curve.Utils.interpolate(o.x,a.x,s.x,h.x,n),l.y=We.Curve.Utils.interpolate(o.y,a.y,s.y,h.y,n),l.z=We.Curve.Utils.interpolate(o.z,a.z,s.z,h.z,n),l}),We.AnimationHandler={LINEAR:0,CATMULLROM:1,CATMULLROM_FORWARD:2,add:function(){console.warn("THREE.AnimationHandler.add() has been deprecated.")},get:function(){console.warn("THREE.AnimationHandler.get() has been deprecated.")},remove:function(){console.warn("THREE.AnimationHandler.remove() has been deprecated.")},animations:[],init:function(t){if(!0!==t.initialized){for(var e=0;e<t.hierarchy.length;e++){for(var r=0;r<t.hierarchy[e].keys.length;r++)if(t.hierarchy[e].keys[r].time<0&&(t.hierarchy[e].keys[r].time=0),void 0!==t.hierarchy[e].keys[r].rot&&!(t.hierarchy[e].keys[r].rot instanceof We.Quaternion)){var i=t.hierarchy[e].keys[r].rot;t.hierarchy[e].keys[r].rot=(new We.Quaternion).fromArray(i)}if(t.hierarchy[e].keys.length&&void 0!==t.hierarchy[e].keys[0].morphTargets){var n={};for(r=0;r<t.hierarchy[e].keys.length;r++)for(var o=0;o<t.hierarchy[e].keys[r].morphTargets.length;o++){n[s=t.hierarchy[e].keys[r].morphTargets[o]]=-1}t.hierarchy[e].usedMorphTargets=n;for(r=0;r<t.hierarchy[e].keys.length;r++){var a={};for(var s in n){for(o=0;o<t.hierarchy[e].keys[r].morphTargets.length;o++)if(t.hierarchy[e].keys[r].morphTargets[o]===s){a[s]=t.hierarchy[e].keys[r].morphTargetsInfluences[o];break}o===t.hierarchy[e].keys[r].morphTargets.length&&(a[s]=0)}t.hierarchy[e].keys[r].morphTargetsInfluences=a}}for(r=1;r<t.hierarchy[e].keys.length;r++)t.hierarchy[e].keys[r].time===t.hierarchy[e].keys[r-1].time&&(t.hierarchy[e].keys.splice(r,1),r--);for(r=0;r<t.hierarchy[e].keys.length;r++)t.hierarchy[e].keys[r].index=r}return t.initialized=!0,t}},parse:function(t){var i=function(t,e){e.push(t);for(var r=0;r<t.children.length;r++)i(t.children[r],e)},e=[];if(t instanceof We.SkinnedMesh)for(var r=0;r<t.skeleton.bones.length;r++)e.push(t.skeleton.bones[r]);else i(t,e);return e},play:function(t){-1===this.animations.indexOf(t)&&this.animations.push(t)},stop:function(t){var e=this.animations.indexOf(t);-1!==e&&this.animations.splice(e,1)},update:function(t){for(var e=0;e<this.animations.length;e++)this.animations[e].resetBlendWeights();for(e=0;e<this.animations.length;e++)this.animations[e].update(t)}},We.Animation=function(t,e){this.root=t,this.data=We.AnimationHandler.init(e),this.hierarchy=We.AnimationHandler.parse(t),this.currentTime=0,this.timeScale=1,this.isPlaying=!1,this.loop=!0,this.weight=0,this.interpolationType=We.AnimationHandler.LINEAR},We.Animation.prototype.keyTypes=["pos","rot","scl"],We.Animation.prototype.play=function(t,e){this.currentTime=void 0!==t?t:0,this.weight=void 0!==e?e:1,this.isPlaying=!0,this.reset(),We.AnimationHandler.play(this)},We.Animation.prototype.stop=function(){this.isPlaying=!1,We.AnimationHandler.stop(this)},We.Animation.prototype.reset=function(){for(var t=0,e=this.hierarchy.length;t<e;t++){var r=this.hierarchy[t];r.matrixAutoUpdate=!0,void 0===r.animationCache&&(r.animationCache={animations:{},blending:{positionWeight:0,quaternionWeight:0,scaleWeight:0}}),void 0===r.animationCache.animations[this.data.name]&&(r.animationCache.animations[this.data.name]={},r.animationCache.animations[this.data.name].prevKey={pos:0,rot:0,scl:0},r.animationCache.animations[this.data.name].nextKey={pos:0,rot:0,scl:0},r.animationCache.animations[this.data.name].originalMatrix=r.matrix);for(var i=r.animationCache.animations[this.data.name],n=0;n<3;n++){for(var o=this.keyTypes[n],a=this.data.hierarchy[t].keys[0],s=this.getNextKeyWith(o,t,1);s.time<this.currentTime&&s.index>a.index;)a=s,s=this.getNextKeyWith(o,t,s.index+1);i.prevKey[o]=a,i.nextKey[o]=s}}},We.Animation.prototype.resetBlendWeights=function(){for(var t=0,e=this.hierarchy.length;t<e;t++){var r=this.hierarchy[t];void 0!==r.animationCache&&(r.animationCache.blending.positionWeight=0,r.animationCache.blending.quaternionWeight=0,r.animationCache.blending.scaleWeight=0)}},We.Animation.prototype.update=(we=[],be=new We.Vector3,Me=new We.Vector3,_e=new We.Quaternion,Se=function(t,e){var r,i,n,o,a,s,h,l,u,c=[],f=[];return n=(r=(t.length-1)*e)-(i=Math.floor(r)),c[0]=0===i?i:i-1,c[1]=i,c[2]=i>t.length-2?i:i+1,c[3]=i>t.length-3?i:i+2,s=t[c[0]],h=t[c[1]],l=t[c[2]],u=t[c[3]],a=n*(o=n*n),f[0]=Te(s[0],h[0],l[0],u[0],n,o,a),f[1]=Te(s[1],h[1],l[1],u[1],n,o,a),f[2]=Te(s[2],h[2],l[2],u[2],n,o,a),f},Te=function(t,e,r,i,n,o,a){var s=.5*(r-t),h=.5*(i-e);return(2*(e-r)+s+h)*a+(-3*(e-r)-2*s-h)*o+s*n+e},function(t){if(!1!==this.isPlaying&&(this.currentTime+=t*this.timeScale,0!==this.weight)){var e=this.data.length;if(this.currentTime>e||this.currentTime<0){if(!this.loop)return void this.stop();this.currentTime%=e,this.currentTime<0&&(this.currentTime+=e),this.reset()}for(var r=0,i=this.hierarchy.length;r<i;r++)for(var n=this.hierarchy[r],o=n.animationCache.animations[this.data.name],a=n.animationCache.blending,s=0;s<3;s++){var h=this.keyTypes[s],l=o.prevKey[h],u=o.nextKey[h];if(0<this.timeScale&&u.time<=this.currentTime||this.timeScale<0&&l.time>=this.currentTime){for(l=this.data.hierarchy[r].keys[0],u=this.getNextKeyWith(h,r,1);u.time<this.currentTime&&u.index>l.index;)l=u,u=this.getNextKeyWith(h,r,u.index+1);o.prevKey[h]=l,o.nextKey[h]=u}n.matrixAutoUpdate=!0,n.matrixWorldNeedsUpdate=!0;var c=(this.currentTime-l.time)/(u.time-l.time),f=l[h],p=u[h];if(c<0&&(c=0),1<c&&(c=1),"pos"===h){if(this.interpolationType===We.AnimationHandler.LINEAR){Me.x=f[0]+(p[0]-f[0])*c,Me.y=f[1]+(p[1]-f[1])*c,Me.z=f[2]+(p[2]-f[2])*c;var d=this.weight/(this.weight+a.positionWeight);n.position.lerp(Me,d),a.positionWeight+=this.weight}else if(this.interpolationType===We.AnimationHandler.CATMULLROM||this.interpolationType===We.AnimationHandler.CATMULLROM_FORWARD){we[0]=this.getPrevKeyWith("pos",r,l.index-1).pos,we[1]=f,we[2]=p,we[3]=this.getNextKeyWith("pos",r,u.index+1).pos;var m=Se(we,c=.33*c+.33);d=this.weight/(this.weight+a.positionWeight),a.positionWeight+=this.weight;var v=n.position;if(v.x=v.x+(m[0]-v.x)*d,v.y=v.y+(m[1]-v.y)*d,v.z=v.z+(m[2]-v.z)*d,this.interpolationType===We.AnimationHandler.CATMULLROM_FORWARD){var g=Se(we,1.01*c);be.set(g[0],g[1],g[2]),be.sub(v),be.y=0,be.normalize();var y=Math.atan2(be.x,be.z);n.rotation.set(0,y,0)}}}else"rot"===h?(We.Quaternion.slerp(f,p,_e,c),0===a.quaternionWeight?(n.quaternion.copy(_e),a.quaternionWeight=this.weight):(d=this.weight/(this.weight+a.quaternionWeight),We.Quaternion.slerp(n.quaternion,_e,n.quaternion,d),a.quaternionWeight+=this.weight)):"scl"===h&&(Me.x=f[0]+(p[0]-f[0])*c,Me.y=f[1]+(p[1]-f[1])*c,Me.z=f[2]+(p[2]-f[2])*c,d=this.weight/(this.weight+a.scaleWeight),n.scale.lerp(Me,d),a.scaleWeight+=this.weight)}return!0}}),We.Animation.prototype.getNextKeyWith=function(t,e,r){var i=this.data.hierarchy[e].keys;for(this.interpolationType===We.AnimationHandler.CATMULLROM||this.interpolationType===We.AnimationHandler.CATMULLROM_FORWARD?r=r<i.length-1?r:i.length-1:r%=i.length;r<i.length;r++)if(void 0!==i[r][t])return i[r];return this.data.hierarchy[e].keys[0]},We.Animation.prototype.getPrevKeyWith=function(t,e,r){var i=this.data.hierarchy[e].keys;for(r=this.interpolationType===We.AnimationHandler.CATMULLROM||this.interpolationType===We.AnimationHandler.CATMULLROM_FORWARD?0<r?r:0:0<=r?r:r+i.length;0<=r;r--)if(void 0!==i[r][t])return i[r];return this.data.hierarchy[e].keys[i.length-1]},We.KeyFrameAnimation=function(t){this.root=t.node,this.data=We.AnimationHandler.init(t),this.hierarchy=We.AnimationHandler.parse(this.root),this.currentTime=0,this.timeScale=.001,this.isPlaying=!1,this.isPaused=!0,this.loop=!0;for(var e=0,r=this.hierarchy.length;e<r;e++){var i=this.data.hierarchy[e].keys,n=this.data.hierarchy[e].sids,o=this.hierarchy[e];if(i.length&&n){for(var a=0;a<n.length;a++){var s=n[a],h=this.getNextKeyWith(s,e,0);h&&h.apply(s)}o.matrixAutoUpdate=!1,this.data.hierarchy[e].node.updateMatrix(),o.matrixWorldNeedsUpdate=!0}}},We.KeyFrameAnimation.prototype.play=function(t){if(this.currentTime=void 0!==t?t:0,!1===this.isPlaying){this.isPlaying=!0;var e,r,i,n=this.hierarchy.length;for(e=0;e<n;e++){r=this.hierarchy[e],void 0===(i=this.data.hierarchy[e]).animationCache&&(i.animationCache={},i.animationCache.prevKey=null,i.animationCache.nextKey=null,i.animationCache.originalMatrix=r.matrix);var o=this.data.hierarchy[e].keys;o.length&&(i.animationCache.prevKey=o[0],i.animationCache.nextKey=o[1],this.startTime=Math.min(o[0].time,this.startTime),this.endTime=Math.max(o[o.length-1].time,this.endTime))}this.update(0)}this.isPaused=!1,We.AnimationHandler.play(this)},We.KeyFrameAnimation.prototype.stop=function(){this.isPlaying=!1,this.isPaused=!1,We.AnimationHandler.stop(this);for(var t=0;t<this.data.hierarchy.length;t++){var e=this.hierarchy[t],r=this.data.hierarchy[t];if(void 0!==r.animationCache){var i=r.animationCache.originalMatrix;i.copy(e.matrix),e.matrix=i,delete r.animationCache}}},We.KeyFrameAnimation.prototype.update=function(t){if(!1!==this.isPlaying){this.currentTime+=t*this.timeScale;var e=this.data.length;!0===this.loop&&this.currentTime>e&&(this.currentTime%=e),this.currentTime=Math.min(this.currentTime,e);for(var r=0,i=this.hierarchy.length;r<i;r++){var n=this.hierarchy[r],o=this.data.hierarchy[r],a=o.keys,s=o.animationCache;if(a.length){var h=s.prevKey,l=s.nextKey;if(l.time<=this.currentTime){for(;l.time<this.currentTime&&l.index>h.index;)l=a[(h=l).index+1];s.prevKey=h,s.nextKey=l}l.time>=this.currentTime?h.interpolate(l,this.currentTime):h.interpolate(l,l.time),this.data.hierarchy[r].node.updateMatrix(),n.matrixWorldNeedsUpdate=!0}}}},We.KeyFrameAnimation.prototype.getNextKeyWith=function(t,e,r){var i=this.data.hierarchy[e].keys;for(r%=i.length;r<i.length;r++)if(i[r].hasTarget(t))return i[r];return i[0]},We.KeyFrameAnimation.prototype.getPrevKeyWith=function(t,e,r){var i=this.data.hierarchy[e].keys;for(r=0<=r?r:r+i.length;0<=r;r--)if(i[r].hasTarget(t))return i[r];return i[i.length-1]},We.MorphAnimation=function(t){this.mesh=t,this.frames=t.morphTargetInfluences.length,this.currentTime=0,this.duration=1e3,this.loop=!0,this.isPlaying=!1},We.MorphAnimation.prototype={play:function(){this.isPlaying=!0},pause:function(){this.isPlaying=!1},update:(Ae=0,Ce=0,function(t){if(!1!==this.isPlaying){this.currentTime+=t,!0===this.loop&&this.currentTime>this.duration&&(this.currentTime%=this.duration),this.currentTime=Math.min(this.currentTime,this.duration);var e=this.duration/this.frames,r=Math.floor(this.currentTime/e);r!=Ce&&(this.mesh.morphTargetInfluences[Ae]=0,this.mesh.morphTargetInfluences[Ce]=1,this.mesh.morphTargetInfluences[r]=0,Ae=Ce,Ce=r),this.mesh.morphTargetInfluences[r]=this.currentTime%e/e,this.mesh.morphTargetInfluences[Ae]=1-this.mesh.morphTargetInfluences[r]}})},We.BoxGeometry=function(t,e,r,i,n,o){We.Geometry.call(this),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:r,widthSegments:i,heightSegments:n,depthSegments:o},this.widthSegments=i||1,this.heightSegments=n||1,this.depthSegments=o||1;var R=this,a=t/2,s=e/2,h=r/2;function l(t,e,r,i,n,o,a,s){var h,l,u,c=R.widthSegments,f=R.heightSegments,p=n/2,d=o/2,m=R.vertices.length;"x"===t&&"y"===e||"y"===t&&"x"===e?h="z":"x"===t&&"z"===e||"z"===t&&"x"===e?(h="y",f=R.depthSegments):("z"===t&&"y"===e||"y"===t&&"z"===e)&&(h="x",c=R.depthSegments);var v=c+1,g=f+1,y=n/c,x=o/f,w=new We.Vector3;for(w[h]=0<a?1:-1,u=0;u<g;u++)for(l=0;l<v;l++){var b=new We.Vector3;b[t]=(l*y-p)*r,b[e]=(u*x-d)*i,b[h]=a,R.vertices.push(b)}for(u=0;u<f;u++)for(l=0;l<c;l++){var M=l+v*u,_=l+v*(u+1),S=l+1+v*(u+1),T=l+1+v*u,A=new We.Vector2(l/c,1-u/f),C=new We.Vector2(l/c,1-(u+1)/f),E=new We.Vector2((l+1)/c,1-(u+1)/f),L=new We.Vector2((l+1)/c,1-u/f),P=new We.Face3(M+m,_+m,T+m);P.normal.copy(w),P.vertexNormals.push(w.clone(),w.clone(),w.clone()),P.materialIndex=s,R.faces.push(P),R.faceVertexUvs[0].push([A,C,L]),(P=new We.Face3(_+m,S+m,T+m)).normal.copy(w),P.vertexNormals.push(w.clone(),w.clone(),w.clone()),P.materialIndex=s,R.faces.push(P),R.faceVertexUvs[0].push([C.clone(),E,L.clone()])}}l("z","y",-1,-1,r,e,a,0),l("z","y",1,-1,r,e,-a,1),l("x","z",1,1,t,r,s,2),l("x","z",1,-1,t,r,-s,3),l("x","y",1,-1,t,e,h,4),l("x","y",-1,-1,t,e,-h,5),this.mergeVertices()},We.BoxGeometry.prototype=Object.create(We.Geometry.prototype),We.CircleGeometry=function(t,e,r,i){We.Geometry.call(this),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:r,thetaLength:i},t=t||50,e=void 0!==e?Math.max(3,e):8,r=void 0!==r?r:0,i=void 0!==i?i:2*Math.PI;var n,o=[],a=new We.Vector3,s=new We.Vector2(.5,.5);for(this.vertices.push(a),o.push(s),n=0;n<=e;n++){var h=new We.Vector3,l=r+n/e*i;h.x=t*Math.cos(l),h.y=t*Math.sin(l),this.vertices.push(h),o.push(new We.Vector2((h.x/t+1)/2,(h.y/t+1)/2))}var u=new We.Vector3(0,0,1);for(n=1;n<=e;n++)this.faces.push(new We.Face3(n,n+1,0,[u.clone(),u.clone(),u.clone()])),this.faceVertexUvs[0].push([o[n].clone(),o[n+1].clone(),s.clone()]);this.computeFaceNormals(),this.boundingSphere=new We.Sphere(new We.Vector3,t)},We.CircleGeometry.prototype=Object.create(We.Geometry.prototype),We.CubeGeometry=function(t,e,r,i,n,o){return console.warn("THREE.CubeGeometry has been renamed to THREE.BoxGeometry."),new We.BoxGeometry(t,e,r,i,n,o)},We.CylinderGeometry=function(t,e,r,i,n,o){We.Geometry.call(this),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:r,radialSegments:i,heightSegments:n,openEnded:o},t=void 0!==t?t:20,e=void 0!==e?e:20,i=i||8,n=n||1,o=void 0!==o&&o;var a,s,h=(r=void 0!==r?r:100)/2,l=[],u=[];for(s=0;s<=n;s++){var c=[],f=[],p=s/n,d=p*(e-t)+t;for(a=0;a<=i;a++){var m=a/i,v=new We.Vector3;v.x=d*Math.sin(m*Math.PI*2),v.y=-p*r+h,v.z=d*Math.cos(m*Math.PI*2),this.vertices.push(v),c.push(this.vertices.length-1),f.push(new We.Vector2(m,1-p))}l.push(c),u.push(f)}var g,y,x=(e-t)/r;for(a=0;a<i;a++)for(0!==t?(g=this.vertices[l[0][a]].clone(),y=this.vertices[l[0][a+1]].clone()):(g=this.vertices[l[1][a]].clone(),y=this.vertices[l[1][a+1]].clone()),g.setY(Math.sqrt(g.x*g.x+g.z*g.z)*x).normalize(),y.setY(Math.sqrt(y.x*y.x+y.z*y.z)*x).normalize(),s=0;s<n;s++){var w=l[s][a],b=l[s+1][a],M=l[s+1][a+1],_=l[s][a+1],S=g.clone(),T=g.clone(),A=y.clone(),C=y.clone(),E=u[s][a].clone(),L=u[s+1][a].clone(),P=u[s+1][a+1].clone(),R=u[s][a+1].clone();this.faces.push(new We.Face3(w,b,_,[S,T,C])),this.faceVertexUvs[0].push([E,L,R]),this.faces.push(new We.Face3(b,M,_,[T.clone(),A,C.clone()])),this.faceVertexUvs[0].push([L.clone(),P,R.clone()])}if(!1===o&&0<t)for(this.vertices.push(new We.Vector3(0,h,0)),a=0;a<i;a++){w=l[0][a],b=l[0][a+1],M=this.vertices.length-1,S=new We.Vector3(0,1,0),T=new We.Vector3(0,1,0),A=new We.Vector3(0,1,0),E=u[0][a].clone(),L=u[0][a+1].clone(),P=new We.Vector2(L.x,0);this.faces.push(new We.Face3(w,b,M,[S,T,A])),this.faceVertexUvs[0].push([E,L,P])}if(!1===o&&0<e)for(this.vertices.push(new We.Vector3(0,-h,0)),a=0;a<i;a++){w=l[s][a+1],b=l[s][a],M=this.vertices.length-1,S=new We.Vector3(0,-1,0),T=new We.Vector3(0,-1,0),A=new We.Vector3(0,-1,0),E=u[s][a+1].clone(),L=u[s][a].clone(),P=new We.Vector2(L.x,1);this.faces.push(new We.Face3(w,b,M,[S,T,A])),this.faceVertexUvs[0].push([E,L,P])}this.computeFaceNormals()},We.CylinderGeometry.prototype=Object.create(We.Geometry.prototype),We.ExtrudeGeometry=function(t,e){void 0!==t?(We.Geometry.call(this),this.type="ExtrudeGeometry",t=t instanceof Array?t:[t],this.addShapeList(t,e),this.computeFaceNormals()):t=[]},We.ExtrudeGeometry.prototype=Object.create(We.Geometry.prototype),We.ExtrudeGeometry.prototype.addShapeList=function(t,e){for(var r=t.length,i=0;i<r;i++){var n=t[i];this.addShape(n,e)}},We.ExtrudeGeometry.prototype.addShape=function(t,e){var r,i,n,o,a,s,h,l,u=void 0!==e.amount?e.amount:100,c=void 0!==e.bevelThickness?e.bevelThickness:6,f=void 0!==e.bevelSize?e.bevelSize:c-2,p=void 0!==e.bevelSegments?e.bevelSegments:3,d=void 0===e.bevelEnabled||e.bevelEnabled,m=void 0!==e.curveSegments?e.curveSegments:12,v=void 0!==e.steps?e.steps:1,g=e.extrudePath,y=!1,x=e.material,w=e.extrudeMaterial,b=void 0!==e.UVGenerator?e.UVGenerator:We.ExtrudeGeometry.WorldUVGenerator;g&&(r=g.getSpacedPoints(v),d=!(y=!0),i=void 0!==e.frames?e.frames:new We.TubeGeometry.FrenetFrames(g,v,!1),n=new We.Vector3,o=new We.Vector3,a=new We.Vector3),d||(f=c=p=0);var M=this,_=this.vertices.length,S=t.extractPoints(m),T=S.shape,A=S.holes,C=!We.Shape.Utils.isClockWise(T);if(C){for(T=T.reverse(),h=0,l=A.length;h<l;h++)s=A[h],We.Shape.Utils.isClockWise(s)&&(A[h]=s.reverse());C=!1}var E=We.Shape.Utils.triangulateShape(T,A),L=T;for(h=0,l=A.length;h<l;h++)s=A[h],T=T.concat(s);function P(t,e,r){return e||console.log("die"),e.clone().multiplyScalar(r).add(t)}var R,F,D,U,B,k,z=T.length,V=E.length;L.length,Math.PI;function N(t,e,r){var i,n,o=1,a=t.x-e.x,s=t.y-e.y,h=r.x-t.x,l=r.y-t.y,u=a*a+s*s,c=a*l-s*h;if(1e-10<Math.abs(c)){var f=Math.sqrt(u),p=Math.sqrt(h*h+l*l),d=e.x-s/f,m=e.y+a/f,v=((r.x-l/p-d)*l-(r.y+h/p-m)*h)/(a*l-s*h),g=(i=d+a*v-t.x)*i+(n=m+s*v-t.y)*n;if(g<=2)return new We.Vector2(i,n);o=Math.sqrt(g/2)}else{var y=!1;1e-10<a?1e-10<h&&(y=!0):a<-1e-10?h<-1e-10&&(y=!0):Math.sign(s)==Math.sign(l)&&(y=!0),y?(i=-s,n=a,o=Math.sqrt(u)):(i=a,n=s,o=Math.sqrt(u/2))}return new We.Vector2(i/o,n/o)}for(var O=[],I=0,G=L.length,H=G-1,W=I+1;I<G;I++,H++,W++){H===G&&(H=0),W===G&&(W=0);L[I],L[H],L[W];O[I]=N(L[I],L[H],L[W])}var j,X,q=[],Y=O.concat();for(h=0,l=A.length;h<l;h++){for(s=A[h],j=[],I=0,H=(G=s.length)-1,W=I+1;I<G;I++,H++,W++)H===G&&(H=0),W===G&&(W=0),j[I]=N(s[I],s[H],s[W]);q.push(j),Y=Y.concat(j)}for(R=0;R<p;R++){for(U=c*(1-(D=R/p)),F=f*Math.sin(D*Math.PI/2),I=0,G=L.length;I<G;I++)Z((B=P(L[I],O[I],F)).x,B.y,-U);for(h=0,l=A.length;h<l;h++)for(s=A[h],j=q[h],I=0,G=s.length;I<G;I++)Z((B=P(s[I],j[I],F)).x,B.y,-U)}for(F=f,I=0;I<z;I++)B=d?P(T[I],Y[I],F):T[I],y?(o.copy(i.normals[0]).multiplyScalar(B.x),n.copy(i.binormals[0]).multiplyScalar(B.y),a.copy(r[0]).add(o).add(n),Z(a.x,a.y,a.z)):Z(B.x,B.y,0);for(X=1;X<=v;X++)for(I=0;I<z;I++)B=d?P(T[I],Y[I],F):T[I],y?(o.copy(i.normals[X]).multiplyScalar(B.x),n.copy(i.binormals[X]).multiplyScalar(B.y),a.copy(r[X]).add(o).add(n),Z(a.x,a.y,a.z)):Z(B.x,B.y,u/v*X);for(R=p-1;0<=R;R--){for(U=c*(1-(D=R/p)),F=f*Math.sin(D*Math.PI/2),I=0,G=L.length;I<G;I++)Z((B=P(L[I],O[I],F)).x,B.y,u+U);for(h=0,l=A.length;h<l;h++)for(s=A[h],j=q[h],I=0,G=s.length;I<G;I++)B=P(s[I],j[I],F),y?Z(B.x,B.y+r[v-1].y,r[v-1].x+U):Z(B.x,B.y,u+U)}function K(t,e){var r,i;for(I=t.length;0<=--I;){(i=(r=I)-1)<0&&(i=t.length-1);var n=0,o=v+2*p;for(n=0;n<o;n++){var a=z*n,s=z*(n+1);J(e+r+a,e+i+a,e+i+s,e+r+s,t,n,o,r,i)}}}function Z(t,e,r){M.vertices.push(new We.Vector3(t,e,r))}function Q(t,e,r){t+=_,e+=_,r+=_,M.faces.push(new We.Face3(t,e,r,null,null,x));var i=b.generateTopUV(M,t,e,r);M.faceVertexUvs[0].push(i)}function J(t,e,r,i,n,o,a,s,h){t+=_,e+=_,r+=_,i+=_,M.faces.push(new We.Face3(t,e,i,null,null,w)),M.faces.push(new We.Face3(e,r,i,null,null,w));var l=b.generateSideWallUV(M,t,e,r,i);M.faceVertexUvs[0].push([l[0],l[1],l[3]]),M.faceVertexUvs[0].push([l[1],l[2],l[3]])}!function(){if(d){var t=0,e=z*t;for(I=0;I<V;I++)Q((k=E[I])[2]+e,k[1]+e,k[0]+e);for(e=z*(t=v+2*p),I=0;I<V;I++)Q((k=E[I])[0]+e,k[1]+e,k[2]+e)}else{for(I=0;I<V;I++)Q((k=E[I])[2],k[1],k[0]);for(I=0;I<V;I++)Q((k=E[I])[0]+z*v,k[1]+z*v,k[2]+z*v)}}(),function(){var t=0;for(K(L,t),t+=L.length,h=0,l=A.length;h<l;h++)K(s=A[h],t),t+=s.length}()},We.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(t,e,r,i){var n=t.vertices,o=n[e],a=n[r],s=n[i];return[new We.Vector2(o.x,o.y),new We.Vector2(a.x,a.y),new We.Vector2(s.x,s.y)]},generateSideWallUV:function(t,e,r,i,n){var o=t.vertices,a=o[e],s=o[r],h=o[i],l=o[n];return Math.abs(a.y-s.y)<.01?[new We.Vector2(a.x,1-a.z),new We.Vector2(s.x,1-s.z),new We.Vector2(h.x,1-h.z),new We.Vector2(l.x,1-l.z)]:[new We.Vector2(a.y,1-a.z),new We.Vector2(s.y,1-s.z),new We.Vector2(h.y,1-h.z),new We.Vector2(l.y,1-l.z)]}},We.ShapeGeometry=function(t,e){We.Geometry.call(this),this.type="ShapeGeometry",t instanceof Array==!1&&(t=[t]),this.addShapeList(t,e),this.computeFaceNormals()},We.ShapeGeometry.prototype=Object.create(We.Geometry.prototype),We.ShapeGeometry.prototype.addShapeList=function(t,e){for(var r=0,i=t.length;r<i;r++)this.addShape(t[r],e);return this},We.ShapeGeometry.prototype.addShape=function(t,e){void 0===e&&(e={});var r,i,n,o=void 0!==e.curveSegments?e.curveSegments:12,a=e.material,s=void 0===e.UVGenerator?We.ExtrudeGeometry.WorldUVGenerator:e.UVGenerator,h=this.vertices.length,l=t.extractPoints(o),u=l.shape,c=l.holes,f=!We.Shape.Utils.isClockWise(u);if(f){for(u=u.reverse(),r=0,i=c.length;r<i;r++)n=c[r],We.Shape.Utils.isClockWise(n)&&(c[r]=n.reverse());f=!1}var p=We.Shape.Utils.triangulateShape(u,c),d=u;for(r=0,i=c.length;r<i;r++)n=c[r],u=u.concat(n);var m,v,g=u.length,y=p.length;d.length;for(r=0;r<g;r++)m=u[r],this.vertices.push(new We.Vector3(m.x,m.y,0));for(r=0;r<y;r++){var x=(v=p[r])[0]+h,w=v[1]+h,b=v[2]+h;this.faces.push(new We.Face3(x,w,b,null,null,a)),this.faceVertexUvs[0].push(s.generateTopUV(this,x,w,b))}},We.LatheGeometry=function(t,e,r,i){We.Geometry.call(this),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:r,phiLength:i},e=e||12,r=r||0,i=i||2*Math.PI;for(var n=1/(t.length-1),o=1/e,a=0,s=e;a<=s;a++)for(var h=r+a*o*i,l=Math.cos(h),u=Math.sin(h),c=0,f=t.length;c<f;c++){var p=t[c],d=new We.Vector3;d.x=l*p.x-u*p.y,d.y=u*p.x+l*p.y,d.z=p.z,this.vertices.push(d)}var m=t.length;for(a=0,s=e;a<s;a++)for(c=0,f=t.length-1;c<f;c++){var v=c+m*a,g=v,y=v+m,x=(l=v+1+m,v+1),w=a*o,b=c*n,M=w+o,_=b+n;this.faces.push(new We.Face3(g,y,x)),this.faceVertexUvs[0].push([new We.Vector2(w,b),new We.Vector2(M,b),new We.Vector2(w,_)]),this.faces.push(new We.Face3(y,l,x)),this.faceVertexUvs[0].push([new We.Vector2(M,b),new We.Vector2(M,_),new We.Vector2(w,_)])}this.mergeVertices(),this.computeFaceNormals(),this.computeVertexNormals()},We.LatheGeometry.prototype=Object.create(We.Geometry.prototype),We.PlaneGeometry=function(t,e,r,i){console.info("THREE.PlaneGeometry: Consider using THREE.PlaneBufferGeometry for lower memory footprint."),We.Geometry.call(this),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:r,heightSegments:i},this.fromBufferGeometry(new We.PlaneBufferGeometry(t,e,r,i))},We.PlaneGeometry.prototype=Object.create(We.Geometry.prototype),We.PlaneBufferGeometry=function(t,e,r,i){We.BufferGeometry.call(this),this.type="PlaneBufferGeometry",this.parameters={width:t,height:e,widthSegments:r,heightSegments:i};for(var n=t/2,o=e/2,a=r||1,s=i||1,h=a+1,l=s+1,u=t/a,c=e/s,f=new Float32Array(h*l*3),p=new Float32Array(h*l*3),d=new Float32Array(h*l*2),m=0,v=0,g=0;g<l;g++)for(var y=g*c-o,x=0;x<h;x++){var w=x*u-n;f[m]=w,f[m+1]=-y,p[m+2]=1,d[v]=x/a,d[v+1]=1-g/s,m+=3,v+=2}m=0;var b=new(65535<f.length/3?Uint32Array:Uint16Array)(a*s*6);for(g=0;g<s;g++)for(x=0;x<a;x++){var M=x+h*g,_=x+h*(g+1),S=x+1+h*(g+1),T=x+1+h*g;b[m]=M,b[m+1]=_,b[m+2]=T,b[m+3]=_,b[m+4]=S,b[m+5]=T,m+=6}this.addAttribute("index",new We.BufferAttribute(b,1)),this.addAttribute("position",new We.BufferAttribute(f,3)),this.addAttribute("normal",new We.BufferAttribute(p,3)),this.addAttribute("uv",new We.BufferAttribute(d,2))},We.PlaneBufferGeometry.prototype=Object.create(We.BufferGeometry.prototype),We.RingGeometry=function(t,e,r,i,n,o){We.Geometry.call(this),this.type="RingGeometry",this.parameters={innerRadius:t,outerRadius:e,thetaSegments:r,phiSegments:i,thetaStart:n,thetaLength:o},t=t||0,e=e||50,n=void 0!==n?n:0,o=void 0!==o?o:2*Math.PI,r=void 0!==r?Math.max(3,r):8;var a,s,h=[],l=t,u=(e-t)/(i=void 0!==i?Math.max(1,i):8);for(a=0;a<i+1;a++){for(s=0;s<r+1;s++){var c=new We.Vector3,f=n+s/r*o;c.x=l*Math.cos(f),c.y=l*Math.sin(f),this.vertices.push(c),h.push(new We.Vector2((c.x/e+1)/2,(c.y/e+1)/2))}l+=u}var p=new We.Vector3(0,0,1);for(a=0;a<i;a++){var d=a*(r+1);for(s=0;s<r;s++){var m=f=s+d,v=f+r+1,g=f+r+2;this.faces.push(new We.Face3(m,v,g,[p.clone(),p.clone(),p.clone()])),this.faceVertexUvs[0].push([h[m].clone(),h[v].clone(),h[g].clone()]),v=(m=f)+r+2,g=f+1,this.faces.push(new We.Face3(m,v,g,[p.clone(),p.clone(),p.clone()])),this.faceVertexUvs[0].push([h[m].clone(),h[v].clone(),h[g].clone()])}}this.computeFaceNormals(),this.boundingSphere=new We.Sphere(new We.Vector3,l)},We.RingGeometry.prototype=Object.create(We.Geometry.prototype),We.SphereGeometry=function(t,e,r,i,n,o,a){We.Geometry.call(this),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:r,phiStart:i,phiLength:n,thetaStart:o,thetaLength:a},t=t||50,e=Math.max(3,Math.floor(e)||8),r=Math.max(2,Math.floor(r)||6),i=void 0!==i?i:0,n=void 0!==n?n:2*Math.PI,o=void 0!==o?o:0,a=void 0!==a?a:Math.PI;var s,h,l=[],u=[];for(h=0;h<=r;h++){var c=[],f=[];for(s=0;s<=e;s++){var p=s/e,d=h/r,m=new We.Vector3;m.x=-t*Math.cos(i+p*n)*Math.sin(o+d*a),m.y=t*Math.cos(o+d*a),m.z=t*Math.sin(i+p*n)*Math.sin(o+d*a),this.vertices.push(m),c.push(this.vertices.length-1),f.push(new We.Vector2(p,1-d))}l.push(c),u.push(f)}for(h=0;h<r;h++)for(s=0;s<e;s++){var v=l[h][s+1],g=l[h][s],y=l[h+1][s],x=l[h+1][s+1],w=this.vertices[v].clone().normalize(),b=this.vertices[g].clone().normalize(),M=this.vertices[y].clone().normalize(),_=this.vertices[x].clone().normalize(),S=u[h][s+1].clone(),T=u[h][s].clone(),A=u[h+1][s].clone(),C=u[h+1][s+1].clone();Math.abs(this.vertices[v].y)===t?(S.x=(S.x+T.x)/2,this.faces.push(new We.Face3(v,y,x,[w,M,_])),this.faceVertexUvs[0].push([S,A,C])):Math.abs(this.vertices[y].y)===t?(A.x=(A.x+C.x)/2,this.faces.push(new We.Face3(v,g,y,[w,b,M])),this.faceVertexUvs[0].push([S,T,A])):(this.faces.push(new We.Face3(v,g,x,[w,b,_])),this.faceVertexUvs[0].push([S,T,C]),this.faces.push(new We.Face3(g,y,x,[b.clone(),M,_.clone()])),this.faceVertexUvs[0].push([T.clone(),A,C.clone()]))}this.computeFaceNormals(),this.boundingSphere=new We.Sphere(new We.Vector3,t)},We.SphereGeometry.prototype=Object.create(We.Geometry.prototype),We.TextGeometry=function(t,e){e=e||{};var r=We.FontUtils.generateShapes(t,e);e.amount=void 0!==e.height?e.height:50,void 0===e.bevelThickness&&(e.bevelThickness=10),void 0===e.bevelSize&&(e.bevelSize=8),void 0===e.bevelEnabled&&(e.bevelEnabled=!1),We.ExtrudeGeometry.call(this,r,e),this.type="TextGeometry"},We.TextGeometry.prototype=Object.create(We.ExtrudeGeometry.prototype),We.TorusGeometry=function(t,e,r,i,n){We.Geometry.call(this),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:r,tubularSegments:i,arc:n},t=t||100,e=e||40,r=r||8,i=i||6,n=n||2*Math.PI;for(var o=new We.Vector3,a=[],s=[],h=0;h<=r;h++)for(var l=0;l<=i;l++){var u=l/i*n,c=h/r*Math.PI*2;o.x=t*Math.cos(u),o.y=t*Math.sin(u);var f=new We.Vector3;f.x=(t+e*Math.cos(c))*Math.cos(u),f.y=(t+e*Math.cos(c))*Math.sin(u),f.z=e*Math.sin(c),this.vertices.push(f),a.push(new We.Vector2(l/i,h/r)),s.push(f.clone().sub(o).normalize())}for(h=1;h<=r;h++)for(l=1;l<=i;l++){var p=(i+1)*h+l-1,d=(i+1)*(h-1)+l-1,m=(i+1)*(h-1)+l,v=(i+1)*h+l,g=new We.Face3(p,d,v,[s[p].clone(),s[d].clone(),s[v].clone()]);this.faces.push(g),this.faceVertexUvs[0].push([a[p].clone(),a[d].clone(),a[v].clone()]),g=new We.Face3(d,m,v,[s[d].clone(),s[m].clone(),s[v].clone()]),this.faces.push(g),this.faceVertexUvs[0].push([a[d].clone(),a[m].clone(),a[v].clone()])}this.computeFaceNormals()},We.TorusGeometry.prototype=Object.create(We.Geometry.prototype),We.TorusKnotGeometry=function(t,e,r,i,n,o,a){We.Geometry.call(this),this.type="TorusKnotGeometry",this.parameters={radius:t,tube:e,radialSegments:r,tubularSegments:i,p:n,q:o,heightScale:a},t=t||100,e=e||40,r=r||64,i=i||8,n=n||2,o=o||3,a=a||1;for(var s=new Array(r),h=new We.Vector3,l=new We.Vector3,u=new We.Vector3,c=0;c<r;++c){s[c]=new Array(i);var f=c/r*2*n*Math.PI,p=P(f,o,n,t,a),d=P(f+.01,o,n,t,a);h.subVectors(d,p),l.addVectors(d,p),u.crossVectors(h,l),l.crossVectors(u,h),u.normalize(),l.normalize();for(var m=0;m<i;++m){var v=m/i*2*Math.PI,g=-e*Math.cos(v),y=e*Math.sin(v),x=new We.Vector3;x.x=p.x+g*l.x+y*u.x,x.y=p.y+g*l.y+y*u.y,x.z=p.z+g*l.z+y*u.z,s[c][m]=this.vertices.push(x)-1}}for(c=0;c<r;++c)for(m=0;m<i;++m){var w=(c+1)%r,b=(m+1)%i,M=s[c][m],_=s[w][m],S=s[w][b],T=s[c][b],A=new We.Vector2(c/r,m/i),C=new We.Vector2((c+1)/r,m/i),E=new We.Vector2((c+1)/r,(m+1)/i),L=new We.Vector2(c/r,(m+1)/i);this.faces.push(new We.Face3(M,_,T)),this.faceVertexUvs[0].push([A,C,L]),this.faces.push(new We.Face3(_,S,T)),this.faceVertexUvs[0].push([C.clone(),E,L.clone()])}function P(t,e,r,i,n){var o=Math.cos(t),a=Math.sin(t),s=e/r*t,h=Math.cos(s),l=i*(2+h)*.5*o,u=i*(2+h)*a*.5,c=n*i*Math.sin(s)*.5;return new We.Vector3(l,u,c)}this.computeFaceNormals(),this.computeVertexNormals()},We.TorusKnotGeometry.prototype=Object.create(We.Geometry.prototype),We.TubeGeometry=function(t,e,r,i,n){We.Geometry.call(this),this.type="TubeGeometry",this.parameters={path:t,segments:e,radius:r,radialSegments:i,closed:n},r=r||1,i=i||8,n=n||!1;var o,a,s,h,l,u,c,f,p,d,m,v,g,y,x,w,b,M,_,S,T,A,C=[],E=this,L=(e=e||64)+1,P=new We.Vector3,R=new We.TubeGeometry.FrenetFrames(t,e,n),F=R.tangents,D=R.normals,U=R.binormals;for(this.tangents=F,this.normals=D,this.binormals=U,f=0;f<L;f++)for(C[f]=[],s=f/(L-1),c=t.getPointAt(s),F[f],o=D[f],a=U[f],p=0;p<i;p++)h=p/i*2*Math.PI,l=-r*Math.cos(h),u=r*Math.sin(h),P.copy(c),P.x+=l*o.x+u*a.x,P.y+=l*o.y+u*a.y,P.z+=l*o.z+u*a.z,C[f][p]=(S=P.x,T=P.y,A=P.z,E.vertices.push(new We.Vector3(S,T,A))-1);for(f=0;f<e;f++)for(p=0;p<i;p++)d=n?(f+1)%e:f+1,m=(p+1)%i,v=C[f][p],g=C[d][p],y=C[d][m],x=C[f][m],w=new We.Vector2(f/e,p/i),b=new We.Vector2((f+1)/e,p/i),M=new We.Vector2((f+1)/e,(p+1)/i),_=new We.Vector2(f/e,(p+1)/i),this.faces.push(new We.Face3(v,g,x)),this.faceVertexUvs[0].push([w,b,_]),this.faces.push(new We.Face3(g,y,x)),this.faceVertexUvs[0].push([b.clone(),M,_.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},We.TubeGeometry.prototype=Object.create(We.Geometry.prototype),We.TubeGeometry.FrenetFrames=function(t,e,r){new We.Vector3;var i,n,o,a,s,h,l,u=new We.Vector3,c=(new We.Vector3,[]),f=[],p=[],d=new We.Vector3,m=new We.Matrix4,v=e+1;for(this.tangents=c,this.normals=f,this.binormals=p,h=0;h<v;h++)l=h/(v-1),c[h]=t.getTangentAt(l),c[h].normalize();for(function(){f[0]=new We.Vector3,p[0]=new We.Vector3,n=Number.MAX_VALUE,o=Math.abs(c[0].x),a=Math.abs(c[0].y),s=Math.abs(c[0].z),o<=n&&(n=o,u.set(1,0,0));a<=n&&(n=a,u.set(0,1,0));s<=n&&u.set(0,0,1);d.crossVectors(c[0],u).normalize(),f[0].crossVectors(c[0],d),p[0].crossVectors(c[0],f[0])}(),h=1;h<v;h++)f[h]=f[h-1].clone(),p[h]=p[h-1].clone(),d.crossVectors(c[h-1],c[h]),1e-4<d.length()&&(d.normalize(),i=Math.acos(We.Math.clamp(c[h-1].dot(c[h]),-1,1)),f[h].applyMatrix4(m.makeRotationAxis(d,i))),p[h].crossVectors(c[h],f[h]);if(r)for(i=Math.acos(We.Math.clamp(f[0].dot(f[v-1]),-1,1)),i/=v-1,0<c[0].dot(d.crossVectors(f[0],f[v-1]))&&(i=-i),h=1;h<v;h++)f[h].applyMatrix4(m.makeRotationAxis(c[h],i*h)),p[h].crossVectors(c[h],f[h])},We.PolyhedronGeometry=function(t,e,r,i){We.Geometry.call(this),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:r,detail:i},r=r||1,i=i||0;for(var p=this,n=0,o=t.length;n<o;n+=3)w(new We.Vector3(t[n],t[n+1],t[n+2]));var a=this.vertices,s=[],h=(n=0,0);for(o=e.length;n<o;n+=3,h++){var l=a[e[n]],u=a[e[n+1]],c=a[e[n+2]];s[h]=new We.Face3(l.index,u.index,c.index,[l.clone(),u.clone(),c.clone()])}var f=new We.Vector3;for(n=0,o=s.length;n<o;n++)M(s[n],i);for(n=0,o=this.faceVertexUvs[0].length;n<o;n++){var d=this.faceVertexUvs[0][n],m=d[0].x,v=d[1].x,g=d[2].x,y=Math.max(m,Math.max(v,g)),x=Math.min(m,Math.min(v,g));.9<y&&x<.1&&(m<.2&&(d[0].x+=1),v<.2&&(d[1].x+=1),g<.2&&(d[2].x+=1))}for(n=0,o=this.vertices.length;n<o;n++)this.vertices[n].multiplyScalar(r);function w(t){var e=t.normalize().clone();e.index=p.vertices.push(e)-1;var r,i=_(t)/2/Math.PI+.5,n=(r=t,Math.atan2(-r.y,Math.sqrt(r.x*r.x+r.z*r.z))/Math.PI+.5);return e.uv=new We.Vector2(i,1-n),e}function b(t,e,r){var i=new We.Face3(t.index,e.index,r.index,[t.clone(),e.clone(),r.clone()]);p.faces.push(i),f.copy(t).add(e).add(r).divideScalar(3);var n=_(f);p.faceVertexUvs[0].push([S(t.uv,t,n),S(e.uv,e,n),S(r.uv,r,n)])}function M(t,e){for(var r=Math.pow(2,e),i=(Math.pow(4,e),w(p.vertices[t.a])),n=w(p.vertices[t.b]),o=w(p.vertices[t.c]),a=[],s=0;s<=r;s++){a[s]=[];for(var h=w(i.clone().lerp(o,s/r)),l=w(n.clone().lerp(o,s/r)),u=r-s,c=0;c<=u;c++)a[s][c]=0==c&&s==r?h:w(h.clone().lerp(l,c/u))}for(s=0;s<r;s++)for(c=0;c<2*(r-s)-1;c++){var f=Math.floor(c/2);c%2==0?b(a[s][f+1],a[s+1][f],a[s][f]):b(a[s][f+1],a[s+1][f+1],a[s+1][f])}}function _(t){return Math.atan2(t.z,-t.x)}function S(t,e,r){return r<0&&1===t.x&&(t=new We.Vector2(t.x-1,t.y)),0===e.x&&0===e.z&&(t=new We.Vector2(r/2/Math.PI+.5,t.y)),t.clone()}this.mergeVertices(),this.computeFaceNormals(),this.boundingSphere=new We.Sphere(new We.Vector3,r)},We.PolyhedronGeometry.prototype=Object.create(We.Geometry.prototype),We.DodecahedronGeometry=function(t,e){this.parameters={radius:t,detail:e};var r=(1+Math.sqrt(5))/2,i=1/r,n=[-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,-i,-r,0,-i,r,0,i,-r,0,i,r,-i,-r,0,-i,r,0,i,-r,0,i,r,0,-r,0,-i,r,0,-i,-r,0,i,r,0,i];We.PolyhedronGeometry.call(this,n,[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,e)},We.DodecahedronGeometry.prototype=Object.create(We.Geometry.prototype),We.IcosahedronGeometry=function(t,e){var r=(1+Math.sqrt(5))/2,i=[-1,r,0,1,r,0,-1,-r,0,1,-r,0,0,-1,r,0,1,r,0,-1,-r,0,1,-r,r,0,-1,r,0,1,-r,0,-1,-r,0,1];We.PolyhedronGeometry.call(this,i,[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,e),this.type="IcosahedronGeometry",this.parameters={radius:t,detail:e}},We.IcosahedronGeometry.prototype=Object.create(We.Geometry.prototype),We.OctahedronGeometry=function(t,e){this.parameters={radius:t,detail:e};We.PolyhedronGeometry.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,e),this.type="OctahedronGeometry",this.parameters={radius:t,detail:e}},We.OctahedronGeometry.prototype=Object.create(We.Geometry.prototype),We.TetrahedronGeometry=function(t,e){We.PolyhedronGeometry.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,e),this.type="TetrahedronGeometry",this.parameters={radius:t,detail:e}},We.TetrahedronGeometry.prototype=Object.create(We.Geometry.prototype),We.ParametricGeometry=function(t,e,r){We.Geometry.call(this),this.type="ParametricGeometry",this.parameters={func:t,slices:e,stacks:r};var i,n,o,a,s,h,l,u,c,f,p,d,m=this.vertices,v=this.faces,g=this.faceVertexUvs[0],y=e+1;for(i=0;i<=r;i++)for(a=i/r,n=0;n<=e;n++)o=t(n/e,a),m.push(o);for(i=0;i<r;i++)for(n=0;n<e;n++)h=(s=i*y+n)+1,l=(i+1)*y+n+1,u=(i+1)*y+n,c=new We.Vector2(n/e,i/r),f=new We.Vector2((n+1)/e,i/r),p=new We.Vector2((n+1)/e,(i+1)/r),d=new We.Vector2(n/e,(i+1)/r),v.push(new We.Face3(s,h,u)),g.push([c,f,d]),v.push(new We.Face3(h,l,u)),g.push([f.clone(),p,d.clone()]);this.computeFaceNormals(),this.computeVertexNormals()},We.ParametricGeometry.prototype=Object.create(We.Geometry.prototype),We.AxisHelper=function(t){t=t||1;var e=new Float32Array([0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t]),r=new Float32Array([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1]),i=new We.BufferGeometry;i.addAttribute("position",new We.BufferAttribute(e,3)),i.addAttribute("color",new We.BufferAttribute(r,3));var n=new We.LineBasicMaterial({vertexColors:We.VertexColors});We.Line.call(this,i,n,We.LinePieces)},We.AxisHelper.prototype=Object.create(We.Line.prototype),We.ArrowHelper=function(){var a=new We.Geometry;a.vertices.push(new We.Vector3(0,0,0),new We.Vector3(0,1,0));var s=new We.CylinderGeometry(0,.5,1,5,1);return s.applyMatrix((new We.Matrix4).makeTranslation(0,-.5,0)),function(t,e,r,i,n,o){We.Object3D.call(this),void 0===i&&(i=16776960),void 0===r&&(r=1),void 0===n&&(n=.2*r),void 0===o&&(o=.2*n),this.position.copy(e),this.line=new We.Line(a,new We.LineBasicMaterial({color:i})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new We.Mesh(s,new We.MeshBasicMaterial({color:i})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(t),this.setLength(r,n,o)}}(),We.ArrowHelper.prototype=Object.create(We.Object3D.prototype),We.ArrowHelper.prototype.setDirection=(Le=new We.Vector3,function(t){.99999<t.y?this.quaternion.set(0,0,0,1):t.y<-.99999?this.quaternion.set(1,0,0,0):(Le.set(t.z,0,-t.x).normalize(),Ee=Math.acos(t.y),this.quaternion.setFromAxisAngle(Le,Ee))}),We.ArrowHelper.prototype.setLength=function(t,e,r){void 0===e&&(e=.2*t),void 0===r&&(r=.2*e),this.line.scale.set(1,t,1),this.line.updateMatrix(),this.cone.scale.set(r,e,r),this.cone.position.y=t,this.cone.updateMatrix()},We.ArrowHelper.prototype.setColor=function(t){this.line.material.color.set(t),this.cone.material.color.set(t)},We.BoxHelper=function(t){var e=new We.BufferGeometry;e.addAttribute("position",new We.BufferAttribute(new Float32Array(72),3)),We.Line.call(this,e,new We.LineBasicMaterial({color:16776960}),We.LinePieces),void 0!==t&&this.update(t)},We.BoxHelper.prototype=Object.create(We.Line.prototype),We.BoxHelper.prototype.update=function(t){var e=t.geometry;null===e.boundingBox&&e.computeBoundingBox();var r=e.boundingBox.min,i=e.boundingBox.max,n=this.geometry.attributes.position.array;n[0]=i.x,n[1]=i.y,n[2]=i.z,n[3]=r.x,n[4]=i.y,n[5]=i.z,n[6]=r.x,n[7]=i.y,n[8]=i.z,n[9]=r.x,n[10]=r.y,n[11]=i.z,n[12]=r.x,n[13]=r.y,n[14]=i.z,n[15]=i.x,n[16]=r.y,n[17]=i.z,n[18]=i.x,n[19]=r.y,n[20]=i.z,n[21]=i.x,n[22]=i.y,n[23]=i.z,n[24]=i.x,n[25]=i.y,n[26]=r.z,n[27]=r.x,n[28]=i.y,n[29]=r.z,n[30]=r.x,n[31]=i.y,n[32]=r.z,n[33]=r.x,n[34]=r.y,n[35]=r.z,n[36]=r.x,n[37]=r.y,n[38]=r.z,n[39]=i.x,n[40]=r.y,n[41]=r.z,n[42]=i.x,n[43]=r.y,n[44]=r.z,n[45]=i.x,n[46]=i.y,n[47]=r.z,n[48]=i.x,n[49]=i.y,n[50]=i.z,n[51]=i.x,n[52]=i.y,n[53]=r.z,n[54]=r.x,n[55]=i.y,n[56]=i.z,n[57]=r.x,n[58]=i.y,n[59]=r.z,n[60]=r.x,n[61]=r.y,n[62]=i.z,n[63]=r.x,n[64]=r.y,n[65]=r.z,n[66]=i.x,n[67]=r.y,n[68]=i.z,n[69]=i.x,n[70]=r.y,n[71]=r.z,this.geometry.attributes.position.needsUpdate=!0,this.geometry.computeBoundingSphere(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1},We.BoundingBoxHelper=function(t,e){var r=void 0!==e?e:8947848;this.object=t,this.box=new We.Box3,We.Mesh.call(this,new We.BoxGeometry(1,1,1),new We.MeshBasicMaterial({color:r,wireframe:!0}))},We.BoundingBoxHelper.prototype=Object.create(We.Mesh.prototype),We.BoundingBoxHelper.prototype.update=function(){this.box.setFromObject(this.object),this.box.size(this.scale),this.box.center(this.position)},We.CameraHelper=function(t){var r=new We.Geometry,e=new We.LineBasicMaterial({color:16777215,vertexColors:We.FaceColors}),i={},n=16755200,o=16711680,a=3355443;function s(t,e,r){h(t,r),h(e,r)}function h(t,e){r.vertices.push(new We.Vector3),r.colors.push(new We.Color(e)),void 0===i[t]&&(i[t]=[]),i[t].push(r.vertices.length-1)}s("n1","n2",n),s("n2","n4",n),s("n4","n3",n),s("n3","n1",n),s("f1","f2",n),s("f2","f4",n),s("f4","f3",n),s("f3","f1",n),s("n1","f1",n),s("n2","f2",n),s("n3","f3",n),s("n4","f4",n),s("p","n1",o),s("p","n2",o),s("p","n3",o),s("p","n4",o),s("u1","u2",43775),s("u2","u3",43775),s("u3","u1",43775),s("c","t",16777215),s("p","c",a),s("cn1","cn2",a),s("cn3","cn4",a),s("cf1","cf2",a),s("cf3","cf4",a),We.Line.call(this,r,e,We.LinePieces),this.camera=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=i,this.update()},We.CameraHelper.prototype=Object.create(We.Line.prototype),We.CameraHelper.prototype.update=(Fe=new We.Vector3,De=new We.Camera,Ue=function(t,e,r,i){Fe.set(e,r,i).unproject(De);var n=Re[t];if(void 0!==n)for(var o=0,a=n.length;o<a;o++)Pe.vertices[n[o]].copy(Fe)},function(){Pe=this.geometry,Re=this.pointMap,De.projectionMatrix.copy(this.camera.projectionMatrix),Ue("c",0,0,-1),Ue("t",0,0,1),Ue("n1",-1,-1,-1),Ue("n2",1,-1,-1),Ue("n3",-1,1,-1),Ue("n4",1,1,-1),Ue("f1",-1,-1,1),Ue("f2",1,-1,1),Ue("f3",-1,1,1),Ue("f4",1,1,1),Ue("u1",.7,1.1,-1),Ue("u2",-.7,1.1,-1),Ue("u3",0,2,-1),Ue("cf1",-1,0,1),Ue("cf2",1,0,1),Ue("cf3",0,-1,1),Ue("cf4",0,1,1),Ue("cn1",-1,0,-1),Ue("cn2",1,0,-1),Ue("cn3",0,-1,-1),Ue("cn4",0,1,-1),Pe.verticesNeedUpdate=!0}),We.DirectionalLightHelper=function(t,e){We.Object3D.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,e=e||1;var r=new We.Geometry;r.vertices.push(new We.Vector3(-e,e,0),new We.Vector3(e,e,0),new We.Vector3(e,-e,0),new We.Vector3(-e,-e,0),new We.Vector3(-e,e,0));var i=new We.LineBasicMaterial({fog:!1});i.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.lightPlane=new We.Line(r,i),this.add(this.lightPlane),(r=new We.Geometry).vertices.push(new We.Vector3,new We.Vector3),(i=new We.LineBasicMaterial({fog:!1})).color.copy(this.light.color).multiplyScalar(this.light.intensity),this.targetLine=new We.Line(r,i),this.add(this.targetLine),this.update()},We.DirectionalLightHelper.prototype=Object.create(We.Object3D.prototype),We.DirectionalLightHelper.prototype.dispose=function(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()},We.DirectionalLightHelper.prototype.update=(Be=new We.Vector3,ke=new We.Vector3,ze=new We.Vector3,function(){Be.setFromMatrixPosition(this.light.matrixWorld),ke.setFromMatrixPosition(this.light.target.matrixWorld),ze.subVectors(ke,Be),this.lightPlane.lookAt(ze),this.lightPlane.material.color.copy(this.light.color).multiplyScalar(this.light.intensity),this.targetLine.geometry.vertices[1].copy(ze),this.targetLine.geometry.verticesNeedUpdate=!0,this.targetLine.material.color.copy(this.lightPlane.material.color)}),We.EdgesHelper=function(t,e){var r=void 0!==e?e:16777215,i=[0,0],n={},o=function(t,e){return t-e},a=["a","b","c"],s=new We.BufferGeometry,h=t.geometry.clone();h.mergeVertices(),h.computeFaceNormals();for(var l=h.vertices,u=h.faces,c=0,f=0,p=u.length;f<p;f++)for(var d=u[f],m=0;m<3;m++){i[0]=d[a[m]],i[1]=d[a[(m+1)%3]],i.sort(o),void 0===n[y=i.toString()]?(n[y]={vert1:i[0],vert2:i[1],face1:f,face2:void 0},c++):n[y].face2=f}var v=new Float32Array(2*c*3),g=0;for(var y in n){var x=n[y];if(void 0===x.face2||u[x.face1].normal.dot(u[x.face2].normal)<.9999){var w=l[x.vert1];v[g++]=w.x,v[g++]=w.y,v[g++]=w.z,w=l[x.vert2],v[g++]=w.x,v[g++]=w.y,v[g++]=w.z}}s.addAttribute("position",new We.BufferAttribute(v,3)),We.Line.call(this,s,new We.LineBasicMaterial({color:r}),We.LinePieces),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1},We.EdgesHelper.prototype=Object.create(We.Line.prototype),We.FaceNormalsHelper=function(t,e,r,i){this.object=t,this.size=void 0!==e?e:1;for(var n=void 0!==r?r:16776960,o=void 0!==i?i:1,a=new We.Geometry,s=0,h=this.object.geometry.faces.length;s<h;s++)a.vertices.push(new We.Vector3,new We.Vector3);We.Line.call(this,a,new We.LineBasicMaterial({color:n,linewidth:o}),We.LinePieces),this.matrixAutoUpdate=!1,this.normalMatrix=new We.Matrix3,this.update()},We.FaceNormalsHelper.prototype=Object.create(We.Line.prototype),We.FaceNormalsHelper.prototype.update=function(){var t=this.geometry.vertices,e=this.object,r=e.geometry.vertices,i=e.geometry.faces,n=e.matrixWorld;e.updateMatrixWorld(!0),this.normalMatrix.getNormalMatrix(n);for(var o=0,a=0,s=i.length;o<s;o++,a+=2){var h=i[o];t[a].copy(r[h.a]).add(r[h.b]).add(r[h.c]).divideScalar(3).applyMatrix4(n),t[a+1].copy(h.normal).applyMatrix3(this.normalMatrix).normalize().multiplyScalar(this.size).add(t[a])}return this.geometry.verticesNeedUpdate=!0,this},We.GridHelper=function(t,e){var r=new We.Geometry,i=new We.LineBasicMaterial({vertexColors:We.VertexColors});this.color1=new We.Color(4473924),this.color2=new We.Color(8947848);for(var n=-t;n<=t;n+=e){r.vertices.push(new We.Vector3(-t,0,n),new We.Vector3(t,0,n),new We.Vector3(n,0,-t),new We.Vector3(n,0,t));var o=0===n?this.color1:this.color2;r.colors.push(o,o,o,o)}We.Line.call(this,r,i,We.LinePieces)},We.GridHelper.prototype=Object.create(We.Line.prototype),We.GridHelper.prototype.setColors=function(t,e){this.color1.set(t),this.color2.set(e),this.geometry.colorsNeedUpdate=!0},We.HemisphereLightHelper=function(t,e,r,i){We.Object3D.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.colors=[new We.Color,new We.Color];var n=new We.SphereGeometry(e,4,2);n.applyMatrix((new We.Matrix4).makeRotationX(-Math.PI/2));for(var o=0;o<8;o++)n.faces[o].color=this.colors[o<4?0:1];var a=new We.MeshBasicMaterial({vertexColors:We.FaceColors,wireframe:!0});this.lightSphere=new We.Mesh(n,a),this.add(this.lightSphere),this.update()},We.HemisphereLightHelper.prototype=Object.create(We.Object3D.prototype),We.HemisphereLightHelper.prototype.dispose=function(){this.lightSphere.geometry.dispose(),this.lightSphere.material.dispose()},We.HemisphereLightHelper.prototype.update=(Ve=new We.Vector3,function(){this.colors[0].copy(this.light.color).multiplyScalar(this.light.intensity),this.colors[1].copy(this.light.groundColor).multiplyScalar(this.light.intensity),this.lightSphere.lookAt(Ve.setFromMatrixPosition(this.light.matrixWorld).negate()),this.lightSphere.geometry.colorsNeedUpdate=!0}),We.PointLightHelper=function(t,e){this.light=t,this.light.updateMatrixWorld();var r=new We.SphereGeometry(e,4,2),i=new We.MeshBasicMaterial({wireframe:!0,fog:!1});i.color.copy(this.light.color).multiplyScalar(this.light.intensity),We.Mesh.call(this,r,i),this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1},We.PointLightHelper.prototype=Object.create(We.Mesh.prototype),We.PointLightHelper.prototype.dispose=function(){this.geometry.dispose(),this.material.dispose()},We.PointLightHelper.prototype.update=function(){this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)},We.SkeletonHelper=function(t){this.bones=this.getBoneList(t);for(var e=new We.Geometry,r=0;r<this.bones.length;r++){this.bones[r].parent instanceof We.Bone&&(e.vertices.push(new We.Vector3),e.vertices.push(new We.Vector3),e.colors.push(new We.Color(0,0,1)),e.colors.push(new We.Color(0,1,0)))}var i=new We.LineBasicMaterial({vertexColors:We.VertexColors,depthTest:!1,depthWrite:!1,transparent:!0});We.Line.call(this,e,i,We.LinePieces),this.root=t,this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.update()},We.SkeletonHelper.prototype=Object.create(We.Line.prototype),We.SkeletonHelper.prototype.getBoneList=function(t){var e=[];t instanceof We.Bone&&e.push(t);for(var r=0;r<t.children.length;r++)e.push.apply(e,this.getBoneList(t.children[r]));return e},We.SkeletonHelper.prototype.update=function(){for(var t=this.geometry,e=(new We.Matrix4).getInverse(this.root.matrixWorld),r=new We.Matrix4,i=0,n=0;n<this.bones.length;n++){var o=this.bones[n];o.parent instanceof We.Bone&&(r.multiplyMatrices(e,o.matrixWorld),t.vertices[i].setFromMatrixPosition(r),r.multiplyMatrices(e,o.parent.matrixWorld),t.vertices[i+1].setFromMatrixPosition(r),i+=2)}t.verticesNeedUpdate=!0,t.computeBoundingSphere()},We.SpotLightHelper=function(t){We.Object3D.call(this),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1;var e=new We.CylinderGeometry(0,1,1,8,1,!0);e.applyMatrix((new We.Matrix4).makeTranslation(0,-.5,0)),e.applyMatrix((new We.Matrix4).makeRotationX(-Math.PI/2));var r=new We.MeshBasicMaterial({wireframe:!0,fog:!1});this.cone=new We.Mesh(e,r),this.add(this.cone),this.update()},We.SpotLightHelper.prototype=Object.create(We.Object3D.prototype),We.SpotLightHelper.prototype.dispose=function(){this.cone.geometry.dispose(),this.cone.material.dispose()},We.SpotLightHelper.prototype.update=(Ne=new We.Vector3,Oe=new We.Vector3,function(){var t=this.light.distance?this.light.distance:1e4,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),Ne.setFromMatrixPosition(this.light.matrixWorld),Oe.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Oe.sub(Ne)),this.cone.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)}),We.VertexNormalsHelper=function(t,e,r,i){this.object=t,this.size=void 0!==e?e:1;for(var n=void 0!==r?r:16711680,o=void 0!==i?i:1,a=new We.Geometry,s=(t.geometry.vertices,t.geometry.faces),h=0,l=s.length;h<l;h++)for(var u=0,c=s[h].vertexNormals.length;u<c;u++)a.vertices.push(new We.Vector3,new We.Vector3);We.Line.call(this,a,new We.LineBasicMaterial({color:n,linewidth:o}),We.LinePieces),this.matrixAutoUpdate=!1,this.normalMatrix=new We.Matrix3,this.update()},We.VertexNormalsHelper.prototype=Object.create(We.Line.prototype),We.VertexNormalsHelper.prototype.update=(Ie=new We.Vector3,function(t){var e=["a","b","c","d"];this.object.updateMatrixWorld(!0),this.normalMatrix.getNormalMatrix(this.object.matrixWorld);for(var r=this.geometry.vertices,i=this.object.geometry.vertices,n=this.object.geometry.faces,o=this.object.matrixWorld,a=0,s=0,h=n.length;s<h;s++)for(var l=n[s],u=0,c=l.vertexNormals.length;u<c;u++){var f=i[l[e[u]]],p=l.vertexNormals[u];r[a].copy(f).applyMatrix4(o),Ie.copy(p).applyMatrix3(this.normalMatrix).normalize().multiplyScalar(this.size),Ie.add(r[a]),r[a+=1].copy(Ie),a+=1}return this.geometry.verticesNeedUpdate=!0,this}),We.VertexTangentsHelper=function(t,e,r,i){this.object=t,this.size=void 0!==e?e:1;for(var n=void 0!==r?r:255,o=void 0!==i?i:1,a=new We.Geometry,s=(t.geometry.vertices,t.geometry.faces),h=0,l=s.length;h<l;h++)for(var u=0,c=s[h].vertexTangents.length;u<c;u++)a.vertices.push(new We.Vector3),a.vertices.push(new We.Vector3);We.Line.call(this,a,new We.LineBasicMaterial({color:n,linewidth:o}),We.LinePieces),this.matrixAutoUpdate=!1,this.update()},We.VertexTangentsHelper.prototype=Object.create(We.Line.prototype),We.VertexTangentsHelper.prototype.update=(Ge=new We.Vector3,function(t){var e=["a","b","c","d"];this.object.updateMatrixWorld(!0);for(var r=this.geometry.vertices,i=this.object.geometry.vertices,n=this.object.geometry.faces,o=this.object.matrixWorld,a=0,s=0,h=n.length;s<h;s++)for(var l=n[s],u=0,c=l.vertexTangents.length;u<c;u++){var f=i[l[e[u]]],p=l.vertexTangents[u];r[a].copy(f).applyMatrix4(o),Ge.copy(p).transformDirection(o).multiplyScalar(this.size),Ge.add(r[a]),r[a+=1].copy(Ge),a+=1}return this.geometry.verticesNeedUpdate=!0,this}),We.WireframeHelper=function(t,e){var r=void 0!==e?e:16777215,i=[0,0],n={},o=function(t,e){return t-e},a=["a","b","c"],s=new We.BufferGeometry;if(t.geometry instanceof We.Geometry){for(var h=t.geometry.vertices,l=t.geometry.faces,u=0,c=new Uint32Array(6*l.length),f=0,p=l.length;f<p;f++)for(var d=l[f],m=0;m<3;m++){i[0]=d[a[m]],i[1]=d[a[(m+1)%3]],i.sort(o),void 0===n[A=i.toString()]&&(c[2*u]=i[0],c[2*u+1]=i[1],n[A]=!0,u++)}var v=new Float32Array(2*u*3);for(f=0,p=u;f<p;f++)for(m=0;m<2;m++){var g=h[c[2*f+m]];v[(S=6*f+3*m)+0]=g.x,v[S+1]=g.y,v[S+2]=g.z}s.addAttribute("position",new We.BufferAttribute(v,3))}else if(t.geometry instanceof We.BufferGeometry)if(void 0!==t.geometry.attributes.index){h=t.geometry.attributes.position.array;var y=t.geometry.attributes.index.array,x=t.geometry.drawcalls;u=0;0===x.length&&(x=[{count:y.length,index:0,start:0}]);c=new Uint32Array(2*y.length);for(var w=0,b=x.length;w<b;++w)for(var M=x[w].start,_=x[w].count,S=x[w].index,T=(f=M,M+_);f<T;f+=3)for(m=0;m<3;m++){var A;i[0]=S+y[f+m],i[1]=S+y[f+(m+1)%3],i.sort(o),void 0===n[A=i.toString()]&&(c[2*u]=i[0],c[2*u+1]=i[1],n[A]=!0,u++)}for(v=new Float32Array(2*u*3),f=0,p=u;f<p;f++)for(m=0;m<2;m++){S=6*f+3*m;var C=3*c[2*f+m];v[S+0]=h[C],v[S+1]=h[C+1],v[S+2]=h[C+2]}s.addAttribute("position",new We.BufferAttribute(v,3))}else{var E=(u=(h=t.geometry.attributes.position.array).length/3)/3;for(v=new Float32Array(2*u*3),f=0,p=E;f<p;f++)for(m=0;m<3;m++){var L=9*f+3*m;v[(S=18*f+6*m)+0]=h[L],v[S+1]=h[L+1],v[S+2]=h[L+2];C=9*f+(m+1)%3*3;v[S+3]=h[C],v[S+4]=h[C+1],v[S+5]=h[C+2]}s.addAttribute("position",new We.BufferAttribute(v,3))}We.Line.call(this,s,new We.LineBasicMaterial({color:r}),We.LinePieces),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1},We.WireframeHelper.prototype=Object.create(We.Line.prototype),We.ImmediateRenderObject=function(){We.Object3D.call(this),this.render=function(t){}},We.ImmediateRenderObject.prototype=Object.create(We.Object3D.prototype),We.MorphBlendMesh=function(t,e){We.Mesh.call(this,t,e),this.animationsMap={},this.animationsList=[];var r=this.geometry.morphTargets.length,i=r-1,n=r/1;this.createAnimation("__default",0,i,n),this.setAnimationWeight("__default",1)},We.MorphBlendMesh.prototype=Object.create(We.Mesh.prototype),We.MorphBlendMesh.prototype.createAnimation=function(t,e,r,i){var n={startFrame:e,endFrame:r,length:r-e+1,fps:i,duration:(r-e)/i,lastFrame:0,currentFrame:0,active:!1,time:0,direction:1,weight:1,directionBackwards:!1,mirroredLoop:!1};this.animationsMap[t]=n,this.animationsList.push(n)},We.MorphBlendMesh.prototype.autoCreateAnimations=function(t){for(var e,r=/([a-z]+)_?(\d+)/,i={},n=this.geometry,o=0,a=n.morphTargets.length;o<a;o++){var s=n.morphTargets[o].name.match(r);if(s&&1<s.length){var h=s[1];s[2];i[h]||(i[h]={start:1/0,end:-1/0}),o<(l=i[h]).start&&(l.start=o),o>l.end&&(l.end=o),e||(e=h)}}for(var h in i){var l=i[h];this.createAnimation(h,l.start,l.end,t)}this.firstAnimation=e},We.MorphBlendMesh.prototype.setAnimationDirectionForward=function(t){var e=this.animationsMap[t];e&&(e.direction=1,e.directionBackwards=!1)},We.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(t){var e=this.animationsMap[t];e&&(e.direction=-1,e.directionBackwards=!0)},We.MorphBlendMesh.prototype.setAnimationFPS=function(t,e){var r=this.animationsMap[t];r&&(r.fps=e,r.duration=(r.end-r.start)/r.fps)},We.MorphBlendMesh.prototype.setAnimationDuration=function(t,e){var r=this.animationsMap[t];r&&(r.duration=e,r.fps=(r.end-r.start)/r.duration)},We.MorphBlendMesh.prototype.setAnimationWeight=function(t,e){var r=this.animationsMap[t];r&&(r.weight=e)},We.MorphBlendMesh.prototype.setAnimationTime=function(t,e){var r=this.animationsMap[t];r&&(r.time=e)},We.MorphBlendMesh.prototype.getAnimationTime=function(t){var e=0,r=this.animationsMap[t];return r&&(e=r.time),e},We.MorphBlendMesh.prototype.getAnimationDuration=function(t){var e=-1,r=this.animationsMap[t];return r&&(e=r.duration),e},We.MorphBlendMesh.prototype.playAnimation=function(t){var e=this.animationsMap[t];e?(e.time=0,e.active=!0):console.warn("animation["+t+"] undefined")},We.MorphBlendMesh.prototype.stopAnimation=function(t){var e=this.animationsMap[t];e&&(e.active=!1)},We.MorphBlendMesh.prototype.update=function(t){for(var e=0,r=this.animationsList.length;e<r;e++){var i=this.animationsList[e];if(i.active){var n=i.duration/i.length;i.time+=i.direction*t,i.mirroredLoop?(i.time>i.duration||i.time<0)&&(i.direction*=-1,i.time>i.duration&&(i.time=i.duration,i.directionBackwards=!0),i.time<0&&(i.time=0,i.directionBackwards=!1)):(i.time=i.time%i.duration,i.time<0&&(i.time+=i.duration));var o=i.startFrame+We.Math.clamp(Math.floor(i.time/n),0,i.length-1),a=i.weight;o!==i.currentFrame&&(this.morphTargetInfluences[i.lastFrame]=0,this.morphTargetInfluences[i.currentFrame]=1*a,this.morphTargetInfluences[o]=0,i.lastFrame=i.currentFrame,i.currentFrame=o);var s=i.time%n/n;i.directionBackwards&&(s=1-s),this.morphTargetInfluences[i.currentFrame]=s*a,this.morphTargetInfluences[i.lastFrame]=(1-s)*a}}},void 0!==r?(void 0!==e&&e.exports&&(r=e.exports=We),r.THREE=We):this.THREE=We},{}],114:[function(t,e,r){e.exports=function(t){if(3!==t.length)throw new TypeError("must provide triangle array of length 3");for(var e=t[0].length,r=new Array(e),i=0;i<e;i++){var n=t[0][i],o=t[1][i],a=t[2][i];r[i]=(n+o+a)/3}return r}},{}],115:[function(t,e,r){(r=e.exports=function(t){return t.replace(/^\s*|\s*$/g,"")}).left=function(t){return t.replace(/^\s*/,"")},r.right=function(t){return t.replace(/\s*$/,"")}},{}],116:[function(t,e,r){var i=function(){},n=t("eases/linear"),o=t("events").EventEmitter;function a(t){o.call(this),this.duration=t&&t.duration||0,this.delay=t&&t.delay||0,this.time=0,this.ease=t&&t.ease,this.active=!0,this.enabled=!0,this.cancelling=!1,this._started=!1}function s(t,e){return"function"==typeof t.ease?t.ease(e):n(e)}t("inherits")(a,o),a.prototype.lerp=i,a.prototype.ready=i,a.prototype.cancel=function(){return this.cancelling=!0,this},a.prototype.tick=function(t,e){if(e="function"==typeof e?e:s,this.cancelling&&this.active&&(this.active=!1,this.emit("cancelling",this),this.emit("complete",this)),this.active&&this.enabled){this.time;this.time+=t;var r=(this.time-this.delay)/this.duration;0<this.time-this.delay&&(this._started||(this._started=!0,this.ready(),this.emit("start",this)),r<0?r=0:1<r&&(r=1),r=e(this,r),this.lerp(r),this.emit("update",this)),this.time>=this.duration+this.delay&&(this.active=!1,this.emit("complete",this))}},e.exports=a},{"eases/linear":62,events:138,inherits:79}],117:[function(t,e,r){var i=t("./lib/object"),n=t("./lib/group");e.exports=function(t,e){return Array.isArray(t)?new n(t,e):new i(t,e)}},{"./lib/group":119,"./lib/object":120}],118:[function(t,e,r){var i=t("tween-base"),s=t("an-array"),h=t("own-enumerable-keys"),l=h(new i);e.exports=function(t,e){var r=[],i=h(e);for(var n in e)if(0<=i.indexOf(n)&&n in t&&-1===l.indexOf(n)){var o=t[n],a=e[n];"number"==typeof o&&"number"==typeof a?r.push({key:n,start:o,end:a}):s(o)&&s(a)&&r.push({key:n,start:o.slice(),end:a.slice()})}return r}},{"an-array":6,"own-enumerable-keys":90,"tween-base":116}],119:[function(t,e,r){var i=t("inherits"),s=t("lerp-array"),n=t("tween-base"),o=t("./end-target");function a(t,e){n.call(this,e),this.target=t,this.end=[],this._options=e}i(a,n),a.prototype.ready=function(){this.end=this.target.map(function(t){return o(t,this._options)},this)},a.prototype.lerp=function(t){for(var e=0;e<this.end.length;e++)for(var r=this.end[e],i=this.target[e],n=0;n<r.length;n++){var o=r[n],a=o.key;i[a]=s(o.start,o.end,t,i[a])}},e.exports=a},{"./end-target":118,inherits:79,"lerp-array":81,"tween-base":116}],120:[function(t,e,r){var i=t("inherits"),n=t("lerp-array"),o=t("tween-base"),a=t("./end-target");function s(t,e){o.call(this,e),this.target=t,this.endings=void 0,this._options=e}i(s,o),s.prototype.ready=function(){this.endings=a(this.target,this._options)},s.prototype.lerp=function(t){for(var e=0;e<this.endings.length;e++){var r=this.endings[e],i=r.key;this.target[i]=n(r.start,r.end,t,this.target[i])}},e.exports=s},{"./end-target":118,inherits:79,"lerp-array":81,"tween-base":116}],121:[function(t,e,r){var i=t("eases/linear"),n=t("tween-objects"),o=t("tween-base");function a(t){if(!(this instanceof a))return new a(t);t=t||{},this.stack=[],this.defaultEase=t.defaultEase||i,this.eases=t.eases||{},this._applyEase=this.ease.bind(this)}a.prototype.clear=a.prototype.cancel=function(){for(var t=0;t<this.stack.length;t++){var e=this.stack[t];e.cancel(),e.tick(0)}return this.stack.length=0,this},a.prototype.to=function(t,e){var r,i=t;if(e&&"object"==typeof e)i=n(t,e);else if(t||e){if("function"!=typeof(r=i).tick||"function"!=typeof r.cancel)throw new Error("must provide options or a tween object")}else i=new o;return this.push(i)},a.prototype.push=function(t){return this.stack.push(t),t},a.prototype.tick=function(t,e){e="function"==typeof e?e:this._applyEase,t="number"==typeof t?t:1/60;for(var r=0;r<this.stack.length;r++)this.stack[r].tick(t,e);for(function(t){for(var e=0;e<t.length;e++){var r=t[e];"function"==typeof r.sync&&r.sync()}}(this.stack),r=this.stack.length-1;0<=r;r--)this.stack[r].active||this.stack.splice(r,1)},a.prototype.ease=function(t,e){var r=t.ease||this.defaultEase;return"string"==typeof r&&(r=this.eases[r]),"function"!=typeof r&&(r=i),r(e)},e.exports=a},{"eases/linear":62,"tween-base":116,"tween-objects":117}],122:[function(t,e,r){var i=t("xtend"),n=t("eases"),o=t("tween-ticker"),a=t("events").EventEmitter,s=t("inherits"),h=t("mixes"),l=t("./loop"),u={eases:n};function c(t){if(!(this instanceof c))return new c(t);o.call(this,i(u,t)),a.call(this),this.timeScale=1,this._handleTick=function(t){t=Math.min(30,t),t/=1e3,t*=this.timeScale,this.emit("tick",t),this.tick(t)}.bind(this),l.on("tick",this._handleTick)}s(e.exports=c,o),h(c,a.prototype),c.prototype.dispose=function(){l.removeListener("tick",this._handleTick)}},{"./loop":123,eases:61,events:138,inherits:79,mixes:85,"tween-ticker":121,xtend:134}],123:[function(t,e,r){var i=t("raf-loop")();i.setMaxListeners(1/0),i.start(),e.exports=i},{"raf-loop":94}],124:[function(t,e,r){"use strict";e.exports=function(t,e,r){var i=t*e,n=c*t,o=n-(n-t),a=t-o,s=c*e,h=s-(s-e),l=e-h,u=a*l-(i-o*h-a*h-o*l);if(r)return r[0]=u,r[1]=i,r;return[u,i]};var c=+(Math.pow(2,27)+1)},{}],125:[function(t,e,r){"use strict";e.exports=function(t,e,r){var i=t+e,n=i-t,o=e-n,a=t-(i-n);if(r)return r[0]=a+o,r[1]=i,r;return[a+o,i]}},{}],126:[function(b,t,M){(function(t,i){"use strict";var n=b("bit-twiddle"),e=b("dup");t.__TYPEDARRAY_POOL||(t.__TYPEDARRAY_POOL={UINT8:e([32,0]),UINT16:e([32,0]),UINT32:e([32,0]),INT8:e([32,0]),INT16:e([32,0]),INT32:e([32,0]),FLOAT:e([32,0]),DOUBLE:e([32,0]),DATA:e([32,0]),UINT8C:e([32,0]),BUFFER:e([32,0])});var r="undefined"!=typeof Uint8ClampedArray,o=t.__TYPEDARRAY_POOL;o.UINT8C||(o.UINT8C=e([32,0])),o.BUFFER||(o.BUFFER=e([32,0]));var a=o.DATA,s=o.BUFFER;function h(t){if(t){var e=t.length||t.byteLength,r=n.log2(e);a[r].push(t)}}function l(t){t=n.nextPow2(t);var e=n.log2(t),r=a[e];return 0<r.length?r.pop():new ArrayBuffer(t)}function u(t){return new Uint8Array(l(t),0,t)}function c(t){return new Uint16Array(l(2*t),0,t)}function f(t){return new Uint32Array(l(4*t),0,t)}function p(t){return new Int8Array(l(t),0,t)}function d(t){return new Int16Array(l(2*t),0,t)}function m(t){return new Int32Array(l(4*t),0,t)}function v(t){return new Float32Array(l(4*t),0,t)}function g(t){return new Float64Array(l(8*t),0,t)}function y(t){return r?new Uint8ClampedArray(l(t),0,t):u(t)}function x(t){return new DataView(l(t),0,t)}function w(t){t=n.nextPow2(t);var e=n.log2(t),r=s[e];return 0<r.length?r.pop():new i(t)}M.free=function(t){if(i.isBuffer(t))s[n.log2(t.length)].push(t);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(t)&&(t=t.buffer),!t)return;var e=t.length||t.byteLength,r=0|n.log2(e);a[r].push(t)}},M.freeUint8=M.freeUint16=M.freeUint32=M.freeInt8=M.freeInt16=M.freeInt32=M.freeFloat32=M.freeFloat=M.freeFloat64=M.freeDouble=M.freeUint8Clamped=M.freeDataView=function(t){h(t.buffer)},M.freeArrayBuffer=h,M.freeBuffer=function(t){s[n.log2(t.length)].push(t)},M.malloc=function(t,e){if(void 0===e||"arraybuffer"===e)return l(t);switch(e){case"uint8":return u(t);case"uint16":return c(t);case"uint32":return f(t);case"int8":return p(t);case"int16":return d(t);case"int32":return m(t);case"float":case"float32":return v(t);case"double":case"float64":return g(t);case"uint8_clamped":return y(t);case"buffer":return w(t);case"data":case"dataview":return x(t);default:return null}return null},M.mallocArrayBuffer=l,M.mallocUint8=u,M.mallocUint16=c,M.mallocUint32=f,M.mallocInt8=p,M.mallocInt16=d,M.mallocInt32=m,M.mallocFloat32=M.mallocFloat=v,M.mallocFloat64=M.mallocDouble=g,M.mallocUint8Clamped=y,M.mallocDataView=x,M.mallocBuffer=w,M.clearCache=function(){for(var t=0;t<32;++t)o.UINT8[t].length=0,o.UINT16[t].length=0,o.UINT32[t].length=0,o.INT8[t].length=0,o.INT16[t].length=0,o.INT32[t].length=0,o.FLOAT[t].length=0,o.DOUBLE[t].length=0,o.UINT8C[t].length=0,a[t].length=0,s[t].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},b("buffer").Buffer)},{"bit-twiddle":24,buffer:137,dup:42}],127:[function(t,e,r){e.exports=function(t,e,r){t.positions&&t.cells&&(r=e,e=t.cells,t=t.positions);r=r||new Float32Array(9*e.length);for(var i=0,n=0,o=e.length;i<o;i+=1)r[n++]=t[e[i][0]][0],r[n++]=t[e[i][0]][1],r[n++]=t[e[i][0]][2],r[n++]=t[e[i][1]][0],r[n++]=t[e[i][1]][1],r[n++]=t[e[i][1]][2],r[n++]=t[e[i][2]][0],r[n++]=t[e[i][2]][1],r[n++]=t[e[i][2]][2];return r}},{}],128:[function(t,e,r){"use strict";"use restrict";function i(t){this.roots=new Array(t),this.ranks=new Array(t);for(var e=0;e<t;++e)this.roots[e]=e,this.ranks[e]=0}var n=(e.exports=i).prototype;Object.defineProperty(n,"length",{get:function(){return this.roots.length}}),n.makeSet=function(){var t=this.roots.length;return this.roots.push(t),this.ranks.push(0),t},n.find=function(t){for(var e=t,r=this.roots;r[t]!==t;)t=r[t];for(;r[e]!==t;){var i=r[e];r[e]=t,e=i}return t},n.link=function(t,e){var r=this.find(t),i=this.find(e);if(r!==i){var n=this.ranks,o=this.roots,a=n[r],s=n[i];a<s?o[r]=i:s<a?o[i]=r:++n[o[i]=r]}}},{}],129:[function(t,e,r){e.exports=function(t,e,r){return(r-t)/(e-t)}},{}],130:[function(t,e,r){e.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t}},{}],131:[function(t,e,r){var i=t("global/window"),d=t("once"),m=t("parse-headers"),v={0:"Internal XMLHttpRequest Error",4:"4xx Client Error",5:"5xx Server Error"},g=i.XMLHttpRequest||x,y="withCredentials"in new g?g:i.XDomainRequest;function x(){}e.exports=function(t,n){"string"==typeof t&&(t={uri:t});t=t||{},n=d(n);var o=t.xhr||null;o||(o=t.cors||t.useXDR?new y:new g);var e,r=o.url=t.uri||t.url,i=o.method=t.method||"GET",a=t.body||t.data,s=o.headers=t.headers||{},h=!!t.sync,l=!1,u=t.response?function(){var t=f(),e=c(),r=p(t,e),i={body:e,statusCode:t,statusText:o.statusText,raw:o};o.getAllResponseHeaders?i.headers=m(o.getAllResponseHeaders()):i.headers={};n(r,i,i.body)}:function(){var t=f(),e=p(t);o.status=o.statusCode=t,o.body=c(),o.headers=m(o.getAllResponseHeaders()),n(e,o,o.body)};"json"in t&&(l=!0,s.Accept="application/json","GET"!==i&&"HEAD"!==i&&(s["Content-Type"]="application/json",a=JSON.stringify(t.json)));o.onreadystatechange=function(){4===o.readyState&&u()},o.onload=u,o.onerror=function(t){n(t,o)},o.onprogress=function(){},o.ontimeout=x,o.open(i,r,!h),(t.withCredentials||t.cors&&!1!==t.withCredentials)&&(o.withCredentials=!0);h||(o.timeout="timeout"in t?t.timeout:5e3);if(o.setRequestHeader)for(e in s)s.hasOwnProperty(e)&&o.setRequestHeader(e,s[e]);else if(t.headers)throw new Error("Headers cannot be set on an XDomainRequest object");"responseType"in t&&(o.responseType=t.responseType);"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(o);return o.send(a),o;function c(){var t=null;if(o.response?t=o.response:"text"!==o.responseType&&o.responseType||(t=o.responseText||o.responseXML),l)try{t=JSON.parse(t)}catch(t){}return t}function f(){return 1223===o.status?204:o.status}function p(t,e){var r=null;if(0===t||400<=t&&t<600){var i="string"==typeof e&&e||v[String(t).charAt(0)];(r=new Error(i)).statusCode=t}return r}}},{"global/window":78,once:132,"parse-headers":91}],132:[function(t,e,r){function i(t){var e=!1;return function(){if(!e)return e=!0,t.apply(this,arguments)}}(e.exports=i).proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:!0})})},{}],133:[function(t,e,r){e.exports=void 0!==self.DOMParser?function(t){return(new self.DOMParser).parseFromString(t,"application/xml")}:void 0!==self.ActiveXObject&&new self.ActiveXObject("Microsoft.XMLDOM")?function(t){var e=new self.ActiveXObject("Microsoft.XMLDOM");return e.async="false",e.loadXML(t),e}:function(t){var e=document.createElement("div");return e.innerHTML=t,e}},{}],134:[function(t,e,r){e.exports=function(){for(var t={},e=0;e<arguments.length;e++){var r=arguments[e];for(var i in r)n.call(r,i)&&(t[i]=r[i])}return t};var n=Object.prototype.hasOwnProperty},{}],135:[function(t,e,r){"use strict";r.byteLength=function(t){return 3*t.length/4-c(t)},r.toByteArray=function(t){var e,r,i,n,o,a=t.length;n=c(t),o=new u(3*a/4-n),r=0<n?a-4:a;var s=0;for(e=0;e<r;e+=4)i=l[t.charCodeAt(e)]<<18|l[t.charCodeAt(e+1)]<<12|l[t.charCodeAt(e+2)]<<6|l[t.charCodeAt(e+3)],o[s++]=i>>16&255,o[s++]=i>>8&255,o[s++]=255&i;2===n?(i=l[t.charCodeAt(e)]<<2|l[t.charCodeAt(e+1)]>>4,o[s++]=255&i):1===n&&(i=l[t.charCodeAt(e)]<<10|l[t.charCodeAt(e+1)]<<4|l[t.charCodeAt(e+2)]>>2,o[s++]=i>>8&255,o[s++]=255&i);return o},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,n="",o=[],a=0,s=r-i;a<s;a+=16383)o.push(f(t,a,s<a+16383?s:a+16383));1===i?(e=t[r-1],n+=h[e>>2],n+=h[e<<4&63],n+="=="):2===i&&(e=(t[r-2]<<8)+t[r-1],n+=h[e>>10],n+=h[e>>4&63],n+=h[e<<2&63],n+="=");return o.push(n),o.join("")};for(var h=[],l=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,o=i.length;n<o;++n)h[n]=i[n],l[i.charCodeAt(n)]=n;function c(t){var e=t.length;if(0<e%4)throw new Error("Invalid string. Length must be a multiple of 4");return"="===t[e-2]?2:"="===t[e-1]?1:0}function f(t,e,r){for(var i,n,o=[],a=e;a<r;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),o.push(h[(n=i)>>18&63]+h[n>>12&63]+h[n>>6&63]+h[63&n]);return o.join("")}l["-".charCodeAt(0)]=62,l["_".charCodeAt(0)]=63},{}],136:[function(t,e,r){},{}],137:[function(t,e,r){"use strict";var i=t("base64-js"),o=t("ieee754");r.Buffer=c,r.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},r.INSPECT_MAX_BYTES=50;var n=2147483647;function a(t){if(n<t)throw new RangeError("Invalid typed array length");var e=new Uint8Array(t);return e.__proto__=c.prototype,e}function c(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return l(t)}return s(t,e,r)}function s(t,e,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return k(t)||t&&k(t.buffer)?function(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');var i;i=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r);return i.__proto__=c.prototype,i}(t,e,r):"string"==typeof t?function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|p(t,e),i=a(r),n=i.write(t,e);n!==r&&(i=i.slice(0,n));return i}(t,e):function(t){if(c.isBuffer(t)){var e=0|f(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}if(t){if(ArrayBuffer.isView(t)||"length"in t)return"number"!=typeof t.length||z(t.length)?a(0):u(t);if("Buffer"===t.type&&Array.isArray(t.data))return u(t.data)}throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.")}(t)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('"size" argument must not be negative')}function l(t){return h(t),a(t<0?0:0|f(t))}function u(t){for(var e=t.length<0?0:0|f(t.length),r=a(e),i=0;i<e;i+=1)r[i]=255&t[i];return r}function f(t){if(n<=t)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return 0|t}function p(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||k(t))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return U(t).length;default:if(i)return D(t).length;e=(""+e).toLowerCase(),i=!0}}function d(t,e,r){var i=t[e];t[e]=t[r],t[r]=i}function m(t,e,r,i,n){if(0===t.length)return-1;if("string"==typeof r?(i=r,r=0):2147483647<r?r=2147483647:r<-2147483648&&(r=-2147483648),z(r=+r)&&(r=n?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(n)return-1;r=t.length-1}else if(r<0){if(!n)return-1;r=0}if("string"==typeof e&&(e=c.from(e,i)),c.isBuffer(e))return 0===e.length?-1:v(t,e,r,i,n);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?n?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,i,n);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,i,n){var o,a=1,s=t.length,h=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;s/=a=2,h/=2,r/=2}function l(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(n){var u=-1;for(o=r;o<s;o++)if(l(t,o)===l(e,-1===u?0:o-u)){if(-1===u&&(u=o),o-u+1===h)return u*a}else-1!==u&&(o-=o-u),u=-1}else for(s<r+h&&(r=s-h),o=r;0<=o;o--){for(var c=!0,f=0;f<h;f++)if(l(t,o+f)!==l(e,f)){c=!1;break}if(c)return o}return-1}function g(t,e,r,i){r=Number(r)||0;var n=t.length-r;i?n<(i=Number(i))&&(i=n):i=n;var o=e.length;o/2<i&&(i=o/2);for(var a=0;a<i;++a){var s=parseInt(e.substr(2*a,2),16);if(z(s))return a;t[r+a]=s}return a}function y(t,e,r,i){return B(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,i)}function x(t,e,r){return 0===e&&r===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,r))}function w(t,e,r){r=Math.min(t.length,r);for(var i=[],n=e;n<r;){var o,a,s,h,l=t[n],u=null,c=239<l?4:223<l?3:191<l?2:1;if(n+c<=r)switch(c){case 1:l<128&&(u=l);break;case 2:128==(192&(o=t[n+1]))&&127<(h=(31&l)<<6|63&o)&&(u=h);break;case 3:o=t[n+1],a=t[n+2],128==(192&o)&&128==(192&a)&&2047<(h=(15&l)<<12|(63&o)<<6|63&a)&&(h<55296||57343<h)&&(u=h);break;case 4:o=t[n+1],a=t[n+2],s=t[n+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&65535<(h=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)&&h<1114112&&(u=h)}null===u?(u=65533,c=1):65535<u&&(u-=65536,i.push(u>>>10&1023|55296),u=56320|1023&u),i.push(u),n+=c}return function(t){var e=t.length;if(e<=b)return String.fromCharCode.apply(String,t);var r="",i=0;for(;i<e;)r+=String.fromCharCode.apply(String,t.slice(i,i+=b));return r}(i)}r.kMaxLength=n,(c.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()}catch(t){return!1}}())||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(c.prototype,"parent",{get:function(){if(this instanceof c)return this.buffer}}),Object.defineProperty(c.prototype,"offset",{get:function(){if(this instanceof c)return this.byteOffset}}),"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),c.poolSize=8192,c.from=function(t,e,r){return s(t,e,r)},c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,c.alloc=function(t,e,r){return n=e,o=r,h(i=t),i<=0?a(i):void 0!==n?"string"==typeof o?a(i).fill(n,o):a(i).fill(n):a(i);var i,n,o},c.allocUnsafe=function(t){return l(t)},c.allocUnsafeSlow=function(t){return l(t)},c.isBuffer=function(t){return null!=t&&!0===t._isBuffer},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,n=0,o=Math.min(r,i);n<o;++n)if(t[n]!==e[n]){r=t[n],i=e[n];break}return r<i?-1:i<r?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var r;if(void 0===e)for(r=e=0;r<t.length;++r)e+=t[r].length;var i=c.allocUnsafe(e),n=0;for(r=0;r<t.length;++r){var o=t[r];if(ArrayBuffer.isView(o)&&(o=c.from(o)),!c.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(i,n),n+=o.length}return i},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)d(this,e,e+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)d(this,e,e+3),d(this,e+1,e+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},c.prototype.toLocaleString=c.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?w(this,0,t):function(t,e,r){var i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return w(this,e,r);case"ascii":return M(this,e,r);case"latin1":case"binary":return _(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,r);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return 0<this.length&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,r,i,n){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===i&&(i=0),void 0===n&&(n=this.length),e<0||r>t.length||i<0||n>this.length)throw new RangeError("out of range index");if(n<=i&&r<=e)return 0;if(n<=i)return-1;if(r<=e)return 1;if(this===t)return 0;for(var o=(n>>>=0)-(i>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),h=this.slice(i,n),l=t.slice(e,r),u=0;u<s;++u)if(h[u]!==l[u]){o=h[u],a=l[u];break}return o<a?-1:a<o?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return m(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return m(this,t,e,r,!1)},c.prototype.write=function(t,e,r,i){if(void 0===e)i="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)i=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===i&&(i="utf8")):(i=r,r=void 0)}var n=this.length-e;if((void 0===r||n<r)&&(r=n),0<t.length&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var o,a,s,h,l,u,c,f,p,d=!1;;)switch(i){case"hex":return g(this,t,e,r);case"utf8":case"utf-8":return f=e,p=r,B(D(t,(c=this).length-f),c,f,p);case"ascii":return y(this,t,e,r);case"latin1":case"binary":return y(this,t,e,r);case"base64":return h=this,l=e,u=r,B(U(t),h,l,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a=e,s=r,B(function(t,e){for(var r,i,n,o=[],a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),i=r>>8,n=r%256,o.push(n),o.push(i);return o}(t,(o=this).length-a),o,a,s);default:if(d)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var b=4096;function M(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;n<r;++n)i+=String.fromCharCode(127&t[n]);return i}function _(t,e,r){var i="";r=Math.min(t.length,r);for(var n=e;n<r;++n)i+=String.fromCharCode(t[n]);return i}function S(t,e,r){var i=t.length;(!e||e<0)&&(e=0),(!r||r<0||i<r)&&(r=i);for(var n="",o=e;o<r;++o)n+=F(t[o]);return n}function T(t,e,r){for(var i=t.slice(e,r),n="",o=0;o<i.length;o+=2)n+=String.fromCharCode(i[o]+256*i[o+1]);return n}function A(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(r<t+e)throw new RangeError("Trying to access beyond buffer length")}function C(t,e,r,i,n,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(n<e||e<o)throw new RangeError('"value" argument is out of bounds');if(r+i>t.length)throw new RangeError("Index out of range")}function E(t,e,r,i,n,o){if(r+i>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,i,n){return e=+e,r>>>=0,n||E(t,0,r,4),o.write(t,e,r,i,23,4),r+4}function P(t,e,r,i,n){return e=+e,r>>>=0,n||E(t,0,r,8),o.write(t,e,r,i,52,8),r+8}c.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):r<t&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):r<e&&(e=r),e<t&&(e=t);var i=this.subarray(t,e);return i.__proto__=c.prototype,i},c.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||A(t,e,this.length);for(var i=this[t],n=1,o=0;++o<e&&(n*=256);)i+=this[t+o]*n;return i},c.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||A(t,e,this.length);for(var i=this[t+--e],n=1;0<e&&(n*=256);)i+=this[t+--e]*n;return i},c.prototype.readUInt8=function(t,e){return t>>>=0,e||A(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||A(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||A(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||A(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||A(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||A(t,e,this.length);for(var i=this[t],n=1,o=0;++o<e&&(n*=256);)i+=this[t+o]*n;return(n*=128)<=i&&(i-=Math.pow(2,8*e)),i},c.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||A(t,e,this.length);for(var i=e,n=1,o=this[t+--i];0<i&&(n*=256);)o+=this[t+--i]*n;return(n*=128)<=o&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return t>>>=0,e||A(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||A(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){t>>>=0,e||A(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||A(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||A(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return t>>>=0,e||A(t,4,this.length),o.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||A(t,4,this.length),o.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||A(t,8,this.length),o.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||A(t,8,this.length),o.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,i){(t=+t,e>>>=0,r>>>=0,i)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var n=1,o=0;for(this[e]=255&t;++o<r&&(n*=256);)this[e+o]=t/n&255;return e+r},c.prototype.writeUIntBE=function(t,e,r,i){(t=+t,e>>>=0,r>>>=0,i)||C(this,t,e,r,Math.pow(2,8*r)-1,0);var n=r-1,o=1;for(this[e+n]=255&t;0<=--n&&(o*=256);)this[e+n]=t/o&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e>>>=0,!i){var n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}var o=0,a=1,s=0;for(this[e]=255&t;++o<r&&(a*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},c.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e>>>=0,!i){var n=Math.pow(2,8*r-1);C(this,t,e,r,n-1,-n)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;0<=--o&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||C(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return P(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return P(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,i){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),0<i&&i<r&&(i=r),i===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var n=i-r;if(this===t&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(e,r,i);else if(this===t&&r<e&&e<i)for(var o=n-1;0<=o;--o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,i),e);return n},c.prototype.fill=function(t,e,r,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,r=this.length):"string"==typeof r&&(i=r,r=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!c.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){var n=t.charCodeAt(0);("utf8"===i&&n<128||"latin1"===i)&&(t=n)}}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var a=c.isBuffer(t)?t:new c(t,i),s=a.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=a[o%s]}return this};var R=/[^+/0-9A-Za-z-_]/g;function F(t){return t<16?"0"+t.toString(16):t.toString(16)}function D(t,e){var r;e=e||1/0;for(var i=t.length,n=null,o=[],a=0;a<i;++a){if(55295<(r=t.charCodeAt(a))&&r<57344){if(!n){if(56319<r){-1<(e-=3)&&o.push(239,191,189);continue}if(a+1===i){-1<(e-=3)&&o.push(239,191,189);continue}n=r;continue}if(r<56320){-1<(e-=3)&&o.push(239,191,189),n=r;continue}r=65536+(n-55296<<10|r-56320)}else n&&-1<(e-=3)&&o.push(239,191,189);if(n=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function U(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function B(t,e,r,i){for(var n=0;n<i&&!(n+r>=e.length||n>=t.length);++n)e[n+r]=t[n];return n}function k(t){return t instanceof ArrayBuffer||null!=t&&null!=t.constructor&&"ArrayBuffer"===t.constructor.name&&"number"==typeof t.byteLength}function z(t){return t!=t}},{"base64-js":135,ieee754:139}],138:[function(t,e,r){var h=Object.create||function(t){var e=function(){};return e.prototype=t,new e},a=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},o=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function i(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=h(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}((e.exports=i).EventEmitter=i).prototype._events=void 0,i.prototype._maxListeners=void 0;var n,s=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),n=0===l.x}catch(t){n=!1}function u(t){return void 0===t._maxListeners?i.defaultMaxListeners:t._maxListeners}function c(t,e,r,i){var n,o,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),a=o[e]):(o=t._events=h(null),t._eventsCount=0),a){if("function"==typeof a?a=o[e]=i?[r,a]:[a,r]:i?a.unshift(r):a.push(r),!a.warned&&(n=u(t))&&0<n&&a.length>n){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}}else a=o[e]=r,++t._eventsCount;return t}function f(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e<t.length;++e)t[e]=arguments[e];this.listener.apply(this.target,t)}}function p(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=o.call(f,i);return n.listener=r,i.wrapFn=n}function d(t){var e=this._events;if(e){var r=e[t];if("function"==typeof r)return 1;if(r)return r.length}return 0}function m(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}n?Object.defineProperty(i,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||t!=t)throw new TypeError('"defaultMaxListeners" must be a positive number');s=t}}):i.defaultMaxListeners=s,i.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},i.prototype.getMaxListeners=function(){return u(this)},i.prototype.emit=function(t){var e,r,i,n,o,a,s="error"===t;if(a=this._events)s=s&&null==a.error;else if(!s)return!1;if(s){if(1<arguments.length&&(e=arguments[1]),e instanceof Error)throw e;var h=new Error('Unhandled "error" event. ('+e+")");throw h.context=e,h}if(!(r=a[t]))return!1;var l="function"==typeof r;switch(i=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var i=t.length,n=m(t,i),o=0;o<i;++o)n[o].call(r)}(r,l,this);break;case 2:!function(t,e,r,i){if(e)t.call(r,i);else for(var n=t.length,o=m(t,n),a=0;a<n;++a)o[a].call(r,i)}(r,l,this,arguments[1]);break;case 3:!function(t,e,r,i,n){if(e)t.call(r,i,n);else for(var o=t.length,a=m(t,o),s=0;s<o;++s)a[s].call(r,i,n)}(r,l,this,arguments[1],arguments[2]);break;case 4:!function(t,e,r,i,n,o){if(e)t.call(r,i,n,o);else for(var a=t.length,s=m(t,a),h=0;h<a;++h)s[h].call(r,i,n,o)}(r,l,this,arguments[1],arguments[2],arguments[3]);break;default:for(n=new Array(i-1),o=1;o<i;o++)n[o-1]=arguments[o];!function(t,e,r,i){if(e)t.apply(r,i);else for(var n=t.length,o=m(t,n),a=0;a<n;++a)o[a].apply(r,i)}(r,l,this,n)}return!0},i.prototype.on=i.prototype.addListener=function(t,e){return c(this,t,e,!1)},i.prototype.prependListener=function(t,e){return c(this,t,e,!0)},i.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,p(this,t,e)),this},i.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,p(this,t,e)),this},i.prototype.removeListener=function(t,e){var r,i,n,o,a;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(i=this._events))return this;if(!(r=i[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=h(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(n=-1,o=r.length-1;0<=o;o--)if(r[o]===e||r[o].listener===e){a=r[o].listener,n=o;break}if(n<0)return this;0===n?r.shift():function(t,e){for(var r=e,i=r+1,n=t.length;i<n;r+=1,i+=1)t[r]=t[i];t.pop()}(r,n),1===r.length&&(i[t]=r[0]),i.removeListener&&this.emit("removeListener",t,a||e)}return this},i.prototype.removeAllListeners=function(t){var e,r,i;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=h(null),this._eventsCount=0):r[t]&&(0==--this._eventsCount?this._events=h(null):delete r[t]),this;if(0===arguments.length){var n,o=a(r);for(i=0;i<o.length;++i)"removeListener"!==(n=o[i])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=h(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(e)for(i=e.length-1;0<=i;i--)this.removeListener(t,e[i]);return this},i.prototype.listeners=function(t){var e,r=this._events;return r&&(e=r[t])?"function"==typeof e?[e.listener||e]:function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(e):[]},i.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},i.prototype.listenerCount=d,i.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}],139:[function(t,e,r){r.read=function(t,e,r,i,n){var o,a,s=8*n-i-1,h=(1<<s)-1,l=h>>1,u=-7,c=r?n-1:0,f=r?-1:1,p=t[e+c];for(c+=f,o=p&(1<<-u)-1,p>>=-u,u+=s;0<u;o=256*o+t[e+c],c+=f,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=i;0<u;a=256*a+t[e+c],c+=f,u-=8);if(0===o)o=1-l;else{if(o===h)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,i),o-=l}return(p?-1:1)*a*Math.pow(2,o-i)},r.write=function(t,e,r,i,n,o){var a,s,h,l=8*o-n-1,u=(1<<l)-1,c=u>>1,f=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:o-1,d=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-a))<1&&(a--,h*=2),2<=(e+=1<=a+c?f/h:f*Math.pow(2,1-c))*h&&(a++,h/=2),u<=a+c?(s=0,a=u):1<=a+c?(s=(e*h-1)*Math.pow(2,n),a+=c):(s=e*Math.pow(2,c-1)*Math.pow(2,n),a=0));8<=n;t[r+p]=255&s,p+=d,s/=256,n-=8);for(a=a<<n|s,l+=n;0<l;t[r+p]=255&a,p+=d,a/=256,l-=8);t[r+p-d]|=128*m}},{}],140:[function(t,e,r){var i,n,o=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function h(e){if(i===setTimeout)return setTimeout(e,0);if((i===a||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:a}catch(t){i=a}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(t){n=s}}();var l,u=[],c=!1,f=-1;function p(){c&&l&&(c=!1,l.length?u=l.concat(u):f=-1,u.length&&d())}function d(){if(!c){var t=h(p);c=!0;for(var e=u.length;e;){for(l=u,u=[];++f<e;)l&&l[f].run();f=-1,e=u.length}l=null,c=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===s||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(t)}}function m(t,e){this.fun=t,this.array=e}function v(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(1<arguments.length)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new m(t,e)),1!==u.length||c||h(d)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=v,o.addListener=v,o.once=v,o.off=v,o.removeListener=v,o.removeAllListeners=v,o.emit=v,o.prependListener=v,o.prependOnceListener=v,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}]},{},[1]);