From c3d29f491b24cdacd22fcd6719fce73fbb1bd41b Mon Sep 17 00:00:00 2001 From: alteredq Date: Sun, 6 Mar 2011 19:54:31 +0100 Subject: [PATCH] More cleanup of WebGLRenderer. --- build/Three.js | 372 ++++++++++++++++----------------- build/custom/ThreeWebGL.js | 44 ++-- src/renderers/WebGLRenderer.js | 26 +-- 3 files changed, 222 insertions(+), 220 deletions(-) diff --git a/build/Three.js b/build/Three.js index 3774aac1..4c4601b0 100755 --- a/build/Three.js +++ b/build/Three.js @@ -12,21 +12,21 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit 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* 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,e=[];a=0;for(c=d.length;a0&&E>0&&L+E<1}var b,d,e,g,h,j,k,n,p,w, -t,q=a.geometry,x=q.vertices,B=[];b=0;for(d=q.faces.length;bk?d:k;e=e>n?e:n}a()}; -this.add3Points=function(k,n,p,w,t,q){if(j){j=!1;c=kp?k>t?k:t:p>t?p:t;e=n>w?n>q?n:q:w>q?w:q}else{c=kp?k>t?k>d?k:d:t>d?t:d:p>t?p>d?p:d:t>d?t:d;e=n>w?n>q?n>e?n:e:q>e?q:e:w>q?w>e?w:e:q>e?q:e}a()};this.addRectangle=function(k){if(j){j=!1;c=k.getLeft();b=k.getTop();d=k.getRight();e=k.getBottom()}else{c=ck.getRight()? +THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,e=[];a=0;for(c=d.length;a0&&E>0&&K+E<1}var b,d,e,g,h,j,k,n,q,x, +u,t=a.geometry,y=t.vertices,A=[];b=0;for(d=t.faces.length;bk?d:k;e=e>n?e:n}a()}; +this.add3Points=function(k,n,q,x,u,t){if(j){j=!1;c=kq?k>u?k:u:q>u?q:u;e=n>x?n>t?n:t:x>t?x:t}else{c=kq?k>u?k>d?k:d:u>d?u:d:q>u?q>d?q:d:u>d?u:d;e=n>x?n>t?n>e?n:e:t>e?t:e:x>t?x>e?x:e:t>e?t:e}a()};this.addRectangle=function(k){if(j){j=!1;c=k.getLeft();b=k.getTop();d=k.getRight();e=k.getBottom()}else{c=ck.getRight()? d:k.getRight();e=e>k.getBottom()?e:k.getBottom()}a()};this.inflate=function(k){c-=k;b-=k;d+=k;e+=k;a()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();b=b>k.getTop()?b:k.getTop();d=d=0&&Math.min(e,k.getBottom())-Math.max(b,k.getTop())>=0};this.empty=function(){j=!0;e=d=b=c=0;a()};this.isEmpty=function(){return j}}; 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,e,g,h,j,k,n,p,w,t,q,x,B){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,j||0,k||0,n||0,p||1,w||0,t||0,q||0,x||0,B||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,j,k,n,p,w,t,q,x,B){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=j;this.n31=k;this.n32=n;this.n33=p;this.n34=w;this.n41=t;this.n42=q;this.n43=x;this.n44=B;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, +THREE.Matrix4=function(a,c,b,d,e,g,h,j,k,n,q,x,u,t,y,A){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,j||0,k||0,n||0,q||1,x||0,u||0,t||0,y||0,A||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,j,k,n,q,x,u,t,y,A){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=j;this.n31=k;this.n32=n;this.n33=q;this.n34=x;this.n41=u;this.n42=t;this.n43=y;this.n44=A;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, e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();d.cross(b,g).normalize();e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,e=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)*e;a.y=(this.n21*c+this.n22*b+this.n23*d+this.n24)*e;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*e;return a}, multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,e=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*e;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*e;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*e;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*e;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,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,n=a.n24,p=a.n31,w=a.n32,t=a.n33,q=a.n34,x=a.n41,B=a.n42,E=a.n43,u=a.n44,F=c.n11,v=c.n12,N=c.n13,L=c.n14,Y=c.n21,M=c.n22,f=c.n23,V=c.n24,S=c.n31,ba=c.n32,ea=c.n33,J=c.n34;this.n11=b*F+d*Y+e*S;this.n12= -b*v+d*M+e*ba;this.n13=b*N+d*f+e*ea;this.n14=b*L+d*V+e*J+g;this.n21=h*F+j*Y+k*S;this.n22=h*v+j*M+k*ba;this.n23=h*N+j*f+k*ea;this.n24=h*L+j*V+k*J+n;this.n31=p*F+w*Y+t*S;this.n32=p*v+w*M+t*ba;this.n33=p*N+w*f+t*ea;this.n34=p*L+w*V+t*J+q;this.n41=x*F+B*Y+E*S;this.n42=x*v+B*M+E*ba;this.n43=x*N+B*f+E*ea;this.n44=x*L+B*V+E*J+u;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.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,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,n=a.n24,q=a.n31,x=a.n32,u=a.n33,t=a.n34,y=a.n41,A=a.n42,E=a.n43,v=a.n44,F=c.n11,w=c.n12,O=c.n13,K=c.n14,Z=c.n21,M=c.n22,f=c.n23,V=c.n24,T=c.n31,ca=c.n32,ea=c.n33,H=c.n34;this.n11=b*F+d*Z+e*T;this.n12= +b*w+d*M+e*ca;this.n13=b*O+d*f+e*ea;this.n14=b*K+d*V+e*H+g;this.n21=h*F+j*Z+k*T;this.n22=h*w+j*M+k*ca;this.n23=h*O+j*f+k*ea;this.n24=h*K+j*V+k*H+n;this.n31=q*F+x*Z+u*T;this.n32=q*w+x*M+u*ca;this.n33=q*O+x*f+u*ea;this.n34=q*K+x*V+u*H+t;this.n41=y*F+A*Z+E*T;this.n42=y*w+A*M+E*ca;this.n43=y*O+A*f+E*ea;this.n44=y*K+A*V+E*H+v;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,e=this.n21,g= -this.n22,h=this.n23,j=this.n24,k=this.n31,n=this.n32,p=this.n33,w=this.n34,t=this.n41,q=this.n42,x=this.n43,B=this.n44;return d*h*n*t-b*j*n*t-d*g*p*t+c*j*p*t+b*g*w*t-c*h*w*t-d*h*k*q+b*j*k*q+d*e*p*q-a*j*p*q-b*e*w*q+a*h*w*q+d*g*k*x-c*j*k*x-d*e*n*x+a*j*n*x+c*e*w*x-a*g*w*x-b*g*k*B+c*h*k*B+b*e*n*B-a*h*n*B-c*e*p*B+a*g*p*B},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= +this.n22,h=this.n23,j=this.n24,k=this.n31,n=this.n32,q=this.n33,x=this.n34,u=this.n41,t=this.n42,y=this.n43,A=this.n44;return d*h*n*u-b*j*n*u-d*g*q*u+c*j*q*u+b*g*x*u-c*h*x*u-d*h*k*t+b*j*k*t+d*e*q*t-a*j*q*t-b*e*x*t+a*h*x*t+d*g*k*y-c*j*k*y-d*e*n*y+a*j*n*y+c*e*x*y-a*g*x*y-b*g*k*A+c*h*k*A+b*e*n*A-a*h*n*A-c*e*q*A+a*g*q*A},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}, @@ -34,9 +34,9 @@ setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a n*j+d*g,e*j*j+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 e=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,j=c*b;this.n11=e*g;this.n12=-e*d;this.n13=b;this.n21=j*g+a*d;this.n22=-j*d+a*g;this.n23=-c*e;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,e=a.w,g=c+c,h= b+b,j=d+d;a=c*g;var k=c*h;c*=j;var n=b*h;b*=j;d*=j;g*=e;h*=e;e*=j;this.n11=1-(n+d);this.n12=k-e;this.n13=c+h;this.n21=k+e;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;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,e=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*e;this.n23=a.n23*e;this.n33=a.n33*e}}; -THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,n=a.n24,p=a.n31,w=a.n32,t=a.n33,q=a.n34,x=a.n41,B=a.n42,E=a.n43,u=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=k*q*B-n*t*B+n*w*E-j*q*E-k*w*u+j*t*u;c.n12=g*t*B-e*q*B-g*w*E+d*q*E+e*w*u-d*t*u;c.n13=e*n*B-g*k*B+g*j*E-d*n*E-e*j*u+d*k*u;c.n14=g*k*w-e*n*w-g*j*t+d*n*t+e*j*q-d*k*q;c.n21=n*t*x-k*q*x-n*p*E+h*q*E+k*p*u-h*t*u;c.n22=e*q*x-g*t*x+g*p*E-b*q*E-e*p*u+b*t*u;c.n23=g*k*x-e*n*x-g*h*E+b*n*E+e*h*u-b*k*u; -c.n24=e*n*p-g*k*p+g*h*t-b*n*t-e*h*q+b*k*q;c.n31=j*q*x-n*w*x+n*p*B-h*q*B-j*p*u+h*w*u;c.n32=g*w*x-d*q*x-g*p*B+b*q*B+d*p*u-b*w*u;c.n33=e*n*x-g*j*x+g*h*B-b*n*B-d*h*u+b*j*u;c.n34=g*j*p-d*n*p-g*h*w+b*n*w+d*h*q-b*j*q;c.n41=k*w*x-j*t*x-k*p*B+h*t*B+j*p*E-h*w*E;c.n42=d*t*x-e*w*x+e*p*B-b*t*B-d*p*E+b*w*E;c.n43=e*j*x-d*k*x-e*h*B+b*k*B+d*h*E-b*j*E;c.n44=d*k*p-e*j*p+e*h*w-b*k*w-d*h*t+b*j*t;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,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*e;b[2]=a*g;b[3]=a*h;b[4]=a*j;b[5]=a*k;b[6]=a*n;b[7]=a*p;b[8]=a*w;return c}; +THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,n=a.n24,q=a.n31,x=a.n32,u=a.n33,t=a.n34,y=a.n41,A=a.n42,E=a.n43,v=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=k*t*A-n*u*A+n*x*E-j*t*E-k*x*v+j*u*v;c.n12=g*u*A-e*t*A-g*x*E+d*t*E+e*x*v-d*u*v;c.n13=e*n*A-g*k*A+g*j*E-d*n*E-e*j*v+d*k*v;c.n14=g*k*x-e*n*x-g*j*u+d*n*u+e*j*t-d*k*t;c.n21=n*u*y-k*t*y-n*q*E+h*t*E+k*q*v-h*u*v;c.n22=e*t*y-g*u*y+g*q*E-b*t*E-e*q*v+b*u*v;c.n23=g*k*y-e*n*y-g*h*E+b*n*E+e*h*v-b*k*v; +c.n24=e*n*q-g*k*q+g*h*u-b*n*u-e*h*t+b*k*t;c.n31=j*t*y-n*x*y+n*q*A-h*t*A-j*q*v+h*x*v;c.n32=g*x*y-d*t*y-g*q*A+b*t*A+d*q*v-b*x*v;c.n33=e*n*y-g*j*y+g*h*A-b*n*A-d*h*v+b*j*v;c.n34=g*j*q-d*n*q-g*h*x+b*n*x+d*h*t-b*j*t;c.n41=k*x*y-j*u*y-k*q*A+h*u*A+j*q*E-h*x*E;c.n42=d*u*y-e*x*y+e*q*A-b*u*A-d*q*E+b*x*E;c.n43=e*j*y-d*k*y-e*h*A+b*k*A+d*h*E-b*j*E;c.n44=d*k*q-e*j*q+e*h*x-b*k*x-d*h*u+b*j*u;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,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,q=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*e;b[2]=a*g;b[3]=a*h;b[4]=a*j;b[5]=a*k;b[6]=a*n;b[7]=a*q;b[8]=a*x;return c}; THREE.Matrix4.makeFrustum=function(a,c,b,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*e/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var e;a=b*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*c,a*c,e,a,b,d)}; THREE.Matrix4.makeOrtho=function(a,c,b,d,e,g){var h,j,k,n;h=new THREE.Matrix4;j=c-a;k=b-d;n=g-e;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((c+a)/j);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((b+d)/k);h.n31=0;h.n32=0;h.n33=-2/n;h.n34=-((g+e)/n);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};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= @@ -47,7 +47,7 @@ undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var c c,b)}}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==undefined?d:1)}; THREE.Quaternion.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},setFromEuler:function(a){var c=0.5*Math.PI/360,b=a.x*c,d=a.y*c,e=a.z*c;a=Math.cos(d);d=Math.sin(d);c=Math.cos(-e);e=Math.sin(-e);var g=Math.cos(b);b=Math.sin(b);var h=a*c,j=d*e;this.w=h*g-j*b;this.x=h*b+j*g;this.y=d*c*g+a*e*b;this.z=a*e*g-d*c*b;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*= -1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var c=this.x,b=this.y,d=this.z,e=this.w,g=a.x,h=a.y,j=a.z;a=a.w;this.x=c*a+e*g+b*j-d*h;this.y=b*a+e*h+d*g-c*j;this.z=d*a+e*j+c*h-b*g;this.w=e*a-c*g-b*h-d*j;return this}, -multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,e=a.z,g=this.x,h=this.y,j=this.z,k=this.w,n=k*b+h*e-j*d,p=k*d+j*b-g*e,w=k*e+g*d-h*b;b=-g*b-h*d-j*e;c.x=n*k+b*-g+p*-j-w*-h;c.y=p*k+b*-h+w*-g-n*-j;c.z=w*k+b*-j+n*-h-p*-g;return c}}; +multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,e=a.z,g=this.x,h=this.y,j=this.z,k=this.w,n=k*b+h*e-j*d,q=k*d+j*b-g*e,x=k*e+g*d-h*b;b=-g*b-h*d-j*e;c.x=n*k+b*-g+q*-j-x*-h;c.y=q*k+b*-h+x*-g-n*-j;c.z=x*k+b*-j+n*-h-q*-g;return c}}; THREE.Quaternion.slerp=function(a,c,b,d){var e=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(e)>=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<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}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b}; THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0}; THREE.Face3=function(a,c,b,d,e){this.a=a;this.b=c;this.c=b;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,c,b,d,e,g){this.a=a;this.b=c;this.c=b;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]}; @@ -56,13 +56,13 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,c,b;a=0;for(c=this.f b.centroid.addSelf(this.vertices[b.d].position);b.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,b,d,e,g,h,j=new THREE.Vector3,k=new THREE.Vector3;d=0;for(e=this.vertices.length;d0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], +this.vertices[d.d].normal.copy(d.vertexNormals[3])}}c=0;for(b=this.vertices.length;c0){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.z this.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;ct.length-2?e:e+1;c[3]=e>t.length-3?e:e+2;k=t[c[0]];n=t[c[1]];p=t[c[2]];w=t[c[3]];h=g*g;j=g*h;b.x=a(k.x,n.x,p.x,w.x,g,h,j);b.y=a(k.y,n.y,p.y,w.y,g,h,j);b.z=a(k.z,n.z,p.z,w.z,g,h,j);return b}}; +THREE.Spline=function(){function a(u,t,y,A,E,v,F){u=(y-u)*0.5;A=(A-t)*0.5;return(2*(t-y)+u+A)*F+(-3*(t-y)-2*u-A)*v+u*E+t}var c=[],b={x:0,y:0,z:0},d,e,g,h,j,k,n,q,x;this.get2DPoint=function(u,t){d=(u.length-1)*t;e=Math.floor(d);g=d-e;c[0]=e==0?e:e-1;c[1]=e;c[2]=e>u.length-2?e:e+1;c[3]=e>u.length-3?e:e+2;k=u[c[0]];n=u[c[1]];q=u[c[2]];x=u[c[3]];h=g*g;j=g*h;b.x=a(k.x,n.x,q.x,x.x,g,h,j);b.y=a(k.y,n.y,q.y,x.y,g,h,j);b.z=a(k.z,n.z,q.z,x.z,g,h,j);return b}}; THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(e){for(var g=0;g1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d);d=d<0?0:1}if(b==="pos")if(this.interpolationType===THREE.AnimationHandler.LINEAR){b=a.position;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}else{var E=[];E[0]=this.getPrevKeyWith(b,q,h.index-1)[b];E[1]=e;E[2]=g;E[3]=this.getNextKeyWith(b,q,j.index+1)[b];d=d*0.33+0.33;d=this.interpolateCatmullRom(E, -d);a.position.x=d[0];a.position.y=d[1];a.position.z=d[2]}else if(b==="rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}}}}if(this.JITCompile&&p[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(q=0;q1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d);d=d<0?0:1}if(b==="pos")if(this.interpolationType===THREE.AnimationHandler.LINEAR){b=a.position;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}else{var E=[];E[0]=this.getPrevKeyWith(b,t,h.index-1)[b];E[1]=e;E[2]=g;E[3]=this.getNextKeyWith(b,t,j.index+1)[b];d=d*0.33+0.33;d=this.interpolateCatmullRom(E, +d);a.position.x=d[0];a.position.y=d[1];a.position.z=d[2]}else if(b==="rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}}}}if(this.JITCompile&&q[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(t=0;ta.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];j=a[b[1]];k=a[b[2]];n=a[b[3]];b=e*e;h=e*b;d[0]=this.interpolate(g[0],j[0],k[0],n[0],e,b,h);d[1]=this.interpolate(g[1],j[1],k[1],n[1],e,b,h);d[2]=this.interpolate(g[2],j[2],k[2],n[2],e,b,h);return d}; THREE.Animation.prototype.interpolate=function(a,c,b,d,e,g,h){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*h+(-3*(c-b)-2*a-d)*g+a*e+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(b%=d.length;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,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()}; @@ -140,120 +140,120 @@ THREE.LOD.prototype.update=function(a,c,b){this.matrixAutoUpdate&&(c|=this.updat THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a)}for(var c=0;c=0&&ea>=0&&J>=0&&ca>=0)return!0;else if(ba<0&&ea<0||J<0&&ca<0)return!1;else{if(ba<0)V=Math.max(V,ba/(ba-ea));else ea<0&&(S=Math.min(S,ba/(ba-ea)));if(J<0)V=Math.max(V,J/(J-ca));else ca<0&&(S=Math.min(S,J/(J-ca)));if(Sba&&da.z0&& -E.z<1){t=x[q]=x[q]||new THREE.RenderableParticle;t.x=E.x/E.w;t.y=E.y/E.w;t.z=E.z;t.rotation=fa.rotation.z;t.scale.x=fa.scale.x*Math.abs(t.x-(E.x+f.projectionMatrix.n11)/(E.w+f.projectionMatrix.n14));t.scale.y=fa.scale.y*Math.abs(t.y-(E.y+f.projectionMatrix.n22)/(E.w+f.projectionMatrix.n24));t.materials=fa.materials;S.push(t);q++}}}}V&&S.sort(a);return S};this.unprojectVector=function(M,f){var V=f.matrixWorld.clone();V.multiplySelf(THREE.Matrix4.makeInvert(f.projectionMatrix));V.multiplyVector3(M); +THREE.Projector=function(){function a(M,f){return f.z-M.z}function c(M,f){var V=0,T=1,ca=M.z+M.w,ea=f.z+f.w,H=-M.z+M.w,ba=-f.z+f.w;if(ca>=0&&ea>=0&&H>=0&&ba>=0)return!0;else if(ca<0&&ea<0||H<0&&ba<0)return!1;else{if(ca<0)V=Math.max(V,ca/(ca-ea));else ea<0&&(T=Math.min(T,ca/(ca-ea)));if(H<0)V=Math.max(V,H/(H-ba));else ba<0&&(T=Math.min(T,H/(H-ba)));if(Tca&&da.z0&& +E.z<1){u=y[t]=y[t]||new THREE.RenderableParticle;u.x=E.x/E.w;u.y=E.y/E.w;u.z=E.z;u.rotation=fa.rotation.z;u.scale.x=fa.scale.x*Math.abs(u.x-(E.x+f.projectionMatrix.n11)/(E.w+f.projectionMatrix.n14));u.scale.y=fa.scale.y*Math.abs(u.y-(E.y+f.projectionMatrix.n22)/(E.w+f.projectionMatrix.n24));u.materials=fa.materials;T.push(u);t++}}}}V&&T.sort(a);return T};this.unprojectVector=function(M,f){var V=f.matrixWorld.clone();V.multiplySelf(THREE.Matrix4.makeInvert(f.projectionMatrix));V.multiplyVector3(M); return M}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,j){b=h;d=j;e=b/2;g=d/2};this.render=function(h,j){var k,n,p,w,t,q,x,B;a=c.projectScene(h,j);k=0;for(n=a.length;k0){K.r+=Ea.r*na;K.g+=Ea.g*na;K.b+=Ea.b*na}}else if(na instanceof THREE.PointLight){z.sub(na.position,W);z.normalize();na=T.dot(z)*va;if(na>0){K.r+=Ea.r*na;K.g+=Ea.g*na;K.b+=Ea.b*na}}}}function Ka(G,W,T){if(T.opacity!=0){a(T.opacity); -c(T.blending);var K,$,na,Ea,va,Ha;if(T instanceof THREE.ParticleBasicMaterial){if(T.map){Ea=T.map.image;va=Ea.width>>1;Ha=Ea.height>>1;$=W.scale.x*j;na=W.scale.y*k;T=$*va;K=na*Ha;R.set(G.x-T,G.y-K,G.x+T,G.y+K);if(oa.instersects(R)){n.save();n.translate(G.x,G.y);n.rotate(-W.rotation);n.scale($,-na);n.translate(-va,-Ha);n.drawImage(Ea,0,0);n.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(ia){m.r=y.r+C.r+l.r;m.g=y.g+C.g+l.g;m.b=y.b+C.b+l.b;S.r=T.color.r*m.r;S.g=T.color.g*m.g;S.b=T.color.b* -m.b;S.updateStyleString()}else S.__styleString=T.color.__styleString;T=W.scale.x*j;K=W.scale.y*k;R.set(G.x-T,G.y-K,G.x+T,G.y+K);if(oa.instersects(R)){$=S.__styleString;if(B!=$)n.fillStyle=B=$;n.save();n.translate(G.x,G.y);n.rotate(-W.rotation);n.scale(T,K);n.beginPath();n.arc(0,0,1,0,o,!0);n.closePath();n.fill();n.restore()}}}}function Q(G,W,T,K){if(K.opacity!=0){a(K.opacity);c(K.blending);n.beginPath();n.moveTo(G.positionScreen.x,G.positionScreen.y);n.lineTo(W.positionScreen.x,W.positionScreen.y); -n.closePath();if(K instanceof THREE.LineBasicMaterial){S.__styleString=K.color.__styleString;G=K.linewidth;if(E!=G)n.lineWidth=E=G;G=S.__styleString;if(x!=G)n.strokeStyle=x=G;n.stroke();R.inflate(K.linewidth*2)}}}function Ga(G,W,T,K,$,na){if($.opacity!=0){a($.opacity);c($.blending);N=G.positionScreen.x;L=G.positionScreen.y;Y=W.positionScreen.x;M=W.positionScreen.y;f=T.positionScreen.x;V=T.positionScreen.y;n.beginPath();n.moveTo(N,L);n.lineTo(Y,M);n.lineTo(f,V);n.lineTo(N,L);n.closePath();if($ instanceof -THREE.MeshBasicMaterial)if($.map)$.map.mapping instanceof THREE.UVMapping&&U(N,L,Y,M,f,V,$.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if($.envMap){if($.envMap.mapping instanceof THREE.SphericalReflectionMapping){G=ka.matrixWorldInverse;z.copy(K.vertexNormalsWorld[0]);ha=(z.x*G.n11+z.y*G.n12+z.z*G.n13)*0.5+0.5;fa=-(z.x*G.n21+z.y*G.n22+z.z*G.n23)*0.5+0.5;z.copy(K.vertexNormalsWorld[1]);ra=(z.x*G.n11+z.y*G.n12+z.z*G.n13)*0.5+0.5;xa=-(z.x*G.n21+z.y*G.n22+z.z*G.n23)* -0.5+0.5;z.copy(K.vertexNormalsWorld[2]);ga=(z.x*G.n11+z.y*G.n12+z.z*G.n13)*0.5+0.5;aa=-(z.x*G.n21+z.y*G.n22+z.z*G.n23)*0.5+0.5;U(N,L,Y,M,f,V,$.envMap.image,ha,fa,ra,xa,ga,aa)}}else $.wireframe?Ca($.color.__styleString,$.wireframeLinewidth):Fa($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&&!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&U(N,L,Y,M,f,V,$.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);c(THREE.SubtractiveBlending)}if(ia)if(!$.wireframe&& -$.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){ba.r=ea.r=J.r=y.r;ba.g=ea.g=J.g=y.g;ba.b=ea.b=J.b=y.b;ma(na,K.v1.positionWorld,K.vertexNormalsWorld[0],ba);ma(na,K.v2.positionWorld,K.vertexNormalsWorld[1],ea);ma(na,K.v3.positionWorld,K.vertexNormalsWorld[2],J);ca.r=(ea.r+J.r)*0.5;ca.g=(ea.g+J.g)*0.5;ca.b=(ea.b+J.b)*0.5;ta=X(ba,ea,J,ca);U(N,L,Y,M,f,V,ta,0,0,1,0,0,1)}else{m.r=y.r;m.g=y.g;m.b=y.b;ma(na,K.centroidWorld,K.normalWorld,m);S.r=$.color.r*m.r;S.g=$.color.g*m.g;S.b=$.color.b* -m.b;S.updateStyleString();$.wireframe?Ca(S.__styleString,$.wireframeLinewidth):Fa(S.__styleString)}else $.wireframe?Ca($.color.__styleString,$.wireframeLinewidth):Fa($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){wa=ka.near;da=ka.far;ba.r=ba.g=ba.b=1-Z(G.positionScreen.z,wa,da);ea.r=ea.g=ea.b=1-Z(W.positionScreen.z,wa,da);J.r=J.g=J.b=1-Z(T.positionScreen.z,wa,da);ca.r=(ea.r+J.r)*0.5;ca.g=(ea.g+J.g)*0.5;ca.b=(ea.b+J.b)*0.5;ta=X(ba,ea,J,ca);U(N,L,Y,M,f,V,ta,0,0,1,0,0,1)}else if($ instanceof -THREE.MeshNormalMaterial){S.r=ya(K.normalWorld.x);S.g=ya(K.normalWorld.y);S.b=ya(K.normalWorld.z);S.updateStyleString();$.wireframe?Ca(S.__styleString,$.wireframeLinewidth):Fa(S.__styleString)}}}function Ca(G,W){if(x!=G)n.strokeStyle=x=G;if(E!=W)n.lineWidth=E=W;n.stroke();R.inflate(W*2)}function Fa(G){if(B!=G)n.fillStyle=B=G;n.fill()}function U(G,W,T,K,$,na,Ea,va,Ha,Oa,Ja,Pa,Sa){var Na,Da;Na=Ea.width-1;Da=Ea.height-1;va*=Na;Ha*=Da;Oa*=Na;Ja*=Da;Pa*=Na;Sa*=Da;T-=G;K-=W;$-=G;na-=W;Oa-=va;Ja-=Ha;Pa-= -va;Sa-=Ha;Na=Oa*Sa-Pa*Ja;if(Na!=0){Da=1/Na;Na=(Sa*T-Ja*$)*Da;Ja=(Sa*K-Ja*na)*Da;T=(Oa*$-Pa*T)*Da;K=(Oa*na-Pa*K)*Da;G=G-Na*va-T*Ha;W=W-Ja*va-K*Ha;n.save();n.transform(Na,Ja,T,K,G,W);n.clip();n.drawImage(Ea,0,0);n.restore()}}function X(G,W,T,K){var $=~~(G.r*255),na=~~(G.g*255);G=~~(G.b*255);var Ea=~~(W.r*255),va=~~(W.g*255);W=~~(W.b*255);var Ha=~~(T.r*255),Oa=~~(T.g*255);T=~~(T.b*255);var Ja=~~(K.r*255),Pa=~~(K.g*255);K=~~(K.b*255);H[0]=$<0?0:$>255?255:$;H[1]=na<0?0:na>255?255:na;H[2]=G<0?0:G>255?255: -G;H[4]=Ea<0?0:Ea>255?255:Ea;H[5]=va<0?0:va>255?255:va;H[6]=W<0?0:W>255?255:W;H[8]=Ha<0?0:Ha>255?255:Ha;H[9]=Oa<0?0:Oa>255?255:Oa;H[10]=T<0?0:T>255?255:T;H[12]=Ja<0?0:Ja>255?255:Ja;H[13]=Pa<0?0:Pa>255?255:Pa;H[14]=K<0?0:K>255?255:K;D.putImageData(P,0,0);la.drawImage(A,0,0);return O}function Z(G,W,T){G=(G-W)/(T-W);return G*G*(3-2*G)}function ya(G){G=(G+1)*0.5;return G<0?0:G>1?1:G}function Ia(G,W){var T=W.x-G.x,K=W.y-G.y,$=1/Math.sqrt(T*T+K*K);T*=$;K*=$;W.x+=T;W.y+=K;G.x-=T;G.y-=K}var Aa,I,qa,Ma,Qa, -La,za,Ba;this.autoClear?this.clear():n.setTransform(1,0,0,-1,j,k);b=d.projectScene(ja,ka,this.sortElements);(ia=ja.lights.length>0)&&sa(ja);Aa=0;for(I=b.length;Aa0){ra.r+=aa.color.r*oa;ra.g+=aa.color.g*oa;ra.b+=aa.color.b*oa}}else if(aa instanceof THREE.PointLight){V.sub(aa.position,fa.centroidWorld);V.normalize();oa=fa.normalWorld.dot(V)*aa.intensity;if(oa>0){ra.r+=aa.color.r*oa;ra.g+=aa.color.g*oa;ra.b+=aa.color.b*oa}}}}function c(ha,fa,ra, -xa,ga,aa){J=d(ca++);J.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(ga instanceof THREE.MeshBasicMaterial)v.__styleString=ga.color.__styleString;else if(ga instanceof THREE.MeshLambertMaterial)if(F){N.r=L.r;N.g=L.g;N.b=L.b;a(aa,xa,N);v.r=ga.color.r*N.r;v.g=ga.color.g*N.g;v.b=ga.color.b*N.b;v.updateStyleString()}else v.__styleString=ga.color.__styleString;else if(ga instanceof -THREE.MeshDepthMaterial){f=1-ga.__2near/(ga.__farPlusNear-xa.z*ga.__farMinusNear);v.setRGB(f,f,f)}else ga instanceof THREE.MeshNormalMaterial&&v.setRGB(e(xa.normalWorld.x),e(xa.normalWorld.y),e(xa.normalWorld.z));ga.wireframe?J.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+ga.wireframeLinewidth+"; stroke-opacity: "+ga.opacity+"; stroke-linecap: "+ga.wireframeLinecap+"; stroke-linejoin: "+ga.wireframeLinejoin):J.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+ -ga.opacity);j.appendChild(J)}function b(ha,fa,ra,xa,ga,aa,oa){J=d(ca++);J.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+xa.positionScreen.x+","+xa.positionScreen.y+"z");if(aa instanceof THREE.MeshBasicMaterial)v.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshLambertMaterial)if(F){N.r=L.r;N.g=L.g;N.b=L.b;a(oa,ga,N);v.r=aa.color.r*N.r;v.g=aa.color.g*N.g; -v.b=aa.color.b*N.b;v.updateStyleString()}else v.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshDepthMaterial){f=1-aa.__2near/(aa.__farPlusNear-ga.z*aa.__farMinusNear);v.setRGB(f,f,f)}else aa instanceof THREE.MeshNormalMaterial&&v.setRGB(e(ga.normalWorld.x),e(ga.normalWorld.y),e(ga.normalWorld.z));aa.wireframe?J.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+aa.wireframeLinewidth+"; stroke-opacity: "+aa.opacity+"; stroke-linecap: "+aa.wireframeLinecap+ -"; stroke-linejoin: "+aa.wireframeLinejoin):J.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+aa.opacity);j.appendChild(J)}function d(ha){if(S[ha]==null){S[ha]=document.createElementNS("http://www.w3.org/2000/svg","path");ta==0&&S[ha].setAttribute("shape-rendering","crispEdges")}return S[ha]}function e(ha){return ha<0?Math.min((1+ha)*0.5,0.5):0.5+Math.min(ha*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,n,p,w,t,q,x,B,E= -new THREE.Rectangle,u=new THREE.Rectangle,F=!1,v=new THREE.Color(16777215),N=new THREE.Color(16777215),L=new THREE.Color(0),Y=new THREE.Color(0),M=new THREE.Color(0),f,V=new THREE.Vector3,S=[],ba=[],ea=[],J,ca,wa,da,ta=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ha){switch(ha){case "high":ta=1;break;case "low":ta=0}};this.setSize=function(ha,fa){k=ha;n=fa;p=k/2;w=n/2;j.setAttribute("viewBox",-p+" "+-w+" "+k+" "+n);j.setAttribute("width", -k);j.setAttribute("height",n);E.set(-p,-w,p,w)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};this.render=function(ha,fa){var ra,xa,ga,aa,oa,pa,R,ia;this.autoClear&&this.clear();g=h.projectScene(ha,fa,this.sortElements);da=wa=ca=0;if(F=ha.lights.length>0){R=ha.lights;L.setRGB(0,0,0);Y.setRGB(0,0,0);M.setRGB(0,0,0);ra=0;for(xa=R.length;ra=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLColorBuffer);f.vertexAttribPointer(m.color,3,f.FLOAT,!1,0,0)}if(m.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLNormalBuffer);f.vertexAttribPointer(m.normal,3,f.FLOAT,!1,0,0)}if(m.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLTangentBuffer);f.vertexAttribPointer(m.tangent, +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,j){b=h;d=j;e=b/2;g=d/2};this.render=function(h,j){var k,n,q,x,u,t,y,A;a=c.projectScene(h,j);k=0;for(n=a.length;k0){J.r+=va.r*ta;J.g+=va.g*ta;J.b+=va.b*ta}}else if(ta instanceof THREE.PointLight){o.sub(ta.position,Y);o.normalize();ta=U.dot(o)*Ha;if(ta>0){J.r+=va.r*ta;J.g+=va.g*ta;J.b+=va.b*ta}}}}function oa(I,Y,U){if(U.opacity!=0){a(U.opacity); +c(U.blending);var J,S,ta,va,Ha,ya;if(U instanceof THREE.ParticleBasicMaterial){if(U.map){va=U.map.image;Ha=va.width>>1;ya=va.height>>1;S=Y.scale.x*j;ta=Y.scale.y*k;U=S*Ha;J=ta*ya;R.set(I.x-U,I.y-J,I.x+U,I.y+J);if(la.instersects(R)){n.save();n.translate(I.x,I.y);n.rotate(-Y.rotation);n.scale(S,-ta);n.translate(-Ha,-ya);n.drawImage(va,0,0);n.restore()}}}else if(U instanceof THREE.ParticleCircleMaterial){if(ia){pa.r=m.r+z.r+p.r;pa.g=m.g+z.g+p.g;pa.b=m.b+z.b+p.b;T.r=U.color.r*pa.r;T.g=U.color.g*pa.g; +T.b=U.color.b*pa.b;T.updateStyleString()}else T.__styleString=U.color.__styleString;U=Y.scale.x*j;J=Y.scale.y*k;R.set(I.x-U,I.y-J,I.x+U,I.y+J);if(la.instersects(R)){S=T.__styleString;if(A!=S)n.fillStyle=A=S;n.save();n.translate(I.x,I.y);n.rotate(-Y.rotation);n.scale(U,J);n.beginPath();n.arc(0,0,1,0,l,!0);n.closePath();n.fill();n.restore()}}}}function Ia(I,Y,U,J){if(J.opacity!=0){a(J.opacity);c(J.blending);n.beginPath();n.moveTo(I.positionScreen.x,I.positionScreen.y);n.lineTo(Y.positionScreen.x,Y.positionScreen.y); +n.closePath();if(J instanceof THREE.LineBasicMaterial){T.__styleString=J.color.__styleString;I=J.linewidth;if(E!=I)n.lineWidth=E=I;I=T.__styleString;if(y!=I)n.strokeStyle=y=I;n.stroke();R.inflate(J.linewidth*2)}}}function Q(I,Y,U,J,S,ta){if(S.opacity!=0){a(S.opacity);c(S.blending);O=I.positionScreen.x;K=I.positionScreen.y;Z=Y.positionScreen.x;M=Y.positionScreen.y;f=U.positionScreen.x;V=U.positionScreen.y;n.beginPath();n.moveTo(O,K);n.lineTo(Z,M);n.lineTo(f,V);n.lineTo(O,K);n.closePath();if(S instanceof +THREE.MeshBasicMaterial)if(S.map)S.map.mapping instanceof THREE.UVMapping&&Ea(O,K,Z,M,f,V,S.map.image,J.uvs[0].u,J.uvs[0].v,J.uvs[1].u,J.uvs[1].v,J.uvs[2].u,J.uvs[2].v);else if(S.envMap){if(S.envMap.mapping instanceof THREE.SphericalReflectionMapping){I=qa.matrixWorldInverse;o.copy(J.vertexNormalsWorld[0]);ha=(o.x*I.n11+o.y*I.n12+o.z*I.n13)*0.5+0.5;fa=-(o.x*I.n21+o.y*I.n22+o.z*I.n23)*0.5+0.5;o.copy(J.vertexNormalsWorld[1]);sa=(o.x*I.n11+o.y*I.n12+o.z*I.n13)*0.5+0.5;xa=-(o.x*I.n21+o.y*I.n22+o.z*I.n23)* +0.5+0.5;o.copy(J.vertexNormalsWorld[2]);ga=(o.x*I.n11+o.y*I.n12+o.z*I.n13)*0.5+0.5;aa=-(o.x*I.n21+o.y*I.n22+o.z*I.n23)*0.5+0.5;Ea(O,K,Z,M,f,V,S.envMap.image,ha,fa,sa,xa,ga,aa)}}else S.wireframe?Fa(S.color.__styleString,S.wireframeLinewidth):Da(S.color.__styleString);else if(S instanceof THREE.MeshLambertMaterial){if(S.map&&!S.wireframe){S.map.mapping instanceof THREE.UVMapping&&Ea(O,K,Z,M,f,V,S.map.image,J.uvs[0].u,J.uvs[0].v,J.uvs[1].u,J.uvs[1].v,J.uvs[2].u,J.uvs[2].v);c(THREE.SubtractiveBlending)}if(ia)if(!S.wireframe&& +S.shading==THREE.SmoothShading&&J.vertexNormalsWorld.length==3){ca.r=ea.r=H.r=m.r;ca.g=ea.g=H.g=m.g;ca.b=ea.b=H.b=m.b;na(ta,J.v1.positionWorld,J.vertexNormalsWorld[0],ca);na(ta,J.v2.positionWorld,J.vertexNormalsWorld[1],ea);na(ta,J.v3.positionWorld,J.vertexNormalsWorld[2],H);ba.r=(ea.r+H.r)*0.5;ba.g=(ea.g+H.g)*0.5;ba.b=(ea.b+H.b)*0.5;ua=W(ca,ea,H,ba);Ea(O,K,Z,M,f,V,ua,0,0,1,0,0,1)}else{pa.r=m.r;pa.g=m.g;pa.b=m.b;na(ta,J.centroidWorld,J.normalWorld,pa);T.r=S.color.r*pa.r;T.g=S.color.g*pa.g;T.b=S.color.b* +pa.b;T.updateStyleString();S.wireframe?Fa(T.__styleString,S.wireframeLinewidth):Da(T.__styleString)}else S.wireframe?Fa(S.color.__styleString,S.wireframeLinewidth):Da(S.color.__styleString)}else if(S instanceof THREE.MeshDepthMaterial){wa=qa.near;da=qa.far;ca.r=ca.g=ca.b=1-X(I.positionScreen.z,wa,da);ea.r=ea.g=ea.b=1-X(Y.positionScreen.z,wa,da);H.r=H.g=H.b=1-X(U.positionScreen.z,wa,da);ba.r=(ea.r+H.r)*0.5;ba.g=(ea.g+H.g)*0.5;ba.b=(ea.b+H.b)*0.5;ua=W(ca,ea,H,ba);Ea(O,K,Z,M,f,V,ua,0,0,1,0,0,1)}else if(S instanceof +THREE.MeshNormalMaterial){T.r=$(J.normalWorld.x);T.g=$(J.normalWorld.y);T.b=$(J.normalWorld.z);T.updateStyleString();S.wireframe?Fa(T.__styleString,S.wireframeLinewidth):Da(T.__styleString)}}}function Fa(I,Y){if(y!=I)n.strokeStyle=y=I;if(E!=Y)n.lineWidth=E=Y;n.stroke();R.inflate(Y*2)}function Da(I){if(A!=I)n.fillStyle=A=I;n.fill()}function Ea(I,Y,U,J,S,ta,va,Ha,ya,Oa,Ja,Ka,Sa){var Ma,Pa;Ma=va.width-1;Pa=va.height-1;Ha*=Ma;ya*=Pa;Oa*=Ma;Ja*=Pa;Ka*=Ma;Sa*=Pa;U-=I;J-=Y;S-=I;ta-=Y;Oa-=Ha;Ja-=ya;Ka-=Ha; +Sa-=ya;Ma=Oa*Sa-Ka*Ja;if(Ma!=0){Pa=1/Ma;Ma=(Sa*U-Ja*S)*Pa;Ja=(Sa*J-Ja*ta)*Pa;U=(Oa*S-Ka*U)*Pa;J=(Oa*ta-Ka*J)*Pa;I=I-Ma*Ha-U*ya;Y=Y-Ja*Ha-J*ya;n.save();n.transform(Ma,Ja,U,J,I,Y);n.clip();n.drawImage(va,0,0);n.restore()}}function W(I,Y,U,J){var S=~~(I.r*255),ta=~~(I.g*255);I=~~(I.b*255);var va=~~(Y.r*255),Ha=~~(Y.g*255);Y=~~(Y.b*255);var ya=~~(U.r*255),Oa=~~(U.g*255);U=~~(U.b*255);var Ja=~~(J.r*255),Ka=~~(J.g*255);J=~~(J.b*255);N[0]=S<0?0:S>255?255:S;N[1]=ta<0?0:ta>255?255:ta;N[2]=I<0?0:I>255?255: +I;N[4]=va<0?0:va>255?255:va;N[5]=Ha<0?0:Ha>255?255:Ha;N[6]=Y<0?0:Y>255?255:Y;N[8]=ya<0?0:ya>255?255:ya;N[9]=Oa<0?0:Oa>255?255:Oa;N[10]=U<0?0:U>255?255:U;N[12]=Ja<0?0:Ja>255?255:Ja;N[13]=Ka<0?0:Ka>255?255:Ka;N[14]=J<0?0:J>255?255:J;B.putImageData(G,0,0);P.drawImage(C,0,0);return L}function X(I,Y,U){I=(I-Y)/(U-Y);return I*I*(3-2*I)}function $(I){I=(I+1)*0.5;return I<0?0:I>1?1:I}function za(I,Y){var U=Y.x-I.x,J=Y.y-I.y,S=1/Math.sqrt(U*U+J*J);U*=S;J*=S;Y.x+=U;Y.y+=J;I.x-=U;I.y-=J}var Ga,Ca,D,Ba,Qa,Ta, +La,Aa;this.autoClear?this.clear():n.setTransform(1,0,0,-1,j,k);b=d.projectScene(ja,qa,this.sortElements);(ia=ja.lights.length>0)&&ra(ja);Ga=0;for(Ca=b.length;Ga0){sa.r+=aa.color.r*la;sa.g+=aa.color.g*la;sa.b+=aa.color.b*la}}else if(aa instanceof THREE.PointLight){V.sub(aa.position,fa.centroidWorld);V.normalize();la=fa.normalWorld.dot(V)*aa.intensity;if(la>0){sa.r+=aa.color.r*la;sa.g+=aa.color.g*la;sa.b+=aa.color.b*la}}}}function c(ha,fa,sa, +xa,ga,aa){H=d(ba++);H.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+"z");if(ga instanceof THREE.MeshBasicMaterial)w.__styleString=ga.color.__styleString;else if(ga instanceof THREE.MeshLambertMaterial)if(F){O.r=K.r;O.g=K.g;O.b=K.b;a(aa,xa,O);w.r=ga.color.r*O.r;w.g=ga.color.g*O.g;w.b=ga.color.b*O.b;w.updateStyleString()}else w.__styleString=ga.color.__styleString;else if(ga instanceof +THREE.MeshDepthMaterial){f=1-ga.__2near/(ga.__farPlusNear-xa.z*ga.__farMinusNear);w.setRGB(f,f,f)}else ga instanceof THREE.MeshNormalMaterial&&w.setRGB(e(xa.normalWorld.x),e(xa.normalWorld.y),e(xa.normalWorld.z));ga.wireframe?H.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+ga.wireframeLinewidth+"; stroke-opacity: "+ga.opacity+"; stroke-linecap: "+ga.wireframeLinecap+"; stroke-linejoin: "+ga.wireframeLinejoin):H.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+ +ga.opacity);j.appendChild(H)}function b(ha,fa,sa,xa,ga,aa,la){H=d(ba++);H.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+" L "+xa.positionScreen.x+","+xa.positionScreen.y+"z");if(aa instanceof THREE.MeshBasicMaterial)w.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshLambertMaterial)if(F){O.r=K.r;O.g=K.g;O.b=K.b;a(la,ga,O);w.r=aa.color.r*O.r;w.g=aa.color.g*O.g; +w.b=aa.color.b*O.b;w.updateStyleString()}else w.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshDepthMaterial){f=1-aa.__2near/(aa.__farPlusNear-ga.z*aa.__farMinusNear);w.setRGB(f,f,f)}else aa instanceof THREE.MeshNormalMaterial&&w.setRGB(e(ga.normalWorld.x),e(ga.normalWorld.y),e(ga.normalWorld.z));aa.wireframe?H.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+aa.wireframeLinewidth+"; stroke-opacity: "+aa.opacity+"; stroke-linecap: "+aa.wireframeLinecap+ +"; stroke-linejoin: "+aa.wireframeLinejoin):H.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+aa.opacity);j.appendChild(H)}function d(ha){if(T[ha]==null){T[ha]=document.createElementNS("http://www.w3.org/2000/svg","path");ua==0&&T[ha].setAttribute("shape-rendering","crispEdges")}return T[ha]}function e(ha){return ha<0?Math.min((1+ha)*0.5,0.5):0.5+Math.min(ha*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,n,q,x,u,t,y,A,E= +new THREE.Rectangle,v=new THREE.Rectangle,F=!1,w=new THREE.Color(16777215),O=new THREE.Color(16777215),K=new THREE.Color(0),Z=new THREE.Color(0),M=new THREE.Color(0),f,V=new THREE.Vector3,T=[],ca=[],ea=[],H,ba,wa,da,ua=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ha){switch(ha){case "high":ua=1;break;case "low":ua=0}};this.setSize=function(ha,fa){k=ha;n=fa;q=k/2;x=n/2;j.setAttribute("viewBox",-q+" "+-x+" "+k+" "+n);j.setAttribute("width", +k);j.setAttribute("height",n);E.set(-q,-x,q,x)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};this.render=function(ha,fa){var sa,xa,ga,aa,la,ma,R,ia;this.autoClear&&this.clear();g=h.projectScene(ha,fa,this.sortElements);da=wa=ba=0;if(F=ha.lights.length>0){R=ha.lights;K.setRGB(0,0,0);Z.setRGB(0,0,0);M.setRGB(0,0,0);sa=0;for(xa=R.length;sa=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLColorBuffer);f.vertexAttribPointer(m.color,3,f.FLOAT,!1,0,0)}if(m.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLNormalBuffer);f.vertexAttribPointer(m.normal,3,f.FLOAT,!1,0,0)}if(m.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLTangentBuffer);f.vertexAttribPointer(m.tangent, 4,f.FLOAT,!1,0,0)}if(m.uv>=0)if(o.__webGLUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLUVBuffer);f.vertexAttribPointer(m.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(m.uv)}else f.disableVertexAttribArray(m.uv);if(m.uv2>=0)if(o.__webGLUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLUV2Buffer);f.vertexAttribPointer(m.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(m.uv2)}else f.disableVertexAttribArray(m.uv2);if(l.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER, -o.__webGLSkinVertexABuffer);f.vertexAttribPointer(m.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);f.vertexAttribPointer(m.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);f.vertexAttribPointer(m.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);f.vertexAttribPointer(m.skinWeight,4,f.FLOAT,!1,0,0)}if(z instanceof THREE.Mesh)if(l.wireframe){f.lineWidth(l.wireframeLinewidth);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, -o.__webGLLineBuffer);f.drawElements(f.LINES,o.__webGLLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);f.drawElements(f.TRIANGLES,o.__webGLFaceCount,f.UNSIGNED_SHORT,0)}else if(z instanceof THREE.Line){z=z.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(l.linewidth);f.drawArrays(z,0,o.__webGLLineCount)}else if(z instanceof THREE.ParticleSystem)f.drawArrays(f.POINTS,0,o.__webGLParticleCount);else z instanceof THREE.Ribbon&&f.drawArrays(f.TRIANGLE_STRIP, -0,o.__webGLVertexCount)}function g(m,y){if(!m.__webGLVertexBuffer)m.__webGLVertexBuffer=f.createBuffer();if(!m.__webGLNormalBuffer)m.__webGLNormalBuffer=f.createBuffer();if(m.hasPos){f.bindBuffer(f.ARRAY_BUFFER,m.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,m.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(y.attributes.position);f.vertexAttribPointer(y.attributes.position,3,f.FLOAT,!1,0,0)}if(m.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,m.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,m.normalArray, -f.DYNAMIC_DRAW);f.enableVertexAttribArray(y.attributes.normal);f.vertexAttribPointer(y.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,m.count);m.count=0}function h(m){if(ea!=m.doubleSided){m.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);ea=m.doubleSided}if(J!=m.flipSided){m.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);J=m.flipSided}}function j(m){if(wa!=m){m?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);wa=m}}function k(m){ra[0].set(m.n41-m.n11,m.n42-m.n12,m.n43-m.n13, -m.n44-m.n14);ra[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);ra[2].set(m.n41+m.n21,m.n42+m.n22,m.n43+m.n23,m.n44+m.n24);ra[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);ra[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);ra[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+m.n34);var y;for(m=0;m<6;m++){y=ra[m];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}}function n(m){for(var y=m.matrixWorld,C=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y, -m.scale.z)),l=0;l<6;l++){m=ra[l].x*y.n14+ra[l].y*y.n24+ra[l].z*y.n34+ra[l].w;if(m<=C)return!1}return!0}function p(m,y){m.list[m.count]=y;m.count+=1}function w(m){var y,C,l=m.object,o=m.opaque,z=m.transparent;z.count=0;m=o.count=0;for(y=l.materials.length;m65535){O[P].counter+=1;H=O[P].hash+"_"+O[P].counter;m.geometryGroups[H]== -undefined&&(m.geometryGroups[H]={faces:[],materials:D,vertices:0})}m.geometryGroups[H].faces.push(o);m.geometryGroups[H].vertices+=A}}function E(m,y,C){m.push({buffer:y,object:C,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function u(m){if(m!=ca){switch(m){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA, -f.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:f.blendEquation(f.FUNC_REVERSE_SUBTRACT);f.blendFunc(f.ONE,f.ONE);break;default:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA)}ca=m}}function F(m,y,C){if((C.width&C.width-1)==0&&(C.height&C.height-1)==0){f.texParameteri(m,f.TEXTURE_WRAP_S,Y(y.wrapS));f.texParameteri(m,f.TEXTURE_WRAP_T,Y(y.wrapT));f.texParameteri(m,f.TEXTURE_MAG_FILTER,Y(y.magFilter));f.texParameteri(m,f.TEXTURE_MIN_FILTER,Y(y.minFilter));f.generateMipmap(m)}else{f.texParameteri(m, -f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(m,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(m,f.TEXTURE_MAG_FILTER,L(y.magFilter));f.texParameteri(m,f.TEXTURE_MIN_FILTER,L(y.minFilter))}}function v(m){if(m&&!m.__webGLFramebuffer){m.__webGLFramebuffer=f.createFramebuffer();m.__webGLRenderbuffer=f.createRenderbuffer();m.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,m.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,m.width,m.height);f.bindTexture(f.TEXTURE_2D, -m.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,Y(m.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,Y(m.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,Y(m.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,Y(m.minFilter));f.texImage2D(f.TEXTURE_2D,0,Y(m.format),m.width,m.height,0,Y(m.format),Y(m.type),null);f.bindFramebuffer(f.FRAMEBUFFER,m.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,m.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER, -f.DEPTH_ATTACHMENT,f.RENDERBUFFER,m.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var y,C;if(m){y=m.__webGLFramebuffer;C=m.width;m=m.height}else{y=null;C=ha;m=fa}if(y!=S){f.bindFramebuffer(f.FRAMEBUFFER,y);f.viewport(da,ta,C,m);S=y}}function N(m,y){var C;if(m=="fragment")C=f.createShader(f.FRAGMENT_SHADER);else m=="vertex"&&(C=f.createShader(f.VERTEX_SHADER));f.shaderSource(C,y);f.compileShader(C);if(!f.getShaderParameter(C, -f.COMPILE_STATUS)){alert(f.getShaderInfoLog(C));return null}return C}function L(m){switch(m){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return f.LINEAR}}function Y(m){switch(m){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT; +o.__webGLSkinVertexABuffer);f.vertexAttribPointer(m.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);f.vertexAttribPointer(m.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);f.vertexAttribPointer(m.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);f.vertexAttribPointer(m.skinWeight,4,f.FLOAT,!1,0,0)}if(C instanceof THREE.Mesh)if(l.wireframe){f.lineWidth(l.wireframeLinewidth);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, +o.__webGLLineBuffer);f.drawElements(f.LINES,o.__webGLLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);f.drawElements(f.TRIANGLES,o.__webGLFaceCount,f.UNSIGNED_SHORT,0)}else if(C instanceof THREE.Line){C=C.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(l.linewidth);f.drawArrays(C,0,o.__webGLLineCount)}else if(C instanceof THREE.ParticleSystem)f.drawArrays(f.POINTS,0,o.__webGLParticleCount);else C instanceof THREE.Ribbon&&f.drawArrays(f.TRIANGLE_STRIP, +0,o.__webGLVertexCount)}function g(m,z){if(!m.__webGLVertexBuffer)m.__webGLVertexBuffer=f.createBuffer();if(!m.__webGLNormalBuffer)m.__webGLNormalBuffer=f.createBuffer();if(m.hasPos){f.bindBuffer(f.ARRAY_BUFFER,m.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,m.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(z.attributes.position);f.vertexAttribPointer(z.attributes.position,3,f.FLOAT,!1,0,0)}if(m.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,m.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,m.normalArray, +f.DYNAMIC_DRAW);f.enableVertexAttribArray(z.attributes.normal);f.vertexAttribPointer(z.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,m.count);m.count=0}function h(m){if(ea!=m.doubleSided){m.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);ea=m.doubleSided}if(H!=m.flipSided){m.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);H=m.flipSided}}function j(m){if(wa!=m){m?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);wa=m}}function k(m){sa[0].set(m.n41-m.n11,m.n42-m.n12,m.n43-m.n13, +m.n44-m.n14);sa[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);sa[2].set(m.n41+m.n21,m.n42+m.n22,m.n43+m.n23,m.n44+m.n24);sa[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);sa[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);sa[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+m.n34);var z;for(m=0;m<6;m++){z=sa[m];z.divideScalar(Math.sqrt(z.x*z.x+z.y*z.y+z.z*z.z))}}function n(m){for(var z=m.matrixWorld,p=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y, +m.scale.z)),l=0;l<6;l++){m=sa[l].x*z.n14+sa[l].y*z.n24+sa[l].z*z.n34+sa[l].w;if(m<=p)return!1}return!0}function q(m,z){m.list[m.count]=z;m.count+=1}function x(m){var z,p,l=m.object,o=m.opaque,C=m.transparent;C.count=0;m=o.count=0;for(z=l.materials.length;m65535){P[N].counter+=1;L=P[N].hash+"_"+P[N].counter;m.geometryGroups[L]== +undefined&&(m.geometryGroups[L]={faces:[],materials:G,vertices:0})}m.geometryGroups[L].faces.push(o);m.geometryGroups[L].vertices+=B}}function E(m,z,p){m.push({buffer:z,object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function v(m){if(m!=ba){switch(m){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA, +f.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:f.blendEquation(f.FUNC_REVERSE_SUBTRACT);f.blendFunc(f.ONE,f.ONE);break;default:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA)}ba=m}}function F(m,z,p){if((p.width&p.width-1)==0&&(p.height&p.height-1)==0){f.texParameteri(m,f.TEXTURE_WRAP_S,Z(z.wrapS));f.texParameteri(m,f.TEXTURE_WRAP_T,Z(z.wrapT));f.texParameteri(m,f.TEXTURE_MAG_FILTER,Z(z.magFilter));f.texParameteri(m,f.TEXTURE_MIN_FILTER,Z(z.minFilter));f.generateMipmap(m)}else{f.texParameteri(m, +f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(m,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(m,f.TEXTURE_MAG_FILTER,K(z.magFilter));f.texParameteri(m,f.TEXTURE_MIN_FILTER,K(z.minFilter))}}function w(m){if(m&&!m.__webGLFramebuffer){m.__webGLFramebuffer=f.createFramebuffer();m.__webGLRenderbuffer=f.createRenderbuffer();m.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,m.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,m.width,m.height);f.bindTexture(f.TEXTURE_2D, +m.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,Z(m.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,Z(m.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,Z(m.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,Z(m.minFilter));f.texImage2D(f.TEXTURE_2D,0,Z(m.format),m.width,m.height,0,Z(m.format),Z(m.type),null);f.bindFramebuffer(f.FRAMEBUFFER,m.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,m.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER, +f.DEPTH_ATTACHMENT,f.RENDERBUFFER,m.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var z,p;if(m){z=m.__webGLFramebuffer;p=m.width;m=m.height}else{z=null;p=ha;m=fa}if(z!=T){f.bindFramebuffer(f.FRAMEBUFFER,z);f.viewport(da,ua,p,m);T=z}}function O(m,z){var p;if(m=="fragment")p=f.createShader(f.FRAGMENT_SHADER);else m=="vertex"&&(p=f.createShader(f.VERTEX_SHADER));f.shaderSource(p,z);f.compileShader(p);if(!f.getShaderParameter(p, +f.COMPILE_STATUS)){alert(f.getShaderInfoLog(p));return null}return p}function K(m){switch(m){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return f.LINEAR}}function Z(m){switch(m){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT; case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT; -case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var M=document.createElement("canvas"),f,V=null,S=null,ba=this,ea=null,J=null,ca=null,wa=null,da=0,ta=0,ha=0,fa=0,ra=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, -new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],xa=new THREE.Matrix4,ga=new Float32Array(16),aa=new Float32Array(16),oa=new THREE.Vector4,pa=!0,R=new THREE.Color(0),ia=0;if(a){if(a.antialias!==undefined)pa=a.antialias;a.clearColor!==undefined&&R.setHex(a.clearColor);if(a.clearAlpha!==undefined)ia=a.clearAlpha}this.domElement=M;this.autoClear=!0;this.sortObjects=!0;(function(m,y,C){try{if(!(f=M.getContext("experimental-webgl",{antialias:m})))throw"Error creating WebGL context.";}catch(l){console.error(l)}f.clearColor(0, -0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA);f.clearColor(y.r,y.g,y.b,C);_cullEnabled=!0})(pa,R,ia);this.context=f;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(m,y){M.width=m;M.height=y;this.setViewport(0,0,M.width,M.height)};this.setViewport=function(m,y,C,l){da=m; -ta=y;ha=C;fa=l;f.viewport(da,ta,ha,fa)};this.setScissor=function(m,y,C,l){f.scissor(m,y,C,l)};this.enableScissorTest=function(m){m?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.setClearColorHex=function(m,y){var C=new THREE.Color(m);f.clearColor(C.r,C.g,C.b,y)};this.setClearColor=function(m,y){f.clearColor(m.r,m.g,m.b,y)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT)};this.initMaterial=function(m,y,C){var l,o;if(m instanceof THREE.MeshDepthMaterial)b(m,THREE.ShaderLib.depth); -else if(m instanceof THREE.MeshNormalMaterial)b(m,THREE.ShaderLib.normal);else if(m instanceof THREE.MeshBasicMaterial)b(m,THREE.ShaderLib.basic);else if(m instanceof THREE.MeshLambertMaterial)b(m,THREE.ShaderLib.lambert);else if(m instanceof THREE.MeshPhongMaterial)b(m,THREE.ShaderLib.phong);else if(m instanceof THREE.LineBasicMaterial)b(m,THREE.ShaderLib.basic);else m instanceof THREE.ParticleBasicMaterial&&b(m,THREE.ShaderLib.particle_basic);var z,A,D,P;o=D=P=0;for(z=y.length;o0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+z.maxDirLights,"#define MAX_POINT_LIGHTS "+z.maxPointLights,z.map?"#define USE_MAP":"",z.envMap?"#define USE_ENVMAP":"",z.lightMap? -"#define USE_LIGHTMAP":"",z.vertexColors?"#define USE_COLOR":"",z.skinning?"#define USE_SKINNING":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); -f.attachShader(C,N("fragment",o+P));f.attachShader(C,N("vertex",z+y));f.linkProgram(C);f.getProgramParameter(C,f.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+f.getProgramParameter(C,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");C.uniforms={};C.attributes={};m.program=C;C=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(l in m.uniforms)C.push(l);l=m.program;P=0;for(y=C.length;P< -y;P++){o=C[P];l.uniforms[o]=f.getUniformLocation(l,o)}l=m.program;C=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];P=0;for(y=C.length;P=0&&f.enableVertexAttribArray(l.color);l.normal>=0&&f.enableVertexAttribArray(l.normal);l.tangent>=0&&f.enableVertexAttribArray(l.tangent);if(m.skinning&&l.skinVertexA>=0&&l.skinVertexB>= -0&&l.skinIndex>=0&&l.skinWeight>=0){f.enableVertexAttribArray(l.skinVertexA);f.enableVertexAttribArray(l.skinVertexB);f.enableVertexAttribArray(l.skinIndex);f.enableVertexAttribArray(l.skinWeight)}};this.render=function(m,y,C,l){var o,z,A,D,P,H,O,la,ua=m.lights,ja=m.fog;y.matrixAutoUpdate&&y.update();y.matrixWorldInverse.flattenToArray(aa);y.projectionMatrix.flattenToArray(ga);xa.multiply(y.projectionMatrix,y.matrixWorldInverse);k(xa);m.update(undefined,!1,y);this.initWebGLObjects(m,y);v(C);(this.autoClear|| -l)&&this.clear();P=m.__webglObjects.length;for(l=0;l=0;o--){l=C.__webglObjects[o].object;y==l&&C.__webglObjects.splice(o,1)}m.__objectsRemoved.splice(0,1)}y=0;for(C=m.__webglObjects.length;y0){f.bindBuffer(f.ARRAY_BUFFER,A.__webGLUVBuffer);f.bufferData(f.ARRAY_BUFFER,Ma,la)}if(Ja&&ja>0){f.bindBuffer(f.ARRAY_BUFFER,A.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER, -Qa,la)}if(Oa){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,$,la);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,na,la)}if(I>0){f.bindBuffer(f.ARRAY_BUFFER,A.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,G,la);f.bindBuffer(f.ARRAY_BUFFER,A.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,W,la);f.bindBuffer(f.ARRAY_BUFFER,A.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,T,la);f.bindBuffer(f.ARRAY_BUFFER, -A.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,K,la)}}}o.__dirtyVertices=!1;o.__dirtyElements=!1;o.__dirtyUvs=!1;o.__dirtyNormals=!1;o.__dirtyTangents=!1;o.__dirtyColors=!1}else if(l instanceof THREE.Ribbon){o=l.geometry;if(o.__dirtyVertices||o.__dirtyColors){l=o;z=f.DYNAMIC_DRAW;H=void 0;H=void 0;D=void 0;A=void 0;O=l.vertices;la=l.colors;ja=O.length;ua=la.length;ka=l.__vertexArray;P=l.__colorArray;sa=l.__dirtyColors;if(l.__dirtyVertices){for(H=0;H0}}; +case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var M=document.createElement("canvas"),f,V=null,T=null,ca=this,ea=null,H=null,ba=null,wa=null,da=0,ua=0,ha=0,fa=0,sa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, +new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],xa=new THREE.Matrix4,ga=new Float32Array(16),aa=new Float32Array(16),la=new THREE.Vector4,ma={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},R=!0,ia=new THREE.Color(0),pa=0;if(a){if(a.antialias!==undefined)R=a.antialias;a.clearColor!==undefined&&ia.setHex(a.clearColor);if(a.clearAlpha!==undefined)pa=a.clearAlpha}this.domElement=M;this.autoClear=!0;this.sortObjects=!0;(function(m,z,p){try{if(!(f= +M.getContext("experimental-webgl",{antialias:m})))throw"Error creating WebGL context.";}catch(l){console.error(l)}f.clearColor(0,0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA);f.clearColor(z.r,z.g,z.b,p);_cullEnabled=!0})(R,ia,pa);this.context=f;this.setSize=function(m,z){M.width=m;M.height=z;this.setViewport(0,0,M.width,M.height)};this.setViewport=function(m, +z,p,l){da=m;ua=z;ha=p;fa=l;f.viewport(da,ua,ha,fa)};this.setScissor=function(m,z,p,l){f.scissor(m,z,p,l)};this.enableScissorTest=function(m){m?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.setClearColorHex=function(m,z){var p=new THREE.Color(m);f.clearColor(p.r,p.g,p.b,z)};this.setClearColor=function(m,z){f.clearColor(m.r,m.g,m.b,z)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT)};this.initMaterial=function(m,z,p){var l,o;if(m instanceof THREE.MeshDepthMaterial)b(m, +THREE.ShaderLib.depth);else if(m instanceof THREE.MeshNormalMaterial)b(m,THREE.ShaderLib.normal);else if(m instanceof THREE.MeshBasicMaterial)b(m,THREE.ShaderLib.basic);else if(m instanceof THREE.MeshLambertMaterial)b(m,THREE.ShaderLib.lambert);else if(m instanceof THREE.MeshPhongMaterial)b(m,THREE.ShaderLib.phong);else if(m instanceof THREE.LineBasicMaterial)b(m,THREE.ShaderLib.basic);else m instanceof THREE.ParticleBasicMaterial&&b(m,THREE.ShaderLib.particle_basic);var C,B,G,N;o=G=N=0;for(C=z.length;o< +C;o++){B=z[o];B instanceof THREE.DirectionalLight&&G++;B instanceof THREE.PointLight&&N++}if(N+G<=4)z=G;else{z=Math.ceil(4*G/(N+G));N=4-z}o={directional:z,point:N};N=m.fragmentShader;z=m.vertexShader;C={fog:p,map:m.map,envMap:m.envMap,lightMap:m.lightMap,vertexColors:m.vertexColors,skinning:m.skinning,maxDirLights:o.directional,maxPointLights:o.point};p=f.createProgram();o=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+C.maxDirLights,"#define MAX_POINT_LIGHTS "+C.maxPointLights, +C.fog?"#define USE_FOG":"",C.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",C.map?"#define USE_MAP":"",C.envMap?"#define USE_ENVMAP":"",C.lightMap?"#define USE_LIGHTMAP":"",C.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");C=[f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+C.maxDirLights,"#define MAX_POINT_LIGHTS "+C.maxPointLights,C.map?"#define USE_MAP":"",C.envMap?"#define USE_ENVMAP": +"",C.lightMap?"#define USE_LIGHTMAP":"",C.vertexColors?"#define USE_COLOR":"",C.skinning?"#define USE_SKINNING":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); +f.attachShader(p,O("fragment",o+N));f.attachShader(p,O("vertex",C+z));f.linkProgram(p);f.getProgramParameter(p,f.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+f.getProgramParameter(p,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");p.uniforms={};p.attributes={};m.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(l in m.uniforms)p.push(l);l=m.program;N=0;for(z=p.length;N< +z;N++){o=p[N];l.uniforms[o]=f.getUniformLocation(l,o)}l=m.program;p=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];N=0;for(z=p.length;N=0&&f.enableVertexAttribArray(l.color);l.normal>=0&&f.enableVertexAttribArray(l.normal);l.tangent>=0&&f.enableVertexAttribArray(l.tangent);if(m.skinning&&l.skinVertexA>=0&&l.skinVertexB>= +0&&l.skinIndex>=0&&l.skinWeight>=0){f.enableVertexAttribArray(l.skinVertexA);f.enableVertexAttribArray(l.skinVertexB);f.enableVertexAttribArray(l.skinIndex);f.enableVertexAttribArray(l.skinWeight)}};this.render=function(m,z,p,l){var o,C,B,G,N,L,P,ka,ja=m.lights,qa=m.fog;z.matrixAutoUpdate&&z.update();z.matrixWorldInverse.flattenToArray(aa);z.projectionMatrix.flattenToArray(ga);xa.multiply(z.projectionMatrix,z.matrixWorldInverse);k(xa);m.update(undefined,!1,z);this.initWebGLObjects(m);w(p);(this.autoClear|| +l)&&this.clear();N=m.__webglObjects.length;for(l=0;l=0;o--){l=p.__webglObjects[o].object;z==l&&p.__webglObjects.splice(o,1)}m.__objectsRemoved.splice(0,1)}z=0;for(p=m.__webglObjects.length;z0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLUVBuffer);f.bufferData(f.ARRAY_BUFFER,Qa,ka)}if(Ka&&qa>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,Ta,ka)}if(Ja){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, +B.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,ta,ka);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,B.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,va,ka)}if(D>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,Y,ka);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,U,ka);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,J,ka);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER, +S,ka)}}}o.__dirtyVertices=!1;o.__dirtyElements=!1;o.__dirtyUvs=!1;o.__dirtyNormals=!1;o.__dirtyTangents=!1;o.__dirtyColors=!1}else if(l instanceof THREE.Ribbon){o=l.geometry;if(o.__dirtyVertices||o.__dirtyColors){l=o;C=f.DYNAMIC_DRAW;L=void 0;L=void 0;G=void 0;B=void 0;P=l.vertices;ka=l.colors;qa=P.length;ja=ka.length;ra=l.__vertexArray;N=l.__colorArray;na=l.__dirtyColors;if(l.__dirtyVertices){for(L=0;L0}}; THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif", envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif", envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif", @@ -278,17 +278,17 @@ THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"ve 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,e=b.length;for(d=0;d25&&(g=25);e=(g-1)*0.5;b=Array(g);for(c=d=0;c25&&(g=25);e=(g-1)*0.5;b=Array(g);for(c=d=0;c0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,j,t)))-1);n.push(p)}c.push(n)}var q,x,B;e=c.length;for(b=0;b0)for(d=0;d1){q=this.vertices[h].position.clone(); -x=this.vertices[k].position.clone();B=this.vertices[n].position.clone();q.normalize();x.normalize();B.normalize();this.faces.push(new THREE.Face3(h,k,n,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([p,w,E])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Sphere=function(a,c,b){THREE.Geometry.call(this);var d,e=Math.PI,g=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,j,u)))-1);n.push(q)}c.push(n)}var t,y,A;e=c.length;for(b=0;b0)for(d=0;d1){t=this.vertices[h].position.clone(); +y=this.vertices[k].position.clone();A=this.vertices[n].position.clone();t.normalize();y.normalize();A.normalize();this.faces.push(new THREE.Face3(h,k,n,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([q,x,E])}}}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 e=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));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;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -var Icosahedron=function(a){function c(w,t,q){var x=Math.sqrt(w*w+t*t+q*q);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(w/x,t/x,q/x)))-1}function b(w,t,q,x){x.faces.push(new THREE.Face3(w,t,q))}function d(w,t){var q=e.vertices[w].position,x=e.vertices[t].position;return c((q.x+x.x)/2,(q.y+x.y)/2,(q.z+x.z)/2)}var e=this,g=new THREE.Geometry,h;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;a=this.maxCount-3&&j(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&&(k=this.size-1);var t=Math.floor(n-j);t<1&&(t=1);n=Math.floor(n+j);n>this.size-1&&(n=this.size-1);var q=Math.floor(p-j);q<1&&(q=1);j=Math.floor(p+j); -j>this.size-1&&(j=this.size-1);for(var x,B,E,u,F,v;w0&&(this.field[E+x]+=u)}}}};this.addPlaneX=function(b,d){var e,g,h,j,k,n=this.size,p=this.yd,w=this.zd,t=this.field,q=n*Math.sqrt(b/d);q>n&&(q=n);for(e=0;e0)for(g=0;gp&&(x=p);for(g=0;g0){k=g*w;for(e=0;esize&&(dist=size);for(h=0;h0){k=zd*h;for(g=0;gthis.size-1&&(k=this.size-1);var u=Math.floor(n-j);u<1&&(u=1);n=Math.floor(n+j);n>this.size-1&&(n=this.size-1);var t=Math.floor(q-j);t<1&&(t=1);j=Math.floor(q+j); +j>this.size-1&&(j=this.size-1);for(var y,A,E,v,F,w;x0&&(this.field[E+y]+=v)}}}};this.addPlaneX=function(b,d){var e,g,h,j,k,n=this.size,q=this.yd,x=this.zd,u=this.field,t=n*Math.sqrt(b/d);t>n&&(t=n);for(e=0;e0)for(g=0;gq&&(y=q);for(g=0;g0){k=g*x;for(e=0;esize&&(dist=size);for(h=0;h0){k=zd*h;for(g=0;g>7)-127;z|=(D&127)<<16|A<<8;if(z==0&&H==-127)return 0;return(1-2*(P>>7))*(1+z*Math.pow(2,-23))*Math.pow(2,H)}function j(l,o){var z=p(l,o),A=p(l,o+1),D=p(l,o+2);return(p(l,o+3)<<24)+(D<<16)+(A<<8)+z}function k(l,o){var z=p(l,o);return(p(l,o+1)<<8)+z}function n(l,o){var z=p(l,o);return z>127?z-256:z}function p(l,o){return l.charCodeAt(o)&255}function w(l){var o,z,A;o=j(a,l); -z=j(a,l+Y);A=j(a,l+M);l=k(a,l+f);THREE.Loader.prototype.f3(u,o,z,A,l)}function t(l){var o,z,A,D,P,H;o=j(a,l);z=j(a,l+Y);A=j(a,l+M);D=k(a,l+f);P=j(a,l+V);H=j(a,l+S);l=j(a,l+ba);THREE.Loader.prototype.f3n(u,N,o,z,A,D,P,H,l)}function q(l){var o,z,A,D;o=j(a,l);z=j(a,l+ea);A=j(a,l+J);D=j(a,l+ca);l=k(a,l+wa);THREE.Loader.prototype.f4(u,o,z,A,D,l)}function x(l){var o,z,A,D,P,H,O,la;o=j(a,l);z=j(a,l+ea);A=j(a,l+J);D=j(a,l+ca);P=k(a,l+wa);H=j(a,l+da);O=j(a,l+ta);la=j(a,l+ha);l=j(a,l+fa);THREE.Loader.prototype.f4n(u, -N,o,z,A,D,P,H,O,la,l)}function B(l){var o,z;o=j(a,l);z=j(a,l+ra);l=j(a,l+xa);THREE.Loader.prototype.uv3(u.uvs,L[o*2],L[o*2+1],L[z*2],L[z*2+1],L[l*2],L[l*2+1])}function E(l){var o,z,A;o=j(a,l);z=j(a,l+ga);A=j(a,l+aa);l=j(a,l+oa);THREE.Loader.prototype.uv4(u.uvs,L[o*2],L[o*2+1],L[z*2],L[z*2+1],L[A*2],L[A*2+1],L[l*2],L[l*2+1])}var u=this,F=0,v,N=[],L=[],Y,M,f,V,S,ba,ea,J,ca,wa,da,ta,ha,fa,ra,xa,ga,aa,oa,pa,R,ia,m,y,C;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,d,g);v={signature:a.substr(F, -8),header_bytes:p(a,F+8),vertex_coordinate_bytes:p(a,F+9),normal_coordinate_bytes:p(a,F+10),uv_coordinate_bytes:p(a,F+11),vertex_index_bytes:p(a,F+12),normal_index_bytes:p(a,F+13),uv_index_bytes:p(a,F+14),material_index_bytes:p(a,F+15),nvertices:j(a,F+16),nnormals:j(a,F+16+4),nuvs:j(a,F+16+8),ntri_flat:j(a,F+16+12),ntri_smooth:j(a,F+16+16),ntri_flat_uv:j(a,F+16+20),ntri_smooth_uv:j(a,F+16+24),nquad_flat:j(a,F+16+28),nquad_smooth:j(a,F+16+32),nquad_flat_uv:j(a,F+16+36),nquad_smooth_uv:j(a,F+16+40)}; -F+=v.header_bytes;Y=v.vertex_index_bytes;M=v.vertex_index_bytes*2;f=v.vertex_index_bytes*3;V=v.vertex_index_bytes*3+v.material_index_bytes;S=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes;ba=v.vertex_index_bytes*3+v.material_index_bytes+v.normal_index_bytes*2;ea=v.vertex_index_bytes;J=v.vertex_index_bytes*2;ca=v.vertex_index_bytes*3;wa=v.vertex_index_bytes*4;da=v.vertex_index_bytes*4+v.material_index_bytes;ta=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes;ha= -v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*2;fa=v.vertex_index_bytes*4+v.material_index_bytes+v.normal_index_bytes*3;ra=v.uv_index_bytes;xa=v.uv_index_bytes*2;ga=v.uv_index_bytes;aa=v.uv_index_bytes*2;oa=v.uv_index_bytes*3;g=v.vertex_index_bytes*3+v.material_index_bytes;C=v.vertex_index_bytes*4+v.material_index_bytes;pa=v.ntri_flat*g;R=v.ntri_smooth*(g+v.normal_index_bytes*3);ia=v.ntri_flat_uv*(g+v.uv_index_bytes*3);m=v.ntri_smooth_uv*(g+v.normal_index_bytes*3+v.uv_index_bytes* -3);y=v.nquad_flat*C;g=v.nquad_smooth*(C+v.normal_index_bytes*4);C=v.nquad_flat_uv*(C+v.uv_index_bytes*4);F+=function(l){for(var o,z,A,D=v.vertex_coordinate_bytes*3,P=l+v.nvertices*D;l>7)-127;o|=(B&127)<<16|C<<8;if(o==0&&N==-127)return 0;return(1-2*(G>>7))*(1+o*Math.pow(2,-23))*Math.pow(2,N)}function j(p,l){var o=q(p,l),C=q(p,l+1),B=q(p,l+2);return(q(p,l+3)<<24)+(B<<16)+(C<<8)+o}function k(p,l){var o=q(p,l);return(q(p,l+1)<<8)+o}function n(p,l){var o=q(p,l);return o>127?o-256:o}function q(p,l){return p.charCodeAt(l)&255}function x(p){var l,o,C;l=j(a,p); +o=j(a,p+Z);C=j(a,p+M);p=k(a,p+f);THREE.Loader.prototype.f3(v,l,o,C,p)}function u(p){var l,o,C,B,G,N;l=j(a,p);o=j(a,p+Z);C=j(a,p+M);B=k(a,p+f);G=j(a,p+V);N=j(a,p+T);p=j(a,p+ca);THREE.Loader.prototype.f3n(v,O,l,o,C,B,G,N,p)}function t(p){var l,o,C,B;l=j(a,p);o=j(a,p+ea);C=j(a,p+H);B=j(a,p+ba);p=k(a,p+wa);THREE.Loader.prototype.f4(v,l,o,C,B,p)}function y(p){var l,o,C,B,G,N,L,P;l=j(a,p);o=j(a,p+ea);C=j(a,p+H);B=j(a,p+ba);G=k(a,p+wa);N=j(a,p+da);L=j(a,p+ua);P=j(a,p+ha);p=j(a,p+fa);THREE.Loader.prototype.f4n(v, +O,l,o,C,B,G,N,L,P,p)}function A(p){var l,o;l=j(a,p);o=j(a,p+sa);p=j(a,p+xa);THREE.Loader.prototype.uv3(v.uvs,K[l*2],K[l*2+1],K[o*2],K[o*2+1],K[p*2],K[p*2+1])}function E(p){var l,o,C;l=j(a,p);o=j(a,p+ga);C=j(a,p+aa);p=j(a,p+la);THREE.Loader.prototype.uv4(v.uvs,K[l*2],K[l*2+1],K[o*2],K[o*2+1],K[C*2],K[C*2+1],K[p*2],K[p*2+1])}var v=this,F=0,w,O=[],K=[],Z,M,f,V,T,ca,ea,H,ba,wa,da,ua,ha,fa,sa,xa,ga,aa,la,ma,R,ia,pa,m,z;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,d,g);w={signature:a.substr(F, +8),header_bytes:q(a,F+8),vertex_coordinate_bytes:q(a,F+9),normal_coordinate_bytes:q(a,F+10),uv_coordinate_bytes:q(a,F+11),vertex_index_bytes:q(a,F+12),normal_index_bytes:q(a,F+13),uv_index_bytes:q(a,F+14),material_index_bytes:q(a,F+15),nvertices:j(a,F+16),nnormals:j(a,F+16+4),nuvs:j(a,F+16+8),ntri_flat:j(a,F+16+12),ntri_smooth:j(a,F+16+16),ntri_flat_uv:j(a,F+16+20),ntri_smooth_uv:j(a,F+16+24),nquad_flat:j(a,F+16+28),nquad_smooth:j(a,F+16+32),nquad_flat_uv:j(a,F+16+36),nquad_smooth_uv:j(a,F+16+40)}; +F+=w.header_bytes;Z=w.vertex_index_bytes;M=w.vertex_index_bytes*2;f=w.vertex_index_bytes*3;V=w.vertex_index_bytes*3+w.material_index_bytes;T=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes;ca=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*2;ea=w.vertex_index_bytes;H=w.vertex_index_bytes*2;ba=w.vertex_index_bytes*3;wa=w.vertex_index_bytes*4;da=w.vertex_index_bytes*4+w.material_index_bytes;ua=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes;ha= +w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*2;fa=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*3;sa=w.uv_index_bytes;xa=w.uv_index_bytes*2;ga=w.uv_index_bytes;aa=w.uv_index_bytes*2;la=w.uv_index_bytes*3;g=w.vertex_index_bytes*3+w.material_index_bytes;z=w.vertex_index_bytes*4+w.material_index_bytes;ma=w.ntri_flat*g;R=w.ntri_smooth*(g+w.normal_index_bytes*3);ia=w.ntri_flat_uv*(g+w.uv_index_bytes*3);pa=w.ntri_smooth_uv*(g+w.normal_index_bytes*3+w.uv_index_bytes* +3);m=w.nquad_flat*z;g=w.nquad_smooth*(z+w.normal_index_bytes*4);z=w.nquad_flat_uv*(z+w.uv_index_bytes*4);F+=function(p){for(var l,o,C,B=w.vertex_coordinate_bytes*3,G=p+w.nvertices*B;p0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +this.vertices[f.c].normal.copy(f.vertexNormals[2]);this.vertices[f.d].normal.copy(f.vertexNormals[3])}}b=0;for(d=this.vertices.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,d=this.vertices.length;bthis.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.z< this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b65535){v[x].counter+=1;s=v[x].hash+"_"+v[x].counter;e.geometryGroups[s]==undefined&&(e.geometryGroups[s]={faces:[],materials:r,vertices:0})}e.geometryGroups[s].faces.push(i); @@ -138,16 +138,16 @@ c.TEXTURE_WRAP_S,Y(e.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,Y(e.w c.RENDERBUFFER,e.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var j,k;if(e){j=e.__webGLFramebuffer;k=e.width;e=e.height}else{j=null;k=Ea;e=Fa}if(j!=la){c.bindFramebuffer(c.FRAMEBUFFER,j);c.viewport(va,Da,k,e);la=j}}function ca(e,j){var k;if(e=="fragment")k=c.createShader(c.FRAGMENT_SHADER);else e=="vertex"&&(k=c.createShader(c.VERTEX_SHADER));c.shaderSource(k,j);c.compileShader(k);if(!c.getShaderParameter(k,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(k)); return null}return k}function aa(e){switch(e){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return c.LINEAR}}function Y(e){switch(e){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST; case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT; -case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var fa=document.createElement("canvas"),c,na=null,la=null,oa=this,pa=null,qa=null,za=null,Aa=null,va=0,Da=0,Ea=0,Fa=0,ra=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ga=new THREE.Matrix4,Pa=new Float32Array(16),Ja=new Float32Array(16), -Ba=new THREE.Vector4,Qa=!0,Ra=new THREE.Color(0),Sa=0;if(a){if(a.antialias!==undefined)Qa=a.antialias;a.clearColor!==undefined&&Ra.setHex(a.clearColor);if(a.clearAlpha!==undefined)Sa=a.clearAlpha}this.domElement=fa;this.autoClear=!0;this.sortObjects=!0;(function(e,j,k){try{if(!(c=fa.getContext("experimental-webgl",{antialias:e})))throw"Error creating WebGL context.";}catch(g){console.error(g)}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK); -c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(j.r,j.g,j.b,k);_cullEnabled=!0})(Qa,Ra,Sa);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(e,j){fa.width=e;fa.height=j;this.setViewport(0,0,fa.width,fa.height)};this.setViewport=function(e,j,k,g){va=e;Da=j;Ea=k;Fa=g;c.viewport(va,Da,Ea,Fa)};this.setScissor=function(e,j,k,g){c.scissor(e,j,k,g)};this.enableScissorTest= +case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var fa=document.createElement("canvas"),c,na=null,la=null,ta=this,oa=null,pa=null,za=null,Aa=null,va=0,Da=0,Ea=0,Fa=0,qa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ga=new THREE.Matrix4,Pa=new Float32Array(16),Ja=new Float32Array(16), +Ba=new THREE.Vector4,Qa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Ra=!0,Sa=new THREE.Color(0),Ta=0;if(a){if(a.antialias!==undefined)Ra=a.antialias;a.clearColor!==undefined&&Sa.setHex(a.clearColor);if(a.clearAlpha!==undefined)Ta=a.clearAlpha}this.domElement=fa;this.autoClear=!0;this.sortObjects=!0;(function(e,j,k){try{if(!(c=fa.getContext("experimental-webgl",{antialias:e})))throw"Error creating WebGL context.";}catch(g){console.error(g)}c.clearColor(0, +0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(j.r,j.g,j.b,k);_cullEnabled=!0})(Ra,Sa,Ta);this.context=c;this.setSize=function(e,j){fa.width=e;fa.height=j;this.setViewport(0,0,fa.width,fa.height)};this.setViewport=function(e,j,k,g){va=e;Da=j;Ea=k;Fa=g;c.viewport(va,Da,Ea,Fa)};this.setScissor=function(e,j,k,g){c.scissor(e,j,k,g)};this.enableScissorTest= function(e){e?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.setClearColorHex=function(e,j){var k=new THREE.Color(e);c.clearColor(k.r,k.g,k.b,j)};this.setClearColor=function(e,j){c.clearColor(e.r,e.g,e.b,j)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.initMaterial=function(e,j,k){var g,i;if(e instanceof THREE.MeshDepthMaterial)d(e,THREE.ShaderLib.depth);else if(e instanceof THREE.MeshNormalMaterial)d(e,THREE.ShaderLib.normal);else if(e instanceof THREE.MeshBasicMaterial)d(e, THREE.ShaderLib.basic);else if(e instanceof THREE.MeshLambertMaterial)d(e,THREE.ShaderLib.lambert);else if(e instanceof THREE.MeshPhongMaterial)d(e,THREE.ShaderLib.phong);else if(e instanceof THREE.LineBasicMaterial)d(e,THREE.ShaderLib.basic);else e instanceof THREE.ParticleBasicMaterial&&d(e,THREE.ShaderLib.particle_basic);var u,o,r,x;i=r=x=0;for(u=j.length;i0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+u.maxDirLights,"#define MAX_POINT_LIGHTS "+u.maxPointLights,u.map?"#define USE_MAP":"",u.envMap?"#define USE_ENVMAP":"",u.lightMap?"#define USE_LIGHTMAP":"",u.vertexColors?"#define USE_COLOR":"",u.skinning?"#define USE_SKINNING":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); c.attachShader(k,ca("fragment",i+x));c.attachShader(k,ca("vertex",u+j));c.linkProgram(k);c.getProgramParameter(k,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(k,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");k.uniforms={};k.attributes={};e.program=k;k=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(g in e.uniforms)k.push(g);g=e.program;x=0;for(j=k.length;x< j;x++){i=k[x];g.uniforms[i]=c.getUniformLocation(g,i)}g=e.program;k=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];x=0;for(j=k.length;x=0&&c.enableVertexAttribArray(g.color);g.normal>=0&&c.enableVertexAttribArray(g.normal);g.tangent>=0&&c.enableVertexAttribArray(g.tangent);if(e.skinning&&g.skinVertexA>=0&&g.skinVertexB>= -0&&g.skinIndex>=0&&g.skinWeight>=0){c.enableVertexAttribArray(g.skinVertexA);c.enableVertexAttribArray(g.skinVertexB);c.enableVertexAttribArray(g.skinIndex);c.enableVertexAttribArray(g.skinWeight)}};this.render=function(e,j,k,g){var i,u,o,r,x,s,v,J,P=e.lights,N=e.fog;j.matrixAutoUpdate&&j.update();j.matrixWorldInverse.flattenToArray(Ja);j.projectionMatrix.flattenToArray(Pa);Ga.multiply(j.projectionMatrix,j.matrixWorldInverse);m(Ga);e.update(undefined,!1,j);this.initWebGLObjects(e,j);X(k);(this.autoClear|| +0&&g.skinIndex>=0&&g.skinWeight>=0){c.enableVertexAttribArray(g.skinVertexA);c.enableVertexAttribArray(g.skinVertexB);c.enableVertexAttribArray(g.skinIndex);c.enableVertexAttribArray(g.skinWeight)}};this.render=function(e,j,k,g){var i,u,o,r,x,s,v,J,P=e.lights,N=e.fog;j.matrixAutoUpdate&&j.update();j.matrixWorldInverse.flattenToArray(Ja);j.projectionMatrix.flattenToArray(Pa);Ga.multiply(j.projectionMatrix,j.matrixWorldInverse);m(Ga);e.update(undefined,!1,j);this.initWebGLObjects(e);X(k);(this.autoClear|| g)&&this.clear();x=e.__webglObjects.length;for(g=0;g=0;i--){g=k.__webglObjects[i].object;j==g&&k.__webglObjects.splice(i,1)}e.__objectsRemoved.splice(0,1)}j=0;for(k=e.__webglObjects.length;j0){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,Ha,J)}if(Ca&&N>0){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLUV2Buffer);c.bufferData(c.ARRAY_BUFFER,Ia,J)}if(La){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,sa,J);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,ja,J)}if(p>0){c.bindBuffer(c.ARRAY_BUFFER, +1;R[p+12]=O.x;R[p+13]=O.y;R[p+14]=O.z;R[p+15]=1;z=xa[t.a];B=xa[t.b];C=xa[t.c];O=xa[t.d];S[p]=z.x;S[p+1]=z.y;S[p+2]=z.z;S[p+3]=1;S[p+4]=B.x;S[p+5]=B.y;S[p+6]=B.z;S[p+7]=1;S[p+8]=C.x;S[p+9]=C.y;S[p+10]=C.z;S[p+11]=1;S[p+12]=O.x;S[p+13]=O.y;S[p+14]=O.z;S[p+15]=1;p+=16}if(Oa&&sa.length){z=sa[t.a];B=sa[t.b];C=sa[t.c];O=sa[t.d];$[W]=z.r;$[W+1]=z.g;$[W+2]=z.b;$[W+3]=B.r;$[W+4]=B.g;$[W+5]=B.b;$[W+6]=C.r;$[W+7]=C.g;$[W+8]=C.b;$[W+9]=O.r;$[W+10]=O.g;$[W+11]=O.b;W+=12}if(Na&&ea.hasTangents){z=ka[t.a].tangent; +B=ka[t.b].tangent;C=ka[t.c].tangent;t=ka[t.d].tangent;Q[G]=z.x;Q[G+1]=z.y;Q[G+2]=z.z;Q[G+3]=z.w;Q[G+4]=B.x;Q[G+5]=B.y;Q[G+6]=B.z;Q[G+7]=B.w;Q[G+8]=C.x;Q[G+9]=C.y;Q[G+10]=C.z;Q[G+11]=C.w;Q[G+12]=t.x;Q[G+13]=t.y;Q[G+14]=t.z;Q[G+15]=t.w;G+=16}if(Ma)if(da.length==4&&Ua)for(t=0;t<4;t++){ba=da[t];ma[K]=ba.x;ma[K+1]=ba.y;ma[K+2]=ba.z;K+=3}else for(t=0;t<4;t++){ma[K]=ba.x;ma[K+1]=ba.y;ma[K+2]=ba.z;K+=3}if(Ca&&ga)for(t=0;t<4;t++){da=ga[t];Ha[v]=da.u;Ha[v+1]=da.v;v+=2}if(Ca&&ha)for(t=0;t<4;t++){ga=ha[t];Ia[N]= +ga.u;Ia[N+1]=ga.v;N+=2}if(La){ra[I]=s;ra[I+1]=s+1;ra[I+2]=s+2;ra[I+3]=s;ra[I+4]=s+2;ra[I+5]=s+3;I+=6;ja[ia]=s;ja[ia+1]=s+1;ja[ia+2]=s;ja[ia+3]=s+3;ja[ia+4]=s+1;ja[ia+5]=s+2;ja[ia+6]=s+2;ja[ia+7]=s+3;ia+=8;s+=4}}}if(Ka){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Z,J)}if(Oa&&sa.length){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,$,J)}if(Ma){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ma,J)}if(Na&& +ea.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,Q,J)}if(Ca&&v>0){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,Ha,J)}if(Ca&&N>0){c.bindBuffer(c.ARRAY_BUFFER,o.__webGLUV2Buffer);c.bufferData(c.ARRAY_BUFFER,Ia,J)}if(La){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,ra,J);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,ja,J)}if(p>0){c.bindBuffer(c.ARRAY_BUFFER, o.__webGLSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,R,J);c.bindBuffer(c.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,S,J);c.bindBuffer(c.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,T,J);c.bindBuffer(c.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,U,J)}}}i.__dirtyVertices=!1;i.__dirtyElements=!1;i.__dirtyUvs=!1;i.__dirtyNormals=!1;i.__dirtyTangents=!1;i.__dirtyColors=!1}else if(g instanceof THREE.Ribbon){i=g.geometry;if(i.__dirtyVertices|| i.__dirtyColors){g=i;u=c.DYNAMIC_DRAW;s=void 0;s=void 0;r=void 0;o=void 0;v=g.vertices;J=g.colors;N=v.length;P=J.length;I=g.__vertexArray;x=g.__colorArray;K=g.__dirtyColors;if(g.__dirtyVertices){for(s=0;s