// ThreeWebGL.js r39 - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}THREE.Color=function(b){this.setHex(b)}; THREE.Color.prototype={autoUpdate:!0,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex;this.__styleString=b.__styleString},setRGB:function(b,e,d){this.r=b;this.g=e;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(b,e,d){var h,g,k,i,p,q;if(d==0)h=g=k=0;else{i=Math.floor(b*6);p=b*6-i;b=d*(1-e);q=d*(1-e*p);e=d*(1-e*(1-p));switch(i){case 1:h=q;g=d;k=b;break;case 2:h=b;g=d;k=e;break;case 3:h=b;g=q;k=d;break;case 4:h=e;g=b;k=d;break;case 5:h=d;g=b; k=q;break;case 6:case 0:h=d;g=e;k=b}}this.r=h;this.g=g;this.b=k;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(b){this.hex=~~b&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,e){this.set(b||0,e||0)}; THREE.Vector2.prototype={set:function(b,e){this.x=b;this.y=e;return this},copy:function(b){this.set(b.x,b.y);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y);return this},add:function(b,e){this.set(b.x+e.x,b.y+e.y);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y);return this},sub:function(b,e){this.set(b.x-e.x,b.y-e.y);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(b,e,d){this.set(b||0,e||0,d||0)}; THREE.Vector3.prototype={set:function(b,e,d){this.x=b;this.y=e;this.z=d;return this},copy:function(b){this.set(b.x,b.y,b.z);return this},add:function(b,e){this.set(b.x+e.x,b.y+e.y,b.z+e.z);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z);return this},addScalar:function(b){this.set(this.x+b,this.y+b,this.z+b);return this},sub:function(b,e){this.set(b.x-e.x,b.y-e.y,b.z-e.z);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z);return this},cross:function(b, e){this.set(b.y*e.z-b.z*e.y,b.z*e.x-b.x*e.z,b.x*e.y-b.y*e.x);return this},crossSelf:function(b){var e=this.x,d=this.y,h=this.z;this.set(d*b.z-h*b.y,h*b.x-e*b.z,e*b.y-d*b.x);return this},multiply:function(b,e){this.set(b.x*e.x,b.y*e.y,b.z*e.z);return this},multiplySelf:function(b){this.set(this.x*b.x,this.y*b.y,this.z*b.z);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b,this.z*b);return this},divideSelf:function(b){this.set(this.x/b.x,this.y/b.y,this.z/b.z);return this},divideScalar:function(b){this.set(this.x/ b,this.y/b,this.z/b);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var e=this.x-b.x,d=this.y-b.y;b=this.z-b.z;return e*e+d*d+b*b},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var b= this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){this.y=Math.asin(b.n13);var e=Math.cos(this.y);if(Math.abs(e)>1.0E-5){this.x=Math.atan2(-b.n23/e,b.n33/e);this.z=Math.atan2(-b.n13/e,b.n11/e)}else{this.x=0;this.z=Math.atan2(b.n21,b.n22)}},setLength:function(b){return this.normalize().multiplyScalar(b)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)< 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(b,e,d,h){this.set(b||0,e||0,d||0,h||1)}; THREE.Vector4.prototype={set:function(b,e,d,h){this.x=b;this.y=e;this.z=d;this.w=h;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,e){this.set(b.x+e.x,b.y+e.y,b.z+e.z,b.w+e.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,e){this.set(b.x-e.x,b.y-e.y,b.z-e.z,b.w-e.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x* b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,e){this.set(this.x+(b.x-this.x)*e,this.y+(b.y-this.y)*e,this.z+(b.z-this.z)*e,this.w+(b.w-this.w)*e)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,e){this.origin=b||new THREE.Vector3;this.direction=e||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(b){var e,d,h=b.objects,g=[];b=0;for(e=h.length;b0&&V>0&&Z+V< 1}var d,h,g,k,i,p,q,u,D,E,I,F=b.geometry,M=F.vertices,N=[];d=0;for(h=F.faces.length;d0:D<0)){u=u.dot((new THREE.Vector3).sub(k, E))/D;E=E.addSelf(I.multiplyScalar(u));if(g instanceof THREE.Face3){if(e(E,k,i,p)){g={distance:this.origin.distanceTo(E),point:E,face:g,object:b};N.push(g)}}else if(g instanceof THREE.Face4&&(e(E,k,i,q)||e(E,i,p,q))){g={distance:this.origin.distanceTo(E),point:E,face:g,object:b};N.push(g)}}}return N}}; THREE.Rectangle=function(){function b(){k=h-e;i=g-d}var e,d,h,g,k,i,p=!0;this.getX=function(){return e};this.getY=function(){return d};this.getWidth=function(){return k};this.getHeight=function(){return i};this.getLeft=function(){return e};this.getTop=function(){return d};this.getRight=function(){return h};this.getBottom=function(){return g};this.set=function(q,u,D,E){p=!1;e=q;d=u;h=D;g=E;b()};this.addPoint=function(q,u){if(p){p=!1;e=q;d=u;h=q;g=u}else{e=eq?h:q;g=g>u?g:u}b()}; this.add3Points=function(q,u,D,E,I,F){if(p){p=!1;e=qD?q>I?q:I:D>I?D:I;g=u>E?u>F?u:F:E>F?E:F}else{e=qD?q>I?q>h?q:h:I>h?I:h:D>I?D>h?D:h:I>h?I:h;g=u>E?u>F?u>g?u:g:F>g?F:g:E>F?E>g?E:g:F>g?F:g}b()};this.addRectangle=function(q){if(p){p=!1;e=q.getLeft();d=q.getTop();h=q.getRight();g=q.getBottom()}else{e=eq.getRight()? h:q.getRight();g=g>q.getBottom()?g:q.getBottom()}b()};this.inflate=function(q){e-=q;d-=q;h+=q;g+=q;b()};this.minSelf=function(q){e=e>q.getLeft()?e:q.getLeft();d=d>q.getTop()?d:q.getTop();h=h=0&&Math.min(g,q.getBottom())-Math.max(d,q.getTop())>=0};this.empty=function(){p=!0;g=h=d=e=0;b()};this.isEmpty=function(){return p}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var b,e=this.m;b=e[1];e[1]=e[3];e[3]=b;b=e[2];e[2]=e[6];e[6]=b;b=e[5];e[5]=e[7];e[7]=b;return this},transposeIntoArray:function(b){var e=this.m;b[0]=e[0];b[1]=e[3];b[2]=e[6];b[3]=e[1];b[4]=e[4];b[5]=e[7];b[6]=e[2];b[7]=e[5];b[8]=e[8];return this}}; THREE.Matrix4=function(b,e,d,h,g,k,i,p,q,u,D,E,I,F,M,N){this.set(b||1,e||0,d||0,h||0,g||0,k||1,i||0,p||0,q||0,u||0,D||1,E||0,I||0,F||0,M||0,N||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={set:function(b,e,d,h,g,k,i,p,q,u,D,E,I,F,M,N){this.n11=b;this.n12=e;this.n13=d;this.n14=h;this.n21=g;this.n22=k;this.n23=i;this.n24=p;this.n31=q;this.n32=u;this.n33=D;this.n34=E;this.n41=I;this.n42=F;this.n43=M;this.n44=N;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,e,d){var h=THREE.Matrix4.__v1, g=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;k.sub(b,e).normalize();if(k.length()===0)k.z=1;h.cross(d,k).normalize();if(h.length()===0){k.x+=1.0E-4;h.cross(d,k).normalize()}g.cross(k,h).normalize();this.n11=h.x;this.n12=g.x;this.n13=k.x;this.n21=h.y;this.n22=g.y;this.n23=k.y;this.n31=h.z;this.n32=g.z;this.n33=k.z;return this},multiplyVector3:function(b){var e=b.x,d=b.y,h=b.z,g=1/(this.n41*e+this.n42*d+this.n43*h+this.n44);b.x=(this.n11*e+this.n12*d+this.n13*h+this.n14)*g;b.y=(this.n21*e+this.n22*d+this.n23* h+this.n24)*g;b.z=(this.n31*e+this.n32*d+this.n33*h+this.n34)*g;return b},multiplyVector4:function(b){var e=b.x,d=b.y,h=b.z,g=b.w;b.x=this.n11*e+this.n12*d+this.n13*h+this.n14*g;b.y=this.n21*e+this.n22*d+this.n23*h+this.n24*g;b.z=this.n31*e+this.n32*d+this.n33*h+this.n34*g;b.w=this.n41*e+this.n42*d+this.n43*h+this.n44*g;return b},rotateAxis:function(b){var e=b.x,d=b.y,h=b.z;b.x=e*this.n11+d*this.n12+h*this.n13;b.y=e*this.n21+d*this.n22+h*this.n23;b.z=e*this.n31+d*this.n32+h*this.n33;b.normalize(); return b},crossVector:function(b){var e=new THREE.Vector4;e.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;e.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;e.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;e.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return e},multiply:function(b,e){var d=b.n11,h=b.n12,g=b.n13,k=b.n14,i=b.n21,p=b.n22,q=b.n23,u=b.n24,D=b.n31,E=b.n32,I=b.n33,F=b.n34,M=b.n41,N=b.n42,V=b.n43,L=b.n44,sa=e.n11,da=e.n12,oa=e.n13,Z=e.n14,K=e.n21,Ia=e.n22, ca=e.n23,Ea=e.n24,fa=e.n31,c=e.n32,S=e.n33,pa=e.n34;this.n11=d*sa+h*K+g*fa;this.n12=d*da+h*Ia+g*c;this.n13=d*oa+h*ca+g*S;this.n14=d*Z+h*Ea+g*pa+k;this.n21=i*sa+p*K+q*fa;this.n22=i*da+p*Ia+q*c;this.n23=i*oa+p*ca+q*S;this.n24=i*Z+p*Ea+q*pa+u;this.n31=D*sa+E*K+I*fa;this.n32=D*da+E*Ia+I*c;this.n33=D*oa+E*ca+I*S;this.n34=D*Z+E*Ea+I*pa+F;this.n41=M*sa+N*K+V*fa;this.n42=M*da+N*Ia+V*c;this.n43=M*oa+N*ca+V*S;this.n44=M*Z+N*Ea+V*pa+L;return this},multiplyToArray:function(b,e,d){this.multiply(b,e);d[0]=this.n11; d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*= b;return this},determinant:function(){var b=this.n11,e=this.n12,d=this.n13,h=this.n14,g=this.n21,k=this.n22,i=this.n23,p=this.n24,q=this.n31,u=this.n32,D=this.n33,E=this.n34,I=this.n41,F=this.n42,M=this.n43,N=this.n44;return h*i*u*I-d*p*u*I-h*k*D*I+e*p*D*I+d*k*E*I-e*i*E*I-h*i*q*F+d*p*q*F+h*g*D*F-b*p*D*F-d*g*E*F+b*i*E*F+h*k*q*M-e*p*q*M-h*g*u*M+b*p*u*M+e*g*E*M-b*k*E*M-d*k*q*N+e*i*q*N+d*g*u*N-b*i*u*N-e*g*D*N+b*k*D*N},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31= this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]= this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42; b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,e){b[e]=this.n11;b[e+1]=this.n21;b[e+2]=this.n31;b[e+3]=this.n41;b[e+4]=this.n12;b[e+5]=this.n22;b[e+6]=this.n32;b[e+7]=this.n42;b[e+8]=this.n13;b[e+9]=this.n23;b[e+10]=this.n33;b[e+11]=this.n43;b[e+12]=this.n14;b[e+13]=this.n24;b[e+14]=this.n34;b[e+15]=this.n44;return b},setTranslation:function(b,e,d){this.set(1,0,0,b,0,1,0,e,0,0,1,d,0,0, 0,1);return this},setScale:function(b,e,d){this.set(b,0,0,0,0,e,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(b){var e=Math.cos(b);b=Math.sin(b);this.set(1,0,0,0,0,e,-b,0,0,b,e,0,0,0,0,1);return this},setRotationY:function(b){var e=Math.cos(b);b=Math.sin(b);this.set(e,0,b,0,0,1,0,0,-b,0,e,0,0,0,0,1);return this},setRotationZ:function(b){var e=Math.cos(b);b=Math.sin(b);this.set(e,-b,0,0,b,e,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,e){var d=Math.cos(e),h=Math.sin(e),g= 1-d,k=b.x,i=b.y,p=b.z,q=g*k,u=g*i;this.set(q*k+d,q*i-h*p,q*p+h*i,0,q*i+h*p,u*i+d,u*p-h*k,0,q*p-h*i,u*p+h*k,g*p*p+d,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var e=b.x,d=b.y,h=b.z;b=Math.cos(e);e=Math.sin(e);var g=Math.cos(d);d=Math.sin(d);var k=Math.cos(h);h=Math.sin(h);var i=b*d,p=e*d;this.n11=g*k;this.n12=-g*h;this.n13=d;this.n21=p*k+b*h;this.n22=-p*h+b*k;this.n23=-e*g;this.n31=-i*k+e*h;this.n32=i*h+e*k;this.n33= b*g;return this},setRotationFromQuaternion:function(b){var e=b.x,d=b.y,h=b.z,g=b.w,k=e+e,i=d+d,p=h+h;b=e*k;var q=e*i;e*=p;var u=d*i;d*=p;h*=p;k*=g;i*=g;g*=p;this.n11=1-(u+h);this.n12=q-g;this.n13=e+i;this.n21=q+g;this.n22=1-(b+h);this.n23=d-k;this.n31=e-i;this.n32=d+k;this.n33=1-(b+u);return this},scale:function(b){var e=b.x,d=b.y;b=b.z;this.n11*=e;this.n12*=d;this.n13*=b;this.n21*=e;this.n22*=d;this.n23*=b;this.n31*=e;this.n32*=d;this.n33*=b;this.n41*=e;this.n42*=d;this.n43*=b;return this},extractPosition:function(b){this.n14= b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,e){var d=1/e.x,h=1/e.y,g=1/e.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31=b.n31*d;this.n12=b.n12*h;this.n22=b.n22*h;this.n32=b.n32*h;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}}; THREE.Matrix4.makeInvert=function(b,e){var d=b.n11,h=b.n12,g=b.n13,k=b.n14,i=b.n21,p=b.n22,q=b.n23,u=b.n24,D=b.n31,E=b.n32,I=b.n33,F=b.n34,M=b.n41,N=b.n42,V=b.n43,L=b.n44;e===undefined&&(e=new THREE.Matrix4);e.n11=q*F*N-u*I*N+u*E*V-p*F*V-q*E*L+p*I*L;e.n12=k*I*N-g*F*N-k*E*V+h*F*V+g*E*L-h*I*L;e.n13=g*u*N-k*q*N+k*p*V-h*u*V-g*p*L+h*q*L;e.n14=k*q*E-g*u*E-k*p*I+h*u*I+g*p*F-h*q*F;e.n21=u*I*M-q*F*M-u*D*V+i*F*V+q*D*L-i*I*L;e.n22=g*F*M-k*I*M+k*D*V-d*F*V-g*D*L+d*I*L;e.n23=k*q*M-g*u*M-k*i*V+d*u*V+g*i*L-d*q*L; e.n24=g*u*D-k*q*D+k*i*I-d*u*I-g*i*F+d*q*F;e.n31=p*F*M-u*E*M+u*D*N-i*F*N-p*D*L+i*E*L;e.n32=k*E*M-h*F*M-k*D*N+d*F*N+h*D*L-d*E*L;e.n33=g*u*M-k*p*M+k*i*N-d*u*N-h*i*L+d*p*L;e.n34=k*p*D-h*u*D-k*i*E+d*u*E+h*i*F-d*p*F;e.n41=q*E*M-p*I*M-q*D*N+i*I*N+p*D*V-i*E*V;e.n42=h*I*M-g*E*M+g*D*N-d*I*N-h*D*V+d*E*V;e.n43=g*p*M-h*q*M-g*i*N+d*q*N+h*i*V-d*p*V;e.n44=h*q*D-g*p*D+g*i*E-d*q*E-h*i*I+d*p*I;e.multiplyScalar(1/b.determinant());return e}; THREE.Matrix4.makeInvert3x3=function(b){var e=b.m33,d=e.m,h=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,k=b.n32*b.n21-b.n31*b.n22,i=-b.n33*b.n12+b.n32*b.n13,p=b.n33*b.n11-b.n31*b.n13,q=-b.n32*b.n11+b.n31*b.n12,u=b.n23*b.n12-b.n22*b.n13,D=-b.n23*b.n11+b.n21*b.n13,E=b.n22*b.n11-b.n21*b.n12;b=b.n11*h+b.n21*i+b.n31*u;if(b==0)throw"matrix not invertible";b=1/b;d[0]=b*h;d[1]=b*g;d[2]=b*k;d[3]=b*i;d[4]=b*p;d[5]=b*q;d[6]=b*u;d[7]=b*D;d[8]=b*E;return e}; THREE.Matrix4.makeFrustum=function(b,e,d,h,g,k){var i;i=new THREE.Matrix4;i.n11=2*g/(e-b);i.n12=0;i.n13=(e+b)/(e-b);i.n14=0;i.n21=0;i.n22=2*g/(h-d);i.n23=(h+d)/(h-d);i.n24=0;i.n31=0;i.n32=0;i.n33=-(k+g)/(k-g);i.n34=-2*k*g/(k-g);i.n41=0;i.n42=0;i.n43=-1;i.n44=0;return i};THREE.Matrix4.makePerspective=function(b,e,d,h){var g;b=d*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*e,b*e,g,b,d,h)}; THREE.Matrix4.makeOrtho=function(b,e,d,h,g,k){var i,p,q,u;i=new THREE.Matrix4;p=e-b;q=d-h;u=k-g;i.n11=2/p;i.n12=0;i.n13=0;i.n14=-((e+b)/p);i.n21=0;i.n22=2/q;i.n23=0;i.n24=-((d+h)/q);i.n31=0;i.n32=0;i.n33=-2/u;i.n34=-((k+g)/u);i.n41=0;i.n42=0;i.n43=0;i.n44=1;return i};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible= !0;this._vector=new THREE.Vector3}; THREE.Object3D.prototype={translate:function(b,e){this.matrix.rotateAxis(e);this.position.addSelf(e.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(this.position,b,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)===-1){b.parent!== undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var e=this;e instanceof THREE.Scene===!1&&e!==undefined;)e=e.parent;e!==undefined&&e.addChildRecurse(b)}},removeChild:function(b){var e=this.children.indexOf(b);if(e!==-1){b.parent=undefined;this.children.splice(e,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!== 1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(b,e,d){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||e){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;e=!0}b=0;for(var h=this.children.length;b=1){d.w=b.w;d.x=b.x;d.y=b.y;d.z=b.z;return d}var k=Math.acos(g),i=Math.sqrt(1-g*g);if(Math.abs(i)<0.0010){d.w=0.5*(b.w+e.w);d.x=0.5*(b.x+e.x);d.y=0.5*(b.y+e.y);d.z=0.5*(b.z+e.z);return d}g=Math.sin((1-h)*k)/i;h=Math.sin(h*k)/i;d.w=b.w*g+e.w*h;d.x=b.x*g+e.x*h;d.y=b.y*g+e.y*h;d.z=b.z*g+e.z*h;return d};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; THREE.Face3=function(b,e,d,h,g,k){this.a=b;this.b=e;this.c=d;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,e,d,h,g,k,i){this.a=b;this.b=e;this.c=d;this.d=h;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=k instanceof THREE.Color?k:new THREE.Color;this.vertexColors=k instanceof Array?k:[];this.vertexTangents=[];this.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3};THREE.UV=function(b,e){this.set(b||0,e||0)}; THREE.UV.prototype={set:function(b,e){this.u=b;this.v=e;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; THREE.Geometry.prototype={computeCentroids:function(){var b,e,d;b=0;for(e=this.faces.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var e=1,d=this.vertices.length;ethis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x; if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,e=0,d=this.vertices.length;e1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+h+" on bone "+F);h=h<0?0:1}if(d==="pos"){d=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){d.x=g[0]+(k[0]-g[0])*h;d.y=g[1]+(k[1]-g[1])*h;d.z=g[2]+(k[2]-g[2])*h}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= this.getPrevKeyWith("pos",F,i.index-1).pos;this.points[1]=g;this.points[2]=k;this.points[3]=this.getNextKeyWith("pos",F,p.index+1).pos;h=h*0.33+0.33;g=this.interpolateCatmullRom(this.points,h);d.x=g[0];d.y=g[1];d.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){h=this.interpolateCatmullRom(this.points,h*1.01);this.target.set(h[0],h[1],h[2]);this.target.subSelf(d);this.target.y=0;this.target.normalize();h=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,h,0)}}}else if(d=== "rot")THREE.Quaternion.slerp(g,k,b.quaternion,h);else if(d==="scl"){d=b.scale;d.x=g[0]+(k[0]-g[0])*h;d.y=g[1]+(k[1]-g[1])*h;d.z=g[2]+(k[2]-g[2])*h}}}}if(this.JITCompile&&D[0][u]===undefined){this.hierarchy[0].update(undefined,!0);for(F=0;Fb.length-2?k:k+1;d[3]=k>b.length-3?k:k+2;k=b[d[0]];p=b[d[1]];q=b[d[2]];u=b[d[3]];d=g*g;i=g*d;h[0]=this.interpolate(k[0],p[0],q[0],u[0],g,d,i);h[1]=this.interpolate(k[1],p[1],q[1],u[1],g,d,i);h[2]=this.interpolate(k[2],p[2],q[2],u[2],g,d,i);return h}; THREE.Animation.prototype.interpolate=function(b,e,d,h,g,k,i){b=(d-b)*0.5;h=(h-e)*0.5;return(2*(e-d)+b+h)*i+(-3*(e-d)-2*b-h)*k+b*g+e};THREE.Animation.prototype.getNextKeyWith=function(b,e,d){var h=this.data.hierarchy[e].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=d0?d:0:d>=0?d:d+h.length;d>=0;d--)if(h[d][b]!==undefined)return h[d];return this.data.hierarchy[e].keys[h.length-1]}; THREE.Camera=function(b,e,d,h,g){THREE.Object3D.call(this);this.fov=b||50;this.aspect=e||1;this.near=d||0.1;this.far=h||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype; THREE.Camera.prototype.translate=function(b,e){this.matrix.rotateAxis(e);this.position.addSelf(e.multiplyScalar(b));this.target.position.addSelf(e.multiplyScalar(b))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)}; THREE.Camera.prototype.update=function(b,e,d){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);e=!0}else{this.matrixAutoUpdate&&(e|=this.updateMatrix());if(e||this.matrixWorldNeedsUpdate){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate= !1;e=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(b=0;b1){b=d.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var h=1;h=this.LODs[h].visibleAtDistance){this.LODs[h-1].object3D.visible= !1;this.LODs[h].object3D.visible=!0}else break;for(;hE){d=D;D=E;E=d}}else if(DF){d=I;I=F;F=d}}else if(I=0&&ta>=0&&aa>=0&&ma>=0)return!0;else if(Fa<0&&ta<0||aa<0&&ma<0)return!1;else{if(Fa<0)pa=Math.max(pa,Fa/(Fa-ta));else ta<0&&(ra=Math.min(ra,Fa/(Fa-ta)));if(aa<0)pa=Math.max(pa,aa/(aa-ma));else ma<0&&(ra=Math.min(ra,aa/(aa-ma)));if(raFa&&i.positionScreen.z0&&Z.z<1){Pa=da[sa]=da[sa]||new THREE.RenderableParticle;sa++;L=Pa;L.x=Z.x/Z.w;L.y=Z.y/Z.w;L.z=Z.z;L.rotation=$.rotation.z;L.scale.x=$.scale.x*Math.abs(L.x-(Z.x+S.projectionMatrix.n11)/(Z.w+S.projectionMatrix.n14));L.scale.y=$.scale.y*Math.abs(L.y-(Z.y+S.projectionMatrix.n22)/(Z.w+S.projectionMatrix.n24));L.materials=$.materials;ra.push(L)}}}}pa&&ra.sort(e);return ra}}; THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(b,e,d){d&&b.update(undefined,!1,e);d=b.sounds;var h,g=d.length;for(h=0;h 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_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#ifdef PHONG\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif", lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\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 pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n#ifdef PHONG\nvPointLight[ i ] = vec4( lVector, lDistance );\n#endif\n}\n#endif\n}", lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", 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\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif", morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif", default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var e,d,h,g={};for(e=0;et){y=z;t=A[y]}c.bindBuffer(c.ARRAY_BUFFER,o.__webglMorphTargetsBuffers[y]);c.vertexAttribPointer(s["morphTarget"+m],3,c.FLOAT,!1,0,0);w.__webglMorphTargetInfluences[m]=t;v[y]=1;t=-1;m++}}c.uniform1fv(n.program.uniforms.morphTargetInfluences, w.__webglMorphTargetInfluences)}else{c.bindBuffer(c.ARRAY_BUFFER,o.__webglVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0)}if(o.__webglCustomAttributes)for(x in o.__webglCustomAttributes)if(f[x]>=0){s=o.__webglCustomAttributes[x];c.bindBuffer(c.ARRAY_BUFFER,s.buffer);c.vertexAttribPointer(f[x],s.size,c.FLOAT,!1,0,0)}if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,o.__webglColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,o.__webglNormalBuffer); c.vertexAttribPointer(f.normal,3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,o.__webglTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(o.__webglUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,o.__webglUVBuffer);c.vertexAttribPointer(f.uv,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv)}else c.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(o.__webglUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,o.__webglUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2); if(n.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,o.__webglSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,o.__webglSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,o.__webglSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,o.__webglSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight, 4,c.FLOAT,!1,0,0)}if(w instanceof THREE.Mesh)if(n.wireframe){c.lineWidth(n.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,o.__webglLineBuffer);c.drawElements(c.LINES,o.__webglLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,o.__webglFaceBuffer);c.drawElements(c.TRIANGLES,o.__webglFaceCount,c.UNSIGNED_SHORT,0)}else if(w instanceof THREE.Line){w=w.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(n.linewidth);c.drawArrays(w,0,o.__webglLineCount)}else if(w instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,0,o.__webglParticleCount);else w instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,o.__webglVertexCount)}}function g(f,s,m){if(!f.__webglVertexBuffer)f.__webglVertexBuffer=c.createBuffer();if(!f.__webglNormalBuffer)f.__webglNormalBuffer=c.createBuffer();if(f.hasPos){c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,f.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(s.attributes.position);c.vertexAttribPointer(s.attributes.position, 3,c.FLOAT,!1,0,0)}if(f.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,f.__webglNormalBuffer);if(m==THREE.FlatShading){var n,o,w,x,v,A,t,y,z,G,B=f.count*3;for(G=0;G0&&W[0]0&&W[1]0.0010&&v.scale>0.0010){O[0]=v.x;O[1]=v.y;O[2]=v.z;G=v.size*v.scale/za;B[0]=G*t;B[1]=G;c.uniform3fv(P.screenPosition,O);c.uniform2fv(P.scale,B);c.uniform1f(P.rotation,v.rotation);c.uniform1f(P.opacity,v.opacity);oa(v.blending);K(v.texture,1);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT, 0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ta)}function V(f,s){f._modelViewMatrix.multiplyToArray(s.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function L(f){var s,m,n,o,w;if(f instanceof THREE.Mesh){m=f.geometry;for(s in m.geometryGroups){n=m.geometryGroups[s];w=!1;for(o in n.__webglCustomAttributes)if(n.__webglCustomAttributes[o].needsUpdate){w=!0;break}if(m.__dirtyVertices|| m.__dirtyMorphTargets||m.__dirtyElements||m.__dirtyUvs||m.__dirtyNormals||m.__dirtyColors||m.__dirtyTangents||w){w=c.DYNAMIC_DRAW;var x=void 0,v=void 0,A=void 0,t=void 0;A=void 0;var y=void 0,z=void 0,G=void 0,B=void 0,O=void 0,W=void 0,P=void 0,X=void 0,Ga=void 0,T=void 0,Q=void 0,U=void 0,ua=void 0;z=void 0;G=void 0;t=void 0;B=void 0;t=void 0;var r=void 0,H=void 0;z=void 0;r=void 0;H=void 0;var j=void 0,Ka=void 0;r=void 0;H=void 0;j=void 0;Ka=void 0;r=void 0;H=void 0;j=void 0;Ka=void 0;r=void 0; H=void 0;j=void 0;t=void 0;B=void 0;y=void 0;A=void 0;A=void 0;r=void 0;H=void 0;j=void 0;var Va=void 0,va=0,Aa=0,Za=0,$a=0,Ja=0,La=0,ea=0,Ma=0,xa=0,C=0,Ba=0;H=r=0;var Ca=n.__vertexArray,fb=n.__uvArray,gb=n.__uv2Array,Qa=n.__normalArray,ha=n.__tangentArray,Da=n.__colorArray,ia=n.__skinVertexAArray,ja=n.__skinVertexBArray,ka=n.__skinIndexArray,la=n.__skinWeightArray,hb=n.__morphTargetsArrays,Ra=n.__webglCustomAttributes;j=void 0;var Na=n.__faceArray,Oa=n.__lineArray,qb=n.__needsSmoothNormals;W=n.__vertexColorType; O=n.__uvType;P=n.__normalType;var Ha=f.geometry,ib=Ha.__dirtyVertices,jb=Ha.__dirtyElements,eb=Ha.__dirtyUvs,kb=Ha.__dirtyNormals,lb=Ha.__dirtyTangents,mb=Ha.__dirtyColors,nb=Ha.__dirtyMorphTargets,ab=Ha.vertices,rb=n.faces,ub=Ha.faces,sb=Ha.faceVertexUvs[0],tb=Ha.faceVertexUvs[1],bb=Ha.skinVerticesA,cb=Ha.skinVerticesB,db=Ha.skinIndices,Wa=Ha.skinWeights,Ya=f instanceof THREE.ShadowVolume?Ha.edgeFaces:undefined;morphTargets=Ha.morphTargets;if(Ra)for(Va in Ra){Ra[Va].offset=0;Ra[Va].offsetSrc=0}x= 0;for(v=rb.length;x0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,Da,w)}if(kb){c.bindBuffer(c.ARRAY_BUFFER,n.__webglNormalBuffer);c.bufferData(c.ARRAY_BUFFER,Qa,w)}if(lb&&Ha.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,n.__webglTangentBuffer);c.bufferData(c.ARRAY_BUFFER,ha,w)}if(eb&&Za>0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglUVBuffer);c.bufferData(c.ARRAY_BUFFER,fb,w)}if(eb&& $a>0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglUV2Buffer);c.bufferData(c.ARRAY_BUFFER,gb,w)}if(jb){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webglFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Na,w);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webglLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Oa,w)}if(C>0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,ia,w);c.bindBuffer(c.ARRAY_BUFFER,n.__webglSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,ja,w);c.bindBuffer(c.ARRAY_BUFFER, n.__webglSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,ka,w);c.bindBuffer(c.ARRAY_BUFFER,n.__webglSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,la,w)}}}m.__dirtyVertices=!1;m.__dirtyMorphTargets=!1;m.__dirtyElements=!1;m.__dirtyUvs=!1;m.__dirtyNormals=!1;m.__dirtyTangents=!1;m.__dirtyColors=!1}else if(f instanceof THREE.Ribbon){m=f.geometry;if(m.__dirtyVertices||m.__dirtyColors){f=m;s=c.DYNAMIC_DRAW;W=f.vertices;n=f.colors;P=W.length;w=n.length;X=f.__vertexArray;x=f.__colorArray;Ga=f.__dirtyColors; if(f.__dirtyVertices){for(v=0;v65535){y[A].counter+=1;t=y[A].hash+"_"+y[A].counter;f.geometryGroups[t]==undefined&&(f.geometryGroups[t]={faces:[],materials:v,vertices:0,numMorphTargets:z})}f.geometryGroups[t].faces.push(o);f.geometryGroups[t].vertices+=x}}function da(f,s,m){f.push({buffer:s,object:m,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function oa(f){if(f!= ga){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD);c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}ga=f}}function Z(f,s,m){if((m.width&m.width-1)==0&&(m.height& m.height-1)==0){c.texParameteri(f,c.TEXTURE_WRAP_S,fa(s.wrapS));c.texParameteri(f,c.TEXTURE_WRAP_T,fa(s.wrapT));c.texParameteri(f,c.TEXTURE_MAG_FILTER,fa(s.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,fa(s.minFilter));c.generateMipmap(f)}else{c.texParameteri(f,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_MAG_FILTER,Ea(s.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,Ea(s.minFilter))}}function K(f,s){if(f.needsUpdate){if(f.__webglInit){c.bindTexture(c.TEXTURE_2D, f.__webglTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,f.image)}else{f.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,f.__webglTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image);f.__webglInit=!0}Z(c.TEXTURE_2D,f,f.image);c.bindTexture(c.TEXTURE_2D,null);f.needsUpdate=!1}c.activeTexture(c.TEXTURE0+s);c.bindTexture(c.TEXTURE_2D,f.__webglTexture)}function Ia(f){if(f&&!f.__webglFramebuffer){if(f.depthBuffer===undefined)f.depthBuffer=!0;if(f.stencilBuffer=== undefined)f.stencilBuffer=!0;f.__webglFramebuffer=c.createFramebuffer();f.__webglRenderbuffer=c.createRenderbuffer();f.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,f.__webglTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,fa(f.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,fa(f.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,fa(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,fa(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,fa(f.format),f.width,f.height, 0,fa(f.format),fa(f.type),null);c.bindRenderbuffer(c.RENDERBUFFER,f.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,f.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,f.__webglTexture,0);if(f.depthBuffer&&!f.stencilBuffer){c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,f.width,f.height);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,f.__webglRenderbuffer)}else if(f.depthBuffer&&f.stencilBuffer){c.renderbufferStorage(c.RENDERBUFFER, c.DEPTH_STENCIL,f.width,f.height);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,f.__webglRenderbuffer)}else c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,f.width,f.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var s,m;if(f){s=f.__webglFramebuffer;m=f.width;f=f.height}else{s=null;m=ya;f=za}if(s!=Fa){c.bindFramebuffer(c.FRAMEBUFFER,s);c.viewport(wa,qa,m,f);Fa=s}}function ca(f,s){var m;if(f=="fragment")m= c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(m=c.createShader(c.VERTEX_SHADER));c.shaderSource(m,s);c.compileShader(m);if(!c.getShaderParameter(m,c.COMPILE_STATUS)){console.error(c.getShaderInfoLog(m));console.error(s);return null}return m}function Ea(f){switch(f){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function fa(f){switch(f){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE; case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT; case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var c,S=document.createElement("canvas"),pa=[],ra=null,Fa=null,ta=!0,aa=this,ma=null,na=null,ga=null,Y=null,wa= 0,qa=0,ya=0,za=0,$=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Pa=new THREE.Matrix4,Ta=new Float32Array(16),Xa=new Float32Array(16),Ua=new THREE.Vector4,Sa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};stencil=b.stencil!==undefined?b.stencil:!0;antialias=b.antialias!==undefined?b.antialias:!1;clearColor=b.clearColor!==undefined?new THREE.Color(b.clearColor): new THREE.Color(0);clearAlpha=b.clearAlpha!==undefined?b.clearAlpha:0;this.maxMorphTargets=8;this.domElement=S;this.autoClear=!0;this.sortObjects=!0;(function(f,s,m,n){try{if(!(c=S.getContext("experimental-webgl",{antialias:f,stencil:n})))throw"Error creating WebGL context.";}catch(o){console.error(o)}console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+" | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION));c.clearColor(0,0,0,1); c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(s.r,s.g,s.b,m)})(antialias,clearColor,clearAlpha,stencil);this.context=c;if(stencil){var R={};R.vertices=new Float32Array(12);R.faces=new Uint16Array(6);R.darkness=0.5;R.vertices[0]=-20;R.vertices[1]=-20;R.vertices[2]=-1;R.vertices[3]=20;R.vertices[4]=-20;R.vertices[5]=-1;R.vertices[6]= 20;R.vertices[7]=20;R.vertices[8]=-1;R.vertices[9]=-20;R.vertices[10]=20;R.vertices[11]=-1;R.faces[0]=0;R.faces[1]=1;R.faces[2]=2;R.faces[3]=0;R.faces[4]=2;R.faces[5]=3;R.vertexBuffer=c.createBuffer();R.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,R.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,R.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,R.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,R.faces,c.STATIC_DRAW);R.program=c.createProgram();c.attachShader(R.program,ca("fragment", THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(R.program,ca("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(R.program);R.vertexLocation=c.getAttribLocation(R.program,"position");R.projectionLocation=c.getUniformLocation(R.program,"projectionMatrix");R.darknessLocation=c.getUniformLocation(R.program,"darkness")}var J={};J.vertices=new Float32Array(16);J.faces=new Uint16Array(6);b=0;J.vertices[b++]=-1;J.vertices[b++]=-1;J.vertices[b++]=0;J.vertices[b++]=0;J.vertices[b++]= 1;J.vertices[b++]=-1;J.vertices[b++]=1;J.vertices[b++]=0;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=-1;J.vertices[b++]=1;J.vertices[b++]=0;J.vertices[b++]=1;b=0;J.faces[b++]=0;J.faces[b++]=1;J.faces[b++]=2;J.faces[b++]=0;J.faces[b++]=2;J.faces[b++]=3;J.vertexBuffer=c.createBuffer();J.elementBuffer=c.createBuffer();J.tempTexture=c.createTexture();J.occlusionTexture=c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,J.vertexBuffer);c.bufferData(c.ARRAY_BUFFER, J.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,J.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,J.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,J.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.bindTexture(c.TEXTURE_2D, J.occlusionTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,16,16,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);if(c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){J.hasVertexTexture=!1;J.program=c.createProgram();c.attachShader(J.program,ca("fragment",THREE.ShaderLib.lensFlare.fragmentShader)); c.attachShader(J.program,ca("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{J.hasVertexTexture=!0;J.program=c.createProgram();c.attachShader(J.program,ca("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));c.attachShader(J.program,ca("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}c.linkProgram(J.program);J.attributes={};J.uniforms={};J.attributes.vertex=c.getAttribLocation(J.program,"position");J.attributes.uv=c.getAttribLocation(J.program,"UV");J.uniforms.renderType= c.getUniformLocation(J.program,"renderType");J.uniforms.map=c.getUniformLocation(J.program,"map");J.uniforms.occlusionMap=c.getUniformLocation(J.program,"occlusionMap");J.uniforms.opacity=c.getUniformLocation(J.program,"opacity");J.uniforms.scale=c.getUniformLocation(J.program,"scale");J.uniforms.rotation=c.getUniformLocation(J.program,"rotation");J.uniforms.screenPosition=c.getUniformLocation(J.program,"screenPosition");var pb=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6); b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2; _sprite.faces[b++]=3;_sprite.vertexBuffer=c.createBuffer();_sprite.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,_sprite.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,_sprite.faces,c.STATIC_DRAW);_sprite.program=c.createProgram();c.attachShader(_sprite.program,ca("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(_sprite.program,ca("vertex",THREE.ShaderLib.sprite.vertexShader)); c.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=c.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=c.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=c.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=c.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=c.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=c.getUniformLocation(_sprite.program,"scale"); _sprite.uniforms.alignment=c.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=c.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=c.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=c.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=c.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=c.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix= c.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=c.getUniformLocation(_sprite.program,"projectionMatrix");var ob=!1;this.setSize=function(f,s){S.width=f;S.height=s;this.setViewport(0,0,S.width,S.height)};this.setViewport=function(f,s,m,n){wa=f;qa=s;ya=m;za=n;c.viewport(wa,qa,ya,za)};this.setScissor=function(f,s,m,n){c.scissor(f,s,m,n)};this.enableScissorTest=function(f){f?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(f){ta= f;c.depthMask(f)};this.setClearColorHex=function(f,s){var m=new THREE.Color(f);c.clearColor(m.r,m.g,m.b,s)};this.setClearColor=function(f,s){c.clearColor(f.r,f.g,f.b,s)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(f){R.darkness=f};this.initMaterial=function(f,s,m,n){var o,w,x;if(f instanceof THREE.MeshDepthMaterial)x="depth";else if(f instanceof THREE.ShadowVolumeDynamicMaterial)x="shadowVolumeDynamic";else if(f instanceof THREE.MeshNormalMaterial)x="normal";else if(f instanceof THREE.MeshBasicMaterial)x="basic";else if(f instanceof THREE.MeshLambertMaterial)x="lambert";else if(f instanceof THREE.MeshPhongMaterial)x="phong";else if(f instanceof THREE.LineBasicMaterial)x="basic";else f instanceof THREE.ParticleBasicMaterial&&(x="particle_basic");if(x){var v=THREE.ShaderLib[x];f.uniforms=THREE.UniformsUtils.clone(v.uniforms);f.vertexShader=v.vertexShader;f.fragmentShader=v.fragmentShader}var A,t,y;A=y=v=0;for(t=s.length;A< t;A++){w=s[A];w instanceof THREE.DirectionalLight&&y++;w instanceof THREE.PointLight&&v++}if(v+y<=4)s=y;else{s=Math.ceil(4*y/(v+y));v=4-s}w={directional:s,point:v};y=50;if(n!==undefined&&n instanceof THREE.SkinnedMesh)y=n.bones.length;var z;a:{A=f.fragmentShader;t=f.vertexShader;v=f.uniforms;s=f.attributes;m={map:!!f.map,envMap:!!f.envMap,lightMap:!!f.lightMap,vertexColors:f.vertexColors,fog:m,sizeAttenuation:f.sizeAttenuation,skinning:f.skinning,morphTargets:f.morphTargets,maxMorphTargets:this.maxMorphTargets, maxDirLights:w.directional,maxPointLights:w.point,maxBones:y};var G;w=[];if(x)w.push(x);else{w.push(A);w.push(t)}for(G in m){w.push(G);w.push(m[G])}x=w.join();G=0;for(w=pa.length;G0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+m.maxDirLights,"#define MAX_POINT_LIGHTS "+m.maxPointLights,"#define MAX_BONES "+m.maxBones,m.map?"#define USE_MAP":"",m.envMap?"#define USE_ENVMAP":"",m.lightMap?"#define USE_LIGHTMAP":"",m.vertexColors? "#define USE_COLOR":"",m.skinning?"#define USE_SKINNING":"",m.morphTargets?"#define USE_MORPHTARGETS":"",m.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); c.attachShader(G,ca("fragment",prefix_fragment+A));c.attachShader(G,ca("vertex",prefix_vertex+t));c.linkProgram(G);c.getProgramParameter(G,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(G,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");G.uniforms={};G.attributes={};var B;A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(B in v)A.push(B); B=A;v=0;for(A=B.length;v=0&&c.enableVertexAttribArray(z.color);z.normal>= 0&&c.enableVertexAttribArray(z.normal);z.tangent>=0&&c.enableVertexAttribArray(z.tangent);if(f.skinning&&z.skinVertexA>=0&&z.skinVertexB>=0&&z.skinIndex>=0&&z.skinWeight>=0){c.enableVertexAttribArray(z.skinVertexA);c.enableVertexAttribArray(z.skinVertexB);c.enableVertexAttribArray(z.skinIndex);c.enableVertexAttribArray(z.skinWeight)}for(o in f.attributes)z[o]>=0&&c.enableVertexAttribArray(z[o]);if(f.morphTargets){f.numSupportedMorphTargets=0;if(z.morphTarget0>=0){c.enableVertexAttribArray(z.morphTarget0); f.numSupportedMorphTargets++}if(z.morphTarget1>=0){c.enableVertexAttribArray(z.morphTarget1);f.numSupportedMorphTargets++}if(z.morphTarget2>=0){c.enableVertexAttribArray(z.morphTarget2);f.numSupportedMorphTargets++}if(z.morphTarget3>=0){c.enableVertexAttribArray(z.morphTarget3);f.numSupportedMorphTargets++}if(z.morphTarget4>=0){c.enableVertexAttribArray(z.morphTarget4);f.numSupportedMorphTargets++}if(z.morphTarget5>=0){c.enableVertexAttribArray(z.morphTarget5);f.numSupportedMorphTargets++}if(z.morphTarget6>= 0){c.enableVertexAttribArray(z.morphTarget6);f.numSupportedMorphTargets++}if(z.morphTarget7>=0){c.enableVertexAttribArray(z.morphTarget7);f.numSupportedMorphTargets++}n.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);f=0;for(o=this.maxMorphTargets;f0||G.faceVertexUvs.length>0)x.__uvArray=new Float32Array(A*2);if(G.faceUvs.length>1||G.faceVertexUvs.length>1)x.__uv2Array=new Float32Array(A*2)}if(v.geometry.skinWeights.length&&v.geometry.skinIndices.length){x.__skinVertexAArray=new Float32Array(A* 4);x.__skinVertexBArray=new Float32Array(A*4);x.__skinIndexArray=new Float32Array(A*4);x.__skinWeightArray=new Float32Array(A*4)}x.__faceArray=new Uint16Array(O*3+(v.geometry.edgeFaces?v.geometry.edgeFaces.length*6:0));x.__lineArray=new Uint16Array(W*2);if(x.numMorphTargets){x.__morphTargetsArrays=[];G=0;for(B=x.numMorphTargets;G=0;o--){n=m.__webglObjects[o].object;if(s==n){m.__webglObjects.splice(o,1);break}}f.__objectsRemoved.splice(0,1)}s=0;for(m=f.__webglObjects.length;s0}}; THREE.WebGLRenderTarget=function(b,e,d){this.width=b;this.height=e;d=d||{};this.wrapS=d.wrapS!==undefined?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==undefined?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==undefined?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==undefined?d.minFilter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBAFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType;this.depthBuffer=d.depthBuffer!== undefined?d.depthBuffer:!0;this.stencilBuffer=d.stencilBuffer!==undefined?d.stencilBuffer:!0};