// three.js - http://github.com/mrdoob/three.js 'use strict';var three=three||{revision:"56"};self.console=self.console||{info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}};self.int32array=self.int32array||array;self.float32array=self.float32array||array;string.prototype.trim=string.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")}; three.extend=function(a,b){if(object.keys)for(var c=object.keys(b),d=0,e=c.length;d>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},sethsv:function(a,b,c){console.log("deprecated: color's .sethsv() will be removed. use .sethsl( h, s, l ) instead.");return this.sethsl(a,b*c/(1>(a=(2-b)*c)?a:2-a),a/2)},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=0.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){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copylineartogamma:function(a){this.r=math.sqrt(a.r);this.g=math.sqrt(a.g);this.b=math.sqrt(a.b);return this},convertgammatolinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertlineartogamma:function(){this.r=math.sqrt(this.r);this.g=math.sqrt(this.g);this.b=math.sqrt(this.b);return this},gethex:function(){return 255* this.r<<16^255*this.g<<8^255*this.b<<0},gethexstring:function(){return("000000"+this.gethex().tostring(16)).slice(-6)},gethsl:function(){var a={h:0,s:0,l:0};return function(){var b=this.r,c=this.g,d=this.b,e=math.max(b,c,d),f=math.min(b,c,d),g,h=(f+e)/2;if(f===e)f=g=0;else{var i=e-f,f=0.5>=h?i/(e+f):i/(2-e-f);switch(e){case b:g=(c-d)/i+(cf&&c>b?(c=2*math.sqrt(1+c-f-b),this.w=(i-g)/c,this.x=0.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=0.25*c,this.z=(g+i)/c):(c=2*math.sqrt(1+b-c-f),this.w=(e-a)/c,this.x=(d+h)/c,this.y=(g+i)/c,this.z=0.25*c);return this},inverse:function(){this.conjugate().normalize(); return this},conjugate:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},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);return this},multiply:function(a,b){return void 0!==b?(console.warn("deprecated: quaternion's .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,i=b.z,k=b.w;this.x=c*k+f*g+d*i-e*h;this.y=d*k+f*h+e*g-c*i;this.z=e*k+f*i+c*h-d*g;this.w=f*k-c*g-d*h-e*i;return this},multiplyvector3:function(a){console.warn("deprecated: quaternion's .multiplyvector3() has been removed. use is now vector.applyquaternion( quaternion ) instead.");return a.applyquaternion(this)},slerp:function(a,b){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),i=math.sqrt(1-g*g);if(0.001>math.abs(i))return this.w=0.5*(f+this.w),this.x=0.5*(c+this.x),this.y=0.5*(d+this.y),this.z=0.5*(e+this.z),this;g=math.sin((1-b)*h)/i;h=math.sin(b*h)/i;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;return this},equals:function(a){return a.x===this.x&&a.y=== this.y&&a.z===this.z&&a.w===this.w},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.extend(three.vector2.prototype,{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 console.warn("deprecated: vector2's .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},addvectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addscalar:function(a){this.x+=a;this.y+=a;return this},sub:function(a,b){if(void 0!==b)return console.warn("deprecated: vector2's .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}, subvectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyscalar:function(a){this.x*=a;this.y*=a;return this},dividescalar:function(a){0!==a?(this.x/=a,this.y/=a):this.set(0,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},negate:function(){return this.multiplyscalar(-1)}, 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},equals:function(a){return a.x===this.x&&a.y===this.y},toarray:function(){return[this.x,this.y]},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.extend(three.vector3.prototype,{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 console.warn("deprecated: vector3's .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 console.warn("deprecated: vector3's .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},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 console.warn("deprecated: vector3's .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},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,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,h=a*b+f*d-g*c,i=a*c+g*b-e*d,k=a*d+e*c-f*b,b=-e*b-f*c-g*d;this.x=h*a+b*-e+i*-g-k*-f;this.y=i*a+b*-f+k*-e-h*-g;this.z=k*a+b*-g+h*-f-i*-e;return this},applyeuler:function(){var a=new three.quaternion;return function(b,c){var d=a.setfromeuler(b,c);this.applyquaternion(d);return this}}(),applyaxisangle:function(){var a= new three.quaternion;return function(b,c){var d=a.setfromaxisangle(b,c);this.applyquaternion(d);return this}}(),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?(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},negate:function(){return this.multiplyscalar(-1)},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},cross:function(a,b){if(void 0!==b)return console.warn("deprecated: vector3's .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){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},projectonvector:function(){var a=new three.vector3;return function(b){a.copy(b).normalize();b=this.dot(a);return this.copy(a).multiplyscalar(b)}}(),projectonplane:function(){var a=new three.vector3;return function(b){a.copy(this).projectonvector(b);return this.sub(a)}}(), reflect:function(){var a=new three.vector3;return function(b){a.copy(this).projectonvector(b).multiplyscalar(2);return this.subvectors(a,this)}}(),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},getpositionfrommatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14]; return this},seteulerfromrotationmatrix:function(a,b){function c(a){return math.min(math.max(a,-1),1)}var d=a.elements,e=d[0],f=d[4],g=d[8],h=d[1],i=d[5],k=d[9],l=d[2],m=d[6],d=d[10];void 0===b||"xyz"===b?(this.y=math.asin(c(g)),0.99999>math.abs(g)?(this.x=math.atan2(-k,d),this.z=math.atan2(-f,e)):(this.x=math.atan2(m,i),this.z=0)):"yxz"===b?(this.x=math.asin(-c(k)),0.99999>math.abs(k)?(this.y=math.atan2(g,d),this.z=math.atan2(h,i)):(this.y=math.atan2(-l,e),this.z=0)):"zxy"===b?(this.x=math.asin(c(m)), 0.99999>math.abs(m)?(this.y=math.atan2(-l,d),this.z=math.atan2(-f,i)):(this.y=0,this.z=math.atan2(h,e))):"zyx"===b?(this.y=math.asin(-c(l)),0.99999>math.abs(l)?(this.x=math.atan2(m,d),this.z=math.atan2(h,e)):(this.x=0,this.z=math.atan2(-f,i))):"yzx"===b?(this.z=math.asin(c(h)),0.99999>math.abs(h)?(this.x=math.atan2(-k,i),this.y=math.atan2(-l,e)):(this.x=0,this.y=math.atan2(g,d))):"xzy"===b&&(this.z=math.asin(-c(f)),0.99999>math.abs(f)?(this.x=math.atan2(m,i),this.y=math.atan2(g,e)):(this.x=math.atan2(-k, d),this.y=0));return this},seteulerfromquaternion:function(a,b){function c(a){return math.min(math.max(a,-1),1)}var d=a.x*a.x,e=a.y*a.y,f=a.z*a.z,g=a.w*a.w;void 0===b||"xyz"===b?(this.x=math.atan2(2*(a.x*a.w-a.y*a.z),g-d-e+f),this.y=math.asin(c(2*(a.x*a.z+a.y*a.w))),this.z=math.atan2(2*(a.z*a.w-a.x*a.y),g+d-e-f)):"yxz"===b?(this.x=math.asin(c(2*(a.x*a.w-a.y*a.z))),this.y=math.atan2(2*(a.x*a.z+a.y*a.w),g-d-e+f),this.z=math.atan2(2*(a.x*a.y+a.z*a.w),g-d+e-f)):"zxy"===b?(this.x=math.asin(c(2*(a.x*a.w+ a.y*a.z))),this.y=math.atan2(2*(a.y*a.w-a.z*a.x),g-d-e+f),this.z=math.atan2(2*(a.z*a.w-a.x*a.y),g-d+e-f)):"zyx"===b?(this.x=math.atan2(2*(a.x*a.w+a.z*a.y),g-d-e+f),this.y=math.asin(c(2*(a.y*a.w-a.x*a.z))),this.z=math.atan2(2*(a.x*a.y+a.z*a.w),g+d-e-f)):"yzx"===b?(this.x=math.atan2(2*(a.x*a.w-a.z*a.y),g-d+e-f),this.y=math.atan2(2*(a.y*a.w-a.x*a.z),g+d-e-f),this.z=math.asin(c(2*(a.x*a.y+a.z*a.w)))):"xzy"===b&&(this.x=math.atan2(2*(a.x*a.w+a.y*a.z),g-d+e-f),this.y=math.atan2(2*(a.x*a.z+a.y*a.w),g+d- e-f),this.z=math.asin(c(2*(a.z*a.w-a.x*a.y))));return this},getscalefrommatrix: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},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},toarray:function(){return[this.x,this.y,this.z]},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.extend(three.vector4.prototype,{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 console.warn("deprecated: vector4's .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 console.warn("deprecated: vector4's .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},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?(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,e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],i=a[9];c=a[2];b=a[6];var k=a[10];if(0.01>math.abs(d-g)&&0.01>math.abs(f-c)&&0.01>math.abs(i-b)){if(0.1>math.abs(d+g)&&0.1>math.abs(f+c)&&0.1>math.abs(i+b)&&0.1>math.abs(e+h+k-3))return this.set(1,0,0,0),this;a=math.pi;e=(e+1)/2;h=(h+1)/2;k=(k+1)/2;d=(d+g)/4;f=(f+c)/4;i=(i+b)/4;e>h&&e>k?0.01>e?(b=0,d=c=0.707106781):(b=math.sqrt(e),c=d/b,d=f/b):h>k?0.01>h?(b=0.707106781,c=0,d=0.707106781):(c=math.sqrt(h), b=d/c,d=i/c):0.01>k?(c=b=0.707106781,d=0):(d=math.sqrt(k),b=f/d,c=i/d);this.set(b,c,d,a);return this}a=math.sqrt((b-i)*(b-i)+(f-c)*(f-c)+(g-d)*(g-d));0.001>math.abs(a)&&(a=1);this.x=(b-i)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=math.acos((e+h+k-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},negate:function(){return this.multiplyscalar(-1)},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},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},toarray:function(){return[this.x, this.y,this.z,this.w]},clone:function(){return new three.vector4(this.x,this.y,this.z,this.w)}});three.line3=function(a,b){this.start=void 0!==a?a:new three.vector3;this.end=void 0!==b?b:new three.vector3}; three.extend(three.line3.prototype,{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(0.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.extend(three.box2.prototype,{set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setfrompoints:function(a){if(0this.max.x&&(this.max.x=b.x),b.ythis.max.y&&(this.max.y=b.y)}else this.makeempty();return this},setfromcenterandsize:function(){var a=new three.vector2;return function(b,c){var d=a.copy(c).multiplyscalar(0.5);this.min.copy(b).sub(d); this.max.copy(b).add(d);return this}}(),copy:function(a){this.min.copy(a.min);this.max.copy(a.max);return this},makeempty:function(){this.min.x=this.min.y=infinity;this.max.x=this.max.y=-infinity;return this},empty:function(){return this.max.xthis.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){return new three.vector2((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.ythis.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.extend(three.box3.prototype,{set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setfrompoints:function(a){if(0this.max.x&&(this.max.x=b.x),b.ythis.max.y&&(this.max.y=b.y),b.zthis.max.z&&(this.max.z=b.z)}else this.makeempty();return this},setfromcenterandsize:function(){var a=new three.vector3; return function(b,c){var d=a.copy(c).multiplyscalar(0.5);this.min.copy(b).sub(d);this.max.copy(b).add(d);return this}}(),copy:function(a){this.min.copy(a.min);this.max.copy(a.max);return this},makeempty:function(){this.min.x=this.min.y=this.min.z=infinity;this.max.x=this.max.y=this.max.z=-infinity;return this},empty:function(){return this.max.xthis.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){return new three.vector3((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=0.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(a,b,c,d,e,f,g,h,i){this.elements=new float32array(9);this.set(void 0!==a?a:1,b||0,c||0,d||0,void 0!==e?e:1,f||0,g||0,h||0,void 0!==i?i:1)}; three.extend(three.matrix3.prototype,{set:function(a,b,c,d,e,f,g,h,i){var k=this.elements;k[0]=a;k[3]=b;k[6]=c;k[1]=d;k[4]=e;k[7]=f;k[2]=g;k[5]=h;k[8]=i;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],a[8]);return this},multiplyvector3:function(a){console.warn("deprecated: matrix3's .multiplyvector3() has been removed. use vector.applymatrix3( matrix ) instead.");return a.applymatrix3(this)},multiplyvector3array:function(){var a= new three.vector3;return function(b){for(var c=0,d=b.length;c=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.extend(three.frustum.prototype,{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],d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],i=c[6],k=c[7],l=c[8],m=c[9],n=c[10],s=c[11],r=c[12],p=c[13],q=c[14],c=c[15];b[0].setcomponents(f-a,k-g,s-l,c-r).normalize();b[1].setcomponents(f+ a,k+g,s+l,c+r).normalize();b[2].setcomponents(f+d,k+h,s+m,c+p).normalize();b[3].setcomponents(f-d,k-h,s-m,c-p).normalize();b[4].setcomponents(f-e,k-i,s-n,c-q).normalize();b[5].setcomponents(f+e,k+i,s+n,c+q).normalize();return this},intersectsobject:function(){var a=new three.vector3;return function(b){var c=b.matrixworld,d=this.planes,b=-b.geometry.boundingsphere.radius*c.getmaxscaleonaxis();a.getpositionfrommatrix(c);for(c=0;6>c;c++)if(d[c].distancetopoint(a)d;d++)if(b[d].distancetopoint(c)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.extend(three.plane.prototype,{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||1c?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 a+math.floor(math.random()*(b-a+1))},randfloat:function(a, b){return a+math.random()*(b-a)},randfloatspread:function(a){return a*(0.5-math.random())},sign:function(a){return 0>a?-1:0this.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1: f+2;k=this.points[c[0]];l=this.points[c[1]];m=this.points[c[2]];n=this.points[c[3]];h=g*g;i=g*h;d.x=b(k.x,l.x,m.x,n.x,g,h,i);d.y=b(k.y,l.y,m.y,n.y,g,h,i);d.z=b(k.z,l.z,m.z,n.z,g,h,i);return d};this.getcontrolpointsarray=function(){var a,b,c=this.points.length,d=[];for(a=0;a=b.x+b.y}}(); three.extend(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 0.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.vertex=function(a){console.warn("three.vertex has been deprecated. use three.vector3 instead.");return a};three.uv=function(a,b){console.warn("three.uv has been deprecated. use three.vector2 instead.");return new three.vector2(a,b)};three.clock=function(a){this.autostart=void 0!==a?a:!0;this.elapsedtime=this.oldtime=this.starttime=0;this.running=!1}; three.extend(three.clock.prototype,{start:function(){this.oldtime=this.starttime=void 0!==window.performance&&void 0!==window.performance.now?window.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!==window.performance&&void 0!==window.performance.now?window.performance.now():date.now(), a=0.001*(b-this.oldtime);this.oldtime=b;this.elapsedtime+=a}return a}});three.eventdispatcher=function(){var a={};this.addeventlistener=function(b,c){void 0===a[b]&&(a[b]=[]);-1===a[b].indexof(c)&&a[b].push(c)};this.removeeventlistener=function(b,c){var d=a[b].indexof(c);-1!==d&&a[b].splice(d,1)};this.dispatchevent=function(b){var c=a[b.type];if(void 0!==c){b.target=this;for(var d=0,e=c.length;dh.scale.x)return k;k.push({distance:i,point:h.position,face:null,object:h})}else if(h instanceof a.mesh){f.getpositionfrommatrix(h.matrixworld);b.set(f,h.geometry.boundingsphere.radius*h.matrixworld.getmaxscaleonaxis());if(!i.ray.isintersectionsphere(b))return k;var s=h.geometry,r=s.vertices,p=h.material instanceof a.meshfacematerial,q=!0===p?h.material.materials:null,y=h.material.side,v,z,t,a=i.precision;h.matrixrotationworld.extractrotation(h.matrixworld);g.getinverse(h.matrixworld);c.copy(i.ray).applymatrix4(g);for(var i=0,c=s.faces.length;ig)){y=y.side;if(y!==a.doubleside&&(v=c.direction.dot(d.normal),!(y===a.frontside?0>v:0i.far)){e=c.at(g,e);if(x instanceof a.face3){if(y=r[x.a],v=r[x.b],z=r[x.c],!a.triangle.containspoint(e,y,v,z))continue}else if(x instanceof a.face4){if(y=r[x.a],v=r[x.b],z=r[x.c],t=r[x.d],!a.triangle.containspoint(e,y,v,t)&&!a.triangle.containspoint(e,v,z,t))continue}else throw error("face type not supported"); k.push({distance:g,point:i.ray.at(g),face:x,faceindex:i,object:h})}}}}}},k=function(a,b,c){for(var a=a.getdescendants(),d=0,e=a.length;de&&0>f||0>g&&0>h)return!1;0>e?c=math.max(c,e/(e-f)):0>f&&(d=math.min(d,e/(e-f)));0>g?c=math.max(c,g/(g-h)):0>h&&(d=math.min(d,g/(g-h)));if(d< c)return!1;a.lerp(b,c);b.lerp(a,1-d);return!0}var e,f,g=[],h=0,i,k,l=[],m=0,n,s,r=[],p=0,q,y=[],v=0,z,t,a=[],i=0,c,x,g=[],j=0,e={objects:[],sprites:[],lights:[],elements:[]},h=new three.vector3,b=new three.vector4,w=new three.box3(new three.vector3(-1,-1,-1),new three.vector3(1,1,1)),f=new three.box3,k=array(3),l=array(4),u=new three.matrix4,fa=new three.matrix4,ca,$a=new three.matrix4,m=new three.matrix3,ca=new three.matrix3,qa=new three.vector3,ha=new three.frustum,ra=new three.vector4,n=new three.vector4; this.projectvector=function(a,b){b.matrixworldinverse.getinverse(b.matrixworld);fa.multiplymatrices(b.projectionmatrix,b.matrixworldinverse);return a.applyprojection(fa)};this.unprojectvector=function(a,b){b.projectionmatrixinverse.getinverse(b.projectionmatrix);fa.multiplymatrices(b.matrixworld,b.projectionmatrixinverse);return a.applyprojection(fa)};this.pickingray=function(a,b){a.z=-1;var c=new three.vector3(a.x,a.y,1);this.unprojectvector(a,b);this.unprojectvector(c,b);c.sub(a).normalize();return new three.raycaster(a, c)};this.projectscene=function(g,h,m,pa){var ta=!1,ka,aa,pa,y,da,la,z,oa,gb,nb,ia,wa,ab;x=t=q=s=0;e.elements.length=0;g.updatematrixworld();void 0===h.parent&&h.updatematrixworld();u.copy(h.matrixworldinverse.getinverse(h.matrixworld));fa.multiplymatrices(h.projectionmatrix,u);ca.getinverse(u);ca.transpose();ha.setfrommatrix(fa);f=0;e.objects.length=0;e.sprites.length=0;e.lights.length=0;var fa=function(b){for(var c=0,d=b.children.length;ci.positionscreen.x||1i.positionscreen.y||1i.positionscreen.z||1(z.positionscreen.x-y.positionscreen.x)*(da.positionscreen.y-y.positionscreen.y)-(z.positionscreen.y-y.positionscreen.y)*(da.positionscreen.x-y.positionscreen.x),la===three.doubleside||ta===(la===three.frontside))s===p?(ia=new three.renderableface3,r.push(ia),p++,s++,n=ia):n=r[s++],n.v1.copy(y),n.v2.copy(da),n.v3.copy(z);else continue; else continue;else if(aa instanceof three.face4)if(y=l[aa.a],da=l[aa.b],z=l[aa.c],ia=l[aa.d],l[0]=y.positionscreen,l[1]=da.positionscreen,l[2]=z.positionscreen,l[3]=ia.positionscreen,!0===y.visible||!0===da.visible||!0===z.visible||!0===ia.visible||w.isintersectionbox(f.setfrompoints(l)))if(ta=0>(ia.positionscreen.x-y.positionscreen.x)*(da.positionscreen.y-y.positionscreen.y)-(ia.positionscreen.y-y.positionscreen.y)*(da.positionscreen.x-y.positionscreen.x)||0>(da.positionscreen.x-z.positionscreen.x)* (ia.positionscreen.y-z.positionscreen.y)-(da.positionscreen.y-z.positionscreen.y)*(ia.positionscreen.x-z.positionscreen.x),la===three.doubleside||ta===(la===three.frontside)){if(q===v){var ub=new three.renderableface4;y.push(ub);v++;q++;n=ub}else n=y[q++];n.v1.copy(y);n.v2.copy(da);n.v3.copy(z);n.v4.copy(ia)}else continue;else continue;n.normalmodel.copy(aa.normal);!1===ta&&(la===three.backside||la===three.doubleside)&&n.normalmodel.negate();n.normalmodel.applymatrix3(m).normalize();n.normalmodelview.copy(n.normalmodel).applymatrix3(ca); n.centroidmodel.copy(aa.centroid).applymatrix4(ca);z=aa.vertexnormals;y=0;for(da=z.length;yb.z&&(x===j?(ta=new three.renderableparticle,g.push(ta),j++,x++,c=ta):c=g[x++],c.object=oa,c.x=b.x/b.w,c.y=b.y/b.w,c.z=b.z,c.rotation=oa.rotation.z,c.scale.x=oa.scale.x*math.abs(c.x-(b.x+h.projectionmatrix.elements[0])/ (b.w+h.projectionmatrix.elements[12])),c.scale.y=oa.scale.y*math.abs(c.y-(b.y+h.projectionmatrix.elements[5])/(b.w+h.projectionmatrix.elements[13])),c.material=oa.material,e.elements.push(c)));!0===pa&&e.elements.sort(c);return e}};three.face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof three.vector3?d:new three.vector3;this.vertexnormals=d instanceof array?d:[];this.color=e instanceof three.color?e:new three.color;this.vertexcolors=e instanceof array?e:[];this.vertextangents=[];this.materialindex=void 0!==f?f:0;this.centroid=new three.vector3}; three.face3.prototype={constructor:three.face3,clone:function(){var a=new three.face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialindex=this.materialindex;var b,c;b=0;for(c=this.vertexnormals.length;be?-1:1,f.vertextangents[d]=new three.vector4(b.x,b.y,b.z,e)}this.hastangents=!0},computelinedistances:function(){for(var a=0,b=this.vertices,c=0,d=b.length;ci;i++)if(h[i]==h[(i+1)%3]){e.push(f);break}}else if(a instanceof three.face4){a.a=c[a.a];a.b=c[a.b];a.c=c[a.c];a.d=c[a.d];h=[a.a,a.b,a.c,a.d];d=-1;for(i=0;4>i;i++)h[i]==h[(i+1)%4]&&(0<=d&&e.push(f),d=i);if(0<=d){h.splice(d,1);var l=new three.face3(h[0],h[1],h[2],a.normal,a.color,a.materialindex);h=0;for(i=this.facevertexuvs.length;hb.max.x&&(b.max.x=c),db.max.y&&(b.max.y=d),eb.max.z&&(b.max.z=e)}if(void 0===a||0===a.length)this.boundingbox.min.set(0,0,0),this.boundingbox.max.set(0,0,0)},computeboundingsphere:function(){null===this.boundingsphere&&(this.boundingsphere= new three.sphere);var a=this.attributes.position.array;if(a){for(var b,c=0,d,e,f=0,g=a.length;fc&&(c=b);this.boundingsphere.radius=math.sqrt(c)}},computevertexnormals:function(){if(this.attributes.position){var a,b,c,d;a=this.attributes.position.array.length;if(void 0===this.attributes.normal)this.attributes.normal={itemsize:3,array:new float32array(a),numitems:a};else{a=0;for(b=this.attributes.normal.array.length;aqa?-1:1;h[4*a]=u.x;h[4*a+1]=u.y;h[4*a+2]=u.z;h[4*a+3]=m}if(void 0===this.attributes.index||void 0===this.attributes.position|| void 0===this.attributes.normal||void 0===this.attributes.uv)console.warn("missing required attributes (index, position, normal or uv) in buffergeometry.computetangents()");else{var b=this.attributes.index.array,c=this.attributes.position.array,d=this.attributes.normal.array,e=this.attributes.uv.array,f=c.length/3;if(void 0===this.attributes.tangent){var g=4*f;this.attributes.tangent={itemsize:4,array:new float32array(g),numitems:g}}for(var h=this.attributes.tangent.array,i=[],k=[],g=0;ga.length?".":a.join("/"))+"/"},initmaterials:function(a,b){for(var c=[],d=0;da.opacity)i.transparent=a.transparent;void 0!==a.depthtest&&(i.depthtest=a.depthtest);void 0!==a.depthwrite&&(i.depthwrite=a.depthwrite);void 0!==a.visible&&(i.visible=a.visible);void 0!==a.flipsided&&(i.side=three.backside); void 0!==a.doublesided&&(i.side=three.doubleside);void 0!==a.wireframe&&(i.wireframe=a.wireframe);void 0!==a.vertexcolors&&("face"===a.vertexcolors?i.vertexcolors=three.facecolors:a.vertexcolors&&(i.vertexcolors=three.vertexcolors));a.colordiffuse?i.color=f(a.colordiffuse):a.dbgcolor&&(i.color=a.dbgcolor);a.colorspecular&&(i.specular=f(a.colorspecular));a.colorambient&&(i.ambient=f(a.colorambient));a.transparency&&(i.opacity=a.transparency);a.specularcoef&&(i.shininess=a.specularcoef);a.mapdiffuse&& b&&e(i,"map",a.mapdiffuse,a.mapdiffuserepeat,a.mapdiffuseoffset,a.mapdiffusewrap,a.mapdiffuseanisotropy);a.maplight&&b&&e(i,"lightmap",a.maplight,a.maplightrepeat,a.maplightoffset,a.maplightwrap,a.maplightanisotropy);a.mapbump&&b&&e(i,"bumpmap",a.mapbump,a.mapbumprepeat,a.mapbumpoffset,a.mapbumpwrap,a.mapbumpanisotropy);a.mapnormal&&b&&e(i,"normalmap",a.mapnormal,a.mapnormalrepeat,a.mapnormaloffset,a.mapnormalwrap,a.mapnormalanisotropy);a.mapspecular&&b&&e(i,"specularmap",a.mapspecular,a.mapspecularrepeat, a.mapspecularoffset,a.mapspecularwrap,a.mapspecularanisotropy);a.mapbumpscale&&(i.bumpscale=a.mapbumpscale);a.mapnormal?(h=three.shaderlib.normalmap,k=three.uniformsutils.clone(h.uniforms),k.tnormal.value=i.normalmap,a.mapnormalfactor&&k.unormalscale.value.set(a.mapnormalfactor,a.mapnormalfactor),i.map&&(k.tdiffuse.value=i.map,k.enablediffuse.value=!0),i.specularmap&&(k.tspecular.value=i.specularmap,k.enablespecular.value=!0),i.lightmap&&(k.tao.value=i.lightmap,k.enableao.value=!0),k.udiffusecolor.value.sethex(i.color), k.uspecularcolor.value.sethex(i.specular),k.uambientcolor.value.sethex(i.ambient),k.ushininess.value=i.shininess,void 0!==i.opacity&&(k.uopacity.value=i.opacity),h=new three.shadermaterial({fragmentshader:h.fragmentshader,vertexshader:h.vertexshader,uniforms:k,lights:!0,fog:!0}),i.transparent&&(h.transparent=!0)):h=new three[h](i);void 0!==a.dbgname&&(h.name=a.dbgname);return h}};three.imageloader=function(){three.eventdispatcher.call(this);this.crossorigin=null};three.imageloader.prototype={constructor:three.imageloader,load:function(a,b){var c=this;void 0===b&&(b=new image);b.addeventlistener("load",function(){c.dispatchevent({type:"load",content:b})},!1);b.addeventlistener("error",function(){c.dispatchevent({type:"error",message:"couldn't load url ["+a+"]"})},!1);c.crossorigin&&(b.crossorigin=c.crossorigin);b.src=a}};three.jsonloader=function(a){three.loader.call(this,a);this.withcredentials=!1};three.jsonloader.prototype=object.create(three.loader.prototype);three.jsonloader.prototype.load=function(a,b,c){c=c&&"string"===typeof c?c:this.extracturlbase(a);this.onloadstart();this.loadajaxjson(this,a,b,c)}; three.jsonloader.prototype.loadajaxjson=function(a,b,c,d,e){var f=new xmlhttprequest,g=0;f.onreadystatechange=function(){if(f.readystate===f.done)if(200===f.status||0===f.status){if(f.responsetext){var h=json.parse(f.responsetext);a.createmodel(h,c,d)}else console.warn("three.jsonloader: ["+b+"] seems to be unreachable or file there is empty");a.onloadcomplete()}else console.error("three.jsonloader: couldn't load ["+b+"] ["+f.status+"]");else f.readystate===f.loading?e&&(0===g&&(g=f.getresponseheader("content-length")), e({total:g,loaded:f.responsetext.length})):f.readystate===f.headers_received&&(g=f.getresponseheader("content-length"))};f.open("get",b,!0);f.withcredentials=this.withcredentials;f.send(null)}; three.jsonloader.prototype.createmodel=function(a,b,c){var d=new three.geometry,e=void 0!==a.scale?1/a.scale:1,f,g,h,i,k,l,m,n,s,r,p,q,y,v,z,t=a.faces;r=a.vertices;var a=a.normals,i=a.colors,c=0;for(f=0;ff.parameters.opacity&& (f.parameters.transparent=!0);f.parameters.normalmap?(e=three.shaderlib.normalmap,b=three.uniformsutils.clone(e.uniforms),q=f.parameters.color,w=f.parameters.specular,p=f.parameters.ambient,h=f.parameters.shininess,b.tnormal.value=x.textures[f.parameters.normalmap],f.parameters.normalscale&&b.unormalscale.value.set(f.parameters.normalscale[0],f.parameters.normalscale[1]),f.parameters.map&&(b.tdiffuse.value=f.parameters.map,b.enablediffuse.value=!0),f.parameters.envmap&&(b.tcube.value=f.parameters.envmap, b.enablereflection.value=!0,b.ureflectivity.value=f.parameters.reflectivity),f.parameters.lightmap&&(b.tao.value=f.parameters.lightmap,b.enableao.value=!0),f.parameters.specularmap&&(b.tspecular.value=x.textures[f.parameters.specularmap],b.enablespecular.value=!0),f.parameters.displacementmap&&(b.tdisplacement.value=x.textures[f.parameters.displacementmap],b.enabledisplacement.value=!0,b.udisplacementbias.value=f.parameters.displacementbias,b.udisplacementscale.value=f.parameters.displacementscale), b.udiffusecolor.value.sethex(q),b.uspecularcolor.value.sethex(w),b.uambientcolor.value.sethex(p),b.ushininess.value=h,f.parameters.opacity&&(b.uopacity.value=f.parameters.opacity),s=new three.shadermaterial({fragmentshader:e.fragmentshader,vertexshader:e.vertexshader,uniforms:b,lights:!0,fog:!0})):s=new three[f.type](f.parameters);x.materials[k]=s}for(k in j.materials)if(f=j.materials[k],f.parameters.materials){l=[];for(q=0;qh.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=1e3*((c.end-c.start)/b),this.time=0):console.warn("animation["+a+"] undefined")}; 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.clone=function(a){void 0===a&&(a=new three.morphanimmesh(this.geometry,this.material));a.duration=this.duration;a.mirroredloop=this.mirroredloop;a.time=this.time;a.lastkeyframe=this.lastkeyframe;a.currentkeyframe=this.currentkeyframe;a.direction=this.direction;a.directionbackwards=this.directionbackwards;three.mesh.prototype.clone.call(this,a);return a};three.ribbon=function(a,b){three.object3d.call(this);this.geometry=a;this.material=b};three.ribbon.prototype=object.create(three.object3d.prototype);three.ribbon.prototype.clone=function(a){void 0===a&&(a=new three.ribbon(this.geometry,this.material));three.object3d.prototype.clone.call(this,a);return a};three.lod=function(){three.object3d.call(this);this.lods=[]};three.lod.prototype=object.create(three.object3d.prototype);three.lod.prototype.addlevel=function(a,b){void 0===b&&(b=0);for(var b=math.abs(b),c=0;c=this.lods[b].visibleatdistance)this.lods[b-1].object3d.visible=!1,this.lods[b].object3d.visible=!0;else break;for(;bi&&t.clearrect(ka.min.x|0,ka.min.y|0,ka.max.x-ka.min.x|0,ka.max.y-ka.min.y|0),0=j||(j*=f.intensity,c.add(gb.multiplyscalar(j)))}else f instanceof three.pointlight&&(g=bb.getpositionfrommatrix(f.matrixworld),j=b.dot(bb.subvectors(g,a).normalize()),0>=j||(j*=0==f.distance?1:1-math.min(a.distanceto(g)/f.distance,1),0!=j&&(j*=f.intensity,c.add(gb.multiplyscalar(j)))))}}function x(a,d,e,f,g,j,h,i){l.info.render.vertices+= 3;l.info.render.faces++;b(i.opacity);c(i.blending);m=a.positionscreen.x;ca=a.positionscreen.y;qa=d.positionscreen.x;ha=d.positionscreen.y;ra=e.positionscreen.x;n=e.positionscreen.y;y(m,ca,qa,ha,ra,n);(i instanceof three.meshlambertmaterial||i instanceof three.meshphongmaterial)&&null===i.map?(z.copy(i.color),oa.copy(i.emissive),i.vertexcolors===three.facecolors&&z.multiply(h.color),!0===gc?!1===i.wireframe&&i.shading==three.smoothshading&&3==h.vertexnormalslength?(pa.copy(vb),y.copy(vb),da.copy(vb), q(h.v1.positionworld,h.vertexnormalsmodel[0],pa),q(h.v2.positionworld,h.vertexnormalsmodel[1],y),q(h.v3.positionworld,h.vertexnormalsmodel[2],da),pa.multiply(z).add(oa),y.multiply(z).add(oa),da.multiply(z).add(oa),la.addcolors(y,da).multiplyscalar(0.5),fa=e(pa,y,da,la),g(m,ca,qa,ha,ra,n,0,0,1,0,0,1,fa)):(aa.copy(vb),q(h.centroidmodel,h.normalmodel,aa),aa.multiply(z).add(oa),!0===i.wireframe?c(aa,i.wireframelinewidth,i.wireframelinecap,i.wireframelinejoin):a(aa)):!0===i.wireframe?c(i.color,i.wireframelinewidth, i.wireframelinecap,i.wireframelinejoin):a(i.color)):i instanceof three.meshbasicmaterial||i instanceof three.meshlambertmaterial||i instanceof three.meshphongmaterial?null!==i.map?i.map.mapping instanceof three.uvmapping&&(xa=h.uvs[0],f(m,ca,qa,ha,ra,n,xa[f].x,xa[f].y,xa[g].x,xa[g].y,xa[j].x,xa[j].y,i.map)):null!==i.envmap?i.envmap.mapping instanceof three.sphericalreflectionmapping&&(bb.copy(h.vertexnormalsmodelview[f]),ub=0.5*bb.x+0.5,ib=0.5*bb.y+0.5,bb.copy(h.vertexnormalsmodelview[g]),jb=0.5* bb.x+0.5,fc=0.5*bb.y+0.5,bb.copy(h.vertexnormalsmodelview[j]),ab=0.5*bb.x+0.5,mc=0.5*bb.y+0.5,f(m,ca,qa,ha,ra,n,ub,ib,jb,fc,ab,mc,i.envmap)):(aa.copy(i.color),i.vertexcolors===three.facecolors&&aa.multiply(h.color),!0===i.wireframe?c(aa,i.wireframelinewidth,i.wireframelinecap,i.wireframelinejoin):a(aa)):i instanceof three.meshdepthmaterial?(wa=p.near,ab=p.far,pa.r=pa.g=pa.b=1-k(a.positionscreen.z*a.positionscreen.w,wa,ab),y.r=y.g=y.b=1-k(d.positionscreen.z*d.positionscreen.w,wa,ab),da.r=da.g=da.b= 1-k(e.positionscreen.z*e.positionscreen.w,wa,ab),la.addcolors(y,da).multiplyscalar(0.5),fa=e(pa,y,da,la),g(m,ca,qa,ha,ra,n,0,0,1,0,0,1,fa)):i instanceof three.meshnormalmaterial&&(i.shading==three.flatshading?(a=h.normalmodelview,aa.setrgb(a.x,a.y,a.z).multiplyscalar(0.5).addscalar(0.5),!0===i.wireframe?c(aa,i.wireframelinewidth,i.wireframelinecap,i.wireframelinejoin):a(aa)):i.shading==three.smoothshading&&(a=h.vertexnormalsmodelview[f],pa.setrgb(a.x,a.y,a.z).multiplyscalar(0.5).addscalar(0.5),a= h.vertexnormalsmodelview[g],y.setrgb(a.x,a.y,a.z).multiplyscalar(0.5).addscalar(0.5),a=h.vertexnormalsmodelview[j],da.setrgb(a.x,a.y,a.z).multiplyscalar(0.5).addscalar(0.5),la.addcolors(y,da).multiplyscalar(0.5),fa=e(pa,y,da,la),g(m,ca,qa,ha,ra,n,0,0,1,0,0,1,fa)))}function y(a,b,c,d,e,f){t.beginpath();t.moveto(a,b);t.lineto(c,d);t.lineto(e,f);t.closepath()}function b(a,b,c,d,e,f,g,j){t.beginpath();t.moveto(a,b);t.lineto(c,d);t.lineto(e,f);t.lineto(g,j);t.closepath()}function c(a,b,c,j){d(b);e(c); f(j);g(a.getstyle());t.stroke();va.expandbyscalar(2*b)}function a(a){h(a.getstyle());t.fill()}function f(a,b,c,d,e,f,g,j,i,wa,k,l,n){if(!(n instanceof three.datatexture||void 0===n.image||0==n.image.width)){if(!0===n.needsupdate){var m=n.wraps==three.repeatwrapping,hb=n.wrapt==three.repeatwrapping;nb[n.id]=t.createpattern(n.image,!0===m&&!0===hb?"repeat":!0===m&&!1===hb?"repeat-x":!1===m&&!0===hb?"repeat-y":"no-repeat");n.needsupdate=!1}void 0===nb[n.id]?h("rgba(0,0,0,1)"):h(nb[n.id]);var m=n.offset.x/ n.repeat.x,hb=n.offset.y/n.repeat.y,p=n.image.width*n.repeat.x,q=n.image.height*n.repeat.y,g=(g+m)*p,j=(1-j+hb)*q,c=c-a,d=d-b,e=e-a,f=f-b,i=(i+m)*p-g,wa=(1-wa+hb)*q-j,k=(k+m)*p-g,l=(1-l+hb)*q-j,m=i*l-k*wa;0===m?(void 0===ia[n.id]&&(b=document.createelement("canvas"),b.width=n.image.width,b.height=n.image.height,b=b.getcontext("2d"),b.drawimage(n.image,0,0),ia[n.id]=b.getimagedata(0,0,n.image.width,n.image.height).data),b=ia[n.id],g=4*(math.floor(g)+math.floor(j)*n.image.width),aa.setrgb(b[g]/255, b[g+1]/255,b[g+2]/255),a(aa)):(m=1/m,n=(l*c-wa*e)*m,wa=(l*d-wa*f)*m,c=(i*e-k*c)*m,d=(i*f-k*d)*m,a=a-n*g-c*j,g=b-wa*g-d*j,t.save(),t.transform(n,wa,c,d,a,g),t.fill(),t.restore())}}function g(a,b,c,d,e,f,g,j,i,h,wa,k,n){var l,m;l=n.width-1;m=n.height-1;g*=l;j*=m;c-=a;d-=b;e-=a;f-=b;i=i*l-g;h=h*m-j;wa=wa*l-g;k=k*m-j;m=1/(i*k-wa*h);l=(k*c-h*e)*m;h=(k*d-h*f)*m;c=(i*e-wa*c)*m;d=(i*f-wa*d)*m;a=a-l*g-c*j;b=b-h*g-d*j;t.save();t.transform(l,h,c,d,a,b);t.clip();t.drawimage(n,0,0);t.restore()}function e(a,b, c,d){ra[0]=255*a.r|0;ra[1]=255*a.g|0;ra[2]=255*a.b|0;ra[4]=255*b.r|0;ra[5]=255*b.g|0;ra[6]=255*b.b|0;ra[8]=255*c.r|0;ra[9]=255*c.g|0;ra[10]=255*c.b|0;ra[12]=255*d.r|0;ra[13]=255*d.g|0;ra[14]=255*d.b|0;j.putimagedata(yb,0,0);sa.drawimage(xb,0,0);return cb}function i(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;0!==e&&(e=1/math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}if(!1===p instanceof three.camera)console.error("three.canvasrenderer.render: camera is not an instance of three.camera.");else{!0=== this.autoclear&&this.clear();t.settransform(1,0,0,-1,v,z);l.info.render.vertices=0;l.info.render.faces=0;m=r.projectscene(a,p,this.sortobjects,this.sortelements);n=m.elements;s=m.lights;gc=0>1,nd=h.height>>1,cb=wa.scale.x*v,db=wa.scale.y*z,bb=cb*md,hb=db*nd,va.min.set(x.x-bb,x.y-hb),va.max.set(x.x+bb,x.y+hb),!1!==pb.isintersectionbox(va)&&(t.save(),t.translate(x.x,x.y),t.rotate(-wa.rotation),t.scale(cb,-db),t.translate(-md,-nd),t.drawimage(h,0,0),t.restore())):p instanceof three.particlecanvasmaterial&&(bb=wa.scale.x*v,hb=wa.scale.y*z,va.min.set(x.x-bb,x.y-hb),va.max.set(x.x+bb,x.y+hb),!1!==pb.isintersectionbox(va)&&(g(p.color.getstyle()), h(p.color.getstyle()),t.save(),t.translate(x.x,x.y),t.rotate(-wa.rotation),t.scale(bb,hb),p.program(t),t.restore()))}else if(h instanceof three.renderableline)k=h.v1,l=h.v2,k.positionscreen.x*=v,k.positionscreen.y*=z,l.positionscreen.x*=v,l.positionscreen.y*=z,va.setfrompoints([k.positionscreen,l.positionscreen]),!0===pb.isintersectionbox(va)&&(x=k,wa=l,b(p.opacity),c(p.blending),t.beginpath(),t.moveto(x.positionscreen.x,x.positionscreen.y),t.lineto(wa.positionscreen.x,wa.positionscreen.y),p instanceof three.linebasicmaterial?(d(p.linewidth),e(p.linecap),f(p.linejoin),g(p.color.getstyle()),i(null,null),t.stroke(),va.expandbyscalar(2*p.linewidth)):p instanceof three.linedashedmaterial&&(d(p.linewidth),e(p.linecap),f(p.linejoin),g(p.color.getstyle()),i(p.dashsize,p.gapsize),t.stroke(),va.expandbyscalar(2*p.linewidth)));else if(h instanceof three.renderableface3){k=h.v1;l=h.v2;u=h.v3;if(-1>k.positionscreen.z||1l.positionscreen.z||1 u.positionscreen.z||1k.positionscreen.z|| 1l.positionscreen.z||1u.positionscreen.z||1fa.positionscreen.z||1 0\nuniform vec3 directionallightcolor[ max_dir_lights ];\nuniform vec3 directionallightdirection[ max_dir_lights ];\n#endif\n#if max_hemi_lights > 0\nuniform vec3 hemispherelightskycolor[ max_hemi_lights ];\nuniform vec3 hemispherelightgroundcolor[ max_hemi_lights ];\nuniform vec3 hemispherelightdirection[ max_hemi_lights ];\n#endif\n#if max_point_lights > 0\nuniform vec3 pointlightcolor[ max_point_lights ];\nuniform vec3 pointlightposition[ max_point_lights ];\nuniform float pointlightdistance[ max_point_lights ];\n#endif\n#if max_spot_lights > 0\nuniform vec3 spotlightcolor[ max_spot_lights ];\nuniform vec3 spotlightposition[ max_spot_lights ];\nuniform vec3 spotlightdirection[ max_spot_lights ];\nuniform float spotlightdistance[ max_spot_lights ];\nuniform float spotlightanglecos[ max_spot_lights ];\nuniform float spotlightexponent[ max_spot_lights ];\n#endif\n#ifdef wrap_around\nuniform vec3 wraprgb;\n#endif", lights_lambert_vertex:"vlightfront = vec3( 0.0 );\n#ifdef double_sided\nvlightback = vec3( 0.0 );\n#endif\ntransformednormal = normalize( transformednormal );\n#if max_dir_lights > 0\nfor( int i = 0; i < max_dir_lights; i ++ ) {\nvec4 ldirection = viewmatrix * vec4( directionallightdirection[ i ], 0.0 );\nvec3 dirvector = normalize( ldirection.xyz );\nfloat dotproduct = dot( transformednormal, dirvector );\nvec3 directionallightweighting = vec3( max( dotproduct, 0.0 ) );\n#ifdef double_sided\nvec3 directionallightweightingback = vec3( max( -dotproduct, 0.0 ) );\n#ifdef wrap_around\nvec3 directionallightweightinghalfback = vec3( max( -0.5 * dotproduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef wrap_around\nvec3 directionallightweightinghalf = vec3( max( 0.5 * dotproduct + 0.5, 0.0 ) );\ndirectionallightweighting = mix( directionallightweighting, directionallightweightinghalf, wraprgb );\n#ifdef double_sided\ndirectionallightweightingback = mix( directionallightweightingback, directionallightweightinghalfback, wraprgb );\n#endif\n#endif\nvlightfront += directionallightcolor[ i ] * directionallightweighting;\n#ifdef double_sided\nvlightback += directionallightcolor[ i ] * directionallightweightingback;\n#endif\n}\n#endif\n#if max_point_lights > 0\nfor( int i = 0; i < max_point_lights; i ++ ) {\nvec4 lposition = viewmatrix * vec4( pointlightposition[ i ], 1.0 );\nvec3 lvector = lposition.xyz - mvposition.xyz;\nfloat ldistance = 1.0;\nif ( pointlightdistance[ i ] > 0.0 )\nldistance = 1.0 - min( ( length( lvector ) / pointlightdistance[ i ] ), 1.0 );\nlvector = normalize( lvector );\nfloat dotproduct = dot( transformednormal, lvector );\nvec3 pointlightweighting = vec3( max( dotproduct, 0.0 ) );\n#ifdef double_sided\nvec3 pointlightweightingback = vec3( max( -dotproduct, 0.0 ) );\n#ifdef wrap_around\nvec3 pointlightweightinghalfback = vec3( max( -0.5 * dotproduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef wrap_around\nvec3 pointlightweightinghalf = vec3( max( 0.5 * dotproduct + 0.5, 0.0 ) );\npointlightweighting = mix( pointlightweighting, pointlightweightinghalf, wraprgb );\n#ifdef double_sided\npointlightweightingback = mix( pointlightweightingback, pointlightweightinghalfback, wraprgb );\n#endif\n#endif\nvlightfront += pointlightcolor[ i ] * pointlightweighting * ldistance;\n#ifdef double_sided\nvlightback += pointlightcolor[ i ] * pointlightweightingback * ldistance;\n#endif\n}\n#endif\n#if max_spot_lights > 0\nfor( int i = 0; i < max_spot_lights; i ++ ) {\nvec4 lposition = viewmatrix * vec4( spotlightposition[ i ], 1.0 );\nvec3 lvector = lposition.xyz - mvposition.xyz;\nfloat spoteffect = dot( spotlightdirection[ i ], normalize( spotlightposition[ i ] - worldposition.xyz ) );\nif ( spoteffect > spotlightanglecos[ i ] ) {\nspoteffect = max( pow( spoteffect, spotlightexponent[ i ] ), 0.0 );\nfloat ldistance = 1.0;\nif ( spotlightdistance[ i ] > 0.0 )\nldistance = 1.0 - min( ( length( lvector ) / spotlightdistance[ i ] ), 1.0 );\nlvector = normalize( lvector );\nfloat dotproduct = dot( transformednormal, lvector );\nvec3 spotlightweighting = vec3( max( dotproduct, 0.0 ) );\n#ifdef double_sided\nvec3 spotlightweightingback = vec3( max( -dotproduct, 0.0 ) );\n#ifdef wrap_around\nvec3 spotlightweightinghalfback = vec3( max( -0.5 * dotproduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef wrap_around\nvec3 spotlightweightinghalf = vec3( max( 0.5 * dotproduct + 0.5, 0.0 ) );\nspotlightweighting = mix( spotlightweighting, spotlightweightinghalf, wraprgb );\n#ifdef double_sided\nspotlightweightingback = mix( spotlightweightingback, spotlightweightinghalfback, wraprgb );\n#endif\n#endif\nvlightfront += spotlightcolor[ i ] * spotlightweighting * ldistance * spoteffect;\n#ifdef double_sided\nvlightback += spotlightcolor[ i ] * spotlightweightingback * ldistance * spoteffect;\n#endif\n}\n}\n#endif\n#if max_hemi_lights > 0\nfor( int i = 0; i < max_hemi_lights; i ++ ) {\nvec4 ldirection = viewmatrix * vec4( hemispherelightdirection[ i ], 0.0 );\nvec3 lvector = normalize( ldirection.xyz );\nfloat dotproduct = dot( transformednormal, lvector );\nfloat hemidiffuseweight = 0.5 * dotproduct + 0.5;\nfloat hemidiffuseweightback = -0.5 * dotproduct + 0.5;\nvlightfront += mix( hemispherelightgroundcolor[ i ], hemispherelightskycolor[ i ], hemidiffuseweight );\n#ifdef double_sided\nvlightback += mix( hemispherelightgroundcolor[ i ], hemispherelightskycolor[ i ], hemidiffuseweightback );\n#endif\n}\n#endif\nvlightfront = vlightfront * diffuse + ambient * ambientlightcolor + emissive;\n#ifdef double_sided\nvlightback = vlightback * diffuse + ambient * ambientlightcolor + emissive;\n#endif", lights_phong_pars_vertex:"#ifndef phong_per_pixel\n#if max_point_lights > 0\nuniform vec3 pointlightposition[ max_point_lights ];\nuniform float pointlightdistance[ max_point_lights ];\nvarying vec4 vpointlight[ max_point_lights ];\n#endif\n#if max_spot_lights > 0\nuniform vec3 spotlightposition[ max_spot_lights ];\nuniform float spotlightdistance[ max_spot_lights ];\nvarying vec4 vspotlight[ max_spot_lights ];\n#endif\n#endif\n#if max_spot_lights > 0 || defined( use_bumpmap )\nvarying vec3 vworldposition;\n#endif", lights_phong_vertex:"#ifndef phong_per_pixel\n#if max_point_lights > 0\nfor( int i = 0; i < max_point_lights; i ++ ) {\nvec4 lposition = viewmatrix * vec4( pointlightposition[ i ], 1.0 );\nvec3 lvector = lposition.xyz - mvposition.xyz;\nfloat ldistance = 1.0;\nif ( pointlightdistance[ i ] > 0.0 )\nldistance = 1.0 - min( ( length( lvector ) / pointlightdistance[ i ] ), 1.0 );\nvpointlight[ i ] = vec4( lvector, ldistance );\n}\n#endif\n#if max_spot_lights > 0\nfor( int i = 0; i < max_spot_lights; i ++ ) {\nvec4 lposition = viewmatrix * vec4( spotlightposition[ i ], 1.0 );\nvec3 lvector = lposition.xyz - mvposition.xyz;\nfloat ldistance = 1.0;\nif ( spotlightdistance[ i ] > 0.0 )\nldistance = 1.0 - min( ( length( lvector ) / spotlightdistance[ i ] ), 1.0 );\nvspotlight[ i ] = vec4( lvector, ldistance );\n}\n#endif\n#endif\n#if max_spot_lights > 0 || defined( use_bumpmap )\nvworldposition = worldposition.xyz;\n#endif", lights_phong_pars_fragment:"uniform vec3 ambientlightcolor;\n#if max_dir_lights > 0\nuniform vec3 directionallightcolor[ max_dir_lights ];\nuniform vec3 directionallightdirection[ max_dir_lights ];\n#endif\n#if max_hemi_lights > 0\nuniform vec3 hemispherelightskycolor[ max_hemi_lights ];\nuniform vec3 hemispherelightgroundcolor[ max_hemi_lights ];\nuniform vec3 hemispherelightdirection[ max_hemi_lights ];\n#endif\n#if max_point_lights > 0\nuniform vec3 pointlightcolor[ max_point_lights ];\n#ifdef phong_per_pixel\nuniform vec3 pointlightposition[ max_point_lights ];\nuniform float pointlightdistance[ max_point_lights ];\n#else\nvarying vec4 vpointlight[ max_point_lights ];\n#endif\n#endif\n#if max_spot_lights > 0\nuniform vec3 spotlightcolor[ max_spot_lights ];\nuniform vec3 spotlightposition[ max_spot_lights ];\nuniform vec3 spotlightdirection[ max_spot_lights ];\nuniform float spotlightanglecos[ max_spot_lights ];\nuniform float spotlightexponent[ max_spot_lights ];\n#ifdef phong_per_pixel\nuniform float spotlightdistance[ max_spot_lights ];\n#else\nvarying vec4 vspotlight[ max_spot_lights ];\n#endif\n#endif\n#if max_spot_lights > 0 || defined( use_bumpmap )\nvarying vec3 vworldposition;\n#endif\n#ifdef wrap_around\nuniform vec3 wraprgb;\n#endif\nvarying vec3 vviewposition;\nvarying vec3 vnormal;", lights_phong_fragment:"vec3 normal = normalize( vnormal );\nvec3 viewposition = normalize( vviewposition );\n#ifdef double_sided\nnormal = normal * ( -1.0 + 2.0 * float( gl_frontfacing ) );\n#endif\n#ifdef use_normalmap\nnormal = perturbnormal2arb( -viewposition, normal );\n#elif defined( use_bumpmap )\nnormal = perturbnormalarb( -vviewposition, normal, dhdxy_fwd() );\n#endif\n#if max_point_lights > 0\nvec3 pointdiffuse = vec3( 0.0 );\nvec3 pointspecular = vec3( 0.0 );\nfor ( int i = 0; i < max_point_lights; i ++ ) {\n#ifdef phong_per_pixel\nvec4 lposition = viewmatrix * vec4( pointlightposition[ i ], 1.0 );\nvec3 lvector = lposition.xyz + vviewposition.xyz;\nfloat ldistance = 1.0;\nif ( pointlightdistance[ i ] > 0.0 )\nldistance = 1.0 - min( ( length( lvector ) / pointlightdistance[ i ] ), 1.0 );\nlvector = normalize( lvector );\n#else\nvec3 lvector = normalize( vpointlight[ i ].xyz );\nfloat ldistance = vpointlight[ i ].w;\n#endif\nfloat dotproduct = dot( normal, lvector );\n#ifdef wrap_around\nfloat pointdiffuseweightfull = max( dotproduct, 0.0 );\nfloat pointdiffuseweighthalf = max( 0.5 * dotproduct + 0.5, 0.0 );\nvec3 pointdiffuseweight = mix( vec3 ( pointdiffuseweightfull ), vec3( pointdiffuseweighthalf ), wraprgb );\n#else\nfloat pointdiffuseweight = max( dotproduct, 0.0 );\n#endif\npointdiffuse += diffuse * pointlightcolor[ i ] * pointdiffuseweight * ldistance;\nvec3 pointhalfvector = normalize( lvector + viewposition );\nfloat pointdotnormalhalf = max( dot( normal, pointhalfvector ), 0.0 );\nfloat pointspecularweight = specularstrength * max( pow( pointdotnormalhalf, shininess ), 0.0 );\n#ifdef physically_based_shading\nfloat specularnormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lvector, pointhalfvector ), 5.0 );\npointspecular += schlick * pointlightcolor[ i ] * pointspecularweight * pointdiffuseweight * ldistance * specularnormalization;\n#else\npointspecular += specular * pointlightcolor[ i ] * pointspecularweight * pointdiffuseweight * ldistance;\n#endif\n}\n#endif\n#if max_spot_lights > 0\nvec3 spotdiffuse = vec3( 0.0 );\nvec3 spotspecular = vec3( 0.0 );\nfor ( int i = 0; i < max_spot_lights; i ++ ) {\n#ifdef phong_per_pixel\nvec4 lposition = viewmatrix * vec4( spotlightposition[ i ], 1.0 );\nvec3 lvector = lposition.xyz + vviewposition.xyz;\nfloat ldistance = 1.0;\nif ( spotlightdistance[ i ] > 0.0 )\nldistance = 1.0 - min( ( length( lvector ) / spotlightdistance[ i ] ), 1.0 );\nlvector = normalize( lvector );\n#else\nvec3 lvector = normalize( vspotlight[ i ].xyz );\nfloat ldistance = vspotlight[ i ].w;\n#endif\nfloat spoteffect = dot( spotlightdirection[ i ], normalize( spotlightposition[ i ] - vworldposition ) );\nif ( spoteffect > spotlightanglecos[ i ] ) {\nspoteffect = max( pow( spoteffect, spotlightexponent[ i ] ), 0.0 );\nfloat dotproduct = dot( normal, lvector );\n#ifdef wrap_around\nfloat spotdiffuseweightfull = max( dotproduct, 0.0 );\nfloat spotdiffuseweighthalf = max( 0.5 * dotproduct + 0.5, 0.0 );\nvec3 spotdiffuseweight = mix( vec3 ( spotdiffuseweightfull ), vec3( spotdiffuseweighthalf ), wraprgb );\n#else\nfloat spotdiffuseweight = max( dotproduct, 0.0 );\n#endif\nspotdiffuse += diffuse * spotlightcolor[ i ] * spotdiffuseweight * ldistance * spoteffect;\nvec3 spothalfvector = normalize( lvector + viewposition );\nfloat spotdotnormalhalf = max( dot( normal, spothalfvector ), 0.0 );\nfloat spotspecularweight = specularstrength * max( pow( spotdotnormalhalf, shininess ), 0.0 );\n#ifdef physically_based_shading\nfloat specularnormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lvector, spothalfvector ), 5.0 );\nspotspecular += schlick * spotlightcolor[ i ] * spotspecularweight * spotdiffuseweight * ldistance * specularnormalization * spoteffect;\n#else\nspotspecular += specular * spotlightcolor[ i ] * spotspecularweight * spotdiffuseweight * ldistance * spoteffect;\n#endif\n}\n}\n#endif\n#if max_dir_lights > 0\nvec3 dirdiffuse = vec3( 0.0 );\nvec3 dirspecular = vec3( 0.0 );\nfor( int i = 0; i < max_dir_lights; i ++ ) {\nvec4 ldirection = viewmatrix * vec4( directionallightdirection[ i ], 0.0 );\nvec3 dirvector = normalize( ldirection.xyz );\nfloat dotproduct = dot( normal, dirvector );\n#ifdef wrap_around\nfloat dirdiffuseweightfull = max( dotproduct, 0.0 );\nfloat dirdiffuseweighthalf = max( 0.5 * dotproduct + 0.5, 0.0 );\nvec3 dirdiffuseweight = mix( vec3( dirdiffuseweightfull ), vec3( dirdiffuseweighthalf ), wraprgb );\n#else\nfloat dirdiffuseweight = max( dotproduct, 0.0 );\n#endif\ndirdiffuse += diffuse * directionallightcolor[ i ] * dirdiffuseweight;\nvec3 dirhalfvector = normalize( dirvector + viewposition );\nfloat dirdotnormalhalf = max( dot( normal, dirhalfvector ), 0.0 );\nfloat dirspecularweight = specularstrength * max( pow( dirdotnormalhalf, shininess ), 0.0 );\n#ifdef physically_based_shading\nfloat specularnormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( dirvector, dirhalfvector ), 5.0 );\ndirspecular += schlick * directionallightcolor[ i ] * dirspecularweight * dirdiffuseweight * specularnormalization;\n#else\ndirspecular += specular * directionallightcolor[ i ] * dirspecularweight * dirdiffuseweight;\n#endif\n}\n#endif\n#if max_hemi_lights > 0\nvec3 hemidiffuse = vec3( 0.0 );\nvec3 hemispecular = vec3( 0.0 );\nfor( int i = 0; i < max_hemi_lights; i ++ ) {\nvec4 ldirection = viewmatrix * vec4( hemispherelightdirection[ i ], 0.0 );\nvec3 lvector = normalize( ldirection.xyz );\nfloat dotproduct = dot( normal, lvector );\nfloat hemidiffuseweight = 0.5 * dotproduct + 0.5;\nvec3 hemicolor = mix( hemispherelightgroundcolor[ i ], hemispherelightskycolor[ i ], hemidiffuseweight );\nhemidiffuse += diffuse * hemicolor;\nvec3 hemihalfvectorsky = normalize( lvector + viewposition );\nfloat hemidotnormalhalfsky = 0.5 * dot( normal, hemihalfvectorsky ) + 0.5;\nfloat hemispecularweightsky = specularstrength * max( pow( hemidotnormalhalfsky, shininess ), 0.0 );\nvec3 lvectorground = -lvector;\nvec3 hemihalfvectorground = normalize( lvectorground + viewposition );\nfloat hemidotnormalhalfground = 0.5 * dot( normal, hemihalfvectorground ) + 0.5;\nfloat hemispecularweightground = specularstrength * max( pow( hemidotnormalhalfground, shininess ), 0.0 );\n#ifdef physically_based_shading\nfloat dotproductground = dot( normal, lvectorground );\nfloat specularnormalization = ( shininess + 2.0001 ) / 8.0;\nvec3 schlicksky = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lvector, hemihalfvectorsky ), 5.0 );\nvec3 schlickground = specular + vec3( 1.0 - specular ) * pow( 1.0 - dot( lvectorground, hemihalfvectorground ), 5.0 );\nhemispecular += hemicolor * specularnormalization * ( schlicksky * hemispecularweightsky * max( dotproduct, 0.0 ) + schlickground * hemispecularweightground * max( dotproductground, 0.0 ) );\n#else\nhemispecular += specular * hemicolor * ( hemispecularweightsky + hemispecularweightground ) * hemidiffuseweight;\n#endif\n}\n#endif\nvec3 totaldiffuse = vec3( 0.0 );\nvec3 totalspecular = vec3( 0.0 );\n#if max_dir_lights > 0\ntotaldiffuse += dirdiffuse;\ntotalspecular += dirspecular;\n#endif\n#if max_hemi_lights > 0\ntotaldiffuse += hemidiffuse;\ntotalspecular += hemispecular;\n#endif\n#if max_point_lights > 0\ntotaldiffuse += pointdiffuse;\ntotalspecular += pointspecular;\n#endif\n#if max_spot_lights > 0\ntotaldiffuse += spotdiffuse;\ntotalspecular += spotspecular;\n#endif\n#ifdef metal\ngl_fragcolor.xyz = gl_fragcolor.xyz * ( emissive + totaldiffuse + ambientlightcolor * ambient + totalspecular );\n#else\ngl_fragcolor.xyz = gl_fragcolor.xyz * ( emissive + totaldiffuse + ambientlightcolor * ambient ) + totalspecular;\n#endif", color_pars_fragment:"#ifdef use_color\nvarying vec3 vcolor;\n#endif",color_fragment:"#ifdef use_color\ngl_fragcolor = gl_fragcolor * vec4( vcolor, opacity );\n#endif",color_pars_vertex:"#ifdef use_color\nvarying vec3 vcolor;\n#endif",color_vertex:"#ifdef use_color\n#ifdef gamma_input\nvcolor = color * color;\n#else\nvcolor = color;\n#endif\n#endif",skinning_pars_vertex:"#ifdef use_skinning\n#ifdef bone_texture\nuniform sampler2d bonetexture;\nmat4 getbonematrix( const in float i ) {\nfloat j = i * 4.0;\nfloat x = mod( j, n_bone_pixel_x );\nfloat y = floor( j / n_bone_pixel_x );\nconst float dx = 1.0 / n_bone_pixel_x;\nconst float dy = 1.0 / n_bone_pixel_y;\ny = dy * ( y + 0.5 );\nvec4 v1 = texture2d( bonetexture, vec2( dx * ( x + 0.5 ), y ) );\nvec4 v2 = texture2d( bonetexture, vec2( dx * ( x + 1.5 ), y ) );\nvec4 v3 = texture2d( bonetexture, vec2( dx * ( x + 2.5 ), y ) );\nvec4 v4 = texture2d( bonetexture, vec2( dx * ( x + 3.5 ), y ) );\nmat4 bone = mat4( v1, v2, v3, v4 );\nreturn bone;\n}\n#else\nuniform mat4 boneglobalmatrices[ max_bones ];\nmat4 getbonematrix( const in float i ) {\nmat4 bone = boneglobalmatrices[ int(i) ];\nreturn bone;\n}\n#endif\n#endif", skinbase_vertex:"#ifdef use_skinning\nmat4 bonematx = getbonematrix( skinindex.x );\nmat4 bonematy = getbonematrix( skinindex.y );\n#endif",skinning_vertex:"#ifdef use_skinning\n#ifdef use_morphtargets\nvec4 skinvertex = vec4( morphed, 1.0 );\n#else\nvec4 skinvertex = vec4( position, 1.0 );\n#endif\nvec4 skinned = bonematx * skinvertex * skinweight.x;\nskinned \t += bonematy * skinvertex * skinweight.y;\n#endif",morphtarget_pars_vertex:"#ifdef use_morphtargets\n#ifndef use_morphnormals\nuniform float morphtargetinfluences[ 8 ];\n#else\nuniform float morphtargetinfluences[ 4 ];\n#endif\n#endif", morphtarget_vertex:"#ifdef use_morphtargets\nvec3 morphed = vec3( 0.0 );\nmorphed += ( morphtarget0 - position ) * morphtargetinfluences[ 0 ];\nmorphed += ( morphtarget1 - position ) * morphtargetinfluences[ 1 ];\nmorphed += ( morphtarget2 - position ) * morphtargetinfluences[ 2 ];\nmorphed += ( morphtarget3 - position ) * morphtargetinfluences[ 3 ];\n#ifndef use_morphnormals\nmorphed += ( morphtarget4 - position ) * morphtargetinfluences[ 4 ];\nmorphed += ( morphtarget5 - position ) * morphtargetinfluences[ 5 ];\nmorphed += ( morphtarget6 - position ) * morphtargetinfluences[ 6 ];\nmorphed += ( morphtarget7 - position ) * morphtargetinfluences[ 7 ];\n#endif\nmorphed += position;\n#endif", default_vertex:"vec4 mvposition;\n#ifdef use_skinning\nmvposition = modelviewmatrix * skinned;\n#endif\n#if !defined( use_skinning ) && defined( use_morphtargets )\nmvposition = modelviewmatrix * vec4( morphed, 1.0 );\n#endif\n#if !defined( use_skinning ) && ! defined( use_morphtargets )\nmvposition = modelviewmatrix * vec4( position, 1.0 );\n#endif\ngl_position = projectionmatrix * mvposition;",morphnormal_vertex:"#ifdef use_morphnormals\nvec3 morphednormal = vec3( 0.0 );\nmorphednormal += ( morphnormal0 - normal ) * morphtargetinfluences[ 0 ];\nmorphednormal += ( morphnormal1 - normal ) * morphtargetinfluences[ 1 ];\nmorphednormal += ( morphnormal2 - normal ) * morphtargetinfluences[ 2 ];\nmorphednormal += ( morphnormal3 - normal ) * morphtargetinfluences[ 3 ];\nmorphednormal += normal;\n#endif", skinnormal_vertex:"#ifdef use_skinning\nmat4 skinmatrix = skinweight.x * bonematx;\nskinmatrix \t+= skinweight.y * bonematy;\n#ifdef use_morphnormals\nvec4 skinnednormal = skinmatrix * vec4( morphednormal, 0.0 );\n#else\nvec4 skinnednormal = skinmatrix * vec4( normal, 0.0 );\n#endif\n#endif",defaultnormal_vertex:"vec3 objectnormal;\n#ifdef use_skinning\nobjectnormal = skinnednormal.xyz;\n#endif\n#if !defined( use_skinning ) && defined( use_morphnormals )\nobjectnormal = morphednormal;\n#endif\n#if !defined( use_skinning ) && ! defined( use_morphnormals )\nobjectnormal = normal;\n#endif\n#ifdef flip_sided\nobjectnormal = -objectnormal;\n#endif\nvec3 transformednormal = normalmatrix * objectnormal;", shadowmap_pars_fragment:"#ifdef use_shadowmap\nuniform sampler2d shadowmap[ max_shadows ];\nuniform vec2 shadowmapsize[ max_shadows ];\nuniform float shadowdarkness[ max_shadows ];\nuniform float shadowbias[ max_shadows ];\nvarying vec4 vshadowcoord[ max_shadows ];\nfloat unpackdepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif",shadowmap_fragment:"#ifdef use_shadowmap\n#ifdef shadowmap_debug\nvec3 frustumcolors[3];\nfrustumcolors[0] = vec3( 1.0, 0.5, 0.0 );\nfrustumcolors[1] = vec3( 0.0, 1.0, 0.8 );\nfrustumcolors[2] = vec3( 0.0, 0.5, 1.0 );\n#endif\n#ifdef shadowmap_cascade\nint infrustumcount = 0;\n#endif\nfloat fdepth;\nvec3 shadowcolor = vec3( 1.0 );\nfor( int i = 0; i < max_shadows; i ++ ) {\nvec3 shadowcoord = vshadowcoord[ i ].xyz / vshadowcoord[ i ].w;\nbvec4 infrustumvec = bvec4 ( shadowcoord.x >= 0.0, shadowcoord.x <= 1.0, shadowcoord.y >= 0.0, shadowcoord.y <= 1.0 );\nbool infrustum = all( infrustumvec );\n#ifdef shadowmap_cascade\ninfrustumcount += int( infrustum );\nbvec3 frustumtestvec = bvec3( infrustum, infrustumcount == 1, shadowcoord.z <= 1.0 );\n#else\nbvec2 frustumtestvec = bvec2( infrustum, shadowcoord.z <= 1.0 );\n#endif\nbool frustumtest = all( frustumtestvec );\nif ( frustumtest ) {\nshadowcoord.z += shadowbias[ i ];\n#if defined( shadowmap_type_pcf )\nfloat shadow = 0.0;\nconst float shadowdelta = 1.0 / 9.0;\nfloat xpixeloffset = 1.0 / shadowmapsize[ i ].x;\nfloat ypixeloffset = 1.0 / shadowmapsize[ i ].y;\nfloat dx0 = -1.25 * xpixeloffset;\nfloat dy0 = -1.25 * ypixeloffset;\nfloat dx1 = 1.25 * xpixeloffset;\nfloat dy1 = 1.25 * ypixeloffset;\nfdepth = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( dx0, dy0 ) ) );\nif ( fdepth < shadowcoord.z ) shadow += shadowdelta;\nfdepth = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( 0.0, dy0 ) ) );\nif ( fdepth < shadowcoord.z ) shadow += shadowdelta;\nfdepth = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( dx1, dy0 ) ) );\nif ( fdepth < shadowcoord.z ) shadow += shadowdelta;\nfdepth = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( dx0, 0.0 ) ) );\nif ( fdepth < shadowcoord.z ) shadow += shadowdelta;\nfdepth = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy ) );\nif ( fdepth < shadowcoord.z ) shadow += shadowdelta;\nfdepth = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( dx1, 0.0 ) ) );\nif ( fdepth < shadowcoord.z ) shadow += shadowdelta;\nfdepth = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( dx0, dy1 ) ) );\nif ( fdepth < shadowcoord.z ) shadow += shadowdelta;\nfdepth = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( 0.0, dy1 ) ) );\nif ( fdepth < shadowcoord.z ) shadow += shadowdelta;\nfdepth = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( dx1, dy1 ) ) );\nif ( fdepth < shadowcoord.z ) shadow += shadowdelta;\nshadowcolor = shadowcolor * vec3( ( 1.0 - shadowdarkness[ i ] * shadow ) );\n#elif defined( shadowmap_type_pcf_soft )\nfloat shadow = 0.0;\nfloat xpixeloffset = 1.0 / shadowmapsize[ i ].x;\nfloat ypixeloffset = 1.0 / shadowmapsize[ i ].y;\nfloat dx0 = -1.0 * xpixeloffset;\nfloat dy0 = -1.0 * ypixeloffset;\nfloat dx1 = 1.0 * xpixeloffset;\nfloat dy1 = 1.0 * ypixeloffset;\nmat3 shadowkernel;\nmat3 depthkernel;\ndepthkernel[0][0] = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( dx0, dy0 ) ) );\nif ( depthkernel[0][0] < shadowcoord.z ) shadowkernel[0][0] = 0.25;\nelse shadowkernel[0][0] = 0.0;\ndepthkernel[0][1] = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( dx0, 0.0 ) ) );\nif ( depthkernel[0][1] < shadowcoord.z ) shadowkernel[0][1] = 0.25;\nelse shadowkernel[0][1] = 0.0;\ndepthkernel[0][2] = unpackdepth( texture2d( shadowmap[ i], shadowcoord.xy + vec2( dx0, dy1 ) ) );\nif ( depthkernel[0][2] < shadowcoord.z ) shadowkernel[0][2] = 0.25;\nelse shadowkernel[0][2] = 0.0;\ndepthkernel[1][0] = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( 0.0, dy0 ) ) );\nif ( depthkernel[1][0] < shadowcoord.z ) shadowkernel[1][0] = 0.25;\nelse shadowkernel[1][0] = 0.0;\ndepthkernel[1][1] = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy ) );\nif ( depthkernel[1][1] < shadowcoord.z ) shadowkernel[1][1] = 0.25;\nelse shadowkernel[1][1] = 0.0;\ndepthkernel[1][2] = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( 0.0, dy1 ) ) );\nif ( depthkernel[1][2] < shadowcoord.z ) shadowkernel[1][2] = 0.25;\nelse shadowkernel[1][2] = 0.0;\ndepthkernel[2][0] = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( dx1, dy0 ) ) );\nif ( depthkernel[2][0] < shadowcoord.z ) shadowkernel[2][0] = 0.25;\nelse shadowkernel[2][0] = 0.0;\ndepthkernel[2][1] = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( dx1, 0.0 ) ) );\nif ( depthkernel[2][1] < shadowcoord.z ) shadowkernel[2][1] = 0.25;\nelse shadowkernel[2][1] = 0.0;\ndepthkernel[2][2] = unpackdepth( texture2d( shadowmap[ i ], shadowcoord.xy + vec2( dx1, dy1 ) ) );\nif ( depthkernel[2][2] < shadowcoord.z ) shadowkernel[2][2] = 0.25;\nelse shadowkernel[2][2] = 0.0;\nvec2 fractionalcoord = 1.0 - fract( shadowcoord.xy * shadowmapsize[i].xy );\nshadowkernel[0] = mix( shadowkernel[1], shadowkernel[0], fractionalcoord.x );\nshadowkernel[1] = mix( shadowkernel[2], shadowkernel[1], fractionalcoord.x );\nvec4 shadowvalues;\nshadowvalues.x = mix( shadowkernel[0][1], shadowkernel[0][0], fractionalcoord.y );\nshadowvalues.y = mix( shadowkernel[0][2], shadowkernel[0][1], fractionalcoord.y );\nshadowvalues.z = mix( shadowkernel[1][1], shadowkernel[1][0], fractionalcoord.y );\nshadowvalues.w = mix( shadowkernel[1][2], shadowkernel[1][1], fractionalcoord.y );\nshadow = dot( shadowvalues, vec4( 1.0 ) );\nshadowcolor = shadowcolor * vec3( ( 1.0 - shadowdarkness[ i ] * shadow ) );\n#else\nvec4 rgbadepth = texture2d( shadowmap[ i ], shadowcoord.xy );\nfloat fdepth = unpackdepth( rgbadepth );\nif ( fdepth < shadowcoord.z )\nshadowcolor = shadowcolor * vec3( 1.0 - shadowdarkness[ i ] );\n#endif\n}\n#ifdef shadowmap_debug\n#ifdef shadowmap_cascade\nif ( infrustum && infrustumcount == 1 ) gl_fragcolor.xyz *= frustumcolors[ i ];\n#else\nif ( infrustum ) gl_fragcolor.xyz *= frustumcolors[ i ];\n#endif\n#endif\n}\n#ifdef gamma_output\nshadowcolor *= shadowcolor;\n#endif\ngl_fragcolor.xyz = gl_fragcolor.xyz * shadowcolor;\n#endif", shadowmap_pars_vertex:"#ifdef use_shadowmap\nvarying vec4 vshadowcoord[ max_shadows ];\nuniform mat4 shadowmatrix[ max_shadows ];\n#endif",shadowmap_vertex:"#ifdef use_shadowmap\nfor( int i = 0; i < max_shadows; i ++ ) {\nvshadowcoord[ i ] = shadowmatrix[ i ] * worldposition;\n}\n#endif",alphatest_fragment:"#ifdef alphatest\nif ( gl_fragcolor.a < alphatest ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef gamma_output\ngl_fragcolor.xyz = sqrt( gl_fragcolor.xyz );\n#endif"}; three.uniformsutils={merge:function(a){var b,c,d,e={};for(b=0;b dashsize ) {\ndiscard;\n}\ngl_fragcolor = vec4( diffuse, opacity );",three.shaderchunk.color_fragment,three.shaderchunk.fog_fragment,"}"].join("\n")},depth:{uniforms:{mnear:{type:"f",value:1},mfar:{type:"f",value:2e3},opacity:{type:"f", value:1}},vertexshader:"void main() {\ngl_position = projectionmatrix * modelviewmatrix * vec4( position, 1.0 );\n}",fragmentshader:"uniform float mnear;\nuniform float mfar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_fragcoord.z / gl_fragcoord.w;\nfloat color = 1.0 - smoothstep( mnear, mfar, depth );\ngl_fragcolor = vec4( vec3( color ), opacity );\n}"},normal:{uniforms:{opacity:{type:"f",value:1}},vertexshader:"varying vec3 vnormal;\nvoid main() {\nvec4 mvposition = modelviewmatrix * vec4( position, 1.0 );\nvnormal = normalize( normalmatrix * normal );\ngl_position = projectionmatrix * mvposition;\n}", fragmentshader:"uniform float opacity;\nvarying vec3 vnormal;\nvoid main() {\ngl_fragcolor = vec4( 0.5 * normalize( vnormal ) + 0.5, opacity );\n}"},normalmap:{uniforms:three.uniformsutils.merge([three.uniformslib.fog,three.uniformslib.lights,three.uniformslib.shadowmap,{enableao:{type:"i",value:0},enablediffuse:{type:"i",value:0},enablespecular:{type:"i",value:0},enablereflection:{type:"i",value:0},enabledisplacement:{type:"i",value:0},tdisplacement:{type:"t",value:null},tdiffuse:{type:"t",value:null}, tcube:{type:"t",value:null},tnormal:{type:"t",value:null},tspecular:{type:"t",value:null},tao:{type:"t",value:null},unormalscale:{type:"v2",value:new three.vector2(1,1)},udisplacementbias:{type:"f",value:0},udisplacementscale:{type:"f",value:1},udiffusecolor:{type:"c",value:new three.color(16777215)},uspecularcolor:{type:"c",value:new three.color(1118481)},uambientcolor:{type:"c",value:new three.color(16777215)},ushininess:{type:"f",value:30},uopacity:{type:"f",value:1},userefract:{type:"i",value:0}, urefractionratio:{type:"f",value:0.98},ureflectivity:{type:"f",value:0.5},uoffset:{type:"v2",value:new three.vector2(0,0)},urepeat:{type:"v2",value:new three.vector2(1,1)},wraprgb:{type:"v3",value:new three.vector3(1,1,1)}}]),fragmentshader:["uniform vec3 uambientcolor;\nuniform vec3 udiffusecolor;\nuniform vec3 uspecularcolor;\nuniform float ushininess;\nuniform float uopacity;\nuniform bool enablediffuse;\nuniform bool enablespecular;\nuniform bool enableao;\nuniform bool enablereflection;\nuniform sampler2d tdiffuse;\nuniform sampler2d tnormal;\nuniform sampler2d tspecular;\nuniform sampler2d tao;\nuniform samplercube tcube;\nuniform vec2 unormalscale;\nuniform bool userefract;\nuniform float urefractionratio;\nuniform float ureflectivity;\nvarying vec3 vtangent;\nvarying vec3 vbinormal;\nvarying vec3 vnormal;\nvarying vec2 vuv;\nuniform vec3 ambientlightcolor;\n#if max_dir_lights > 0\nuniform vec3 directionallightcolor[ max_dir_lights ];\nuniform vec3 directionallightdirection[ max_dir_lights ];\n#endif\n#if max_hemi_lights > 0\nuniform vec3 hemispherelightskycolor[ max_hemi_lights ];\nuniform vec3 hemispherelightgroundcolor[ max_hemi_lights ];\nuniform vec3 hemispherelightdirection[ max_hemi_lights ];\n#endif\n#if max_point_lights > 0\nuniform vec3 pointlightcolor[ max_point_lights ];\nuniform vec3 pointlightposition[ max_point_lights ];\nuniform float pointlightdistance[ max_point_lights ];\n#endif\n#if max_spot_lights > 0\nuniform vec3 spotlightcolor[ max_spot_lights ];\nuniform vec3 spotlightposition[ max_spot_lights ];\nuniform vec3 spotlightdirection[ max_spot_lights ];\nuniform float spotlightanglecos[ max_spot_lights ];\nuniform float spotlightexponent[ max_spot_lights ];\nuniform float spotlightdistance[ max_spot_lights ];\n#endif\n#ifdef wrap_around\nuniform vec3 wraprgb;\n#endif\nvarying vec3 vworldposition;\nvarying vec3 vviewposition;", three.shaderchunk.shadowmap_pars_fragment,three.shaderchunk.fog_pars_fragment,"void main() {\ngl_fragcolor = vec4( vec3( 1.0 ), uopacity );\nvec3 speculartex = vec3( 1.0 );\nvec3 normaltex = texture2d( tnormal, vuv ).xyz * 2.0 - 1.0;\nnormaltex.xy *= unormalscale;\nnormaltex = normalize( normaltex );\nif( enablediffuse ) {\n#ifdef gamma_input\nvec4 texelcolor = texture2d( tdiffuse, vuv );\ntexelcolor.xyz *= texelcolor.xyz;\ngl_fragcolor = gl_fragcolor * texelcolor;\n#else\ngl_fragcolor = gl_fragcolor * texture2d( tdiffuse, vuv );\n#endif\n}\nif( enableao ) {\n#ifdef gamma_input\nvec4 aocolor = texture2d( tao, vuv );\naocolor.xyz *= aocolor.xyz;\ngl_fragcolor.xyz = gl_fragcolor.xyz * aocolor.xyz;\n#else\ngl_fragcolor.xyz = gl_fragcolor.xyz * texture2d( tao, vuv ).xyz;\n#endif\n}\nif( enablespecular )\nspeculartex = texture2d( tspecular, vuv ).xyz;\nmat3 tsb = mat3( normalize( vtangent ), normalize( vbinormal ), normalize( vnormal ) );\nvec3 finalnormal = tsb * normaltex;\n#ifdef flip_sided\nfinalnormal = -finalnormal;\n#endif\nvec3 normal = normalize( finalnormal );\nvec3 viewposition = normalize( vviewposition );\n#if max_point_lights > 0\nvec3 pointdiffuse = vec3( 0.0 );\nvec3 pointspecular = vec3( 0.0 );\nfor ( int i = 0; i < max_point_lights; i ++ ) {\nvec4 lposition = viewmatrix * vec4( pointlightposition[ i ], 1.0 );\nvec3 pointvector = lposition.xyz + vviewposition.xyz;\nfloat pointdistance = 1.0;\nif ( pointlightdistance[ i ] > 0.0 )\npointdistance = 1.0 - min( ( length( pointvector ) / pointlightdistance[ i ] ), 1.0 );\npointvector = normalize( pointvector );\n#ifdef wrap_around\nfloat pointdiffuseweightfull = max( dot( normal, pointvector ), 0.0 );\nfloat pointdiffuseweighthalf = max( 0.5 * dot( normal, pointvector ) + 0.5, 0.0 );\nvec3 pointdiffuseweight = mix( vec3 ( pointdiffuseweightfull ), vec3( pointdiffuseweighthalf ), wraprgb );\n#else\nfloat pointdiffuseweight = max( dot( normal, pointvector ), 0.0 );\n#endif\npointdiffuse += pointdistance * pointlightcolor[ i ] * udiffusecolor * pointdiffuseweight;\nvec3 pointhalfvector = normalize( pointvector + viewposition );\nfloat pointdotnormalhalf = max( dot( normal, pointhalfvector ), 0.0 );\nfloat pointspecularweight = speculartex.r * max( pow( pointdotnormalhalf, ushininess ), 0.0 );\n#ifdef physically_based_shading\nfloat specularnormalization = ( ushininess + 2.0001 ) / 8.0;\nvec3 schlick = uspecularcolor + vec3( 1.0 - uspecularcolor ) * pow( 1.0 - dot( pointvector, pointhalfvector ), 5.0 );\npointspecular += schlick * pointlightcolor[ i ] * pointspecularweight * pointdiffuseweight * pointdistance * specularnormalization;\n#else\npointspecular += pointdistance * pointlightcolor[ i ] * uspecularcolor * pointspecularweight * pointdiffuseweight;\n#endif\n}\n#endif\n#if max_spot_lights > 0\nvec3 spotdiffuse = vec3( 0.0 );\nvec3 spotspecular = vec3( 0.0 );\nfor ( int i = 0; i < max_spot_lights; i ++ ) {\nvec4 lposition = viewmatrix * vec4( spotlightposition[ i ], 1.0 );\nvec3 spotvector = lposition.xyz + vviewposition.xyz;\nfloat spotdistance = 1.0;\nif ( spotlightdistance[ i ] > 0.0 )\nspotdistance = 1.0 - min( ( length( spotvector ) / spotlightdistance[ i ] ), 1.0 );\nspotvector = normalize( spotvector );\nfloat spoteffect = dot( spotlightdirection[ i ], normalize( spotlightposition[ i ] - vworldposition ) );\nif ( spoteffect > spotlightanglecos[ i ] ) {\nspoteffect = max( pow( spoteffect, spotlightexponent[ i ] ), 0.0 );\n#ifdef wrap_around\nfloat spotdiffuseweightfull = max( dot( normal, spotvector ), 0.0 );\nfloat spotdiffuseweighthalf = max( 0.5 * dot( normal, spotvector ) + 0.5, 0.0 );\nvec3 spotdiffuseweight = mix( vec3 ( spotdiffuseweightfull ), vec3( spotdiffuseweighthalf ), wraprgb );\n#else\nfloat spotdiffuseweight = max( dot( normal, spotvector ), 0.0 );\n#endif\nspotdiffuse += spotdistance * spotlightcolor[ i ] * udiffusecolor * spotdiffuseweight * spoteffect;\nvec3 spothalfvector = normalize( spotvector + viewposition );\nfloat spotdotnormalhalf = max( dot( normal, spothalfvector ), 0.0 );\nfloat spotspecularweight = speculartex.r * max( pow( spotdotnormalhalf, ushininess ), 0.0 );\n#ifdef physically_based_shading\nfloat specularnormalization = ( ushininess + 2.0001 ) / 8.0;\nvec3 schlick = uspecularcolor + vec3( 1.0 - uspecularcolor ) * pow( 1.0 - dot( spotvector, spothalfvector ), 5.0 );\nspotspecular += schlick * spotlightcolor[ i ] * spotspecularweight * spotdiffuseweight * spotdistance * specularnormalization * spoteffect;\n#else\nspotspecular += spotdistance * spotlightcolor[ i ] * uspecularcolor * spotspecularweight * spotdiffuseweight * spoteffect;\n#endif\n}\n}\n#endif\n#if max_dir_lights > 0\nvec3 dirdiffuse = vec3( 0.0 );\nvec3 dirspecular = vec3( 0.0 );\nfor( int i = 0; i < max_dir_lights; i++ ) {\nvec4 ldirection = viewmatrix * vec4( directionallightdirection[ i ], 0.0 );\nvec3 dirvector = normalize( ldirection.xyz );\n#ifdef wrap_around\nfloat directionallightweightingfull = max( dot( normal, dirvector ), 0.0 );\nfloat directionallightweightinghalf = max( 0.5 * dot( normal, dirvector ) + 0.5, 0.0 );\nvec3 dirdiffuseweight = mix( vec3( directionallightweightingfull ), vec3( directionallightweightinghalf ), wraprgb );\n#else\nfloat dirdiffuseweight = max( dot( normal, dirvector ), 0.0 );\n#endif\ndirdiffuse += directionallightcolor[ i ] * udiffusecolor * dirdiffuseweight;\nvec3 dirhalfvector = normalize( dirvector + viewposition );\nfloat dirdotnormalhalf = max( dot( normal, dirhalfvector ), 0.0 );\nfloat dirspecularweight = speculartex.r * max( pow( dirdotnormalhalf, ushininess ), 0.0 );\n#ifdef physically_based_shading\nfloat specularnormalization = ( ushininess + 2.0001 ) / 8.0;\nvec3 schlick = uspecularcolor + vec3( 1.0 - uspecularcolor ) * pow( 1.0 - dot( dirvector, dirhalfvector ), 5.0 );\ndirspecular += schlick * directionallightcolor[ i ] * dirspecularweight * dirdiffuseweight * specularnormalization;\n#else\ndirspecular += directionallightcolor[ i ] * uspecularcolor * dirspecularweight * dirdiffuseweight;\n#endif\n}\n#endif\n#if max_hemi_lights > 0\nvec3 hemidiffuse = vec3( 0.0 );\nvec3 hemispecular = vec3( 0.0 );\nfor( int i = 0; i < max_hemi_lights; i ++ ) {\nvec4 ldirection = viewmatrix * vec4( hemispherelightdirection[ i ], 0.0 );\nvec3 lvector = normalize( ldirection.xyz );\nfloat dotproduct = dot( normal, lvector );\nfloat hemidiffuseweight = 0.5 * dotproduct + 0.5;\nvec3 hemicolor = mix( hemispherelightgroundcolor[ i ], hemispherelightskycolor[ i ], hemidiffuseweight );\nhemidiffuse += udiffusecolor * hemicolor;\nvec3 hemihalfvectorsky = normalize( lvector + viewposition );\nfloat hemidotnormalhalfsky = 0.5 * dot( normal, hemihalfvectorsky ) + 0.5;\nfloat hemispecularweightsky = speculartex.r * max( pow( hemidotnormalhalfsky, ushininess ), 0.0 );\nvec3 lvectorground = -lvector;\nvec3 hemihalfvectorground = normalize( lvectorground + viewposition );\nfloat hemidotnormalhalfground = 0.5 * dot( normal, hemihalfvectorground ) + 0.5;\nfloat hemispecularweightground = speculartex.r * max( pow( hemidotnormalhalfground, ushininess ), 0.0 );\n#ifdef physically_based_shading\nfloat dotproductground = dot( normal, lvectorground );\nfloat specularnormalization = ( ushininess + 2.0001 ) / 8.0;\nvec3 schlicksky = uspecularcolor + vec3( 1.0 - uspecularcolor ) * pow( 1.0 - dot( lvector, hemihalfvectorsky ), 5.0 );\nvec3 schlickground = uspecularcolor + vec3( 1.0 - uspecularcolor ) * pow( 1.0 - dot( lvectorground, hemihalfvectorground ), 5.0 );\nhemispecular += hemicolor * specularnormalization * ( schlicksky * hemispecularweightsky * max( dotproduct, 0.0 ) + schlickground * hemispecularweightground * max( dotproductground, 0.0 ) );\n#else\nhemispecular += uspecularcolor * hemicolor * ( hemispecularweightsky + hemispecularweightground ) * hemidiffuseweight;\n#endif\n}\n#endif\nvec3 totaldiffuse = vec3( 0.0 );\nvec3 totalspecular = vec3( 0.0 );\n#if max_dir_lights > 0\ntotaldiffuse += dirdiffuse;\ntotalspecular += dirspecular;\n#endif\n#if max_hemi_lights > 0\ntotaldiffuse += hemidiffuse;\ntotalspecular += hemispecular;\n#endif\n#if max_point_lights > 0\ntotaldiffuse += pointdiffuse;\ntotalspecular += pointspecular;\n#endif\n#if max_spot_lights > 0\ntotaldiffuse += spotdiffuse;\ntotalspecular += spotspecular;\n#endif\n#ifdef metal\ngl_fragcolor.xyz = gl_fragcolor.xyz * ( totaldiffuse + ambientlightcolor * uambientcolor + totalspecular );\n#else\ngl_fragcolor.xyz = gl_fragcolor.xyz * ( totaldiffuse + ambientlightcolor * uambientcolor ) + totalspecular;\n#endif\nif ( enablereflection ) {\nvec3 vreflect;\nvec3 cameratovertex = normalize( vworldposition - cameraposition );\nif ( userefract ) {\nvreflect = refract( cameratovertex, normal, urefractionratio );\n} else {\nvreflect = reflect( cameratovertex, normal );\n}\nvec4 cubecolor = texturecube( tcube, vec3( -vreflect.x, vreflect.yz ) );\n#ifdef gamma_input\ncubecolor.xyz *= cubecolor.xyz;\n#endif\ngl_fragcolor.xyz = mix( gl_fragcolor.xyz, cubecolor.xyz, speculartex.r * ureflectivity );\n}", three.shaderchunk.shadowmap_fragment,three.shaderchunk.linear_to_gamma_fragment,three.shaderchunk.fog_fragment,"}"].join("\n"),vertexshader:["attribute vec4 tangent;\nuniform vec2 uoffset;\nuniform vec2 urepeat;\nuniform bool enabledisplacement;\n#ifdef vertex_textures\nuniform sampler2d tdisplacement;\nuniform float udisplacementscale;\nuniform float udisplacementbias;\n#endif\nvarying vec3 vtangent;\nvarying vec3 vbinormal;\nvarying vec3 vnormal;\nvarying vec2 vuv;\nvarying vec3 vworldposition;\nvarying vec3 vviewposition;", three.shaderchunk.skinning_pars_vertex,three.shaderchunk.shadowmap_pars_vertex,"void main() {",three.shaderchunk.skinbase_vertex,three.shaderchunk.skinnormal_vertex,"#ifdef use_skinning\nvnormal = normalize( normalmatrix * skinnednormal.xyz );\nvec4 skinnedtangent = skinmatrix * vec4( tangent.xyz, 0.0 );\nvtangent = normalize( normalmatrix * skinnedtangent.xyz );\n#else\nvnormal = normalize( normalmatrix * normal );\nvtangent = normalize( normalmatrix * tangent.xyz );\n#endif\nvbinormal = normalize( cross( vnormal, vtangent ) * tangent.w );\nvuv = uv * urepeat + uoffset;\nvec3 displacedposition;\n#ifdef vertex_textures\nif ( enabledisplacement ) {\nvec3 dv = texture2d( tdisplacement, uv ).xyz;\nfloat df = udisplacementscale * dv.x + udisplacementbias;\ndisplacedposition = position + normalize( normal ) * df;\n} else {\n#ifdef use_skinning\nvec4 skinvertex = vec4( position, 1.0 );\nvec4 skinned = bonematx * skinvertex * skinweight.x;\nskinned \t += bonematy * skinvertex * skinweight.y;\ndisplacedposition = skinned.xyz;\n#else\ndisplacedposition = position;\n#endif\n}\n#else\n#ifdef use_skinning\nvec4 skinvertex = vec4( position, 1.0 );\nvec4 skinned = bonematx * skinvertex * skinweight.x;\nskinned \t += bonematy * skinvertex * skinweight.y;\ndisplacedposition = skinned.xyz;\n#else\ndisplacedposition = position;\n#endif\n#endif\nvec4 mvposition = modelviewmatrix * vec4( displacedposition, 1.0 );\nvec4 worldposition = modelmatrix * vec4( displacedposition, 1.0 );\ngl_position = projectionmatrix * mvposition;\nvworldposition = worldposition.xyz;\nvviewposition = -mvposition.xyz;\n#ifdef use_shadowmap\nfor( int i = 0; i < max_shadows; i ++ ) {\nvshadowcoord[ i ] = shadowmatrix[ i ] * worldposition;\n}\n#endif\n}"].join("\n")}, cube:{uniforms:{tcube:{type:"t",value:null},tflip:{type:"f",value:-1}},vertexshader:"varying vec3 vworldposition;\nvoid main() {\nvec4 worldposition = modelmatrix * vec4( position, 1.0 );\nvworldposition = worldposition.xyz;\ngl_position = projectionmatrix * modelviewmatrix * vec4( position, 1.0 );\n}",fragmentshader:"uniform samplercube tcube;\nuniform float tflip;\nvarying vec3 vworldposition;\nvoid main() {\ngl_fragcolor = texturecube( tcube, vec3( tflip * vworldposition.x, vworldposition.yz ) );\n}"}, depthrgba:{uniforms:{},vertexshader:[three.shaderchunk.morphtarget_pars_vertex,three.shaderchunk.skinning_pars_vertex,"void main() {",three.shaderchunk.skinbase_vertex,three.shaderchunk.morphtarget_vertex,three.shaderchunk.skinning_vertex,three.shaderchunk.default_vertex,"}"].join("\n"),fragmentshader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_fragdata[ 0 ] = pack_depth( gl_fragcoord.z );\n}"}};three.webglrenderer=function(a){function b(a){if(a.__webglcustomattributeslist)for(var b in a.__webglcustomattributeslist)j.deletebuffer(a.__webglcustomattributeslist[b].buffer)}function c(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){void 0===a.__webglcustomattributeslist&&(a.__webglcustomattributeslist=[]);for(var e in d.attributes){var f=d.attributes[e];if(!f.__webglinitialized||f.createuniquebuffers){f.__webglinitialized=!0;var g=1;"v2"===f.type?g=2:"v3"===f.type?g=3:"v4"===f.type? g=4:"c"===f.type&&(g=3);f.size=g;f.array=new float32array(c*g);f.buffer=j.createbuffer();f.buffer.belongstoattribute=e;f.needsupdate=!0}a.__webglcustomattributeslist.push(f)}}}function d(a,b){var c=b.geometry,d=a.faces3,h=a.faces4,i=3*d.length+4*h.length,k=1*d.length+2*h.length,h=3*d.length+4*h.length,d=e(b,a),n=g(d),l=f(d),m=d.vertexcolors?d.vertexcolors:!1;a.__vertexarray=new float32array(3*i);l&&(a.__normalarray=new float32array(3*i));c.hastangents&&(a.__tangentarray=new float32array(4*i));m&& (a.__colorarray=new float32array(3*i));if(n){if(0l;l++)n.autoscalecubemaps&&!f?(m=k,r=l,t=c.image[l],y=gd,t.width<=y&&t.height<=y||(z=math.max(t.width,t.height),v=math.floor(t.width*y/z),y=math.floor(t.height*y/z),z=document.createelement("canvas"),z.width=v,z.height=y,z.getcontext("2d").drawimage(t,0,0,t.width,t.height,0,0,v,y),t=z),m[r]=t):k[l]=c.image[l];l=k[0];m=0===(l.width&l.width-1)&&0===(l.height&l.height-1);r=l(c.format); t=l(c.type);w(j.texture_cube_map,c,m);for(l=0;6>l;l++)if(f){y=k[l].mipmaps;z=0;for(b=y.length;z=mc&&console.warn("webglrenderer: trying to use "+ a+" texture units while this gpu supports only "+mc);y+=1;return a}function c(a,b){a._modelviewmatrix.multiplymatrices(b.matrixworldinverse,a.matrixworld);a._normalmatrix.getinverse(a._modelviewmatrix);a._normalmatrix.transpose()}function x(a,b,c,d){a[b]=c.r*c.r*d;a[b+1]=c.g*c.g*d;a[b+2]=c.b*c.b*d}function g(a,b,c,d){a[b]=c.r*d;a[b+1]=c.g*d;a[b+2]=c.b*d}function j(a){a!==ub&&(j.linewidth(a),ub=a)}function e(a,b,c){ab!==a&&(a?j.enable(j.polygon_offset_fill):j.disable(j.polygon_offset_fill),ab=a);if(a&& (fa!==b||xa!==c))j.polygonoffset(b,c),fa=b,xa=c}function h(a){for(var a=a.split("\n"),b=0,c=a.length;bb;b++)j.deleteframebuffer(a.__webglframebuffer[b]),j.deleterenderbuffer(a.__webglrenderbuffer[b]); else j.deleteframebuffer(a.__webglframebuffer),j.deleterenderbuffer(a.__webglrenderbuffer);n.info.memory.textures--},x=function(a){a=a.target;a.removeeventlistener("dispose",x);pc(a)},pc=function(a){var b=a.program;if(void 0!==b){a.program=void 0;var c,d,e=!1,a=0;for(c=ma.length;ad.numsupportedmorphtargets?(i.sort(n),i.length=d.numsupportedmorphtargets):i.length>d.numsupportedmorphnormals?i.sort(n):0===i.length&&i.push([0,0]);for(h=0;hxa;xa++)nc=ab[xa],fb[kb]=nc.x,fb[kb+1]=nc.y,fb[kb+2]=nc.z,kb+=3;else for(xa=0;3>xa;xa++)fb[kb]=xa.x,fb[kb+1]=xa.y,fb[kb+2]=xa.z,kb+=3;d=0;for(v=va.length;dxa;xa++)nc= ab[xa],fb[kb]=nc.x,fb[kb+1]=nc.y,fb[kb+2]=nc.z,kb+=3;else for(xa=0;4>xa;xa++)fb[kb]=xa.x,fb[kb+1]=xa.y,fb[kb+2]=xa.z,kb+=3;j.bindbuffer(j.array_buffer,sa.__webglnormalbuffer);j.bufferdata(j.array_buffer,fb,pa)}if(cc&&pd&&bb){d=0;for(v=ua.length;dxa;xa++)ab=pb[xa],dc[ic]=ab.x,dc[ic+1]=ab.y,ic+=2;d=0;for(v=va.length;dxa;xa++)ab=pb[xa],dc[ic]=ab.x,dc[ic+1]=ab.y,ic+=2;0xa;xa++)yc=ub[xa],ec[jc]=yc.x,ec[jc+1]=yc.y,jc+=2;d=0;for(v=va.length;dxa;xa++)yc=ub[xa],ec[jc]=yc.x,ec[jc+1]=yc.y,jc+=2;0f;f++){a.__webglframebuffer[f]=j.createframebuffer();a.__webglrenderbuffer[f]=j.createrenderbuffer();j.teximage2d(j.texture_cube_map_positive_x+f,0,d,a.width,a.height,0,d,e,null);var g=a,i=j.texture_cube_map_positive_x+f;j.bindframebuffer(j.framebuffer, a.__webglframebuffer[f]);j.framebuffertexture2d(j.framebuffer,j.color_attachment0,i,g.__webgltexture,0);f(a.__webglrenderbuffer[f],a)}c&&j.generatemipmap(j.texture_cube_map)}else a.__webglframebuffer=j.createframebuffer(),a.__webglrenderbuffer=a.sharedepthfrom?a.sharedepthfrom.__webglrenderbuffer:j.createrenderbuffer(),j.bindtexture(j.texture_2d,a.__webgltexture),w(j.texture_2d,a,c),j.teximage2d(j.texture_2d,0,d,a.width,a.height,0,d,e,null),d=j.texture_2d,j.bindframebuffer(j.framebuffer,a.__webglframebuffer), j.framebuffertexture2d(j.framebuffer,j.color_attachment0,d,a.__webgltexture,0),a.sharedepthfrom?a.depthbuffer&&!a.stencilbuffer?j.framebufferrenderbuffer(j.framebuffer,j.depth_attachment,j.renderbuffer,a.__webglrenderbuffer):a.depthbuffer&&a.stencilbuffer&&j.framebufferrenderbuffer(j.framebuffer,j.depth_stencil_attachment,j.renderbuffer,a.__webglrenderbuffer):f(a.__webglrenderbuffer,a),c&&j.generatemipmap(j.texture_2d);b?j.bindtexture(j.texture_cube_map,null):j.bindtexture(j.texture_2d,null);j.bindrenderbuffer(j.renderbuffer, null);j.bindframebuffer(j.framebuffer,null)}a?(b=b?a.__webglframebuffer[a.activecubeface]:a.__webglframebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=fc,a=ab,d=ib,e=jb);b!==pa&&(j.bindframebuffer(j.framebuffer,b),j.viewport(d,e,c,a),pa=b);mc=c;pb=a};this.shadowmapplugin=new three.shadowmapplugin;this.addpreplugin(this.shadowmapplugin);this.addpostplugin(new three.spriteplugin);this.addpostplugin(new three.lensflareplugin)};three.webglrendertarget=function(a,b,c){three.eventdispatcher.call(this);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=null}; three.webglrendertarget.prototype.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}; three.webglrendertarget.prototype.dispose=function(){this.dispatchevent({type:"dispose"})};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.renderablevertex=function(){this.positionworld=new three.vector3;this.positionscreen=new three.vector4;this.visible=!0};three.renderablevertex.prototype.copy=function(a){this.positionworld.copy(a.positionworld);this.positionscreen.copy(a.positionscreen)};three.renderableface3=function(){this.v1=new three.renderablevertex;this.v2=new three.renderablevertex;this.v3=new three.renderablevertex;this.centroidmodel=new three.vector3;this.normalmodel=new three.vector3;this.normalmodelview=new three.vector3;this.vertexnormalslength=0;this.vertexnormalsmodel=[new three.vector3,new three.vector3,new three.vector3];this.vertexnormalsmodelview=[new three.vector3,new three.vector3,new three.vector3];this.material=this.color=null;this.uvs=[[]];this.z=null};three.renderableface4=function(){this.v1=new three.renderablevertex;this.v2=new three.renderablevertex;this.v3=new three.renderablevertex;this.v4=new three.renderablevertex;this.centroidmodel=new three.vector3;this.normalmodel=new three.vector3;this.normalmodelview=new three.vector3;this.vertexnormalslength=0;this.vertexnormalsmodel=[new three.vector3,new three.vector3,new three.vector3,new three.vector3];this.vertexnormalsmodelview=[new three.vector3,new three.vector3,new three.vector3,new three.vector3]; this.material=this.color=null;this.uvs=[[]];this.z=null};three.renderableobject=function(){this.z=this.object=null};three.renderableparticle=function(){this.rotation=this.z=this.y=this.x=this.object=null;this.scale=new three.vector2;this.material=null};three.renderableline=function(){this.z=null;this.v1=new three.renderablevertex;this.v2=new three.renderablevertex;this.material=null};three.geometryutils={merge:function(a,b){var c,d,e=a.vertices.length,f=b instanceof three.mesh?b.geometry:b,g=a.vertices,h=f.vertices,i=a.faces,k=f.faces,l=a.facevertexuvs[0],f=f.facevertexuvs[0];b instanceof three.mesh&&(b.matrixautoupdate&&b.updatematrix(),c=b.matrix,d=new three.matrix3,d.getinverse(c),d.transpose());for(var m=0,n=h.length;ma?b(c,e-1):k[e]>8&255,i>>16&255,i>>24&255)),d}d.mipmapcount=1;h[2]&131072&&!1!==b&&(d.mipmapcount=math.max(1,h[7]));d.iscubemap=h[28]&512?!0:!1;d.width=h[4];d.height=h[3];for(var h=h[1]+4,f=d.width,g=d.height,i=d.iscubemap? 6:1,k=0;km-1?0:m-1,s=m+1>e-1?e-1:m+1,r=0>l-1?0:l-1,p=l+1>d-1?d-1:l+1,q=[],y=[0,0,h[4*(m*d+l)]/255*b];q.push([-1,0,h[4*(m*d+r)]/255*b]);q.push([-1,-1,h[4*(n*d+r)]/255*b]);q.push([0,-1,h[4*(n*d+l)]/255*b]);q.push([1,-1,h[4*(n*d+p)]/255*b]);q.push([1,0,h[4*(m*d+p)]/255*b]);q.push([1,1,h[4*(s*d+p)]/255*b]);q.push([0,1,h[4*(s*d+l)]/255*b]);q.push([-1,1,h[4*(s*d+r)]/255*b]);n=[];r=q.length;for(s=0;se)return null;var f=[],g=[],h=[],i,k,l;if(0=m--){console.log("warning, unable to triangulate polygon!");break}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);l=k+1;e<=l&&(l=0);var n;a:{var s=n=void 0,r=void 0,p=void 0,q=void 0,y=void 0,v=void 0,z=void 0,t= void 0,s=a[g[i]].x,r=a[g[i]].y,p=a[g[k]].x,q=a[g[k]].y,y=a[g[l]].x,v=a[g[l]].y;if(1e-10>(p-s)*(v-r)-(q-r)*(y-s))n=!1;else{var a=void 0,i=void 0,c=void 0,x=void 0,g=void 0,j=void 0,e=void 0,h=void 0,b=void 0,w=void 0,b=h=e=t=z=void 0,a=y-p,i=v-q,c=s-y,x=r-v,g=p-s,j=q-r;for(n=0;ni)g=d+1;else if(0b&&(b=0);1d.length-2?d.length-1:a+1;c[3]=a>d.length-3?d.length-1:a+2;b.x=three.curve.utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,e);b.y=three.curve.utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,e);return b}; 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.getpoint=function(a){var b=this.aendangle-this.astartangle;this.aclockwise||(a=1-a);b=this.astartangle+a*b;a=this.ax+this.xradius*math.cos(b);b=this.ay+this.yradius*math.sin(b);return new three.vector2(a,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.curve.utils={tangentquadraticbezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentcubicbezier:function(a,b,c,d,e){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*e},tangentspline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,e){var a=0.5*(c-a),d=0.5*(d-b),f=e*e;return(2*b-2*c+a+d)*e*f+(-3*b+3*c-2*a-d)*f+a*e+b}}; three.curve.create=function(a,b){a.prototype=object.create(three.curve.prototype);a.prototype.getpoint=b;return a};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,c;b=three.shape.utils.b2(a,this.v0.x,this.v1.x,this.v2.x);c=three.shape.utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=three.shape.utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new three.vector3(b,c,a)}); 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,c;b=three.shape.utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);c=three.shape.utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=three.shape.utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new three.vector3(b,c,a)}); three.splinecurve3=three.curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=new three.vector3,c=[],d=this.points,e,a=(d.length-1)*a;e=math.floor(a);a-=e;c[0]=0==e?e:e-1;c[1]=e;c[2]=e>d.length-2?d.length-1:e+1;c[3]=e>d.length-3?d.length-1:e+2;e=d[c[0]];var f=d[c[1]],g=d[c[2]],c=d[c[3]];b.x=three.curve.utils.interpolate(e.x,f.x,g.x,c.x,a);b.y=three.curve.utils.interpolate(e.y,f.y,g.y,c.y,a);b.z=three.curve.utils.interpolate(e.z,f.z,g.z,c.z,a);return b}); three.closedsplinecurve3=three.curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=new three.vector3,c=[],d=this.points,e;e=(d.length-0)*a;a=math.floor(e);e-=a;a+=0=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(){var a,b,c,d,e=[],f=new three.path;a=0;for(b=this.actions.length;a h&&(h+=c.length);h%=c.length;0>g&&(g+=k.length);g%=k.length;e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:k.length-1;p=[k[g],c[h],c[e]];p=three.fontutils.triangulate.area(p);q=[k[g],k[f],c[h]];q=three.fontutils.triangulate.area(q);m+n>p+q&&(h=s,g=l,0>h&&(h+=c.length),h%=c.length,0>g&&(g+=k.length),g%=k.length,e=0<=h-1?h-1:c.length-1,f=0<=g-1?g-1:k.length-1);m=c.slice(0,h);n=c.slice(h);s=k.slice(g);l=k.slice(0,g);f=[k[g],k[f],c[h]];r.push([k[g],c[h],c[e]]);r.push(f);c=m.concat(s).concat(l).concat(n)}return{shape:c, isolatedpts:r,allpoints:d}},triangulateshape:function(a,b){var c=three.shape.utils.removeholes(a,b),d=c.allpoints,e=c.isolatedpts,c=three.fontutils.triangulate(c.shape,!1),f,g,h,i,k={};f=0;for(g=d.length;fd;d++)i=h[d].x+":"+h[d].y,i=k[i],void 0!==i&&(h[d]=i)}f=0;for(g=e.length;fd;d++)i=h[d].x+":"+h[d].y,i=k[i],void 0!==i&&(h[d]=i)}return c.concat(e)}, 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.animationhandler=function(){var a=[],b={},c={update:function(b){for(var c=0;ca.hierarchy[c].keys[d].time&& (a.hierarchy[c].keys[d].time=0),void 0!==a.hierarchy[c].keys[d].rot&&!(a.hierarchy[c].keys[d].rot instanceof three.quaternion)){var h=a.hierarchy[c].keys[d].rot;a.hierarchy[c].keys[d].rot=new three.quaternion(h[0],h[1],h[2],h[3])}if(a.hierarchy[c].keys.length&&void 0!==a.hierarchy[c].keys[0].morphtargets){h={};for(d=0;ds;s++){c=b[s];g=i.prevkey[c];h=i.nextkey[c];if(h.time<=l){if(kd||1d?0:1;if("pos"===c)if(c=a.position,this.interpolationtype===three.animationhandler.linear)c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+ (f[2]-e[2])*d;else{if(this.interpolationtype===three.animationhandler.catmullrom||this.interpolationtype===three.animationhandler.catmullrom_forward)this.points[0]=this.getprevkeywith("pos",m,g.index-1).pos,this.points[1]=e,this.points[2]=f,this.points[3]=this.getnextkeywith("pos",m,h.index+1).pos,d=0.33*d+0.33,e=this.interpolatecatmullrom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationtype===three.animationhandler.catmullrom_forward&&(d=this.interpolatecatmullrom(this.points,1.01*d), this.target.set(d[0],d[1],d[2]),this.target.sub(c),this.target.y=0,this.target.normalize(),d=math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0))}else"rot"===c?three.quaternion.slerp(e,f,a.quaternion,d):"scl"===c&&(c=a.scale,c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d)}}}}; three.animation.prototype.interpolatecatmullrom=function(a,b){var c=[],d=[],e,f,g,h,i,k;e=(a.length-1)*b;f=math.floor(e);e-=f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];i=a[c[2]];k=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],k[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],k[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],k[2],e,c,g);return d}; three.animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b};three.animation.prototype.getnextkeywith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationtype===three.animationhandler.catmullrom||this.interpolationtype===three.animationhandler.catmullrom_forward?c=g?b.interpolate(c,g):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updatematrix();d.matrixworldneedsupdate=!0}}if(this.jitcompile&&void 0===f[0][e]){this.hierarchy[0].updatematrixworld(!0);for(a=0;ag?(b=math.atan2(b.y-a.y,b.x-a.x),a=math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=2*math.pi),c=(b+a)/2,a=-math.cos(c),c=-math.sin(c),new three.vector2(a,c)):d.multiplyscalar(g).add(i).sub(a).clone()}function e(c,d){var e,f;for(m=c.length;0<=--m;){e=m;f=m-1;0>f&&(f=c.length-1);for(var g=0,i=s+2*l, g=0;gmath.abs(c-i)?[new three.vector2(b,1-e),new three.vector2(d,1-f),new three.vector2(k,1-g),new three.vector2(m,1-a)]:[new three.vector2(c,1-e),new three.vector2(i,1-f),new three.vector2(l,1-g),new three.vector2(n,1-a)]}};three.extrudegeometry.__v1=new three.vector2;three.extrudegeometry.__v2=new three.vector2;three.extrudegeometry.__v3=new three.vector2;three.extrudegeometry.__v4=new three.vector2; three.extrudegeometry.__v5=new three.vector2;three.extrudegeometry.__v6=new three.vector2;three.shapegeometry=function(a,b){three.geometry.call(this);!1===a instanceof array&&(a=[a]);this.shapebb=a[a.length-1].getboundingbox();this.addshapelist(a,b);this.computecentroids();this.computefacenormals()};three.shapegeometry.prototype=object.create(three.geometry.prototype);three.shapegeometry.prototype.addshapelist=function(a,b){for(var c=0,d=a.length;cd?(d=new three.face3(a.index,b.index,c.index,[a.clone(),b.clone(),c.clone()]),d.centroid.add(a).add(b).add(c).dividescalar(3),d.normal=d.centroid.clone().normalize(),i.faces.push(d),d=math.atan2(d.centroid.z,-d.centroid.x),i.facevertexuvs[0].push([h(a.uv, a,d),h(b.uv,b,d),h(c.uv,c,d)])):(d-=1,f(a,g(a,b),g(a,c),d),f(g(a,b),b,g(b,c),d),f(g(a,c),g(b,c),c,d),f(g(a,b),g(b,c),g(a,c),d))}function g(a,b){m[a.index]||(m[a.index]=[]);m[b.index]||(m[b.index]=[]);var c=m[a.index][b.index];void 0===c&&(m[a.index][b.index]=m[b.index][a.index]=c=e((new three.vector3).addvectors(a,b).dividescalar(2)));return c}function h(a,b,c){0>c&&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+0.5,a.y));return a}three.geometry.call(this); for(var c=c||1,d=d||0,i=this,k=0,l=a.length;k=l){for(k=0;3>k;k++){l=[i[k],i[(k+1)%3]];m=!0;for(n=0;nh;h++)void 0===f[g[h]]&&(f[g[h]]=e++,this.vertices.push(a[g[h]])),g[h]=f[g[h]]}for(d=0;db.y?this.rotation.set(math.pi,0,0):(a=three.arrowhelper.__v2.set(b.z,0,-b.x).normalize(),b=math.acos(b.y),a=three.arrowhelper.__q1.setfromaxisangle(a,b),this.rotation.seteulerfromquaternion(a,this.eulerorder))}; three.arrowhelper.prototype.setlength=function(a){this.scale.set(a,a,a)};three.arrowhelper.prototype.setcolor=function(a){this.line.material.color.sethex(a);this.cone.material.color.sethex(a)};three.arrowhelper.__v1=new three.vector3;three.arrowhelper.__v2=new three.vector3;three.arrowhelper.__q1=new three.quaternion;three.camerahelper=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.geometry.vertices.push(new three.vector3);d.geometry.colors.push(new three.color(b));void 0===d.pointmap[a]&&(d.pointmap[a]=[]);d.pointmap[a].push(d.geometry.vertices.length-1)}three.line.call(this);var d=this;this.geometry=new three.geometry;this.material=new three.linebasicmaterial({color:16777215,vertexcolors:three.facecolors});this.type=three.linepieces;this.matrixworld=a.matrixworld;this.matrixautoupdate=!1;this.pointmap= {};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);this.camera=a;this.update(a)};three.camerahelper.prototype=object.create(three.line.prototype); three.camerahelper.prototype.update=function(){function a(a,d,e,f){three.camerahelper.__v.set(d,e,f);three.camerahelper.__projector.unprojectvector(three.camerahelper.__v,three.camerahelper.__c);a=b.pointmap[a];if(void 0!==a){d=0;for(e=a.length;dh.end&&(h.end=f);c||(c=i)}}for(i in d)h=d[i],this.createanimation(i,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):console.warn("animation["+a+"] undefined")};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}}};three.lensflareplugin=function(){function a(a,c){var d=b.createprogram(),e=b.createshader(b.fragment_shader),f=b.createshader(b.vertex_shader),g="precision "+c+" float;\n";b.shadersource(e,g+a.fragmentshader);b.shadersource(f,g+a.vertexshader);b.compileshader(e);b.compileshader(f);b.attachshader(d,e);b.attachshader(d,f);b.linkprogram(d);return d}var b,c,d,e,f,g,h,i,k,l,m,n,s;this.init=function(r){b=r.context;c=r;d=r.getprecision();e=new float32array(16);f=new uint16array(6);r=0;e[r++]=-1;e[r++]=-1; e[r++]=0;e[r++]=0;e[r++]=1;e[r++]=-1;e[r++]=1;e[r++]=0;e[r++]=1;e[r++]=1;e[r++]=1;e[r++]=1;e[r++]=-1;e[r++]=1;e[r++]=0;e[r++]=1;r=0;f[r++]=0;f[r++]=1;f[r++]=2;f[r++]=0;f[r++]=2;f[r++]=3;g=b.createbuffer();h=b.createbuffer();b.bindbuffer(b.array_buffer,g);b.bufferdata(b.array_buffer,e,b.static_draw);b.bindbuffer(b.element_array_buffer,h);b.bufferdata(b.element_array_buffer,f,b.static_draw);i=b.createtexture();k=b.createtexture();b.bindtexture(b.texture_2d,i);b.teximage2d(b.texture_2d,0,b.rgb,16,16, 0,b.rgb,b.unsigned_byte,null);b.texparameteri(b.texture_2d,b.texture_wrap_s,b.clamp_to_edge);b.texparameteri(b.texture_2d,b.texture_wrap_t,b.clamp_to_edge);b.texparameteri(b.texture_2d,b.texture_mag_filter,b.nearest);b.texparameteri(b.texture_2d,b.texture_min_filter,b.nearest);b.bindtexture(b.texture_2d,k);b.teximage2d(b.texture_2d,0,b.rgba,16,16,0,b.rgba,b.unsigned_byte,null);b.texparameteri(b.texture_2d,b.texture_wrap_s,b.clamp_to_edge);b.texparameteri(b.texture_2d,b.texture_wrap_t,b.clamp_to_edge); b.texparameteri(b.texture_2d,b.texture_mag_filter,b.nearest);b.texparameteri(b.texture_2d,b.texture_min_filter,b.nearest);0>=b.getparameter(b.max_vertex_texture_image_units)?(l=!1,m=a(three.shaderflares.lensflare,d)):(l=!0,m=a(three.shaderflares.lensflarevertextexture,d));n={};s={};n.vertex=b.getattriblocation(m,"position");n.uv=b.getattriblocation(m,"uv");s.rendertype=b.getuniformlocation(m,"rendertype");s.map=b.getuniformlocation(m,"map");s.occlusionmap=b.getuniformlocation(m,"occlusionmap");s.opacity= b.getuniformlocation(m,"opacity");s.color=b.getuniformlocation(m,"color");s.scale=b.getuniformlocation(m,"scale");s.rotation=b.getuniformlocation(m,"rotation");s.screenposition=b.getuniformlocation(m,"screenposition")};this.render=function(a,d,e,f){var a=a.__webglflares,v=a.length;if(v){var z=new three.vector3,t=f/e,a=0.5*e,i=0.5*f,c=16/f,x=new three.vector2(c*t,c),g=new three.vector3(1,1,0),j=new three.vector2(1,1),e=s,c=n;b.useprogram(m);b.enablevertexattribarray(n.vertex);b.enablevertexattribarray(n.uv); b.uniform1i(e.occlusionmap,0);b.uniform1i(e.map,1);b.bindbuffer(b.array_buffer,g);b.vertexattribpointer(c.vertex,2,b.float,!1,16,0);b.vertexattribpointer(c.uv,2,b.float,!1,16,8);b.bindbuffer(b.element_array_buffer,h);b.disable(b.cull_face);b.depthmask(!1);var h,b,w,f,k;for(h=0;hx;x++)t[x]=new three.vector3,v[x]=new three.vector3;t=a.shadowcascadenearz[z];a=a.shadowcascadefarz[z];v[0].set(-1,-1,t);v[1].set(1,-1,t);v[2].set(-1, 1,t);v[3].set(1,1,t);v[4].set(-1,-1,a);v[5].set(1,-1,a);v[6].set(-1,1,a);v[7].set(1,1,a);c.originalcamera=n;v=new three.gyroscope;v.position=p.shadowcascadeoffset;v.add(c);v.add(c.target);n.add(v);p.shadowcascadearray[y]=c;console.log("created virtuallight",c)}z=p;t=y;a=z.shadowcascadearray[t];a.position.copy(z.position);a.target.position.copy(z.target.position);a.lookat(a.target);a.shadowcameravisible=z.shadowcameravisible;a.shadowdarkness=z.shadowdarkness;a.shadowbias=z.shadowcascadebias[t];v=z.shadowcascadenearz[t]; z=z.shadowcascadefarz[t];a=a.pointsfrustum;a[0].z=v;a[1].z=v;a[2].z=v;a[3].z=v;a[4].z=z;a[5].z=z;a[6].z=z;a[7].z=z;i[q]=c;q++}else i[q]=p,q++;s=0;for(r=i.length;sz;z++)t=a[z],t.copy(v[z]),three.shadowmapplugin.__projector.unprojectvector(t,y),t.applymatrix4(q.matrixworldinverse),t.xk.x&&(k.x=t.x),t.yk.y&&(k.y=t.y),t.zk.z&& (k.z=t.z);q.left=i.x;q.right=k.x;q.top=k.y;q.bottom=i.y;q.updateprojectionmatrix()}q=p.shadowmap;v=p.shadowmatrix;y=p.shadowcamera;y.position.getpositionfrommatrix(p.matrixworld);l.getpositionfrommatrix(p.target.matrixworld);y.lookat(l);y.updatematrixworld();y.matrixworldinverse.getinverse(y.matrixworld);p.camerahelper&&(p.camerahelper.visible=p.shadowcameravisible);p.shadowcameravisible&&p.camerahelper.update();v.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);v.multiply(y.projectionmatrix);v.multiply(y.matrixworldinverse); h.multiplymatrices(y.projectionmatrix,y.matrixworldinverse);g.setfrommatrix(h);b.setrendertarget(q);b.clear();a=m.__webglobjects;p=0;for(q=a.length;p 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}"}};