// threejs.org/license 'use strict';var three={revision:"71"};"object"===typeof module&&(module.exports=three);void 0===math.sign&&(math.sign=function(a){return 0>a?-1:0>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setrgb:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},sethsl:function(a,b,c){if(0===b)this.r=this.g=this.b=c;else{var d=function(a,b,c){0>c&&(c+=1);1c?b:c<2/3?a+6*(b-a)*(2/3-c):a};b=.5>=c?c*(1+b):c+b-c*b;c=2*c-b;this.r=d(c,b,a+1/3);this.g=d(c,b,a);this.b=d(c,b,a-1/3)}return this},setstyle:function(a){if(/^rgb\((\d+), ?(\d+), ?(\d+)\)$/i.test(a))return a=/^rgb\((\d+), ?(\d+), ?(\d+)\)$/i.exec(a),this.r=math.min(255,parseint(a[1],10))/255,this.g=math.min(255,parseint(a[2],10))/255,this.b=math.min(255,parseint(a[3],10))/255,this;if(/^rgb\((\d+)\%, ?(\d+)\%, ?(\d+)\%\)$/i.test(a))return a=/^rgb\((\d+)\%, ?(\d+)\%, ?(\d+)\%\)$/i.exec(a),this.r= math.min(100,parseint(a[1],10))/100,this.g=math.min(100,parseint(a[2],10))/100,this.b=math.min(100,parseint(a[3],10))/100,this;if(/^\#([0-9a-f]{6})$/i.test(a))return a=/^\#([0-9a-f]{6})$/i.exec(a),this.sethex(parseint(a[1],16)),this;if(/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.test(a))return a=/^\#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(a),this.sethex(parseint(a[1]+a[1]+a[2]+a[2]+a[3]+a[3],16)),this;if(/^(\w+)$/i.test(a))return this.sethex(three.colorkeywords[a]),this},copy:function(a){this.r=a.r;this.g= a.g;this.b=a.b;return this},copygammatolinear:function(a,b){void 0===b&&(b=2);this.r=math.pow(a.r,b);this.g=math.pow(a.g,b);this.b=math.pow(a.b,b);return this},copylineartogamma:function(a,b){void 0===b&&(b=2);var c=0=h?k/(e+f):k/(2-e-f);switch(e){case b:g=(c-d)/k+(cf&&c>b?(c=2*math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y= .25*c,this._z=(g+k)/c):(c=2*math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c);this.onchangecallback();return this},setfromunitvectors:function(){var a,b;return function(c,d){void 0===a&&(a=new three.vector3);b=c.dot(d)+1;1e-6>b?(b=0,math.abs(c.x)>math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossvectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;this.normalize();return this}}(),inverse:function(){this.conjugate().normalize();return this},conjugate:function(){this._x*= -1;this._y*=-1;this._z*=-1;this.onchangecallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._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 a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onchangecallback();return this}, multiply:function(a,b){return void 0!==b?(three.warn("three.quaternion: .multiply() now only accepts one argument. use .multiplyquaternions( a, b ) instead."),this.multiplyquaternions(a,b)):this.multiplyquaternions(this,a)},multiplyquaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f=a._w,g=b._x,h=b._y,k=b._z,l=b._w;this._x=c*l+f*g+d*k-e*h;this._y=d*l+f*h+e*g-c*k;this._z=e*l+f*k+c*h-d*g;this._w=f*l-c*g-d*h-e*k;this.onchangecallback();return this},multiplyvector3:function(a){three.warn("three.quaternion: .multiplyvector3() has been removed. use is now vector.applyquaternion( quaternion ) instead."); return a.applyquaternion(this)},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=math.acos(g),k=math.sqrt(1-g*g);if(.001>math.abs(k))return this._w=.5*(f+this._w),this._x=.5*(c+this._x),this._y=.5*(d+this._y),this._z=.5*(e+this._z),this;g=math.sin((1-b)*h)/k;h= math.sin(b*h)/k;this._w=f*g+this._w*h;this._x=c*g+this._x*h;this._y=d*g+this._y*h;this._z=e*g+this._z*h;this.onchangecallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromarray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onchangecallback();return this},toarray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onchange:function(a){this.onchangecallback= a;return this},onchangecallback:function(){},clone:function(){return new three.quaternion(this._x,this._y,this._z,this._w)}};three.quaternion.slerp=function(a,b,c,d){return c.copy(a).slerp(b,d)};three.vector2=function(a,b){this.x=a||0;this.y=b||0}; three.vector2.prototype={constructor:three.vector2,set:function(a,b){this.x=a;this.y=b;return this},setx:function(a){this.x=a;return this},sety:function(a){this.y=a;return this},setcomponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw error("index is out of range: "+a);}},getcomponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw error("index is out of range: "+a);}},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a, b){if(void 0!==b)return three.warn("three.vector2: .add() now only accepts one argument. use .addvectors( a, b ) instead."),this.addvectors(a,b);this.x+=a.x;this.y+=a.y;return this},addscalar:function(a){this.x+=a;this.y+=a;return this},addvectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},sub:function(a,b){if(void 0!==b)return three.warn("three.vector2: .sub() now only accepts one argument. use .subvectors( a, b ) instead."),this.subvectors(a,b);this.x-=a.x;this.y-=a.y;return this}, subscalar:function(a){this.x-=a;this.y-=a;return this},subvectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyscalar:function(a){this.x*=a;this.y*=a;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},dividescalar:function(a){0!==a?(a=1/a,this.x*=a,this.y*=a):this.y=this.x=0;return this},min:function(a){this.x>a.x&&(this.x=a.x);this.y>a.y&&(this.y=a.y);return this},max:function(a){this.xb.x&&(this.x=b.x);this.yb.y&&(this.y=b.y);return this},clampscalar:function(){var a,b;return function(c,d){void 0===a&&(a=new three.vector2,b=new three.vector2);a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),floor:function(){this.x=math.floor(this.x);this.y=math.floor(this.y);return this},ceil:function(){this.x=math.ceil(this.x);this.y=math.ceil(this.y);return this},round:function(){this.x= math.round(this.x);this.y=math.round(this.y);return this},roundtozero:function(){this.x=0>this.x?math.ceil(this.x):math.floor(this.x);this.y=0>this.y?math.ceil(this.y):math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.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(a){return math.sqrt(this.distancetosquared(a))}, distancetosquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},setlength:function(a){var b=this.length();0!==b&&a!==b&&this.multiplyscalar(a/b);return this},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpvectors:function(a,b,c){this.subvectors(b,a).multiplyscalar(c).add(a);return this},equals:function(a){return a.x===this.x&&a.y===this.y},fromarray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toarray:function(a,b){void 0=== a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromattribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemsize+c;this.x=a.array[b];this.y=a.array[b+1];return this},clone:function(){return new three.vector2(this.x,this.y)}};three.vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}; three.vector3.prototype={constructor:three.vector3,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setx:function(a){this.x=a;return this},sety:function(a){this.y=a;return this},setz:function(a){this.z=a;return this},setcomponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw error("index is out of range: "+a);}},getcomponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw error("index is out of range: "+ a);}},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return three.warn("three.vector3: .add() now only accepts one argument. use .addvectors( a, b ) instead."),this.addvectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addscalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addvectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},sub:function(a,b){if(void 0!==b)return three.warn("three.vector3: .sub() now only accepts one argument. use .subvectors( a, b ) instead."), this.subvectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subscalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subvectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return three.warn("three.vector3: .multiply() now only accepts one argument. use .multiplyvectors( a, b ) instead."),this.multiplyvectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyscalar:function(a){this.x*=a;this.y*=a;this.z*= a;return this},multiplyvectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyeuler:function(){var a;return function(b){!1===b instanceof three.euler&&three.error("three.vector3: .applyeuler() now expects a euler rotation rather than a vector3 and order.");void 0===a&&(a=new three.quaternion);this.applyquaternion(a.setfromeuler(b));return this}}(),applyaxisangle:function(){var a;return function(b,c){void 0===a&&(a=new three.quaternion);this.applyquaternion(a.setfromaxisangle(b, c));return this}}(),applymatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applymatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12];this.y=a[1]*b+a[5]*c+a[9]*d+a[13];this.z=a[2]*b+a[6]*c+a[10]*d+a[14];return this},applyprojection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]* c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyquaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,l=a*d+e*c-f*b,b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-l*-f;this.y=k*a+b*-f+l*-e-h*-g;this.z=l*a+b*-g+h*-f-k*-e;return this},project:function(){var a;return function(b){void 0===a&&(a=new three.matrix4);a.multiplymatrices(b.projectionmatrix,a.getinverse(b.matrixworld));return this.applyprojection(a)}}(), unproject:function(){var a;return function(b){void 0===a&&(a=new three.matrix4);a.multiplymatrices(b.matrixworld,a.getinverse(b.projectionmatrix));return this.applyprojection(a)}}(),transformdirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;this.normalize();return this},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},dividescalar:function(a){0!==a?(a=1/a,this.x*=a,this.y*=a,this.z*= a):this.z=this.y=this.x=0;return this},min:function(a){this.x>a.x&&(this.x=a.x);this.y>a.y&&(this.y=a.y);this.z>a.z&&(this.z=a.z);return this},max:function(a){this.xb.x&&(this.x=b.x);this.yb.y&&(this.y=b.y);this.zb.z&&(this.z=b.z);return this},clampscalar:function(){var a,b;return function(c,d){void 0===a&&(a=new three.vector3, b=new three.vector3);a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=math.floor(this.x);this.y=math.floor(this.y);this.z=math.floor(this.z);return this},ceil:function(){this.x=math.ceil(this.x);this.y=math.ceil(this.y);this.z=math.ceil(this.z);return this},round:function(){this.x=math.round(this.x);this.y=math.round(this.y);this.z=math.round(this.z);return this},roundtozero:function(){this.x=0>this.x?math.ceil(this.x):math.floor(this.x);this.y=0>this.y?math.ceil(this.y): math.floor(this.y);this.z=0>this.z?math.ceil(this.z):math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.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(a){var b=this.length();0!==b&&a!==b&&this.multiplyscalar(a/b);return this},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpvectors:function(a,b,c){this.subvectors(b,a).multiplyscalar(c).add(a);return this},cross:function(a,b){if(void 0!==b)return three.warn("three.vector3: .cross() now only accepts one argument. use .crossvectors( a, b ) instead."),this.crossvectors(a,b);var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y= e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},crossvectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g;this.y=e*f-c*h;this.z=c*g-d*f;return this},projectonvector:function(){var a,b;return function(c){void 0===a&&(a=new three.vector3);a.copy(c).normalize();b=this.dot(a);return this.copy(a).multiplyscalar(b)}}(),projectonplane:function(){var a;return function(b){void 0===a&&(a=new three.vector3);a.copy(this).projectonvector(b);return this.sub(a)}}(),reflect:function(){var a;return function(b){void 0=== a&&(a=new three.vector3);return this.sub(a.copy(b).multiplyscalar(2*this.dot(b)))}}(),angleto:function(a){a=this.dot(a)/(this.length()*a.length());return math.acos(three.math.clamp(a,-1,1))},distanceto:function(a){return math.sqrt(this.distancetosquared(a))},distancetosquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},seteulerfromrotationmatrix:function(a,b){three.error("three.vector3: .seteulerfromrotationmatrix() has been removed. use euler.setfromrotationmatrix() instead.")}, seteulerfromquaternion:function(a,b){three.error("three.vector3: .seteulerfromquaternion() has been removed. use euler.setfromquaternion() instead.")},getpositionfrommatrix:function(a){three.warn("three.vector3: .getpositionfrommatrix() has been renamed to .setfrommatrixposition().");return this.setfrommatrixposition(a)},getscalefrommatrix:function(a){three.warn("three.vector3: .getscalefrommatrix() has been renamed to .setfrommatrixscale().");return this.setfrommatrixscale(a)},getcolumnfrommatrix:function(a, b){three.warn("three.vector3: .getcolumnfrommatrix() has been renamed to .setfrommatrixcolumn().");return this.setfrommatrixcolumn(a,b)},setfrommatrixposition:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setfrommatrixscale:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length();a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x=b;this.y=c;this.z=a; return this},setfrommatrixcolumn:function(a,b){var c=4*a,d=b.elements;this.x=d[c];this.y=d[c+1];this.z=d[c+2];return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromarray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toarray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromattribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemsize+c;this.x=a.array[b];this.y=a.array[b+1];this.z= a.array[b+2];return this},clone:function(){return new three.vector3(this.x,this.y,this.z)}};three.vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}; three.vector4.prototype={constructor:three.vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setx:function(a){this.x=a;return this},sety:function(a){this.y=a;return this},setz:function(a){this.z=a;return this},setw:function(a){this.w=a;return this},setcomponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw error("index is out of range: "+a);}},getcomponent:function(a){switch(a){case 0:return this.x; case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw error("index is out of range: "+a);}},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return three.warn("three.vector4: .add() now only accepts one argument. use .addvectors( a, b ) instead."),this.addvectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addscalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addvectors:function(a, b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},sub:function(a,b){if(void 0!==b)return three.warn("three.vector4: .sub() now only accepts one argument. use .subvectors( a, b ) instead."),this.subvectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subscalar:function(a){this.x-=a;this.y-=a;this.z-=a;this.w-=a;return this},subvectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyscalar:function(a){this.x*= a;this.y*=a;this.z*=a;this.w*=a;return this},applymatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},dividescalar:function(a){0!==a?(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a):(this.z=this.y=this.x=0,this.w=1);return this},setaxisanglefromquaternion:function(a){this.w=2*math.acos(a.w);var b=math.sqrt(1-a.w*a.w);1e-4> b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setaxisanglefromrotationmatrix:function(a){var b,c,d;a=a.elements;var e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],k=a[9];c=a[2];b=a[6];var l=a[10];if(.01>math.abs(d-g)&&.01>math.abs(f-c)&&.01>math.abs(k-b)){if(.1>math.abs(d+g)&&.1>math.abs(f+c)&&.1>math.abs(k+b)&&.1>math.abs(e+h+l-3))return this.set(1,0,0,0),this;a=math.pi;e=(e+1)/2;h=(h+1)/2;l=(l+1)/2;d=(d+g)/4;f=(f+c)/4;k=(k+b)/4;e>h&&e>l?.01>e?(b=0,d=c=.707106781):(b= math.sqrt(e),c=d/b,d=f/b):h>l?.01>h?(b=.707106781,c=0,d=.707106781):(c=math.sqrt(h),b=d/c,d=k/c):.01>l?(c=b=.707106781,d=0):(d=math.sqrt(l),b=f/d,c=k/d);this.set(b,c,d,a);return this}a=math.sqrt((b-k)*(b-k)+(f-c)*(f-c)+(g-d)*(g-d));.001>math.abs(a)&&(a=1);this.x=(b-k)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=math.acos((e+h+l-1)/2);return this},min:function(a){this.x>a.x&&(this.x=a.x);this.y>a.y&&(this.y=a.y);this.z>a.z&&(this.z=a.z);this.w>a.w&&(this.w=a.w);return this},max:function(a){this.xb.x&&(this.x=b.x);this.yb.y&&(this.y=b.y);this.zb.z&&(this.z=b.z);this.wb.w&&(this.w=b.w);return this},clampscalar:function(){var a,b;return function(c,d){void 0===a&&(a=new three.vector4,b=new three.vector4);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x= math.floor(this.x);this.y=math.floor(this.y);this.z=math.floor(this.z);this.w=math.floor(this.w);return this},ceil:function(){this.x=math.ceil(this.x);this.y=math.ceil(this.y);this.z=math.ceil(this.z);this.w=math.ceil(this.w);return this},round:function(){this.x=math.round(this.x);this.y=math.round(this.y);this.z=math.round(this.z);this.w=math.round(this.w);return this},roundtozero:function(){this.x=0>this.x?math.ceil(this.x):math.floor(this.x);this.y=0>this.y?math.ceil(this.y):math.floor(this.y); this.z=0>this.z?math.ceil(this.z):math.floor(this.z);this.w=0>this.w?math.ceil(this.w):math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.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(a){var b=this.length();0!==b&&a!==b&&this.multiplyscalar(a/b);return this},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpvectors:function(a,b,c){this.subvectors(b,a).multiplyscalar(c).add(a);return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w}, fromarray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toarray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromattribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemsize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];this.w=a.array[b+3];return this},clone:function(){return new three.vector4(this.x,this.y,this.z,this.w)}}; three.euler=function(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||three.euler.defaultorder};three.euler.rotationorders="xyz yzx zxy xzy yxz zyx".split(" ");three.euler.defaultorder="xyz"; three.euler.prototype={constructor:three.euler,_x:0,_y:0,_z:0,_order:three.euler.defaultorder,get x(){return this._x},set x(a){this._x=a;this.onchangecallback()},get y(){return this._y},set y(a){this._y=a;this.onchangecallback()},get z(){return this._z},set z(a){this._z=a;this.onchangecallback()},get order(){return this._order},set order(a){this._order=a;this.onchangecallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this.onchangecallback();return this},copy:function(a){this._x= a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onchangecallback();return this},setfromrotationmatrix:function(a,b,c){var d=three.math.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],k=e[5],l=e[9],p=e[2],q=e[6],e=e[10];b=b||this._order;"xyz"===b?(this._y=math.asin(d(g,-1,1)),.99999>math.abs(g)?(this._x=math.atan2(-l,e),this._z=math.atan2(-f,a)):(this._x=math.atan2(q,k),this._z=0)):"yxz"===b?(this._x=math.asin(-d(l,-1,1)),.99999>math.abs(l)?(this._y=math.atan2(g,e),this._z=math.atan2(h, k)):(this._y=math.atan2(-p,a),this._z=0)):"zxy"===b?(this._x=math.asin(d(q,-1,1)),.99999>math.abs(q)?(this._y=math.atan2(-p,e),this._z=math.atan2(-f,k)):(this._y=0,this._z=math.atan2(h,a))):"zyx"===b?(this._y=math.asin(-d(p,-1,1)),.99999>math.abs(p)?(this._x=math.atan2(q,e),this._z=math.atan2(h,a)):(this._x=0,this._z=math.atan2(-f,k))):"yzx"===b?(this._z=math.asin(d(h,-1,1)),.99999>math.abs(h)?(this._x=math.atan2(-l,k),this._y=math.atan2(-p,a)):(this._x=0,this._y=math.atan2(g,e))):"xzy"===b?(this._z= math.asin(-d(f,-1,1)),.99999>math.abs(f)?(this._x=math.atan2(q,k),this._y=math.atan2(g,a)):(this._x=math.atan2(-l,e),this._y=0)):three.warn("three.euler: .setfromrotationmatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onchangecallback();return this},setfromquaternion:function(){var a;return function(b,c,d){void 0===a&&(a=new three.matrix4);a.makerotationfromquaternion(b);this.setfromrotationmatrix(a,c,d);return this}}(),setfromvector3:function(a,b){return this.set(a.x,a.y,a.z, b||this._order)},reorder:function(){var a=new three.quaternion;return function(b){a.setfromeuler(this);this.setfromquaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromarray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onchangecallback();return this},toarray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},tovector3:function(a){return a? a.set(this._x,this._y,this._z):new three.vector3(this._x,this._y,this._z)},onchange:function(a){this.onchangecallback=a;return this},onchangecallback:function(){},clone:function(){return new three.euler(this._x,this._y,this._z,this._order)}};three.line3=function(a,b){this.start=void 0!==a?a:new three.vector3;this.end=void 0!==b?b:new three.vector3}; three.line3.prototype={constructor:three.line3,set:function(a,b){this.start.copy(a);this.end.copy(b);return this},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},center:function(a){return(a||new three.vector3).addvectors(this.start,this.end).multiplyscalar(.5)},delta:function(a){return(a||new three.vector3).subvectors(this.end,this.start)},distancesq:function(){return this.start.distancetosquared(this.end)},distance:function(){return this.start.distanceto(this.end)},at:function(a, b){var c=b||new three.vector3;return this.delta(c).multiplyscalar(a).add(this.start)},closestpointtopointparameter:function(){var a=new three.vector3,b=new three.vector3;return function(c,d){a.subvectors(c,this.start);b.subvectors(this.end,this.start);var e=b.dot(b),e=b.dot(a)/e;d&&(e=three.math.clamp(e,0,1));return e}}(),closestpointtopoint:function(a,b,c){a=this.closestpointtopointparameter(a,b);c=c||new three.vector3;return this.delta(c).multiplyscalar(a).add(this.start)},applymatrix4:function(a){this.start.applymatrix4(a); this.end.applymatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)},clone:function(){return(new three.line3).copy(this)}};three.box2=function(a,b){this.min=void 0!==a?a:new three.vector2(infinity,infinity);this.max=void 0!==b?b:new three.vector2(-infinity,-infinity)}; three.box2.prototype={constructor:three.box2,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setfrompoints:function(a){this.makeempty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y?!1:!0},containsbox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y?!0:!1},getparameter:function(a,b){return(b||new three.vector2).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},isintersectionbox:function(a){return a.max.xthis.max.x||a.max.y this.max.y?!1:!0},clamppoint:function(a,b){return(b||new three.vector2).copy(a).clamp(this.min,this.max)},distancetopoint:function(){var a=new three.vector2;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&& a.max.equals(this.max)},clone:function(){return(new three.box2).copy(this)}};three.box3=function(a,b){this.min=void 0!==a?a:new three.vector3(infinity,infinity,infinity);this.max=void 0!==b?b:new three.vector3(-infinity,-infinity,-infinity)}; three.box3.prototype={constructor:three.box3,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setfrompoints:function(a){this.makeempty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y||a.zthis.max.z?!1:!0},containsbox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z?!0:!1},getparameter:function(a,b){return(b||new three.vector3).set((a.x-this.min.x)/(this.max.x- this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},isintersectionbox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y||a.max.zthis.max.z?!1:!0},clamppoint:function(a,b){return(b||new three.vector3).copy(a).clamp(this.min,this.max)},distancetopoint:function(){var a=new three.vector3;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getboundingsphere:function(){var a= new three.vector3;return function(b){b=b||new three.sphere;b.center=this.center();b.radius=.5*this.size(a).length();return b}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applymatrix4:function(){var a=[new three.vector3,new three.vector3,new three.vector3,new three.vector3,new three.vector3,new three.vector3,new three.vector3,new three.vector3];return function(b){a[0].set(this.min.x,this.min.y, this.min.z).applymatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applymatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applymatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applymatrix4(b);a[4].set(this.max.x,this.min.y,this.min.z).applymatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applymatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applymatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applymatrix4(b);this.makeempty();this.setfrompoints(a);return this}}(),translate:function(a){this.min.add(a); this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)},clone:function(){return(new three.box3).copy(this)}};three.matrix3=function(){this.elements=new float32array([1,0,0,0,1,0,0,0,1]);0this.determinant()&&(g=-g);c.x=f[12]; c.y=f[13];c.z=f[14];b.elements.set(this.elements);c=1/g;var f=1/h,l=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=l;b.elements[9]*=l;b.elements[10]*=l;d.setfromrotationmatrix(b);e.x=g;e.y=h;e.z=k;return this}}(),makefrustum:function(a,b,c,d,e,f){var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(d-c);g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0; g[11]=-1;g[15]=0;return this},makeperspective:function(a,b,c,d){a=c*math.tan(three.math.degtorad(.5*a));var e=-a;return this.makefrustum(e*b,a*b,e,a,c,d)},makeorthographic:function(a,b,c,d,e,f){var g=this.elements,h=b-a,k=c-d,l=f-e;g[0]=2/h;g[4]=0;g[8]=0;g[12]=-((b+a)/h);g[1]=0;g[5]=2/k;g[9]=0;g[13]=-((c+d)/k);g[2]=0;g[6]=0;g[10]=-2/l;g[14]=-((f+e)/l);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},fromarray:function(a){this.elements.set(a);return this},toarray:function(){var a=this.elements;return[a[0], a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]]},clone:function(){return(new three.matrix4).fromarray(this.elements)}};three.ray=function(a,b){this.origin=void 0!==a?a:new three.vector3;this.direction=void 0!==b?b:new three.vector3}; three.ray.prototype={constructor:three.ray,set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,b){return(b||new three.vector3).copy(this.direction).multiplyscalar(a).add(this.origin)},recast:function(){var a=new three.vector3;return function(b){this.origin.copy(this.at(b,a));return this}}(),closestpointtopoint:function(a,b){var c=b||new three.vector3;c.subvectors(a,this.origin); var d=c.dot(this.direction);return 0>d?c.copy(this.origin):c.copy(this.direction).multiplyscalar(d).add(this.origin)},distancetopoint:function(){var a=new three.vector3;return function(b){var c=a.subvectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceto(b);a.copy(this.direction).multiplyscalar(c).add(this.origin);return a.distanceto(b)}}(),distancesqtosegment:function(){var a=new three.vector3,b=new three.vector3,c=new three.vector3;return function(d,e,f,g){a.copy(d).add(e).multiplyscalar(.5); b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceto(e),k=-this.direction.dot(b),l=c.dot(this.direction),p=-c.dot(b),q=c.lengthsq(),n=math.abs(1-k*k),t;0=-t?e<=t?(h=1/n,d*=h,e*=h,k=d*(d+k*e+2*l)+e*(k*d+e+2*p)+q):(e=h,d=math.max(0,-(k*e+l)),k=-d*d+e*(e+2*p)+q):(e=-h,d=math.max(0,-(k*e+l)),k=-d*d+e*(e+2*p)+q):e<=-t?(d=math.max(0,-(-k*h+l)),e=0f)return null;f=math.sqrt(f-e);e=d-f;d+=f;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),isintersectionplane:function(a){var b=a.distancetopoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},distancetoplane:function(a){var b=a.normal.dot(this.direction);if(0==b)return 0==a.distancetopoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectplane:function(a,b){var c=this.distancetoplane(a);return null===c?null:this.at(c,b)}, isintersectionbox:function(){var a=new three.vector3;return function(b){return null!==this.intersectbox(b,a)}}(),intersectbox:function(a,b){var c,d,e,f,g;d=1/this.direction.x;f=1/this.direction.y;g=1/this.direction.z;var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=f?(e=(a.min.y-h.y)*f,f*=a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e;if(fg||e>d)return null;if(e>c||c!==c)c=e;if(gd?null:this.at(0<=c?c:d,b)},intersecttriangle:function(){var a=new three.vector3,b=new three.vector3,c=new three.vector3,d=new three.vector3;return function(e,f,g,h,k){b.subvectors(f,e);c.subvectors(g,e);d.crossvectors(b,c);f=this.direction.dot(d);if(0f)h=-1,f=-f;else return null;a.subvectors(this.origin,e);e=h*this.direction.dot(c.crossvectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a)); if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applymatrix4:function(a){this.direction.add(this.origin).applymatrix4(a);this.origin.applymatrix4(a);this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)},clone:function(){return(new three.ray).copy(this)}};three.sphere=function(a,b){this.center=void 0!==a?a:new three.vector3;this.radius=void 0!==b?b:0}; three.sphere.prototype={constructor:three.sphere,set:function(a,b){this.center.copy(a);this.radius=b;return this},setfrompoints:function(){var a=new three.box3;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setfrompoints(b).center(d);for(var e=0,f=0,g=b.length;f=this.radius},containspoint:function(a){return a.distancetosquared(this.center)<= this.radius*this.radius},distancetopoint:function(a){return a.distanceto(this.center)-this.radius},intersectssphere:function(a){var b=this.radius+a.radius;return a.center.distancetosquared(this.center)<=b*b},clamppoint:function(a,b){var c=this.center.distancetosquared(a),d=b||new three.vector3;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyscalar(this.radius).add(this.center));return d},getboundingbox:function(a){a=a||new three.box3;a.set(this.center,this.center);a.expandbyscalar(this.radius); return a},applymatrix4:function(a){this.center.applymatrix4(a);this.radius*=a.getmaxscaleonaxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius},clone:function(){return(new three.sphere).copy(this)}}; three.frustum=function(a,b,c,d,e,f){this.planes=[void 0!==a?a:new three.plane,void 0!==b?b:new three.plane,void 0!==c?c:new three.plane,void 0!==d?d:new three.plane,void 0!==e?e:new three.plane,void 0!==f?f:new three.plane]}; three.frustum.prototype={constructor:three.frustum,set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f);return this},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setfrommatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],l=c[7],p=c[8],q=c[9],n=c[10],t=c[11],r=c[12],s=c[13],u=c[14],c=c[15];b[0].setcomponents(f-a,l-g,t-p,c-r).normalize();b[1].setcomponents(f+ a,l+g,t+p,c+r).normalize();b[2].setcomponents(f+d,l+h,t+q,c+s).normalize();b[3].setcomponents(f-d,l-h,t-q,c-s).normalize();b[4].setcomponents(f-e,l-k,t-n,c-u).normalize();b[5].setcomponents(f+e,l+k,t+n,c+u).normalize();return this},intersectsobject:function(){var a=new three.sphere;return function(b){var c=b.geometry;null===c.boundingsphere&&c.computeboundingsphere();a.copy(c.boundingsphere);a.applymatrix4(b.matrixworld);return this.intersectssphere(a)}}(),intersectssphere:function(a){var b=this.planes, c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distancetopoint(c)e;e++){var f=d[e];a.x=0g&&0>f)return!1}return!0}}(), containspoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distancetopoint(a))return!1;return!0},clone:function(){return(new three.frustum).copy(this)}};three.plane=function(a,b){this.normal=void 0!==a?a:new three.vector3(1,0,0);this.constant=void 0!==b?b:0}; three.plane.prototype={constructor:three.plane,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setcomponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setfromnormalandcoplanarpoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setfromcoplanarpoints:function(){var a=new three.vector3,b=new three.vector3;return function(c,d,e){d=a.subvectors(e,d).cross(b.subvectors(c,d)).normalize();this.setfromnormalandcoplanarpoint(d, c);return this}}(),copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyscalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distancetopoint:function(a){return this.normal.dot(a)+this.constant},distancetosphere:function(a){return this.distancetopoint(a.center)-a.radius},projectpoint:function(a,b){return this.orthopoint(a,b).sub(a).negate()},orthopoint:function(a, b){var c=this.distancetopoint(a);return(b||new three.vector3).copy(this.normal).multiplyscalar(c)},isintersectionline:function(a){var b=this.distancetopoint(a.start);a=this.distancetopoint(a.end);return 0>b&&0a&&0f||1e;e++)8==e||13==e||18==e||23==e?b[e]="-":14==e?b[e]="4":(2>=c&&(c=33554432+16777216*math.random()|0),d=c&15,c>>=4,b[e]=a[19==e?d&3|8:d]);return b.join("")}}(),clamp:function(a,b,c){return ac?c:a},clampbottom:function(a,b){return a=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},random16:function(){return(65280*math.random()+255*math.random())/65535},randint:function(a,b){return math.floor(this.randfloat(a,b))},randfloat:function(a,b){return a+math.random()*(b-a)},randfloatspread:function(a){return a*(.5-math.random())},degtorad:function(){var a=math.pi/180;return function(b){return b*a}}(),radtodeg:function(){var a= 180/math.pi;return function(b){return b*a}}(),ispoweroftwo:function(a){return 0===(a&a-1)&&0!==a},nextpoweroftwo:function(a){a--;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;a++;return a}}; three.spline=function(a){function b(a,b,c,d,e,f,g){a=.5*(c-a);d=.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,k,l,p,q,n;this.initfromarray=function(a){this.points=[];for(var b=0;bthis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1:f+ 2;l=this.points[c[0]];p=this.points[c[1]];q=this.points[c[2]];n=this.points[c[3]];h=g*g;k=g*h;d.x=b(l.x,p.x,q.x,n.x,g,h,k);d.y=b(l.y,p.y,q.y,n.y,g,h,k);d.z=b(l.z,p.z,q.z,n.z,g,h,k);return d};this.getcontrolpointsarray=function(){var a,b,c=this.points.length,d=[];for(a=0;a=b.x+b.y}}(); three.triangle.prototype={constructor:three.triangle,set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setfrompointsandindices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},area:function(){var a=new three.vector3,b=new three.vector3;return function(){a.subvectors(this.c,this.b);b.subvectors(this.a,this.b);return.5*a.cross(b).length()}}(),midpoint:function(a){return(a|| new three.vector3).addvectors(this.a,this.b).add(this.c).multiplyscalar(1/3)},normal:function(a){return three.triangle.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new three.plane).setfromcoplanarpoints(this.a,this.b,this.c)},barycoordfrompoint:function(a,b){return three.triangle.barycoordfrompoint(a,this.a,this.b,this.c,b)},containspoint:function(a){return three.triangle.containspoint(a,this.a,this.b,this.c)},equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}, clone:function(){return(new three.triangle).copy(this)}};three.clock=function(a){this.autostart=void 0!==a?a:!0;this.elapsedtime=this.oldtime=this.starttime=0;this.running=!1}; three.clock.prototype={constructor:three.clock,start:function(){this.oldtime=this.starttime=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():date.now();this.running=!0},stop:function(){this.getelapsedtime();this.running=!1},getelapsedtime:function(){this.getdelta();return this.elapsedtime},getdelta:function(){var a=0;this.autostart&&!this.running&&this.start();if(this.running){var b=void 0!==self.performance&&void 0!==self.performance.now?self.performance.now():date.now(), a=.001*(b-this.oldtime);this.oldtime=b;this.elapsedtime+=a}return a}};three.eventdispatcher=function(){}; three.eventdispatcher.prototype={constructor:three.eventdispatcher,apply:function(a){a.addeventlistener=three.eventdispatcher.prototype.addeventlistener;a.haseventlistener=three.eventdispatcher.prototype.haseventlistener;a.removeeventlistener=three.eventdispatcher.prototype.removeeventlistener;a.dispatchevent=three.eventdispatcher.prototype.dispatchevent},addeventlistener:function(a,b){void 0===this._listeners&&(this._listeners={});var c=this._listeners;void 0===c[a]&&(c[a]=[]);-1===c[a].indexof(b)&& c[a].push(b)},haseventlistener:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;return void 0!==c[a]&&-1!==c[a].indexof(b)?!0:!1},removeeventlistener:function(a,b){if(void 0!==this._listeners){var c=this._listeners[a];if(void 0!==c){var d=c.indexof(b);-1!==d&&c.splice(d,1)}}},dispatchevent:function(a){if(void 0!==this._listeners){var b=this._listeners[a.type];if(void 0!==b){a.target=this;for(var c=[],d=b.length,e=0;eqa?-1:1;h[4*a]=oa.x;h[4*a+1]=oa.y;h[4*a+2]=oa.z;h[4*a+3]=ca}if(void 0===this.attributes.index||void 0===this.attributes.position||void 0===this.attributes.normal|| void 0===this.attributes.uv)three.warn("three.buffergeometry: missing required attributes (index, position, normal or uv) in buffergeometry.computetangents()");else{var c=this.attributes.index.array,d=this.attributes.position.array,e=this.attributes.normal.array,f=this.attributes.uv.array,g=d.length/3;void 0===this.attributes.tangent&&this.addattribute("tangent",new three.bufferattribute(new float32array(4*g),4));for(var h=this.attributes.tangent.array,k=[],l=[],p=0;p s;s++)r=b[3*c+s],-1==n[r]?(q[2*s]=r,q[2*s+1]=-1,p++):n[r]k.index+a)for(k={start:f,count:0,index:g},h.push(k),p=0;6>p;p+=2)s=q[p+1],-1p;p+=2)r=q[p],s=q[p+1],-1===s&&(s=g++),n[r]=s,t[s]=r,e[f++]=s-k.index,k.count++}this.reorderbuffers(e,t,g);return this.drawcalls=this.offsets=h},merge:function(a,b){if(!1===a instanceof three.buffergeometry)three.error("three.buffergeometry.merge(): geometry not an instance of three.buffergeometry.", a);else{void 0===b&&(b=0);var c=this.attributes,d;for(d in c)if(void 0!==a.attributes[d])for(var e=c[d].array,f=a.attributes[d],g=f.array,h=0,f=f.itemsize*b;hd?-1:1,e.vertextangents[c]=new three.vector4(w.x,w.y,w.z,d);this.hastangents=!0},computelinedistances:function(){for(var a=0,b=this.vertices,c=0,d=b.length;cd;d++)if(e[d]==e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e,1),c=0,g=this.facevertexuvs.length;ca.opacity&&(h.transparent=!0);void 0!==a.depthtest&&(h.depthtest=a.depthtest);void 0!==a.depthwrite&&(h.depthwrite=a.depthwrite);void 0!==a.visible&&(h.visible=a.visible);void 0!==a.flipsided&&(h.side=three.backside);void 0!==a.doublesided&&(h.side=three.doubleside);void 0!==a.wireframe&&(h.wireframe=a.wireframe); void 0!==a.vertexcolors&&("face"===a.vertexcolors?h.vertexcolors=three.facecolors:a.vertexcolors&&(h.vertexcolors=three.vertexcolors));a.colordiffuse?h.color=e(a.colordiffuse):a.dbgcolor&&(h.color=a.dbgcolor);a.colorspecular&&(h.specular=e(a.colorspecular));a.coloremissive&&(h.emissive=e(a.coloremissive));void 0!==a.transparency&&(console.warn("three.loader: transparency has been renamed to opacity"),a.opacity=a.transparency);void 0!==a.opacity&&(h.opacity=a.opacity);a.specularcoef&&(h.shininess= a.specularcoef);a.mapdiffuse&&b&&d(h,"map",a.mapdiffuse,a.mapdiffuserepeat,a.mapdiffuseoffset,a.mapdiffusewrap,a.mapdiffuseanisotropy);a.maplight&&b&&d(h,"lightmap",a.maplight,a.maplightrepeat,a.maplightoffset,a.maplightwrap,a.maplightanisotropy);a.mapbump&&b&&d(h,"bumpmap",a.mapbump,a.mapbumprepeat,a.mapbumpoffset,a.mapbumpwrap,a.mapbumpanisotropy);a.mapnormal&&b&&d(h,"normalmap",a.mapnormal,a.mapnormalrepeat,a.mapnormaloffset,a.mapnormalwrap,a.mapnormalanisotropy);a.mapspecular&&b&&d(h,"specularmap", a.mapspecular,a.mapspecularrepeat,a.mapspecularoffset,a.mapspecularwrap,a.mapspecularanisotropy);a.mapalpha&&b&&d(h,"alphamap",a.mapalpha,a.mapalpharepeat,a.mapalphaoffset,a.mapalphawrap,a.mapalphaanisotropy);a.mapbumpscale&&(h.bumpscale=a.mapbumpscale);a.mapnormalfactor&&(h.normalscale=new three.vector2(a.mapnormalfactor,a.mapnormalfactor));g=new three[g](h);void 0!==a.dbgname&&(g.name=a.dbgname);return g}}; three.loader.handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=0,c=this.handlers.length;bg;g++)n=x[k++],v=u[2*n],n=u[2*n+1],v=new three.vector2(v,n),2!==g&&c.facevertexuvs[d][h].push(v),0!==g&&c.facevertexuvs[d][h+1].push(v);q&&(q=3*x[k++],t.normal.set(d[q++],d[q++],d[q]),s.normal.copy(t.normal));if(r)for(d=0;4>d;d++)q=3*x[k++],r=new three.vector3(d[q++], d[q++],d[q]),2!==d&&t.vertexnormals.push(r),0!==d&&s.vertexnormals.push(r);p&&(p=x[k++],p=w[p],t.color.sethex(p),s.color.sethex(p));if(b)for(d=0;4>d;d++)p=x[k++],p=w[p],2!==d&&t.vertexcolors.push(new three.color(p)),0!==d&&s.vertexcolors.push(new three.color(p));c.faces.push(t);c.faces.push(s)}else{t=new three.face3;t.a=x[k++];t.b=x[k++];t.c=x[k++];h&&(h=x[k++],t.materialindex=h);h=c.faces.length;if(d)for(d=0;dg;g++)n=x[k++],v=u[2*n],n=u[2*n+1], v=new three.vector2(v,n),c.facevertexuvs[d][h].push(v);q&&(q=3*x[k++],t.normal.set(d[q++],d[q++],d[q]));if(r)for(d=0;3>d;d++)q=3*x[k++],r=new three.vector3(d[q++],d[q++],d[q]),t.vertexnormals.push(r);p&&(p=x[k++],t.color.sethex(w[p]));if(b)for(d=0;3>d;d++)p=x[k++],t.vertexcolors.push(new three.color(w[p]));c.faces.push(t)}})(d);(function(){var b=void 0!==a.influencespervertex?a.influencespervertex:2;if(a.skinweights)for(var d=0,g=a.skinweights.length;dthis.opacity&&(a.opacity=this.opacity);!1!==this.transparent&&(a.transparent=this.transparent);!1!==this.wireframe&& (a.wireframe=this.wireframe);return a},clone:function(a){void 0===a&&(a=new three.material);a.name=this.name;a.side=this.side;a.opacity=this.opacity;a.transparent=this.transparent;a.blending=this.blending;a.blendsrc=this.blendsrc;a.blenddst=this.blenddst;a.blendequation=this.blendequation;a.blendsrcalpha=this.blendsrcalpha;a.blenddstalpha=this.blenddstalpha;a.blendequationalpha=this.blendequationalpha;a.depthtest=this.depthtest;a.depthwrite=this.depthwrite;a.polygonoffset=this.polygonoffset;a.polygonoffsetfactor= this.polygonoffsetfactor;a.polygonoffsetunits=this.polygonoffsetunits;a.alphatest=this.alphatest;a.overdraw=this.overdraw;a.visible=this.visible;return a},update:function(){this.dispatchevent({type:"update"})},dispose:function(){this.dispatchevent({type:"dispose"})}};three.eventdispatcher.prototype.apply(three.material.prototype);three.materialidcount=0; three.linebasicmaterial=function(a){three.material.call(this);this.type="linebasicmaterial";this.color=new three.color(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.vertexcolors=three.nocolors;this.fog=!0;this.setvalues(a)};three.linebasicmaterial.prototype=object.create(three.material.prototype);three.linebasicmaterial.prototype.constructor=three.linebasicmaterial; three.linebasicmaterial.prototype.clone=function(){var a=new three.linebasicmaterial;three.material.prototype.clone.call(this,a);a.color.copy(this.color);a.linewidth=this.linewidth;a.linecap=this.linecap;a.linejoin=this.linejoin;a.vertexcolors=this.vertexcolors;a.fog=this.fog;return a}; three.linedashedmaterial=function(a){three.material.call(this);this.type="linedashedmaterial";this.color=new three.color(16777215);this.scale=this.linewidth=1;this.dashsize=3;this.gapsize=1;this.vertexcolors=!1;this.fog=!0;this.setvalues(a)};three.linedashedmaterial.prototype=object.create(three.material.prototype);three.linedashedmaterial.prototype.constructor=three.linedashedmaterial; three.linedashedmaterial.prototype.clone=function(){var a=new three.linedashedmaterial;three.material.prototype.clone.call(this,a);a.color.copy(this.color);a.linewidth=this.linewidth;a.scale=this.scale;a.dashsize=this.dashsize;a.gapsize=this.gapsize;a.vertexcolors=this.vertexcolors;a.fog=this.fog;return a}; three.meshbasicmaterial=function(a){three.material.call(this);this.type="meshbasicmaterial";this.color=new three.color(16777215);this.envmap=this.alphamap=this.specularmap=this.lightmap=this.map=null;this.combine=three.multiplyoperation;this.reflectivity=1;this.refractionratio=.98;this.fog=!0;this.shading=three.smoothshading;this.wireframe=!1;this.wireframelinewidth=1;this.wireframelinejoin=this.wireframelinecap="round";this.vertexcolors=three.nocolors;this.morphtargets=this.skinning=!1;this.setvalues(a)}; three.meshbasicmaterial.prototype=object.create(three.material.prototype);three.meshbasicmaterial.prototype.constructor=three.meshbasicmaterial; three.meshbasicmaterial.prototype.clone=function(){var a=new three.meshbasicmaterial;three.material.prototype.clone.call(this,a);a.color.copy(this.color);a.map=this.map;a.lightmap=this.lightmap;a.specularmap=this.specularmap;a.alphamap=this.alphamap;a.envmap=this.envmap;a.combine=this.combine;a.reflectivity=this.reflectivity;a.refractionratio=this.refractionratio;a.fog=this.fog;a.shading=this.shading;a.wireframe=this.wireframe;a.wireframelinewidth=this.wireframelinewidth;a.wireframelinecap=this.wireframelinecap; a.wireframelinejoin=this.wireframelinejoin;a.vertexcolors=this.vertexcolors;a.skinning=this.skinning;a.morphtargets=this.morphtargets;return a}; three.meshlambertmaterial=function(a){three.material.call(this);this.type="meshlambertmaterial";this.color=new three.color(16777215);this.emissive=new three.color(0);this.wraparound=!1;this.wraprgb=new three.vector3(1,1,1);this.envmap=this.alphamap=this.specularmap=this.lightmap=this.map=null;this.combine=three.multiplyoperation;this.reflectivity=1;this.refractionratio=.98;this.fog=!0;this.shading=three.smoothshading;this.wireframe=!1;this.wireframelinewidth=1;this.wireframelinejoin=this.wireframelinecap= "round";this.vertexcolors=three.nocolors;this.morphnormals=this.morphtargets=this.skinning=!1;this.setvalues(a)};three.meshlambertmaterial.prototype=object.create(three.material.prototype);three.meshlambertmaterial.prototype.constructor=three.meshlambertmaterial; three.meshlambertmaterial.prototype.clone=function(){var a=new three.meshlambertmaterial;three.material.prototype.clone.call(this,a);a.color.copy(this.color);a.emissive.copy(this.emissive);a.wraparound=this.wraparound;a.wraprgb.copy(this.wraprgb);a.map=this.map;a.lightmap=this.lightmap;a.specularmap=this.specularmap;a.alphamap=this.alphamap;a.envmap=this.envmap;a.combine=this.combine;a.reflectivity=this.reflectivity;a.refractionratio=this.refractionratio;a.fog=this.fog;a.shading=this.shading;a.wireframe= this.wireframe;a.wireframelinewidth=this.wireframelinewidth;a.wireframelinecap=this.wireframelinecap;a.wireframelinejoin=this.wireframelinejoin;a.vertexcolors=this.vertexcolors;a.skinning=this.skinning;a.morphtargets=this.morphtargets;a.morphnormals=this.morphnormals;return a}; three.meshphongmaterial=function(a){three.material.call(this);this.type="meshphongmaterial";this.color=new three.color(16777215);this.emissive=new three.color(0);this.specular=new three.color(1118481);this.shininess=30;this.wraparound=this.metal=!1;this.wraprgb=new three.vector3(1,1,1);this.bumpmap=this.lightmap=this.map=null;this.bumpscale=1;this.normalmap=null;this.normalscale=new three.vector2(1,1);this.envmap=this.alphamap=this.specularmap=null;this.combine=three.multiplyoperation;this.reflectivity= 1;this.refractionratio=.98;this.fog=!0;this.shading=three.smoothshading;this.wireframe=!1;this.wireframelinewidth=1;this.wireframelinejoin=this.wireframelinecap="round";this.vertexcolors=three.nocolors;this.morphnormals=this.morphtargets=this.skinning=!1;this.setvalues(a)};three.meshphongmaterial.prototype=object.create(three.material.prototype);three.meshphongmaterial.prototype.constructor=three.meshphongmaterial; three.meshphongmaterial.prototype.clone=function(){var a=new three.meshphongmaterial;three.material.prototype.clone.call(this,a);a.color.copy(this.color);a.emissive.copy(this.emissive);a.specular.copy(this.specular);a.shininess=this.shininess;a.metal=this.metal;a.wraparound=this.wraparound;a.wraprgb.copy(this.wraprgb);a.map=this.map;a.lightmap=this.lightmap;a.bumpmap=this.bumpmap;a.bumpscale=this.bumpscale;a.normalmap=this.normalmap;a.normalscale.copy(this.normalscale);a.specularmap=this.specularmap; a.alphamap=this.alphamap;a.envmap=this.envmap;a.combine=this.combine;a.reflectivity=this.reflectivity;a.refractionratio=this.refractionratio;a.fog=this.fog;a.shading=this.shading;a.wireframe=this.wireframe;a.wireframelinewidth=this.wireframelinewidth;a.wireframelinecap=this.wireframelinecap;a.wireframelinejoin=this.wireframelinejoin;a.vertexcolors=this.vertexcolors;a.skinning=this.skinning;a.morphtargets=this.morphtargets;a.morphnormals=this.morphnormals;return a}; three.meshdepthmaterial=function(a){three.material.call(this);this.type="meshdepthmaterial";this.wireframe=this.morphtargets=!1;this.wireframelinewidth=1;this.setvalues(a)};three.meshdepthmaterial.prototype=object.create(three.material.prototype);three.meshdepthmaterial.prototype.constructor=three.meshdepthmaterial; three.meshdepthmaterial.prototype.clone=function(){var a=new three.meshdepthmaterial;three.material.prototype.clone.call(this,a);a.wireframe=this.wireframe;a.wireframelinewidth=this.wireframelinewidth;return a};three.meshnormalmaterial=function(a){three.material.call(this,a);this.type="meshnormalmaterial";this.wireframe=!1;this.wireframelinewidth=1;this.morphtargets=!1;this.setvalues(a)};three.meshnormalmaterial.prototype=object.create(three.material.prototype); three.meshnormalmaterial.prototype.constructor=three.meshnormalmaterial;three.meshnormalmaterial.prototype.clone=function(){var a=new three.meshnormalmaterial;three.material.prototype.clone.call(this,a);a.wireframe=this.wireframe;a.wireframelinewidth=this.wireframelinewidth;return a};three.meshfacematerial=function(a){this.uuid=three.math.generateuuid();this.type="meshfacematerial";this.materials=a instanceof array?a:[]}; three.meshfacematerial.prototype={constructor:three.meshfacematerial,tojson:function(){for(var a={metadata:{version:4.2,type:"material",generator:"materialexporter"},uuid:this.uuid,type:this.type,materials:[]},b=0,c=this.materials.length;bf||(d=b.origin.distanceto(p),dd.far||e.push({distance:d,point:l.clone().applymatrix4(this.matrixworld),index:g,offsetindex:s,face:null,faceindex:null, object:this}))}}else for(n=n.position.array,g=0;gf||(d=b.origin.distanceto(p),dd.far||e.push({distance:d,point:l.clone().applymatrix4(this.matrixworld),index:g,face:null,faceindex:null,object:this}))}else if(g instanceof three.geometry)for(h=g.vertices,k=h.length,g=0;gf||(d=b.origin.distanceto(p),dd.far||e.push({distance:d,point:l.clone().applymatrix4(this.matrixworld), index:g,face:null,faceindex:null,object:this}))}}}();three.line.prototype.clone=function(a){void 0===a&&(a=new three.line(this.geometry,this.material,this.mode));three.object3d.prototype.clone.call(this,a);return a};three.mesh=function(a,b){three.object3d.call(this);this.type="mesh";this.geometry=void 0!==a?a:new three.geometry;this.material=void 0!==b?b:new three.meshbasicmaterial({color:16777215*math.random()});this.updatemorphtargets()};three.mesh.prototype=object.create(three.object3d.prototype); three.mesh.prototype.constructor=three.mesh;three.mesh.prototype.updatemorphtargets=function(){if(void 0!==this.geometry.morphtargets&&0g.far||h.push({distance:a,point:y,face:new three.face3(p,q,n,three.triangle.normal(d,e,f)),faceindex:null,object:this})}}}else for(s=p.position.array,r=k=0,w=s.length;k g.far||h.push({distance:a,point:y,face:new three.face3(p,q,n,three.triangle.normal(d,e,f)),faceindex:null,object:this}))}}else if(k instanceof three.geometry)for(r=this.material instanceof three.meshfacematerial,s=!0===r?this.material.materials:null,t=g.precision,u=k.vertices,v=0,x=k.faces.length;vg.far||h.push({distance:a,point:y,face:d,faceindex:v,object:this}))}}}();three.mesh.prototype.clone=function(a,b){void 0===a&&(a=new three.mesh(this.geometry,this.material));three.object3d.prototype.clone.call(this,a,b);return a};three.bone=function(a){three.object3d.call(this);this.type="bone";this.skin=a};three.bone.prototype=object.create(three.object3d.prototype);three.bone.prototype.constructor=three.bone; three.skeleton=function(a,b,c){this.usevertextexture=void 0!==c?c:!0;this.identitymatrix=new three.matrix4;a=a||[];this.bones=a.slice(0);this.usevertextexture?(this.bonetextureheight=this.bonetexturewidth=a=256h.end&&(h.end=e);b||(b=g)}}a.firstanimation=b}; three.morphanimmesh.prototype.setanimationlabel=function(a,b,c){this.geometry.animations||(this.geometry.animations={});this.geometry.animations[a]={start:b,end:c}};three.morphanimmesh.prototype.playanimation=function(a,b){var c=this.geometry.animations[a];c?(this.setframerange(c.start,c.end),this.duration=(c.end-c.start)/b*1e3,this.time=0):three.warn("three.morphanimmesh: animation["+a+"] undefined in .playanimation()")}; three.morphanimmesh.prototype.updateanimation=function(a){var b=this.duration/this.length;this.time+=this.direction*a;if(this.mirroredloop){if(this.time>this.duration||0>this.time)this.direction*=-1,this.time>this.duration&&(this.time=this.duration,this.directionbackwards=!0),0>this.time&&(this.time=0,this.directionbackwards=!1)}else this.time%=this.duration,0>this.time&&(this.time+=this.duration);a=this.startkeyframe+three.math.clamp(math.floor(this.time/b),0,this.length-1);a!==this.currentkeyframe&& (this.morphtargetinfluences[this.lastkeyframe]=0,this.morphtargetinfluences[this.currentkeyframe]=1,this.morphtargetinfluences[a]=0,this.lastkeyframe=this.currentkeyframe,this.currentkeyframe=a);b=this.time%b/b;this.directionbackwards&&(b=1-b);this.morphtargetinfluences[this.currentkeyframe]=b;this.morphtargetinfluences[this.lastkeyframe]=1-b}; three.morphanimmesh.prototype.interpolatetargets=function(a,b,c){for(var d=this.morphtargetinfluences,e=0,f=d.length;e=this.objects[d].distance)this.objects[d-1].object.visible=!1,this.objects[d].object.visible=!0;else break;for(;dthis.scale.x||c.push({distance:d,point:this.position,face:null,object:this})}}();three.sprite.prototype.clone=function(a){void 0===a&&(a=new three.sprite(this.material));three.object3d.prototype.clone.call(this,a);return a}; three.particle=three.sprite;three.lensflare=function(a,b,c,d,e){three.object3d.call(this);this.lensflares=[];this.positionscreen=new three.vector3;this.customupdatecallback=void 0;void 0!==a&&this.add(a,b,c,d,e)};three.lensflare.prototype=object.create(three.object3d.prototype);three.lensflare.prototype.constructor=three.lensflare; three.lensflare.prototype.add=function(a,b,c,d,e,f){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===f&&(f=1);void 0===e&&(e=new three.color(16777215));void 0===d&&(d=three.normalblending);c=math.min(c,math.max(0,c));this.lensflares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:f,color:e,blending:d})}; three.lensflare.prototype.updatelensflares=function(){var a,b=this.lensflares.length,c,d=2*-this.positionscreen.x,e=2*-this.positionscreen.y;for(a=0;a 0.0 ) {\n\t return pow( saturate( 1.0 - lightdistance / cutoffdistance ), decayexponent );\n\t}\n\treturn 1.0;\n}\n\nvec3 inputtolinear( in vec3 a ) {\n#ifdef gamma_input\n\treturn pow( a, vec3( float( gamma_factor ) ) );\n#else\n\treturn a;\n#endif\n}\nvec3 lineartooutput( in vec3 a ) {\n#ifdef gamma_output\n\treturn pow( a, vec3( 1.0 / float( gamma_factor ) ) );\n#else\n\treturn a;\n#endif\n}\n"; three.shaderchunk.alphatest_fragment="#ifdef alphatest\n\n\tif ( diffusecolor.a < alphatest ) discard;\n\n#endif\n";three.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\tvec3 dirvector = transformdirection( directionallightdirection[ i ], viewmatrix );\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 attenuation = calclightattenuation( length( lvector ), pointlightdistance[ i ], pointlightdecay[ i ] );\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 * attenuation;\n\n\t\t#ifdef double_sided\n\n\t\t\tvlightback += pointlightcolor[ i ] * pointlightweightingback * attenuation;\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 attenuation = calclightattenuation( length( lvector ), spotlightdistance[ i ], spotlightdecay[ i ] );\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 * attenuation * spoteffect;\n\n\t\t\t#ifdef double_sided\n\n\t\t\t\tvlightback += spotlightcolor[ i ] * spotlightweightingback * attenuation * 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\tvec3 lvector = transformdirection( hemispherelightdirection[ i ], viewmatrix );\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 += ambientlightcolor;\n\n#ifdef double_sided\n\n\tvlightback += ambientlightcolor;\n\n#endif\n"; three.shaderchunk.map_particle_pars_fragment="#ifdef use_map\n\n\tuniform vec4 offsetrepeat;\n\tuniform sampler2d map;\n\n#endif\n";three.shaderchunk.default_vertex="#ifdef use_skinning\n\n\tvec4 mvposition = modelviewmatrix * skinned;\n\n#elif defined( use_morphtargets )\n\n\tvec4 mvposition = modelviewmatrix * vec4( morphed, 1.0 );\n\n#else\n\n\tvec4 mvposition = modelviewmatrix * vec4( position, 1.0 );\n\n#endif\n\ngl_position = projectionmatrix * mvposition;\n"; three.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";three.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"; three.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";three.shaderchunk.lightmap_pars_vertex="#ifdef use_lightmap\n\n\tvarying vec2 vuv2;\n\n#endif";three.shaderchunk.lights_phong_fragment="#ifndef flat_shaded\n\n\tvec3 normal = normalize( vnormal );\n\n\t#ifdef double_sided\n\n\t\tnormal = normal * ( -1.0 + 2.0 * float( gl_frontfacing ) );\n\n\t#endif\n\n#else\n\n\tvec3 fdx = dfdx( vviewposition );\n\tvec3 fdy = dfdy( vviewposition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n\n#endif\n\nvec3 viewposition = normalize( vviewposition );\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\nvec3 totaldiffuselight = vec3( 0.0 );\nvec3 totalspecularlight = vec3( 0.0 );\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 + vviewposition.xyz;\n\n\t\tfloat attenuation = calclightattenuation( length( lvector ), pointlightdistance[ i ], pointlightdecay[ i ] );\n\n\t\tlvector = normalize( lvector );\n\n\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\ttotaldiffuselight += pointlightcolor[ i ] * pointdiffuseweight * attenuation;\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\ttotalspecularlight += schlick * pointlightcolor[ i ] * pointspecularweight * pointdiffuseweight * attenuation * specularnormalization;\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 + vviewposition.xyz;\n\n\t\tfloat attenuation = calclightattenuation( length( lvector ), spotlightdistance[ i ], spotlightdecay[ i ] );\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// 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\ttotaldiffuselight += spotlightcolor[ i ] * spotdiffuseweight * attenuation * spoteffect;\n\n\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\ttotalspecularlight += schlick * spotlightcolor[ i ] * spotspecularweight * spotdiffuseweight * attenuation * specularnormalization * spoteffect;\n\n\t\t}\n\n\t}\n\n#endif\n\n#if max_dir_lights > 0\n\n\tfor( int i = 0; i < max_dir_lights; i ++ ) {\n\n\t\tvec3 dirvector = transformdirection( directionallightdirection[ i ], viewmatrix );\n\n\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\ttotaldiffuselight += 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\ttotalspecularlight += schlick * directionallightcolor[ i ] * dirspecularweight * dirdiffuseweight * specularnormalization;\n\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\tvec3 lvector = transformdirection( hemispherelightdirection[ i ], viewmatrix );\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\ttotaldiffuselight += 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\ttotalspecularlight += hemicolor * specularnormalization * ( schlicksky * hemispecularweightsky * max( dotproduct, 0.0 ) + schlickground * hemispecularweightground * max( dotproductground, 0.0 ) );\n\n\t}\n\n#endif\n\n#ifdef metal\n\n\toutgoinglight += diffusecolor.rgb * ( totaldiffuselight + ambientlightcolor ) * specular + totalspecularlight + emissive;\n\n#else\n\n\toutgoinglight += diffusecolor.rgb * ( totaldiffuselight + ambientlightcolor ) + totalspecularlight + emissive;\n\n#endif\n"; three.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";three.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"; three.shaderchunk.envmap_pars_fragment="#ifdef use_envmap\n\n\tuniform float reflectivity;\n\t#ifdef envmap_type_cube\n\t\tuniform samplercube envmap;\n\t#else\n\t\tuniform sampler2d envmap;\n\t#endif\n\tuniform float flipenvmap;\n\n\t#if defined( use_bumpmap ) || defined( use_normalmap ) || defined( phong )\n\n\t\tuniform float refractionratio;\n\n\t#else\n\n\t\tvarying vec3 vreflect;\n\n\t#endif\n\n#endif\n";three.shaderchunk.logdepthbuf_fragment="#if defined(use_logdepthbuf) && defined(use_logdepthbuf_ext)\n\n\tgl_fragdepthext = log2(vfragdepth) * logdepthbuffc * 0.5;\n\n#endif"; three.shaderchunk.normalmap_pars_fragment="#ifdef use_normalmap\n\n\tuniform sampler2d normalmap;\n\tuniform vec2 normalscale;\n\n\t// per-pixel tangent space normal mapping\n\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n\tvec3 perturbnormal2arb( vec3 eye_pos, vec3 surf_norm ) {\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"; three.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";three.shaderchunk.lightmap_pars_fragment="#ifdef use_lightmap\n\n\tvarying vec2 vuv2;\n\tuniform sampler2d lightmap;\n\n#endif";three.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"; three.shaderchunk.lights_phong_vertex="#if max_spot_lights > 0 || defined( use_bumpmap ) || defined( use_envmap )\n\n\tvworldposition = worldposition.xyz;\n\n#endif";three.shaderchunk.map_fragment="#ifdef use_map\n\n\tvec4 texelcolor = texture2d( map, vuv );\n\n\ttexelcolor.xyz = inputtolinear( texelcolor.xyz );\n\n\tdiffusecolor *= texelcolor;\n\n#endif";three.shaderchunk.lightmap_vertex="#ifdef use_lightmap\n\n\tvuv2 = uv2;\n\n#endif";three.shaderchunk.map_particle_fragment="#ifdef use_map\n\n\tdiffusecolor *= texture2d( map, vec2( gl_pointcoord.x, 1.0 - gl_pointcoord.y ) * offsetrepeat.zw + offsetrepeat.xy );\n\n#endif\n"; three.shaderchunk.color_pars_fragment="#ifdef use_color\n\n\tvarying vec3 vcolor;\n\n#endif\n";three.shaderchunk.color_vertex="#ifdef use_color\n\n\tvcolor.xyz = inputtolinear( color.xyz );\n\n#endif";three.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"; three.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\n#endif\n";three.shaderchunk.linear_to_gamma_fragment="\n\toutgoinglight = lineartooutput( outgoinglight );\n";three.shaderchunk.color_pars_vertex="#ifdef use_color\n\n\tvarying vec3 vcolor;\n\n#endif";three.shaderchunk.lights_lambert_pars_vertex="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\tuniform vec3 pointlightposition[ max_point_lights ];\n\tuniform float pointlightdistance[ max_point_lights ];\n\tuniform float pointlightdecay[ 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\tuniform float spotlightdecay[ max_spot_lights ];\n\n#endif\n\n#ifdef wrap_around\n\n\tuniform vec3 wraprgb;\n\n#endif\n"; three.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";three.shaderchunk.envmap_fragment="#ifdef use_envmap\n\n\t#if defined( use_bumpmap ) || defined( use_normalmap ) || defined( phong )\n\n\t\tvec3 cameratovertex = normalize( vworldposition - cameraposition );\n\n\t\t// transforming normal vectors with the inverse transformation\n\t\tvec3 worldnormal = inversetransformdirection( normal, viewmatrix );\n\n\t\t#ifdef envmap_mode_reflection\n\n\t\t\tvec3 reflectvec = reflect( cameratovertex, worldnormal );\n\n\t\t#else\n\n\t\t\tvec3 reflectvec = refract( cameratovertex, worldnormal, refractionratio );\n\n\t\t#endif\n\n\t#else\n\n\t\tvec3 reflectvec = vreflect;\n\n\t#endif\n\n\t#ifdef double_sided\n\t\tfloat flipnormal = ( -1.0 + 2.0 * float( gl_frontfacing ) );\n\t#else\n\t\tfloat flipnormal = 1.0;\n\t#endif\n\n\t#ifdef envmap_type_cube\n\t\tvec4 envcolor = texturecube( envmap, flipnormal * vec3( flipenvmap * reflectvec.x, reflectvec.yz ) );\n\n\t#elif defined( envmap_type_equirec )\n\t\tvec2 sampleuv;\n\t\tsampleuv.y = saturate( flipnormal * reflectvec.y * 0.5 + 0.5 );\n\t\tsampleuv.x = atan( flipnormal * reflectvec.z, flipnormal * reflectvec.x ) * reciprocal_pi2 + 0.5;\n\t\tvec4 envcolor = texture2d( envmap, sampleuv );\n\n\t#elif defined( envmap_type_sphere )\n\t\tvec3 reflectview = flipnormal * normalize((viewmatrix * vec4( reflectvec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n\t\tvec4 envcolor = texture2d( envmap, reflectview.xy * 0.5 + 0.5 );\n\t#endif\n\n\tenvcolor.xyz = inputtolinear( envcolor.xyz );\n\n\t#ifdef envmap_blending_multiply\n\n\t\toutgoinglight = mix( outgoinglight, outgoinglight * envcolor.xyz, specularstrength * reflectivity );\n\n\t#elif defined( envmap_blending_mix )\n\n\t\toutgoinglight = mix( outgoinglight, envcolor.xyz, specularstrength * reflectivity );\n\n\t#elif defined( envmap_blending_add )\n\n\t\toutgoinglight += envcolor.xyz * specularstrength * reflectivity;\n\n\t#endif\n\n#endif\n"; three.shaderchunk.specularmap_pars_fragment="#ifdef use_specularmap\n\n\tuniform sampler2d specularmap;\n\n#endif";three.shaderchunk.logdepthbuf_vertex="#ifdef use_logdepthbuf\n\n\tgl_position.z = log2(max( epsilon, 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";three.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"; three.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";three.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\tfloat fogfactor = exp2( - square( fogdensity ) * square( depth ) * log2 );\n\t\tfogfactor = whitecompliment( fogfactor );\n\n\t#else\n\n\t\tfloat fogfactor = smoothstep( fognear, fogfar, depth );\n\n\t#endif\n\t\n\toutgoinglight = mix( outgoinglight, fogcolor, fogfactor );\n\n#endif"; three.shaderchunk.bumpmap_pars_fragment="#ifdef use_bumpmap\n\n\tuniform sampler2d bumpmap;\n\tuniform float bumpscale;\n\n\t// derivative maps - bump mapping unparametrized surfaces by morten mikkelsen\n\t// http://mmikkelsen3d.blogspot.sk/2011/07/derivative-maps.html\n\n\t// evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\n\n\tvec2 dhdxy_fwd() {\n\n\t\tvec2 dstdx = dfdx( vuv );\n\t\tvec2 dstdy = dfdy( vuv );\n\n\t\tfloat hll = bumpscale * texture2d( bumpmap, vuv ).x;\n\t\tfloat dbx = bumpscale * texture2d( bumpmap, vuv + dstdx ).x - hll;\n\t\tfloat dby = bumpscale * texture2d( bumpmap, vuv + dstdy ).x - hll;\n\n\t\treturn vec2( dbx, dby );\n\n\t}\n\n\tvec3 perturbnormalarb( vec3 surf_pos, vec3 surf_norm, vec2 dhdxy ) {\n\n\t\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\n"; three.shaderchunk.defaultnormal_vertex="#ifdef use_skinning\n\n\tvec3 objectnormal = skinnednormal.xyz;\n\n#elif defined( use_morphnormals )\n\n\tvec3 objectnormal = morphednormal;\n\n#else\n\n\tvec3 objectnormal = normal;\n\n#endif\n\n#ifdef flip_sided\n\n\tobjectnormal = -objectnormal;\n\n#endif\n\nvec3 transformednormal = normalmatrix * objectnormal;\n";three.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\tuniform float pointlightdecay[ 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\tuniform float spotlightdistance[ max_spot_lights ];\n\tuniform float spotlightdecay[ 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;\n\n#ifndef flat_shaded\n\n\tvarying vec3 vnormal;\n\n#endif\n"; three.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";three.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"; three.shaderchunk.lightmap_fragment="#ifdef use_lightmap\n\n\toutgoinglight *= diffusecolor.xyz * texture2d( lightmap, vuv2 ).xyz;\n\n#endif";three.shaderchunk.shadowmap_pars_vertex="#ifdef use_shadowmap\n\n\tvarying vec4 vshadowcoord[ max_shadows ];\n\tuniform mat4 shadowmatrix[ max_shadows ];\n\n#endif";three.shaderchunk.color_fragment="#ifdef use_color\n\n\tdiffusecolor.rgb *= vcolor;\n\n#endif";three.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"; three.shaderchunk.envmap_vertex="#if defined( use_envmap ) && ! defined( use_bumpmap ) && ! defined( use_normalmap ) && ! defined( phong )\n\n\tvec3 worldnormal = transformdirection( objectnormal, modelmatrix );\n\n\tvec3 cameratovertex = normalize( worldposition.xyz - cameraposition );\n\n\t#ifdef envmap_mode_reflection\n\n\t\tvreflect = reflect( cameratovertex, worldnormal );\n\n\t#else\n\n\t\tvreflect = refract( cameratovertex, worldnormal, refractionratio );\n\n\t#endif\n\n#endif\n"; three.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 ) outgoinglight *= frustumcolors[ i ];\n\n\t\t\t#else\n\n\t\t\t\tif ( infrustum ) outgoinglight *= frustumcolors[ i ];\n\n\t\t\t#endif\n\n\t\t#endif\n\n\t}\n\n\t// note: i am unsure if this is correct in linear space. -bhouston, dec 29, 2014\n\tshadowcolor = inputtolinear( shadowcolor );\n\n\toutgoinglight = outgoinglight * shadowcolor;\n\n#endif\n"; three.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#elif defined( use_morphtargets )\n\n\t\tvec4 worldposition = modelmatrix * vec4( morphed, 1.0 );\n\n\t#else\n\n\t\tvec4 worldposition = modelmatrix * vec4( position, 1.0 );\n\n\t#endif\n\n#endif\n";three.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"; three.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"; three.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";three.shaderchunk.alphamap_fragment="#ifdef use_alphamap\n\n\tdiffusecolor.a *= texture2d( alphamap, vuv ).g;\n\n#endif\n";three.shaderchunk.alphamap_pars_fragment="#ifdef use_alphamap\n\n\tuniform sampler2d alphamap;\n\n#endif\n"; three.uniformsutils={merge:function(a){for(var b={},c=0;c dashsize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoinglight = vec3( 0.0 );\n\tvec4 diffusecolor = vec4( diffuse, opacity );",three.shaderchunk.logdepthbuf_fragment,three.shaderchunk.color_fragment,"\toutgoinglight = diffusecolor.rgb;",three.shaderchunk.fog_fragment,"\tgl_fragcolor = vec4( outgoinglight, diffusecolor.a );\n}"].join("\n")}, depth:{uniforms:{mnear:{type:"f",value:1},mfar:{type:"f",value:2e3},opacity:{type:"f",value:1}},vertexshader:[three.shaderchunk.common,three.shaderchunk.morphtarget_pars_vertex,three.shaderchunk.logdepthbuf_pars_vertex,"void main() {",three.shaderchunk.morphtarget_vertex,three.shaderchunk.default_vertex,three.shaderchunk.logdepthbuf_vertex,"}"].join("\n"),fragmentshader:["uniform float mnear;\nuniform float mfar;\nuniform float opacity;",three.shaderchunk.common,three.shaderchunk.logdepthbuf_pars_fragment, "void main() {",three.shaderchunk.logdepthbuf_fragment,"\t#ifdef use_logdepthbuf_ext\n\t\tfloat depth = gl_fragdepthext / gl_fragcoord.w;\n\t#else\n\t\tfloat depth = gl_fragcoord.z / gl_fragcoord.w;\n\t#endif\n\tfloat color = 1.0 - smoothstep( mnear, mfar, depth );\n\tgl_fragcolor = vec4( vec3( color ), opacity );\n}"].join("\n")},normal:{uniforms:{opacity:{type:"f",value:1}},vertexshader:["varying vec3 vnormal;",three.shaderchunk.common,three.shaderchunk.morphtarget_pars_vertex,three.shaderchunk.logdepthbuf_pars_vertex, "void main() {\n\tvnormal = normalize( normalmatrix * normal );",three.shaderchunk.morphtarget_vertex,three.shaderchunk.default_vertex,three.shaderchunk.logdepthbuf_vertex,"}"].join("\n"),fragmentshader:["uniform float opacity;\nvarying vec3 vnormal;",three.shaderchunk.common,three.shaderchunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_fragcolor = vec4( 0.5 * normalize( vnormal ) + 0.5, opacity );",three.shaderchunk.logdepthbuf_fragment,"}"].join("\n")},cube:{uniforms:{tcube:{type:"t",value:null}, tflip:{type:"f",value:-1}},vertexshader:["varying vec3 vworldposition;",three.shaderchunk.common,three.shaderchunk.logdepthbuf_pars_vertex,"void main() {\n\tvworldposition = transformdirection( position, modelmatrix );\n\tgl_position = projectionmatrix * modelviewmatrix * vec4( position, 1.0 );",three.shaderchunk.logdepthbuf_vertex,"}"].join("\n"),fragmentshader:["uniform samplercube tcube;\nuniform float tflip;\nvarying vec3 vworldposition;",three.shaderchunk.common,three.shaderchunk.logdepthbuf_pars_fragment, "void main() {\n\tgl_fragcolor = texturecube( tcube, vec3( tflip * vworldposition.x, vworldposition.yz ) );",three.shaderchunk.logdepthbuf_fragment,"}"].join("\n")},equirect:{uniforms:{tequirect:{type:"t",value:null},tflip:{type:"f",value:-1}},vertexshader:["varying vec3 vworldposition;",three.shaderchunk.common,three.shaderchunk.logdepthbuf_pars_vertex,"void main() {\n\tvworldposition = transformdirection( position, modelmatrix );\n\tgl_position = projectionmatrix * modelviewmatrix * vec4( position, 1.0 );", three.shaderchunk.logdepthbuf_vertex,"}"].join("\n"),fragmentshader:["uniform sampler2d tequirect;\nuniform float tflip;\nvarying vec3 vworldposition;",three.shaderchunk.common,three.shaderchunk.logdepthbuf_pars_fragment,"void main() {\nvec3 direction = normalize( vworldposition );\nvec2 sampleuv;\nsampleuv.y = saturate( tflip * direction.y * -0.5 + 0.5 );\nsampleuv.x = atan( direction.z, direction.x ) * reciprocal_pi2 + 0.5;\ngl_fragcolor = texture2d( tequirect, sampleuv );",three.shaderchunk.logdepthbuf_fragment, "}"].join("\n")},depthrgba:{uniforms:{},vertexshader:[three.shaderchunk.common,three.shaderchunk.morphtarget_pars_vertex,three.shaderchunk.skinning_pars_vertex,three.shaderchunk.logdepthbuf_pars_vertex,"void main() {",three.shaderchunk.skinbase_vertex,three.shaderchunk.morphtarget_vertex,three.shaderchunk.skinning_vertex,three.shaderchunk.default_vertex,three.shaderchunk.logdepthbuf_vertex,"}"].join("\n"),fragmentshader:[three.shaderchunk.common,three.shaderchunk.logdepthbuf_pars_fragment,"vec4 pack_depth( const in float depth ) {\n\tconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\n\tconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\n\tvec4 res = mod( depth * bit_shift * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );\n\tres -= res.xxyz * bit_mask;\n\treturn res;\n}\nvoid main() {", three.shaderchunk.logdepthbuf_fragment,"\t#ifdef use_logdepthbuf_ext\n\t\tgl_fragdata[ 0 ] = pack_depth( gl_fragdepthext );\n\t#else\n\t\tgl_fragdata[ 0 ] = pack_depth( gl_fragcoord.z );\n\t#endif\n}"].join("\n")}}; three.webglrenderer=function(a){function b(a){var b=a.geometry;a=a.material;var c=b.vertices.length;if(a.attributes){void 0===b.__webglcustomattributeslist&&(b.__webglcustomattributeslist=[]);for(var d in a.attributes){var e=a.attributes[d];if(!e.__webglinitialized||e.createuniquebuffers){e.__webglinitialized=!0;var f=1;"v2"===e.type?f=2:"v3"===e.type?f=3:"v4"===e.type?f=4:"c"===e.type&&(f=3);e.size=f;e.array=new float32array(c*f);e.buffer=m.createbuffer();e.buffer.belongstoattribute=d;e.needsupdate= !0}b.__webglcustomattributeslist.push(e)}}}function c(a,b){return a.material instanceof three.meshfacematerial?a.material.materials[b.materialindex]:a.material}function d(a,b,c,d){c=c.attributes;var e=b.attributes;b=b.attributeskeys;for(var f=0,g=b.length;fh&&(e[u].counter+=1,k=e[u].hash+"_"+e[u].counter,k in s||(q={id:qb++,faces3:[],materialindex:u,vertices:0,nummorphtargets:l, nummorphnormals:p},s[k]=q,t.push(q)));s[k].faces3.push(r);s[k].vertices+=3}f[g]=t;b.groupsneedupdate=!1}f=ua[b.id];g=0;for(d=f.length;gy;y++)pa=i[y],na[ra]=pa.x,na[ra+1]= pa.y,na[ra+2]=pa.z,ra+=3;else for(y=0;3>y;y++)na[ra]=h.x,na[ra+1]=h.y,na[ra+2]=h.z,ra+=3;m.bindbuffer(m.array_buffer,v.__webglnormalbuffer);m.bufferdata(m.array_buffer,na,d)}if(vb&&hb){y=0;for(z=$.length;yy;y++)ab=u[y],ab[kb]=ab.x,ab[kb+1]=ab.y,kb+=2;0y;y++)oa=o[y],lb[yb]=oa.x,lb[yb+1]=oa.y, yb+=2;0ya;ya++)gb[ya]=!b.autoscalecubemaps||rb||ib?ib? x.image[ya].image:x.image[ya]:e(x.image[ya],qc);var yb=gb[0],zb=three.math.ispoweroftwo(yb.width)&&three.math.ispoweroftwo(yb.height),wa=i(x.format),tb=i(x.type);a(m.texture_cube_map,x,zb);for(ya=0;6>ya;ya++)if(rb)for(var hb,$b=gb[ya].mipmaps,fb=0,sb=$b.length;fb=wb&&three.warn("webglrenderer: trying to use "+a+" texture units while this gpu supports only "+wb);mb+=1;return a}function w(a,b){a._modelviewmatrix.multiplymatrices(b.matrixworldinverse,a.matrixworld);a._normalmatrix.getnormalmatrix(a._modelviewmatrix)} function y(a,b,c,d){a[b]=c.r*d;a[b+1]=c.g*d;a[b+2]=c.b*d}function a(a,b,c){c?(m.texparameteri(a,m.texture_wrap_s,i(b.wraps)),m.texparameteri(a,m.texture_wrap_t,i(b.wrapt)),m.texparameteri(a,m.texture_mag_filter,i(b.magfilter)),m.texparameteri(a,m.texture_min_filter,i(b.minfilter))):(m.texparameteri(a,m.texture_wrap_s,m.clamp_to_edge),m.texparameteri(a,m.texture_wrap_t,m.clamp_to_edge),b.wraps===three.clamptoedgewrapping&&b.wrapt===three.clamptoedgewrapping||three.warn("three.webglrenderer: texture is not power of two. texture.wraps and texture.wrapt should be set to three.clamptoedgewrapping. ( "+ b.sourcefile+" )"),m.texparameteri(a,m.texture_mag_filter,z(b.magfilter)),m.texparameteri(a,m.texture_min_filter,z(b.minfilter)),b.minfilter!==three.nearestfilter&&b.minfilter!==three.linearfilter&&three.warn("three.webglrenderer: texture is not power of two. texture.minfilter should be set to three.nearestfilter or three.linearfilter. ( "+b.sourcefile+" )"));(c=da.get("ext_texture_filter_anisotropic"))&&b.type!==three.floattype&&b.type!==three.halffloattype&&(1b||a.height>b){var c=b/math.max(a.width,a.height),d=document.createelement("canvas");d.width=math.floor(a.width*c);d.height=math.floor(a.height*c);d.getcontext("2d").drawimage(a,0,0,a.width,a.height,0,0,d.width,d.height);three.warn("three.webglrenderer: image is too big ("+a.width+"x"+a.height+"). resized to "+d.width+"x"+d.height,a);return d}return a} function g(a,b){m.bindrenderbuffer(m.renderbuffer,a);b.depthbuffer&&!b.stencilbuffer?(m.renderbufferstorage(m.renderbuffer,m.depth_component16,b.width,b.height),m.framebufferrenderbuffer(m.framebuffer,m.depth_attachment,m.renderbuffer,a)):b.depthbuffer&&b.stencilbuffer?(m.renderbufferstorage(m.renderbuffer,m.depth_stencil,b.width,b.height),m.framebufferrenderbuffer(m.framebuffer,m.depth_stencil_attachment,m.renderbuffer,a)):m.renderbufferstorage(m.renderbuffer,m.rgba4,b.width,b.height)}function f(a){a instanceof three.webglrendertargetcube?(m.bindtexture(m.texture_cube_map,a.__webgltexture),m.generatemipmap(m.texture_cube_map),m.bindtexture(m.texture_cube_map,null)):(m.bindtexture(m.texture_2d,a.__webgltexture),m.generatemipmap(m.texture_2d),m.bindtexture(m.texture_2d,null))}function z(a){return a===three.nearestfilter||a===three.nearestmipmapnearestfilter||a===three.nearestmipmaplinearfilter?m.nearest:m.linear}function i(a){var b;if(a===three.repeatwrapping)return m.repeat;if(a===three.clamptoedgewrapping)return m.clamp_to_edge; if(a===three.mirroredrepeatwrapping)return m.mirrored_repeat;if(a===three.nearestfilter)return m.nearest;if(a===three.nearestmipmapnearestfilter)return m.nearest_mipmap_nearest;if(a===three.nearestmipmaplinearfilter)return m.nearest_mipmap_linear;if(a===three.linearfilter)return m.linear;if(a===three.linearmipmapnearestfilter)return m.linear_mipmap_nearest;if(a===three.linearmipmaplinearfilter)return m.linear_mipmap_linear;if(a===three.unsignedbytetype)return m.unsigned_byte;if(a===three.unsignedshort4444type)return m.unsigned_short_4_4_4_4; if(a===three.unsignedshort5551type)return m.unsigned_short_5_5_5_1;if(a===three.unsignedshort565type)return m.unsigned_short_5_6_5;if(a===three.bytetype)return m.byte;if(a===three.shorttype)return m.short;if(a===three.unsignedshorttype)return m.unsigned_short;if(a===three.inttype)return m.int;if(a===three.unsignedinttype)return m.unsigned_int;if(a===three.floattype)return m.float;b=da.get("oes_texture_half_float");if(null!==b&&a===three.halffloattype)return b.half_float_oes;if(a===three.alphaformat)return m.alpha; if(a===three.rgbformat)return m.rgb;if(a===three.rgbaformat)return m.rgba;if(a===three.luminanceformat)return m.luminance;if(a===three.luminancealphaformat)return m.luminance_alpha;if(a===three.addequation)return m.func_add;if(a===three.subtractequation)return m.func_subtract;if(a===three.reversesubtractequation)return m.func_reverse_subtract;if(a===three.zerofactor)return m.zero;if(a===three.onefactor)return m.one;if(a===three.srccolorfactor)return m.src_color;if(a===three.oneminussrccolorfactor)return m.one_minus_src_color; if(a===three.srcalphafactor)return m.src_alpha;if(a===three.oneminussrcalphafactor)return m.one_minus_src_alpha;if(a===three.dstalphafactor)return m.dst_alpha;if(a===three.oneminusdstalphafactor)return m.one_minus_dst_alpha;if(a===three.dstcolorfactor)return m.dst_color;if(a===three.oneminusdstcolorfactor)return m.one_minus_dst_color;if(a===three.srcalphasaturatefactor)return m.src_alpha_saturate;b=da.get("webgl_compressed_texture_s3tc");if(null!==b){if(a===three.rgb_s3tc_dxt1_format)return b.compressed_rgb_s3tc_dxt1_ext; if(a===three.rgba_s3tc_dxt1_format)return b.compressed_rgba_s3tc_dxt1_ext;if(a===three.rgba_s3tc_dxt3_format)return b.compressed_rgba_s3tc_dxt3_ext;if(a===three.rgba_s3tc_dxt5_format)return b.compressed_rgba_s3tc_dxt5_ext}b=da.get("webgl_compressed_texture_pvrtc");if(null!==b){if(a===three.rgb_pvrtc_4bppv1_format)return b.compressed_rgb_pvrtc_4bppv1_img;if(a===three.rgb_pvrtc_2bppv1_format)return b.compressed_rgb_pvrtc_2bppv1_img;if(a===three.rgba_pvrtc_4bppv1_format)return b.compressed_rgba_pvrtc_4bppv1_img; if(a===three.rgba_pvrtc_2bppv1_format)return b.compressed_rgba_pvrtc_2bppv1_img}b=da.get("ext_blend_minmax");if(null!==b){if(a===three.minequation)return b.min_ext;if(a===three.maxequation)return b.max_ext}return 0}console.log("three.webglrenderer",three.revision);a=a||{};var u=void 0!==a.canvas?a.canvas:document.createelement("canvas"),m=void 0!==a.context?a.context:null,h=1,l=void 0!==a.precision?a.precision:"highp",p=void 0!==a.alpha?a.alpha:!1,n=void 0!==a.depth?a.depth:!0,r=void 0!==a.stencil? a.stencil:!0,v=void 0!==a.antialias?a.antialias:!1,j=void 0!==a.premultipliedalpha?a.premultipliedalpha:!0,oa=void 0!==a.preservedrawingbuffer?a.preservedrawingbuffer:!1,ja=void 0!==a.logarithmicdepthbuffer?a.logarithmicdepthbuffer:!1,ha=new three.color(0),o=0,ca=[],ba={},qa=[],ka=[],qa=[],xa=[],ya=[];this.domelement=u;this.context=null;this.sortobjects=this.autoclearstencil=this.autocleardepth=this.autoclearcolor=this.autoclear=!0;this.gammafactor=2;this.shadowmapenabled=this.gammaoutput=this.gammainput= !1;this.shadowmaptype=three.pcfshadowmap;this.shadowmapcullface=three.cullfacefront;this.shadowmapcascade=this.shadowmapdebug=!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 b=this,pa=[],ob=null,ab=null,ub=-1,ta="",vb=null,mb=0,ib=0,bb=0,pb=u.width,qb=u.height,xb=0,fc=0,cb=new three.frustum,db=new three.matrix4,wa=new three.vector3,pa=new three.vector3,ob=!0,jc={ambient:[0, 0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[],decays:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],anglescos:[],exponents:[],decays:[]},hemi:{length:0,skycolors:[],groundcolors:[],positions:[]}},m;try{var yb={alpha:p,depth:n,stencil:r,antialias:v,premultipliedalpha:j,preservedrawingbuffer:oa};m=m||u.getcontext("webgl",yb)||u.getcontext("experimental-webgl",yb);if(null===m){if(null!==u.getcontext("webgl"))throw"error creating webgl context with your selected attributes."; throw"error creating webgl context.";}u.addeventlistener("webglcontextlost",function(a){a.preventdefault();zb();lc();ba={}},!1)}catch(rc){three.error("three.webglrenderer: "+rc)}var w=new three.webglstate(m,i);void 0===m.getshaderprecisionformat&&(m.getshaderprecisionformat=function(){return{rangemin:1,rangemax:1,precision:1}});var da=new three.webglextensions(m);da.get("oes_texture_float");da.get("oes_texture_float_linear");da.get("oes_texture_half_float");da.get("oes_texture_half_float_linear"); da.get("oes_standard_derivatives");ja&&da.get("ext_frag_depth");var rb=function(a,b,c,d){!0===j&&(a*=d,b*=d,c*=d);m.clearcolor(a,b,c,d)},lc=function(){m.clearcolor(0,0,0,1);m.cleardepth(1);m.clearstencil(0);m.enable(m.depth_test);m.depthfunc(m.lequal);m.frontface(m.ccw);m.cullface(m.back);m.enable(m.cull_face);m.enable(m.blend);m.blendequation(m.func_add);m.blendfunc(m.src_alpha,m.one_minus_src_alpha);m.viewport(ib,bb,pb,qb);rb(ha.r,ha.g,ha.b,o)},zb=function(){vb=ob=null;ta="";ub=-1;ob=!0;w.reset()}; lc();this.context=m;this.state=w;var wb=m.getparameter(m.max_texture_image_units),sc=m.getparameter(m.max_vertex_texture_image_units),tc=m.getparameter(m.max_texture_size),qc=m.getparameter(m.max_cube_map_texture_size),vb=0b;b++)m.deleteframebuffer(a.__webglframebuffer[b]),m.deleterenderbuffer(a.__webglrenderbuffer[b]);else m.deleteframebuffer(a.__webglframebuffer),m.deleterenderbuffer(a.__webglrenderbuffer);delete a.__webglframebuffer;delete a.__webglrenderbuffer}b.info.memory.textures--},ic=function(a){a=a.target;a.removeeventlistener("dispose",ic);hc(a)},nc=function(a){for(var b= "__webglvertexbuffer __webglnormalbuffer __webgltangentbuffer __webglcolorbuffer __webgluvbuffer __webgluv2buffer __webglskinindicesbuffer __webglskinweightsbuffer __webglfacebuffer __webgllinebuffer __webgllinedistancebuffer".split(" "),c=0,d=b.length;ch.length&&(console.warn("three.webglrenderer: influences array is bigger than morphtargets array."),n.length=h.length);h=0;for(l=n.length;hd.numsupportedmorphtargets?(k.sort(g),k.length=d.numsupportedmorphtargets):k.length>d.numsupportedmorphnormals?k.sort(g):0===k.length&&k.push([0,0]);for(var h=0,p=d.numsupportedmorphtargets;hf;f++){a.__webglframebuffer[f]=m.createframebuffer();a.__webglrenderbuffer[f]=m.createrenderbuffer();m.teximage2d(m.texture_cube_map_positive_x+f,0,d,a.width,a.height,0,d,e,null);var g=a,h=m.texture_cube_map_positive_x+f;m.bindframebuffer(m.framebuffer, a.__webglframebuffer[f]);m.framebuffertexture2d(m.framebuffer,m.color_attachment0,h,g.__webgltexture,0);g(a.__webglrenderbuffer[f],a)}c&&m.generatemipmap(m.texture_cube_map)}else a.__webglframebuffer=m.createframebuffer(),a.__webglrenderbuffer=a.sharedepthfrom?a.sharedepthfrom.__webglrenderbuffer:m.createrenderbuffer(),m.bindtexture(m.texture_2d,a.__webgltexture),a(m.texture_2d,a,c),m.teximage2d(m.texture_2d,0,d,a.width,a.height,0,d,e,null),d=m.texture_2d,m.bindframebuffer(m.framebuffer,a.__webglframebuffer), m.framebuffertexture2d(m.framebuffer,m.color_attachment0,d,a.__webgltexture,0),a.sharedepthfrom?a.depthbuffer&&!a.stencilbuffer?m.framebufferrenderbuffer(m.framebuffer,m.depth_attachment,m.renderbuffer,a.__webglrenderbuffer):a.depthbuffer&&a.stencilbuffer&&m.framebufferrenderbuffer(m.framebuffer,m.depth_stencil_attachment,m.renderbuffer,a.__webglrenderbuffer):g(a.__webglrenderbuffer,a),c&&m.generatemipmap(m.texture_2d);b?m.bindtexture(m.texture_cube_map,null):m.bindtexture(m.texture_2d,null);m.bindrenderbuffer(m.renderbuffer, null);m.bindframebuffer(m.framebuffer,null)}a?(b=b?a.__webglframebuffer[a.activecubeface]:a.__webglframebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=pb,a=qb,d=ib,e=bb);b!==ab&&(m.bindframebuffer(m.framebuffer,b),m.viewport(d,e,c,a),ab=b);xb=c;fc=a};this.readrendertargetpixels=function(a,b,c,d,e,f){if(!(a instanceof three.webglrendertarget))console.error("three.webglrenderer.readrendertargetpixels: rendertarget is not three.webglrendertarget.");else if(a.__webglframebuffer)if(a.format!==three.rgbaformat)console.error("three.webglrenderer.readrendertargetpixels: rendertarget is not in rgba format. readpixels can read only rgba format."); else{var g=!1;a.__webglframebuffer!==ab&&(m.bindframebuffer(m.framebuffer,a.__webglframebuffer),g=!0);m.checkframebufferstatus(m.framebuffer)===m.framebuffer_complete?m.readpixels(b,c,d,e,m.rgba,m.unsigned_byte,f):console.error("three.webglrenderer.readrendertargetpixels: readpixels from rendertarget failed. framebuffer not complete.");g&&m.bindframebuffer(m.framebuffer,ab)}};this.initmaterial=function(){three.warn("three.webglrenderer: .initmaterial() has been removed.")};this.addpreplugin=function(){three.warn("three.webglrenderer: .addpreplugin() has been removed.")}; this.addpostplugin=function(){three.warn("three.webglrenderer: .addpostplugin() has been removed.")};this.updateshadowmap=function(){three.warn("three.webglrenderer: .updateshadowmap() has been removed.")}}; three.webglrendertarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wraps=void 0!==c.wraps?c.wraps:three.clamptoedgewrapping;this.wrapt=void 0!==c.wrapt?c.wrapt:three.clamptoedgewrapping;this.magfilter=void 0!==c.magfilter?c.magfilter:three.linearfilter;this.minfilter=void 0!==c.minfilter?c.minfilter:three.linearmipmaplinearfilter;this.anisotropy=void 0!==c.anisotropy?c.anisotropy:1;this.offset=new three.vector2(0,0);this.repeat=new three.vector2(1,1);this.format=void 0!==c.format?c.format: three.rgbaformat;this.type=void 0!==c.type?c.type:three.unsignedbytetype;this.depthbuffer=void 0!==c.depthbuffer?c.depthbuffer:!0;this.stencilbuffer=void 0!==c.stencilbuffer?c.stencilbuffer:!0;this.generatemipmaps=!0;this.sharedepthfrom=void 0!==c.sharedepthfrom?c.sharedepthfrom:null}; three.webglrendertarget.prototype={constructor:three.webglrendertarget,setsize:function(a,b){this.width=a;this.height=b},clone:function(){var a=new three.webglrendertarget(this.width,this.height);a.wraps=this.wraps;a.wrapt=this.wrapt;a.magfilter=this.magfilter;a.minfilter=this.minfilter;a.anisotropy=this.anisotropy;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthbuffer=this.depthbuffer;a.stencilbuffer=this.stencilbuffer;a.generatemipmaps=this.generatemipmaps; a.sharedepthfrom=this.sharedepthfrom;return a},dispose:function(){this.dispatchevent({type:"dispose"})}};three.eventdispatcher.prototype.apply(three.webglrendertarget.prototype);three.webglrendertargetcube=function(a,b,c){three.webglrendertarget.call(this,a,b,c);this.activecubeface=0};three.webglrendertargetcube.prototype=object.create(three.webglrendertarget.prototype);three.webglrendertargetcube.prototype.constructor=three.webglrendertargetcube; three.webglextensions=function(a){var b={};this.get=function(c){if(void 0!==b[c])return b[c];var d;switch(c){case "ext_texture_filter_anisotropic":d=a.getextension("ext_texture_filter_anisotropic")||a.getextension("moz_ext_texture_filter_anisotropic")||a.getextension("webkit_ext_texture_filter_anisotropic");break;case "webgl_compressed_texture_s3tc":d=a.getextension("webgl_compressed_texture_s3tc")||a.getextension("moz_webgl_compressed_texture_s3tc")||a.getextension("webkit_webgl_compressed_texture_s3tc"); break;case "webgl_compressed_texture_pvrtc":d=a.getextension("webgl_compressed_texture_pvrtc")||a.getextension("webkit_webgl_compressed_texture_pvrtc");break;default:d=a.getextension(c)}null===d&&three.warn("three.webglrenderer: "+c+" extension not supported.");return b[c]=d}}; three.webglprogram=function(){var a=0;return function(b,c,d,e){var f=b.context,g=d.defines,h=d.__webglshader.uniforms,k=d.attributes,l=d.__webglshader.vertexshader,p=d.__webglshader.fragmentshader,q=d.index0attributename;void 0===q&&!0===e.morphtargets&&(q="position");var n="shadowmap_type_basic";e.shadowmaptype===three.pcfshadowmap?n="shadowmap_type_pcf":e.shadowmaptype===three.pcfsoftshadowmap&&(n="shadowmap_type_pcf_soft");var t="envmap_type_cube",r="envmap_mode_reflection",s="envmap_blending_multiply"; if(e.envmap){switch(d.envmap.mapping){case three.cubereflectionmapping:case three.cuberefractionmapping:t="envmap_type_cube";break;case three.equirectangularreflectionmapping:case three.equirectangularrefractionmapping:t="envmap_type_equirec";break;case three.sphericalreflectionmapping:t="envmap_type_sphere"}switch(d.envmap.mapping){case three.cuberefractionmapping:case three.equirectangularrefractionmapping:r="envmap_mode_refraction"}switch(d.combine){case three.multiplyoperation:s="envmap_blending_multiply"; break;case three.mixoperation:s="envmap_blending_mix";break;case three.addoperation:s="envmap_blending_add"}}var u=0l;l++)i[l]=new three.vector3,f[l]=new three.vector3;i=z.shadowcascadenearz[h];z=z.shadowcascadefarz[h];f[0].set(-1,-1,i);f[1].set(1,-1,i);f[2].set(-1,1,i);f[3].set(1,1,i);f[4].set(-1,-1,z);f[5].set(1,-1,z);f[6].set(-1,1,z);f[7].set(1,1,z);m.originalcamera=v;f=new three.gyroscope;f.position.copy(a.shadowcascadeoffset);f.add(m);f.add(m.target);v.add(f);a.shadowcascadearray[g]=m}h=a;i=g;z=h.shadowcascadearray[i];z.position.copy(h.position); z.target.position.copy(h.target.position);z.lookat(z.target);z.shadowcameravisible=h.shadowcameravisible;z.shadowdarkness=h.shadowdarkness;z.shadowbias=h.shadowcascadebias[i];f=h.shadowcascadenearz[i];h=h.shadowcascadefarz[i];z=z.pointsfrustum;z[0].z=f;z[1].z=f;z[2].z=f;z[3].z=f;z[4].z=h;z[5].z=h;z[6].z=h;z[7].z=h;u[e]=m;e++}else u[e]=a,e++;u=0;for(y=u.length;u h;h++)i=z[h],i.copy(f[h]),i.unproject(g),i.applymatrix4(e.matrixworldinverse),i.xt.x&&(t.x=i.x),i.yt.y&&(t.y=i.y),i.zt.z&&(t.z=i.z);e.left=n.x;e.right=t.x;e.top=t.y;e.bottom=n.y;e.updateprojectionmatrix()}e=a.shadowmap;f=a.shadowmatrix;g=a.shadowcamera;g.position.setfrommatrixposition(a.matrixworld);r.setfrommatrixposition(a.target.matrixworld);g.lookat(r);g.updatematrixworld();g.matrixworldinverse.getinverse(g.matrixworld);a.camerahelper&& (a.camerahelper.visible=a.shadowcameravisible);a.shadowcameravisible&&a.camerahelper.update();f.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);f.multiply(g.projectionmatrix);f.multiply(g.matrixworldinverse);q.multiplymatrices(g.projectionmatrix,g.matrixworldinverse);p.setfrommatrix(q);a.setrendertarget(e);a.clear();s.length=0;e(c,c,g);a=0;for(e=s.length;a 0 ) {\nfloat depth = gl_fragcoord.z / gl_fragcoord.w;\nfloat fogfactor = 0.0;\nif ( fogtype == 1 ) {\nfogfactor = smoothstep( fognear, fogfar, depth );\n} else {\nconst float log2 = 1.442695;\nfloat fogfactor = exp2( - fogdensity * fogdensity * depth * depth * log2 );\nfogfactor = 1.0 - clamp( fogfactor, 0.0, 1.0 );\n}\ngl_fragcolor = mix( gl_fragcolor, vec4( fogcolor, gl_fragcolor.w ), fogfactor );\n}\n}"].join("\n")); w.compileshader(l);w.compileshader(p);w.attachshader(h,l);w.attachshader(h,p);w.linkprogram(h);e=h;v=w.getattriblocation(e,"position");x=w.getattriblocation(e,"uv");c=w.getuniformlocation(e,"uvoffset");d=w.getuniformlocation(e,"uvscale");e=w.getuniformlocation(e,"rotation");f=w.getuniformlocation(e,"scale");g=w.getuniformlocation(e,"color");h=w.getuniformlocation(e,"map");k=w.getuniformlocation(e,"opacity");l=w.getuniformlocation(e,"modelviewmatrix");p=w.getuniformlocation(e,"projectionmatrix");q= w.getuniformlocation(e,"fogtype");n=w.getuniformlocation(e,"fogdensity");t=w.getuniformlocation(e,"fognear");r=w.getuniformlocation(e,"fogfar");s=w.getuniformlocation(e,"fogcolor");u=w.getuniformlocation(e,"alphatest");h=document.createelement("canvas");h.width=8;h.height=8;l=h.getcontext("2d");l.fillstyle="white";l.fillrect(0,0,8,8);g=new three.texture(h);g.needsupdate=!0}w.useprogram(e);w.enablevertexattribarray(v);w.enablevertexattribarray(x);w.disable(w.cull_face);w.enable(w.blend);w.bindbuffer(w.array_buffer, y);w.vertexattribpointer(v,2,w.float,!1,16,0);w.vertexattribpointer(x,2,w.float,!1,16,8);w.bindbuffer(w.element_array_buffer,a);w.uniformmatrix4fv(p,!1,m.projectionmatrix.elements);w.activetexture(w.texture0);w.uniform1i(h,0);l=h=0;(p=u.fog)?(w.uniform3f(s,p.color.r,p.color.g,p.color.b),p instanceof three.fog?(w.uniform1f(t,p.near),w.uniform1f(r,p.far),w.uniform1i(q,1),l=h=1):p instanceof three.fogexp2&&(w.uniform1f(n,p.density),w.uniform1i(q,2),l=h=2)):(w.uniform1i(q,0),l=h=0);for(var p=0,n=b.length;p< n;p++){var r=b[p];r._modelviewmatrix.multiplymatrices(m.matrixworldinverse,r.matrixworld);r.z=-r._modelviewmatrix.elements[14]}b.sort(d);for(var v=[],p=0,n=b.length;pq-1?0:q-1,t=q+1>e-1?e-1:q+1,r=0>p-1?0:p-1,s=p+1>d-1?d-1:p+1,u=[],v=[0,0,h[4*(q*d+p)]/255*b];u.push([-1,0,h[4*(q*d+r)]/255*b]);u.push([-1,-1,h[4*(n*d+r)]/255*b]);u.push([0,-1,h[4*(n*d+p)]/255*b]);u.push([1,-1,h[4*(n*d+s)]/255*b]);u.push([1,0,h[4*(q*d+s)]/255*b]);u.push([1,1,h[4*(t*d+s)]/255*b]);u.push([0,1,h[4*(t*d+p)]/255* b]);u.push([-1,1,h[4*(t*d+r)]/255*b]);n=[];r=u.length;for(t=0;te)return null;var f=[],g=[],h=[],k,l,p;if(0=q--){three.warn("three.fontutils: warning, unable to triangulate polygon! in triangulate.process()");break}k=l;e<=k&&(k=0);l=k+1;e<=l&&(l=0);p=l+1;e<=p&&(p=0);var n;a:{var t=n=void 0,r=void 0,s=void 0, u=void 0,v=void 0,x=void 0,d=void 0,w=void 0,t=a[g[k]].x,r=a[g[k]].y,s=a[g[l]].x,u=a[g[l]].y,v=a[g[p]].x,x=a[g[p]].y;if(1e-10>(s-t)*(x-r)-(u-r)*(v-t))n=!1;else{var y=void 0,a=void 0,e=void 0,g=void 0,f=void 0,z=void 0,i=void 0,u=void 0,m=void 0,h=void 0,m=u=i=w=d=void 0,y=v-s,a=x-u,e=t-v,g=r-x,f=s-t,z=u-r;for(n=0;nk)g=d+1;else if(0b&&(b=0);1=b)return b=c[a]-b,a=this.curves[a],b=1-b/a.getlength(),a.getpointat(b);a++}return null};three.curvepath.prototype.getlength=function(){var a=this.getcurvelengths();return a[a.length-1]}; three.curvepath.prototype.getcurvelengths=function(){if(this.cachelengths&&this.cachelengths.length==this.curves.length)return this.cachelengths;var a=[],b=0,c,d=this.curves.length;for(c=0;cb?b=h.x:h.xc?c=h.y:h.yd?d=h.z:h.zmath.abs(d.x-c[0].x)&&1e-10>math.abs(d.y-c[0].y)&&c.splice(c.length-1,1);b&&c.push(c[0]);return c}; three.path.prototype.toshapes=function(a,b){function c(a){for(var b=[],c=0,d=a.length;cn&&(g=b[f],k=-k,h=b[e],n=-n),!(a.yh.y))if(a.y==g.y){if(a.x==g.x)return!0}else{e=n*(a.x-g.x)-k*(a.y-g.y);if(0==e)return!0;0>e||(d=!d)}}else if(a.y==g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<= h.x))return!0}return d}var e=function(a){var b,c,d,e,f=[],g=new three.path;b=0;for(c=a.length;bg||g>e)return[];k=l*p-k*q;if(0>k||k>e)return[]}else{if(0d?[]:k==d?f?[]:[g]:a<=d?[g,h]: [g,l]}function e(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return 1e-10f&&(f=d);var g=a+1;g>d&&(g=0);d=e(h[a],h[f],h[g],k[b]); if(!d)return!1;d=k.length-1;f=b-1;0>f&&(f=d);g=b+1;g>d&&(g=0);return(d=e(k[b],k[f],k[g],h[a]))?!0:!1}function f(a,b){var c,e;for(c=0;c h){console.log("infinite loop! holes left:"+l.length+", probably hole outside shape!");break}for(q=z;qh;h++)l=k[h].x+":"+k[h].y,l=p[l],void 0!==l&&(k[h]=l);return q.concat()},isclockwise:function(a){return 0>three.fontutils.triangulate.area(a)},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a* a*a*b},b3:function(a,b,c,d,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+this.b3p3(a,e)}};three.linecurve=function(a,b){this.v1=a;this.v2=b};three.linecurve.prototype=object.create(three.curve.prototype);three.linecurve.prototype.constructor=three.linecurve;three.linecurve.prototype.getpoint=function(a){var b=this.v2.clone().sub(this.v1);b.multiplyscalar(a).add(this.v1);return b};three.linecurve.prototype.getpointat=function(a){return this.getpoint(a)}; three.linecurve.prototype.gettangent=function(a){return this.v2.clone().sub(this.v1).normalize()};three.quadraticbeziercurve=function(a,b,c){this.v0=a;this.v1=b;this.v2=c};three.quadraticbeziercurve.prototype=object.create(three.curve.prototype);three.quadraticbeziercurve.prototype.constructor=three.quadraticbeziercurve; three.quadraticbeziercurve.prototype.getpoint=function(a){var b=new three.vector2;b.x=three.shape.utils.b2(a,this.v0.x,this.v1.x,this.v2.x);b.y=three.shape.utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return b};three.quadraticbeziercurve.prototype.gettangent=function(a){var b=new three.vector2;b.x=three.curve.utils.tangentquadraticbezier(a,this.v0.x,this.v1.x,this.v2.x);b.y=three.curve.utils.tangentquadraticbezier(a,this.v0.y,this.v1.y,this.v2.y);return b.normalize()}; three.cubicbeziercurve=function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d};three.cubicbeziercurve.prototype=object.create(three.curve.prototype);three.cubicbeziercurve.prototype.constructor=three.cubicbeziercurve;three.cubicbeziercurve.prototype.getpoint=function(a){var b;b=three.shape.utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=three.shape.utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new three.vector2(b,a)}; three.cubicbeziercurve.prototype.gettangent=function(a){var b;b=three.curve.utils.tangentcubicbezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=three.curve.utils.tangentcubicbezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=new three.vector2(b,a);b.normalize();return b};three.splinecurve=function(a){this.points=void 0==a?[]:a};three.splinecurve.prototype=object.create(three.curve.prototype);three.splinecurve.prototype.constructor=three.splinecurve; three.splinecurve.prototype.getpoint=function(a){var b=this.points;a*=b.length-1;var c=math.floor(a);a-=c;var d=b[0==c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=new three.vector2;c.x=three.curve.utils.interpolate(d.x,e.x,f.x,b.x,a);c.y=three.curve.utils.interpolate(d.y,e.y,f.y,b.y,a);return c};three.ellipsecurve=function(a,b,c,d,e,f,g){this.ax=a;this.ay=b;this.xradius=c;this.yradius=d;this.astartangle=e;this.aendangle=f;this.aclockwise=g}; three.ellipsecurve.prototype=object.create(three.curve.prototype);three.ellipsecurve.prototype.constructor=three.ellipsecurve;three.ellipsecurve.prototype.getpoint=function(a){var b=this.aendangle-this.astartangle;0>b&&(b+=2*math.pi);b>2*math.pi&&(b-=2*math.pi);a=!0===this.aclockwise?this.aendangle+(1-a)*(2*math.pi-b):this.astartangle+a*b;b=new three.vector2;b.x=this.ax+this.xradius*math.cos(a);b.y=this.ay+this.yradius*math.sin(a);return b}; three.arccurve=function(a,b,c,d,e,f){three.ellipsecurve.call(this,a,b,c,c,d,e,f)};three.arccurve.prototype=object.create(three.ellipsecurve.prototype);three.arccurve.prototype.constructor=three.arccurve;three.linecurve3=three.curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new three.vector3;b.subvectors(this.v2,this.v1);b.multiplyscalar(a);b.add(this.v1);return b}); three.quadraticbeziercurve3=three.curve.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b=new three.vector3;b.x=three.shape.utils.b2(a,this.v0.x,this.v1.x,this.v2.x);b.y=three.shape.utils.b2(a,this.v0.y,this.v1.y,this.v2.y);b.z=three.shape.utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return b}); three.cubicbeziercurve3=three.curve.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b=new three.vector3;b.x=three.shape.utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b.y=three.shape.utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b.z=three.shape.utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return b}); three.splinecurve3=three.curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=this.points;a*=b.length-1;var c=math.floor(a);a-=c;var d=b[0==c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=new three.vector3;c.x=three.curve.utils.interpolate(d.x,e.x,f.x,b.x,a);c.y=three.curve.utils.interpolate(d.y,e.y,f.y,b.y,a);c.z=three.curve.utils.interpolate(d.z,e.z,f.z,b.z,a);return c}); three.closedsplinecurve3=three.curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=this.points;a*=b.length-0;var c=math.floor(a);a-=c;var c=c+(0a.hierarchy[b].keys[c].time&&(a.hierarchy[b].keys[c].time= 0),void 0!==a.hierarchy[b].keys[c].rot&&!(a.hierarchy[b].keys[c].rot instanceof three.quaternion)){var d=a.hierarchy[b].keys[c].rot;a.hierarchy[b].keys[c].rot=(new three.quaternion).fromarray(d)}if(a.hierarchy[b].keys.length&&void 0!==a.hierarchy[b].keys[0].morphtargets){d={};for(c=0;cc;c++){for(var d=this.keytypes[c],e=this.data.hierarchy[a].keys[0],g=this.getnextkeywith(d,a,1);g.timee.index;)e=g,g=this.getnextkeywith(d,a,g.index+1);f.prevkey[d]=e;f.nextkey[d]=g}}},resetblendweights:function(){for(var a=0,b=this.hierarchy.length;aa.length-2?q:q+1;c[3]=q>a.length-3?q:q+2;q=a[c[0]];t=a[c[1]];r=a[c[2]];s=a[c[3]];c=e*e;n=e*c;d[0]=f(q[0],t[0],r[0],s[0],e,c,n);d[1]=f(q[1],t[1],r[1],s[1],e,c,n);d[2]=f(q[2],t[2],r[2],s[2],e,c,n);return d},f=function(a,b,c,d, e,f,n){a=.5*(c-a);d=.5*(d-b);return(2*(b-c)+a+d)*n+(-3*(b-c)-2*a-d)*f+a*e+b};return function(f){if(!1!==this.isplaying&&(this.currenttime+=f*this.timescale,0!==this.weight)){f=this.data.length;if(this.currenttime>f||0>this.currenttime)this.loop?(this.currenttime%=f,0>this.currenttime&&(this.currenttime+=f),this.reset()):this.stop();f=0;for(var h=this.hierarchy.length;fq;q++){var n=this.keytypes[q], t=l.prevkey[n],r=l.nextkey[n];if(0this.timescale&&t.time>=this.currenttime){t=this.data.hierarchy[f].keys[0];for(r=this.getnextkeywith(n,f,1);r.timet.index;)t=r,r=this.getnextkeywith(n,f,r.index+1);l.prevkey[n]=t;l.nextkey[n]=r}var s=(this.currenttime-t.time)/(r.time-t.time),u=t[n],v=r[n];0>s&&(s=0);1a&&(this.currenttime%=a);this.currenttime=math.min(this.currenttime,a);a=0;for(var b=this.hierarchy.length;af.index;)f=g,g=e[f.index+1];d.prevkey=f;d.nextkey=g}g.time>=this.currenttime?f.interpolate(g,this.currenttime): f.interpolate(g,g.time);this.data.hierarchy[a].node.updatematrix();c.matrixworldneedsupdate=!0}}}},getnextkeywith:function(a,b,c){b=this.data.hierarchy[b].keys;for(c%=b.length;cthis.duration&&(this.currenttime%=this.duration);this.currenttime=math.min(this.currenttime,this.duration);a=this.duration/this.frames;var b=math.floor(this.currenttime/a),c=this.mesh.morphtargetinfluences;b!=this.currentframe&&(c[this.lastframe]=0,c[this.currentframe]= 1,c[b]=0,this.lastframe=this.currentframe,this.currentframe=b);c[b]=this.currenttime%a/a;c[this.lastframe]=1-c[b]}}}; three.boxgeometry=function(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,s){var u,v=h.widthsegments,x=h.heightsegments,d=e/2,w=f/2,y=h.vertices.length;if("x"===a&&"y"===b||"y"===a&&"x"===b)u="z";else if("x"===a&&"z"===b||"z"===a&&"x"===b)u="y",x=h.depthsegments;else if("z"===a&&"y"===b||"y"===a&&"z"===b)u="x",v=h.depthsegments;var a=v+1,e=x+1,g=e/v,f=f/x,z=new three.vector3;z[u]=0=d)return new three.vector2(c,a);d=math.sqrt(d/2)}else a=!1,1e-10d?-1e-10>f&&(a=!0):math.sign(e)==math.sign(g)&&(a=!0),a?(c=-e,a=d,d=math.sqrt(h)):(c=d,a=e,d=math.sqrt(h/2));return new three.vector2(c/d,a/d)}function e(a,b){var c,d;for(o=a.length;0<=--o;){c=o;d=o-1;0>d&&(d=a.length-1);for(var e=0,f=t+2*p,e=0;emath.abs(b.y-c.y)?[new three.vector2(b.x,1-b.z),new three.vector2(c.x,1-c.z),new three.vector2(d.x,1-d.z),new three.vector2(e.x,1-e.z)]:[new three.vector2(b.y,1-b.z),new three.vector2(c.y,1-c.z),new three.vector2(d.y, 1-d.z),new three.vector2(e.y,1-e.z)]}};three.shapegeometry=function(a,b){three.geometry.call(this);this.type="shapegeometry";!1===a instanceof array&&(a=[a]);this.addshapelist(a,b);this.computefacenormals()};three.shapegeometry.prototype=object.create(three.geometry.prototype);three.shapegeometry.prototype.constructor=three.shapegeometry;three.shapegeometry.prototype.addshapelist=function(a,b){for(var c=0,d=a.length;cc&&1===a.x&&(a=new three.vector2(a.x-1,a.y));0===b.x&&0===b.z&&(a=new three.vector2(c/2/math.pi+.5,a.y));return a.clone()} three.geometry.call(this);this.type="polyhedrongeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};c=c||1;d=d||0;for(var k=this,l=0,p=a.length;lt&&(.2>d&&(b[0].x+=1),.2>a&&(b[1].x+=1),.2>q&&(b[2].x+=1));l=0;for(p=this.vertices.length;lc.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=math.acos(c.y),this.quaternion.setfromaxisangle(a,b))}}();three.arrowhelper.prototype.setlength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,a-b,1);this.line.updatematrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updatematrix()}; three.arrowhelper.prototype.setcolor=function(a){this.line.material.color.set(a);this.cone.material.color.set(a)};three.boxhelper=function(a){var b=new three.buffergeometry;b.addattribute("position",new three.bufferattribute(new float32array(72),3));three.line.call(this,b,new three.linebasicmaterial({color:16776960}),three.linepieces);void 0!==a&&this.update(a)};three.boxhelper.prototype=object.create(three.line.prototype);three.boxhelper.prototype.constructor=three.boxhelper; three.boxhelper.prototype.update=function(a){var b=a.geometry;null===b.boundingbox&&b.computeboundingbox();var c=b.boundingbox.min,b=b.boundingbox.max,d=this.geometry.attributes.position.array;d[0]=b.x;d[1]=b.y;d[2]=b.z;d[3]=c.x;d[4]=b.y;d[5]=b.z;d[6]=c.x;d[7]=b.y;d[8]=b.z;d[9]=c.x;d[10]=c.y;d[11]=b.z;d[12]=c.x;d[13]=c.y;d[14]=b.z;d[15]=b.x;d[16]=c.y;d[17]=b.z;d[18]=b.x;d[19]=c.y;d[20]=b.z;d[21]=b.x;d[22]=b.y;d[23]=b.z;d[24]=b.x;d[25]=b.y;d[26]=c.z;d[27]=c.x;d[28]=b.y;d[29]=c.z;d[30]=c.x;d[31]=b.y; d[32]=c.z;d[33]=c.x;d[34]=c.y;d[35]=c.z;d[36]=c.x;d[37]=c.y;d[38]=c.z;d[39]=b.x;d[40]=c.y;d[41]=c.z;d[42]=b.x;d[43]=c.y;d[44]=c.z;d[45]=b.x;d[46]=b.y;d[47]=c.z;d[48]=b.x;d[49]=b.y;d[50]=b.z;d[51]=b.x;d[52]=b.y;d[53]=c.z;d[54]=c.x;d[55]=b.y;d[56]=b.z;d[57]=c.x;d[58]=b.y;d[59]=c.z;d[60]=c.x;d[61]=c.y;d[62]=b.z;d[63]=c.x;d[64]=c.y;d[65]=c.z;d[66]=b.x;d[67]=c.y;d[68]=b.z;d[69]=b.x;d[70]=c.y;d[71]=c.z;this.geometry.attributes.position.needsupdate=!0;this.geometry.computeboundingsphere();this.matrix=a.matrixworld; this.matrixautoupdate=!1};three.boundingboxhelper=function(a,b){var c=void 0!==b?b:8947848;this.object=a;this.box=new three.box3;three.mesh.call(this,new three.boxgeometry(1,1,1),new three.meshbasicmaterial({color:c,wireframe:!0}))};three.boundingboxhelper.prototype=object.create(three.mesh.prototype);three.boundingboxhelper.prototype.constructor=three.boundingboxhelper;three.boundingboxhelper.prototype.update=function(){this.box.setfromobject(this.object);this.box.size(this.scale);this.box.center(this.position)}; three.camerahelper=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.vertices.push(new three.vector3);d.colors.push(new three.color(b));void 0===f[a]&&(f[a]=[]);f[a].push(d.vertices.length-1)}var d=new three.geometry,e=new three.linebasicmaterial({color:16777215,vertexcolors:three.facecolors}),f={};b("n1","n2",16755200);b("n2","n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200); b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680);b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1","cf2",3355443);b("cf3","cf4",3355443);three.line.call(this,d,e,three.linepieces);this.camera=a;this.matrix=a.matrixworld;this.matrixautoupdate=!1;this.pointmap=f;this.update()}; three.camerahelper.prototype=object.create(three.line.prototype);three.camerahelper.prototype.constructor=three.camerahelper; three.camerahelper.prototype.update=function(){var a,b,c=new three.vector3,d=new three.camera,e=function(e,g,h,k){c.set(g,h,k).unproject(d);e=b[e];if(void 0!==e)for(g=0,h=e.length;gr;r++){d[0]=t[g[r]];d[1]=t[g[(r+1)%3]];d.sort(f);var s=d.tostring(); void 0===e[s]?(e[s]={vert1:d[0],vert2:d[1],face1:q,face2:void 0},p++):e[s].face2=q}d=new float32array(6*p);f=0;for(s in e)if(g=e[s],void 0===g.face2||k[g.face1].normal.dot(k[g.face2].normal)<=c)p=l[g.vert1],d[f++]=p.x,d[f++]=p.y,d[f++]=p.z,p=l[g.vert2],d[f++]=p.x,d[f++]=p.y,d[f++]=p.z;h.addattribute("position",new three.bufferattribute(d,3));three.line.call(this,h,new three.linebasicmaterial({color:b}),three.linepieces);this.matrix=a.matrixworld;this.matrixautoupdate=!1}; three.edgeshelper.prototype=object.create(three.line.prototype);three.edgeshelper.prototype.constructor=three.edgeshelper; three.facenormalshelper=function(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16776960;d=void 0!==d?d:1;b=new three.geometry;c=0;for(var e=this.object.geometry.faces.length;cd;d++)c.faces[d].color=this.colors[4>d?0:1];d=new three.meshbasicmaterial({vertexcolors:three.facecolors,wireframe:!0});this.lightsphere=new three.mesh(c,d);this.add(this.lightsphere); this.update()};three.hemispherelighthelper.prototype=object.create(three.object3d.prototype);three.hemispherelighthelper.prototype.constructor=three.hemispherelighthelper;three.hemispherelighthelper.prototype.dispose=function(){this.lightsphere.geometry.dispose();this.lightsphere.material.dispose()}; three.hemispherelighthelper.prototype.update=function(){var a=new three.vector3;return 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(a.setfrommatrixposition(this.light.matrixworld).negate());this.lightsphere.geometry.colorsneedupdate=!0}}(); three.pointlighthelper=function(a,b){this.light=a;this.light.updatematrixworld();var c=new three.spheregeometry(b,4,2),d=new three.meshbasicmaterial({wireframe:!0,fog:!1});d.color.copy(this.light.color).multiplyscalar(this.light.intensity);three.mesh.call(this,c,d);this.matrix=this.light.matrixworld;this.matrixautoupdate=!1};three.pointlighthelper.prototype=object.create(three.mesh.prototype);three.pointlighthelper.prototype.constructor=three.pointlighthelper; three.pointlighthelper.prototype.dispose=function(){this.geometry.dispose();this.material.dispose()};three.pointlighthelper.prototype.update=function(){this.material.color.copy(this.light.color).multiplyscalar(this.light.intensity)}; three.skeletonhelper=function(a){this.bones=this.getbonelist(a);for(var b=new three.geometry,c=0;cs;s++){d[0]=r[g[s]];d[1]=r[g[(s+1)%3]];d.sort(f);var u=d.tostring();void 0===e[u]&&(q[2*p]=d[0],q[2*p+1]=d[1],e[u]=!0,p++)}d=new float32array(6*p);n=0;for(t=p;ns;s++)p= k[q[2*n+s]],g=6*n+3*s,d[g+0]=p.x,d[g+1]=p.y,d[g+2]=p.z;h.addattribute("position",new three.bufferattribute(d,3))}else if(a.geometry instanceof three.buffergeometry){if(void 0!==a.geometry.attributes.index){k=a.geometry.attributes.position.array;t=a.geometry.attributes.index.array;l=a.geometry.drawcalls;p=0;0===l.length&&(l=[{count:t.length,index:0,start:0}]);for(var q=new uint32array(2*t.length),r=0,v=l.length;rs;s++)d[0]= g+t[n+s],d[1]=g+t[n+(s+1)%3],d.sort(f),u=d.tostring(),void 0===e[u]&&(q[2*p]=d[0],q[2*p+1]=d[1],e[u]=!0,p++);d=new float32array(6*p);n=0;for(t=p;ns;s++)g=6*n+3*s,p=3*q[2*n+s],d[g+0]=k[p],d[g+1]=k[p+1],d[g+2]=k[p+2]}else for(k=a.geometry.attributes.position.array,p=k.length/3,q=p/3,d=new float32array(6*p),n=0,t=q;ns;s++)g=18*n+6*s,q=9*n+3*s,d[g+0]=k[q],d[g+1]=k[q+1],d[g+2]=k[q+2],p=9*n+(s+1)%3*3,d[g+3]=k[p],d[g+4]=k[p+1],d[g+5]=k[p+2];h.addattribute("position",new three.bufferattribute(d, 3))}three.line.call(this,h,new three.linebasicmaterial({color:c}),three.linepieces);this.matrix=a.matrixworld;this.matrixautoupdate=!1};three.wireframehelper.prototype=object.create(three.line.prototype);three.wireframehelper.prototype.constructor=three.wireframehelper;three.immediaterenderobject=function(){three.object3d.call(this);this.render=function(a){}};three.immediaterenderobject.prototype=object.create(three.object3d.prototype);three.immediaterenderobject.prototype.constructor=three.immediaterenderobject; three.morphblendmesh=function(a,b){three.mesh.call(this,a,b);this.animationsmap={};this.animationslist=[];var c=this.geometry.morphtargets.length;this.createanimation("__default",0,c-1,c/1);this.setanimationweight("__default",1)};three.morphblendmesh.prototype=object.create(three.mesh.prototype);three.morphblendmesh.prototype.constructor=three.morphblendmesh; three.morphblendmesh.prototype.createanimation=function(a,b,c,d){b={startframe:b,endframe:c,length:c-b+1,fps:d,duration:(c-b)/d,lastframe:0,currentframe:0,active:!1,time:0,direction:1,weight:1,directionbackwards:!1,mirroredloop:!1};this.animationsmap[a]=b;this.animationslist.push(b)}; three.morphblendmesh.prototype.autocreateanimations=function(a){for(var b=/([a-z]+)_?(\d+)/,c,d={},e=this.geometry,f=0,g=e.morphtargets.length;fh.end&&(h.end=f);c||(c=k)}}for(k in d)h=d[k],this.createanimation(k,h.start,h.end,a);this.firstanimation=c}; three.morphblendmesh.prototype.setanimationdirectionforward=function(a){if(a=this.animationsmap[a])a.direction=1,a.directionbackwards=!1};three.morphblendmesh.prototype.setanimationdirectionbackward=function(a){if(a=this.animationsmap[a])a.direction=-1,a.directionbackwards=!0};three.morphblendmesh.prototype.setanimationfps=function(a,b){var c=this.animationsmap[a];c&&(c.fps=b,c.duration=(c.end-c.start)/c.fps)}; three.morphblendmesh.prototype.setanimationduration=function(a,b){var c=this.animationsmap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)};three.morphblendmesh.prototype.setanimationweight=function(a,b){var c=this.animationsmap[a];c&&(c.weight=b)};three.morphblendmesh.prototype.setanimationtime=function(a,b){var c=this.animationsmap[a];c&&(c.time=b)};three.morphblendmesh.prototype.getanimationtime=function(a){var b=0;if(a=this.animationsmap[a])b=a.time;return b}; three.morphblendmesh.prototype.getanimationduration=function(a){var b=-1;if(a=this.animationsmap[a])b=a.duration;return b};three.morphblendmesh.prototype.playanimation=function(a){var b=this.animationsmap[a];b?(b.time=0,b.active=!0):three.warn("three.morphblendmesh: animation["+a+"] undefined in .playanimation()")};three.morphblendmesh.prototype.stopanimation=function(a){if(a=this.animationsmap[a])a.active=!1}; three.morphblendmesh.prototype.update=function(a){for(var b=0,c=this.animationslist.length;bd.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionbackwards=!0),0>d.time&&(d.time=0,d.directionbackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.startframe+three.math.clamp(math.floor(d.time/e),0,d.length-1),g=d.weight; f!==d.currentframe&&(this.morphtargetinfluences[d.lastframe]=0,this.morphtargetinfluences[d.currentframe]=1*g,this.morphtargetinfluences[f]=0,d.lastframe=d.currentframe,d.currentframe=f);e=d.time%e/e;d.directionbackwards&&(e=1-e);this.morphtargetinfluences[d.currentframe]=e*g;this.morphtargetinfluences[d.lastframe]=(1-e)*g}}};