From fd145f038e88f1b99e1e25f329b1eed3070fa321 Mon Sep 17 00:00:00 2001 From: alteredq Date: Mon, 28 Mar 2011 16:45:11 +0200 Subject: [PATCH] Reverted accidental reverting of mrdoob's changes. --- build/Three.js | 512 ++++++++--------- src/renderers/WebGLRenderer.js | 969 +++++++++++++++++---------------- 2 files changed, 754 insertions(+), 727 deletions(-) diff --git a/build/Three.js b/build/Three.js index 9f2647108a..23f0f0162d 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,88 +1,88 @@ // Three.js r37 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)}; -THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,f,g,j,k,m;if(b==0)d=f=g=0;else{j=Math.floor(a*6);k=a*6-j;a=b*(1-c);m=b*(1-c*k);c=b*(1-c*(1-k));switch(j){case 1:d=m;f=b;g=a;break;case 2:d=a;f=b;g=c;break;case 3:d=a;f=m;g=b;break;case 4:d=c;f=a;g=b;break;case 5:d=b;f=a; -g=m;break;case 6:case 0:d=b;f=c;g=a}}this.r=d;this.g=f;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&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* +THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var e,f,g,j,k,m;if(b==0)e=f=g=0;else{j=Math.floor(a*6);k=a*6-j;a=b*(1-c);m=b*(1-c*k);c=b*(1-c*(1-k));switch(j){case 1:e=m;f=b;g=a;break;case 2:e=a;f=b;g=c;break;case 3:e=a;f=m;g=b;break;case 4:e=c;f=a;g=b;break;case 5:e=b;f=a; +g=m;break;case 6:case 0:e=b;f=c;g=a}}this.r=e;this.g=f;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&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(a,c){this.set(a||0,c||0)}; THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);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(a,c,b){this.set(a||0,c||0,b||0)}; THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, -c){this.set(a.y*c.z-a.z*c.y,a.z*c.x-a.x*c.z,a.x*c.y-a.y*c.x);return this},crossSelf:function(a){var c=this.x,b=this.y,d=this.z;this.set(b*a.z-d*a.y,d*a.x-c*a.z,c*a.y-b*a.x);return this},multiply:function(a,c){this.set(a.x*c.x,a.y*c.y,a.z*c.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/ +c){this.set(a.y*c.z-a.z*c.y,a.z*c.x-a.x*c.z,a.x*c.y-a.y*c.x);return this},crossSelf:function(a){var c=this.x,b=this.y,e=this.z;this.set(b*a.z-e*a.y,e*a.x-c*a.z,c*a.y-b*a.x);return this},multiply:function(a,c){this.set(a.x*c.x,a.y*c.y,a.z*c.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/ a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,b=this.y-a.y;a=this.z-a.z;return c*c+b*b+a*a},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 a= this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var c=Math.cos(this.y);if(Math.abs(c)>1.0E-5){this.x=Math.atan2(-a.n23/c,a.n33/c);this.z=Math.atan2(-a.n13/c,a.n11/c)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},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(a,c,b,d){this.set(a||0,c||0,b||0,d||1)}; -THREE.Vector4.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* +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(a,c,b,e){this.set(a||0,c||0,b||0,e||1)}; +THREE.Vector4.prototype={set:function(a,c,b,e){this.x=a;this.y=c;this.z=b;this.w=e;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,c){this.set(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c,this.z+(a.z-this.z)*c,this.w+(a.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,f=[];a=0;for(c=d.length;a0&&I>0&&R+I<1}var b,d,f,g,j,k,m,n,o,x, -z,y=a.geometry,B=y.vertices,H=[];b=0;for(d=y.faces.length;b0&&I>0&&R+I<1}var b,e,f,g,j,k,m,n,o,x, +z,y=a.geometry,B=y.vertices,H=[];b=0;for(e=y.faces.length;bm?d:m;f=f>n?f:n}a()}; -this.add3Points=function(m,n,o,x,z,y){if(k){k=!1;c=mo?m>z?m:z:o>z?o:z;f=n>x?n>y?n:y:x>y?x:y}else{c=mo?m>z?m>d?m:d:z>d?z:d:o>z?o>d?o:d:z>d?z:d;f=n>x?n>y?n>f?n:f:y>f?y:f:x>y?x>f?x:f:y>f?y:f}a()};this.addRectangle=function(m){if(k){k=!1;c=m.getLeft();b=m.getTop();d=m.getRight();f=m.getBottom()}else{c=cm.getRight()? -d:m.getRight();f=f>m.getBottom()?f:m.getBottom()}a()};this.inflate=function(m){c-=m;b-=m;d+=m;f+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();b=b>m.getTop()?b:m.getTop();d=d=0&&Math.min(f,m.getBottom())-Math.max(b,m.getTop())>=0};this.empty=function(){k=!0;f=d=b=c=0;a()};this.isEmpty=function(){return k}}; +THREE.Rectangle=function(){function a(){g=e-c;j=f-b}var c,b,e,f,g,j,k=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return g};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(m,n,o,x){k=!1;c=m;b=n;e=o;f=x;a()};this.addPoint=function(m,n){if(k){k=!1;c=m;b=n;e=m;f=n}else{c=cm?e:m;f=f>n?f:n}a()}; +this.add3Points=function(m,n,o,x,z,y){if(k){k=!1;c=mo?m>z?m:z:o>z?o:z;f=n>x?n>y?n:y:x>y?x:y}else{c=mo?m>z?m>e?m:e:z>e?z:e:o>z?o>e?o:e:z>e?z:e;f=n>x?n>y?n>f?n:f:y>f?y:f:x>y?x>f?x:f:y>f?y:f}a()};this.addRectangle=function(m){if(k){k=!1;c=m.getLeft();b=m.getTop();e=m.getRight();f=m.getBottom()}else{c=cm.getRight()? +e:m.getRight();f=f>m.getBottom()?f:m.getBottom()}a()};this.inflate=function(m){c-=m;b-=m;e+=m;f+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();b=b>m.getTop()?b:m.getTop();e=e=0&&Math.min(f,m.getBottom())-Math.max(b,m.getTop())>=0};this.empty=function(){k=!0;f=e=b=c=0;a()};this.isEmpty=function(){return k}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; -THREE.Matrix4=function(a,c,b,d,f,g,j,k,m,n,o,x,z,y,B,H){this.set(a||1,c||0,b||0,d||0,f||0,g||1,j||0,k||0,m||0,n||0,o||1,x||0,z||0,y||0,B||0,H||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,c,b,d,f,g,j,k,m,n,o,x,z,y,B,H){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=f;this.n22=g;this.n23=j;this.n24=k;this.n31=m;this.n32=n;this.n33=o;this.n34=x;this.n41=z;this.n42=y;this.n43=B;this.n44=H;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(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,b){var d=THREE.Matrix4.__v1, -f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();if(g.length()===0)g.z=1;d.cross(b,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(b,g).normalize()}f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,f=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*f;a.y=(this.n21*c+this.n22*b+this.n23* -d+this.n24)*f;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,f=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*f;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*f;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*f;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize(); -return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,f=a.n13,g=a.n14,j=a.n21,k=a.n22,m=a.n23,n=a.n24,o=a.n31,x=a.n32,z=a.n33,y=a.n34,B=a.n41,H=a.n42,I=a.n43,F=a.n44,M=c.n11,D=c.n12,Q=c.n13,R=c.n14,P=c.n21,ka=c.n22, -$=c.n23,e=c.n24,X=c.n31,da=c.n32,Y=c.n33,ua=c.n34;this.n11=b*M+d*P+f*X;this.n12=b*D+d*ka+f*da;this.n13=b*Q+d*$+f*Y;this.n14=b*R+d*e+f*ua+g;this.n21=j*M+k*P+m*X;this.n22=j*D+k*ka+m*da;this.n23=j*Q+k*$+m*Y;this.n24=j*R+k*e+m*ua+n;this.n31=o*M+x*P+z*X;this.n32=o*D+x*ka+z*da;this.n33=o*Q+x*$+z*Y;this.n34=o*R+x*e+z*ua+y;this.n41=B*M+H*P+I*X;this.n42=B*D+H*ka+I*da;this.n43=B*Q+H*$+I*Y;this.n44=B*R+H*e+I*ua+F;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);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 this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this}, -determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14,f=this.n21,g=this.n22,j=this.n23,k=this.n24,m=this.n31,n=this.n32,o=this.n33,x=this.n34,z=this.n41,y=this.n42,B=this.n43,H=this.n44;return d*j*n*z-b*k*n*z-d*g*o*z+c*k*o*z+b*g*x*z-c*j*x*z-d*j*m*y+b*k*m*y+d*f*o*y-a*k*o*y-b*f*x*y+a*j*x*y+d*g*m*B-c*k*m*B-d*f*n*B+a*k*n*B+c*f*x*B-a*g*x*B-b*g*m*H+c*j*m*H+b*f*n*H-a*j*n*H-c*f*o*H+a*g*o*H},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13= +THREE.Matrix4=function(a,c,b,e,f,g,j,k,m,n,o,x,z,y,B,H){this.set(a||1,c||0,b||0,e||0,f||0,g||1,j||0,k||0,m||0,n||0,o||1,x||0,z||0,y||0,B||0,H||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,c,b,e,f,g,j,k,m,n,o,x,z,y,B,H){this.n11=a;this.n12=c;this.n13=b;this.n14=e;this.n21=f;this.n22=g;this.n23=j;this.n24=k;this.n31=m;this.n32=n;this.n33=o;this.n34=x;this.n41=z;this.n42=y;this.n43=B;this.n44=H;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(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,b){var e=THREE.Matrix4.__v1, +f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();if(g.length()===0)g.z=1;e.cross(b,g).normalize();if(e.length()===0){g.x+=1.0E-4;e.cross(b,g).normalize()}f.cross(g,e).normalize();this.n11=e.x;this.n12=f.x;this.n13=g.x;this.n21=e.y;this.n22=f.y;this.n23=g.y;this.n31=e.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,e=a.z,f=1/(this.n41*c+this.n42*b+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*e+this.n14)*f;a.y=(this.n21*c+this.n22*b+this.n23* +e+this.n24)*f;a.z=(this.n31*c+this.n32*b+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,b=a.y,e=a.z,f=a.w;a.x=this.n11*c+this.n12*b+this.n13*e+this.n14*f;a.y=this.n21*c+this.n22*b+this.n23*e+this.n24*f;a.z=this.n31*c+this.n32*b+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*b+this.n43*e+this.n44*f;return a},rotateAxis:function(a){var c=a.x,b=a.y,e=a.z;a.x=c*this.n11+b*this.n12+e*this.n13;a.y=c*this.n21+b*this.n22+e*this.n23;a.z=c*this.n31+b*this.n32+e*this.n33;a.normalize(); +return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,e=a.n12,f=a.n13,g=a.n14,j=a.n21,k=a.n22,m=a.n23,n=a.n24,o=a.n31,x=a.n32,z=a.n33,y=a.n34,B=a.n41,H=a.n42,I=a.n43,F=a.n44,M=c.n11,D=c.n12,Q=c.n13,R=c.n14,P=c.n21,ka=c.n22, +d=c.n23,fa=c.n24,X=c.n31,ca=c.n32,Y=c.n33,ua=c.n34;this.n11=b*M+e*P+f*X;this.n12=b*D+e*ka+f*ca;this.n13=b*Q+e*d+f*Y;this.n14=b*R+e*fa+f*ua+g;this.n21=j*M+k*P+m*X;this.n22=j*D+k*ka+m*ca;this.n23=j*Q+k*d+m*Y;this.n24=j*R+k*fa+m*ua+n;this.n31=o*M+x*P+z*X;this.n32=o*D+x*ka+z*ca;this.n33=o*Q+x*d+z*Y;this.n34=o*R+x*fa+z*ua+y;this.n41=B*M+H*P+I*X;this.n42=B*D+H*ka+I*ca;this.n43=B*Q+H*d+I*Y;this.n44=B*R+H*fa+I*ua+F;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);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 this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this}, +determinant:function(){var a=this.n11,c=this.n12,b=this.n13,e=this.n14,f=this.n21,g=this.n22,j=this.n23,k=this.n24,m=this.n31,n=this.n32,o=this.n33,x=this.n34,z=this.n41,y=this.n42,B=this.n43,H=this.n44;return e*j*n*z-b*k*n*z-e*g*o*z+c*k*o*z+b*g*x*z-c*j*x*z-e*j*m*y+b*k*m*y+e*f*o*y-a*k*o*y-b*f*x*y+a*j*x*y+e*g*m*B-c*k*m*B-e*f*n*B+a*k*n*B+c*f*x*B-a*g*x*B-b*g*m*H+c*j*m*H+b*f*n*H-a*j*n*H-c*f*o*H+a*g*o*H},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13= a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},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(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13; a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this}, -setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),f=1-b,g=a.x,j=a.y,k= -a.z,m=f*g,n=f*j;this.set(m*g+b,m*j-d*k,m*k+d*j,0,m*j+d*k,n*j+b,n*k-d*g,0,m*k-d*j,n*k+d*g,f*k*k+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var j=a*b,k=c*b;this.n11=f*g;this.n12=-f*d;this.n13=b;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-c*f;this.n31=-j*g+c*d;this.n32=j*d+c*g;this.n33=a*f;return this}, -setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,f=a.w,g=c+c,j=b+b,k=d+d;a=c*g;var m=c*j;c*=k;var n=b*j;b*=k;d*=k;g*=f;j*=f;f*=k;this.n11=1-(n+d);this.n12=m-f;this.n13=c+j;this.n21=m+f;this.n22=1-(a+d);this.n23=b-g;this.n31=c-j;this.n32=b+g;this.n33=1-(a+n);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14= -a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var b=1/c.x,d=1/c.y,f=1/c.z;this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*f;this.n23=a.n23*f;this.n33=a.n33*f}}; -THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,f=a.n13,g=a.n14,j=a.n21,k=a.n22,m=a.n23,n=a.n24,o=a.n31,x=a.n32,z=a.n33,y=a.n34,B=a.n41,H=a.n42,I=a.n43,F=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=m*y*H-n*z*H+n*x*I-k*y*I-m*x*F+k*z*F;c.n12=g*z*H-f*y*H-g*x*I+d*y*I+f*x*F-d*z*F;c.n13=f*n*H-g*m*H+g*k*I-d*n*I-f*k*F+d*m*F;c.n14=g*m*x-f*n*x-g*k*z+d*n*z+f*k*y-d*m*y;c.n21=n*z*B-m*y*B-n*o*I+j*y*I+m*o*F-j*z*F;c.n22=f*y*B-g*z*B+g*o*I-b*y*I-f*o*F+b*z*F;c.n23=g*m*B-f*n*B-g*j*I+b*n*I+f*j*F-b*m*F; -c.n24=f*n*o-g*m*o+g*j*z-b*n*z-f*j*y+b*m*y;c.n31=k*y*B-n*x*B+n*o*H-j*y*H-k*o*F+j*x*F;c.n32=g*x*B-d*y*B-g*o*H+b*y*H+d*o*F-b*x*F;c.n33=f*n*B-g*k*B+g*j*H-b*n*H-d*j*F+b*k*F;c.n34=g*k*o-d*n*o-g*j*x+b*n*x+d*j*y-b*k*y;c.n41=m*x*B-k*z*B-m*o*H+j*z*H+k*o*I-j*x*I;c.n42=d*z*B-f*x*B+f*o*H-b*z*H-d*o*I+b*x*I;c.n43=f*k*B-d*m*B-f*j*H+b*m*H+d*j*I-b*k*I;c.n44=d*m*o-f*k*o+f*j*x-b*m*x-d*j*z+b*k*z;c.multiplyScalar(1/a.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,j=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,o=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*j+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*f;b[2]=a*g;b[3]=a*j;b[4]=a*k;b[5]=a*m;b[6]=a*n;b[7]=a*o;b[8]=a*x;return c}; -THREE.Matrix4.makeFrustum=function(a,c,b,d,f,g){var j;j=new THREE.Matrix4;j.n11=2*f/(c-a);j.n12=0;j.n13=(c+a)/(c-a);j.n14=0;j.n21=0;j.n22=2*f/(d-b);j.n23=(d+b)/(d-b);j.n24=0;j.n31=0;j.n32=0;j.n33=-(g+f)/(g-f);j.n34=-2*g*f/(g-f);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,c,b,d){var f;a=b*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,b,d)}; -THREE.Matrix4.makeOrtho=function(a,c,b,d,f,g){var j,k,m,n;j=new THREE.Matrix4;k=c-a;m=b-d;n=g-f;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((c+a)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((b+d)/m);j.n31=0;j.n32=0;j.n33=-2/n;j.n34=-((g+f)/n);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),e=Math.sin(c),f=1-b,g=a.x,j=a.y,k= +a.z,m=f*g,n=f*j;this.set(m*g+b,m*j-e*k,m*k+e*j,0,m*j+e*k,n*j+b,n*k-e*g,0,m*k-e*j,n*k+e*g,f*k*k+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,e=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(b);b=Math.sin(b);var g=Math.cos(e);e=Math.sin(e);var j=a*b,k=c*b;this.n11=f*g;this.n12=-f*e;this.n13=b;this.n21=k*g+a*e;this.n22=-k*e+a*g;this.n23=-c*f;this.n31=-j*g+c*e;this.n32=j*e+c*g;this.n33=a*f;return this}, +setRotationFromQuaternion:function(a){var c=a.x,b=a.y,e=a.z,f=a.w,g=c+c,j=b+b,k=e+e;a=c*g;var m=c*j;c*=k;var n=b*j;b*=k;e*=k;g*=f;j*=f;f*=k;this.n11=1-(n+e);this.n12=m-f;this.n13=c+j;this.n21=m+f;this.n22=1-(a+e);this.n23=b-g;this.n31=c-j;this.n32=b+g;this.n33=1-(a+n);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14= +a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var b=1/c.x,e=1/c.y,f=1/c.z;this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*e;this.n22=a.n22*e;this.n32=a.n32*e;this.n13=a.n13*f;this.n23=a.n23*f;this.n33=a.n33*f}}; +THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,e=a.n12,f=a.n13,g=a.n14,j=a.n21,k=a.n22,m=a.n23,n=a.n24,o=a.n31,x=a.n32,z=a.n33,y=a.n34,B=a.n41,H=a.n42,I=a.n43,F=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=m*y*H-n*z*H+n*x*I-k*y*I-m*x*F+k*z*F;c.n12=g*z*H-f*y*H-g*x*I+e*y*I+f*x*F-e*z*F;c.n13=f*n*H-g*m*H+g*k*I-e*n*I-f*k*F+e*m*F;c.n14=g*m*x-f*n*x-g*k*z+e*n*z+f*k*y-e*m*y;c.n21=n*z*B-m*y*B-n*o*I+j*y*I+m*o*F-j*z*F;c.n22=f*y*B-g*z*B+g*o*I-b*y*I-f*o*F+b*z*F;c.n23=g*m*B-f*n*B-g*j*I+b*n*I+f*j*F-b*m*F; +c.n24=f*n*o-g*m*o+g*j*z-b*n*z-f*j*y+b*m*y;c.n31=k*y*B-n*x*B+n*o*H-j*y*H-k*o*F+j*x*F;c.n32=g*x*B-e*y*B-g*o*H+b*y*H+e*o*F-b*x*F;c.n33=f*n*B-g*k*B+g*j*H-b*n*H-e*j*F+b*k*F;c.n34=g*k*o-e*n*o-g*j*x+b*n*x+e*j*y-b*k*y;c.n41=m*x*B-k*z*B-m*o*H+j*z*H+k*o*I-j*x*I;c.n42=e*z*B-f*x*B+f*o*H-b*z*H-e*o*I+b*x*I;c.n43=f*k*B-e*m*B-f*j*H+b*m*H+e*j*I-b*k*I;c.n44=e*m*o-f*k*o+f*j*x-b*m*x-e*j*z+b*k*z;c.multiplyScalar(1/a.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,e=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,j=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,o=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*j+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*e;b[1]=a*f;b[2]=a*g;b[3]=a*j;b[4]=a*k;b[5]=a*m;b[6]=a*n;b[7]=a*o;b[8]=a*x;return c}; +THREE.Matrix4.makeFrustum=function(a,c,b,e,f,g){var j;j=new THREE.Matrix4;j.n11=2*f/(c-a);j.n12=0;j.n13=(c+a)/(c-a);j.n14=0;j.n21=0;j.n22=2*f/(e-b);j.n23=(e+b)/(e-b);j.n24=0;j.n31=0;j.n32=0;j.n33=-(g+f)/(g-f);j.n34=-2*g*f/(g-f);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,c,b,e){var f;a=b*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,b,e)}; +THREE.Matrix4.makeOrtho=function(a,c,b,e,f,g){var j,k,m,n;j=new THREE.Matrix4;k=c-a;m=b-e;n=g-f;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((c+a)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((b+e)/m);j.n31=0;j.n32=0;j.n33=-2/n;j.n34=-((g+f)/n);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};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(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!== undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var c=this;c instanceof THREE.Scene===!1&&c!==undefined;)c=c.parent;c!==undefined&&c.addChildRecurse(a)}},removeChild:function(a){var c=this.children.indexOf(a);if(c!==-1){a.parent=undefined;this.children.splice(c,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(a,c,b){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;c=!0}a=0;for(var d=this.children.length;a=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(f),j=Math.sqrt(1-f*f);if(Math.abs(j)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}f=Math.sin((1-d)*g)/j;d=Math.sin(d*g)/j;b.w=a.w*f+c.w*d;b.x=a.x*f+c.x*d;b.y=a.y*f+c.y*d;b.z=a.z*f+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; -THREE.Face3=function(a,c,b,d,f,g){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; -THREE.Face4=function(a,c,b,d,f,g,j){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)}; +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(a,c,b){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;c=!0}a=0;for(var e=this.children.length;a=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(f),j=Math.sqrt(1-f*f);if(Math.abs(j)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}f=Math.sin((1-e)*g)/j;e=Math.sin(e*g)/j;b.w=a.w*f+c.w*e;b.x=a.x*f+c.x*e;b.y=a.y*f+c.y*e;b.z=a.z*f+c.z*e;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,c,b,e,f,g){this.a=a;this.b=c;this.c=b;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; +THREE.Face4=function(a,c,b,e,f,g,j){this.a=a;this.b=c;this.c=b;this.d=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)}; THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; THREE.Geometry.prototype={computeCentroids:function(){var a,c,b;a=0;for(c=this.faces.length;a0){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 c=1,b=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,b=this.vertices.length;cthis.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;n=this.points[b[0]];o=this.points[b[1]]; -x=this.points[b[2]];z=this.points[b[3]];k=j*j;m=j*k;d.x=c(n.x,o.x,x.x,z.x,j,k,m);d.y=c(n.y,o.y,x.y,z.y,j,k,m);d.z=c(n.z,o.z,x.z,z.z,j,k,m);return d};this.getControlPointsArray=function(){var y,B,H=this.points.length,I=[];for(y=0;ythis.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;n=this.points[b[0]];o=this.points[b[1]]; +x=this.points[b[2]];z=this.points[b[3]];k=j*j;m=j*k;e.x=c(n.x,o.x,x.x,z.x,j,k,m);e.y=c(n.y,o.y,x.y,z.y,j,k,m);e.z=c(n.z,o.z,x.z,z.z,j,k,m);return e};this.getControlPointsArray=function(){var y,B,H=this.points.length,I=[];for(y=0;y1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+y);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= -this.getPrevKeyWith("pos",y,j.index-1).pos;this.points[1]=f;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",y,k.index+1).pos;d=d*0.33+0.33;f=this.interpolateCatmullRom(this.points,d);b.x=f[0];b.y=f[1];b.z=f[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d=this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(b);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(b=== -"rot")THREE.Quaternion.slerp(f,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}}}}if(this.JITCompile&&o[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(y=0;ya.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];k=a[b[1]];m=a[b[2]];n=a[b[3]];b=f*f;j=f*b;d[0]=this.interpolate(g[0],k[0],m[0],n[0],f,b,j);d[1]=this.interpolate(g[1],k[1],m[1],n[1],f,b,j);d[2]=this.interpolate(g[2],k[2],m[2],n[2],f,b,j);return d}; -THREE.Animation.prototype.interpolate=function(a,c,b,d,f,g,j){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*j+(-3*(c-b)-2*a-d)*g+a*f+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b0?b:0:b>=0?b:b+d.length;b>=0;b--)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[d.length-1]}; -THREE.Camera=function(a,c,b,d,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||2E3;this.target=f||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; +x)}m.prevKey[b]=j;m.nextKey[b]=k}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(x-j.time)/(k.time-j.time);f=j[b];g=k[b];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+y);e=e<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=f[0]+(g[0]-f[0])*e;b.y=f[1]+(g[1]-f[1])*e;b.z=f[2]+(g[2]-f[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= +this.getPrevKeyWith("pos",y,j.index-1).pos;this.points[1]=f;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",y,k.index+1).pos;e=e*0.33+0.33;f=this.interpolateCatmullRom(this.points,e);b.x=f[0];b.y=f[1];b.z=f[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(b);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(b=== +"rot")THREE.Quaternion.slerp(f,g,a.quaternion,e);else if(b==="scl"){b=a.scale;b.x=f[0]+(g[0]-f[0])*e;b.y=f[1]+(g[1]-f[1])*e;b.z=f[2]+(g[2]-f[2])*e}}}}if(this.JITCompile&&o[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(y=0;ya.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];k=a[b[1]];m=a[b[2]];n=a[b[3]];b=f*f;j=f*b;e[0]=this.interpolate(g[0],k[0],m[0],n[0],f,b,j);e[1]=this.interpolate(g[1],k[1],m[1],n[1],f,b,j);e[2]=this.interpolate(g[2],k[2],m[2],n[2],f,b,j);return e}; +THREE.Animation.prototype.interpolate=function(a,c,b,e,f,g,j){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*j+(-3*(c-b)-2*a-e)*g+a*f+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b0?b:0:b>=0?b:b+e.length;b>=0;b--)if(e[b][a]!==undefined)return e[b];return this.data.hierarchy[c].keys[e.length-1]}; +THREE.Camera=function(a,c,b,e,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=e||2E3;this.target=f||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(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};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(a,c,b){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);c=!0}else{this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate= !1;c=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a1){a=b.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var d=1;d=this.LODs[d].visibleAtDistance){this.LODs[d-1].object3D.visible= -!1;this.LODs[d].object3D.visible=!0}else break;for(;d1){a=b.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var e=1;e=this.LODs[e].visibleAtDistance){this.LODs[e-1].object3D.visible= +!1;this.LODs[e].object3D.visible=!0}else break;for(;e=0&&ma>=0&&W>=0&&ia>=0)return!0;else if(za<0&&ma<0||W<0&&ia<0)return!1;else{if(za<0)ua=Math.max(ua,za/(za-ma));else ma<0&&(va=Math.min(va,za/(za-ma)));if(W<0)ua=Math.max(ua,W/(W-ia));else ia<0&&(va=Math.min(va,W/(W-ia)));if(va=0&&ma>=0&&W>=0&&ia>=0)return!0;else if(za<0&&ma<0||W<0&&ia<0)return!1;else{if(za<0)ua=Math.max(ua,za/(za-ma));else ma<0&&(va=Math.min(va,za/(za-ma)));if(W<0)ua=Math.max(ua,W/(W-ia));else ia<0&&(va=Math.min(va,W/(W-ia)));if(vaza&&j.positionScreen.z0&&R.z<1){Da=D[M]=D[M]||new THREE.RenderableParticle;M++;F=Da;F.x=R.x/R.w;F.y=R.y/R.w;F.z=R.z;F.rotation=xa.rotation.z;F.scale.x=xa.scale.x*Math.abs(F.x-(R.x+Y.projectionMatrix.n11)/(R.w+Y.projectionMatrix.n14));F.scale.y=xa.scale.y*Math.abs(F.y-(R.y+Y.projectionMatrix.n22)/(R.w+Y.projectionMatrix.n24));F.materials=xa.materials;va.push(F)}}}}ua&&va.sort(c);return va}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,f,g;this.domElement=document.createElement("div");this.setSize=function(j,k){b=j;d=k;f=b/2;g=d/2};this.render=function(j,k){var m,n,o,x,z,y,B,H;a=c.projectScene(j,k);m=0;for(n=a.length;m0){ea.r+=ga.r*Aa;ea.g+=ga.g*Aa;ea.b+=ga.b*Aa}}else if(Aa instanceof THREE.PointLight){T.sub(Aa.position,aa);T.normalize();Aa=oa.dot(T)*ca;if(Aa> -0){ea.r+=ga.r*Aa;ea.g+=ga.g*Aa;ea.b+=ga.b*Aa}}}}function fb(L,aa,oa){a(oa.opacity);c(oa.blending);var ea,ta,Aa,ga,ca,La;if(oa instanceof THREE.ParticleBasicMaterial){if(oa.map){ga=oa.map.image;ca=ga.width>>1;La=ga.height>>1;oa=aa.scale.x*k;Aa=aa.scale.y*m;ea=oa*ca;ta=Aa*La;G.set(L.x-ea,L.y-ta,L.x+ea,L.y+ta);if(p.instersects(G)){n.save();n.translate(L.x,L.y);n.rotate(-aa.rotation);n.scale(oa,-Aa);n.translate(-ca,-La);n.drawImage(ga,0,0);n.restore()}}}else if(oa instanceof THREE.ParticleCanvasMaterial){if(J){E.r= -A.r+V.r+K.r;E.g=A.g+V.g+K.g;E.b=A.b+V.b+K.b;Z.r=oa.color.r*E.r;Z.g=oa.color.g*E.g;Z.b=oa.color.b*E.b;Z.updateStyleString()}else Z.__styleString=oa.color.__styleString;ea=aa.scale.x*k;ta=aa.scale.y*m;G.set(L.x-ea,L.y-ta,L.x+ea,L.y+ta);if(p.instersects(G)){n.save();n.translate(L.x,L.y);n.rotate(-aa.rotation);n.scale(ea,ta);oa.program(n,Z);n.restore()}}}function Ua(L,aa,oa,ea){a(ea.opacity);c(ea.blending);n.beginPath();n.moveTo(L.positionScreen.x,L.positionScreen.y);n.lineTo(aa.positionScreen.x,aa.positionScreen.y); -n.closePath();if(ea instanceof THREE.LineBasicMaterial){Z.__styleString=ea.color.__styleString;L=ea.linewidth;if(I!=L)n.lineWidth=I=L;L=Z.__styleString;if(B!=L)n.strokeStyle=B=L;n.stroke();G.inflate(ea.linewidth*2)}}function Ja(L,aa,oa,ea,ta,Aa,ga,ca,La){a(ca.opacity);c(ca.blending);ka=L.positionScreen.x;$=L.positionScreen.y;e=aa.positionScreen.x;X=aa.positionScreen.y;da=oa.positionScreen.x;Y=oa.positionScreen.y;cb(ka,$,e,X,da,Y);if(ca instanceof THREE.MeshBasicMaterial)if(ca.map){if(ca.map.mapping instanceof -THREE.UVMapping){Da=ga.uvs[0];Ea(ka,$,e,X,da,Y,ca.map.image,Da[ea].u,Da[ea].v,Da[ta].u,Da[ta].v,Da[Aa].u,Da[Aa].v)}}else if(ca.envMap){if(ca.envMap.mapping instanceof THREE.SphericalReflectionMapping){L=la.matrixWorldInverse;T.copy(ga.vertexNormalsWorld[0]);$a=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;ab=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ga.vertexNormalsWorld[1]);Ia=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;h=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ga.vertexNormalsWorld[2]);t=(T.x* -L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;w=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;Ea(ka,$,e,X,da,Y,ca.envMap.image,$a,ab,Ia,h,t,w)}}else ca.wireframe?Qa(ca.color.__styleString,ca.wireframeLinewidth):Va(ca.color.__styleString);else if(ca instanceof THREE.MeshLambertMaterial){if(ca.map&&!ca.wireframe){if(ca.map.mapping instanceof THREE.UVMapping){Da=ga.uvs[0];Ea(ka,$,e,X,da,Y,ca.map.image,Da[ea].u,Da[ea].v,Da[ta].u,Da[ta].v,Da[Aa].u,Da[Aa].v)}c(THREE.SubtractiveBlending)}if(J)if(!ca.wireframe&&ca.shading== -THREE.SmoothShading&&ga.vertexNormalsWorld.length==3){S.r=N.r=ha.r=A.r;S.g=N.g=ha.g=A.g;S.b=N.b=ha.b=A.b;Ha(La,ga.v1.positionWorld,ga.vertexNormalsWorld[0],S);Ha(La,ga.v2.positionWorld,ga.vertexNormalsWorld[1],N);Ha(La,ga.v3.positionWorld,ga.vertexNormalsWorld[2],ha);ra.r=(N.r+ha.r)*0.5;ra.g=(N.g+ha.g)*0.5;ra.b=(N.b+ha.b)*0.5;xa=Wa(S,N,ha,ra);Ea(ka,$,e,X,da,Y,xa,0,0,1,0,0,1)}else{E.r=A.r;E.g=A.g;E.b=A.b;Ha(La,ga.centroidWorld,ga.normalWorld,E);Z.r=ca.color.r*E.r;Z.g=ca.color.g*E.g;Z.b=ca.color.b* -E.b;Z.updateStyleString();ca.wireframe?Qa(Z.__styleString,ca.wireframeLinewidth):Va(Z.__styleString)}else ca.wireframe?Qa(ca.color.__styleString,ca.wireframeLinewidth):Va(ca.color.__styleString)}else if(ca instanceof THREE.MeshDepthMaterial){na=la.near;qa=la.far;S.r=S.g=S.b=1-Na(L.positionScreen.z,na,qa);N.r=N.g=N.b=1-Na(aa.positionScreen.z,na,qa);ha.r=ha.g=ha.b=1-Na(oa.positionScreen.z,na,qa);ra.r=(N.r+ha.r)*0.5;ra.g=(N.g+ha.g)*0.5;ra.b=(N.b+ha.b)*0.5;xa=Wa(S,N,ha,ra);Ea(ka,$,e,X,da,Y,xa,0,0,1,0, -0,1)}else if(ca instanceof THREE.MeshNormalMaterial){Z.r=O(ga.normalWorld.x);Z.g=O(ga.normalWorld.y);Z.b=O(ga.normalWorld.z);Z.updateStyleString();ca.wireframe?Qa(Z.__styleString,ca.wireframeLinewidth):Va(Z.__styleString)}}function Sa(L,aa,oa,ea,ta,Aa,ga,ca,La){a(ca.opacity);c(ca.blending);if(ca.map||ca.envMap){Ja(L,aa,ea,0,1,3,ga,ca,La);Ja(ta,oa,Aa,1,2,3,ga,ca,La)}else{ka=L.positionScreen.x;$=L.positionScreen.y;e=aa.positionScreen.x;X=aa.positionScreen.y;da=oa.positionScreen.x;Y=oa.positionScreen.y; -ua=ea.positionScreen.x;va=ea.positionScreen.y;za=ta.positionScreen.x;ma=ta.positionScreen.y;W=Aa.positionScreen.x;ia=Aa.positionScreen.y;if(ca instanceof THREE.MeshBasicMaterial){eb(ka,$,e,X,da,Y,ua,va);ca.wireframe?Qa(ca.color.__styleString,ca.wireframeLinewidth):Va(ca.color.__styleString)}else if(ca instanceof THREE.MeshLambertMaterial)if(J)if(!ca.wireframe&&ca.shading==THREE.SmoothShading&&ga.vertexNormalsWorld.length==4){S.r=N.r=ha.r=ra.r=A.r;S.g=N.g=ha.g=ra.g=A.g;S.b=N.b=ha.b=ra.b=A.b;Ha(La, -ga.v1.positionWorld,ga.vertexNormalsWorld[0],S);Ha(La,ga.v2.positionWorld,ga.vertexNormalsWorld[1],N);Ha(La,ga.v4.positionWorld,ga.vertexNormalsWorld[3],ha);Ha(La,ga.v3.positionWorld,ga.vertexNormalsWorld[2],ra);xa=Wa(S,N,ha,ra);cb(ka,$,e,X,ua,va);Ea(ka,$,e,X,ua,va,xa,0,0,1,0,0,1);cb(za,ma,da,Y,W,ia);Ea(za,ma,da,Y,W,ia,xa,1,0,1,1,0,1)}else{E.r=A.r;E.g=A.g;E.b=A.b;Ha(La,ga.centroidWorld,ga.normalWorld,E);Z.r=ca.color.r*E.r;Z.g=ca.color.g*E.g;Z.b=ca.color.b*E.b;Z.updateStyleString();eb(ka,$,e,X,da, -Y,ua,va);ca.wireframe?Qa(Z.__styleString,ca.wireframeLinewidth):Va(Z.__styleString)}else{eb(ka,$,e,X,da,Y,ua,va);ca.wireframe?Qa(ca.color.__styleString,ca.wireframeLinewidth):Va(ca.color.__styleString)}else if(ca instanceof THREE.MeshNormalMaterial){Z.r=O(ga.normalWorld.x);Z.g=O(ga.normalWorld.y);Z.b=O(ga.normalWorld.z);Z.updateStyleString();eb(ka,$,e,X,da,Y,ua,va);ca.wireframe?Qa(Z.__styleString,ca.wireframeLinewidth):Va(Z.__styleString)}else if(ca instanceof THREE.MeshDepthMaterial){na=la.near; -qa=la.far;S.r=S.g=S.b=1-Na(L.positionScreen.z,na,qa);N.r=N.g=N.b=1-Na(aa.positionScreen.z,na,qa);ha.r=ha.g=ha.b=1-Na(ea.positionScreen.z,na,qa);ra.r=ra.g=ra.b=1-Na(oa.positionScreen.z,na,qa);xa=Wa(S,N,ha,ra);cb(ka,$,e,X,ua,va);Ea(ka,$,e,X,ua,va,xa,0,0,1,0,0,1);cb(za,ma,da,Y,W,ia);Ea(za,ma,da,Y,W,ia,xa,1,0,1,1,0,1)}}}function cb(L,aa,oa,ea,ta,Aa){n.beginPath();n.moveTo(L,aa);n.lineTo(oa,ea);n.lineTo(ta,Aa);n.lineTo(L,aa);n.closePath()}function eb(L,aa,oa,ea,ta,Aa,ga,ca){n.beginPath();n.moveTo(L,aa); -n.lineTo(oa,ea);n.lineTo(ta,Aa);n.lineTo(ga,ca);n.lineTo(L,aa);n.closePath()}function Qa(L,aa){if(B!=L)n.strokeStyle=B=L;if(I!=aa)n.lineWidth=I=aa;n.stroke();G.inflate(aa*2)}function Va(L){if(H!=L)n.fillStyle=H=L;n.fill()}function Ea(L,aa,oa,ea,ta,Aa,ga,ca,La,Ya,Za,db,hb){var bb,Xa;bb=ga.width-1;Xa=ga.height-1;ca*=bb;La*=Xa;Ya*=bb;Za*=Xa;db*=bb;hb*=Xa;oa-=L;ea-=aa;ta-=L;Aa-=aa;Ya-=ca;Za-=La;db-=ca;hb-=La;bb=Ya*hb-db*Za;if(bb!=0){Xa=1/bb;bb=(hb*oa-Za*ta)*Xa;Za=(hb*ea-Za*Aa)*Xa;oa=(Ya*ta-db*oa)*Xa; -ea=(Ya*Aa-db*ea)*Xa;L=L-bb*ca-oa*La;aa=aa-Za*ca-ea*La;n.save();n.transform(bb,Za,oa,ea,L,aa);n.clip();n.drawImage(ga,0,0);n.restore()}}function Wa(L,aa,oa,ea){var ta=~~(L.r*255),Aa=~~(L.g*255);L=~~(L.b*255);var ga=~~(aa.r*255),ca=~~(aa.g*255);aa=~~(aa.b*255);var La=~~(oa.r*255),Ya=~~(oa.g*255);oa=~~(oa.b*255);var Za=~~(ea.r*255),db=~~(ea.g*255);ea=~~(ea.b*255);Ba[0]=ta<0?0:ta>255?255:ta;Ba[1]=Aa<0?0:Aa>255?255:Aa;Ba[2]=L<0?0:L>255?255:L;Ba[4]=ga<0?0:ga>255?255:ga;Ba[5]=ca<0?0:ca>255?255:ca;Ba[6]= -aa<0?0:aa>255?255:aa;Ba[8]=La<0?0:La>255?255:La;Ba[9]=Ya<0?0:Ya>255?255:Ya;Ba[10]=oa<0?0:oa>255?255:oa;Ba[12]=Za<0?0:Za>255?255:Za;Ba[13]=db<0?0:db>255?255:db;Ba[14]=ea<0?0:ea>255?255:ea;pa.putImageData(sa,0,0);Fa.drawImage(ja,0,0);return ya}function Na(L,aa,oa){L=(L-aa)/(oa-aa);return L*L*(3-2*L)}function O(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function Oa(L,aa){var oa=aa.x-L.x,ea=aa.y-L.y,ta=1/Math.sqrt(oa*oa+ea*ea);oa*=ta;ea*=ta;aa.x+=oa;aa.y+=ea;L.x-=oa;L.y-=ea}var Ra,jb,Ca,Ta,Ga,Pa,Ka,wa;this.autoClear? -this.clear():n.setTransform(1,0,0,-1,k,m);b=d.projectScene(U,la,this.sortElements);(J=U.lights.length>0)&&Ma(U);Ra=0;for(jb=b.length;Ra0){ia.r+=N.color.r*ha;ia.g+=N.color.g*ha;ia.b+=N.color.b*ha}}else if(N instanceof THREE.PointLight){e.sub(N.position,W.centroidWorld);e.normalize();ha=W.normalWorld.dot(e)*N.intensity;if(ha>0){ia.r+=N.color.r*ha;ia.g+=N.color.g*ha;ia.b+=N.color.b*ha}}}}function c(ma,W,ia,Z,S,N){Y=d(ua++);Y.setAttribute("d", -"M "+ma.positionScreen.x+" "+ma.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+ia.positionScreen.x+","+ia.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)D.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(M){Q.r=R.r;Q.g=R.g;Q.b=R.b;a(N,Z,Q);D.r=S.color.r*Q.r;D.g=S.color.g*Q.g;D.b=S.color.b*Q.b;D.updateStyleString()}else D.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){$=1-S.__2near/(S.__farPlusNear- -Z.z*S.__farMinusNear);D.setRGB($,$,$)}else S instanceof THREE.MeshNormalMaterial&&D.setRGB(f(Z.normalWorld.x),f(Z.normalWorld.y),f(Z.normalWorld.z));S.wireframe?Y.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+S.wireframeLinewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframeLinecap+"; stroke-linejoin: "+S.wireframeLinejoin):Y.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+S.opacity);k.appendChild(Y)}function b(ma,W,ia,Z,S,N,ha){Y= -d(ua++);Y.setAttribute("d","M "+ma.positionScreen.x+" "+ma.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+ia.positionScreen.x+","+ia.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)D.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(M){Q.r=R.r;Q.g=R.g;Q.b=R.b;a(ha,S,Q);D.r=N.color.r*Q.r;D.g=N.color.g*Q.g;D.b=N.color.b*Q.b;D.updateStyleString()}else D.__styleString=N.color.__styleString; -else if(N instanceof THREE.MeshDepthMaterial){$=1-N.__2near/(N.__farPlusNear-S.z*N.__farMinusNear);D.setRGB($,$,$)}else N instanceof THREE.MeshNormalMaterial&&D.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));N.wireframe?Y.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+N.wireframeLinewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframeLinecap+"; stroke-linejoin: "+N.wireframeLinejoin):Y.setAttribute("style","fill: "+D.__styleString+ -"; fill-opacity: "+N.opacity);k.appendChild(Y)}function d(ma){if(X[ma]==null){X[ma]=document.createElementNS("http://www.w3.org/2000/svg","path");za==0&&X[ma].setAttribute("shape-rendering","crispEdges")}return X[ma]}function f(ma){return ma<0?Math.min((1+ma)*0.5,0.5):0.5+Math.min(ma*0.5,0.5)}var g=null,j=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,o,x,z,y,B,H,I=new THREE.Rectangle,F=new THREE.Rectangle,M=!1,D=new THREE.Color(16777215),Q=new THREE.Color(16777215), -R=new THREE.Color(0),P=new THREE.Color(0),ka=new THREE.Color(0),$,e=new THREE.Vector3,X=[],da=[],Y,ua,va,za=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ma){switch(ma){case "high":za=1;break;case "low":za=0}};this.setSize=function(ma,W){m=ma;n=W;o=m/2;x=n/2;k.setAttribute("viewBox",-o+" "+-x+" "+m+" "+n);k.setAttribute("width",m);k.setAttribute("height",n);I.set(-o,-x,o,x)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,e,f,g;this.domElement=document.createElement("div");this.setSize=function(j,k){b=j;e=k;f=b/2;g=e/2};this.render=function(j,k){var m,n,o,x,z,y,B,H;a=c.projectScene(j,k);m=0;for(n=a.length;m0){da.r+=ga.r*Aa;da.g+=ga.g*Aa;da.b+=ga.b*Aa}}else if(Aa instanceof THREE.PointLight){T.sub(Aa.position,$);T.normalize();Aa=oa.dot(T)*aa;if(Aa> +0){da.r+=ga.r*Aa;da.g+=ga.g*Aa;da.b+=ga.b*Aa}}}}function fb(L,$,oa){a(oa.opacity);c(oa.blending);var da,ta,Aa,ga,aa,La;if(oa instanceof THREE.ParticleBasicMaterial){if(oa.map){ga=oa.map.image;aa=ga.width>>1;La=ga.height>>1;oa=$.scale.x*k;Aa=$.scale.y*m;da=oa*aa;ta=Aa*La;G.set(L.x-da,L.y-ta,L.x+da,L.y+ta);if(p.instersects(G)){n.save();n.translate(L.x,L.y);n.rotate(-$.rotation);n.scale(oa,-Aa);n.translate(-aa,-La);n.drawImage(ga,0,0);n.restore()}}}else if(oa instanceof THREE.ParticleCanvasMaterial){if(J){E.r= +A.r+V.r+K.r;E.g=A.g+V.g+K.g;E.b=A.b+V.b+K.b;Z.r=oa.color.r*E.r;Z.g=oa.color.g*E.g;Z.b=oa.color.b*E.b;Z.updateStyleString()}else Z.__styleString=oa.color.__styleString;da=$.scale.x*k;ta=$.scale.y*m;G.set(L.x-da,L.y-ta,L.x+da,L.y+ta);if(p.instersects(G)){n.save();n.translate(L.x,L.y);n.rotate(-$.rotation);n.scale(da,ta);oa.program(n,Z);n.restore()}}}function Ua(L,$,oa,da){a(da.opacity);c(da.blending);n.beginPath();n.moveTo(L.positionScreen.x,L.positionScreen.y);n.lineTo($.positionScreen.x,$.positionScreen.y); +n.closePath();if(da instanceof THREE.LineBasicMaterial){Z.__styleString=da.color.__styleString;L=da.linewidth;if(I!=L)n.lineWidth=I=L;L=Z.__styleString;if(B!=L)n.strokeStyle=B=L;n.stroke();G.inflate(da.linewidth*2)}}function Ja(L,$,oa,da,ta,Aa,ga,aa,La){a(aa.opacity);c(aa.blending);ka=L.positionScreen.x;d=L.positionScreen.y;fa=$.positionScreen.x;X=$.positionScreen.y;ca=oa.positionScreen.x;Y=oa.positionScreen.y;cb(ka,d,fa,X,ca,Y);if(aa instanceof THREE.MeshBasicMaterial)if(aa.map){if(aa.map.mapping instanceof +THREE.UVMapping){Da=ga.uvs[0];Ea(ka,d,fa,X,ca,Y,aa.map.image,Da[da].u,Da[da].v,Da[ta].u,Da[ta].v,Da[Aa].u,Da[Aa].v)}}else if(aa.envMap){if(aa.envMap.mapping instanceof THREE.SphericalReflectionMapping){L=la.matrixWorldInverse;T.copy(ga.vertexNormalsWorld[0]);$a=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;ab=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ga.vertexNormalsWorld[1]);Ia=(T.x*L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;h=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;T.copy(ga.vertexNormalsWorld[2]);t=(T.x* +L.n11+T.y*L.n12+T.z*L.n13)*0.5+0.5;w=-(T.x*L.n21+T.y*L.n22+T.z*L.n23)*0.5+0.5;Ea(ka,d,fa,X,ca,Y,aa.envMap.image,$a,ab,Ia,h,t,w)}}else aa.wireframe?Qa(aa.color.__styleString,aa.wireframeLinewidth):Va(aa.color.__styleString);else if(aa instanceof THREE.MeshLambertMaterial){if(aa.map&&!aa.wireframe){if(aa.map.mapping instanceof THREE.UVMapping){Da=ga.uvs[0];Ea(ka,d,fa,X,ca,Y,aa.map.image,Da[da].u,Da[da].v,Da[ta].u,Da[ta].v,Da[Aa].u,Da[Aa].v)}c(THREE.SubtractiveBlending)}if(J)if(!aa.wireframe&&aa.shading== +THREE.SmoothShading&&ga.vertexNormalsWorld.length==3){S.r=N.r=ha.r=A.r;S.g=N.g=ha.g=A.g;S.b=N.b=ha.b=A.b;Ha(La,ga.v1.positionWorld,ga.vertexNormalsWorld[0],S);Ha(La,ga.v2.positionWorld,ga.vertexNormalsWorld[1],N);Ha(La,ga.v3.positionWorld,ga.vertexNormalsWorld[2],ha);ra.r=(N.r+ha.r)*0.5;ra.g=(N.g+ha.g)*0.5;ra.b=(N.b+ha.b)*0.5;xa=Wa(S,N,ha,ra);Ea(ka,d,fa,X,ca,Y,xa,0,0,1,0,0,1)}else{E.r=A.r;E.g=A.g;E.b=A.b;Ha(La,ga.centroidWorld,ga.normalWorld,E);Z.r=aa.color.r*E.r;Z.g=aa.color.g*E.g;Z.b=aa.color.b* +E.b;Z.updateStyleString();aa.wireframe?Qa(Z.__styleString,aa.wireframeLinewidth):Va(Z.__styleString)}else aa.wireframe?Qa(aa.color.__styleString,aa.wireframeLinewidth):Va(aa.color.__styleString)}else if(aa instanceof THREE.MeshDepthMaterial){na=la.near;qa=la.far;S.r=S.g=S.b=1-Na(L.positionScreen.z,na,qa);N.r=N.g=N.b=1-Na($.positionScreen.z,na,qa);ha.r=ha.g=ha.b=1-Na(oa.positionScreen.z,na,qa);ra.r=(N.r+ha.r)*0.5;ra.g=(N.g+ha.g)*0.5;ra.b=(N.b+ha.b)*0.5;xa=Wa(S,N,ha,ra);Ea(ka,d,fa,X,ca,Y,xa,0,0,1,0, +0,1)}else if(aa instanceof THREE.MeshNormalMaterial){Z.r=O(ga.normalWorld.x);Z.g=O(ga.normalWorld.y);Z.b=O(ga.normalWorld.z);Z.updateStyleString();aa.wireframe?Qa(Z.__styleString,aa.wireframeLinewidth):Va(Z.__styleString)}}function Sa(L,$,oa,da,ta,Aa,ga,aa,La){a(aa.opacity);c(aa.blending);if(aa.map||aa.envMap){Ja(L,$,da,0,1,3,ga,aa,La);Ja(ta,oa,Aa,1,2,3,ga,aa,La)}else{ka=L.positionScreen.x;d=L.positionScreen.y;fa=$.positionScreen.x;X=$.positionScreen.y;ca=oa.positionScreen.x;Y=oa.positionScreen.y; +ua=da.positionScreen.x;va=da.positionScreen.y;za=ta.positionScreen.x;ma=ta.positionScreen.y;W=Aa.positionScreen.x;ia=Aa.positionScreen.y;if(aa instanceof THREE.MeshBasicMaterial){eb(ka,d,fa,X,ca,Y,ua,va);aa.wireframe?Qa(aa.color.__styleString,aa.wireframeLinewidth):Va(aa.color.__styleString)}else if(aa instanceof THREE.MeshLambertMaterial)if(J)if(!aa.wireframe&&aa.shading==THREE.SmoothShading&&ga.vertexNormalsWorld.length==4){S.r=N.r=ha.r=ra.r=A.r;S.g=N.g=ha.g=ra.g=A.g;S.b=N.b=ha.b=ra.b=A.b;Ha(La, +ga.v1.positionWorld,ga.vertexNormalsWorld[0],S);Ha(La,ga.v2.positionWorld,ga.vertexNormalsWorld[1],N);Ha(La,ga.v4.positionWorld,ga.vertexNormalsWorld[3],ha);Ha(La,ga.v3.positionWorld,ga.vertexNormalsWorld[2],ra);xa=Wa(S,N,ha,ra);cb(ka,d,fa,X,ua,va);Ea(ka,d,fa,X,ua,va,xa,0,0,1,0,0,1);cb(za,ma,ca,Y,W,ia);Ea(za,ma,ca,Y,W,ia,xa,1,0,1,1,0,1)}else{E.r=A.r;E.g=A.g;E.b=A.b;Ha(La,ga.centroidWorld,ga.normalWorld,E);Z.r=aa.color.r*E.r;Z.g=aa.color.g*E.g;Z.b=aa.color.b*E.b;Z.updateStyleString();eb(ka,d,fa,X, +ca,Y,ua,va);aa.wireframe?Qa(Z.__styleString,aa.wireframeLinewidth):Va(Z.__styleString)}else{eb(ka,d,fa,X,ca,Y,ua,va);aa.wireframe?Qa(aa.color.__styleString,aa.wireframeLinewidth):Va(aa.color.__styleString)}else if(aa instanceof THREE.MeshNormalMaterial){Z.r=O(ga.normalWorld.x);Z.g=O(ga.normalWorld.y);Z.b=O(ga.normalWorld.z);Z.updateStyleString();eb(ka,d,fa,X,ca,Y,ua,va);aa.wireframe?Qa(Z.__styleString,aa.wireframeLinewidth):Va(Z.__styleString)}else if(aa instanceof THREE.MeshDepthMaterial){na=la.near; +qa=la.far;S.r=S.g=S.b=1-Na(L.positionScreen.z,na,qa);N.r=N.g=N.b=1-Na($.positionScreen.z,na,qa);ha.r=ha.g=ha.b=1-Na(da.positionScreen.z,na,qa);ra.r=ra.g=ra.b=1-Na(oa.positionScreen.z,na,qa);xa=Wa(S,N,ha,ra);cb(ka,d,fa,X,ua,va);Ea(ka,d,fa,X,ua,va,xa,0,0,1,0,0,1);cb(za,ma,ca,Y,W,ia);Ea(za,ma,ca,Y,W,ia,xa,1,0,1,1,0,1)}}}function cb(L,$,oa,da,ta,Aa){n.beginPath();n.moveTo(L,$);n.lineTo(oa,da);n.lineTo(ta,Aa);n.lineTo(L,$);n.closePath()}function eb(L,$,oa,da,ta,Aa,ga,aa){n.beginPath();n.moveTo(L,$);n.lineTo(oa, +da);n.lineTo(ta,Aa);n.lineTo(ga,aa);n.lineTo(L,$);n.closePath()}function Qa(L,$){if(B!=L)n.strokeStyle=B=L;if(I!=$)n.lineWidth=I=$;n.stroke();G.inflate($*2)}function Va(L){if(H!=L)n.fillStyle=H=L;n.fill()}function Ea(L,$,oa,da,ta,Aa,ga,aa,La,Ya,Za,db,hb){var bb,Xa;bb=ga.width-1;Xa=ga.height-1;aa*=bb;La*=Xa;Ya*=bb;Za*=Xa;db*=bb;hb*=Xa;oa-=L;da-=$;ta-=L;Aa-=$;Ya-=aa;Za-=La;db-=aa;hb-=La;bb=Ya*hb-db*Za;if(bb!=0){Xa=1/bb;bb=(hb*oa-Za*ta)*Xa;Za=(hb*da-Za*Aa)*Xa;oa=(Ya*ta-db*oa)*Xa;da=(Ya*Aa-db*da)*Xa; +L=L-bb*aa-oa*La;$=$-Za*aa-da*La;n.save();n.transform(bb,Za,oa,da,L,$);n.clip();n.drawImage(ga,0,0);n.restore()}}function Wa(L,$,oa,da){var ta=~~(L.r*255),Aa=~~(L.g*255);L=~~(L.b*255);var ga=~~($.r*255),aa=~~($.g*255);$=~~($.b*255);var La=~~(oa.r*255),Ya=~~(oa.g*255);oa=~~(oa.b*255);var Za=~~(da.r*255),db=~~(da.g*255);da=~~(da.b*255);Ba[0]=ta<0?0:ta>255?255:ta;Ba[1]=Aa<0?0:Aa>255?255:Aa;Ba[2]=L<0?0:L>255?255:L;Ba[4]=ga<0?0:ga>255?255:ga;Ba[5]=aa<0?0:aa>255?255:aa;Ba[6]=$<0?0:$>255?255:$;Ba[8]=La<0? +0:La>255?255:La;Ba[9]=Ya<0?0:Ya>255?255:Ya;Ba[10]=oa<0?0:oa>255?255:oa;Ba[12]=Za<0?0:Za>255?255:Za;Ba[13]=db<0?0:db>255?255:db;Ba[14]=da<0?0:da>255?255:da;pa.putImageData(sa,0,0);Fa.drawImage(ja,0,0);return ya}function Na(L,$,oa){L=(L-$)/(oa-$);return L*L*(3-2*L)}function O(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function Oa(L,$){var oa=$.x-L.x,da=$.y-L.y,ta=1/Math.sqrt(oa*oa+da*da);oa*=ta;da*=ta;$.x+=oa;$.y+=da;L.x-=oa;L.y-=da}var Ra,jb,Ca,Ta,Ga,Pa,Ka,wa;this.autoClear?this.clear():n.setTransform(1, +0,0,-1,k,m);b=e.projectScene(U,la,this.sortElements);(J=U.lights.length>0)&&Ma(U);Ra=0;for(jb=b.length;Ra0){ia.r+=N.color.r*ha;ia.g+=N.color.g*ha;ia.b+=N.color.b*ha}}else if(N instanceof THREE.PointLight){fa.sub(N.position,W.centroidWorld);fa.normalize();ha=W.normalWorld.dot(fa)*N.intensity;if(ha>0){ia.r+=N.color.r*ha;ia.g+=N.color.g*ha;ia.b+=N.color.b*ha}}}}function c(ma,W,ia,Z,S,N){Y=e(ua++);Y.setAttribute("d", +"M "+ma.positionScreen.x+" "+ma.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+ia.positionScreen.x+","+ia.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)D.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(M){Q.r=R.r;Q.g=R.g;Q.b=R.b;a(N,Z,Q);D.r=S.color.r*Q.r;D.g=S.color.g*Q.g;D.b=S.color.b*Q.b;D.updateStyleString()}else D.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){d=1-S.__2near/(S.__farPlusNear- +Z.z*S.__farMinusNear);D.setRGB(d,d,d)}else S instanceof THREE.MeshNormalMaterial&&D.setRGB(f(Z.normalWorld.x),f(Z.normalWorld.y),f(Z.normalWorld.z));S.wireframe?Y.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+S.wireframeLinewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframeLinecap+"; stroke-linejoin: "+S.wireframeLinejoin):Y.setAttribute("style","fill: "+D.__styleString+"; fill-opacity: "+S.opacity);k.appendChild(Y)}function b(ma,W,ia,Z,S,N,ha){Y= +e(ua++);Y.setAttribute("d","M "+ma.positionScreen.x+" "+ma.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+ia.positionScreen.x+","+ia.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)D.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(M){Q.r=R.r;Q.g=R.g;Q.b=R.b;a(ha,S,Q);D.r=N.color.r*Q.r;D.g=N.color.g*Q.g;D.b=N.color.b*Q.b;D.updateStyleString()}else D.__styleString=N.color.__styleString; +else if(N instanceof THREE.MeshDepthMaterial){d=1-N.__2near/(N.__farPlusNear-S.z*N.__farMinusNear);D.setRGB(d,d,d)}else N instanceof THREE.MeshNormalMaterial&&D.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));N.wireframe?Y.setAttribute("style","fill: none; stroke: "+D.__styleString+"; stroke-width: "+N.wireframeLinewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframeLinecap+"; stroke-linejoin: "+N.wireframeLinejoin):Y.setAttribute("style","fill: "+D.__styleString+ +"; fill-opacity: "+N.opacity);k.appendChild(Y)}function e(ma){if(X[ma]==null){X[ma]=document.createElementNS("http://www.w3.org/2000/svg","path");za==0&&X[ma].setAttribute("shape-rendering","crispEdges")}return X[ma]}function f(ma){return ma<0?Math.min((1+ma)*0.5,0.5):0.5+Math.min(ma*0.5,0.5)}var g=null,j=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,n,o,x,z,y,B,H,I=new THREE.Rectangle,F=new THREE.Rectangle,M=!1,D=new THREE.Color(16777215),Q=new THREE.Color(16777215), +R=new THREE.Color(0),P=new THREE.Color(0),ka=new THREE.Color(0),d,fa=new THREE.Vector3,X=[],ca=[],Y,ua,va,za=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ma){switch(ma){case "high":za=1;break;case "low":za=0}};this.setSize=function(ma,W){m=ma;n=W;o=m/2;x=n/2;k.setAttribute("viewBox",-o+" "+-x+" "+m+" "+n);k.setAttribute("width",m);k.setAttribute("height",n);I.set(-o,-x,o,x)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])}; this.render=function(ma,W){var ia,Z,S,N,ha,ra,na,qa;this.autoClear&&this.clear();g=j.projectScene(ma,W,this.sortElements);va=ua=0;if(M=ma.lights.length>0){na=ma.lights;R.setRGB(0,0,0);P.setRGB(0,0,0);ka.setRGB(0,0,0);ia=0;for(Z=na.length;iaA){V=K;A=E[V]}e.bindBuffer(e.ARRAY_BUFFER,C.__webGLMorphTargetsBuffers[V]);e.vertexAttribPointer(t["morphTarget"+w],3,e.FLOAT,!1,0,0);G.__webGLMorphTargetInfluences[w]=A;J[V]=1;A=-1;w++}}e.uniform1fv(p.program.uniforms.morphTargetInfluences,G.__webGLMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,C.__webGLVertexBuffer);e.vertexAttribPointer(h.position,3, -e.FLOAT,!1,0,0)}if(h.color>=0){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLColorBuffer);e.vertexAttribPointer(h.color,3,e.FLOAT,!1,0,0)}if(h.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLNormalBuffer);e.vertexAttribPointer(h.normal,3,e.FLOAT,!1,0,0)}if(h.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLTangentBuffer);e.vertexAttribPointer(h.tangent,4,e.FLOAT,!1,0,0)}if(h.uv>=0)if(C.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLUVBuffer);e.vertexAttribPointer(h.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(h.uv)}else e.disableVertexAttribArray(h.uv); -if(h.uv2>=0)if(C.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLUV2Buffer);e.vertexAttribPointer(h.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(h.uv2)}else e.disableVertexAttribArray(h.uv2);if(p.skinning&&h.skinVertexA>=0&&h.skinVertexB>=0&&h.skinIndex>=0&&h.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinVertexABuffer);e.vertexAttribPointer(h.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinVertexBBuffer);e.vertexAttribPointer(h.skinVertexB,4,e.FLOAT,!1,0, -0);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinIndicesBuffer);e.vertexAttribPointer(h.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinWeightsBuffer);e.vertexAttribPointer(h.skinWeight,4,e.FLOAT,!1,0,0)}if(G instanceof THREE.Mesh)if(p.wireframe){e.lineWidth(p.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLLineBuffer);e.drawElements(e.LINES,C.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLFaceBuffer);e.drawElements(e.TRIANGLES, -C.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(G instanceof THREE.Line){G=G.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(p.linewidth);e.drawArrays(G,0,C.__webGLLineCount)}else if(G instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,C.__webGLParticleCount);else G instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,C.__webGLVertexCount)}}function g(h,t){if(!h.__webGLVertexBuffer)h.__webGLVertexBuffer=e.createBuffer();if(!h.__webGLNormalBuffer)h.__webGLNormalBuffer=e.createBuffer(); -if(h.hasPos){e.bindBuffer(e.ARRAY_BUFFER,h.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,h.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(t.attributes.position);e.vertexAttribPointer(t.attributes.position,3,e.FLOAT,!1,0,0)}if(h.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,h.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,h.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(t.attributes.normal);e.vertexAttribPointer(t.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,h.count); -h.count=0}function j(h){if(ua!=h.doubleSided){h.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);ua=h.doubleSided}if(va!=h.flipSided){h.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);va=h.flipSided}}function k(h){if(ma!=h){h?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);ma=h}}function m(h){N[0].set(h.n41-h.n11,h.n42-h.n12,h.n43-h.n13,h.n44-h.n14);N[1].set(h.n41+h.n11,h.n42+h.n12,h.n43+h.n13,h.n44+h.n14);N[2].set(h.n41+h.n21,h.n42+h.n22,h.n43+h.n23,h.n44+h.n24);N[3].set(h.n41-h.n21,h.n42- -h.n22,h.n43-h.n23,h.n44-h.n24);N[4].set(h.n41-h.n31,h.n42-h.n32,h.n43-h.n33,h.n44-h.n34);N[5].set(h.n41+h.n31,h.n42+h.n32,h.n43+h.n33,h.n44+h.n34);var t;for(h=0;h<6;h++){t=N[h];t.divideScalar(Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z))}}function n(h){for(var t=h.matrixWorld,w=-h.geometry.boundingSphere.radius*Math.max(h.scale.x,Math.max(h.scale.y,h.scale.z)),p=0;p<6;p++){h=N[p].x*t.n14+N[p].y*t.n24+N[p].z*t.n34+N[p].w;if(h<=w)return!1}return!0}function o(h,t){h.list[h.count]=t;h.count+=1}function x(h){var t, -w,p=h.object,C=h.opaque,G=h.transparent;G.count=0;h=C.count=0;for(t=p.materials.length;h0){e.bindBuffer(e.ARRAY_BUFFER,p.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,Pa,C)}if(Za){e.bindBuffer(e.ARRAY_BUFFER,p.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Ta,C)}if(db&&ga.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,p.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,Ga,C)}if(Ya&&cb>0){e.bindBuffer(e.ARRAY_BUFFER,p.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,jb,C)}if(Ya&& -eb>0){e.bindBuffer(e.ARRAY_BUFFER,p.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Ca,C)}if(La){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ea,C);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ta,C)}if(O>0){e.bindBuffer(e.ARRAY_BUFFER,p.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,Ka,C);e.bindBuffer(e.ARRAY_BUFFER,p.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,wa,C);e.bindBuffer(e.ARRAY_BUFFER, -p.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,L,C);e.bindBuffer(e.ARRAY_BUFFER,p.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,aa,C)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(h instanceof THREE.Ribbon){w=h.geometry;if(w.__dirtyVertices||w.__dirtyColors){h=w;t=e.DYNAMIC_DRAW;Ba=h.vertices;C=h.colors;ya=Ba.length;G=C.length;Fa=h.__vertexArray;J=h.__colorArray;Ja=h.__dirtyColors; -if(h.__dirtyVertices){for(pa=0;pa65535){K[A].counter+=1;V=K[A].hash+"_"+K[A].counter;h.geometryGroups[V]==undefined&&(h.geometryGroups[V]={faces:[],materials:E,vertices:0,numMorphTargets:T})}h.geometryGroups[V].faces.push(C);h.geometryGroups[V].vertices+=J}}function F(h,t,w){h.push({buffer:t,object:w,opaque:{list:[], -count:0},transparent:{list:[],count:0}})}function M(h){if(h!=za){switch(h){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA)}za=h}}function D(h,t,w){if((w.width&w.width-1)==0&&(w.height&w.height-1)== -0){e.texParameteri(h,e.TEXTURE_WRAP_S,ka(t.wrapS));e.texParameteri(h,e.TEXTURE_WRAP_T,ka(t.wrapT));e.texParameteri(h,e.TEXTURE_MAG_FILTER,ka(t.magFilter));e.texParameteri(h,e.TEXTURE_MIN_FILTER,ka(t.minFilter));e.generateMipmap(h)}else{e.texParameteri(h,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(h,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(h,e.TEXTURE_MAG_FILTER,P(t.magFilter));e.texParameteri(h,e.TEXTURE_MIN_FILTER,P(t.minFilter))}}function Q(h){if(h&&!h.__webGLFramebuffer){h.__webGLFramebuffer= -e.createFramebuffer();h.__webGLRenderbuffer=e.createRenderbuffer();h.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,h.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,h.width,h.height);e.bindTexture(e.TEXTURE_2D,h.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,ka(h.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,ka(h.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,ka(h.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER, -ka(h.minFilter));e.texImage2D(e.TEXTURE_2D,0,ka(h.format),h.width,h.height,0,ka(h.format),ka(h.type),null);e.bindFramebuffer(e.FRAMEBUFFER,h.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,h.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,h.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var t,w;if(h){t=h.__webGLFramebuffer;w=h.width; -h=h.height}else{t=null;w=Z;h=S}if(t!=da){e.bindFramebuffer(e.FRAMEBUFFER,t);e.viewport(W,ia,w,h);da=t}}function R(h,t){var w;if(h=="fragment")w=e.createShader(e.FRAGMENT_SHADER);else h=="vertex"&&(w=e.createShader(e.VERTEX_SHADER));e.shaderSource(w,t);e.compileShader(w);if(!e.getShaderParameter(w,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(w));console.error(t);return null}return w}function P(h){switch(h){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST; -default:return e.LINEAR}}function ka(h){switch(h){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR; -case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0} -var $=document.createElement("canvas"),e,X=null,da=null,Y=this,ua=null,va=null,za=null,ma=null,W=0,ia=0,Z=0,S=0,N=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ha=new THREE.Matrix4,ra=new Float32Array(16),na=new Float32Array(16),qa=new THREE.Vector4,xa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Da=!0,$a=new THREE.Color(0),ab=0;if(a){if(a.antialias!==undefined)Da=a.antialias; -a.clearColor!==undefined&&$a.setHex(a.clearColor);if(a.clearAlpha!==undefined)ab=a.clearAlpha}this.maxMorphTargets=8;this.domElement=$;this.autoClear=!0;this.sortObjects=!0;(function(h,t,w){try{if(!(e=$.getContext("experimental-webgl",{antialias:h,stencil:!0})))throw"Error creating WebGL context.";}catch(p){console.error(p)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE, -e.ONE_MINUS_SRC_ALPHA);e.clearColor(t.r,t.g,t.b,w)})(Da,$a,ab);this.context=e;var Ia={};a=[];Da=[];a[0]=-2;a[1]=-1;a[2]=-1;a[3]=2;a[4]=-1;a[5]=-1;a[6]=2;a[7]=1;a[8]=-1;a[9]=-2;a[10]=1;a[11]=-1;Da[0]=0;Da[1]=1;Da[2]=2;Da[3]=0;Da[4]=2;Da[5]=3;Ia.vertexBuffer=e.createBuffer();Ia.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,Ia.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,new Float32Array(a),e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,Ia.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER, -new Uint16Array(Da),e.STATIC_DRAW);Ia.program=e.createProgram();e.attachShader(Ia.program,R("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(Ia.program,R("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(Ia.program);Ia.vertexLocation=e.getAttribLocation(Ia.program,"position");Ia.projectionLocation=e.getUniformLocation(Ia.program,"projectionMatrix");this.setSize=function(h,t){$.width=h;$.height=t;this.setViewport(0,0,$.width,$.height)};this.setViewport=function(h, -t,w,p){W=h;ia=t;Z=w;S=p;e.viewport(W,ia,Z,S)};this.setScissor=function(h,t,w,p){e.scissor(h,t,w,p)};this.enableScissorTest=function(h){h?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(h){e.depthMask(h)};this.setClearColorHex=function(h,t){var w=new THREE.Color(h);e.clearColor(w.r,w.g,w.b,t)};this.setClearColor=function(h,t){e.clearColor(h.r,h.g,h.b,t)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.initMaterial= -function(h,t,w,p){var C,G,J,E;if(h instanceof THREE.MeshDepthMaterial)b(h,THREE.ShaderLib.depth);else if(h instanceof THREE.ShadowVolumeDynamicMaterial)b(h,THREE.ShaderLib.shadowVolumeDynamic);else if(h instanceof THREE.MeshNormalMaterial)b(h,THREE.ShaderLib.normal);else if(h instanceof THREE.MeshBasicMaterial)b(h,THREE.ShaderLib.basic);else if(h instanceof THREE.MeshLambertMaterial)b(h,THREE.ShaderLib.lambert);else if(h instanceof THREE.MeshPhongMaterial)b(h,THREE.ShaderLib.phong);else if(h instanceof -THREE.LineBasicMaterial)b(h,THREE.ShaderLib.basic);else h instanceof THREE.ParticleBasicMaterial&&b(h,THREE.ShaderLib.particle_basic);if(!h.program){var A,V,K;A=K=E=0;for(J=t.length;A0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+J.maxDirLights,"#define MAX_POINT_LIGHTS "+J.maxPointLights,"#define MAX_BONES "+J.maxBones,J.map?"#define USE_MAP":"",J.envMap?"#define USE_ENVMAP":"",J.lightMap?"#define USE_LIGHTMAP":"",J.vertexColors?"#define USE_COLOR":"",J.skinning?"#define USE_SKINNING":"",J.morphTargets?"#define USE_MORPHTARGETS": -"",J.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_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_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); -e.attachShader(t,R("fragment",A+w));e.attachShader(t,R("vertex",J+E));e.linkProgram(t);e.getProgramParameter(t,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(t,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");t.uniforms={};t.attributes={};h.program=t;w=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(C in h.uniforms)w.push(C); -C=h.program;E=0;for(t=w.length;E=0&&e.enableVertexAttribArray(G.color);G.normal>=0&&e.enableVertexAttribArray(G.normal); -G.tangent>=0&&e.enableVertexAttribArray(G.tangent);if(h.skinning&&G.skinVertexA>=0&&G.skinVertexB>=0&&G.skinIndex>=0&&G.skinWeight>=0){e.enableVertexAttribArray(G.skinVertexA);e.enableVertexAttribArray(G.skinVertexB);e.enableVertexAttribArray(G.skinIndex);e.enableVertexAttribArray(G.skinWeight)}if(h.morphTargets){h.numSupportedMorphTargets=0;if(G.morphTarget0>=0){e.enableVertexAttribArray(G.morphTarget0);h.numSupportedMorphTargets++}if(G.morphTarget1>=0){e.enableVertexAttribArray(G.morphTarget1); -h.numSupportedMorphTargets++}if(G.morphTarget2>=0){e.enableVertexAttribArray(G.morphTarget2);h.numSupportedMorphTargets++}if(G.morphTarget3>=0){e.enableVertexAttribArray(G.morphTarget3);h.numSupportedMorphTargets++}if(G.morphTarget4>=0){e.enableVertexAttribArray(G.morphTarget4);h.numSupportedMorphTargets++}if(G.morphTarget5>=0){e.enableVertexAttribArray(G.morphTarget5);h.numSupportedMorphTargets++}if(G.morphTarget6>=0){e.enableVertexAttribArray(G.morphTarget6);h.numSupportedMorphTargets++}if(G.morphTarget7>= -0){e.enableVertexAttribArray(G.morphTarget7);h.numSupportedMorphTargets++}p.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(C=0;CA){V=K;A=E[V]}d.bindBuffer(d.ARRAY_BUFFER,C.__webglMorphTargetsBuffers[V]);d.vertexAttribPointer(t["morphTarget"+w],3,d.FLOAT,!1,0,0);G.__webglMorphTargetInfluences[w]=A;J[V]=1;A=-1;w++}}d.uniform1fv(p.program.uniforms.morphTargetInfluences,G.__webglMorphTargetInfluences)}else{d.bindBuffer(d.ARRAY_BUFFER,C.__webglVertexBuffer);d.vertexAttribPointer(h.position,3,d.FLOAT,!1,0,0)}if(h.color>=0){d.bindBuffer(d.ARRAY_BUFFER,C.__webglColorBuffer); +d.vertexAttribPointer(h.color,3,d.FLOAT,!1,0,0)}if(h.normal>=0){d.bindBuffer(d.ARRAY_BUFFER,C.__webglNormalBuffer);d.vertexAttribPointer(h.normal,3,d.FLOAT,!1,0,0)}if(h.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,C.__webglTangentBuffer);d.vertexAttribPointer(h.tangent,4,d.FLOAT,!1,0,0)}if(h.uv>=0)if(C.__webglUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,C.__webglUVBuffer);d.vertexAttribPointer(h.uv,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(h.uv)}else d.disableVertexAttribArray(h.uv);if(h.uv2>=0)if(C.__webglUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER, +C.__webglUV2Buffer);d.vertexAttribPointer(h.uv2,2,d.FLOAT,!1,0,0);d.enableVertexAttribArray(h.uv2)}else d.disableVertexAttribArray(h.uv2);if(p.skinning&&h.skinVertexA>=0&&h.skinVertexB>=0&&h.skinIndex>=0&&h.skinWeight>=0){d.bindBuffer(d.ARRAY_BUFFER,C.__webglSkinVertexABuffer);d.vertexAttribPointer(h.skinVertexA,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,C.__webglSkinVertexBBuffer);d.vertexAttribPointer(h.skinVertexB,4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,C.__webglSkinIndicesBuffer);d.vertexAttribPointer(h.skinIndex, +4,d.FLOAT,!1,0,0);d.bindBuffer(d.ARRAY_BUFFER,C.__webglSkinWeightsBuffer);d.vertexAttribPointer(h.skinWeight,4,d.FLOAT,!1,0,0)}if(G instanceof THREE.Mesh)if(p.wireframe){d.lineWidth(p.wireframeLinewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,C.__webglLineBuffer);d.drawElements(d.LINES,C.__webglLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,C.__webglFaceBuffer);d.drawElements(d.TRIANGLES,C.__webglFaceCount,d.UNSIGNED_SHORT,0)}else if(G instanceof THREE.Line){G=G.type==THREE.LineStrip? +d.LINE_STRIP:d.LINES;d.lineWidth(p.linewidth);d.drawArrays(G,0,C.__webglLineCount)}else if(G instanceof THREE.ParticleSystem)d.drawArrays(d.POINTS,0,C.__webglParticleCount);else G instanceof THREE.Ribbon&&d.drawArrays(d.TRIANGLE_STRIP,0,C.__webglVertexCount)}}function g(h,t){if(!h.__webglVertexBuffer)h.__webglVertexBuffer=d.createBuffer();if(!h.__webglNormalBuffer)h.__webglNormalBuffer=d.createBuffer();if(h.hasPos){d.bindBuffer(d.ARRAY_BUFFER,h.__webglVertexBuffer);d.bufferData(d.ARRAY_BUFFER,h.positionArray, +d.DYNAMIC_DRAW);d.enableVertexAttribArray(t.attributes.position);d.vertexAttribPointer(t.attributes.position,3,d.FLOAT,!1,0,0)}if(h.hasNormal){d.bindBuffer(d.ARRAY_BUFFER,h.__webglNormalBuffer);d.bufferData(d.ARRAY_BUFFER,h.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(t.attributes.normal);d.vertexAttribPointer(t.attributes.normal,3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,0,h.count);h.count=0}function j(h){if(ua!=h.doubleSided){h.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE);ua= +h.doubleSided}if(va!=h.flipSided){h.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW);va=h.flipSided}}function k(h){if(ma!=h){h?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST);ma=h}}function m(h){N[0].set(h.n41-h.n11,h.n42-h.n12,h.n43-h.n13,h.n44-h.n14);N[1].set(h.n41+h.n11,h.n42+h.n12,h.n43+h.n13,h.n44+h.n14);N[2].set(h.n41+h.n21,h.n42+h.n22,h.n43+h.n23,h.n44+h.n24);N[3].set(h.n41-h.n21,h.n42-h.n22,h.n43-h.n23,h.n44-h.n24);N[4].set(h.n41-h.n31,h.n42-h.n32,h.n43-h.n33,h.n44-h.n34);N[5].set(h.n41+h.n31, +h.n42+h.n32,h.n43+h.n33,h.n44+h.n34);var t;for(h=0;h<6;h++){t=N[h];t.divideScalar(Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z))}}function n(h){for(var t=h.matrixWorld,w=-h.geometry.boundingSphere.radius*Math.max(h.scale.x,Math.max(h.scale.y,h.scale.z)),p=0;p<6;p++){h=N[p].x*t.n14+N[p].y*t.n24+N[p].z*t.n34+N[p].w;if(h<=w)return!1}return!0}function o(h,t){h.list[h.count]=t;h.count+=1}function x(h){var t,w,p=h.object,C=h.opaque,G=h.transparent;G.count=0;h=C.count=0;for(t=p.materials.length;h0){d.bindBuffer(d.ARRAY_BUFFER,p.__webglColorBuffer);d.bufferData(d.ARRAY_BUFFER,Pa,C)}if(Za){d.bindBuffer(d.ARRAY_BUFFER,p.__webglNormalBuffer);d.bufferData(d.ARRAY_BUFFER,Ta,C)}if(db&&ga.hasTangents){d.bindBuffer(d.ARRAY_BUFFER,p.__webglTangentBuffer);d.bufferData(d.ARRAY_BUFFER,Ga,C)}if(Ya&&cb>0){d.bindBuffer(d.ARRAY_BUFFER,p.__webglUVBuffer);d.bufferData(d.ARRAY_BUFFER,jb,C)}if(Ya&&eb>0){d.bindBuffer(d.ARRAY_BUFFER,p.__webglUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ca,C)}if(La){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER, +p.__webglFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,da,C);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,p.__webglLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,ta,C)}if(O>0){d.bindBuffer(d.ARRAY_BUFFER,p.__webglSkinVertexABuffer);d.bufferData(d.ARRAY_BUFFER,Ka,C);d.bindBuffer(d.ARRAY_BUFFER,p.__webglSkinVertexBBuffer);d.bufferData(d.ARRAY_BUFFER,wa,C);d.bindBuffer(d.ARRAY_BUFFER,p.__webglSkinIndicesBuffer);d.bufferData(d.ARRAY_BUFFER,L,C);d.bindBuffer(d.ARRAY_BUFFER,p.__webglSkinWeightsBuffer);d.bufferData(d.ARRAY_BUFFER, +$,C)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(h instanceof THREE.Ribbon){w=h.geometry;if(w.__dirtyVertices||w.__dirtyColors){h=w;t=d.DYNAMIC_DRAW;Ba=h.vertices;C=h.colors;ya=Ba.length;G=C.length;Fa=h.__vertexArray;J=h.__colorArray;Ja=h.__dirtyColors;if(h.__dirtyVertices){for(pa=0;pa65535){K[A].counter+=1;V=K[A].hash+"_"+K[A].counter;h.geometryGroups[V]==undefined&&(h.geometryGroups[V]={faces:[],materials:E,vertices:0,numMorphTargets:T})}h.geometryGroups[V].faces.push(C);h.geometryGroups[V].vertices+=J}}function F(h,t,w){h.push({buffer:t,object:w,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(h){if(h!=za){switch(h){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA, +d.ONE);break;case THREE.SubtractiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ZERO,d.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ZERO,d.SRC_COLOR);break;default:d.blendEquationSeparate(d.FUNC_ADD,d.FUNC_ADD);d.blendFuncSeparate(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA)}za=h}}function D(h,t,w){if((w.width&w.width-1)==0&&(w.height&w.height-1)==0){d.texParameteri(h,d.TEXTURE_WRAP_S,ka(t.wrapS));d.texParameteri(h,d.TEXTURE_WRAP_T, +ka(t.wrapT));d.texParameteri(h,d.TEXTURE_MAG_FILTER,ka(t.magFilter));d.texParameteri(h,d.TEXTURE_MIN_FILTER,ka(t.minFilter));d.generateMipmap(h)}else{d.texParameteri(h,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE);d.texParameteri(h,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE);d.texParameteri(h,d.TEXTURE_MAG_FILTER,P(t.magFilter));d.texParameteri(h,d.TEXTURE_MIN_FILTER,P(t.minFilter))}}function Q(h){if(h&&!h.__webglFramebuffer){h.__webglFramebuffer=d.createFramebuffer();h.__webglRenderbuffer=d.createRenderbuffer();h.__webglTexture= +d.createTexture();d.bindRenderbuffer(d.RENDERBUFFER,h.__webglRenderbuffer);d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,h.width,h.height);d.bindTexture(d.TEXTURE_2D,h.__webglTexture);d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,ka(h.wrapS));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,ka(h.wrapT));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,ka(h.magFilter));d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,ka(h.minFilter));d.texImage2D(d.TEXTURE_2D,0,ka(h.format),h.width,h.height, +0,ka(h.format),ka(h.type),null);d.bindFramebuffer(d.FRAMEBUFFER,h.__webglFramebuffer);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,h.__webglTexture,0);d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,h.__webglRenderbuffer);d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER,null)}var t,w;if(h){t=h.__webglFramebuffer;w=h.width;h=h.height}else{t=null;w=Z;h=S}if(t!=ca){d.bindFramebuffer(d.FRAMEBUFFER, +t);d.viewport(W,ia,w,h);ca=t}}function R(h,t){var w;if(h=="fragment")w=d.createShader(d.FRAGMENT_SHADER);else h=="vertex"&&(w=d.createShader(d.VERTEX_SHADER));d.shaderSource(w,t);d.compileShader(w);if(!d.getShaderParameter(w,d.COMPILE_STATUS)){console.error(d.getShaderInfoLog(w));console.error(t);return null}return w}function P(h){switch(h){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return d.NEAREST;default:return d.LINEAR}}function ka(h){switch(h){case THREE.RepeatWrapping:return d.REPEAT; +case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE; +case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var d,fa=document.createElement("canvas"), +X=null,ca=null,Y=this,ua=null,va=null,za=null,ma=null,W=0,ia=0,Z=0,S=0,N=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ha=new THREE.Matrix4,ra=new Float32Array(16),na=new Float32Array(16),qa=new THREE.Vector4,xa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Da=!0,$a=new THREE.Color(0),ab=0;if(a){if(a.antialias!==undefined)Da=a.antialias;a.clearColor!==undefined&&$a.setHex(a.clearColor); +if(a.clearAlpha!==undefined)ab=a.clearAlpha}this.maxMorphTargets=8;this.domElement=fa;this.autoClear=!0;this.sortObjects=!0;(function(h,t,w){try{if(!(d=fa.getContext("experimental-webgl",{antialias:h,stencil:!0})))throw"Error creating WebGL context.";}catch(p){console.error(p)}d.clearColor(0,0,0,1);d.clearDepth(1);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA); +d.clearColor(t.r,t.g,t.b,w)})(Da,$a,ab);this.context=d;var Ia={};a=[];Da=[];a[0]=-2;a[1]=-1;a[2]=-1;a[3]=2;a[4]=-1;a[5]=-1;a[6]=2;a[7]=1;a[8]=-1;a[9]=-2;a[10]=1;a[11]=-1;Da[0]=0;Da[1]=1;Da[2]=2;Da[3]=0;Da[4]=2;Da[5]=3;Ia.vertexBuffer=d.createBuffer();Ia.elementBuffer=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,Ia.vertexBuffer);d.bufferData(d.ARRAY_BUFFER,new Float32Array(a),d.STATIC_DRAW);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,Ia.elementBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,new Uint16Array(Da), +d.STATIC_DRAW);Ia.program=d.createProgram();d.attachShader(Ia.program,R("fragment",THREE.ShaderLib.shadowPost.fragmentShader));d.attachShader(Ia.program,R("vertex",THREE.ShaderLib.shadowPost.vertexShader));d.linkProgram(Ia.program);Ia.vertexLocation=d.getAttribLocation(Ia.program,"position");Ia.projectionLocation=d.getUniformLocation(Ia.program,"projectionMatrix");this.setSize=function(h,t){fa.width=h;fa.height=t;this.setViewport(0,0,fa.width,fa.height)};this.setViewport=function(h,t,w,p){W=h;ia= +t;Z=w;S=p;d.viewport(W,ia,Z,S)};this.setScissor=function(h,t,w,p){d.scissor(h,t,w,p)};this.enableScissorTest=function(h){h?d.enable(d.SCISSOR_TEST):d.disable(d.SCISSOR_TEST)};this.enableDepthBufferWrite=function(h){d.depthMask(h)};this.setClearColorHex=function(h,t){var w=new THREE.Color(h);d.clearColor(w.r,w.g,w.b,t)};this.setClearColor=function(h,t){d.clearColor(h.r,h.g,h.b,t)};this.clear=function(){d.clear(d.COLOR_BUFFER_BIT|d.DEPTH_BUFFER_BIT|d.STENCIL_BUFFER_BIT)};this.initMaterial=function(h, +t,w,p){var C,G,J,E;if(h instanceof THREE.MeshDepthMaterial)b(h,THREE.ShaderLib.depth);else if(h instanceof THREE.ShadowVolumeDynamicMaterial)b(h,THREE.ShaderLib.shadowVolumeDynamic);else if(h instanceof THREE.MeshNormalMaterial)b(h,THREE.ShaderLib.normal);else if(h instanceof THREE.MeshBasicMaterial)b(h,THREE.ShaderLib.basic);else if(h instanceof THREE.MeshLambertMaterial)b(h,THREE.ShaderLib.lambert);else if(h instanceof THREE.MeshPhongMaterial)b(h,THREE.ShaderLib.phong);else if(h instanceof THREE.LineBasicMaterial)b(h, +THREE.ShaderLib.basic);else h instanceof THREE.ParticleBasicMaterial&&b(h,THREE.ShaderLib.particle_basic);if(!h.program){var A,V,K;A=K=E=0;for(J=t.length;A0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+J.maxDirLights,"#define MAX_POINT_LIGHTS "+J.maxPointLights,"#define MAX_BONES "+J.maxBones,J.map?"#define USE_MAP":"",J.envMap?"#define USE_ENVMAP":"",J.lightMap?"#define USE_LIGHTMAP":"",J.vertexColors?"#define USE_COLOR":"",J.skinning?"#define USE_SKINNING":"",J.morphTargets?"#define USE_MORPHTARGETS":"",J.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"); +d.attachShader(t,R("fragment",A+w));d.attachShader(t,R("vertex",J+E));d.linkProgram(t);d.getProgramParameter(t,d.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+d.getProgramParameter(t,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");t.uniforms={};t.attributes={};h.program=t;w=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(C in h.uniforms)w.push(C); +C=h.program;E=0;for(t=w.length;E=0&&d.enableVertexAttribArray(G.color);G.normal>=0&&d.enableVertexAttribArray(G.normal); +G.tangent>=0&&d.enableVertexAttribArray(G.tangent);if(h.skinning&&G.skinVertexA>=0&&G.skinVertexB>=0&&G.skinIndex>=0&&G.skinWeight>=0){d.enableVertexAttribArray(G.skinVertexA);d.enableVertexAttribArray(G.skinVertexB);d.enableVertexAttribArray(G.skinIndex);d.enableVertexAttribArray(G.skinWeight)}if(h.morphTargets){h.numSupportedMorphTargets=0;if(G.morphTarget0>=0){d.enableVertexAttribArray(G.morphTarget0);h.numSupportedMorphTargets++}if(G.morphTarget1>=0){d.enableVertexAttribArray(G.morphTarget1); +h.numSupportedMorphTargets++}if(G.morphTarget2>=0){d.enableVertexAttribArray(G.morphTarget2);h.numSupportedMorphTargets++}if(G.morphTarget3>=0){d.enableVertexAttribArray(G.morphTarget3);h.numSupportedMorphTargets++}if(G.morphTarget4>=0){d.enableVertexAttribArray(G.morphTarget4);h.numSupportedMorphTargets++}if(G.morphTarget5>=0){d.enableVertexAttribArray(G.morphTarget5);h.numSupportedMorphTargets++}if(G.morphTarget6>=0){d.enableVertexAttribArray(G.morphTarget6);h.numSupportedMorphTargets++}if(G.morphTarget7>= +0){d.enableVertexAttribArray(G.morphTarget7);h.numSupportedMorphTargets++}p.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);C=0;for(G=this.maxMorphTargets;C0||Ba.faceVertexUvs.length>0)J.__uvArray=new Float32Array(A*2);if(Ba.faceUvs.length>1||Ba.faceVertexUvs.length>1)J.__uv2Array=new Float32Array(A*2)}if(E.geometry.skinWeights.length&&E.geometry.skinIndices.length){J.__skinVertexAArray=new Float32Array(A*4);J.__skinVertexBArray=new Float32Array(A*4);J.__skinIndexArray=new Float32Array(A*4);J.__skinWeightArray=new Float32Array(A*4)}J.__faceArray=new Uint16Array(ja*3+(E.geometry.edgeFaces?E.geometry.edgeFaces.length*6:0)); -J.__lineArray=new Uint16Array(pa*2);if(J.numMorphTargets){Ba=void 0;ya=void 0;J.__morphTargetsArrays=[];Ba=0;for(ya=J.numMorphTargets;Ba=0;C--){p=w.__webglObjects[C].object; -t==p&&w.__webglObjects.splice(C,1)}h.__objectsRemoved.splice(0,1)}t=0;for(w=h.__webglObjects.length;t -0}};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(a,c,b){b&&a.update(undefined,!1,c);b=a.sounds;var d,f=b.length;for(d=0;d=0;C--){p=w.__webglObjects[C].object; +t==p&&w.__webglObjects.splice(C,1)}h.__objectsRemoved.splice(0,1)}t=0;for(w=h.__webglObjects.length;t +0}};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(a,c,b){b&&a.update(undefined,!1,c);b=a.sounds;var e,f=b.length;for(e=0;e25&&(g=25);f=(g-1)*0.5;b=Array(g);for(c=d=0;c25&&(g=25);f=(g-1)*0.5;b=Array(g);for(c=e=0;cthis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed); -var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;b=this.target.position;var d=this.position;b.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=d.y+100*Math.cos(this.phi);b.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()}, +var b=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;b=this.target.position;var e=this.position;b.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=e.y+100*Math.cos(this.phi);b.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()}, !1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype; THREE.QuakeCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))}; THREE.PathCamera=function(a){function c(n,o,x,z){var y={name:x,fps:0.6,length:z,hierarchy:[]},B,H=o.getControlPointsArray(),I=o.getLength(),F=H.length,M=0;B=F-1;o={parent:-1,keys:[]};o.keys[0]={time:0,pos:H[0],rot:[0,0,0,1],scl:[1,1,1]};o.keys[B]={time:z,pos:H[B],rot:[0,0,0,1],scl:[1,1,1]};for(B=1;B=0?z:z+f;z=this.verticalAngleMap.srcRange;y=this.verticalAngleMap.dstRange; this.phi=(this.phi-z[0])*(y[1]-y[0])/(z[1]-z[0])+y[0];z=this.horizontalAngleMap.srcRange;y=this.horizontalAngleMap.dstRange;this.theta=(this.theta-z[0])*(y[1]-y[0])/(z[1]-z[0])+y[0];z=this.target.position;z.x=100*Math.sin(this.phi)*Math.cos(this.theta);z.y=100*Math.cos(this.phi);z.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,n,o,x)};this.onMouseMove=function(n){this.mouseX=n.clientX-this.windowHalfX;this.mouseY=n.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var j=new THREE.MeshLambertMaterial({color:65280}),k=new Cube(10,10,20),m=new Cube(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(m,j);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= -c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(n,o){return function(){o.apply(n,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; -var Cube=function(a,c,b,d,f,g,j,k,m){function n(I,F,M,D,Q,R,P,ka){var $,e,X=d||1,da=f||1,Y=Q/2,ua=R/2,va=o.vertices.length;if(I=="x"&&F=="y"||I=="y"&&F=="x")$="z";else if(I=="x"&&F=="z"||I=="z"&&F=="x"){$="y";da=g||1}else if(I=="z"&&F=="y"||I=="y"&&F=="z"){$="x";X=g||1}var za=X+1,ma=da+1;Q/=X;var W=R/da;for(e=0;e0){j(0,0,-n-(g||0));for(d=a;d0){j(0,0,n+(f||0)); -for(d=a+a/2;d<2*a;d++)k.faces.push(new THREE.Face4(2*a+1,(2*d-2*a+2)%a+a,(2*d-2*a+1)%a+a,(2*d-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder; -var Icosahedron=function(a){function c(x,z,y){var B=Math.sqrt(x*x+z*z+y*y);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(x/B,z/B,y/B)))-1}function b(x,z,y,B){B.faces.push(new THREE.Face3(x,z,y))}function d(x,z){var y=f.vertices[x].position,B=f.vertices[z].position;return c((y.x+B.x)/2,(y.y+B.y)/2,(y.z+B.z)/2)}var f=this,g=new THREE.Geometry,j;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0, -1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a0){j(0,0,-n-(g||0));for(e=a;e0){j(0,0,n+(f||0)); +for(e=a+a/2;e<2*a;e++)k.faces.push(new THREE.Face4(2*a+1,(2*e-2*a+2)%a+a,(2*e-2*a+1)%a+a,(2*e-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder; +var Icosahedron=function(a){function c(x,z,y){var B=Math.sqrt(x*x+z*z+y*y);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(x/B,z/B,y/B)))-1}function b(x,z,y,B){B.faces.push(new THREE.Face3(x,z,y))}function e(x,z){var y=f.vertices[x].position,B=f.vertices[z].position;return c((y.x+B.x)/2,(y.y+B.y)/2,(y.z+B.z)/2)}var f=this,g=new THREE.Geometry,j;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0, +1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,z)))-1);n.push(o)}c.push(n)}var y,B,H;f=c.length;for(b=0;b0)for(d=0;d1){y=this.vertices[j].position.clone(); +var Sphere=function(a,c,b){THREE.Geometry.call(this);var e,f=Math.PI,g=Math.max(3,c||8),j=Math.max(2,b||6);c=[];for(b=0;b0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,z)))-1);n.push(o)}c.push(n)}var y,B,H;f=c.length;for(b=0;b0)for(e=0;e1){y=this.vertices[j].position.clone(); B=this.vertices[m].position.clone();H=this.vertices[n].position.clone();y.normalize();B.normalize();H.normalize();this.faces.push(new THREE.Face3(j,m,n,[new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(H.x,H.y,H.z)]));this.faceVertexUvs[0].push([o,x,I])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; -var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(d),(this.radius+this.tube*Math.cos(f))*Math.sin(d),this.tube*Math.sin(f))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b= -1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;f=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,j=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,f,g,j));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[j][0],a[j][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -var TorusKnot=function(a,c,b,d,f,g,j){function k(x,z,y,B,H,I){z=y/B*x;y=Math.cos(z);return new THREE.Vector3(H*(2+y)*0.5*Math.cos(x),H*(2+y)*Math.sin(x)*0.5,I*H*Math.sin(z)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=f||2;this.q=g||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a>7)-127;w|=(C&127)<<16|p<<8;if(w==0&&J==-127)return 0;return(1-2*(G>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,J)}function k(h,t){var w=o(h,t),p=o(h,t+1),C=o(h,t+2);return(o(h,t+3)<<24)+(C<<16)+(p<<8)+w}function m(h,t){var w=o(h,t);return(o(h,t+1)<<8)+w}function n(h,t){var w=o(h,t);return w>127?w-256:w}function o(h, -t){return h.charCodeAt(t)&255}function x(h){var t,w,p;t=k(a,h);w=k(a,h+P);p=k(a,h+ka);h=m(a,h+$);THREE.BinaryLoader.prototype.f3(F,t,w,p,h)}function z(h){var t,w,p,C,G,J;t=k(a,h);w=k(a,h+P);p=k(a,h+ka);C=m(a,h+$);G=k(a,h+e);J=k(a,h+X);h=k(a,h+da);THREE.BinaryLoader.prototype.f3n(F,Q,t,w,p,C,G,J,h)}function y(h){var t,w,p,C;t=k(a,h);w=k(a,h+Y);p=k(a,h+ua);C=k(a,h+va);h=m(a,h+za);THREE.BinaryLoader.prototype.f4(F,t,w,p,C,h)}function B(h){var t,w,p,C,G,J,E,A;t=k(a,h);w=k(a,h+Y);p=k(a,h+ua);C=k(a,h+va); -G=m(a,h+za);J=k(a,h+ma);E=k(a,h+W);A=k(a,h+ia);h=k(a,h+Z);THREE.BinaryLoader.prototype.f4n(F,Q,t,w,p,C,G,J,E,A,h)}function H(h){var t,w;t=k(a,h);w=k(a,h+S);h=k(a,h+N);THREE.BinaryLoader.prototype.uv3(F.faceVertexUvs[0],R[t*2],R[t*2+1],R[w*2],R[w*2+1],R[h*2],R[h*2+1])}function I(h){var t,w,p;t=k(a,h);w=k(a,h+ha);p=k(a,h+ra);h=k(a,h+na);THREE.BinaryLoader.prototype.uv4(F.faceVertexUvs[0],R[t*2],R[t*2+1],R[w*2],R[w*2+1],R[p*2],R[p*2+1],R[h*2],R[h*2+1])}var F=this,M=0,D,Q=[],R=[],P,ka,$,e,X,da,Y,ua,va, -za,ma,W,ia,Z,S,N,ha,ra,na,qa,xa,Da,$a,ab,Ia;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,d,g);D={signature:a.substr(M,8),header_bytes:o(a,M+8),vertex_coordinate_bytes:o(a,M+9),normal_coordinate_bytes:o(a,M+10),uv_coordinate_bytes:o(a,M+11),vertex_index_bytes:o(a,M+12),normal_index_bytes:o(a,M+13),uv_index_bytes:o(a,M+14),material_index_bytes:o(a,M+15),nvertices:k(a,M+16),nnormals:k(a,M+16+4),nuvs:k(a,M+16+8),ntri_flat:k(a,M+16+12),ntri_smooth:k(a,M+16+16),ntri_flat_uv:k(a,M+16+ -20),ntri_smooth_uv:k(a,M+16+24),nquad_flat:k(a,M+16+28),nquad_smooth:k(a,M+16+32),nquad_flat_uv:k(a,M+16+36),nquad_smooth_uv:k(a,M+16+40)};M+=D.header_bytes;P=D.vertex_index_bytes;ka=D.vertex_index_bytes*2;$=D.vertex_index_bytes*3;e=D.vertex_index_bytes*3+D.material_index_bytes;X=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes;da=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*2;Y=D.vertex_index_bytes;ua=D.vertex_index_bytes*2;va=D.vertex_index_bytes*3;za=D.vertex_index_bytes* -4;ma=D.vertex_index_bytes*4+D.material_index_bytes;W=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes;ia=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*2;Z=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*3;S=D.uv_index_bytes;N=D.uv_index_bytes*2;ha=D.uv_index_bytes;ra=D.uv_index_bytes*2;na=D.uv_index_bytes*3;g=D.vertex_index_bytes*3+D.material_index_bytes;Ia=D.vertex_index_bytes*4+D.material_index_bytes;qa=D.ntri_flat*g;xa=D.ntri_smooth*(g+ -D.normal_index_bytes*3);Da=D.ntri_flat_uv*(g+D.uv_index_bytes*3);$a=D.ntri_smooth_uv*(g+D.normal_index_bytes*3+D.uv_index_bytes*3);ab=D.nquad_flat*Ia;g=D.nquad_smooth*(Ia+D.normal_index_bytes*4);Ia=D.nquad_flat_uv*(Ia+D.uv_index_bytes*4);M+=function(h){for(var t,w,p,C=D.vertex_coordinate_bytes*3,G=h+D.nvertices*C;h>7)-127;w|=(C&127)<<16|p<<8;if(w==0&&J==-127)return 0;return(1-2*(G>>7))*(1+w*Math.pow(2,-23))*Math.pow(2,J)}function k(h,t){var w=o(h,t),p=o(h,t+1),C=o(h,t+2);return(o(h,t+3)<<24)+(C<<16)+(p<<8)+w}function m(h,t){var w=o(h,t);return(o(h,t+1)<<8)+w}function n(h,t){var w=o(h,t);return w>127?w-256:w}function o(h, +t){return h.charCodeAt(t)&255}function x(h){var t,w,p;t=k(a,h);w=k(a,h+P);p=k(a,h+ka);h=m(a,h+d);THREE.BinaryLoader.prototype.f3(F,t,w,p,h)}function z(h){var t,w,p,C,G,J;t=k(a,h);w=k(a,h+P);p=k(a,h+ka);C=m(a,h+d);G=k(a,h+fa);J=k(a,h+X);h=k(a,h+ca);THREE.BinaryLoader.prototype.f3n(F,Q,t,w,p,C,G,J,h)}function y(h){var t,w,p,C;t=k(a,h);w=k(a,h+Y);p=k(a,h+ua);C=k(a,h+va);h=m(a,h+za);THREE.BinaryLoader.prototype.f4(F,t,w,p,C,h)}function B(h){var t,w,p,C,G,J,E,A;t=k(a,h);w=k(a,h+Y);p=k(a,h+ua);C=k(a,h+ +va);G=m(a,h+za);J=k(a,h+ma);E=k(a,h+W);A=k(a,h+ia);h=k(a,h+Z);THREE.BinaryLoader.prototype.f4n(F,Q,t,w,p,C,G,J,E,A,h)}function H(h){var t,w;t=k(a,h);w=k(a,h+S);h=k(a,h+N);THREE.BinaryLoader.prototype.uv3(F.faceVertexUvs[0],R[t*2],R[t*2+1],R[w*2],R[w*2+1],R[h*2],R[h*2+1])}function I(h){var t,w,p;t=k(a,h);w=k(a,h+ha);p=k(a,h+ra);h=k(a,h+na);THREE.BinaryLoader.prototype.uv4(F.faceVertexUvs[0],R[t*2],R[t*2+1],R[w*2],R[w*2+1],R[p*2],R[p*2+1],R[h*2],R[h*2+1])}var F=this,M=0,D,Q=[],R=[],P,ka,d,fa,X,ca,Y, +ua,va,za,ma,W,ia,Z,S,N,ha,ra,na,qa,xa,Da,$a,ab,Ia;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,e,g);D={signature:a.substr(M,8),header_bytes:o(a,M+8),vertex_coordinate_bytes:o(a,M+9),normal_coordinate_bytes:o(a,M+10),uv_coordinate_bytes:o(a,M+11),vertex_index_bytes:o(a,M+12),normal_index_bytes:o(a,M+13),uv_index_bytes:o(a,M+14),material_index_bytes:o(a,M+15),nvertices:k(a,M+16),nnormals:k(a,M+16+4),nuvs:k(a,M+16+8),ntri_flat:k(a,M+16+12),ntri_smooth:k(a,M+16+16),ntri_flat_uv:k(a, +M+16+20),ntri_smooth_uv:k(a,M+16+24),nquad_flat:k(a,M+16+28),nquad_smooth:k(a,M+16+32),nquad_flat_uv:k(a,M+16+36),nquad_smooth_uv:k(a,M+16+40)};M+=D.header_bytes;P=D.vertex_index_bytes;ka=D.vertex_index_bytes*2;d=D.vertex_index_bytes*3;fa=D.vertex_index_bytes*3+D.material_index_bytes;X=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes;ca=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*2;Y=D.vertex_index_bytes;ua=D.vertex_index_bytes*2;va=D.vertex_index_bytes*3; +za=D.vertex_index_bytes*4;ma=D.vertex_index_bytes*4+D.material_index_bytes;W=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes;ia=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*2;Z=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*3;S=D.uv_index_bytes;N=D.uv_index_bytes*2;ha=D.uv_index_bytes;ra=D.uv_index_bytes*2;na=D.uv_index_bytes*3;g=D.vertex_index_bytes*3+D.material_index_bytes;Ia=D.vertex_index_bytes*4+D.material_index_bytes;qa=D.ntri_flat* +g;xa=D.ntri_smooth*(g+D.normal_index_bytes*3);Da=D.ntri_flat_uv*(g+D.uv_index_bytes*3);$a=D.ntri_smooth_uv*(g+D.normal_index_bytes*3+D.uv_index_bytes*3);ab=D.nquad_flat*Ia;g=D.nquad_smooth*(Ia+D.normal_index_bytes*4);Ia=D.nquad_flat_uv*(Ia+D.uv_index_bytes*4);M+=function(h){for(var t,w,p,C=D.vertex_coordinate_bytes*3,G=h+D.nvertices*C;h=this.maxCount-3&&k(this)};this.begin= -function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;dthis.size-1&&(m=this.size-1);var z=Math.floor(n-k);z<1&&(z=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var y=Math.floor(o-k);y<1&&(y=1);k=Math.floor(o+k); -k>this.size-1&&(k=this.size-1);for(var B,H,I,F,M,D;x0&&(this.field[I+B]+=F)}}}};this.addPlaneX=function(b,d){var f,g,j,k,m,n=this.size,o=this.yd,x=this.zd,z=this.field,y=n*Math.sqrt(b/d);y>n&&(y=n);for(f=0;f0)for(g=0;go&&(B=o);for(g=0;g0){m=g*x;for(f=0;fsize&&(dist=size);for(j=0;j0){m=zd*j;for(g=0;g= +this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;ethis.size-1&&(m=this.size-1);var z=Math.floor(n-k);z<1&&(z=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var y=Math.floor(o- +k);y<1&&(y=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size-1);for(var B,H,I,F,M,D;x0&&(this.field[I+B]+=F)}}}};this.addPlaneX=function(b,e){var f,g,j,k,m,n=this.size,o=this.yd,x=this.zd,z=this.field,y=n*Math.sqrt(b/e);y>n&&(y=n);for(f=0;f0)for(g=0;go&&(B=o);for(g=0;g0){m=g*x;for(f=0;fsize&&(dist=size);for(j=0;j0){m=zd*j;for(g=0;g 0 || geometry.faceVertexUvs.length > 0 ) { - + geometryGroup.__uvArray = new Float32Array( nvertices * 2 ); } if ( geometry.faceUvs.length > 1 || geometry.faceVertexUvs.length > 1 ) { - + geometryGroup.__uv2Array = new Float32Array( nvertices * 2 ); } @@ -448,46 +447,46 @@ THREE.WebGLRenderer = function ( parameters ) { geometryGroup.__faceArray = new Uint16Array( ntris * 3 + ( object.geometry.edgeFaces ? object.geometry.edgeFaces.length * 2 * 3 : 0 )); geometryGroup.__lineArray = new Uint16Array( nlines * 2 ); - if( geometryGroup.numMorphTargets ) { - + if ( geometryGroup.numMorphTargets ) { + var m, ml; geometryGroup.__morphTargetsArrays = []; - - for( m = 0, ml = geometryGroup.numMorphTargets; m < ml; m++ ) { - + + for ( m = 0, ml = geometryGroup.numMorphTargets; m < ml; m++ ) { + geometryGroup.__morphTargetsArrays.push( new Float32Array( nvertices * 3 ) ); } } - + geometryGroup.__needsSmoothNormals = ( normalType == THREE.SmoothShading ); - + geometryGroup.__uvType = uvType; geometryGroup.__vertexColorType = vertexColorType; geometryGroup.__normalType = normalType; - geometryGroup.__webGLFaceCount = ntris * 3 + ( object.geometry.edgeFaces ? object.geometry.edgeFaces.length * 2 * 3 : 0 ); - geometryGroup.__webGLLineCount = nlines * 2; + geometryGroup.__webglFaceCount = ntris * 3 + ( object.geometry.edgeFaces ? object.geometry.edgeFaces.length * 2 * 3 : 0 ); + geometryGroup.__webglLineCount = nlines * 2; }; function setMeshBuffers ( geometryGroup, object, hint ) { var f, fl, fi, face, - vertexNormals, faceNormal, normal, - vertexColors, faceColor, - vertexTangents, - uvType, vertexColorType, normalType, - uv, uv2, v1, v2, v3, v4, t1, t2, t3, t4, - c1, c2, c3, c4, - sw1, sw2, sw3, sw4, - si1, si2, si3, si4, - sa1, sa2, sa3, sa4, - sb1, sb2, sb3, sb4, - m, ml, i, - vn, uvi, uv2i, - vk, vkl, vka, + vertexNormals, faceNormal, normal, + vertexColors, faceColor, + vertexTangents, + uvType, vertexColorType, normalType, + uv, uv2, v1, v2, v3, v4, t1, t2, t3, t4, + c1, c2, c3, c4, + sw1, sw2, sw3, sw4, + si1, si2, si3, si4, + sa1, sa2, sa3, sa4, + sb1, sb2, sb3, sb4, + m, ml, i, + vn, uvi, uv2i, + vk, vkl, vka, vertexIndex = 0, @@ -520,7 +519,7 @@ THREE.WebGLRenderer = function ( parameters ) { lineArray = geometryGroup.__lineArray, needsSmoothNormals = geometryGroup.__needsSmoothNormals, - + vertexColorType = geometryGroup.__vertexColorType, uvType = geometryGroup.__uvType, normalType = geometryGroup.__normalType, @@ -538,10 +537,10 @@ THREE.WebGLRenderer = function ( parameters ) { vertices = geometry.vertices, chunk_faces = geometryGroup.faces, obj_faces = geometry.faces, - + obj_uvs = geometry.faceVertexUvs[ 0 ], obj_uvs2 = geometry.faceVertexUvs[ 1 ], - + obj_colors = geometry.colors, obj_skinVerticesA = geometry.skinVerticesA, @@ -551,31 +550,30 @@ THREE.WebGLRenderer = function ( parameters ) { obj_edgeFaces = geometry.edgeFaces, morphTargets = geometry.morphTargets; - - for ( f = 0, fl = chunk_faces.length; f < fl; f++ ) { + for ( f = 0, fl = chunk_faces.length; f < fl; f ++ ) { fi = chunk_faces[ f ]; face = obj_faces[ fi ]; - - if( obj_uvs ) { + + if ( obj_uvs ) { uv = obj_uvs[ fi ]; } - - if( obj_uvs2 ) { - + + if ( obj_uvs2 ) { + uv2 = obj_uvs2[ fi ]; } vertexNormals = face.vertexNormals; faceNormal = face.normal; - + vertexColors = face.vertexColors; faceColor = face.color; - + vertexTangents = face.vertexTangents; if ( face instanceof THREE.Face3 ) { @@ -603,31 +601,30 @@ THREE.WebGLRenderer = function ( parameters ) { } if ( dirtyMorphTargets ) { - - for( vk = 0, vkl = morphTargets.length; vk < vkl; vk++ ) { - + + for ( vk = 0, vkl = morphTargets.length; vk < vkl; vk ++ ) { + v1 = morphTargets[ vk ].vertices[ face.a ].position; v2 = morphTargets[ vk ].vertices[ face.b ].position; v3 = morphTargets[ vk ].vertices[ face.c ].position; vka = morphTargetsArrays[ vk ]; - + vka[ offset_morphTarget + 0 ] = v1.x; vka[ offset_morphTarget + 1 ] = v1.y; vka[ offset_morphTarget + 2 ] = v1.z; - + vka[ offset_morphTarget + 3 ] = v2.x; vka[ offset_morphTarget + 4 ] = v2.y; vka[ offset_morphTarget + 5 ] = v2.z; - + vka[ offset_morphTarget + 6 ] = v3.x; vka[ offset_morphTarget + 7 ] = v3.y; vka[ offset_morphTarget + 8 ] = v3.z; - } offset_morphTarget += 9; - + } if ( obj_skinWeights.length ) { @@ -729,7 +726,7 @@ THREE.WebGLRenderer = function ( parameters ) { c3 = vertexColors[ 2 ]; } else { - + c1 = faceColor; c2 = faceColor; c3 = faceColor; @@ -839,7 +836,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - if( dirtyElements ) { + if ( dirtyElements ) { faceArray[ offset_face ] = vertexIndex; faceArray[ offset_face + 1 ] = vertexIndex + 1; @@ -893,36 +890,35 @@ THREE.WebGLRenderer = function ( parameters ) { } if ( dirtyMorphTargets ) { - - for( vk = 0, vkl = morphTargets.length; vk < vkl; vk++ ) { - + + for ( vk = 0, vkl = morphTargets.length; vk < vkl; vk++ ) { + v1 = morphTargets[ vk ].vertices[ face.a ].position; v2 = morphTargets[ vk ].vertices[ face.b ].position; v3 = morphTargets[ vk ].vertices[ face.c ].position; v4 = morphTargets[ vk ].vertices[ face.d ].position; - + vka = morphTargetsArrays[ vk ]; - + vka[ offset_morphTarget + 0 ] = v1.x; vka[ offset_morphTarget + 1 ] = v1.y; vka[ offset_morphTarget + 2 ] = v1.z; - + vka[ offset_morphTarget + 3 ] = v2.x; vka[ offset_morphTarget + 4 ] = v2.y; vka[ offset_morphTarget + 5 ] = v2.z; - + vka[ offset_morphTarget + 6 ] = v3.x; vka[ offset_morphTarget + 7 ] = v3.y; vka[ offset_morphTarget + 8 ] = v3.z; - - vka[ offset_morphTarget + 9 ] = v4.x; + + vka[ offset_morphTarget + 9 ] = v4.x; vka[ offset_morphTarget + 10 ] = v4.y; vka[ offset_morphTarget + 11 ] = v4.z; - } offset_morphTarget += 12; - + } if ( obj_skinWeights.length ) { @@ -1049,7 +1045,7 @@ THREE.WebGLRenderer = function ( parameters ) { c4 = vertexColors[ 3 ]; } else { - + c1 = faceColor; c2 = faceColor; c3 = faceColor; @@ -1173,12 +1169,12 @@ THREE.WebGLRenderer = function ( parameters ) { if ( dirtyElements ) { faceArray[ offset_face ] = vertexIndex; - faceArray[ offset_face + 1 ] = vertexIndex + 1; - faceArray[ offset_face + 2 ] = vertexIndex + 3; + faceArray[ offset_face + 1 ] = vertexIndex + 1; + faceArray[ offset_face + 2 ] = vertexIndex + 3; - faceArray[ offset_face + 3 ] = vertexIndex + 1; - faceArray[ offset_face + 4 ] = vertexIndex + 2; - faceArray[ offset_face + 5 ] = vertexIndex + 3; + faceArray[ offset_face + 3 ] = vertexIndex + 1; + faceArray[ offset_face + 4 ] = vertexIndex + 2; + faceArray[ offset_face + 5 ] = vertexIndex + 3; offset_face += 6; @@ -1204,10 +1200,10 @@ THREE.WebGLRenderer = function ( parameters ) { } - if( obj_edgeFaces ) { - - for( f = 0, fl = obj_edgeFaces.length; f < fl; f++ ) { - + if ( obj_edgeFaces ) { + + for ( f = 0, fl = obj_edgeFaces.length; f < fl; f ++ ) { + faceArray[ offset_face ] = obj_edgeFaces[ f ].a; faceArray[ offset_face + 1 ] = obj_edgeFaces[ f ].b; faceArray[ offset_face + 2 ] = obj_edgeFaces[ f ].c; @@ -1218,85 +1214,83 @@ THREE.WebGLRenderer = function ( parameters ) { offset_face += 6; } - - } + } if ( dirtyVertices ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLVertexBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglVertexBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, vertexArray, hint ); } if ( dirtyMorphTargets ) { - - for( vk = 0, vkl = morphTargets.length; vk < vkl; vk++ ) { - - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLMorphTargetsBuffers[ vk ] ); + + for ( vk = 0, vkl = morphTargets.length; vk < vkl; vk ++ ) { + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglMorphTargetsBuffers[ vk ] ); _gl.bufferData( _gl.ARRAY_BUFFER, morphTargetsArrays[ vk ], hint ); - - } + } } if ( dirtyColors && offset_color > 0 ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLColorBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglColorBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, colorArray, hint ); } if ( dirtyNormals ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLNormalBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglNormalBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, normalArray, hint ); } if ( dirtyTangents && geometry.hasTangents ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLTangentBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglTangentBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, tangentArray, hint ); } if ( dirtyUvs && offset_uv > 0 ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLUVBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglUVBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, uvArray, hint ); } if ( dirtyUvs && offset_uv2 > 0 ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLUV2Buffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglUV2Buffer ); _gl.bufferData( _gl.ARRAY_BUFFER, uv2Array, hint ); } if ( dirtyElements ) { - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webGLFaceBuffer ); + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webglFaceBuffer ); _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, faceArray, hint ); - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webGLLineBuffer ); + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webglLineBuffer ); _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, lineArray, hint ); } if ( offset_skin > 0 ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinVertexABuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglSkinVertexABuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, skinVertexAArray, hint ); - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinVertexBBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglSkinVertexBBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, skinVertexBArray, hint ); - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinIndicesBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglSkinIndicesBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, skinIndexArray, hint ); - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinWeightsBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglSkinWeightsBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, skinWeightArray, hint ); } @@ -1306,16 +1300,16 @@ THREE.WebGLRenderer = function ( parameters ) { function setLineBuffers ( geometry, hint ) { var v, c, vertex, offset, - vertices = geometry.vertices, - colors = geometry.colors, - vl = vertices.length, - cl = colors.length, + vertices = geometry.vertices, + colors = geometry.colors, + vl = vertices.length, + cl = colors.length, - vertexArray = geometry.__vertexArray, - colorArray = geometry.__colorArray, + vertexArray = geometry.__vertexArray, + colorArray = geometry.__colorArray, - dirtyVertices = geometry.__dirtyVertices, - dirtyColors = geometry.__dirtyColors; + dirtyVertices = geometry.__dirtyVertices, + dirtyColors = geometry.__dirtyColors; if ( dirtyVertices ) { @@ -1331,7 +1325,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webGLVertexBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglVertexBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, vertexArray, hint ); } @@ -1350,7 +1344,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webGLColorBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglColorBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, colorArray, hint ); } @@ -1360,16 +1354,16 @@ THREE.WebGLRenderer = function ( parameters ) { function setRibbonBuffers ( geometry, hint ) { var v, c, vertex, offset, - vertices = geometry.vertices, - colors = geometry.colors, - vl = vertices.length, - cl = colors.length, + vertices = geometry.vertices, + colors = geometry.colors, + vl = vertices.length, + cl = colors.length, - vertexArray = geometry.__vertexArray, - colorArray = geometry.__colorArray, + vertexArray = geometry.__vertexArray, + colorArray = geometry.__colorArray, - dirtyVertices = geometry.__dirtyVertices, - dirtyColors = geometry.__dirtyColors; + dirtyVertices = geometry.__dirtyVertices, + dirtyColors = geometry.__dirtyColors; if ( dirtyVertices ) { @@ -1385,7 +1379,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webGLVertexBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglVertexBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, vertexArray, hint ); } @@ -1404,7 +1398,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webGLColorBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglColorBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, colorArray, hint ); } @@ -1414,20 +1408,20 @@ THREE.WebGLRenderer = function ( parameters ) { function setParticleBuffers ( geometry, hint, object ) { var v, c, vertex, offset, - vertices = geometry.vertices, - vl = vertices.length, + vertices = geometry.vertices, + vl = vertices.length, - colors = geometry.colors, - cl = colors.length, + colors = geometry.colors, + cl = colors.length, - vertexArray = geometry.__vertexArray, - colorArray = geometry.__colorArray, + vertexArray = geometry.__vertexArray, + colorArray = geometry.__colorArray, - sortArray = geometry.__sortArray, + sortArray = geometry.__sortArray, - dirtyVertices = geometry.__dirtyVertices, - dirtyElements = geometry.__dirtyElements, - dirtyColors = geometry.__dirtyColors; + dirtyVertices = geometry.__dirtyVertices, + dirtyElements = geometry.__dirtyElements, + dirtyColors = geometry.__dirtyColors; if ( object.sortParticles ) { @@ -1509,14 +1503,14 @@ THREE.WebGLRenderer = function ( parameters ) { if ( dirtyVertices || object.sortParticles ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webGLVertexBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglVertexBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, vertexArray, hint ); } if ( dirtyColors || object.sortParticles ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webGLColorBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglColorBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, colorArray, hint ); } @@ -1533,12 +1527,7 @@ THREE.WebGLRenderer = function ( parameters ) { function refreshUniformsCommon( uniforms, material ) { - // premultiply alpha - uniforms.diffuse.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity ); - - // pure color - //uniforms.color.value.setHex( material.color.hex ); - + uniforms.diffuse.value.setRGB( material.color.r, material.color.g, material.color.b ); uniforms.opacity.value = material.opacity; uniforms.map.texture = material.map; @@ -1552,16 +1541,16 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function refreshUniformsLine ( uniforms, material ) { + function refreshUniformsLine( uniforms, material ) { - uniforms.diffuse.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity ); + uniforms.diffuse.value.setRGB( material.color.r, material.color.g, material.color.b ); uniforms.opacity.value = material.opacity; }; - function refreshUniformsParticle ( uniforms, material ) { + function refreshUniformsParticle( uniforms, material ) { - uniforms.psColor.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity ); + uniforms.psColor.value.setRGB( material.color.r, material.color.g, material.color.b ); uniforms.opacity.value = material.opacity; uniforms.size.value = material.size; uniforms.scale.value = _canvas.height / 2.0; // TODO: Cache this. @@ -1569,7 +1558,7 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function refreshUniformsFog ( uniforms, fog ) { + function refreshUniformsFog( uniforms, fog ) { uniforms.fogColor.value.setHex( fog.color.hex ); @@ -1586,7 +1575,7 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function refreshUniformsPhong ( uniforms, material ) { + function refreshUniformsPhong( uniforms, material ) { //uniforms.ambient.value.setHex( material.ambient.hex ); //uniforms.specular.value.setHex( material.specular.hex ); @@ -1597,7 +1586,7 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function refreshUniformsLights ( uniforms, lights ) { + function refreshUniformsLights( uniforms, lights ) { uniforms.enableLighting.value = lights.directional.length + lights.point.length; uniforms.ambientLightColor.value = lights.ambient; @@ -1655,24 +1644,26 @@ THREE.WebGLRenderer = function ( parameters ) { maxBones = allocateBones( object ); - parameters = { fog: fog, map: material.map, envMap: material.envMap, lightMap: material.lightMap, - vertexColors: material.vertexColors, - sizeAttenuation: material.sizeAttenuation, - skinning: material.skinning, - morphTargets: material.morphTargets, - maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point, - maxBones: maxBones }; + parameters = { + map: material.map, envMap: material.envMap, lightMap: material.lightMap, vertexColors: material.vertexColors, + fog: fog, sizeAttenuation: material.sizeAttenuation, + skinning: material.skinning, + morphTargets: material.morphTargets, + maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point, + maxBones: maxBones + }; material.program = buildProgram( material.fragmentShader, material.vertexShader, parameters ); // load uniforms - identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition', - 'cameraInverseMatrix', 'boneGlobalMatrices', 'morphTargetInfluences' - ]; + identifiers = [ + 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition', + 'cameraInverseMatrix', 'boneGlobalMatrices', 'morphTargetInfluences' + ]; - for( u in material.uniforms ) { + for ( u in material.uniforms ) { identifiers.push(u); @@ -1683,8 +1674,10 @@ THREE.WebGLRenderer = function ( parameters ) { // load attributes - identifiers = [ "position", "normal", "uv", "uv2", "tangent", "color", - "skinVertexA", "skinVertexB", "skinIndex", "skinWeight" ]; + identifiers = [ + "position", "normal", "uv", "uv2", "tangent", "color", + "skinVertexA", "skinVertexB", "skinIndex", "skinWeight" + ]; for ( i = 0; i < this.maxMorphTargets; i++ ) { @@ -1700,14 +1693,13 @@ THREE.WebGLRenderer = function ( parameters ) { cacheAttributeLocations( material.program, identifiers ); - var attributes = material.program.attributes; _gl.enableVertexAttribArray( attributes.position ); - if ( attributes.color >= 0 ) _gl.enableVertexAttribArray( attributes.color ); - if ( attributes.normal >= 0 ) _gl.enableVertexAttribArray( attributes.normal ); - if ( attributes.tangent >= 0 ) _gl.enableVertexAttribArray( attributes.tangent ); + if ( attributes.color >= 0 ) _gl.enableVertexAttribArray( attributes.color ); + if ( attributes.normal >= 0 ) _gl.enableVertexAttribArray( attributes.normal ); + if ( attributes.tangent >= 0 ) _gl.enableVertexAttribArray( attributes.tangent ); if ( material.skinning && attributes.skinVertexA >=0 && attributes.skinVertexB >= 0 && @@ -1724,20 +1716,64 @@ THREE.WebGLRenderer = function ( parameters ) { material.numSupportedMorphTargets = 0; - if( attributes.morphTarget0 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget0 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget1 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget1 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget2 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget2 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget3 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget3 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget4 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget4 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget5 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget5 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget6 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget6 ); material.numSupportedMorphTargets++ } - if( attributes.morphTarget7 >= 0 ) { _gl.enableVertexAttribArray( attributes.morphTarget7 ); material.numSupportedMorphTargets++ } + if ( attributes.morphTarget0 >= 0 ) { + + _gl.enableVertexAttribArray( attributes.morphTarget0 ); + material.numSupportedMorphTargets ++; + + } + + if ( attributes.morphTarget1 >= 0 ) { + + _gl.enableVertexAttribArray( attributes.morphTarget1 ); + material.numSupportedMorphTargets ++; + + } + + if ( attributes.morphTarget2 >= 0 ) { + + _gl.enableVertexAttribArray( attributes.morphTarget2 ); + material.numSupportedMorphTargets ++; + } + + if ( attributes.morphTarget3 >= 0 ) { + + _gl.enableVertexAttribArray( attributes.morphTarget3 ); + material.numSupportedMorphTargets ++; + } + + if ( attributes.morphTarget4 >= 0 ) { + + _gl.enableVertexAttribArray( attributes.morphTarget4 ); + material.numSupportedMorphTargets ++; + + } + + if ( attributes.morphTarget5 >= 0 ) { + + _gl.enableVertexAttribArray( attributes.morphTarget5 ); + material.numSupportedMorphTargets ++; + } + + if ( attributes.morphTarget6 >= 0 ) { + + _gl.enableVertexAttribArray( attributes.morphTarget6 ); + material.numSupportedMorphTargets ++; - object.__webGLMorphTargetInfluences = new Float32Array( this.maxMorphTargets ); + } - for( var i = 0; i < this.maxMorphTargets; i++ ) { + if ( attributes.morphTarget7 >= 0 ) { - object.__webGLMorphTargetInfluences[ i ] = 0; + _gl.enableVertexAttribArray( attributes.morphTarget7 ); + material.numSupportedMorphTargets ++; + + } + + object.__webglMorphTargetInfluences = new Float32Array( this.maxMorphTargets ); + + for ( var i = 0, il = this.maxMorphTargets; i < il; i ++ ) { + + object.__webglMorphTargetInfluences[ i ] = 0; } @@ -1761,10 +1797,10 @@ THREE.WebGLRenderer = function ( parameters ) { p_uniforms = program.uniforms, m_uniforms = material.uniforms; - if( program != _oldProgram ) { + if ( program != _currentProgram ) { _gl.useProgram( program ); - _oldProgram = program; + _currentProgram = program; } @@ -1859,14 +1895,14 @@ THREE.WebGLRenderer = function ( parameters ) { } - if( material instanceof THREE.ShadowVolumeDynamicMaterial ) { - + if ( material instanceof THREE.ShadowVolumeDynamicMaterial ) { + var dirLight = m_uniforms.directionalLightDirection.value; - + dirLight[ 0 ] = -lights.position.x; dirLight[ 1 ] = -lights.position.y; dirLight[ 2 ] = -lights.position.z; - + _gl.uniform3fv( p_uniforms.directionalLightDirection, dirLight ); _gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray ); _gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray ); @@ -1878,7 +1914,7 @@ THREE.WebGLRenderer = function ( parameters ) { loadUniformsSkinning( p_uniforms, object ); } - + return program; }; @@ -1896,21 +1932,21 @@ THREE.WebGLRenderer = function ( parameters ) { // vertices if ( !material.morphTargets ) { - - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLVertexBuffer ); + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglVertexBuffer ); _gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 ); - + } else { - + setupMorphTargets( material, geometryGroup, object ); - + } // colors if ( attributes.color >= 0 ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLColorBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglColorBuffer ); _gl.vertexAttribPointer( attributes.color, 3, _gl.FLOAT, false, 0, 0 ); } @@ -1919,7 +1955,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( attributes.normal >= 0 ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLNormalBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglNormalBuffer ); _gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 ); } @@ -1928,7 +1964,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( attributes.tangent >= 0 ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLTangentBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglTangentBuffer ); _gl.vertexAttribPointer( attributes.tangent, 4, _gl.FLOAT, false, 0, 0 ); } @@ -1937,9 +1973,9 @@ THREE.WebGLRenderer = function ( parameters ) { if ( attributes.uv >= 0 ) { - if ( geometryGroup.__webGLUVBuffer ) { + if ( geometryGroup.__webglUVBuffer ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLUVBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglUVBuffer ); _gl.vertexAttribPointer( attributes.uv, 2, _gl.FLOAT, false, 0, 0 ); _gl.enableVertexAttribArray( attributes.uv ); @@ -1954,9 +1990,9 @@ THREE.WebGLRenderer = function ( parameters ) { if ( attributes.uv2 >= 0 ) { - if ( geometryGroup.__webGLUV2Buffer ) { + if ( geometryGroup.__webglUV2Buffer ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLUV2Buffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglUV2Buffer ); _gl.vertexAttribPointer( attributes.uv2, 2, _gl.FLOAT, false, 0, 0 ); _gl.enableVertexAttribArray( attributes.uv2 ); @@ -1973,16 +2009,16 @@ THREE.WebGLRenderer = function ( parameters ) { attributes.skinVertexA >= 0 && attributes.skinVertexB >= 0 && attributes.skinIndex >= 0 && attributes.skinWeight >= 0 ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinVertexABuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglSkinVertexABuffer ); _gl.vertexAttribPointer( attributes.skinVertexA, 4, _gl.FLOAT, false, 0, 0 ); - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinVertexBBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglSkinVertexBBuffer ); _gl.vertexAttribPointer( attributes.skinVertexB, 4, _gl.FLOAT, false, 0, 0 ); - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinIndicesBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglSkinIndicesBuffer ); _gl.vertexAttribPointer( attributes.skinIndex, 4, _gl.FLOAT, false, 0, 0 ); - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinWeightsBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglSkinWeightsBuffer ); _gl.vertexAttribPointer( attributes.skinWeight, 4, _gl.FLOAT, false, 0, 0 ); } @@ -1996,15 +2032,16 @@ THREE.WebGLRenderer = function ( parameters ) { if ( material.wireframe ) { _gl.lineWidth( material.wireframeLinewidth ); - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webGLLineBuffer ); - _gl.drawElements( _gl.LINES, geometryGroup.__webGLLineCount, _gl.UNSIGNED_SHORT, 0 ); + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webglLineBuffer ); + _gl.drawElements( _gl.LINES, geometryGroup.__webglLineCount, _gl.UNSIGNED_SHORT, 0 ); // triangles } else { - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webGLFaceBuffer ); - _gl.drawElements( _gl.TRIANGLES, geometryGroup.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 ); + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webglFaceBuffer ); + _gl.drawElements( _gl.TRIANGLES, geometryGroup.__webglFaceCount, _gl.UNSIGNED_SHORT, 0 ); + } // render lines @@ -2014,19 +2051,19 @@ THREE.WebGLRenderer = function ( parameters ) { primitives = ( object.type == THREE.LineStrip ) ? _gl.LINE_STRIP : _gl.LINES; _gl.lineWidth( material.linewidth ); - _gl.drawArrays( primitives, 0, geometryGroup.__webGLLineCount ); + _gl.drawArrays( primitives, 0, geometryGroup.__webglLineCount ); // render particles } else if ( object instanceof THREE.ParticleSystem ) { - _gl.drawArrays( _gl.POINTS, 0, geometryGroup.__webGLParticleCount ); + _gl.drawArrays( _gl.POINTS, 0, geometryGroup.__webglParticleCount ); // render ribbon } else if ( object instanceof THREE.Ribbon ) { - _gl.drawArrays( _gl.TRIANGLE_STRIP, 0, geometryGroup.__webGLVertexCount ); + _gl.drawArrays( _gl.TRIANGLE_STRIP, 0, geometryGroup.__webglVertexCount ); } @@ -2034,102 +2071,94 @@ THREE.WebGLRenderer = function ( parameters ) { function setupMorphTargets( material, geometryGroup, object ) { - + // set base - + var attributes = material.program.attributes; - + if( object.morphTargetBase !== -1 ) { - - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLMorphTargetsBuffers[ object.morphTargetBase ] ); + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglMorphTargetsBuffers[ object.morphTargetBase ] ); _gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 ); - + } else { - - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLVertexBuffer ); + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglVertexBuffer ); _gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 ); - + } - - + if( object.morphTargetForcedOrder.length ) { // set forced order - + var m = 0; var order = object.morphTargetForcedOrder; var influences = object.morphTargetInfluences; - - while( m < material.numSupportedMorphTargets && m < order.length ) { - - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLMorphTargetsBuffers[ order[ m ] ] ); + + while ( m < material.numSupportedMorphTargets && m < order.length ) { + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglMorphTargetsBuffers[ order[ m ] ] ); _gl.vertexAttribPointer( attributes[ "morphTarget" + m ], 3, _gl.FLOAT, false, 0, 0 ); - - object.__webGLMorphTargetInfluences[ m ] = influences[ order[ m ]]; - m++; + object.__webglMorphTargetInfluences[ m ] = influences[ order[ m ]]; + + m ++; + } - } - } else { - + // find most influencing - + var used = []; - var candidateInfluence = -1; + var candidateInfluence = - 1; var candidate = 0; var influences = object.morphTargetInfluences; var i, il = influences.length; var m = 0; - - if( object.morphTargetBase !== -1 ) { - + + if ( object.morphTargetBase !== -1 ) { + used[ object.morphTargetBase ] = true; - + } - - while( m < material.numSupportedMorphTargets ) { - - for( i = 0; i < il; i++ ) { - - if( !used[ i ] && influences[ i ] > candidateInfluence ) { - + + while ( m < material.numSupportedMorphTargets ) { + + for ( i = 0; i < il; i++ ) { + + if ( !used[ i ] && influences[ i ] > candidateInfluence ) { + candidate = i; candidateInfluence = influences[ candidate ]; - } - } - - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLMorphTargetsBuffers[ candidate ] ); + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglMorphTargetsBuffers[ candidate ] ); _gl.vertexAttribPointer( attributes[ "morphTarget" + m ], 3, _gl.FLOAT, false, 0, 0 ); - - object.__webGLMorphTargetInfluences[ m ] = candidateInfluence; - + + object.__webglMorphTargetInfluences[ m ] = candidateInfluence; + used[ candidate ] = 1; candidateInfluence = -1; - m++; - + m ++; } - } - // load updated influences uniform - - _gl.uniform1fv( material.program.uniforms.morphTargetInfluences, object.__webGLMorphTargetInfluences ); + _gl.uniform1fv( material.program.uniforms.morphTargetInfluences, object.__webglMorphTargetInfluences ); } function renderBufferImmediate ( object, program ) { - if ( ! object.__webGLVertexBuffer ) object.__webGLVertexBuffer = _gl.createBuffer(); - if ( ! object.__webGLNormalBuffer ) object.__webGLNormalBuffer = _gl.createBuffer(); + if ( ! object.__webglVertexBuffer ) object.__webglVertexBuffer = _gl.createBuffer(); + if ( ! object.__webglNormalBuffer ) object.__webglNormalBuffer = _gl.createBuffer(); if ( object.hasPos ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLVertexBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webglVertexBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, object.positionArray, _gl.DYNAMIC_DRAW ); _gl.enableVertexAttribArray( program.attributes.position ); _gl.vertexAttribPointer( program.attributes.position, 3, _gl.FLOAT, false, 0, 0 ); @@ -2138,7 +2167,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( object.hasNormal ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webGLNormalBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, object.__webglNormalBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, object.normalArray, _gl.DYNAMIC_DRAW ); _gl.enableVertexAttribArray( program.attributes.normal ); _gl.vertexAttribPointer( program.attributes.normal, 3, _gl.FLOAT, false, 0, 0 ); @@ -2358,7 +2387,6 @@ THREE.WebGLRenderer = function ( parameters ) { this.clear(); } - // set matrices @@ -2557,67 +2585,61 @@ THREE.WebGLRenderer = function ( parameters ) { // supposed to do stencil shadows but is much faster // - if( scene.__webglShadowVolumes.length && scene.lights.length ) { - + if ( scene.__webglShadowVolumes.length && scene.lights.length ) { + // setup stencil - + _gl.enable( _gl.POLYGON_OFFSET_FILL ); _gl.polygonOffset( 0.1, 1.0 ); _gl.enable( _gl.STENCIL_TEST ); _gl.depthMask( false ); _gl.colorMask( false, false, false, false ); - + _gl.stencilFunc( _gl.ALWAYS, 1, 0xFF ); _gl.stencilOpSeparate( _gl.BACK, _gl.KEEP, _gl.INCR, _gl.KEEP ); _gl.stencilOpSeparate( _gl.FRONT, _gl.KEEP, _gl.DECR, _gl.KEEP ); - - - + + // loop through all directional lights - - var l, ll = scene.lights.length; - var p; - var light, geometryGroup; - var dirLight = []; - var program; - var p_uniforms; - var m_uniforms; - var attributes; - + + var l, ll = scene.lights.length, + p, light, geometryGroup, dirLight = [], + program, p_uniforms, m_uniforms, + attributes; + ol = scene.__webglShadowVolumes.length; - - for( l = 0; l < ll; l++ ) { - + + for ( l = 0; l < ll; l++ ) { + light = scene.lights[ l ]; - - if( light instanceof THREE.DirectionalLight ) { + + if ( light instanceof THREE.DirectionalLight ) { dirLight[ 0 ] = -light.position.x; dirLight[ 1 ] = -light.position.y; dirLight[ 2 ] = -light.position.z; - // render all volumes - + for ( o = 0; o < ol; o++ ) { - + object = scene.__webglShadowVolumes[ o ].object; geometryGroup = scene.__webglShadowVolumes[ o ].buffer; material = object.materials[ 0 ]; if ( !material.program ) _this.initMaterial( material, lights, fog, object ); - + program = material.program, p_uniforms = program.uniforms, - m_uniforms = material.uniforms, - attributes = program.attributes; + m_uniforms = material.uniforms, + attributes = program.attributes; + + if ( _currentProgram !== program ) { - if( _oldProgram !== program ) { - _gl.useProgram( program ); - _oldProgram = program; + _currentProgram = program; _gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, _projectionMatrixArray ); _gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray ); @@ -2631,61 +2653,58 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray ); //_gl.uniformMatrix4fv( p_uniforms.modelViewMatrix, false, object._modelViewMatrixArray ); - - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLVertexBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglVertexBuffer ); _gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 ); - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLNormalBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webglNormalBuffer ); _gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 ); - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webGLFaceBuffer ); + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webglFaceBuffer ); _gl.cullFace( _gl.FRONT ); - _gl.drawElements( _gl.TRIANGLES, geometryGroup.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 ); + _gl.drawElements( _gl.TRIANGLES, geometryGroup.__webglFaceCount, _gl.UNSIGNED_SHORT, 0 ); _gl.cullFace( _gl.BACK ); - _gl.drawElements( _gl.TRIANGLES, geometryGroup.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 ); - + _gl.drawElements( _gl.TRIANGLES, geometryGroup.__webglFaceCount, _gl.UNSIGNED_SHORT, 0 ); + } - + } - + } - - - // draw darkening polygon - + + // draw darkening polygon + _gl.disable( _gl.POLYGON_OFFSET_FILL ); _gl.colorMask( true, true, true, true ); _gl.stencilFunc( _gl.NOTEQUAL, 0, 0xFF ); _gl.stencilOp( _gl.KEEP, _gl.KEEP, _gl.KEEP ); - _gl.disable( _gl.DEPTH_TEST ); - + _gl.disable( _gl.DEPTH_TEST ); + _gl.enable( _gl.BLEND ); _gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA ); _gl.blendEquation( _gl.FUNC_ADD ); - - + _oldBlending = ""; - _oldProgram = _shadow.program; - + _currentProgram = _shadow.program; + _gl.useProgram( _shadow.program ); _gl.uniformMatrix4fv( _shadow.projectionLocation, false, _projectionMatrixArray ); - + _gl.bindBuffer( _gl.ARRAY_BUFFER, _shadow.vertexBuffer ); _gl.vertexAttribPointer( _shadow.vertexLocation, 3, _gl.FLOAT, false, 0, 0 ); _gl.enableVertexAttribArray( _shadow.vertexLocation ); - + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _shadow.elementBuffer ); _gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 ); - - + // disable stencil - - _gl.disable ( _gl.STENCIL_TEST ); - _gl.enable ( _gl.DEPTH_TEST ); - _gl.disable ( _gl.BLEND ); - _gl.depthMask( true ); + + _gl.disable( _gl.STENCIL_TEST ); + _gl.enable( _gl.DEPTH_TEST ); + _gl.disable( _gl.BLEND ); + _gl.depthMask( true ); + } @@ -2739,13 +2758,13 @@ THREE.WebGLRenderer = function ( parameters ) { updateObject( scene.__webglObjects[ o ].object, scene ); } - + for ( var o = 0, ol = scene.__webglShadowVolumes.length; o < ol; o ++ ) { updateObject( scene.__webglShadowVolumes[ o ].object, scene ); } - + }; @@ -2783,7 +2802,7 @@ THREE.WebGLRenderer = function ( parameters ) { // initialise VBO on the first access - if ( ! geometryGroup.__webGLVertexBuffer ) { + if ( ! geometryGroup.__webglVertexBuffer ) { createMeshBuffers( geometryGroup ); initMeshBuffers( geometryGroup, object ); @@ -2800,22 +2819,23 @@ THREE.WebGLRenderer = function ( parameters ) { // create separate wrapper per each use of VBO - if( object instanceof THREE.ShadowVolume ) { - + if ( object instanceof THREE.ShadowVolume ) { + addBuffer( scene.__webglShadowVolumes, geometryGroup, object ); - + } else { - + addBuffer( scene.__webglObjects, geometryGroup, object ); - + } + } } else if ( object instanceof THREE.Ribbon ) { geometry = object.geometry; - if( ! geometry.__webGLVertexBuffer ) { + if( ! geometry.__webglVertexBuffer ) { createRibbonBuffers( geometry ); initRibbonBuffers( geometry ); @@ -2831,7 +2851,7 @@ THREE.WebGLRenderer = function ( parameters ) { geometry = object.geometry; - if( ! geometry.__webGLVertexBuffer ) { + if( ! geometry.__webglVertexBuffer ) { createLineBuffers( geometry ); initLineBuffers( geometry ); @@ -2847,7 +2867,7 @@ THREE.WebGLRenderer = function ( parameters ) { geometry = object.geometry; - if ( ! geometry.__webGLVertexBuffer ) { + if ( ! geometry.__webglVertexBuffer ) { createParticleBuffers( geometry ); initParticleBuffers( geometry ); @@ -3140,15 +3160,19 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.enable( _gl.CULL_FACE ); _gl.enable( _gl.BLEND ); - _gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA ); + _gl.blendEquation( _gl.FUNC_ADD ); + _gl.blendFunc( _gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA ); + _gl.clearColor( clearColor.r, clearColor.g, clearColor.b, clearAlpha ); + // _gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, true ); + _cullEnabled = true; }; function buildProgram ( fragmentShader, vertexShader, parameters ) { - + var program = _gl.createProgram(), prefix_fragment = [ @@ -3203,8 +3227,15 @@ THREE.WebGLRenderer = function ( parameters ) { "attribute vec3 normal;", "attribute vec2 uv;", "attribute vec2 uv2;", + + "#ifdef USE_COLOR", + "attribute vec3 color;", + + "#endif", + "#ifdef USE_MORPHTARGETS", + "attribute vec3 morphTarget0;", "attribute vec3 morphTarget1;", "attribute vec3 morphTarget2;", @@ -3213,18 +3244,18 @@ THREE.WebGLRenderer = function ( parameters ) { "attribute vec3 morphTarget5;", "attribute vec3 morphTarget6;", "attribute vec3 morphTarget7;", - "#endif", - - "#ifdef USE_COLOR", - "attribute vec3 color;", + "#endif", "#ifdef USE_SKINNING", + "attribute vec4 skinVertexA;", "attribute vec4 skinVertexB;", "attribute vec4 skinIndex;", "attribute vec4 skinWeight;", + "#endif", + "" ].join("\n"); @@ -3255,7 +3286,7 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.uniformMatrix4fv( uniforms.boneGlobalMatrices, false, object.boneMatrices ); }; - + function loadUniformsMatrices ( uniforms, object ) { @@ -3345,30 +3376,26 @@ THREE.WebGLRenderer = function ( parameters ) { case THREE.SubtractiveBlending: - //_gl.blendEquation( _gl.FUNC_SUBTRACT ); - _gl.blendFunc( _gl.DST_COLOR, _gl.ZERO ); + // TODO: Find blendFuncSeparate() combination + + _gl.blendEquation( _gl.FUNC_ADD ); + _gl.blendFunc( _gl.ZERO, _gl.ONE_MINUS_SRC_COLOR ); break; - /* - case THREE.BillboardBlending: + case THREE.MultiplyBlending: + + // TODO: Find blendFuncSeparate() combination _gl.blendEquation( _gl.FUNC_ADD ); - _gl.blendFunc( _gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA); + _gl.blendFunc( _gl.ZERO, _gl.SRC_COLOR ); break; - */ - - case THREE.ReverseSubtractiveBlending: - _gl.blendEquation( _gl.FUNC_REVERSE_SUBTRACT ); - _gl.blendFunc( _gl.ONE, _gl.ONE ); - - break; default: - _gl.blendEquation( _gl.FUNC_ADD ); - _gl.blendFunc( _gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA ); + _gl.blendEquationSeparate( _gl.FUNC_ADD, _gl.FUNC_ADD ); + _gl.blendFuncSeparate( _gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA, _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA ); break; @@ -3396,43 +3423,43 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE ); _gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE ); - + _gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) ); _gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) ); } }; - + function setTexture ( texture, slot ) { if ( texture.needsUpdate ) { - if ( !texture.__wasSetOnce ) { + if ( !texture.__webglInit ) { - texture.__webGLTexture = _gl.createTexture(); + texture.__webglTexture = _gl.createTexture(); - _gl.bindTexture( _gl.TEXTURE_2D, texture.__webGLTexture ); + _gl.bindTexture( _gl.TEXTURE_2D, texture.__webglTexture ); _gl.texImage2D( _gl.TEXTURE_2D, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image ); - texture.__wasSetOnce = true; + texture.__webglInit = true; } else { - _gl.bindTexture( _gl.TEXTURE_2D, texture.__webGLTexture ); + _gl.bindTexture( _gl.TEXTURE_2D, texture.__webglTexture ); _gl.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image ); } setTextureParameters( _gl.TEXTURE_2D, texture, texture.image ); _gl.bindTexture( _gl.TEXTURE_2D, null ); - + texture.needsUpdate = false; } _gl.activeTexture( _gl.TEXTURE0 + slot ); - _gl.bindTexture( _gl.TEXTURE_2D, texture.__webGLTexture ); + _gl.bindTexture( _gl.TEXTURE_2D, texture.__webglTexture ); }; @@ -3441,24 +3468,24 @@ THREE.WebGLRenderer = function ( parameters ) { if ( texture.image.length == 6 ) { if ( texture.needsUpdate ) { - - if ( !texture.__wasSetOnce ) { - texture.image.__webGLTextureCube = _gl.createTexture(); + if ( !texture.__webglInit ) { + + texture.image.__webglTextureCube = _gl.createTexture(); - _gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webGLTextureCube ); + _gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webglTextureCube ); for ( var i = 0; i < 6; ++i ) { _gl.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image[ i ] ); } - - texture.__wasSetOnce = true; + + texture.__webglInit = true; } else { - _gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webGLTextureCube ); + _gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webglTextureCube ); for ( var i = 0; i < 6; ++i ) { @@ -3472,11 +3499,11 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.bindTexture( _gl.TEXTURE_CUBE_MAP, null ); texture.needsUpdate = false; - + } _gl.activeTexture( _gl.TEXTURE0 + slot ); - _gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webGLTextureCube ); + _gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webglTextureCube ); } @@ -3484,20 +3511,20 @@ THREE.WebGLRenderer = function ( parameters ) { function setRenderTarget ( renderTexture ) { - if ( renderTexture && !renderTexture.__webGLFramebuffer ) { + if ( renderTexture && !renderTexture.__webglFramebuffer ) { - renderTexture.__webGLFramebuffer = _gl.createFramebuffer(); - renderTexture.__webGLRenderbuffer = _gl.createRenderbuffer(); - renderTexture.__webGLTexture = _gl.createTexture(); + renderTexture.__webglFramebuffer = _gl.createFramebuffer(); + renderTexture.__webglRenderbuffer = _gl.createRenderbuffer(); + renderTexture.__webglTexture = _gl.createTexture(); // Setup renderbuffer - _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTexture.__webGLRenderbuffer ); + _gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer ); _gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_COMPONENT16, renderTexture.width, renderTexture.height ); // Setup texture - _gl.bindTexture( _gl.TEXTURE_2D, renderTexture.__webGLTexture ); + _gl.bindTexture( _gl.TEXTURE_2D, renderTexture.__webglTexture ); _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, paramThreeToGL( renderTexture.wrapS ) ); _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, paramThreeToGL( renderTexture.wrapT ) ); _gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, paramThreeToGL( renderTexture.magFilter ) ); @@ -3506,9 +3533,9 @@ THREE.WebGLRenderer = function ( parameters ) { // Setup framebuffer - _gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTexture.__webGLFramebuffer ); - _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, renderTexture.__webGLTexture, 0 ); - _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webGLRenderbuffer ); + _gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTexture.__webglFramebuffer ); + _gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, renderTexture.__webglTexture, 0 ); + _gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer ); // Release everything @@ -3522,7 +3549,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( renderTexture ) { - framebuffer = renderTexture.__webGLFramebuffer; + framebuffer = renderTexture.__webglFramebuffer; width = renderTexture.width; height = renderTexture.height; @@ -3534,12 +3561,12 @@ THREE.WebGLRenderer = function ( parameters ) { } - if( framebuffer != _oldFramebuffer ) { + if( framebuffer != _currentFramebuffer ) { _gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer ); _gl.viewport( _viewportX, _viewportY, width, height ); - _oldFramebuffer = framebuffer; + _currentFramebuffer = framebuffer; } @@ -3547,7 +3574,7 @@ THREE.WebGLRenderer = function ( parameters ) { function updateRenderTargetMipmap ( renderTarget ) { - _gl.bindTexture( _gl.TEXTURE_2D, renderTarget.__webGLTexture ); + _gl.bindTexture( _gl.TEXTURE_2D, renderTarget.__webglTexture ); _gl.generateMipmap( _gl.TEXTURE_2D ); _gl.bindTexture( _gl.TEXTURE_2D, null ); @@ -3754,47 +3781,47 @@ THREE.WebGLRenderer = function ( parameters ) { } } - + return materials; }; - + function bufferGuessVertexColorType ( materials, geometryGroup, object ) { - + var i, m, ml = materials.length; - + // use vertexColor type from the first material in unrolled materials - + for ( i = 0; i < ml; i++ ) { - + m = materials[ i ]; - + if ( m.vertexColors ) { - + return m.vertexColors; } - + } - + return false; - + }; function bufferGuessNormalType ( materials, geometryGroup, object ) { - + var i, m, ml = materials.length; - + // only MeshBasicMaterial and MeshDepthMaterial don't need normals - + for ( i = 0; i < ml; i++ ) { - + m = materials[ i ]; - + if ( ( m instanceof THREE.MeshBasicMaterial && !m.envMap ) || m instanceof THREE.MeshDepthMaterial ) continue; - + if ( materialNeedsSmoothNormals( m ) ) { - + return THREE.SmoothShading; } else { @@ -3804,35 +3831,35 @@ THREE.WebGLRenderer = function ( parameters ) { } } - + return false; - + }; function bufferGuessUVType ( materials, geometryGroup, object ) { - + var i, m, ml = materials.length; - + // material must use some texture to require uvs - + for ( i = 0; i < ml; i++ ) { - + m = materials[ i ]; - + if ( m.map || m.lightMap || m instanceof THREE.MeshShaderMaterial ) { - + return true; - + } - + } - + return false; - + }; - + function allocateBones ( object ) { - + // default for when object is not specified // ( for example when prebuilding shader // to be used with multiple objects ) -- GitLab