From 8227d9f11839bf859562fe7210e4c0418ffb6f78 Mon Sep 17 00:00:00 2001 From: alteredq Date: Thu, 3 Feb 2011 02:53:33 +0100 Subject: [PATCH] Added billboard particles (semi-opaque depth sorted). Work in progress, caveats: - sort happens just inside one ParticleSystems, so everything gets messed up when more ParticleSystems are in the same screen space - not yet solved proper order of operations, if you change object transform, you need to update ParticleSystem object matrix manually before rendering (so that sort works, otherwise it will use transform from previous frame) Also fixed transparency in fog and did small optimizations in WebGLRenderer. --- build/Three.js | 241 +++++++++-------- build/ThreeDebug.js | 243 ++++++++--------- build/ThreeExtras.js | 376 +++++++++++++------------- examples/particles_billboards_gl.html | 212 +++++++++++++++ examples/particles_random_gl.html | 2 - examples/particles_sprites_gl.html | 2 - examples/textures/sprites/circle.png | Bin 0 -> 5527 bytes src/materials/Material.js | 1 + src/objects/ParticleSystem.js | 2 + src/renderers/WebGLRenderer.js | 124 +++++++-- 10 files changed, 744 insertions(+), 459 deletions(-) create mode 100644 examples/particles_billboards_gl.html create mode 100644 examples/textures/sprites/circle.png diff --git a/build/Three.js b/build/Three.js index 46d1f967..2f17da18 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,6 +1,6 @@ // Three.js r32 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)}; -THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,i,b,n,o,l;if(d==0)e=i=b=0;else{n=Math.floor(a*6);o=a*6-n;a=d*(1-c);l=d*(1-c*o);c=d*(1-c*(1-o));switch(n){case 1:e=l;i=d;b=a;break;case 2:e=a;i=d;b=c;break;case 3:e=a;i=l;b=d;break;case 4:e=c;i=a;b=d;break;case 5:e=d;i=a;b=l;break;case 6:case 0:e=d;i=c;b=a}}this.r=e;this.g=i;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, +THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,i,b,n,o,k;if(d==0)e=i=b=0;else{n=Math.floor(a*6);o=a*6-n;a=d*(1-c);k=d*(1-c*o);c=d*(1-c*(1-o));switch(n){case 1:e=k;i=d;b=a;break;case 2:e=a;i=d;b=c;break;case 3:e=a;i=k;b=d;break;case 4:e=c;i=a;b=d;break;case 5:e=d;i=a;b=k;break;case 6:case 0:e=d;i=c;b=a}}this.r=e;this.g=i;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+ this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0}; THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* @@ -13,47 +13,47 @@ THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1} THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){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)},toString:function(){return"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,d,e=a.objects,i=[];a=0;for(c=e.length;a0&&I>0&&j+I<1}var d,e,i,b,n,o,l,m,z,y, -u,x=a.geometry,G=x.vertices,H=[];d=0;for(e=x.faces.length;dl?e:l;i=i>m? -i:m}a()};this.add3Points=function(l,m,z,y,u,x){if(o){o=false;c=lz?l>u?l:u:z>u?z:u;i=m>y?m>x?m:x:y>x?y:x}else{c=lz?l>u?l>e?l:e:u>e?u:e:z>u?z>e?z:e:u>e?u:e;i=m>y?m>x?m>i?m:i:x>i?x:i:y>x?y>i?y:i:x>i?x:i}a()};this.addRectangle=function(l){if(o){o=false;c=l.getLeft();d=l.getTop();e=l.getRight();i=l.getBottom()}else{c=cl.getRight()?e:l.getRight();i=i>l.getBottom()?i:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;e+=l;i+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();e=e=0&&Math.min(i,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){o=true;i=e=d=c=0;a()};this.isEmpty=function(){return o};this.toString= +THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,i=[];a=0;for(c=e.length;a0&&K>0&&j+K<1}var d,e,i,b,n,o,k,l,z,y, +w,x=a.geometry,I=x.vertices,J=[];d=0;for(e=x.faces.length;dk?e:k;i=i>l? +i:l}a()};this.add3Points=function(k,l,z,y,w,x){if(o){o=false;c=kz?k>w?k:w:z>w?z:w;i=l>y?l>x?l:x:y>x?y:x}else{c=kz?k>w?k>e?k:e:w>e?w:e:z>w?z>e?z:e:w>e?w:e;i=l>y?l>x?l>i?l:i:x>i?x:i:y>x?y>i?y:i:x>i?x:i}a()};this.addRectangle=function(k){if(o){o=false;c=k.getLeft();d=k.getTop();e=k.getRight();i=k.getBottom()}else{c=ck.getRight()?e:k.getRight();i=i>k.getBottom()?i:k.getBottom()}a()};this.inflate=function(k){c-=k;d-=k;e+=k;i+=k;a()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();d=d>k.getTop()?d:k.getTop();e=e=0&&Math.min(i,k.getBottom())-Math.max(d,k.getTop())>=0};this.empty=function(){o=true;i=e=d=c=0;a()};this.isEmpty=function(){return o};this.toString= function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+i+", width: "+b+", height: "+n+" )"}};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}}; -THREE.Matrix4=function(a,c,d,e,i,b,n,o,l,m,z,y,u,x,G,H){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=i||0;this.n22=b||1;this.n23=n||0;this.n24=o||0;this.n31=l||0;this.n32=m||0;this.n33=z||1;this.n34=y||0;this.n41=u||0;this.n42=x||0;this.n43=G||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,i,b,n,o,l,m,z,y,u,x,G,H){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=i;this.n22=b;this.n23=n;this.n24=o;this.n31=l;this.n32=m;this.n33=z;this.n34=y;this.n41=u;this.n42=x;this.n43=G;this.n44=H;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +THREE.Matrix4=function(a,c,d,e,i,b,n,o,k,l,z,y,w,x,I,J){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=i||0;this.n22=b||1;this.n23=n||0;this.n24=o||0;this.n31=k||0;this.n32=l||0;this.n33=z||1;this.n34=y||0;this.n41=w||0;this.n42=x||0;this.n43=I||0;this.n44=J||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,i,b,n,o,k,l,z,y,w,x,I,J){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=i;this.n22=b;this.n23=n;this.n24=o;this.n31=k;this.n32=l;this.n33=z;this.n34=y;this.n41=w;this.n42=x;this.n43=I;this.n44=J;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,i=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();i.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a); this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,i=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*i;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*i;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*i;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,i=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*i;a.y=this.n21*c+this.n22*d+this.n23* -e+this.n24*i;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*i;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*i;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 d=a.n11,e=a.n12,i=a.n13,b=a.n14,n=a.n21,o=a.n22,l=a.n23,m=a.n24,z=a.n31, -y=a.n32,u=a.n33,x=a.n34,G=a.n41,H=a.n42,I=a.n43,p=a.n44,g=c.n11,h=c.n12,f=c.n13,j=c.n14,s=c.n21,t=c.n22,k=c.n23,A=c.n24,q=c.n31,C=c.n32,r=c.n33,v=c.n34,D=c.n41,W=c.n42,E=c.n43,O=c.n44;this.n11=d*g+e*s+i*q+b*D;this.n12=d*h+e*t+i*C+b*W;this.n13=d*f+e*k+i*r+b*E;this.n14=d*j+e*A+i*v+b*O;this.n21=n*g+o*s+l*q+m*D;this.n22=n*h+o*t+l*C+m*W;this.n23=n*f+o*k+l*r+m*E;this.n24=n*j+o*A+l*v+m*O;this.n31=z*g+y*s+u*q+x*D;this.n32=z*h+y*t+u*C+x*W;this.n33=z*f+y*k+u*r+x*E;this.n34=z*j+y*A+u*v+x*O;this.n41=G*g+H*s+ -I*q+p*D;this.n42=G*h+H*t+I*C+p*W;this.n43=G*f+H*k+I*r+p*E;this.n44=G*j+H*A+I*v+p*O;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,i=this.n14,b=this.n21,n=this.n22,o=this.n23,l=this.n24,m=this.n31,z=this.n32,y=this.n33,u=this.n34,x=this.n41,G=this.n42,H=this.n43,I=this.n44,p=a.n11,g=a.n21,h=a.n31,f=a.n41,j=a.n12,s=a.n22,t=a.n32,k=a.n42,A=a.n13,q=a.n23,C=a.n33,r=a.n43,v=a.n14,D=a.n24,W=a.n34;a=a.n44;this.n11=c*p+d*g+e*h+i*f;this.n12=c*j+d*s+e*t+i*k;this.n13=c*A+d*q+e*C+i* -r;this.n14=c*v+d*D+e*W+i*a;this.n21=b*p+n*g+o*h+l*f;this.n22=b*j+n*s+o*t+l*k;this.n23=b*A+n*q+o*C+l*r;this.n24=b*v+n*D+o*W+l*a;this.n31=m*p+z*g+y*h+u*f;this.n32=m*j+z*s+y*t+u*k;this.n33=m*A+z*q+y*C+u*r;this.n34=m*v+z*D+y*W+u*a;this.n41=x*p+G*g+H*h+I*f;this.n42=x*j+G*s+H*t+I*k;this.n43=x*A+G*q+H*C+I*r;this.n44=x*v+G*D+H*W+I*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,d=this.n13,e=this.n14,i=this.n21,b=this.n22,n=this.n23,o=this.n24,l=this.n31,m=this.n32,z=this.n33,y=this.n34,u=this.n41,x=this.n42,G=this.n43,H=this.n44;return e*n*m*u-d*o*m*u-e*b*z*u+c*o*z*u+d*b*y*u-c*n*y*u-e*n*l*x+d*o*l*x+e*i*z*x-a*o*z*x-d*i*y*x+a*n*y*x+e*b*l*G-c*o*l*G-e*i*m*G+a*o*m*G+c*i*y*G-a*b*y*G-d*b*l*H+c*n*l*H+d*i*m*H-a*n*m*H-c*i*z*H+a*b*z*H},transpose:function(){function a(c,d, +e+this.n24*i;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*i;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*i;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 d=a.n11,e=a.n12,i=a.n13,b=a.n14,n=a.n21,o=a.n22,k=a.n23,l=a.n24,z=a.n31, +y=a.n32,w=a.n33,x=a.n34,I=a.n41,J=a.n42,K=a.n43,s=a.n44,T=c.n11,F=c.n12,f=c.n13,j=c.n14,g=c.n21,h=c.n22,m=c.n23,u=c.n24,p=c.n31,q=c.n32,r=c.n33,v=c.n34,t=c.n41,L=c.n42,D=c.n43,R=c.n44;this.n11=d*T+e*g+i*p+b*t;this.n12=d*F+e*h+i*q+b*L;this.n13=d*f+e*m+i*r+b*D;this.n14=d*j+e*u+i*v+b*R;this.n21=n*T+o*g+k*p+l*t;this.n22=n*F+o*h+k*q+l*L;this.n23=n*f+o*m+k*r+l*D;this.n24=n*j+o*u+k*v+l*R;this.n31=z*T+y*g+w*p+x*t;this.n32=z*F+y*h+w*q+x*L;this.n33=z*f+y*m+w*r+x*D;this.n34=z*j+y*u+w*v+x*R;this.n41=I*T+J*g+ +K*p+s*t;this.n42=I*F+J*h+K*q+s*L;this.n43=I*f+J*m+K*r+s*D;this.n44=I*j+J*u+K*v+s*R;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,i=this.n14,b=this.n21,n=this.n22,o=this.n23,k=this.n24,l=this.n31,z=this.n32,y=this.n33,w=this.n34,x=this.n41,I=this.n42,J=this.n43,K=this.n44,s=a.n11,T=a.n21,F=a.n31,f=a.n41,j=a.n12,g=a.n22,h=a.n32,m=a.n42,u=a.n13,p=a.n23,q=a.n33,r=a.n43,v=a.n14,t=a.n24,L=a.n34;a=a.n44;this.n11=c*s+d*T+e*F+i*f;this.n12=c*j+d*g+e*h+i*m;this.n13=c*u+d*p+e*q+i* +r;this.n14=c*v+d*t+e*L+i*a;this.n21=b*s+n*T+o*F+k*f;this.n22=b*j+n*g+o*h+k*m;this.n23=b*u+n*p+o*q+k*r;this.n24=b*v+n*t+o*L+k*a;this.n31=l*s+z*T+y*F+w*f;this.n32=l*j+z*g+y*h+w*m;this.n33=l*u+z*p+y*q+w*r;this.n34=l*v+z*t+y*L+w*a;this.n41=x*s+I*T+J*F+K*f;this.n42=x*j+I*g+J*h+K*m;this.n43=x*u+I*p+J*q+K*r;this.n44=x*v+I*t+J*L+K*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,d=this.n13,e=this.n14,i=this.n21,b=this.n22,n=this.n23,o=this.n24,k=this.n31,l=this.n32,z=this.n33,y=this.n34,w=this.n41,x=this.n42,I=this.n43,J=this.n44;return e*n*l*w-d*o*l*w-e*b*z*w+c*o*z*w+d*b*y*w-c*n*y*w-e*n*k*x+d*o*k*x+e*i*z*x-a*o*z*x-d*i*y*x+a*n*y*x+e*b*k*I-c*o*k*I-e*i*l*I+a*o*l*I+c*i*y*I-a*b*y*I-d*b*k*J+c*n*k*J+d*i*l*J-a*n*l*J-c*i*z*J+a*b*z*J},transpose:function(){function a(c,d, e){var i=c[d];c[d]=c[e];c[e]=i}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){var a=this.flat;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},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c= -Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),i=1-d,b=a.x,n=a.y,o=a.z,l=i*b,m=i*n;this.set(l*b+d,l*n-e*o,l*o+e*n,0,l*n+e*o,m*n+d,m*o-e*b,0,l*o-e*n,m*o+e*b,i*o*o+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+ +Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),i=1-d,b=a.x,n=a.y,o=a.z,k=i*b,l=i*n;this.set(k*b+d,k*n-e*o,k*o+e*n,0,k*n+e*o,l*n+d,l*o-e*b,0,k*o-e*n,l*o+e*b,i*o*o+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+ this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c}; THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d}; -THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,i=a.n14,b=a.n21,n=a.n22,o=a.n23,l=a.n24,m=a.n31,z=a.n32,y=a.n33,u=a.n34,x=a.n41,G=a.n42,H=a.n43,I=a.n44,p=new THREE.Matrix4;p.n11=o*u*G-l*y*G+l*z*H-n*u*H-o*z*I+n*y*I;p.n12=i*y*G-e*u*G-i*z*H+d*u*H+e*z*I-d*y*I;p.n13=e*l*G-i*o*G+i*n*H-d*l*H-e*n*I+d*o*I;p.n14=i*o*z-e*l*z-i*n*y+d*l*y+e*n*u-d*o*u;p.n21=l*y*x-o*u*x-l*m*H+b*u*H+o*m*I-b*y*I;p.n22=e*u*x-i*y*x+i*m*H-c*u*H-e*m*I+c*y*I;p.n23=i*o*x-e*l*x-i*b*H+c*l*H+e*b*I-c*o*I;p.n24=e*l*m-i*o*m+ -i*b*y-c*l*y-e*b*u+c*o*u;p.n31=n*u*x-l*z*x+l*m*G-b*u*G-n*m*I+b*z*I;p.n32=i*z*x-d*u*x-i*m*G+c*u*G+d*m*I-c*z*I;p.n33=e*l*x-i*n*x+i*b*G-c*l*G-d*b*I+c*n*I;p.n34=i*n*m-d*l*m-i*b*z+c*l*z+d*b*u-c*n*u;p.n41=o*z*x-n*y*x-o*m*G+b*y*G+n*m*H-b*z*H;p.n42=d*y*x-e*z*x+e*m*G-c*y*G-d*m*H+c*z*H;p.n43=e*n*x-d*o*x-e*b*G+c*o*G+d*b*H-c*n*H;p.n44=d*o*m-e*n*m+e*b*z-c*o*z-d*b*y+c*n*y;p.multiplyScalar(1/a.determinant());return p}; -THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],i=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],n=-c[10]*c[4]+c[6]*c[8],o=c[10]*c[0]-c[2]*c[8],l=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],z=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*n+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*i;d[2]=c*b;d[3]=c*n;d[4]=c*o;d[5]=c*l;d[6]=c*m;d[7]=c*z;d[8]=c*y;return a}; -THREE.Matrix4.makeFrustum=function(a,c,d,e,i,b){var n,o,l;n=new THREE.Matrix4;o=2*i/(c-a);l=2*i/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+i)/(b-i);i=-2*b*i/(b-i);n.n11=o;n.n12=0;n.n13=a;n.n14=0;n.n21=0;n.n22=l;n.n23=d;n.n24=0;n.n31=0;n.n32=0;n.n33=e;n.n34=i;n.n41=0;n.n42=0;n.n43=-1;n.n44=0;return n};THREE.Matrix4.makePerspective=function(a,c,d,e){var i;a=d*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*c,a*c,i,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,c,d,e,i,b){var n,o,l,m;n=new THREE.Matrix4;o=c-a;l=d-e;m=b-i;a=(c+a)/o;d=(d+e)/l;i=(b+i)/m;n.n11=2/o;n.n12=0;n.n13=0;n.n14=-a;n.n21=0;n.n22=2/l;n.n23=0;n.n24=-d;n.n31=0;n.n32=0;n.n33=-2/m;n.n34=-i;n.n41=0;n.n42=0;n.n43=0;n.n44=1;return n};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; +THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,i=a.n14,b=a.n21,n=a.n22,o=a.n23,k=a.n24,l=a.n31,z=a.n32,y=a.n33,w=a.n34,x=a.n41,I=a.n42,J=a.n43,K=a.n44,s=new THREE.Matrix4;s.n11=o*w*I-k*y*I+k*z*J-n*w*J-o*z*K+n*y*K;s.n12=i*y*I-e*w*I-i*z*J+d*w*J+e*z*K-d*y*K;s.n13=e*k*I-i*o*I+i*n*J-d*k*J-e*n*K+d*o*K;s.n14=i*o*z-e*k*z-i*n*y+d*k*y+e*n*w-d*o*w;s.n21=k*y*x-o*w*x-k*l*J+b*w*J+o*l*K-b*y*K;s.n22=e*w*x-i*y*x+i*l*J-c*w*J-e*l*K+c*y*K;s.n23=i*o*x-e*k*x-i*b*J+c*k*J+e*b*K-c*o*K;s.n24=e*k*l-i*o*l+ +i*b*y-c*k*y-e*b*w+c*o*w;s.n31=n*w*x-k*z*x+k*l*I-b*w*I-n*l*K+b*z*K;s.n32=i*z*x-d*w*x-i*l*I+c*w*I+d*l*K-c*z*K;s.n33=e*k*x-i*n*x+i*b*I-c*k*I-d*b*K+c*n*K;s.n34=i*n*l-d*k*l-i*b*z+c*k*z+d*b*w-c*n*w;s.n41=o*z*x-n*y*x-o*l*I+b*y*I+n*l*J-b*z*J;s.n42=d*y*x-e*z*x+e*l*I-c*y*I-d*l*J+c*z*J;s.n43=e*n*x-d*o*x-e*b*I+c*o*I+d*b*J-c*n*J;s.n44=d*o*l-e*n*l+e*b*z-c*o*z-d*b*y+c*n*y;s.multiplyScalar(1/a.determinant());return s}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],i=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],n=-c[10]*c[4]+c[6]*c[8],o=c[10]*c[0]-c[2]*c[8],k=-c[6]*c[0]+c[2]*c[4],l=c[9]*c[4]-c[5]*c[8],z=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*n+c[2]*l;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*i;d[2]=c*b;d[3]=c*n;d[4]=c*o;d[5]=c*k;d[6]=c*l;d[7]=c*z;d[8]=c*y;return a}; +THREE.Matrix4.makeFrustum=function(a,c,d,e,i,b){var n,o,k;n=new THREE.Matrix4;o=2*i/(c-a);k=2*i/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+i)/(b-i);i=-2*b*i/(b-i);n.n11=o;n.n12=0;n.n13=a;n.n14=0;n.n21=0;n.n22=k;n.n23=d;n.n24=0;n.n31=0;n.n32=0;n.n33=e;n.n34=i;n.n41=0;n.n42=0;n.n43=-1;n.n44=0;return n};THREE.Matrix4.makePerspective=function(a,c,d,e){var i;a=d*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*c,a*c,i,a,d,e)}; +THREE.Matrix4.makeOrtho=function(a,c,d,e,i,b){var n,o,k,l;n=new THREE.Matrix4;o=c-a;k=d-e;l=b-i;a=(c+a)/o;d=(d+e)/k;i=(b+i)/l;n.n11=2/o;n.n12=0;n.n13=0;n.n14=-a;n.n21=0;n.n22=2/k;n.n23=0;n.n24=-d;n.n31=0;n.n32=0;n.n33=-2/l;n.n34=-i;n.n41=0;n.n42=0;n.n43=0;n.n44=1;return n};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; 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=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; THREE.Face3=function(a,c,d,e,i){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; THREE.Face4=function(a,c,d,e,i,b){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0}; THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], +this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=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,d=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,d=this.vertices.length;c65535){m[o].counter+=1;l=m[o].hash+"_"+m[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:n,vertices:0}}this.geometryChunks[l].faces.push(e);this.geometryChunks[l].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+ +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,d=this.vertices.length;c65535){l[o].counter+=1;k=l[o].hash+"_"+l[o].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:n,vertices:0}}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; this.translateZ=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()}; @@ -61,9 +61,9 @@ THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.positio THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0}; -THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c]};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; +THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()}; -THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; +THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3; THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}}; THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!== @@ -98,98 +98,99 @@ var Uniforms={clone:function(a){var c,d,e,i={};for(c in a){i[c]={};for(d in a[c] THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}}; THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4}; -THREE.Projector=function(){function a(t,k){return k.z-t.z}function c(t,k){var A=0,q=1,C=t.z+t.w,r=k.z+k.w,v=-t.z+t.w,D=-k.z+k.w;if(C>=0&&r>=0&&v>=0&&D>=0)return true;else if(C<0&&r<0||v<0&&D<0)return false;else{if(C<0)A=Math.max(A,C/(C-r));else if(r<0)q=Math.min(q,C/(C-r));if(v<0)A=Math.max(A,v/(v-D));else if(D<0)q=Math.min(q,v/(v-D));if(qC&&E.z0&&I.z<1){u=G[x]=G[x]||new THREE.RenderableParticle;u.x=I.x/I.w;u.y=I.y/I.w;u.z=I.z;u.rotation=J.rotation.z;u.scale.x=J.scale.x*Math.abs(u.x-(I.x+k.projectionMatrix.n11)/(I.w+k.projectionMatrix.n14)); -u.scale.y=J.scale.y*Math.abs(u.y-(I.y+k.projectionMatrix.n22)/(I.w+k.projectionMatrix.n24));u.materials=J.materials;q.push(u);x++}}}}A&&q.sort(a);return q};this.unprojectVector=function(t,k){var A=THREE.Matrix4.makeInvert(k.matrix);A.multiplySelf(THREE.Matrix4.makeInvert(k.projectionMatrix));A.multiplyVector3(t);return t}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,i,b;this.domElement=document.createElement("div");this.setSize=function(n,o){d=n;e=o;i=d/2;b=e/2};this.render=function(n,o){var l,m,z,y,u,x,G,H;a=c.projectScene(n,o);l=0;for(m=a.length;l0){F.r+=fa.r*Z;F.g+=fa.g*Z;F.b+=fa.b*Z}}else if(Z instanceof THREE.PointLight){Y.sub(Z.position,X);Y.normalize();Z=T.dot(Y)*ha;if(Z>0){F.r+=fa.r*Z;F.g+=fa.g*Z;F.b+=fa.b*Z}}}}function Na(B,X,T){if(T.opacity!=0){a(T.opacity);c(T.blending); -var F,Q,Z,fa,ha,ia;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){fa=T.map.image;ha=fa.width>>1;ia=fa.height>>1;Q=X.scale.x*o;Z=X.scale.y*l;T=Q*ha;F=Z*ia;w.set(B.x-T,B.y-F,B.x+T,B.y+F);if(U.instersects(w)){m.save();m.translate(B.x,B.y);m.rotate(-X.rotation);m.scale(Q,-Z);m.translate(-ha,-ia);m.drawImage(fa,0,0);m.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(L){P.r=ga.r+ja.r+ca.r;P.g=ga.g+ja.g+ca.g;P.b=ga.b+ja.b+ca.b;q.r=T.color.r*P.r;q.g=T.color.g* -P.g;q.b=T.color.b*P.b;q.updateStyleString()}else q.__styleString=T.color.__styleString;T=X.scale.x*o;F=X.scale.y*l;w.set(B.x-T,B.y-F,B.x+T,B.y+F);if(U.instersects(w)){Q=q.__styleString;if(H!=Q)m.fillStyle=H=Q;m.save();m.translate(B.x,B.y);m.rotate(-X.rotation);m.scale(T,F);m.beginPath();m.arc(0,0,1,0,$,true);m.closePath();m.fill();m.restore()}}}}function Oa(B,X,T,F){if(F.opacity!=0){a(F.opacity);c(F.blending);m.beginPath();m.moveTo(B.positionScreen.x,B.positionScreen.y);m.lineTo(X.positionScreen.x, -X.positionScreen.y);m.closePath();if(F instanceof THREE.LineBasicMaterial){q.__styleString=F.color.__styleString;B=F.linewidth;if(I!=B)m.lineWidth=I=B;B=q.__styleString;if(G!=B)m.strokeStyle=G=B;m.stroke();w.inflate(F.linewidth*2)}}}function Ia(B,X,T,F,Q,Z){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);f=B.positionScreen.x;j=B.positionScreen.y;s=X.positionScreen.x;t=X.positionScreen.y;k=T.positionScreen.x;A=T.positionScreen.y;m.beginPath();m.moveTo(f,j);m.lineTo(s,t);m.lineTo(k,A);m.lineTo(f,j);m.closePath(); -if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&xa(f,j,s,t,k,A,Q.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof THREE.SphericalReflectionMapping){B=ta.matrix;Y.copy(F.vertexNormalsWorld[0]);M=(Y.x*B.n11+Y.y*B.n12+Y.z*B.n13)*0.5+0.5;J=-(Y.x*B.n21+Y.y*B.n22+Y.z*B.n23)*0.5+0.5;Y.copy(F.vertexNormalsWorld[1]);S=(Y.x*B.n11+Y.y*B.n12+Y.z* -B.n13)*0.5+0.5;V=-(Y.x*B.n21+Y.y*B.n22+Y.z*B.n23)*0.5+0.5;Y.copy(F.vertexNormalsWorld[2]);N=(Y.x*B.n11+Y.y*B.n12+Y.z*B.n13)*0.5+0.5;K=-(Y.x*B.n21+Y.y*B.n22+Y.z*B.n23)*0.5+0.5;xa(f,j,s,t,k,A,Q.env_map.image,M,J,S,V,N,K)}}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&xa(f,j,s,t,k,A,Q.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u, -F.uvs[2].v);c(THREE.SubtractiveBlending)}if(L)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){C.r=r.r=v.r=ga.r;C.g=r.g=v.g=ga.g;C.b=r.b=v.b=ga.b;Aa(Z,F.v1.positionWorld,F.vertexNormalsWorld[0],C);Aa(Z,F.v2.positionWorld,F.vertexNormalsWorld[1],r);Aa(Z,F.v3.positionWorld,F.vertexNormalsWorld[2],v);D.r=(r.r+v.r)*0.5;D.g=(r.g+v.g)*0.5;D.b=(r.b+v.b)*0.5;O=Ja(C,r,v,D);xa(f,j,s,t,k,A,O,0,0,1,0,0,1)}else{P.r=ga.r;P.g=ga.g;P.b=ga.b;Aa(Z,F.centroidWorld,F.normalWorld,P);q.r= -Q.color.r*P.r;q.g=Q.color.g*P.g;q.b=Q.color.b*P.b;q.updateStyleString();Q.wireframe?Ba(q.__styleString,Q.wireframe_linewidth):Ca(q.__styleString)}else Q.wireframe?Ba(Q.color.__styleString,Q.wireframe_linewidth):Ca(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){W=ta.near;E=ta.far;C.r=C.g=C.b=1-Ea(B.positionScreen.z,W,E);r.r=r.g=r.b=1-Ea(X.positionScreen.z,W,E);v.r=v.g=v.b=1-Ea(T.positionScreen.z,W,E);D.r=(r.r+v.r)*0.5;D.g=(r.g+v.g)*0.5;D.b=(r.b+v.b)*0.5;O=Ja(C,r,v,D);xa(f,j,s, -t,k,A,O,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){q.r=Fa(F.normalWorld.x);q.g=Fa(F.normalWorld.y);q.b=Fa(F.normalWorld.z);q.updateStyleString();Q.wireframe?Ba(q.__styleString,Q.wireframe_linewidth):Ca(q.__styleString)}}}function Ba(B,X){if(G!=B)m.strokeStyle=G=B;if(I!=X)m.lineWidth=I=X;m.stroke();w.inflate(X*2)}function Ca(B){if(H!=B)m.fillStyle=H=B;m.fill()}function xa(B,X,T,F,Q,Z,fa,ha,ia,na,ka,oa,ya){var ua,pa;ua=fa.width-1;pa=fa.height-1;ha*=ua;ia*=pa;na*=ua;ka*=pa;oa*=ua;ya*= -pa;T-=B;F-=X;Q-=B;Z-=X;na-=ha;ka-=ia;oa-=ha;ya-=ia;pa=1/(na*ya-oa*ka);ua=(ya*T-ka*Q)*pa;ka=(ya*F-ka*Z)*pa;T=(na*Q-oa*T)*pa;F=(na*Z-oa*F)*pa;B=B-ua*ha-T*ia;X=X-ka*ha-F*ia;m.save();m.transform(ua,ka,T,F,B,X);m.clip();m.drawImage(fa,0,0);m.restore()}function Ja(B,X,T,F){var Q=~~(B.r*255),Z=~~(B.g*255);B=~~(B.b*255);var fa=~~(X.r*255),ha=~~(X.g*255);X=~~(X.b*255);var ia=~~(T.r*255),na=~~(T.g*255);T=~~(T.b*255);var ka=~~(F.r*255),oa=~~(F.g*255);F=~~(F.b*255);aa[0]=Q<0?0:Q>255?255:Q;aa[1]=Z<0?0:Z>255?255: -Z;aa[2]=B<0?0:B>255?255:B;aa[4]=fa<0?0:fa>255?255:fa;aa[5]=ha<0?0:ha>255?255:ha;aa[6]=X<0?0:X>255?255:X;aa[8]=ia<0?0:ia>255?255:ia;aa[9]=na<0?0:na>255?255:na;aa[10]=T<0?0:T>255?255:T;aa[12]=ka<0?0:ka>255?255:ka;aa[13]=oa<0?0:oa>255?255:oa;aa[14]=F<0?0:F>255?255:F;qa.putImageData(la,0,0);va.drawImage(da,0,0);return ra}function Ea(B,X,T){B=(B-X)/(T-X);return B*B*(3-2*B)}function Fa(B){B=(B+1)*0.5;return B<0?0:B>1?1:B}function Ga(B,X){var T=X.x-B.x,F=X.y-B.y,Q=1/Math.sqrt(T*T+F*F);T*=Q;F*=Q;X.x+=T;X.y+= -F;B.x-=T;B.y-=F}var Da,Ka,ba,ma,wa,Ha,La,za;this.autoClear?this.clear():m.setTransform(1,0,0,-1,o,l);d=e.projectScene(ea,ta,this.sortElements);(L=ea.lights.length>0)&&Ma(ea);Da=0;for(Ka=d.length;Da0){S.r+=K.color.r*U;S.g+=K.color.g*U;S.b+=K.color.b*U}}else if(K instanceof THREE.PointLight){A.sub(K.position,J.centroidWorld);A.normalize();U=J.normalWorld.dot(A)*K.intensity;if(U>0){S.r+=K.color.r*U;S.g+=K.color.g*U;S.b+=K.color.b*U}}}}function c(M,J,S,V,N,K){v=e(D++);v.setAttribute("d","M "+M.positionScreen.x+ -" "+M.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)h.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(g){f.r=j.r;f.g=j.g;f.b=j.b;a(K,V,f);h.r=N.color.r*f.r;h.g=N.color.g*f.g;h.b=N.color.b*f.b;h.updateStyleString()}else h.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshDepthMaterial){k=1-N.__2near/(N.__farPlusNear-V.z*N.__farMinusNear); -h.setRGB(k,k,k)}else N instanceof THREE.MeshNormalMaterial&&h.setRGB(i(V.normalWorld.x),i(V.normalWorld.y),i(V.normalWorld.z));N.wireframe?v.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):v.setAttribute("style","fill: "+h.__styleString+"; fill-opacity: "+N.opacity);o.appendChild(v)}function d(M,J,S,V,N,K,U){v=e(D++);v.setAttribute("d", -"M "+M.positionScreen.x+" "+M.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(K instanceof THREE.MeshBasicMaterial)h.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshLambertMaterial)if(g){f.r=j.r;f.g=j.g;f.b=j.b;a(U,N,f);h.r=K.color.r*f.r;h.g=K.color.g*f.g;h.b=K.color.b*f.b;h.updateStyleString()}else h.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshDepthMaterial){k= -1-K.__2near/(K.__farPlusNear-N.z*K.__farMinusNear);h.setRGB(k,k,k)}else K instanceof THREE.MeshNormalMaterial&&h.setRGB(i(N.normalWorld.x),i(N.normalWorld.y),i(N.normalWorld.z));K.wireframe?v.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: "+K.wireframe_linecap+"; stroke-linejoin: "+K.wireframe_linejoin):v.setAttribute("style","fill: "+h.__styleString+"; fill-opacity: "+K.opacity);o.appendChild(v)} -function e(M){if(q[M]==null){q[M]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&q[M].setAttribute("shape-rendering","crispEdges");return q[M]}return q[M]}function i(M){return M<0?Math.min((1+M)*0.5,0.5):0.5+Math.min(M*0.5,0.5)}var b=null,n=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,z,y,u,x,G,H,I=new THREE.Rectangle,p=new THREE.Rectangle,g=false,h=new THREE.Color(16777215),f=new THREE.Color(16777215),j=new THREE.Color(0),s=new THREE.Color(0), -t=new THREE.Color(0),k,A=new THREE.Vector3,q=[],C=[],r=[],v,D,W,E,O=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(M){switch(M){case "high":O=1;break;case "low":O=0}};this.setSize=function(M,J){l=M;m=J;z=l/2;y=m/2;o.setAttribute("viewBox",-z+" "+-y+" "+l+" "+m);o.setAttribute("width",l);o.setAttribute("height",m);I.set(-z,-y,z,y)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(M,J){var S,V, -N,K,U,R,w,L;this.autoClear&&this.clear();b=n.projectScene(M,J,this.sortElements);E=W=D=0;if(g=M.lights.length>0){w=M.lights;j.setRGB(0,0,0);s.setRGB(0,0,0);t.setRGB(0,0,0);S=0;for(V=w.length;S=0&&r>=0&&v>=0&&t>=0)return true;else if(q<0&&r<0||v<0&&t<0)return false;else{if(q<0)u=Math.max(u,q/(q-r));else if(r<0)p=Math.min(p,q/(q-r));if(v<0)u=Math.max(u,v/(v-t));else if(t<0)p=Math.min(p,v/(v-t));if(pq&&D.z0&&K.z<1){w=I[x]=I[x]||new THREE.RenderableParticle;w.x=K.x/K.w;w.y=K.y/K.w;w.z=K.z;w.rotation=H.rotation.z;w.scale.x=H.scale.x*Math.abs(w.x-(K.x+m.projectionMatrix.n11)/(K.w+m.projectionMatrix.n14)); +w.scale.y=H.scale.y*Math.abs(w.y-(K.y+m.projectionMatrix.n22)/(K.w+m.projectionMatrix.n24));w.materials=H.materials;p.push(w);x++}}}}u&&p.sort(a);return p};this.unprojectVector=function(h,m){var u=THREE.Matrix4.makeInvert(m.matrix);u.multiplySelf(THREE.Matrix4.makeInvert(m.projectionMatrix));u.multiplyVector3(h);return h}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,i,b;this.domElement=document.createElement("div");this.setSize=function(n,o){d=n;e=o;i=d/2;b=e/2};this.render=function(n,o){var k,l,z,y,w,x,I,J;a=c.projectScene(n,o);k=0;for(l=a.length;k0){E.r+=ea.r*$;E.g+=ea.g*$;E.b+=ea.b*$}}else if($ instanceof THREE.PointLight){Y.sub($.position,W);Y.normalize();$=S.dot(Y)*ha;if($>0){E.r+=ea.r*$;E.g+=ea.g*$;E.b+=ea.b*$}}}}function Na(A,W,S){if(S.opacity!=0){a(S.opacity);c(S.blending); +var E,P,$,ea,ha,ka;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){ea=S.map.image;ha=ea.width>>1;ka=ea.height>>1;P=W.scale.x*o;$=W.scale.y*k;S=P*ha;E=$*ka;B.set(A.x-S,A.y-E,A.x+S,A.y+E);if(V.instersects(B)){l.save();l.translate(A.x,A.y);l.rotate(-W.rotation);l.scale(P,-$);l.translate(-ha,-ka);l.drawImage(ea,0,0);l.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(M){N.r=aa.r+ba.r+la.r;N.g=aa.g+ba.g+la.g;N.b=aa.b+ba.b+la.b;p.r=S.color.r*N.r;p.g=S.color.g* +N.g;p.b=S.color.b*N.b;p.updateStyleString()}else p.__styleString=S.color.__styleString;S=W.scale.x*o;E=W.scale.y*k;B.set(A.x-S,A.y-E,A.x+S,A.y+E);if(V.instersects(B)){P=p.__styleString;if(J!=P)l.fillStyle=J=P;l.save();l.translate(A.x,A.y);l.rotate(-W.rotation);l.scale(S,E);l.beginPath();l.arc(0,0,1,0,ua,true);l.closePath();l.fill();l.restore()}}}}function Oa(A,W,S,E){if(E.opacity!=0){a(E.opacity);c(E.blending);l.beginPath();l.moveTo(A.positionScreen.x,A.positionScreen.y);l.lineTo(W.positionScreen.x, +W.positionScreen.y);l.closePath();if(E instanceof THREE.LineBasicMaterial){p.__styleString=E.color.__styleString;A=E.linewidth;if(K!=A)l.lineWidth=K=A;A=p.__styleString;if(I!=A)l.strokeStyle=I=A;l.stroke();B.inflate(E.linewidth*2)}}}function Ja(A,W,S,E,P,$){if(P.opacity!=0){a(P.opacity);c(P.blending);f=A.positionScreen.x;j=A.positionScreen.y;g=W.positionScreen.x;h=W.positionScreen.y;m=S.positionScreen.x;u=S.positionScreen.y;l.beginPath();l.moveTo(f,j);l.lineTo(g,h);l.lineTo(m,u);l.lineTo(f,j);l.closePath(); +if(P instanceof THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&xa(f,j,g,h,m,u,P.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=oa.matrix;Y.copy(E.vertexNormalsWorld[0]);O=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;H=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;Y.copy(E.vertexNormalsWorld[1]);Q=(Y.x*A.n11+Y.y*A.n12+Y.z* +A.n13)*0.5+0.5;X=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;Y.copy(E.vertexNormalsWorld[2]);G=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;C=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;xa(f,j,g,h,m,u,P.env_map.image,O,H,Q,X,G,C)}}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&xa(f,j,g,h,m,u,P.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u, +E.uvs[2].v);c(THREE.SubtractiveBlending)}if(M)if(!P.wireframe&&P.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){q.r=r.r=v.r=aa.r;q.g=r.g=v.g=aa.g;q.b=r.b=v.b=aa.b;Aa($,E.v1.positionWorld,E.vertexNormalsWorld[0],q);Aa($,E.v2.positionWorld,E.vertexNormalsWorld[1],r);Aa($,E.v3.positionWorld,E.vertexNormalsWorld[2],v);t.r=(r.r+v.r)*0.5;t.g=(r.g+v.g)*0.5;t.b=(r.b+v.b)*0.5;R=Ka(q,r,v,t);xa(f,j,g,h,m,u,R,0,0,1,0,0,1)}else{N.r=aa.r;N.g=aa.g;N.b=aa.b;Aa($,E.centroidWorld,E.normalWorld,N);p.r= +P.color.r*N.r;p.g=P.color.g*N.g;p.b=P.color.b*N.b;p.updateStyleString();P.wireframe?Ba(p.__styleString,P.wireframe_linewidth):Ca(p.__styleString)}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){L=oa.near;D=oa.far;q.r=q.g=q.b=1-Fa(A.positionScreen.z,L,D);r.r=r.g=r.b=1-Fa(W.positionScreen.z,L,D);v.r=v.g=v.b=1-Fa(S.positionScreen.z,L,D);t.r=(r.r+v.r)*0.5;t.g=(r.g+v.g)*0.5;t.b=(r.b+v.b)*0.5;R=Ka(q,r,v,t);xa(f,j,g, +h,m,u,R,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){p.r=Ga(E.normalWorld.x);p.g=Ga(E.normalWorld.y);p.b=Ga(E.normalWorld.z);p.updateStyleString();P.wireframe?Ba(p.__styleString,P.wireframe_linewidth):Ca(p.__styleString)}}}function Ba(A,W){if(I!=A)l.strokeStyle=I=A;if(K!=W)l.lineWidth=K=W;l.stroke();B.inflate(W*2)}function Ca(A){if(J!=A)l.fillStyle=J=A;l.fill()}function xa(A,W,S,E,P,$,ea,ha,ka,ra,na,sa,ya){var va,ta;va=ea.width-1;ta=ea.height-1;ha*=va;ka*=ta;ra*=va;na*=ta;sa*=va;ya*= +ta;S-=A;E-=W;P-=A;$-=W;ra-=ha;na-=ka;sa-=ha;ya-=ka;ta=1/(ra*ya-sa*na);va=(ya*S-na*P)*ta;na=(ya*E-na*$)*ta;S=(ra*P-sa*S)*ta;E=(ra*$-sa*E)*ta;A=A-va*ha-S*ka;W=W-na*ha-E*ka;l.save();l.transform(va,na,S,E,A,W);l.clip();l.drawImage(ea,0,0);l.restore()}function Ka(A,W,S,E){var P=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var ea=~~(W.r*255),ha=~~(W.g*255);W=~~(W.b*255);var ka=~~(S.r*255),ra=~~(S.g*255);S=~~(S.b*255);var na=~~(E.r*255),sa=~~(E.g*255);E=~~(E.b*255);ja[0]=P<0?0:P>255?255:P;ja[1]=$<0?0:$>255?255: +$;ja[2]=A<0?0:A>255?255:A;ja[4]=ea<0?0:ea>255?255:ea;ja[5]=ha<0?0:ha>255?255:ha;ja[6]=W<0?0:W>255?255:W;ja[8]=ka<0?0:ka>255?255:ka;ja[9]=ra<0?0:ra>255?255:ra;ja[10]=S<0?0:S>255?255:S;ja[12]=na<0?0:na>255?255:na;ja[13]=sa<0?0:sa>255?255:sa;ja[14]=E<0?0:E>255?255:E;ia.putImageData(fa,0,0);ga.drawImage(Z,0,0);return ma}function Fa(A,W,S){A=(A-W)/(S-W);return A*A*(3-2*A)}function Ga(A){A=(A+1)*0.5;return A<0?0:A>1?1:A}function Ha(A,W){var S=W.x-A.x,E=W.y-A.y,P=1/Math.sqrt(S*S+E*E);S*=P;E*=P;W.x+=S;W.y+= +E;A.x-=S;A.y-=E}var Da,La,ca,pa,wa,Ia,Ma,za;this.autoClear?this.clear():l.setTransform(1,0,0,-1,o,k);d=e.projectScene(da,oa,this.sortElements);(M=da.lights.length>0)&&Ea(da);Da=0;for(La=d.length;Da0){Q.r+=C.color.r*V;Q.g+=C.color.g*V;Q.b+=C.color.b*V}}else if(C instanceof THREE.PointLight){u.sub(C.position,H.centroidWorld);u.normalize();V=H.normalWorld.dot(u)*C.intensity;if(V>0){Q.r+=C.color.r*V;Q.g+=C.color.g*V;Q.b+=C.color.b*V}}}}function c(O,H,Q,X,G,C){v=e(t++);v.setAttribute("d","M "+O.positionScreen.x+ +" "+O.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(G instanceof THREE.MeshBasicMaterial)F.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshLambertMaterial)if(T){f.r=j.r;f.g=j.g;f.b=j.b;a(C,X,f);F.r=G.color.r*f.r;F.g=G.color.g*f.g;F.b=G.color.b*f.b;F.updateStyleString()}else F.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshDepthMaterial){m=1-G.__2near/(G.__farPlusNear-X.z*G.__farMinusNear); +F.setRGB(m,m,m)}else G instanceof THREE.MeshNormalMaterial&&F.setRGB(i(X.normalWorld.x),i(X.normalWorld.y),i(X.normalWorld.z));G.wireframe?v.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+G.wireframe_linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.wireframe_linecap+"; stroke-linejoin: "+G.wireframe_linejoin):v.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+G.opacity);o.appendChild(v)}function d(O,H,Q,X,G,C,V){v=e(t++);v.setAttribute("d", +"M "+O.positionScreen.x+" "+O.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)F.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(T){f.r=j.r;f.g=j.g;f.b=j.b;a(V,G,f);F.r=C.color.r*f.r;F.g=C.color.g*f.g;F.b=C.color.b*f.b;F.updateStyleString()}else F.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){m= +1-C.__2near/(C.__farPlusNear-G.z*C.__farMinusNear);F.setRGB(m,m,m)}else C instanceof THREE.MeshNormalMaterial&&F.setRGB(i(G.normalWorld.x),i(G.normalWorld.y),i(G.normalWorld.z));C.wireframe?v.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):v.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+C.opacity);o.appendChild(v)} +function e(O){if(p[O]==null){p[O]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&p[O].setAttribute("shape-rendering","crispEdges");return p[O]}return p[O]}function i(O){return O<0?Math.min((1+O)*0.5,0.5):0.5+Math.min(O*0.5,0.5)}var b=null,n=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,z,y,w,x,I,J,K=new THREE.Rectangle,s=new THREE.Rectangle,T=false,F=new THREE.Color(16777215),f=new THREE.Color(16777215),j=new THREE.Color(0),g=new THREE.Color(0), +h=new THREE.Color(0),m,u=new THREE.Vector3,p=[],q=[],r=[],v,t,L,D,R=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(O){switch(O){case "high":R=1;break;case "low":R=0}};this.setSize=function(O,H){k=O;l=H;z=k/2;y=l/2;o.setAttribute("viewBox",-z+" "+-y+" "+k+" "+l);o.setAttribute("width",k);o.setAttribute("height",l);K.set(-z,-y,z,y)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(O,H){var Q,X, +G,C,V,U,B,M;this.autoClear&&this.clear();b=n.projectScene(O,H,this.sortElements);D=L=t=0;if(T=O.lights.length>0){B=O.lights;j.setRGB(0,0,0);g.setRGB(0,0,0);h.setRGB(0,0,0);Q=0;for(X=B.length;Q0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ga,f)}if(t&&K>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,ja,f)}if(s){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, -g.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Y,f);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,da,f)}};this.setLineBuffers=function(g,h,f,j){var s,t,k=g.vertices,A=k.length,q=g.__vertexArray,C=g.__lineArray;if(f)for(f=0;f0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP": -"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(f,d("fragment",s+q));b.attachShader(f,d("vertex",t+h));b.linkProgram(f);b.getProgramParameter(f,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(f,b.VALIDATE_STATUS)+ -", gl error ["+b.getError()+"]");f.uniforms={};f.attributes={};g.program=f;f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(j in g.uniforms)f.push(j);j=g.program;q=0;for(h=f.length;q=0){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLNormalBuffer);b.vertexAttribPointer(k.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.normal)}if(k.tangent>= -0){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLTangentBuffer);b.vertexAttribPointer(k.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.tangent)}if(k.uv>=0)if(s.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLUVBuffer);b.vertexAttribPointer(k.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv)}else b.disableVertexAttribArray(k.uv);if(k.uv2>=0)if(s.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLUV2Buffer);b.vertexAttribPointer(k.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv2)}else b.disableVertexAttribArray(k.uv2); -if(j.wireframe||j instanceof THREE.LineBasicMaterial){k=j.wireframe_linewidth!==undefined?j.wireframe_linewidth:j.linewidth!==undefined?j.linewidth:1;j=j instanceof THREE.LineBasicMaterial&&t.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(k);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,s.__webGLLineBuffer);b.drawElements(j,s.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(j instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,s.__webGLParticleBuffer);b.drawElements(b.POINTS,s.__webGLParticleCount, -b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,s.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,s.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(g,h,f,j,s,t,k){var A,q,C,r,v;C=0;for(r=j.materials.length;C=0;f--){j=g.__webGLObjects[f].object;h==j&&g.__webGLObjects.splice(f, -1)}};this.setupMatrices=function(g,h){g.autoUpdateMatrix&&g.updateMatrix();l.multiply(h.matrix,g.matrix);y.set(l.flatten());m=THREE.Matrix4.makeInvert3x3(l).transpose();x.set(m.m);G.set(g.matrix.flatten())};this.loadMatrices=function(g){b.uniformMatrix4fv(g.uniforms.viewMatrix,false,z);b.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,y);b.uniformMatrix4fv(g.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(g.uniforms.normalMatrix,false,x);b.uniformMatrix4fv(g.uniforms.objectMatrix,false,G)}; -this.loadCamera=function(g,h){b.uniform3f(g.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(g){switch(g){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,h){if(g){!h||h=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(g=="back")b.cullFace(b.BACK); -else g=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; -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, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif", +case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var i=document.createElement("canvas"),b,n=null,o=null,k=new THREE.Matrix4,l,z=new Float32Array(16),y=new Float32Array(16), +w=new Float32Array(16),x=new Float32Array(9),I=new Float32Array(16),J=new THREE.Matrix4,K=new THREE.Vector4,s=true,T=new THREE.Color(0),F=0;if(a){if(a.antialias!==undefined)s=a.antialias;a.clearColor!==undefined&&T.setHex(a.clearColor);if(a.clearAlpha!==undefined)F=a.clearAlpha}this.domElement=i;this.autoClear=true;(function(f,j,g){try{b=i.getContext("experimental-webgl",{antialias:f})}catch(h){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1); +b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(j.r,j.g,j.b,g)})(s,T,F);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,j){i.width=f;i.height=j;b.viewport(0,0,i.width,i.height)};this.setClearColor=function(f,j){var g=new THREE.Color(f);b.clearColor(g.r,g.g,g.b,j)}; +this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(f,j){var g,h,m,u=0,p=0,q=0,r,v,t,L=this.lights,D=L.directional.colors,R=L.directional.positions,O=L.point.colors,H=L.point.positions,Q=0,X=0;g=0;for(h=j.length;g0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,la,g)}if(u&& +U>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,ua,g)}if(m){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ia,g);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,g)}};this.setLineBuffers=function(f,j,g,h){var m,u,p=f.vertices,q=p.length,r=f.__vertexArray,v=f.__lineArray;if(g)for(g=0;g0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+u.maxDirLights,"#define MAX_POINT_LIGHTS "+u.maxPointLights,u.map?"#define USE_MAP":"",u.env_map?"#define USE_ENVMAP":"",u.light_map?"#define USE_LIGHTMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n"); +b.attachShader(g,d("fragment",m+r));b.attachShader(g,d("vertex",u+j));b.linkProgram(g);b.getProgramParameter(g,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(g,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");g.uniforms={};g.attributes={};f.program=g;g=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in f.uniforms)g.push(h);h=f.program;r=0;for(j=g.length;r=0){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLNormalBuffer);b.vertexAttribPointer(p.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(p.normal)}if(p.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLTangentBuffer);b.vertexAttribPointer(p.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(p.tangent)}if(p.uv>=0)if(m.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLUVBuffer);b.vertexAttribPointer(p.uv,2,b.FLOAT,false,0,0); +b.enableVertexAttribArray(p.uv)}else b.disableVertexAttribArray(p.uv);if(p.uv2>=0)if(m.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLUV2Buffer);b.vertexAttribPointer(p.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(p.uv2)}else b.disableVertexAttribArray(p.uv2);if(h.wireframe||h instanceof THREE.LineBasicMaterial){p=h.wireframe_linewidth!==undefined?h.wireframe_linewidth:h.linewidth!==undefined?h.linewidth:1;h=h instanceof THREE.LineBasicMaterial&&u.type==THREE.LineStrip?b.LINE_STRIP: +b.LINES;b.lineWidth(p);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.__webGLLineBuffer);b.drawElements(h,m.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(h instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.__webGLParticleBuffer);b.drawElements(b.POINTS,m.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,m.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(f,j,g,h,m,u,p){var q,r,v,t,L;v=0; +for(t=h.materials.length;v=0;g--){h=f.__webGLObjects[g].object;j==h&&f.__webGLObjects.splice(g,1)}};this.setupMatrices= +function(f,j){k.multiply(j.matrix,f.matrix);y.set(k.flatten());l=THREE.Matrix4.makeInvert3x3(k).transpose();x.set(l.m);I.set(f.matrix.flatten())};this.loadMatrices=function(f){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,z);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,y);b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,w);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,x);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,I)};this.loadCamera=function(f,j){b.uniform3f(f.uniforms.cameraPosition, +j.position.x,j.position.y,j.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,j){if(f){!j||j=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW); +if(f=="back")b.cullFace(b.BACK);else f=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; +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 env_map;\nuniform int combine;\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\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 ), refraction_ratio );\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",map_particle_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif", lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\nlightmapColor = texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", diff --git a/build/ThreeDebug.js b/build/ThreeDebug.js index 9667e1f9..0e636e73 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -1,6 +1,6 @@ // ThreeDebug.js r32 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)}; -THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,i,b,n,o,l;if(d==0)e=i=b=0;else{n=Math.floor(a*6);o=a*6-n;a=d*(1-c);l=d*(1-c*o);c=d*(1-c*(1-o));switch(n){case 1:e=l;i=d;b=a;break;case 2:e=a;i=d;b=c;break;case 3:e=a;i=l;b=d;break;case 4:e=c;i=a;b=d;break;case 5:e=d;i=a;b=l;break;case 6:case 0:e=d;i=c;b=a}}this.r=e;this.g=i;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, +THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,i,b,n,o,k;if(d==0)e=i=b=0;else{n=Math.floor(a*6);o=a*6-n;a=d*(1-c);k=d*(1-c*o);c=d*(1-c*(1-o));switch(n){case 1:e=k;i=d;b=a;break;case 2:e=a;i=d;b=c;break;case 3:e=a;i=k;b=d;break;case 4:e=c;i=a;b=d;break;case 5:e=d;i=a;b=k;break;case 6:case 0:e=d;i=c;b=a}}this.r=e;this.g=i;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+ this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0}; THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* @@ -13,47 +13,47 @@ THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1} THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){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)},toString:function(){return"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,d,e=a.objects,i=[];a=0;for(c=e.length;a0&&I>0&&j+I<1}var d,e,i,b,n,o,l,m,z,y, -u,x=a.geometry,G=x.vertices,H=[];d=0;for(e=x.faces.length;dl?e:l;i=i>m? -i:m}a()};this.add3Points=function(l,m,z,y,u,x){if(o){o=false;c=lz?l>u?l:u:z>u?z:u;i=m>y?m>x?m:x:y>x?y:x}else{c=lz?l>u?l>e?l:e:u>e?u:e:z>u?z>e?z:e:u>e?u:e;i=m>y?m>x?m>i?m:i:x>i?x:i:y>x?y>i?y:i:x>i?x:i}a()};this.addRectangle=function(l){if(o){o=false;c=l.getLeft();d=l.getTop();e=l.getRight();i=l.getBottom()}else{c=cl.getRight()?e:l.getRight();i=i>l.getBottom()?i:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;e+=l;i+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();e=e=0&&Math.min(i,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){o=true;i=e=d=c=0;a()};this.isEmpty=function(){return o};this.toString= +THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,i=[];a=0;for(c=e.length;a0&&K>0&&j+K<1}var d,e,i,b,n,o,k,l,z,y, +w,x=a.geometry,I=x.vertices,J=[];d=0;for(e=x.faces.length;dk?e:k;i=i>l? +i:l}a()};this.add3Points=function(k,l,z,y,w,x){if(o){o=false;c=kz?k>w?k:w:z>w?z:w;i=l>y?l>x?l:x:y>x?y:x}else{c=kz?k>w?k>e?k:e:w>e?w:e:z>w?z>e?z:e:w>e?w:e;i=l>y?l>x?l>i?l:i:x>i?x:i:y>x?y>i?y:i:x>i?x:i}a()};this.addRectangle=function(k){if(o){o=false;c=k.getLeft();d=k.getTop();e=k.getRight();i=k.getBottom()}else{c=ck.getRight()?e:k.getRight();i=i>k.getBottom()?i:k.getBottom()}a()};this.inflate=function(k){c-=k;d-=k;e+=k;i+=k;a()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();d=d>k.getTop()?d:k.getTop();e=e=0&&Math.min(i,k.getBottom())-Math.max(d,k.getTop())>=0};this.empty=function(){o=true;i=e=d=c=0;a()};this.isEmpty=function(){return o};this.toString= function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+i+", width: "+b+", height: "+n+" )"}};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}}; -THREE.Matrix4=function(a,c,d,e,i,b,n,o,l,m,z,y,u,x,G,H){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=i||0;this.n22=b||1;this.n23=n||0;this.n24=o||0;this.n31=l||0;this.n32=m||0;this.n33=z||1;this.n34=y||0;this.n41=u||0;this.n42=x||0;this.n43=G||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,i,b,n,o,l,m,z,y,u,x,G,H){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=i;this.n22=b;this.n23=n;this.n24=o;this.n31=l;this.n32=m;this.n33=z;this.n34=y;this.n41=u;this.n42=x;this.n43=G;this.n44=H;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +THREE.Matrix4=function(a,c,d,e,i,b,n,o,k,l,z,y,w,x,I,J){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=i||0;this.n22=b||1;this.n23=n||0;this.n24=o||0;this.n31=k||0;this.n32=l||0;this.n33=z||1;this.n34=y||0;this.n41=w||0;this.n42=x||0;this.n43=I||0;this.n44=J||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,i,b,n,o,k,l,z,y,w,x,I,J){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=i;this.n22=b;this.n23=n;this.n24=o;this.n31=k;this.n32=l;this.n33=z;this.n34=y;this.n41=w;this.n42=x;this.n43=I;this.n44=J;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,i=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();i.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a); this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,i=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*i;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*i;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*i;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,i=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*i;a.y=this.n21*c+this.n22*d+this.n23* -e+this.n24*i;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*i;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*i;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 d=a.n11,e=a.n12,i=a.n13,b=a.n14,n=a.n21,o=a.n22,l=a.n23,m=a.n24,z=a.n31, -y=a.n32,u=a.n33,x=a.n34,G=a.n41,H=a.n42,I=a.n43,p=a.n44,g=c.n11,h=c.n12,f=c.n13,j=c.n14,s=c.n21,t=c.n22,k=c.n23,B=c.n24,q=c.n31,C=c.n32,r=c.n33,v=c.n34,D=c.n41,W=c.n42,E=c.n43,O=c.n44;this.n11=d*g+e*s+i*q+b*D;this.n12=d*h+e*t+i*C+b*W;this.n13=d*f+e*k+i*r+b*E;this.n14=d*j+e*B+i*v+b*O;this.n21=n*g+o*s+l*q+m*D;this.n22=n*h+o*t+l*C+m*W;this.n23=n*f+o*k+l*r+m*E;this.n24=n*j+o*B+l*v+m*O;this.n31=z*g+y*s+u*q+x*D;this.n32=z*h+y*t+u*C+x*W;this.n33=z*f+y*k+u*r+x*E;this.n34=z*j+y*B+u*v+x*O;this.n41=G*g+H*s+ -I*q+p*D;this.n42=G*h+H*t+I*C+p*W;this.n43=G*f+H*k+I*r+p*E;this.n44=G*j+H*B+I*v+p*O;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,i=this.n14,b=this.n21,n=this.n22,o=this.n23,l=this.n24,m=this.n31,z=this.n32,y=this.n33,u=this.n34,x=this.n41,G=this.n42,H=this.n43,I=this.n44,p=a.n11,g=a.n21,h=a.n31,f=a.n41,j=a.n12,s=a.n22,t=a.n32,k=a.n42,B=a.n13,q=a.n23,C=a.n33,r=a.n43,v=a.n14,D=a.n24,W=a.n34;a=a.n44;this.n11=c*p+d*g+e*h+i*f;this.n12=c*j+d*s+e*t+i*k;this.n13=c*B+d*q+e*C+i* -r;this.n14=c*v+d*D+e*W+i*a;this.n21=b*p+n*g+o*h+l*f;this.n22=b*j+n*s+o*t+l*k;this.n23=b*B+n*q+o*C+l*r;this.n24=b*v+n*D+o*W+l*a;this.n31=m*p+z*g+y*h+u*f;this.n32=m*j+z*s+y*t+u*k;this.n33=m*B+z*q+y*C+u*r;this.n34=m*v+z*D+y*W+u*a;this.n41=x*p+G*g+H*h+I*f;this.n42=x*j+G*s+H*t+I*k;this.n43=x*B+G*q+H*C+I*r;this.n44=x*v+G*D+H*W+I*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,d=this.n13,e=this.n14,i=this.n21,b=this.n22,n=this.n23,o=this.n24,l=this.n31,m=this.n32,z=this.n33,y=this.n34,u=this.n41,x=this.n42,G=this.n43,H=this.n44;return e*n*m*u-d*o*m*u-e*b*z*u+c*o*z*u+d*b*y*u-c*n*y*u-e*n*l*x+d*o*l*x+e*i*z*x-a*o*z*x-d*i*y*x+a*n*y*x+e*b*l*G-c*o*l*G-e*i*m*G+a*o*m*G+c*i*y*G-a*b*y*G-d*b*l*H+c*n*l*H+d*i*m*H-a*n*m*H-c*i*z*H+a*b*z*H},transpose:function(){function a(c,d, +e+this.n24*i;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*i;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*i;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 d=a.n11,e=a.n12,i=a.n13,b=a.n14,n=a.n21,o=a.n22,k=a.n23,l=a.n24,z=a.n31, +y=a.n32,w=a.n33,x=a.n34,I=a.n41,J=a.n42,K=a.n43,s=a.n44,T=c.n11,F=c.n12,f=c.n13,j=c.n14,g=c.n21,h=c.n22,m=c.n23,u=c.n24,p=c.n31,q=c.n32,r=c.n33,v=c.n34,t=c.n41,L=c.n42,D=c.n43,R=c.n44;this.n11=d*T+e*g+i*p+b*t;this.n12=d*F+e*h+i*q+b*L;this.n13=d*f+e*m+i*r+b*D;this.n14=d*j+e*u+i*v+b*R;this.n21=n*T+o*g+k*p+l*t;this.n22=n*F+o*h+k*q+l*L;this.n23=n*f+o*m+k*r+l*D;this.n24=n*j+o*u+k*v+l*R;this.n31=z*T+y*g+w*p+x*t;this.n32=z*F+y*h+w*q+x*L;this.n33=z*f+y*m+w*r+x*D;this.n34=z*j+y*u+w*v+x*R;this.n41=I*T+J*g+ +K*p+s*t;this.n42=I*F+J*h+K*q+s*L;this.n43=I*f+J*m+K*r+s*D;this.n44=I*j+J*u+K*v+s*R;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,i=this.n14,b=this.n21,n=this.n22,o=this.n23,k=this.n24,l=this.n31,z=this.n32,y=this.n33,w=this.n34,x=this.n41,I=this.n42,J=this.n43,K=this.n44,s=a.n11,T=a.n21,F=a.n31,f=a.n41,j=a.n12,g=a.n22,h=a.n32,m=a.n42,u=a.n13,p=a.n23,q=a.n33,r=a.n43,v=a.n14,t=a.n24,L=a.n34;a=a.n44;this.n11=c*s+d*T+e*F+i*f;this.n12=c*j+d*g+e*h+i*m;this.n13=c*u+d*p+e*q+i* +r;this.n14=c*v+d*t+e*L+i*a;this.n21=b*s+n*T+o*F+k*f;this.n22=b*j+n*g+o*h+k*m;this.n23=b*u+n*p+o*q+k*r;this.n24=b*v+n*t+o*L+k*a;this.n31=l*s+z*T+y*F+w*f;this.n32=l*j+z*g+y*h+w*m;this.n33=l*u+z*p+y*q+w*r;this.n34=l*v+z*t+y*L+w*a;this.n41=x*s+I*T+J*F+K*f;this.n42=x*j+I*g+J*h+K*m;this.n43=x*u+I*p+J*q+K*r;this.n44=x*v+I*t+J*L+K*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,d=this.n13,e=this.n14,i=this.n21,b=this.n22,n=this.n23,o=this.n24,k=this.n31,l=this.n32,z=this.n33,y=this.n34,w=this.n41,x=this.n42,I=this.n43,J=this.n44;return e*n*l*w-d*o*l*w-e*b*z*w+c*o*z*w+d*b*y*w-c*n*y*w-e*n*k*x+d*o*k*x+e*i*z*x-a*o*z*x-d*i*y*x+a*n*y*x+e*b*k*I-c*o*k*I-e*i*l*I+a*o*l*I+c*i*y*I-a*b*y*I-d*b*k*J+c*n*k*J+d*i*l*J-a*n*l*J-c*i*z*J+a*b*z*J},transpose:function(){function a(c,d, e){var i=c[d];c[d]=c[e];c[e]=i}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){var a=this.flat;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},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c= -Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),i=1-d,b=a.x,n=a.y,o=a.z,l=i*b,m=i*n;this.set(l*b+d,l*n-e*o,l*o+e*n,0,l*n+e*o,m*n+d,m*o-e*b,0,l*o-e*n,m*o+e*b,i*o*o+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+ +Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),i=1-d,b=a.x,n=a.y,o=a.z,k=i*b,l=i*n;this.set(k*b+d,k*n-e*o,k*o+e*n,0,k*n+e*o,l*n+d,l*o-e*b,0,k*o-e*n,l*o+e*b,i*o*o+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+ this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c}; THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d}; -THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,i=a.n14,b=a.n21,n=a.n22,o=a.n23,l=a.n24,m=a.n31,z=a.n32,y=a.n33,u=a.n34,x=a.n41,G=a.n42,H=a.n43,I=a.n44,p=new THREE.Matrix4;p.n11=o*u*G-l*y*G+l*z*H-n*u*H-o*z*I+n*y*I;p.n12=i*y*G-e*u*G-i*z*H+d*u*H+e*z*I-d*y*I;p.n13=e*l*G-i*o*G+i*n*H-d*l*H-e*n*I+d*o*I;p.n14=i*o*z-e*l*z-i*n*y+d*l*y+e*n*u-d*o*u;p.n21=l*y*x-o*u*x-l*m*H+b*u*H+o*m*I-b*y*I;p.n22=e*u*x-i*y*x+i*m*H-c*u*H-e*m*I+c*y*I;p.n23=i*o*x-e*l*x-i*b*H+c*l*H+e*b*I-c*o*I;p.n24=e*l*m-i*o*m+ -i*b*y-c*l*y-e*b*u+c*o*u;p.n31=n*u*x-l*z*x+l*m*G-b*u*G-n*m*I+b*z*I;p.n32=i*z*x-d*u*x-i*m*G+c*u*G+d*m*I-c*z*I;p.n33=e*l*x-i*n*x+i*b*G-c*l*G-d*b*I+c*n*I;p.n34=i*n*m-d*l*m-i*b*z+c*l*z+d*b*u-c*n*u;p.n41=o*z*x-n*y*x-o*m*G+b*y*G+n*m*H-b*z*H;p.n42=d*y*x-e*z*x+e*m*G-c*y*G-d*m*H+c*z*H;p.n43=e*n*x-d*o*x-e*b*G+c*o*G+d*b*H-c*n*H;p.n44=d*o*m-e*n*m+e*b*z-c*o*z-d*b*y+c*n*y;p.multiplyScalar(1/a.determinant());return p}; -THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],i=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],n=-c[10]*c[4]+c[6]*c[8],o=c[10]*c[0]-c[2]*c[8],l=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],z=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*n+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*i;d[2]=c*b;d[3]=c*n;d[4]=c*o;d[5]=c*l;d[6]=c*m;d[7]=c*z;d[8]=c*y;return a}; -THREE.Matrix4.makeFrustum=function(a,c,d,e,i,b){var n,o,l;n=new THREE.Matrix4;o=2*i/(c-a);l=2*i/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+i)/(b-i);i=-2*b*i/(b-i);n.n11=o;n.n12=0;n.n13=a;n.n14=0;n.n21=0;n.n22=l;n.n23=d;n.n24=0;n.n31=0;n.n32=0;n.n33=e;n.n34=i;n.n41=0;n.n42=0;n.n43=-1;n.n44=0;return n};THREE.Matrix4.makePerspective=function(a,c,d,e){var i;a=d*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*c,a*c,i,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,c,d,e,i,b){var n,o,l,m;n=new THREE.Matrix4;o=c-a;l=d-e;m=b-i;a=(c+a)/o;d=(d+e)/l;i=(b+i)/m;n.n11=2/o;n.n12=0;n.n13=0;n.n14=-a;n.n21=0;n.n22=2/l;n.n23=0;n.n24=-d;n.n31=0;n.n32=0;n.n33=-2/m;n.n34=-i;n.n41=0;n.n42=0;n.n43=0;n.n44=1;return n};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; +THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,i=a.n14,b=a.n21,n=a.n22,o=a.n23,k=a.n24,l=a.n31,z=a.n32,y=a.n33,w=a.n34,x=a.n41,I=a.n42,J=a.n43,K=a.n44,s=new THREE.Matrix4;s.n11=o*w*I-k*y*I+k*z*J-n*w*J-o*z*K+n*y*K;s.n12=i*y*I-e*w*I-i*z*J+d*w*J+e*z*K-d*y*K;s.n13=e*k*I-i*o*I+i*n*J-d*k*J-e*n*K+d*o*K;s.n14=i*o*z-e*k*z-i*n*y+d*k*y+e*n*w-d*o*w;s.n21=k*y*x-o*w*x-k*l*J+b*w*J+o*l*K-b*y*K;s.n22=e*w*x-i*y*x+i*l*J-c*w*J-e*l*K+c*y*K;s.n23=i*o*x-e*k*x-i*b*J+c*k*J+e*b*K-c*o*K;s.n24=e*k*l-i*o*l+ +i*b*y-c*k*y-e*b*w+c*o*w;s.n31=n*w*x-k*z*x+k*l*I-b*w*I-n*l*K+b*z*K;s.n32=i*z*x-d*w*x-i*l*I+c*w*I+d*l*K-c*z*K;s.n33=e*k*x-i*n*x+i*b*I-c*k*I-d*b*K+c*n*K;s.n34=i*n*l-d*k*l-i*b*z+c*k*z+d*b*w-c*n*w;s.n41=o*z*x-n*y*x-o*l*I+b*y*I+n*l*J-b*z*J;s.n42=d*y*x-e*z*x+e*l*I-c*y*I-d*l*J+c*z*J;s.n43=e*n*x-d*o*x-e*b*I+c*o*I+d*b*J-c*n*J;s.n44=d*o*l-e*n*l+e*b*z-c*o*z-d*b*y+c*n*y;s.multiplyScalar(1/a.determinant());return s}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],i=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],n=-c[10]*c[4]+c[6]*c[8],o=c[10]*c[0]-c[2]*c[8],k=-c[6]*c[0]+c[2]*c[4],l=c[9]*c[4]-c[5]*c[8],z=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*n+c[2]*l;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*i;d[2]=c*b;d[3]=c*n;d[4]=c*o;d[5]=c*k;d[6]=c*l;d[7]=c*z;d[8]=c*y;return a}; +THREE.Matrix4.makeFrustum=function(a,c,d,e,i,b){var n,o,k;n=new THREE.Matrix4;o=2*i/(c-a);k=2*i/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+i)/(b-i);i=-2*b*i/(b-i);n.n11=o;n.n12=0;n.n13=a;n.n14=0;n.n21=0;n.n22=k;n.n23=d;n.n24=0;n.n31=0;n.n32=0;n.n33=e;n.n34=i;n.n41=0;n.n42=0;n.n43=-1;n.n44=0;return n};THREE.Matrix4.makePerspective=function(a,c,d,e){var i;a=d*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*c,a*c,i,a,d,e)}; +THREE.Matrix4.makeOrtho=function(a,c,d,e,i,b){var n,o,k,l;n=new THREE.Matrix4;o=c-a;k=d-e;l=b-i;a=(c+a)/o;d=(d+e)/k;i=(b+i)/l;n.n11=2/o;n.n12=0;n.n13=0;n.n14=-a;n.n21=0;n.n22=2/k;n.n23=0;n.n24=-d;n.n31=0;n.n32=0;n.n33=-2/l;n.n34=-i;n.n41=0;n.n42=0;n.n43=0;n.n44=1;return n};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; 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=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; THREE.Face3=function(a,c,d,e,i){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; THREE.Face4=function(a,c,d,e,i,b){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0}; THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], +this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=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,d=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,d=this.vertices.length;c65535){m[o].counter+=1;l=m[o].hash+"_"+m[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:n,vertices:0}}this.geometryChunks[l].faces.push(e);this.geometryChunks[l].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+ +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,d=this.vertices.length;c65535){l[o].counter+=1;k=l[o].hash+"_"+l[o].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:n,vertices:0}}this.geometryChunks[k].faces.push(e);this.geometryChunks[k].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; this.translateZ=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()}; @@ -61,9 +61,9 @@ THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.positio THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0}; -THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c]};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; +THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()}; -THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; +THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3; THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}}; THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!== @@ -98,99 +98,100 @@ var Uniforms={clone:function(a){var c,d,e,i={};for(c in a){i[c]={};for(d in a[c] THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}}; THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4}; -THREE.Projector=function(){function a(t,k){return k.z-t.z}function c(t,k){var B=0,q=1,C=t.z+t.w,r=k.z+k.w,v=-t.z+t.w,D=-k.z+k.w;if(C>=0&&r>=0&&v>=0&&D>=0)return true;else if(C<0&&r<0||v<0&&D<0)return false;else{if(C<0)B=Math.max(B,C/(C-r));else if(r<0)q=Math.min(q,C/(C-r));if(v<0)B=Math.max(B,v/(v-D));else if(D<0)q=Math.min(q,v/(v-D));if(qC&&E.z0&&I.z<1){u=G[x]=G[x]||new THREE.RenderableParticle;u.x=I.x/I.w;u.y=I.y/I.w;u.z=I.z;u.rotation=J.rotation.z;u.scale.x=J.scale.x*Math.abs(u.x-(I.x+k.projectionMatrix.n11)/(I.w+k.projectionMatrix.n14)); -u.scale.y=J.scale.y*Math.abs(u.y-(I.y+k.projectionMatrix.n22)/(I.w+k.projectionMatrix.n24));u.materials=J.materials;q.push(u);x++}}}}B&&q.sort(a);return q};this.unprojectVector=function(t,k){var B=THREE.Matrix4.makeInvert(k.matrix);B.multiplySelf(THREE.Matrix4.makeInvert(k.projectionMatrix));B.multiplyVector3(t);return t}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,i,b;this.domElement=document.createElement("div");this.setSize=function(n,o){d=n;e=o;i=d/2;b=e/2};this.render=function(n,o){var l,m,z,y,u,x,G,H;a=c.projectScene(n,o);l=0;for(m=a.length;l0){F.r+=fa.r*Z;F.g+=fa.g*Z;F.b+=fa.b*Z}}else if(Z instanceof THREE.PointLight){Y.sub(Z.position,X);Y.normalize();Z=T.dot(Y)*ha;if(Z>0){F.r+=fa.r*Z;F.g+=fa.g*Z;F.b+=fa.b*Z}}}}function Na(A,X,T){if(T.opacity!=0){a(T.opacity);c(T.blending); -var F,R,Z,fa,ha,ia;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){fa=T.map.image;ha=fa.width>>1;ia=fa.height>>1;R=X.scale.x*o;Z=X.scale.y*l;T=R*ha;F=Z*ia;w.set(A.x-T,A.y-F,A.x+T,A.y+F);if(!U.instersects(w))return;m.save();m.translate(A.x,A.y);m.rotate(-X.rotation);m.scale(R,-Z);m.translate(-ha,-ia);m.drawImage(fa,0,0);m.restore()}m.beginPath();m.moveTo(A.x-10,A.y);m.lineTo(A.x+10,A.y);m.moveTo(A.x,A.y-10);m.lineTo(A.x,A.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)"; -m.stroke()}else if(T instanceof THREE.ParticleCircleMaterial){if(L){Q.r=ga.r+ja.r+ca.r;Q.g=ga.g+ja.g+ca.g;Q.b=ga.b+ja.b+ca.b;q.r=T.color.r*Q.r;q.g=T.color.g*Q.g;q.b=T.color.b*Q.b;q.updateStyleString()}else q.__styleString=T.color.__styleString;T=X.scale.x*o;F=X.scale.y*l;w.set(A.x-T,A.y-F,A.x+T,A.y+F);if(U.instersects(w)){R=q.__styleString;if(H!=R)m.fillStyle=H=R;m.save();m.translate(A.x,A.y);m.rotate(-X.rotation);m.scale(T,F);m.beginPath();m.arc(0,0,1,0,$,true);m.closePath();m.fill();m.restore()}}}} -function Oa(A,X,T,F){if(F.opacity!=0){a(F.opacity);c(F.blending);m.beginPath();m.moveTo(A.positionScreen.x,A.positionScreen.y);m.lineTo(X.positionScreen.x,X.positionScreen.y);m.closePath();if(F instanceof THREE.LineBasicMaterial){q.__styleString=F.color.__styleString;A=F.linewidth;if(I!=A)m.lineWidth=I=A;A=q.__styleString;if(G!=A)m.strokeStyle=G=A;m.stroke();w.inflate(F.linewidth*2)}}}function Ia(A,X,T,F,R,Z){if(R.opacity!=0){a(R.opacity);c(R.blending);f=A.positionScreen.x;j=A.positionScreen.y;s= -X.positionScreen.x;t=X.positionScreen.y;k=T.positionScreen.x;B=T.positionScreen.y;m.beginPath();m.moveTo(f,j);m.lineTo(s,t);m.lineTo(k,B);m.lineTo(f,j);m.closePath();if(R instanceof THREE.MeshBasicMaterial)if(R.map)R.map.image.loaded&&R.map.mapping instanceof THREE.UVMapping&&xa(f,j,s,t,k,B,R.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(R.env_map){if(R.env_map.image.loaded)if(R.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=ta.matrix;Y.copy(F.vertexNormalsWorld[0]); -M=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;J=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;Y.copy(F.vertexNormalsWorld[1]);S=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;V=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;Y.copy(F.vertexNormalsWorld[2]);N=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;K=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;xa(f,j,s,t,k,B,R.env_map.image,M,J,S,V,N,K)}}else R.wireframe?Ba(R.color.__styleString,R.wireframe_linewidth):Ca(R.color.__styleString);else if(R instanceof THREE.MeshLambertMaterial){if(R.map&& -!R.wireframe){R.map.mapping instanceof THREE.UVMapping&&xa(f,j,s,t,k,B,R.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);c(THREE.SubtractiveBlending)}if(L)if(!R.wireframe&&R.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){C.r=r.r=v.r=ga.r;C.g=r.g=v.g=ga.g;C.b=r.b=v.b=ga.b;Aa(Z,F.v1.positionWorld,F.vertexNormalsWorld[0],C);Aa(Z,F.v2.positionWorld,F.vertexNormalsWorld[1],r);Aa(Z,F.v3.positionWorld,F.vertexNormalsWorld[2],v);D.r=(r.r+v.r)*0.5;D.g=(r.g+v.g)* -0.5;D.b=(r.b+v.b)*0.5;O=Ja(C,r,v,D);xa(f,j,s,t,k,B,O,0,0,1,0,0,1)}else{Q.r=ga.r;Q.g=ga.g;Q.b=ga.b;Aa(Z,F.centroidWorld,F.normalWorld,Q);q.r=R.color.r*Q.r;q.g=R.color.g*Q.g;q.b=R.color.b*Q.b;q.updateStyleString();R.wireframe?Ba(q.__styleString,R.wireframe_linewidth):Ca(q.__styleString)}else R.wireframe?Ba(R.color.__styleString,R.wireframe_linewidth):Ca(R.color.__styleString)}else if(R instanceof THREE.MeshDepthMaterial){W=ta.near;E=ta.far;C.r=C.g=C.b=1-Ea(A.positionScreen.z,W,E);r.r=r.g=r.b=1-Ea(X.positionScreen.z, -W,E);v.r=v.g=v.b=1-Ea(T.positionScreen.z,W,E);D.r=(r.r+v.r)*0.5;D.g=(r.g+v.g)*0.5;D.b=(r.b+v.b)*0.5;O=Ja(C,r,v,D);xa(f,j,s,t,k,B,O,0,0,1,0,0,1)}else if(R instanceof THREE.MeshNormalMaterial){q.r=Fa(F.normalWorld.x);q.g=Fa(F.normalWorld.y);q.b=Fa(F.normalWorld.z);q.updateStyleString();R.wireframe?Ba(q.__styleString,R.wireframe_linewidth):Ca(q.__styleString)}}}function Ba(A,X){if(G!=A)m.strokeStyle=G=A;if(I!=X)m.lineWidth=I=X;m.stroke();w.inflate(X*2)}function Ca(A){if(H!=A)m.fillStyle=H=A;m.fill()} -function xa(A,X,T,F,R,Z,fa,ha,ia,na,ka,oa,ya){var ua,pa;ua=fa.width-1;pa=fa.height-1;ha*=ua;ia*=pa;na*=ua;ka*=pa;oa*=ua;ya*=pa;T-=A;F-=X;R-=A;Z-=X;na-=ha;ka-=ia;oa-=ha;ya-=ia;pa=1/(na*ya-oa*ka);ua=(ya*T-ka*R)*pa;ka=(ya*F-ka*Z)*pa;T=(na*R-oa*T)*pa;F=(na*Z-oa*F)*pa;A=A-ua*ha-T*ia;X=X-ka*ha-F*ia;m.save();m.transform(ua,ka,T,F,A,X);m.clip();m.drawImage(fa,0,0);m.restore()}function Ja(A,X,T,F){var R=~~(A.r*255),Z=~~(A.g*255);A=~~(A.b*255);var fa=~~(X.r*255),ha=~~(X.g*255);X=~~(X.b*255);var ia=~~(T.r*255), -na=~~(T.g*255);T=~~(T.b*255);var ka=~~(F.r*255),oa=~~(F.g*255);F=~~(F.b*255);aa[0]=R<0?0:R>255?255:R;aa[1]=Z<0?0:Z>255?255:Z;aa[2]=A<0?0:A>255?255:A;aa[4]=fa<0?0:fa>255?255:fa;aa[5]=ha<0?0:ha>255?255:ha;aa[6]=X<0?0:X>255?255:X;aa[8]=ia<0?0:ia>255?255:ia;aa[9]=na<0?0:na>255?255:na;aa[10]=T<0?0:T>255?255:T;aa[12]=ka<0?0:ka>255?255:ka;aa[13]=oa<0?0:oa>255?255:oa;aa[14]=F<0?0:F>255?255:F;qa.putImageData(la,0,0);va.drawImage(da,0,0);return ra}function Ea(A,X,T){A=(A-X)/(T-X);return A*A*(3-2*A)}function Fa(A){A= -(A+1)*0.5;return A<0?0:A>1?1:A}function Ga(A,X){var T=X.x-A.x,F=X.y-A.y,R=1/Math.sqrt(T*T+F*F);T*=R;F*=R;X.x+=T;X.y+=F;A.x-=T;A.y-=F}var Da,Ka,ba,ma,wa,Ha,La,za;this.autoClear?this.clear():m.setTransform(1,0,0,-1,o,l);d=e.projectScene(ea,ta,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(U.getX(),U.getY(),U.getWidth(),U.getHeight());(L=ea.lights.length>0)&&Ma(ea);Da=0;for(Ka=d.length;Da0){S.r+=K.color.r*U;S.g+=K.color.g*U;S.b+=K.color.b*U}}else if(K instanceof THREE.PointLight){B.sub(K.position,J.centroidWorld);B.normalize();U=J.normalWorld.dot(B)*K.intensity;if(U>0){S.r+=K.color.r*U;S.g+=K.color.g*U;S.b+=K.color.b*U}}}}function c(M,J,S,V,N,K){v=e(D++);v.setAttribute("d","M "+M.positionScreen.x+ -" "+M.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)h.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(g){f.r=j.r;f.g=j.g;f.b=j.b;a(K,V,f);h.r=N.color.r*f.r;h.g=N.color.g*f.g;h.b=N.color.b*f.b;h.updateStyleString()}else h.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshDepthMaterial){k=1-N.__2near/(N.__farPlusNear-V.z*N.__farMinusNear); -h.setRGB(k,k,k)}else N instanceof THREE.MeshNormalMaterial&&h.setRGB(i(V.normalWorld.x),i(V.normalWorld.y),i(V.normalWorld.z));N.wireframe?v.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):v.setAttribute("style","fill: "+h.__styleString+"; fill-opacity: "+N.opacity);o.appendChild(v)}function d(M,J,S,V,N,K,U){v=e(D++);v.setAttribute("d", -"M "+M.positionScreen.x+" "+M.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+S.positionScreen.x+","+S.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(K instanceof THREE.MeshBasicMaterial)h.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshLambertMaterial)if(g){f.r=j.r;f.g=j.g;f.b=j.b;a(U,N,f);h.r=K.color.r*f.r;h.g=K.color.g*f.g;h.b=K.color.b*f.b;h.updateStyleString()}else h.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshDepthMaterial){k= -1-K.__2near/(K.__farPlusNear-N.z*K.__farMinusNear);h.setRGB(k,k,k)}else K instanceof THREE.MeshNormalMaterial&&h.setRGB(i(N.normalWorld.x),i(N.normalWorld.y),i(N.normalWorld.z));K.wireframe?v.setAttribute("style","fill: none; stroke: "+h.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: "+K.wireframe_linecap+"; stroke-linejoin: "+K.wireframe_linejoin):v.setAttribute("style","fill: "+h.__styleString+"; fill-opacity: "+K.opacity);o.appendChild(v)} -function e(M){if(q[M]==null){q[M]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&q[M].setAttribute("shape-rendering","crispEdges");return q[M]}return q[M]}function i(M){return M<0?Math.min((1+M)*0.5,0.5):0.5+Math.min(M*0.5,0.5)}var b=null,n=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,z,y,u,x,G,H,I=new THREE.Rectangle,p=new THREE.Rectangle,g=false,h=new THREE.Color(16777215),f=new THREE.Color(16777215),j=new THREE.Color(0),s=new THREE.Color(0), -t=new THREE.Color(0),k,B=new THREE.Vector3,q=[],C=[],r=[],v,D,W,E,O=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(M){switch(M){case "high":O=1;break;case "low":O=0}};this.setSize=function(M,J){l=M;m=J;z=l/2;y=m/2;o.setAttribute("viewBox",-z+" "+-y+" "+l+" "+m);o.setAttribute("width",l);o.setAttribute("height",m);I.set(-z,-y,z,y)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(M,J){var S,V, -N,K,U,P,w,L;this.autoClear&&this.clear();b=n.projectScene(M,J,this.sortElements);E=W=D=0;if(g=M.lights.length>0){w=M.lights;j.setRGB(0,0,0);s.setRGB(0,0,0);t.setRGB(0,0,0);S=0;for(V=w.length;S=0&&r>=0&&v>=0&&t>=0)return true;else if(q<0&&r<0||v<0&&t<0)return false;else{if(q<0)u=Math.max(u,q/(q-r));else if(r<0)p=Math.min(p,q/(q-r));if(v<0)u=Math.max(u,v/(v-t));else if(t<0)p=Math.min(p,v/(v-t));if(pq&&D.z0&&K.z<1){w=I[x]=I[x]||new THREE.RenderableParticle;w.x=K.x/K.w;w.y=K.y/K.w;w.z=K.z;w.rotation=H.rotation.z;w.scale.x=H.scale.x*Math.abs(w.x-(K.x+m.projectionMatrix.n11)/(K.w+m.projectionMatrix.n14)); +w.scale.y=H.scale.y*Math.abs(w.y-(K.y+m.projectionMatrix.n22)/(K.w+m.projectionMatrix.n24));w.materials=H.materials;p.push(w);x++}}}}u&&p.sort(a);return p};this.unprojectVector=function(h,m){var u=THREE.Matrix4.makeInvert(m.matrix);u.multiplySelf(THREE.Matrix4.makeInvert(m.projectionMatrix));u.multiplyVector3(h);return h}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,i,b;this.domElement=document.createElement("div");this.setSize=function(n,o){d=n;e=o;i=d/2;b=e/2};this.render=function(n,o){var k,l,z,y,w,x,I,J;a=c.projectScene(n,o);k=0;for(l=a.length;k0){E.r+=ea.r*$;E.g+=ea.g*$;E.b+=ea.b*$}}else if($ instanceof THREE.PointLight){Y.sub($.position,W);Y.normalize();$=S.dot(Y)*ha;if($>0){E.r+=ea.r*$;E.g+=ea.g*$;E.b+=ea.b*$}}}}function Na(A,W,S){if(S.opacity!=0){a(S.opacity);c(S.blending); +var E,P,$,ea,ha,ka;if(S instanceof THREE.ParticleBasicMaterial){if(S.map&&S.map.image.loaded){ea=S.map.image;ha=ea.width>>1;ka=ea.height>>1;P=W.scale.x*o;$=W.scale.y*k;S=P*ha;E=$*ka;B.set(A.x-S,A.y-E,A.x+S,A.y+E);if(!V.instersects(B))return;l.save();l.translate(A.x,A.y);l.rotate(-W.rotation);l.scale(P,-$);l.translate(-ha,-ka);l.drawImage(ea,0,0);l.restore()}l.beginPath();l.moveTo(A.x-10,A.y);l.lineTo(A.x+10,A.y);l.moveTo(A.x,A.y-10);l.lineTo(A.x,A.y+10);l.closePath();l.strokeStyle="rgb(255,255,0)"; +l.stroke()}else if(S instanceof THREE.ParticleCircleMaterial){if(M){N.r=aa.r+ba.r+la.r;N.g=aa.g+ba.g+la.g;N.b=aa.b+ba.b+la.b;p.r=S.color.r*N.r;p.g=S.color.g*N.g;p.b=S.color.b*N.b;p.updateStyleString()}else p.__styleString=S.color.__styleString;S=W.scale.x*o;E=W.scale.y*k;B.set(A.x-S,A.y-E,A.x+S,A.y+E);if(V.instersects(B)){P=p.__styleString;if(J!=P)l.fillStyle=J=P;l.save();l.translate(A.x,A.y);l.rotate(-W.rotation);l.scale(S,E);l.beginPath();l.arc(0,0,1,0,ua,true);l.closePath();l.fill();l.restore()}}}} +function Oa(A,W,S,E){if(E.opacity!=0){a(E.opacity);c(E.blending);l.beginPath();l.moveTo(A.positionScreen.x,A.positionScreen.y);l.lineTo(W.positionScreen.x,W.positionScreen.y);l.closePath();if(E instanceof THREE.LineBasicMaterial){p.__styleString=E.color.__styleString;A=E.linewidth;if(K!=A)l.lineWidth=K=A;A=p.__styleString;if(I!=A)l.strokeStyle=I=A;l.stroke();B.inflate(E.linewidth*2)}}}function Ja(A,W,S,E,P,$){if(P.opacity!=0){a(P.opacity);c(P.blending);f=A.positionScreen.x;j=A.positionScreen.y;g= +W.positionScreen.x;h=W.positionScreen.y;m=S.positionScreen.x;u=S.positionScreen.y;l.beginPath();l.moveTo(f,j);l.lineTo(g,h);l.lineTo(m,u);l.lineTo(f,j);l.closePath();if(P instanceof THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&xa(f,j,g,h,m,u,P.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=oa.matrix;Y.copy(E.vertexNormalsWorld[0]); +O=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;H=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;Y.copy(E.vertexNormalsWorld[1]);Q=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;X=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;Y.copy(E.vertexNormalsWorld[2]);G=(Y.x*A.n11+Y.y*A.n12+Y.z*A.n13)*0.5+0.5;C=-(Y.x*A.n21+Y.y*A.n22+Y.z*A.n23)*0.5+0.5;xa(f,j,g,h,m,u,P.env_map.image,O,H,Q,X,G,C)}}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&& +!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&xa(f,j,g,h,m,u,P.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);c(THREE.SubtractiveBlending)}if(M)if(!P.wireframe&&P.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){q.r=r.r=v.r=aa.r;q.g=r.g=v.g=aa.g;q.b=r.b=v.b=aa.b;Aa($,E.v1.positionWorld,E.vertexNormalsWorld[0],q);Aa($,E.v2.positionWorld,E.vertexNormalsWorld[1],r);Aa($,E.v3.positionWorld,E.vertexNormalsWorld[2],v);t.r=(r.r+v.r)*0.5;t.g=(r.g+v.g)* +0.5;t.b=(r.b+v.b)*0.5;R=Ka(q,r,v,t);xa(f,j,g,h,m,u,R,0,0,1,0,0,1)}else{N.r=aa.r;N.g=aa.g;N.b=aa.b;Aa($,E.centroidWorld,E.normalWorld,N);p.r=P.color.r*N.r;p.g=P.color.g*N.g;p.b=P.color.b*N.b;p.updateStyleString();P.wireframe?Ba(p.__styleString,P.wireframe_linewidth):Ca(p.__styleString)}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){L=oa.near;D=oa.far;q.r=q.g=q.b=1-Fa(A.positionScreen.z,L,D);r.r=r.g=r.b=1-Fa(W.positionScreen.z, +L,D);v.r=v.g=v.b=1-Fa(S.positionScreen.z,L,D);t.r=(r.r+v.r)*0.5;t.g=(r.g+v.g)*0.5;t.b=(r.b+v.b)*0.5;R=Ka(q,r,v,t);xa(f,j,g,h,m,u,R,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){p.r=Ga(E.normalWorld.x);p.g=Ga(E.normalWorld.y);p.b=Ga(E.normalWorld.z);p.updateStyleString();P.wireframe?Ba(p.__styleString,P.wireframe_linewidth):Ca(p.__styleString)}}}function Ba(A,W){if(I!=A)l.strokeStyle=I=A;if(K!=W)l.lineWidth=K=W;l.stroke();B.inflate(W*2)}function Ca(A){if(J!=A)l.fillStyle=J=A;l.fill()} +function xa(A,W,S,E,P,$,ea,ha,ka,ra,na,sa,ya){var va,ta;va=ea.width-1;ta=ea.height-1;ha*=va;ka*=ta;ra*=va;na*=ta;sa*=va;ya*=ta;S-=A;E-=W;P-=A;$-=W;ra-=ha;na-=ka;sa-=ha;ya-=ka;ta=1/(ra*ya-sa*na);va=(ya*S-na*P)*ta;na=(ya*E-na*$)*ta;S=(ra*P-sa*S)*ta;E=(ra*$-sa*E)*ta;A=A-va*ha-S*ka;W=W-na*ha-E*ka;l.save();l.transform(va,na,S,E,A,W);l.clip();l.drawImage(ea,0,0);l.restore()}function Ka(A,W,S,E){var P=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var ea=~~(W.r*255),ha=~~(W.g*255);W=~~(W.b*255);var ka=~~(S.r*255), +ra=~~(S.g*255);S=~~(S.b*255);var na=~~(E.r*255),sa=~~(E.g*255);E=~~(E.b*255);ja[0]=P<0?0:P>255?255:P;ja[1]=$<0?0:$>255?255:$;ja[2]=A<0?0:A>255?255:A;ja[4]=ea<0?0:ea>255?255:ea;ja[5]=ha<0?0:ha>255?255:ha;ja[6]=W<0?0:W>255?255:W;ja[8]=ka<0?0:ka>255?255:ka;ja[9]=ra<0?0:ra>255?255:ra;ja[10]=S<0?0:S>255?255:S;ja[12]=na<0?0:na>255?255:na;ja[13]=sa<0?0:sa>255?255:sa;ja[14]=E<0?0:E>255?255:E;ia.putImageData(fa,0,0);ga.drawImage(Z,0,0);return ma}function Fa(A,W,S){A=(A-W)/(S-W);return A*A*(3-2*A)}function Ga(A){A= +(A+1)*0.5;return A<0?0:A>1?1:A}function Ha(A,W){var S=W.x-A.x,E=W.y-A.y,P=1/Math.sqrt(S*S+E*E);S*=P;E*=P;W.x+=S;W.y+=E;A.x-=S;A.y-=E}var Da,La,ca,pa,wa,Ia,Ma,za;this.autoClear?this.clear():l.setTransform(1,0,0,-1,o,k);d=e.projectScene(da,oa,this.sortElements);l.fillStyle="rgba( 0, 255, 255, 0.5 )";l.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight());(M=da.lights.length>0)&&Ea(da);Da=0;for(La=d.length;Da0){Q.r+=C.color.r*V;Q.g+=C.color.g*V;Q.b+=C.color.b*V}}else if(C instanceof THREE.PointLight){u.sub(C.position,H.centroidWorld);u.normalize();V=H.normalWorld.dot(u)*C.intensity;if(V>0){Q.r+=C.color.r*V;Q.g+=C.color.g*V;Q.b+=C.color.b*V}}}}function c(O,H,Q,X,G,C){v=e(t++);v.setAttribute("d","M "+O.positionScreen.x+ +" "+O.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(G instanceof THREE.MeshBasicMaterial)F.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshLambertMaterial)if(T){f.r=j.r;f.g=j.g;f.b=j.b;a(C,X,f);F.r=G.color.r*f.r;F.g=G.color.g*f.g;F.b=G.color.b*f.b;F.updateStyleString()}else F.__styleString=G.color.__styleString;else if(G instanceof THREE.MeshDepthMaterial){m=1-G.__2near/(G.__farPlusNear-X.z*G.__farMinusNear); +F.setRGB(m,m,m)}else G instanceof THREE.MeshNormalMaterial&&F.setRGB(i(X.normalWorld.x),i(X.normalWorld.y),i(X.normalWorld.z));G.wireframe?v.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+G.wireframe_linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.wireframe_linecap+"; stroke-linejoin: "+G.wireframe_linejoin):v.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+G.opacity);o.appendChild(v)}function d(O,H,Q,X,G,C,V){v=e(t++);v.setAttribute("d", +"M "+O.positionScreen.x+" "+O.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)F.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(T){f.r=j.r;f.g=j.g;f.b=j.b;a(V,G,f);F.r=C.color.r*f.r;F.g=C.color.g*f.g;F.b=C.color.b*f.b;F.updateStyleString()}else F.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){m= +1-C.__2near/(C.__farPlusNear-G.z*C.__farMinusNear);F.setRGB(m,m,m)}else C instanceof THREE.MeshNormalMaterial&&F.setRGB(i(G.normalWorld.x),i(G.normalWorld.y),i(G.normalWorld.z));C.wireframe?v.setAttribute("style","fill: none; stroke: "+F.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):v.setAttribute("style","fill: "+F.__styleString+"; fill-opacity: "+C.opacity);o.appendChild(v)} +function e(O){if(p[O]==null){p[O]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&p[O].setAttribute("shape-rendering","crispEdges");return p[O]}return p[O]}function i(O){return O<0?Math.min((1+O)*0.5,0.5):0.5+Math.min(O*0.5,0.5)}var b=null,n=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,z,y,w,x,I,J,K=new THREE.Rectangle,s=new THREE.Rectangle,T=false,F=new THREE.Color(16777215),f=new THREE.Color(16777215),j=new THREE.Color(0),g=new THREE.Color(0), +h=new THREE.Color(0),m,u=new THREE.Vector3,p=[],q=[],r=[],v,t,L,D,R=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(O){switch(O){case "high":R=1;break;case "low":R=0}};this.setSize=function(O,H){k=O;l=H;z=k/2;y=l/2;o.setAttribute("viewBox",-z+" "+-y+" "+k+" "+l);o.setAttribute("width",k);o.setAttribute("height",l);K.set(-z,-y,z,y)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(O,H){var Q,X, +G,C,V,U,B,M;this.autoClear&&this.clear();b=n.projectScene(O,H,this.sortElements);D=L=t=0;if(T=O.lights.length>0){B=O.lights;j.setRGB(0,0,0);g.setRGB(0,0,0);h.setRGB(0,0,0);Q=0;for(X=B.length;Q0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ga,f)}if(t&&K>0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,ja,f)}if(s){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER, -g.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Y,f);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,da,f)}};this.setLineBuffers=function(g,h,f,j){var s,t,k=g.vertices,B=k.length,q=g.__vertexArray,C=g.__lineArray;if(f)for(f=0;f0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP": -"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(f,d("fragment",s+q));b.attachShader(f,d("vertex",t+h));b.linkProgram(f);b.getProgramParameter(f,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(f,b.VALIDATE_STATUS)+ -", gl error ["+b.getError()+"]");f.uniforms={};f.attributes={};g.program=f;f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(j in g.uniforms)f.push(j);j=g.program;q=0;for(h=f.length;q=0){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLNormalBuffer);b.vertexAttribPointer(k.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.normal)}if(k.tangent>= -0){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLTangentBuffer);b.vertexAttribPointer(k.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.tangent)}if(k.uv>=0)if(s.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLUVBuffer);b.vertexAttribPointer(k.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv)}else b.disableVertexAttribArray(k.uv);if(k.uv2>=0)if(s.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,s.__webGLUV2Buffer);b.vertexAttribPointer(k.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(k.uv2)}else b.disableVertexAttribArray(k.uv2); -if(j.wireframe||j instanceof THREE.LineBasicMaterial){k=j.wireframe_linewidth!==undefined?j.wireframe_linewidth:j.linewidth!==undefined?j.linewidth:1;j=j instanceof THREE.LineBasicMaterial&&t.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(k);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,s.__webGLLineBuffer);b.drawElements(j,s.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(j instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,s.__webGLParticleBuffer);b.drawElements(b.POINTS,s.__webGLParticleCount, -b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,s.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,s.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(g,h,f,j,s,t,k){var B,q,C,r,v;C=0;for(r=j.materials.length;C=0;f--){j=g.__webGLObjects[f].object;h==j&&g.__webGLObjects.splice(f, -1)}};this.setupMatrices=function(g,h){g.autoUpdateMatrix&&g.updateMatrix();l.multiply(h.matrix,g.matrix);y.set(l.flatten());m=THREE.Matrix4.makeInvert3x3(l).transpose();x.set(m.m);G.set(g.matrix.flatten())};this.loadMatrices=function(g){b.uniformMatrix4fv(g.uniforms.viewMatrix,false,z);b.uniformMatrix4fv(g.uniforms.modelViewMatrix,false,y);b.uniformMatrix4fv(g.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(g.uniforms.normalMatrix,false,x);b.uniformMatrix4fv(g.uniforms.objectMatrix,false,G)}; -this.loadCamera=function(g,h){b.uniform3f(g.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(g){switch(g){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(g,h){if(g){!h||h=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(g=="back")b.cullFace(b.BACK); -else g=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; -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, 1.0 ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif", +case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var i=document.createElement("canvas"),b,n=null,o=null,k=new THREE.Matrix4,l,z=new Float32Array(16),y=new Float32Array(16), +w=new Float32Array(16),x=new Float32Array(9),I=new Float32Array(16),J=new THREE.Matrix4,K=new THREE.Vector4,s=true,T=new THREE.Color(0),F=0;if(a){if(a.antialias!==undefined)s=a.antialias;a.clearColor!==undefined&&T.setHex(a.clearColor);if(a.clearAlpha!==undefined)F=a.clearAlpha}this.domElement=i;this.autoClear=true;(function(f,j,g){try{b=i.getContext("experimental-webgl",{antialias:f})}catch(h){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1); +b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(j.r,j.g,j.b,g)})(s,T,F);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,j){i.width=f;i.height=j;b.viewport(0,0,i.width,i.height)};this.setClearColor=function(f,j){var g=new THREE.Color(f);b.clearColor(g.r,g.g,g.b,j)}; +this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(f,j){var g,h,m,u=0,p=0,q=0,r,v,t,L=this.lights,D=L.directional.colors,R=L.directional.positions,O=L.point.colors,H=L.point.positions,Q=0,X=0;g=0;for(h=j.length;g0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,la,g)}if(u&& +U>0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,ua,g)}if(m){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ia,g);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,fa,g)}};this.setLineBuffers=function(f,j,g,h){var m,u,p=f.vertices,q=p.length,r=f.__vertexArray,v=f.__lineArray;if(g)for(g=0;g0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+u.maxDirLights,"#define MAX_POINT_LIGHTS "+u.maxPointLights,u.map?"#define USE_MAP":"",u.env_map?"#define USE_ENVMAP":"",u.light_map?"#define USE_LIGHTMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n"); +b.attachShader(g,d("fragment",m+r));b.attachShader(g,d("vertex",u+j));b.linkProgram(g);b.getProgramParameter(g,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(g,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");g.uniforms={};g.attributes={};f.program=g;g=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in f.uniforms)g.push(h);h=f.program;r=0;for(j=g.length;r=0){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLNormalBuffer);b.vertexAttribPointer(p.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(p.normal)}if(p.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLTangentBuffer);b.vertexAttribPointer(p.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(p.tangent)}if(p.uv>=0)if(m.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLUVBuffer);b.vertexAttribPointer(p.uv,2,b.FLOAT,false,0,0); +b.enableVertexAttribArray(p.uv)}else b.disableVertexAttribArray(p.uv);if(p.uv2>=0)if(m.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,m.__webGLUV2Buffer);b.vertexAttribPointer(p.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(p.uv2)}else b.disableVertexAttribArray(p.uv2);if(h.wireframe||h instanceof THREE.LineBasicMaterial){p=h.wireframe_linewidth!==undefined?h.wireframe_linewidth:h.linewidth!==undefined?h.linewidth:1;h=h instanceof THREE.LineBasicMaterial&&u.type==THREE.LineStrip?b.LINE_STRIP: +b.LINES;b.lineWidth(p);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.__webGLLineBuffer);b.drawElements(h,m.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(h instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.__webGLParticleBuffer);b.drawElements(b.POINTS,m.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,m.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,m.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(f,j,g,h,m,u,p){var q,r,v,t,L;v=0; +for(t=h.materials.length;v=0;g--){h=f.__webGLObjects[g].object;j==h&&f.__webGLObjects.splice(g,1)}};this.setupMatrices= +function(f,j){k.multiply(j.matrix,f.matrix);y.set(k.flatten());l=THREE.Matrix4.makeInvert3x3(k).transpose();x.set(l.m);I.set(f.matrix.flatten())};this.loadMatrices=function(f){b.uniformMatrix4fv(f.uniforms.viewMatrix,false,z);b.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,y);b.uniformMatrix4fv(f.uniforms.projectionMatrix,false,w);b.uniformMatrix3fv(f.uniforms.normalMatrix,false,x);b.uniformMatrix4fv(f.uniforms.objectMatrix,false,I)};this.loadCamera=function(f,j){b.uniform3f(f.uniforms.cameraPosition, +j.position.x,j.position.y,j.position.z)};this.setBlending=function(f){switch(f){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(f,j){if(f){!j||j=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW); +if(f=="back")b.cullFace(b.BACK);else f=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; +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 env_map;\nuniform int combine;\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\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 ), refraction_ratio );\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",map_particle_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif", lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\nlightmapColor = texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", diff --git a/build/ThreeExtras.js b/build/ThreeExtras.js index 971c6794..6276dc2d 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -1,6 +1,6 @@ // ThreeExtras.js r32 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)}; -THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,g,b,l,j,h;if(d==0)e=g=b=0;else{l=Math.floor(a*6);j=a*6-l;a=d*(1-c);h=d*(1-c*j);c=d*(1-c*(1-j));switch(l){case 1:e=h;g=d;b=a;break;case 2:e=a;g=d;b=c;break;case 3:e=a;g=h;b=d;break;case 4:e=c;g=a;b=d;break;case 5:e=d;g=a;b=h;break;case 6:case 0:e=d;g=c;b=a}}this.r=e;this.g=g;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, +THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var e,f,b,j,h,g;if(d==0)e=f=b=0;else{j=Math.floor(a*6);h=a*6-j;a=d*(1-c);g=d*(1-c*h);c=d*(1-c*(1-h));switch(j){case 1:e=g;f=d;b=a;break;case 2:e=a;f=d;b=c;break;case 3:e=a;f=g;b=d;break;case 4:e=c;f=a;b=d;break;case 5:e=d;f=a;b=g;break;case 6:case 0:e=d;f=c;b=a}}this.r=e;this.g=f;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+ this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0}; THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* @@ -13,57 +13,57 @@ THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1} THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){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)},toString:function(){return"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,d,e=a.objects,g=[];a=0;for(c=e.length;a0&&G>0&&n+G<1}var d,e,g,b,l,j,h,o,v,z, -u,q=a.geometry,x=q.vertices,B=[];d=0;for(e=q.faces.length;dh?e:h;g=g>o? -g:o}a()};this.add3Points=function(h,o,v,z,u,q){if(j){j=false;c=hv?h>u?h:u:v>u?v:u;g=o>z?o>q?o:q:z>q?z:q}else{c=hv?h>u?h>e?h:e:u>e?u:e:v>u?v>e?v:e:u>e?u:e;g=o>z?o>q?o>g?o:g:q>g?q:g:z>q?z>g?z:g:q>g?q:g}a()};this.addRectangle=function(h){if(j){j=false;c=h.getLeft();d=h.getTop();e=h.getRight();g=h.getBottom()}else{c=ch.getRight()?e:h.getRight();g=g>h.getBottom()?g:h.getBottom()}a()};this.inflate=function(h){c-=h;d-=h;e+=h;g+=h;a()};this.minSelf=function(h){c=c>h.getLeft()?c:h.getLeft();d=d>h.getTop()?d:h.getTop();e=e=0&&Math.min(g,h.getBottom())-Math.max(d,h.getTop())>=0};this.empty=function(){j=true;g=e=d=c=0;a()};this.isEmpty=function(){return j};this.toString= -function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+g+", width: "+b+", height: "+l+" )"}};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}}; -THREE.Matrix4=function(a,c,d,e,g,b,l,j,h,o,v,z,u,q,x,B){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=g||0;this.n22=b||1;this.n23=l||0;this.n24=j||0;this.n31=h||0;this.n32=o||0;this.n33=v||1;this.n34=z||0;this.n41=u||0;this.n42=q||0;this.n43=x||0;this.n44=B||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,g,b,l,j,h,o,v,z,u,q,x,B){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=g;this.n22=b;this.n23=l;this.n24=j;this.n31=h;this.n32=o;this.n33=v;this.n34=z;this.n41=u;this.n42=q;this.n43=x;this.n44=B;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= -a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();g.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a); -this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,g=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23* -e+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*g;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 d=a.n11,e=a.n12,g=a.n13,b=a.n14,l=a.n21,j=a.n22,h=a.n23,o=a.n24,v=a.n31, -z=a.n32,u=a.n33,q=a.n34,x=a.n41,B=a.n42,G=a.n43,t=a.n44,k=c.n11,f=c.n12,m=c.n13,n=c.n14,C=c.n21,w=c.n22,p=c.n23,F=c.n24,y=c.n31,J=c.n32,E=c.n33,A=c.n34,M=c.n41,aa=c.n42,N=c.n43,U=c.n44;this.n11=d*k+e*C+g*y+b*M;this.n12=d*f+e*w+g*J+b*aa;this.n13=d*m+e*p+g*E+b*N;this.n14=d*n+e*F+g*A+b*U;this.n21=l*k+j*C+h*y+o*M;this.n22=l*f+j*w+h*J+o*aa;this.n23=l*m+j*p+h*E+o*N;this.n24=l*n+j*F+h*A+o*U;this.n31=v*k+z*C+u*y+q*M;this.n32=v*f+z*w+u*J+q*aa;this.n33=v*m+z*p+u*E+q*N;this.n34=v*n+z*F+u*A+q*U;this.n41=x*k+ -B*C+G*y+t*M;this.n42=x*f+B*w+G*J+t*aa;this.n43=x*m+B*p+G*E+t*N;this.n44=x*n+B*F+G*A+t*U;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,g=this.n14,b=this.n21,l=this.n22,j=this.n23,h=this.n24,o=this.n31,v=this.n32,z=this.n33,u=this.n34,q=this.n41,x=this.n42,B=this.n43,G=this.n44,t=a.n11,k=a.n21,f=a.n31,m=a.n41,n=a.n12,C=a.n22,w=a.n32,p=a.n42,F=a.n13,y=a.n23,J=a.n33,E=a.n43,A=a.n14,M=a.n24,aa=a.n34;a=a.n44;this.n11=c*t+d*k+e*f+g*m;this.n12=c*n+d*C+e*w+g*p;this.n13=c*F+d*y+ -e*J+g*E;this.n14=c*A+d*M+e*aa+g*a;this.n21=b*t+l*k+j*f+h*m;this.n22=b*n+l*C+j*w+h*p;this.n23=b*F+l*y+j*J+h*E;this.n24=b*A+l*M+j*aa+h*a;this.n31=o*t+v*k+z*f+u*m;this.n32=o*n+v*C+z*w+u*p;this.n33=o*F+v*y+z*J+u*E;this.n34=o*A+v*M+z*aa+u*a;this.n41=q*t+x*k+B*f+G*m;this.n42=q*n+x*C+B*w+G*p;this.n43=q*F+x*y+B*J+G*E;this.n44=q*A+x*M+B*aa+G*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,d=this.n13,e=this.n14,g=this.n21,b=this.n22,l=this.n23,j=this.n24,h=this.n31,o=this.n32,v=this.n33,z=this.n34,u=this.n41,q=this.n42,x=this.n43,B=this.n44;return e*l*o*u-d*j*o*u-e*b*v*u+c*j*v*u+d*b*z*u-c*l*z*u-e*l*h*q+d*j*h*q+e*g*v*q-a*j*v*q-d*g*z*q+a*l*z*q+e*b*h*x-c*j*h*x-e*g*o*x+a*j*o*x+c*g*z*x-a*b*z*x-d*b*h*B+c*l*h*B+d*g*o*B-a*l*o*B-c*g*v*B+a*b*v*B},transpose:function(){function a(c, -d,e){var g=c[d];c[d]=c[e];c[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){var a=this.flat;a[0]=this.n11; +THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,f=[];a=0;for(c=e.length;a0&&H>0&&p+H<1}var d,e,f,b,j,h,g,m,w,B, +u,q=a.geometry,x=q.vertices,E=[];d=0;for(e=q.faces.length;dg?e:g;f=f>m? +f:m}a()};this.add3Points=function(g,m,w,B,u,q){if(h){h=false;c=gw?g>u?g:u:w>u?w:u;f=m>B?m>q?m:q:B>q?B:q}else{c=gw?g>u?g>e?g:e:u>e?u:e:w>u?w>e?w:e:u>e?u:e;f=m>B?m>q?m>f?m:f:q>f?q:f:B>q?B>f?B:f:q>f?q:f}a()};this.addRectangle=function(g){if(h){h=false;c=g.getLeft();d=g.getTop();e=g.getRight();f=g.getBottom()}else{c=cg.getRight()?e:g.getRight();f=f>g.getBottom()?f:g.getBottom()}a()};this.inflate=function(g){c-=g;d-=g;e+=g;f+=g;a()};this.minSelf=function(g){c=c>g.getLeft()?c:g.getLeft();d=d>g.getTop()?d:g.getTop();e=e=0&&Math.min(f,g.getBottom())-Math.max(d,g.getTop())>=0};this.empty=function(){h=true;f=e=d=c=0;a()};this.isEmpty=function(){return h};this.toString= +function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+f+", width: "+b+", height: "+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}}; +THREE.Matrix4=function(a,c,d,e,f,b,j,h,g,m,w,B,u,q,x,E){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=b||1;this.n23=j||0;this.n24=h||0;this.n31=g||0;this.n32=m||0;this.n33=w||1;this.n34=B||0;this.n41=u||0;this.n42=q||0;this.n43=x||0;this.n44=E||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,f,b,j,h,g,m,w,B,u,q,x,E){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=b;this.n23=j;this.n24=h;this.n31=g;this.n32=m;this.n33=w;this.n34=B;this.n41=u;this.n42=q;this.n43=x;this.n44=E;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();f.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a); +this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,f=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*c+this.n22*d+this.n23* +e+this.n24*f;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;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 d=a.n11,e=a.n12,f=a.n13,b=a.n14,j=a.n21,h=a.n22,g=a.n23,m=a.n24,w=a.n31, +B=a.n32,u=a.n33,q=a.n34,x=a.n41,E=a.n42,H=a.n43,t=a.n44,I=c.n11,o=c.n12,k=c.n13,p=c.n14,n=c.n21,l=c.n22,v=c.n23,C=c.n24,y=c.n31,z=c.n32,D=c.n33,A=c.n34,F=c.n41,T=c.n42,N=c.n43,X=c.n44;this.n11=d*I+e*n+f*y+b*F;this.n12=d*o+e*l+f*z+b*T;this.n13=d*k+e*v+f*D+b*N;this.n14=d*p+e*C+f*A+b*X;this.n21=j*I+h*n+g*y+m*F;this.n22=j*o+h*l+g*z+m*T;this.n23=j*k+h*v+g*D+m*N;this.n24=j*p+h*C+g*A+m*X;this.n31=w*I+B*n+u*y+q*F;this.n32=w*o+B*l+u*z+q*T;this.n33=w*k+B*v+u*D+q*N;this.n34=w*p+B*C+u*A+q*X;this.n41=x*I+E*n+ +H*y+t*F;this.n42=x*o+E*l+H*z+t*T;this.n43=x*k+E*v+H*D+t*N;this.n44=x*p+E*C+H*A+t*X;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,f=this.n14,b=this.n21,j=this.n22,h=this.n23,g=this.n24,m=this.n31,w=this.n32,B=this.n33,u=this.n34,q=this.n41,x=this.n42,E=this.n43,H=this.n44,t=a.n11,I=a.n21,o=a.n31,k=a.n41,p=a.n12,n=a.n22,l=a.n32,v=a.n42,C=a.n13,y=a.n23,z=a.n33,D=a.n43,A=a.n14,F=a.n24,T=a.n34;a=a.n44;this.n11=c*t+d*I+e*o+f*k;this.n12=c*p+d*n+e*l+f*v;this.n13=c*C+d*y+e*z+f* +D;this.n14=c*A+d*F+e*T+f*a;this.n21=b*t+j*I+h*o+g*k;this.n22=b*p+j*n+h*l+g*v;this.n23=b*C+j*y+h*z+g*D;this.n24=b*A+j*F+h*T+g*a;this.n31=m*t+w*I+B*o+u*k;this.n32=m*p+w*n+B*l+u*v;this.n33=m*C+w*y+B*z+u*D;this.n34=m*A+w*F+B*T+u*a;this.n41=q*t+x*I+E*o+H*k;this.n42=q*p+x*n+E*l+H*v;this.n43=q*C+x*y+E*z+H*D;this.n44=q*A+x*F+E*T+H*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,d=this.n13,e=this.n14,f=this.n21,b=this.n22,j=this.n23,h=this.n24,g=this.n31,m=this.n32,w=this.n33,B=this.n34,u=this.n41,q=this.n42,x=this.n43,E=this.n44;return e*j*m*u-d*h*m*u-e*b*w*u+c*h*w*u+d*b*B*u-c*j*B*u-e*j*g*q+d*h*g*q+e*f*w*q-a*h*w*q-d*f*B*q+a*j*B*q+e*b*g*x-c*h*g*x-e*f*m*x+a*h*m*x+c*f*B*x-a*b*B*x-d*b*g*E+c*j*g*E+d*f*m*E-a*j*m*E-c*f*w*E+a*b*w*E},transpose:function(){function a(c,d, +e){var f=c[d];c[d]=c[e];c[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){var a=this.flat;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},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c= -Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),g=1-d,b=a.x,l=a.y,j=a.z,h=g*b,o=g*l;this.set(h*b+d,h*l-e*j,h*j+e*l,0,h*l+e*j,o*l+d,o*j-e*b,0,h*j-e*l,o*j+e*b,g*j*j+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+ +Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),f=1-d,b=a.x,j=a.y,h=a.z,g=f*b,m=f*j;this.set(g*b+d,g*j-e*h,g*h+e*j,0,g*j+e*h,m*j+d,m*h-e*b,0,g*h-e*j,m*h+e*b,f*h*h+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+ this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c}; THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d}; -THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,b=a.n21,l=a.n22,j=a.n23,h=a.n24,o=a.n31,v=a.n32,z=a.n33,u=a.n34,q=a.n41,x=a.n42,B=a.n43,G=a.n44,t=new THREE.Matrix4;t.n11=j*u*x-h*z*x+h*v*B-l*u*B-j*v*G+l*z*G;t.n12=g*z*x-e*u*x-g*v*B+d*u*B+e*v*G-d*z*G;t.n13=e*h*x-g*j*x+g*l*B-d*h*B-e*l*G+d*j*G;t.n14=g*j*v-e*h*v-g*l*z+d*h*z+e*l*u-d*j*u;t.n21=h*z*q-j*u*q-h*o*B+b*u*B+j*o*G-b*z*G;t.n22=e*u*q-g*z*q+g*o*B-c*u*B-e*o*G+c*z*G;t.n23=g*j*q-e*h*q-g*b*B+c*h*B+e*b*G-c*j*G;t.n24=e*h*o-g*j*o+ -g*b*z-c*h*z-e*b*u+c*j*u;t.n31=l*u*q-h*v*q+h*o*x-b*u*x-l*o*G+b*v*G;t.n32=g*v*q-d*u*q-g*o*x+c*u*x+d*o*G-c*v*G;t.n33=e*h*q-g*l*q+g*b*x-c*h*x-d*b*G+c*l*G;t.n34=g*l*o-d*h*o-g*b*v+c*h*v+d*b*u-c*l*u;t.n41=j*v*q-l*z*q-j*o*x+b*z*x+l*o*B-b*v*B;t.n42=d*z*q-e*v*q+e*o*x-c*z*x-d*o*B+c*v*B;t.n43=e*l*q-d*j*q-e*b*x+c*j*x+d*b*B-c*l*B;t.n44=d*j*o-e*l*o+e*b*v-c*j*v-d*b*z+c*l*z;t.multiplyScalar(1/a.determinant());return t}; -THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],g=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],l=-c[10]*c[4]+c[6]*c[8],j=c[10]*c[0]-c[2]*c[8],h=-c[6]*c[0]+c[2]*c[4],o=c[9]*c[4]-c[5]*c[8],v=-c[9]*c[0]+c[1]*c[8],z=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*l+c[2]*o;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*g;d[2]=c*b;d[3]=c*l;d[4]=c*j;d[5]=c*h;d[6]=c*o;d[7]=c*v;d[8]=c*z;return a}; -THREE.Matrix4.makeFrustum=function(a,c,d,e,g,b){var l,j,h;l=new THREE.Matrix4;j=2*g/(c-a);h=2*g/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+g)/(b-g);g=-2*b*g/(b-g);l.n11=j;l.n12=0;l.n13=a;l.n14=0;l.n21=0;l.n22=h;l.n23=d;l.n24=0;l.n31=0;l.n32=0;l.n33=e;l.n34=g;l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,c,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,c,d,e,g,b){var l,j,h,o;l=new THREE.Matrix4;j=c-a;h=d-e;o=b-g;a=(c+a)/j;d=(d+e)/h;g=(b+g)/o;l.n11=2/j;l.n12=0;l.n13=0;l.n14=-a;l.n21=0;l.n22=2/h;l.n23=0;l.n24=-d;l.n31=0;l.n32=0;l.n33=-2/o;l.n34=-g;l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; +THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,b=a.n21,j=a.n22,h=a.n23,g=a.n24,m=a.n31,w=a.n32,B=a.n33,u=a.n34,q=a.n41,x=a.n42,E=a.n43,H=a.n44,t=new THREE.Matrix4;t.n11=h*u*x-g*B*x+g*w*E-j*u*E-h*w*H+j*B*H;t.n12=f*B*x-e*u*x-f*w*E+d*u*E+e*w*H-d*B*H;t.n13=e*g*x-f*h*x+f*j*E-d*g*E-e*j*H+d*h*H;t.n14=f*h*w-e*g*w-f*j*B+d*g*B+e*j*u-d*h*u;t.n21=g*B*q-h*u*q-g*m*E+b*u*E+h*m*H-b*B*H;t.n22=e*u*q-f*B*q+f*m*E-c*u*E-e*m*H+c*B*H;t.n23=f*h*q-e*g*q-f*b*E+c*g*E+e*b*H-c*h*H;t.n24=e*g*m-f*h*m+ +f*b*B-c*g*B-e*b*u+c*h*u;t.n31=j*u*q-g*w*q+g*m*x-b*u*x-j*m*H+b*w*H;t.n32=f*w*q-d*u*q-f*m*x+c*u*x+d*m*H-c*w*H;t.n33=e*g*q-f*j*q+f*b*x-c*g*x-d*b*H+c*j*H;t.n34=f*j*m-d*g*m-f*b*w+c*g*w+d*b*u-c*j*u;t.n41=h*w*q-j*B*q-h*m*x+b*B*x+j*m*E-b*w*E;t.n42=d*B*q-e*w*q+e*m*x-c*B*x-d*m*E+c*w*E;t.n43=e*j*q-d*h*q-e*b*x+c*h*x+d*b*E-c*j*E;t.n44=d*h*m-e*j*m+e*b*w-c*h*w-d*b*B+c*j*B;t.multiplyScalar(1/a.determinant());return t}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],j=-c[10]*c[4]+c[6]*c[8],h=c[10]*c[0]-c[2]*c[8],g=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],w=-c[9]*c[0]+c[1]*c[8],B=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*j+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*f;d[2]=c*b;d[3]=c*j;d[4]=c*h;d[5]=c*g;d[6]=c*m;d[7]=c*w;d[8]=c*B;return a}; +THREE.Matrix4.makeFrustum=function(a,c,d,e,f,b){var j,h,g;j=new THREE.Matrix4;h=2*f/(c-a);g=2*f/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+f)/(b-f);f=-2*b*f/(b-f);j.n11=h;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=g;j.n23=d;j.n24=0;j.n31=0;j.n32=0;j.n33=e;j.n34=f;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,c,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,d,e)}; +THREE.Matrix4.makeOrtho=function(a,c,d,e,f,b){var j,h,g,m;j=new THREE.Matrix4;h=c-a;g=d-e;m=b-f;a=(c+a)/h;d=(d+e)/g;f=(b+f)/m;j.n11=2/h;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/g;j.n23=0;j.n24=-d;j.n31=0;j.n32=0;j.n33=-2/m;j.n34=-f;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; 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=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; -THREE.Face3=function(a,c,d,e,g){this.a=a;this.b=c;this.c=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]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,c,d,e,g,b){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0}; +THREE.Face3=function(a,c,d,e,f){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,c,d,e,f,b){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=b instanceof Array?b:[b]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||0}; THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], +c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(A,F,T,N,X,W,R){b=A.vertices[F].position;j=A.vertices[T].position;h=A.vertices[N].position;g=f[X];m=f[W];w=f[R];B=j.x-b.x;u=h.x-b.x;q=j.y-b.y;x=h.y-b.y; +E=j.z-b.z;H=h.z-b.z;t=m.u-g.u;I=w.u-g.u;o=m.v-g.v;k=w.v-g.v;p=1/(t*k-I*o);v.set((k*B-o*u)*p,(k*q-o*x)*p,(k*E-o*H)*p);C.set((t*u-I*B)*p,(t*x-I*q)*p,(t*H-I*E)*p);n[F].addSelf(v);n[T].addSelf(v);n[N].addSelf(v);l[F].addSelf(C);l[T].addSelf(C);l[N].addSelf(C)}var c,d,e,f,b,j,h,g,m,w,B,u,q,x,E,H,t,I,o,k,p,n=[],l=[],v=new THREE.Vector3,C=new THREE.Vector3,y=new THREE.Vector3,z=new THREE.Vector3,D=new THREE.Vector3;c=0;for(d=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,d=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,d=this.vertices.length;c65535){o[j].counter+=1;h=o[j].hash+"_"+o[j].counter;if(this.geometryChunks[h]==undefined)this.geometryChunks[h]={faces:[],materials:l,vertices:0}}this.geometryChunks[h].faces.push(e);this.geometryChunks[h].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+ +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,d=this.vertices.length;c65535){m[h].counter+=1;g=m[h].hash+"_"+m[h].counter;if(this.geometryChunks[g]==undefined)this.geometryChunks[g]={faces:[],materials:j,vertices:0}}this.geometryChunks[g].faces.push(e);this.geometryChunks[g].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; -this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()}; +THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; +this.translateZ=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()}; THREE.Camera.prototype={toString:function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light; THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,e=this.tmpMatrix;this.matrix.setTranslation(a.x,a.y,a.z);this.rotationMatrix.setRotX(c.x);if(c.y!=0){e.setRotY(c.y);this.rotationMatrix.multiplySelf(e)}if(c.z!=0){e.setRotZ(c.z);this.rotationMatrix.multiplySelf(e)}this.matrix.multiplySelf(this.rotationMatrix);if(d.x!=0||d.y!=0||d.z!=0){e.setScale(d.x,d.y,d.z);this.matrix.multiplySelf(e)}}};THREE.Object3DCounter={value:0}; -THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c]};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; +THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()}; -THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2; +THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3; THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}}; THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.light_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!== @@ -90,110 +90,110 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.size=this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending}}; THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
size: "+this.size+"
blending: "+this.blending+"
)"}}; THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; -THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,e,g,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=b!==undefined?b:THREE.LinearMipMapLinearFilter}; +THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,e,f,b){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=f!==undefined?f:THREE.LinearFilter;this.min_filter=b!==undefined?b:THREE.LinearMipMapLinearFilter}; THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+this.min_filter+"
)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2; THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20; THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType}; -var Uniforms={clone:function(a){var c,d,e,g={};for(c in a){g[c]={};for(d in a[c]){e=a[c][d];g[c][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var c,d,e,g={};for(c=0;c=0&&E>=0&&A>=0&&M>=0)return true;else if(J<0&&E<0||A<0&&M<0)return false;else{if(J<0)F=Math.max(F,J/(J-E));else if(E<0)y=Math.min(y,J/(J-E));if(A<0)F=Math.max(F,A/(A-M));else if(M<0)y=Math.min(y,A/(A-M));if(yJ&&N.z0&&G.z<1){u=x[q]=x[q]||new THREE.RenderableParticle;u.x=G.x/G.w;u.y=G.y/G.w;u.z=G.z;u.rotation=R.rotation.z;u.scale.x=R.scale.x*Math.abs(u.x-(G.x+p.projectionMatrix.n11)/(G.w+p.projectionMatrix.n14)); -u.scale.y=R.scale.y*Math.abs(u.y-(G.y+p.projectionMatrix.n22)/(G.w+p.projectionMatrix.n24));u.materials=R.materials;y.push(u);q++}}}}F&&y.sort(a);return y};this.unprojectVector=function(w,p){var F=THREE.Matrix4.makeInvert(p.matrix);F.multiplySelf(THREE.Matrix4.makeInvert(p.projectionMatrix));F.multiplyVector3(w);return w}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,g,b;this.domElement=document.createElement("div");this.setSize=function(l,j){d=l;e=j;g=d/2;b=e/2};this.render=function(l,j){var h,o,v,z,u,q,x,B;a=c.projectScene(l,j);h=0;for(o=a.length;h0){O.r+=ma.r*ga;O.g+=ma.g*ga;O.b+=ma.b*ga}}else if(ga instanceof THREE.PointLight){K.sub(ga.position,ea);K.normalize();ga=$.dot(K)*na;if(ga>0){O.r+=ma.r*ga;O.g+=ma.g*ga;O.b+=ma.b*ga}}}}function Qa(L,ea,$){if($.opacity!=0){a($.opacity); -c($.blending);var O,Y,ga,ma,na,oa;if($ instanceof THREE.ParticleBasicMaterial){if($.map&&$.map.image.loaded){ma=$.map.image;na=ma.width>>1;oa=ma.height>>1;Y=ea.scale.x*j;ga=ea.scale.y*h;$=Y*na;O=ga*oa;I.set(L.x-$,L.y-O,L.x+$,L.y+O);if(ba.instersects(I)){o.save();o.translate(L.x,L.y);o.rotate(-ea.rotation);o.scale(Y,-ga);o.translate(-na,-oa);o.drawImage(ma,0,0);o.restore()}}}else if($ instanceof THREE.ParticleCircleMaterial){if(Q){V.r=ha.r+ka.r+D.r;V.g=ha.g+ka.g+D.g;V.b=ha.b+ka.b+D.b;y.r=$.color.r* -V.r;y.g=$.color.g*V.g;y.b=$.color.b*V.b;y.updateStyleString()}else y.__styleString=$.color.__styleString;$=ea.scale.x*j;O=ea.scale.y*h;I.set(L.x-$,L.y-O,L.x+$,L.y+O);if(ba.instersects(I)){Y=y.__styleString;if(B!=Y)o.fillStyle=B=Y;o.save();o.translate(L.x,L.y);o.rotate(-ea.rotation);o.scale($,O);o.beginPath();o.arc(0,0,1,0,H,true);o.closePath();o.fill();o.restore()}}}}function Ra(L,ea,$,O){if(O.opacity!=0){a(O.opacity);c(O.blending);o.beginPath();o.moveTo(L.positionScreen.x,L.positionScreen.y);o.lineTo(ea.positionScreen.x, -ea.positionScreen.y);o.closePath();if(O instanceof THREE.LineBasicMaterial){y.__styleString=O.color.__styleString;L=O.linewidth;if(G!=L)o.lineWidth=G=L;L=y.__styleString;if(x!=L)o.strokeStyle=x=L;o.stroke();I.inflate(O.linewidth*2)}}}function La(L,ea,$,O,Y,ga){if(Y.opacity!=0){a(Y.opacity);c(Y.blending);m=L.positionScreen.x;n=L.positionScreen.y;C=ea.positionScreen.x;w=ea.positionScreen.y;p=$.positionScreen.x;F=$.positionScreen.y;o.beginPath();o.moveTo(m,n);o.lineTo(C,w);o.lineTo(p,F);o.lineTo(m,n); -o.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Aa(m,n,C,w,p,F,Y.map.image,O.uvs[0].u,O.uvs[0].v,O.uvs[1].u,O.uvs[1].v,O.uvs[2].u,O.uvs[2].v);else if(Y.env_map){if(Y.env_map.image.loaded)if(Y.env_map.mapping instanceof THREE.SphericalReflectionMapping){L=xa.matrix;K.copy(O.vertexNormalsWorld[0]);T=(K.x*L.n11+K.y*L.n12+K.z*L.n13)*0.5+0.5;R=-(K.x*L.n21+K.y*L.n22+K.z*L.n23)*0.5+0.5;K.copy(O.vertexNormalsWorld[1]);Z=(K.x*L.n11+ -K.y*L.n12+K.z*L.n13)*0.5+0.5;ca=-(K.x*L.n21+K.y*L.n22+K.z*L.n23)*0.5+0.5;K.copy(O.vertexNormalsWorld[2]);W=(K.x*L.n11+K.y*L.n12+K.z*L.n13)*0.5+0.5;S=-(K.x*L.n21+K.y*L.n22+K.z*L.n23)*0.5+0.5;Aa(m,n,C,w,p,F,Y.env_map.image,T,R,Z,ca,W,S)}}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){Y.map.mapping instanceof THREE.UVMapping&&Aa(m,n,C,w,p,F,Y.map.image,O.uvs[0].u,O.uvs[0].v,O.uvs[1].u, -O.uvs[1].v,O.uvs[2].u,O.uvs[2].v);c(THREE.SubtractiveBlending)}if(Q)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&O.vertexNormalsWorld.length==3){J.r=E.r=A.r=ha.r;J.g=E.g=A.g=ha.g;J.b=E.b=A.b=ha.b;Da(ga,O.v1.positionWorld,O.vertexNormalsWorld[0],J);Da(ga,O.v2.positionWorld,O.vertexNormalsWorld[1],E);Da(ga,O.v3.positionWorld,O.vertexNormalsWorld[2],A);M.r=(E.r+A.r)*0.5;M.g=(E.g+A.g)*0.5;M.b=(E.b+A.b)*0.5;U=Ma(J,E,A,M);Aa(m,n,C,w,p,F,U,0,0,1,0,0,1)}else{V.r=ha.r;V.g=ha.g;V.b=ha.b;Da(ga,O.centroidWorld, -O.normalWorld,V);y.r=Y.color.r*V.r;y.g=Y.color.g*V.g;y.b=Y.color.b*V.b;y.updateStyleString();Y.wireframe?Ea(y.__styleString,Y.wireframe_linewidth):Fa(y.__styleString)}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){aa=xa.near;N=xa.far;J.r=J.g=J.b=1-Ha(L.positionScreen.z,aa,N);E.r=E.g=E.b=1-Ha(ea.positionScreen.z,aa,N);A.r=A.g=A.b=1-Ha($.positionScreen.z,aa,N);M.r=(E.r+A.r)*0.5;M.g=(E.g+A.g)*0.5;M.b=(E.b+A.b)* -0.5;U=Ma(J,E,A,M);Aa(m,n,C,w,p,F,U,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){y.r=Ia(O.normalWorld.x);y.g=Ia(O.normalWorld.y);y.b=Ia(O.normalWorld.z);y.updateStyleString();Y.wireframe?Ea(y.__styleString,Y.wireframe_linewidth):Fa(y.__styleString)}}}function Ea(L,ea){if(x!=L)o.strokeStyle=x=L;if(G!=ea)o.lineWidth=G=ea;o.stroke();I.inflate(ea*2)}function Fa(L){if(B!=L)o.fillStyle=B=L;o.fill()}function Aa(L,ea,$,O,Y,ga,ma,na,oa,ta,pa,ua,Ba){var ya,va;ya=ma.width-1;va=ma.height-1;na*= -ya;oa*=va;ta*=ya;pa*=va;ua*=ya;Ba*=va;$-=L;O-=ea;Y-=L;ga-=ea;ta-=na;pa-=oa;ua-=na;Ba-=oa;va=1/(ta*Ba-ua*pa);ya=(Ba*$-pa*Y)*va;pa=(Ba*O-pa*ga)*va;$=(ta*Y-ua*$)*va;O=(ta*ga-ua*O)*va;L=L-ya*na-$*oa;ea=ea-pa*na-O*oa;o.save();o.transform(ya,pa,$,O,L,ea);o.clip();o.drawImage(ma,0,0);o.restore()}function Ma(L,ea,$,O){var Y=~~(L.r*255),ga=~~(L.g*255);L=~~(L.b*255);var ma=~~(ea.r*255),na=~~(ea.g*255);ea=~~(ea.b*255);var oa=~~($.r*255),ta=~~($.g*255);$=~~($.b*255);var pa=~~(O.r*255),ua=~~(O.g*255);O=~~(O.b* -255);fa[0]=Y<0?0:Y>255?255:Y;fa[1]=ga<0?0:ga>255?255:ga;fa[2]=L<0?0:L>255?255:L;fa[4]=ma<0?0:ma>255?255:ma;fa[5]=na<0?0:na>255?255:na;fa[6]=ea<0?0:ea>255?255:ea;fa[8]=oa<0?0:oa>255?255:oa;fa[9]=ta<0?0:ta>255?255:ta;fa[10]=$<0?0:$>255?255:$;fa[12]=pa<0?0:pa>255?255:pa;fa[13]=ua<0?0:ua>255?255:ua;fa[14]=O<0?0:O>255?255:O;da.putImageData(ia,0,0);sa.drawImage(P,0,0);return qa}function Ha(L,ea,$){L=(L-ea)/($-ea);return L*L*(3-2*L)}function Ia(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function Ja(L,ea){var $= -ea.x-L.x,O=ea.y-L.y,Y=1/Math.sqrt($*$+O*O);$*=Y;O*=Y;ea.x+=$;ea.y+=O;L.x-=$;L.y-=O}var Ga,Na,ja,ra,za,Ka,Oa,Ca;this.autoClear?this.clear():o.setTransform(1,0,0,-1,j,h);d=e.projectScene(la,xa,this.sortElements);(Q=la.lights.length>0)&&Pa(la);Ga=0;for(Na=d.length;Ga0){Z.r+=S.color.r*ba;Z.g+=S.color.g*ba;Z.b+=S.color.b*ba}}else if(S instanceof THREE.PointLight){F.sub(S.position,R.centroidWorld);F.normalize();ba=R.normalWorld.dot(F)*S.intensity;if(ba>0){Z.r+=S.color.r*ba;Z.g+=S.color.g*ba;Z.b+=S.color.b*ba}}}}function c(T,R,Z,ca,W,S){A=e(M++);A.setAttribute("d", -"M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+"z");if(W instanceof THREE.MeshBasicMaterial)f.__styleString=W.color.__styleString;else if(W instanceof THREE.MeshLambertMaterial)if(k){m.r=n.r;m.g=n.g;m.b=n.b;a(S,ca,m);f.r=W.color.r*m.r;f.g=W.color.g*m.g;f.b=W.color.b*m.b;f.updateStyleString()}else f.__styleString=W.color.__styleString;else if(W instanceof THREE.MeshDepthMaterial){p=1-W.__2near/(W.__farPlusNear- -ca.z*W.__farMinusNear);f.setRGB(p,p,p)}else W instanceof THREE.MeshNormalMaterial&&f.setRGB(g(ca.normalWorld.x),g(ca.normalWorld.y),g(ca.normalWorld.z));W.wireframe?A.setAttribute("style","fill: none; stroke: "+f.__styleString+"; stroke-width: "+W.wireframe_linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.wireframe_linecap+"; stroke-linejoin: "+W.wireframe_linejoin):A.setAttribute("style","fill: "+f.__styleString+"; fill-opacity: "+W.opacity);j.appendChild(A)}function d(T,R,Z,ca,W, -S,ba){A=e(M++);A.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)f.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(k){m.r=n.r;m.g=n.g;m.b=n.b;a(ba,W,m);f.r=S.color.r*m.r;f.g=S.color.g*m.g;f.b=S.color.b*m.b;f.updateStyleString()}else f.__styleString=S.color.__styleString; -else if(S instanceof THREE.MeshDepthMaterial){p=1-S.__2near/(S.__farPlusNear-W.z*S.__farMinusNear);f.setRGB(p,p,p)}else S instanceof THREE.MeshNormalMaterial&&f.setRGB(g(W.normalWorld.x),g(W.normalWorld.y),g(W.normalWorld.z));S.wireframe?A.setAttribute("style","fill: none; stroke: "+f.__styleString+"; stroke-width: "+S.wireframe_linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframe_linecap+"; stroke-linejoin: "+S.wireframe_linejoin):A.setAttribute("style","fill: "+f.__styleString+ -"; fill-opacity: "+S.opacity);j.appendChild(A)}function e(T){if(y[T]==null){y[T]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&y[T].setAttribute("shape-rendering","crispEdges");return y[T]}return y[T]}function g(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var b=null,l=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,o,v,z,u,q,x,B,G=new THREE.Rectangle,t=new THREE.Rectangle,k=false,f=new THREE.Color(16777215),m=new THREE.Color(16777215), -n=new THREE.Color(0),C=new THREE.Color(0),w=new THREE.Color(0),p,F=new THREE.Vector3,y=[],J=[],E=[],A,M,aa,N,U=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":U=1;break;case "low":U=0}};this.setSize=function(T,R){h=T;o=R;v=h/2;z=o/2;j.setAttribute("viewBox",-v+" "+-z+" "+h+" "+o);j.setAttribute("width",h);j.setAttribute("height",o);G.set(-v,-z,v,z)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])}; -this.render=function(T,R){var Z,ca,W,S,ba,X,I,Q;this.autoClear&&this.clear();b=l.projectScene(T,R,this.sortElements);N=aa=M=0;if(k=T.lights.length>0){I=T.lights;n.setRGB(0,0,0);C.setRGB(0,0,0);w.setRGB(0,0,0);Z=0;for(ca=I.length;Z=0&&D>=0&&A>=0&&F>=0)return true;else if(z<0&&D<0||A<0&&F<0)return false;else{if(z<0)C=Math.max(C,z/(z-D));else if(D<0)y=Math.min(y,z/(z-D));if(A<0)C=Math.max(C,A/(A-F));else if(F<0)y=Math.min(y,A/(A-F));if(yz&&N.z0&&H.z<1){u=x[q]=x[q]||new THREE.RenderableParticle;u.x=H.x/H.w;u.y=H.y/H.w;u.z=H.z;u.rotation=R.rotation.z;u.scale.x=R.scale.x*Math.abs(u.x-(H.x+v.projectionMatrix.n11)/(H.w+v.projectionMatrix.n14)); +u.scale.y=R.scale.y*Math.abs(u.y-(H.y+v.projectionMatrix.n22)/(H.w+v.projectionMatrix.n24));u.materials=R.materials;y.push(u);q++}}}}C&&y.sort(a);return y};this.unprojectVector=function(l,v){var C=THREE.Matrix4.makeInvert(v.matrix);C.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));C.multiplyVector3(l);return l}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,f,b;this.domElement=document.createElement("div");this.setSize=function(j,h){d=j;e=h;f=d/2;b=e/2};this.render=function(j,h){var g,m,w,B,u,q,x,E;a=c.projectScene(j,h);g=0;for(m=a.length;g0){S.r+=na.r*ha;S.g+=na.g*ha;S.b+=na.b*ha}}else if(ha instanceof THREE.PointLight){J.sub(ha.position,da);J.normalize();ha=$.dot(J)*oa;if(ha>0){S.r+=na.r*ha;S.g+=na.g*ha;S.b+=na.b*ha}}}}function Qa(M,da,$){if($.opacity!=0){a($.opacity); +c($.blending);var S,Z,ha,na,oa,qa;if($ instanceof THREE.ParticleBasicMaterial){if($.map&&$.map.image.loaded){na=$.map.image;oa=na.width>>1;qa=na.height>>1;Z=da.scale.x*h;ha=da.scale.y*g;$=Z*oa;S=ha*qa;K.set(M.x-$,M.y-S,M.x+$,M.y+S);if(ca.instersects(K)){m.save();m.translate(M.x,M.y);m.rotate(-da.rotation);m.scale(Z,-ha);m.translate(-oa,-qa);m.drawImage(na,0,0);m.restore()}}}else if($ instanceof THREE.ParticleCircleMaterial){if(U){V.r=ga.r+fa.r+G.r;V.g=ga.g+fa.g+G.g;V.b=ga.b+fa.b+G.b;y.r=$.color.r* +V.r;y.g=$.color.g*V.g;y.b=$.color.b*V.b;y.updateStyleString()}else y.__styleString=$.color.__styleString;$=da.scale.x*h;S=da.scale.y*g;K.set(M.x-$,M.y-S,M.x+$,M.y+S);if(ca.instersects(K)){Z=y.__styleString;if(E!=Z)m.fillStyle=E=Z;m.save();m.translate(M.x,M.y);m.rotate(-da.rotation);m.scale($,S);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function Ra(M,da,$,S){if(S.opacity!=0){a(S.opacity);c(S.blending);m.beginPath();m.moveTo(M.positionScreen.x,M.positionScreen.y);m.lineTo(da.positionScreen.x, +da.positionScreen.y);m.closePath();if(S instanceof THREE.LineBasicMaterial){y.__styleString=S.color.__styleString;M=S.linewidth;if(H!=M)m.lineWidth=H=M;M=y.__styleString;if(x!=M)m.strokeStyle=x=M;m.stroke();K.inflate(S.linewidth*2)}}}function Ma(M,da,$,S,Z,ha){if(Z.opacity!=0){a(Z.opacity);c(Z.blending);k=M.positionScreen.x;p=M.positionScreen.y;n=da.positionScreen.x;l=da.positionScreen.y;v=$.positionScreen.x;C=$.positionScreen.y;m.beginPath();m.moveTo(k,p);m.lineTo(n,l);m.lineTo(v,C);m.lineTo(k,p); +m.closePath();if(Z instanceof THREE.MeshBasicMaterial)if(Z.map)Z.map.image.loaded&&Z.map.mapping instanceof THREE.UVMapping&&Aa(k,p,n,l,v,C,Z.map.image,S.uvs[0].u,S.uvs[0].v,S.uvs[1].u,S.uvs[1].v,S.uvs[2].u,S.uvs[2].v);else if(Z.env_map){if(Z.env_map.image.loaded)if(Z.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=sa.matrix;J.copy(S.vertexNormalsWorld[0]);W=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;R=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(S.vertexNormalsWorld[1]);Y=(J.x*M.n11+ +J.y*M.n12+J.z*M.n13)*0.5+0.5;ea=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(S.vertexNormalsWorld[2]);Q=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;P=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;Aa(k,p,n,l,v,C,Z.env_map.image,W,R,Y,ea,Q,P)}}else Z.wireframe?Ea(Z.color.__styleString,Z.wireframe_linewidth):Fa(Z.color.__styleString);else if(Z instanceof THREE.MeshLambertMaterial){if(Z.map&&!Z.wireframe){Z.map.mapping instanceof THREE.UVMapping&&Aa(k,p,n,l,v,C,Z.map.image,S.uvs[0].u,S.uvs[0].v,S.uvs[1].u, +S.uvs[1].v,S.uvs[2].u,S.uvs[2].v);c(THREE.SubtractiveBlending)}if(U)if(!Z.wireframe&&Z.shading==THREE.SmoothShading&&S.vertexNormalsWorld.length==3){z.r=D.r=A.r=ga.r;z.g=D.g=A.g=ga.g;z.b=D.b=A.b=ga.b;Da(ha,S.v1.positionWorld,S.vertexNormalsWorld[0],z);Da(ha,S.v2.positionWorld,S.vertexNormalsWorld[1],D);Da(ha,S.v3.positionWorld,S.vertexNormalsWorld[2],A);F.r=(D.r+A.r)*0.5;F.g=(D.g+A.g)*0.5;F.b=(D.b+A.b)*0.5;X=Na(z,D,A,F);Aa(k,p,n,l,v,C,X,0,0,1,0,0,1)}else{V.r=ga.r;V.g=ga.g;V.b=ga.b;Da(ha,S.centroidWorld, +S.normalWorld,V);y.r=Z.color.r*V.r;y.g=Z.color.g*V.g;y.b=Z.color.b*V.b;y.updateStyleString();Z.wireframe?Ea(y.__styleString,Z.wireframe_linewidth):Fa(y.__styleString)}else Z.wireframe?Ea(Z.color.__styleString,Z.wireframe_linewidth):Fa(Z.color.__styleString)}else if(Z instanceof THREE.MeshDepthMaterial){T=sa.near;N=sa.far;z.r=z.g=z.b=1-Ia(M.positionScreen.z,T,N);D.r=D.g=D.b=1-Ia(da.positionScreen.z,T,N);A.r=A.g=A.b=1-Ia($.positionScreen.z,T,N);F.r=(D.r+A.r)*0.5;F.g=(D.g+A.g)*0.5;F.b=(D.b+A.b)*0.5; +X=Na(z,D,A,F);Aa(k,p,n,l,v,C,X,0,0,1,0,0,1)}else if(Z instanceof THREE.MeshNormalMaterial){y.r=Ja(S.normalWorld.x);y.g=Ja(S.normalWorld.y);y.b=Ja(S.normalWorld.z);y.updateStyleString();Z.wireframe?Ea(y.__styleString,Z.wireframe_linewidth):Fa(y.__styleString)}}}function Ea(M,da){if(x!=M)m.strokeStyle=x=M;if(H!=da)m.lineWidth=H=da;m.stroke();K.inflate(da*2)}function Fa(M){if(E!=M)m.fillStyle=E=M;m.fill()}function Aa(M,da,$,S,Z,ha,na,oa,qa,va,ra,wa,Ba){var ya,xa;ya=na.width-1;xa=na.height-1;oa*=ya;qa*= +xa;va*=ya;ra*=xa;wa*=ya;Ba*=xa;$-=M;S-=da;Z-=M;ha-=da;va-=oa;ra-=qa;wa-=oa;Ba-=qa;xa=1/(va*Ba-wa*ra);ya=(Ba*$-ra*Z)*xa;ra=(Ba*S-ra*ha)*xa;$=(va*Z-wa*$)*xa;S=(va*ha-wa*S)*xa;M=M-ya*oa-$*qa;da=da-ra*oa-S*qa;m.save();m.transform(ya,ra,$,S,M,da);m.clip();m.drawImage(na,0,0);m.restore()}function Na(M,da,$,S){var Z=~~(M.r*255),ha=~~(M.g*255);M=~~(M.b*255);var na=~~(da.r*255),oa=~~(da.g*255);da=~~(da.b*255);var qa=~~($.r*255),va=~~($.g*255);$=~~($.b*255);var ra=~~(S.r*255),wa=~~(S.g*255);S=~~(S.b*255);ja[0]= +Z<0?0:Z>255?255:Z;ja[1]=ha<0?0:ha>255?255:ha;ja[2]=M<0?0:M>255?255:M;ja[4]=na<0?0:na>255?255:na;ja[5]=oa<0?0:oa>255?255:oa;ja[6]=da<0?0:da>255?255:da;ja[8]=qa<0?0:qa>255?255:qa;ja[9]=va<0?0:va>255?255:va;ja[10]=$<0?0:$>255?255:$;ja[12]=ra<0?0:ra>255?255:ra;ja[13]=wa<0?0:wa>255?255:wa;ja[14]=S<0?0:S>255?255:S;ba.putImageData(ia,0,0);la.drawImage(O,0,0);return pa}function Ia(M,da,$){M=(M-da)/($-da);return M*M*(3-2*M)}function Ja(M){M=(M+1)*0.5;return M<0?0:M>1?1:M}function Ka(M,da){var $=da.x-M.x,S= +da.y-M.y,Z=1/Math.sqrt($*$+S*S);$*=Z;S*=Z;da.x+=$;da.y+=S;M.x-=$;M.y-=S}var Ga,Oa,ka,ta,za,La,Pa,Ca;this.autoClear?this.clear():m.setTransform(1,0,0,-1,h,g);d=e.projectScene(ma,sa,this.sortElements);(U=ma.lights.length>0)&&Ha(ma);Ga=0;for(Oa=d.length;Ga0){Y.r+=P.color.r*ca;Y.g+=P.color.g*ca;Y.b+=P.color.b*ca}}else if(P instanceof THREE.PointLight){C.sub(P.position,R.centroidWorld);C.normalize();ca=R.normalWorld.dot(C)*P.intensity;if(ca>0){Y.r+=P.color.r*ca;Y.g+=P.color.g*ca;Y.b+=P.color.b*ca}}}}function c(W,R,Y,ea,Q,P){A=e(F++);A.setAttribute("d", +"M "+W.positionScreen.x+" "+W.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+"z");if(Q instanceof THREE.MeshBasicMaterial)o.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshLambertMaterial)if(I){k.r=p.r;k.g=p.g;k.b=p.b;a(P,ea,k);o.r=Q.color.r*k.r;o.g=Q.color.g*k.g;o.b=Q.color.b*k.b;o.updateStyleString()}else o.__styleString=Q.color.__styleString;else if(Q instanceof THREE.MeshDepthMaterial){v=1-Q.__2near/(Q.__farPlusNear- +ea.z*Q.__farMinusNear);o.setRGB(v,v,v)}else Q instanceof THREE.MeshNormalMaterial&&o.setRGB(f(ea.normalWorld.x),f(ea.normalWorld.y),f(ea.normalWorld.z));Q.wireframe?A.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+Q.wireframe_linewidth+"; stroke-opacity: "+Q.opacity+"; stroke-linecap: "+Q.wireframe_linecap+"; stroke-linejoin: "+Q.wireframe_linejoin):A.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+Q.opacity);h.appendChild(A)}function d(W,R,Y,ea,Q, +P,ca){A=e(F++);A.setAttribute("d","M "+W.positionScreen.x+" "+W.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+" L "+ea.positionScreen.x+","+ea.positionScreen.y+"z");if(P instanceof THREE.MeshBasicMaterial)o.__styleString=P.color.__styleString;else if(P instanceof THREE.MeshLambertMaterial)if(I){k.r=p.r;k.g=p.g;k.b=p.b;a(ca,Q,k);o.r=P.color.r*k.r;o.g=P.color.g*k.g;o.b=P.color.b*k.b;o.updateStyleString()}else o.__styleString=P.color.__styleString; +else if(P instanceof THREE.MeshDepthMaterial){v=1-P.__2near/(P.__farPlusNear-Q.z*P.__farMinusNear);o.setRGB(v,v,v)}else P instanceof THREE.MeshNormalMaterial&&o.setRGB(f(Q.normalWorld.x),f(Q.normalWorld.y),f(Q.normalWorld.z));P.wireframe?A.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+P.wireframe_linewidth+"; stroke-opacity: "+P.opacity+"; stroke-linecap: "+P.wireframe_linecap+"; stroke-linejoin: "+P.wireframe_linejoin):A.setAttribute("style","fill: "+o.__styleString+ +"; fill-opacity: "+P.opacity);h.appendChild(A)}function e(W){if(y[W]==null){y[W]=document.createElementNS("http://www.w3.org/2000/svg","path");X==0&&y[W].setAttribute("shape-rendering","crispEdges");return y[W]}return y[W]}function f(W){return W<0?Math.min((1+W)*0.5,0.5):0.5+Math.min(W*0.5,0.5)}var b=null,j=new THREE.Projector,h=document.createElementNS("http://www.w3.org/2000/svg","svg"),g,m,w,B,u,q,x,E,H=new THREE.Rectangle,t=new THREE.Rectangle,I=false,o=new THREE.Color(16777215),k=new THREE.Color(16777215), +p=new THREE.Color(0),n=new THREE.Color(0),l=new THREE.Color(0),v,C=new THREE.Vector3,y=[],z=[],D=[],A,F,T,N,X=1;this.domElement=h;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(W){switch(W){case "high":X=1;break;case "low":X=0}};this.setSize=function(W,R){g=W;m=R;w=g/2;B=m/2;h.setAttribute("viewBox",-w+" "+-B+" "+g+" "+m);h.setAttribute("width",g);h.setAttribute("height",m);H.set(-w,-B,w,B)};this.clear=function(){for(;h.childNodes.length>0;)h.removeChild(h.childNodes[0])}; +this.render=function(W,R){var Y,ea,Q,P,ca,aa,K,U;this.autoClear&&this.clear();b=j.projectScene(W,R,this.sortElements);N=T=F=0;if(I=W.lights.length>0){K=W.lights;p.setRGB(0,0,0);n.setRGB(0,0,0);l.setRGB(0,0,0);Y=0;for(ea=K.length;Y0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,ha,m)}if(w&&S>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER, -ka,m)}if(C){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,K,m);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,P,m)}};this.setLineBuffers=function(k,f,m,n){var C,w,p=k.vertices,F=p.length,y=k.__vertexArray,J=k.__lineArray;if(m)for(m=0;m0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.map?"#define USE_MAP": -"",w.env_map?"#define USE_ENVMAP":"",w.light_map?"#define USE_LIGHTMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(m,d("fragment",C+y));b.attachShader(m,d("vertex",w+f));b.linkProgram(m);b.getProgramParameter(m,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+ -b.getProgramParameter(m,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");m.uniforms={};m.attributes={};k.program=m;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(n in k.uniforms)m.push(n);n=k.program;y=0;for(f=m.length;y=0){b.bindBuffer(b.ARRAY_BUFFER,C.__webGLNormalBuffer); -b.vertexAttribPointer(p.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(p.normal)}if(p.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,C.__webGLTangentBuffer);b.vertexAttribPointer(p.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(p.tangent)}if(p.uv>=0)if(C.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,C.__webGLUVBuffer);b.vertexAttribPointer(p.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(p.uv)}else b.disableVertexAttribArray(p.uv);if(p.uv2>=0)if(C.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER, -C.__webGLUV2Buffer);b.vertexAttribPointer(p.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(p.uv2)}else b.disableVertexAttribArray(p.uv2);if(n.wireframe||n instanceof THREE.LineBasicMaterial){p=n.wireframe_linewidth!==undefined?n.wireframe_linewidth:n.linewidth!==undefined?n.linewidth:1;n=n instanceof THREE.LineBasicMaterial&&w.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(p);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,C.__webGLLineBuffer);b.drawElements(n,C.__webGLLineCount,b.UNSIGNED_SHORT, -0)}else if(n instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,C.__webGLParticleBuffer);b.drawElements(b.POINTS,C.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,C.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,C.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(k,f,m,n,C,w,p){var F,y,J,E,A;J=0;for(E=n.materials.length;J=0;m--){n=k.__webGLObjects[m].object;f==n&&k.__webGLObjects.splice(m,1)}};this.setupMatrices=function(k,f){k.autoUpdateMatrix&&k.updateMatrix();h.multiply(f.matrix,k.matrix);z.set(h.flatten());o=THREE.Matrix4.makeInvert3x3(h).transpose();q.set(o.m);x.set(k.matrix.flatten())};this.loadMatrices=function(k){b.uniformMatrix4fv(k.uniforms.viewMatrix,false,v);b.uniformMatrix4fv(k.uniforms.modelViewMatrix, -false,z);b.uniformMatrix4fv(k.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(k.uniforms.normalMatrix,false,q);b.uniformMatrix4fv(k.uniforms.objectMatrix,false,x)};this.loadCamera=function(k,f){b.uniform3f(k.uniforms.cameraPosition,f.position.x,f.position.y,f.position.z)};this.setBlending=function(k){switch(k){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;default:b.blendEquation(b.FUNC_ADD); -b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(k,f){if(k){!f||f=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(k=="back")b.cullFace(b.BACK);else k=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; -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, 1.0 ), fogFactor );\n#endif", -envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\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 ), refraction_ratio );\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", -map_particle_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif", -lightmap_fragment:"#ifdef USE_LIGHTMAP\nlightmapColor = texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", +case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var f=document.createElement("canvas"),b,j=null,h=null,g=new THREE.Matrix4,m,w=new Float32Array(16),B=new Float32Array(16), +u=new Float32Array(16),q=new Float32Array(9),x=new Float32Array(16),E=new THREE.Matrix4,H=new THREE.Vector4,t=true,I=new THREE.Color(0),o=0;if(a){if(a.antialias!==undefined)t=a.antialias;a.clearColor!==undefined&&I.setHex(a.clearColor);if(a.clearAlpha!==undefined)o=a.clearAlpha}this.domElement=f;this.autoClear=true;(function(k,p,n){try{b=f.getContext("experimental-webgl",{antialias:k})}catch(l){}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,0,1);b.clearDepth(1); +b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(p.r,p.g,p.b,n)})(t,I,o);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(k,p){f.width=k;f.height=p;b.viewport(0,0,f.width,f.height)};this.setClearColor=function(k,p){var n=new THREE.Color(k);b.clearColor(n.r,n.g,n.b,p)}; +this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(k,p){var n,l,v,C=0,y=0,z=0,D,A,F,T=this.lights,N=T.directional.colors,X=T.directional.positions,W=T.point.colors,R=T.point.positions,Y=0,ea=0;n=0;for(l=p.length;n0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER, +G,n)}if(C&&aa>0){b.bindBuffer(b.ARRAY_BUFFER,k.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,L,n)}if(v){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ba,n);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,k.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ia,n)}};this.setLineBuffers=function(k,p,n,l){var v,C,y=k.vertices,z=y.length,D=k.__vertexArray,A=k.__lineArray;if(n)for(n=0;n0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+C.maxDirLights,"#define MAX_POINT_LIGHTS "+C.maxPointLights,C.map?"#define USE_MAP":"",C.env_map?"#define USE_ENVMAP":"",C.light_map?"#define USE_LIGHTMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n"); +b.attachShader(n,d("fragment",v+D));b.attachShader(n,d("vertex",C+p));b.linkProgram(n);b.getProgramParameter(n,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(n,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");n.uniforms={};n.attributes={};k.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(l in k.uniforms)n.push(l);l=k.program;D=0;for(p=n.length;D=0){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLNormalBuffer);b.vertexAttribPointer(y.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(y.normal)}if(y.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLTangentBuffer);b.vertexAttribPointer(y.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(y.tangent)}if(y.uv>=0)if(v.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLUVBuffer);b.vertexAttribPointer(y.uv,2,b.FLOAT,false,0,0); +b.enableVertexAttribArray(y.uv)}else b.disableVertexAttribArray(y.uv);if(y.uv2>=0)if(v.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,v.__webGLUV2Buffer);b.vertexAttribPointer(y.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(y.uv2)}else b.disableVertexAttribArray(y.uv2);if(l.wireframe||l instanceof THREE.LineBasicMaterial){y=l.wireframe_linewidth!==undefined?l.wireframe_linewidth:l.linewidth!==undefined?l.linewidth:1;l=l instanceof THREE.LineBasicMaterial&&C.type==THREE.LineStrip?b.LINE_STRIP: +b.LINES;b.lineWidth(y);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v.__webGLLineBuffer);b.drawElements(l,v.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(l instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v.__webGLParticleBuffer);b.drawElements(b.POINTS,v.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,v.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,v.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(k,p,n,l,v,C,y){var z,D,A,F,T;A=0; +for(F=l.materials.length;A=0;n--){l=k.__webGLObjects[n].object;p==l&&k.__webGLObjects.splice(n,1)}};this.setupMatrices= +function(k,p){g.multiply(p.matrix,k.matrix);B.set(g.flatten());m=THREE.Matrix4.makeInvert3x3(g).transpose();q.set(m.m);x.set(k.matrix.flatten())};this.loadMatrices=function(k){b.uniformMatrix4fv(k.uniforms.viewMatrix,false,w);b.uniformMatrix4fv(k.uniforms.modelViewMatrix,false,B);b.uniformMatrix4fv(k.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(k.uniforms.normalMatrix,false,q);b.uniformMatrix4fv(k.uniforms.objectMatrix,false,x)};this.loadCamera=function(k,p){b.uniform3f(k.uniforms.cameraPosition, +p.position.x,p.position.y,p.position.z)};this.setBlending=function(k){switch(k){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(k,p){if(k){!p||p=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW); +if(k=="back")b.cullFace(b.BACK);else k=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; +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 env_map;\nuniform int combine;\n#endif", +envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\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 ), refraction_ratio );\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",map_particle_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif", +lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\nlightmapColor = texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}", lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif"}; THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},light_map:{type:"t",value:2,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i", @@ -209,20 +209,20 @@ THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),verte THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragment_shader:["uniform vec3 color;\nuniform float opacity;",THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\nvec4 mColor = vec4( color, opacity );\nvec4 mapColor = vec4( 1.0 );",THREE.Snippets.map_particle_fragment,"gl_FragColor = mColor * mapColor;",THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:"uniform float size;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"}}; THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=false;this.uvs=[null,null,null]}; THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null}; -var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,g=d?c.geometry:c,b=a.vertices,l=g.vertices,j=a.faces,h=g.faces,o=a.uvs;g=g.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var v=0,z=l.length;v= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", @@ -231,46 +231,46 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying ve value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25)b=25;g=(b-1)*0.5;d=Array(b);for(c=e=0;c25)b=25;f=(b-1)*0.5;d=Array(b);for(c=e=0;c0||(v=this.vertices.push(new THREE.Vertex(new THREE.Vector3(z,j,u)))-1);o.push(v)}c.push(o)}var q,x,B;g=c.length;for(d=0;d0)for(e=0;e1){q=this.vertices[l].position.clone(); -x=this.vertices[h].position.clone();B=this.vertices[o].position.clone();q.normalize();x.normalize();B.normalize();this.faces.push(new THREE.Face3(l,h,o,[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([v,z,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; -var Torus=function(a,c,d,e){this.radius=a||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var g=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d= -1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;g=(this.segmentsT+1)*c+d-1;var b=(this.segmentsT+1)*(c-1)+d-1,l=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,g,b,l));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[b][0],a[b][1]),new THREE.UV(a[l][0],a[l][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -var Icosahedron=function(a){function c(z,u,q){var x=Math.sqrt(z*z+u*u+q*q);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(z/x,u/x,q/x)))-1}function d(z,u,q,x){x.faces.push(new THREE.Face3(z,u,q))}function e(z,u){var q=g.vertices[z].position,x=g.vertices[u].position;return c((q.x+x.x)/2,(q.y+x.y)/2,(q.z+x.z)/2)}var g=this,b=new THREE.Geometry,l;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);d(0,11,5,b);d(0,5,1,b);d(0,1,7,b);d(0,7,10,b);d(0,10,11,b);d(1,5,9,b);d(5,11,4,b);d(11,10,2,b);d(10,7,6,b);d(7,1,8,b);d(3,9,4,b);d(3,4,2,b);d(3,2,6,b);d(3,6,8,b);d(3,8,9,b);d(4,9,5,b);d(2,4,11,b);d(6,2,10,b);d(8,6,7,b);d(9,8,1,b);for(a=0;a0||(w=this.vertices.push(new THREE.Vertex(new THREE.Vector3(B,h,u)))-1);m.push(w)}c.push(m)}var q,x,E;f=c.length;for(d=0;d0)for(e=0;e1){q=this.vertices[j].position.clone(); +x=this.vertices[g].position.clone();E=this.vertices[m].position.clone();q.normalize();x.normalize();E.normalize();this.faces.push(new THREE.Face3(j,g,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(E.x,E.y,E.z)]));this.uvs.push([w,B,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Torus=function(a,c,d,e){this.radius=a||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d= +1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;f=(this.segmentsT+1)*c+d-1;var b=(this.segmentsT+1)*(c-1)+d-1,j=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,f,b,j));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[b][0],a[b][1]),new THREE.UV(a[j][0],a[j][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; +var Icosahedron=function(a){function c(B,u,q){var x=Math.sqrt(B*B+u*u+q*q);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(B/x,u/x,q/x)))-1}function d(B,u,q,x){x.faces.push(new THREE.Face3(B,u,q))}function e(B,u){var q=f.vertices[B].position,x=f.vertices[u].position;return c((q.x+x.x)/2,(q.y+x.y)/2,(q.z+x.z)/2)}var f=this,b=new THREE.Geometry,j;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0, +1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);d(0,11,5,b);d(0,5,1,b);d(0,1,7,b);d(0,7,10,b);d(0,10,11,b);d(1,5,9,b);d(5,11,4,b);d(11,10,2,b);d(10,7,6,b);d(7,1,8,b);d(3,9,4,b);d(3,4,2,b);d(3,2,6,b);d(3,6,8,b);d(3,8,9,b);d(4,9,5,b);d(2,4,11,b);d(6,2,10,b);d(8,6,7,b);d(9,8,1,b);for(a=0;a>7)-127;K=(da&127)<<16|P<<8|K;if(K==0&&fa==-127)return 0;return(1-2*(ia>>7))*(1+K*Math.pow(2,-23))*Math.pow(2,fa)}function j(D,H){var K=v(D,H),P=v(D,H+1),da=v(D,H+2);return(v(D,H+3)<<24)+(da<<16)+(P<<8)+K}function h(D,H){var K=v(D,H);return(v(D,H+1)<<8)+K}function o(D,H){var K=v(D,H);return K>127?K-256:K}function v(D,H){return D.charCodeAt(H)&255}function z(D){var H, -K,P;H=j(a,D);K=j(a,D+C);P=j(a,D+w);D=h(a,D+p);THREE.Loader.prototype.f3(t,H,K,P,D)}function u(D){var H,K,P,da,ia,fa;H=j(a,D);K=j(a,D+C);P=j(a,D+w);da=h(a,D+p);ia=j(a,D+F);fa=j(a,D+y);D=j(a,D+J);THREE.Loader.prototype.f3n(t,m,H,K,P,da,ia,fa,D)}function q(D){var H,K,P,da;H=j(a,D);K=j(a,D+E);P=j(a,D+A);da=j(a,D+M);D=h(a,D+aa);THREE.Loader.prototype.f4(t,H,K,P,da,D)}function x(D){var H,K,P,da,ia,fa,qa,sa;H=j(a,D);K=j(a,D+E);P=j(a,D+A);da=j(a,D+M);ia=h(a,D+aa);fa=j(a,D+N);qa=j(a,D+U);sa=j(a,D+T);D=j(a, -D+R);THREE.Loader.prototype.f4n(t,m,H,K,P,da,ia,fa,qa,sa,D)}function B(D){var H,K;H=j(a,D);K=j(a,D+Z);D=j(a,D+ca);THREE.Loader.prototype.uv3(t.uvs,n[H*2],n[H*2+1],n[K*2],n[K*2+1],n[D*2],n[D*2+1])}function G(D){var H,K,P;H=j(a,D);K=j(a,D+W);P=j(a,D+S);D=j(a,D+ba);THREE.Loader.prototype.uv4(t.uvs,n[H*2],n[H*2+1],n[K*2],n[K*2+1],n[P*2],n[P*2+1],n[D*2],n[D*2+1])}var t=this,k=0,f,m=[],n=[],C,w,p,F,y,J,E,A,M,aa,N,U,T,R,Z,ca,W,S,ba,X,I,Q,V,ha,ka;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t, -e,b);f={signature:a.substr(k,8),header_bytes:v(a,k+8),vertex_coordinate_bytes:v(a,k+9),normal_coordinate_bytes:v(a,k+10),uv_coordinate_bytes:v(a,k+11),vertex_index_bytes:v(a,k+12),normal_index_bytes:v(a,k+13),uv_index_bytes:v(a,k+14),material_index_bytes:v(a,k+15),nvertices:j(a,k+16),nnormals:j(a,k+16+4),nuvs:j(a,k+16+8),ntri_flat:j(a,k+16+12),ntri_smooth:j(a,k+16+16),ntri_flat_uv:j(a,k+16+20),ntri_smooth_uv:j(a,k+16+24),nquad_flat:j(a,k+16+28),nquad_smooth:j(a,k+16+32),nquad_flat_uv:j(a,k+16+36), -nquad_smooth_uv:j(a,k+16+40)};k+=f.header_bytes;C=f.vertex_index_bytes;w=f.vertex_index_bytes*2;p=f.vertex_index_bytes*3;F=f.vertex_index_bytes*3+f.material_index_bytes;y=f.vertex_index_bytes*3+f.material_index_bytes+f.normal_index_bytes;J=f.vertex_index_bytes*3+f.material_index_bytes+f.normal_index_bytes*2;E=f.vertex_index_bytes;A=f.vertex_index_bytes*2;M=f.vertex_index_bytes*3;aa=f.vertex_index_bytes*4;N=f.vertex_index_bytes*4+f.material_index_bytes;U=f.vertex_index_bytes*4+f.material_index_bytes+ -f.normal_index_bytes;T=f.vertex_index_bytes*4+f.material_index_bytes+f.normal_index_bytes*2;R=f.vertex_index_bytes*4+f.material_index_bytes+f.normal_index_bytes*3;Z=f.uv_index_bytes;ca=f.uv_index_bytes*2;W=f.uv_index_bytes;S=f.uv_index_bytes*2;ba=f.uv_index_bytes*3;b=f.vertex_index_bytes*3+f.material_index_bytes;ka=f.vertex_index_bytes*4+f.material_index_bytes;X=f.ntri_flat*b;I=f.ntri_smooth*(b+f.normal_index_bytes*3);Q=f.ntri_flat_uv*(b+f.uv_index_bytes*3);V=f.ntri_smooth_uv*(b+f.normal_index_bytes* -3+f.uv_index_bytes*3);ha=f.nquad_flat*ka;b=f.nquad_smooth*(ka+f.normal_index_bytes*4);ka=f.nquad_flat_uv*(ka+f.uv_index_bytes*4);k+=function(D){var H,K,P,da=f.vertex_coordinate_bytes*3,ia=D+f.nvertices*da;for(D=D;D>7)-127;J=(ba&127)<<16|O<<8|J;if(J==0&&ja==-127)return 0;return(1-2*(ia>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ja)}function h(G,L){var J=w(G,L),O=w(G,L+1),ba=w(G,L+2);return(w(G,L+3)<<24)+(ba<<16)+(O<<8)+J}function g(G,L){var J=w(G,L);return(w(G,L+1)<<8)+J}function m(G,L){var J=w(G,L);return J>127?J-256:J}function w(G,L){return G.charCodeAt(L)&255}function B(G){var L, +J,O;L=h(a,G);J=h(a,G+n);O=h(a,G+l);G=g(a,G+v);THREE.Loader.prototype.f3(t,L,J,O,G)}function u(G){var L,J,O,ba,ia,ja;L=h(a,G);J=h(a,G+n);O=h(a,G+l);ba=g(a,G+v);ia=h(a,G+C);ja=h(a,G+y);G=h(a,G+z);THREE.Loader.prototype.f3n(t,k,L,J,O,ba,ia,ja,G)}function q(G){var L,J,O,ba;L=h(a,G);J=h(a,G+D);O=h(a,G+A);ba=h(a,G+F);G=g(a,G+T);THREE.Loader.prototype.f4(t,L,J,O,ba,G)}function x(G){var L,J,O,ba,ia,ja,pa,la;L=h(a,G);J=h(a,G+D);O=h(a,G+A);ba=h(a,G+F);ia=g(a,G+T);ja=h(a,G+N);pa=h(a,G+X);la=h(a,G+W);G=h(a,G+ +R);THREE.Loader.prototype.f4n(t,k,L,J,O,ba,ia,ja,pa,la,G)}function E(G){var L,J;L=h(a,G);J=h(a,G+Y);G=h(a,G+ea);THREE.Loader.prototype.uv3(t.uvs,p[L*2],p[L*2+1],p[J*2],p[J*2+1],p[G*2],p[G*2+1])}function H(G){var L,J,O;L=h(a,G);J=h(a,G+Q);O=h(a,G+P);G=h(a,G+ca);THREE.Loader.prototype.uv4(t.uvs,p[L*2],p[L*2+1],p[J*2],p[J*2+1],p[O*2],p[O*2+1],p[G*2],p[G*2+1])}var t=this,I=0,o,k=[],p=[],n,l,v,C,y,z,D,A,F,T,N,X,W,R,Y,ea,Q,P,ca,aa,K,U,V,ga,fa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(t, +e,b);o={signature:a.substr(I,8),header_bytes:w(a,I+8),vertex_coordinate_bytes:w(a,I+9),normal_coordinate_bytes:w(a,I+10),uv_coordinate_bytes:w(a,I+11),vertex_index_bytes:w(a,I+12),normal_index_bytes:w(a,I+13),uv_index_bytes:w(a,I+14),material_index_bytes:w(a,I+15),nvertices:h(a,I+16),nnormals:h(a,I+16+4),nuvs:h(a,I+16+8),ntri_flat:h(a,I+16+12),ntri_smooth:h(a,I+16+16),ntri_flat_uv:h(a,I+16+20),ntri_smooth_uv:h(a,I+16+24),nquad_flat:h(a,I+16+28),nquad_smooth:h(a,I+16+32),nquad_flat_uv:h(a,I+16+36), +nquad_smooth_uv:h(a,I+16+40)};I+=o.header_bytes;n=o.vertex_index_bytes;l=o.vertex_index_bytes*2;v=o.vertex_index_bytes*3;C=o.vertex_index_bytes*3+o.material_index_bytes;y=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;z=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;D=o.vertex_index_bytes;A=o.vertex_index_bytes*2;F=o.vertex_index_bytes*3;T=o.vertex_index_bytes*4;N=o.vertex_index_bytes*4+o.material_index_bytes;X=o.vertex_index_bytes*4+o.material_index_bytes+ +o.normal_index_bytes;W=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;R=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;Y=o.uv_index_bytes;ea=o.uv_index_bytes*2;Q=o.uv_index_bytes;P=o.uv_index_bytes*2;ca=o.uv_index_bytes*3;b=o.vertex_index_bytes*3+o.material_index_bytes;fa=o.vertex_index_bytes*4+o.material_index_bytes;aa=o.ntri_flat*b;K=o.ntri_smooth*(b+o.normal_index_bytes*3);U=o.ntri_flat_uv*(b+o.uv_index_bytes*3);V=o.ntri_smooth_uv*(b+o.normal_index_bytes* +3+o.uv_index_bytes*3);ga=o.nquad_flat*fa;b=o.nquad_smooth*(fa+o.normal_index_bytes*4);fa=o.nquad_flat_uv*(fa+o.uv_index_bytes*4);I+=function(G){var L,J,O,ba=o.vertex_coordinate_bytes*3,ia=G+o.nvertices*ba;for(G=G;G + + + three.js - particles - billboards - webgl + + + + + +
+ three.js - webgl particle billboards example +
+ +
+
+ Sorry, your browser doesn't support WebGL + and Web Workers.
+
+ Please try in + Chrome 9+ / + Firefox 4+ / + Safari OSX 10.6+ +
+
+ + + + + + + diff --git a/examples/particles_random_gl.html b/examples/particles_random_gl.html index 9b0bb1db..b0a6a4f5 100644 --- a/examples/particles_random_gl.html +++ b/examples/particles_random_gl.html @@ -126,8 +126,6 @@ } - scene.addObject( particles ); - renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); container.appendChild( renderer.domElement ); diff --git a/examples/particles_sprites_gl.html b/examples/particles_sprites_gl.html index 995f255f..469484e8 100644 --- a/examples/particles_sprites_gl.html +++ b/examples/particles_sprites_gl.html @@ -131,8 +131,6 @@ } - scene.addObject( particles ); - renderer = new THREE.WebGLRenderer( { clearAlpha: 1 }); renderer.setSize( window.innerWidth, window.innerHeight ); container.appendChild( renderer.domElement ); diff --git a/examples/textures/sprites/circle.png b/examples/textures/sprites/circle.png new file mode 100644 index 0000000000000000000000000000000000000000..5392bed3b6473fc63795db8c533f895d248081a4 GIT binary patch literal 5527 zcmV;I6=>>-P)Px#24YJ`L;wH)0002_L%V+f000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipPz z0TCiwBeDSi000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}000#7Nkl!;q~G7j;naQ~}}J zz3_$i&#mpNHt(NX+n@cWoBmdUuZ#XT;wRVbdHWqy{k&pg+; z7OX-B0Qly8`+5C-eoKwOZ*bzY5llC$oh>Cq1tcayh5`fxD5!#htSX<&0KfpCZ{F9> zTTtQ?Ch{NEfK~XdI?EJznQI3CI|SGh^NyHzgtQ~Vg^(H&3Lppq9!;R2q7u9+duH~^ zJVfSmL_SyL697EVb(m`fDK^>z|BgoBSN<$+R9!YFy`Srnh%Q<9N?0z5`I3n)h-lA5 zJ0NO^*a(3UkmgRas-mi_sw^{~$BL)Sdx!zW{(MCcY7s8)3O&;TvJOX67qmx+JDO5$_0bAv|e7jlY=%6_DUr*)!`fgpbFF zd7wh`bW! zYht-#rVA$8Bhx}iiim=UjDT1O0992536P#ymYIFk0FQhK_xp&rb@y8re=lzD%>2E( zzn^=#pL^?bzwtHZAYUjvZ-n0iz$E~@5|KBm?X9YQrz+oz$XgM4Eh?{s<%*dviD<{n z3lk|43L-Hg5&{z7kRPD33L+~#BRw;FL_A02Q-t5U`<=Vry8Amfz9F_NHs1GcOI7OJ z-{ait>MXwq1o;Z#mnr-;0=(ANzH3c?P;Eb`>JKXVov6H3(N`>TEy5QfvLmL(#7fLU zh>VCth|>oajxYdKRasdX8IhS55f&Z?&v<_|-h|@y z^+h1aSE&6S0B(@zZBzZewf0kM?I&&eql*5Zt-aM@23MkTAtE~#Rv}ShVkROaA|gTr zI0k_laiFrYDl0QHGa@6y-NPdM(uFVG{K}lJi20J4E{SN5L<Fd5RpYhR79AWnV5-({D?$AFdzUx zD9D0g1dvsg=@prk5$PV`?&fAYD0|U2E;Ns$Qw;UR9flDhsoU5V4>zBQe2Lf_eA| z2nYp*1pt)^nF$$Lkx}76F3#@GE~0Fv#-zm5khu|&5~2X%_T+PduuY-;bCKaw8nD{^ zZgqIA>Gw-(KQB%H+FJXc)|Q`_rG4L8d)>5Mx7K#5+Ei6kghd2d1%(BL1&|4b79b!J zAR>&T2dFBjD#%QT49Ey{4{-N#cQQBLyo3mO`V$_;Q~&^pBcF(f@E6kN7jp#pOsqfJ zebe?y zAtIqN&?6zj!QH{#P)xA1;p#?kAV|2{_Wbp#^2oBxXRE671gXA61I|_dikV+))9+hb zerm1#ye#dfr7hpL*4`}3a=kR&x3;v_8n@P1RZ&%8fFPhEz$`#Qz{EgAKsd1;wE$GE z8W0eX5FX$I05oGDHkj`77(>?W)<`5Wt9;}T)vNMwI2`&}rubq3C7(I{3qZJ0)winp zLlgZ`RexwrziX|%ZmnH49l|e5lhzh$t)aGtO%+rWLf@VIcxl9glNKsHm){%$||Y5%DOR4;pbF5sy{%ywQX_*8=%Op1((=D-nII zD&MKdcdf}=QGKPVSK4&nRNK-TFKwY^2#!lzpe+-CVFsY8AS@svz(RmDe8CCxjRTBT z^#ei-j0xC>)({XN0#-pm0Ra?LW@Y9sGea|8MdTqu9y8=FMD9f7-pn3m@${k=oSVQg z?yJhRD!&rZH>&zZL|>`M40WwFZLBJ!+EAATm)2le8nk5r)dp=*XxgSJD2PlAU;@G+ z6s&1r7DNT4=W6@lE- z!z`zHf^aOw<%Q6<0OAER--zgI5qT{luSDcpL@rdMiKvJQt1hHXVbKPABSaJhT5D6JPKsXGdu(d@UjuqOypJ>I`+N0!Ccr z=0V3dzm@h`rAy+JNDIz;&ZY(Uq zLLwu(6B(*K!kvJwK&)CYBSLEnXcJIr(-+W8hVXc*F)}}}&OpQ?O5hZ{60!m!6C?uE z1405^9n}?_oo3mg#JrHmo|!KP8N-)M{1O20A^^m=Fw%aQ0q&V;M??!Vs}K`2BQxU> z1QrlhP&on7njQsTR&AJ(K~zDA0D0~s3nJ&~yN{5^cr=fp?juVK2?!Ag6<}u&n;IpI z#7r|)R$C-O<~mrkr5G)c<^D6kn{Ar+eas#m5>>bIiiB7fVi9zs}Wg{Ns5VxiI|Cnkd=vd z%(P>oJrOO_2gruZjjaz@H9$s*$&Hv6WLk)5kQp>eS|%RZ7!fehX*26*Ihn@r{<`r8 z3$!+U0Syya)!)njJ582!IJ(FHaRuQ35eK%7@H|XqydyF*(%732lM+#*!51uuxDb(M z=D+kM&ZB@3p&;R8Z&46Y7?F{X5DAfS2tU(Wn)$tKPeq1lu*fMPTJwaqOozxr*i5jg z`T%$mJ_5wozq18;f=xUND;!Q036P19k>NhQTI|=dGHEgfR9t zc7=$9gp7!SaFm5N>VHiC|FsyxBM`^36988ZbC6l%H9|D5U?2dF*u6CoI-1DnXfdCd5pHj=zHAd81u; zs`vrNI^RJRjPDJ8dGqhJ{fGI;`cqDD$~tncg39?@tNincb(FK_!;WkF^)Za)>3vOh z%%tQ01*jhb|gSN0>XX7|5&rY z^*I4m6QHW&=YoVvfT|(yJiGv?fP%R)UmCWMGtw~TQ@o(OYLE?CIT-7#%G{jJsW5@4 zgp7j7gp4@V_U7R1U~H2I7?~e40|E}P%%NL{-VNLg%tv7q;Sh29d*j*Tc?0bA>w+Ae zg=2%Is=Tr+A+0K{>P2b{_;+ovUo^mS4ku*f zQw)ynkP#LU5gD186_FL;5GlCY_oT3ajlqeb&w^((fJaH2nczN%5u^#qWP{xY2e^V@ zhoJ>F&0<{xkf~u2ki$$W!fR|XJR*h+8BZDUl$p<)7J8g(Ky5T&0uYbu%E+h4Jc8g6 z9PZ?kxfPjqF5|Sw42TKPW&>oM0m*;}9jP+O$QcTuVA!x9waCDFhl6$K{V+h7z}VEX zm}YS_kMxSjxxMTe@f;D4nK@)Q0r2M<007S!`IHe4>3JU!58?6T5#2pJ+{MMq&Cz9^ z+Dc*^Gq^Qv!QsVc$;%NSyw(qR_Wc~HZUHtOV(%UL;V?d%flvR?SB-EhH!Cww503~p z&v}sA!j&gleEJicr`~O9!C?T=r#ZMAShqCuG&6Vi?(R?ScJCgy z5q=x)x9)L2Y4QF!TD&%$)D8fT?tW(;?^(DIJMndAx+J4L5ii6fbKCZX#FfZ6HaCxqZ*0sU+@a5?uxdf?R)^jP0R0fXck8`Bo7sbVzcsf% z-0U|q`_0_nx%-DrKfwR2H~5hw1b_#3zwKrh%zVk6E;`bFP)#U!>Tr(wqkyW4hCK(S z3-Y9j)(`nv?_lcOJAAJ3@3w&GUL9o z0*wI)KpuTQptaEl$KK$&)`G}SrceU_%Wgdmz4w0T&%O8i-Vg74x8Hm3zxHmwnAxw^ z?e~mW)qkBV%`ce`*gC@l06b)-TDL|-3n8{aF98ou2-fnrDs#z9i71K)3RPeaP!V+T zBaev4lk8Y`v-SrQVs?mUx?64r;a=Unyjz;}=w`k5{@f4!;b8rJ@BO#l5C1gl|LEO* z>AnAIX72#t?h{SX&zb;iLSmox!|twhKt-5iDaR47<8VS`W=3Vp2#r(@4`O9>ADJJ^ zIv>PvqSNM_=xlq%(140e2=|KcGV?OCF!wOC?q<)u_lHC8@2&UWdq4crd;i-N;m9?bgfRQrGS-v8bYhrjjS|8Y1Reygl^)Apaw zZ2zm~1h*04I3(SB$4z4~s%n#%{NvF3KQr@p0N8r|_}uA#3V`ho zz63(m7)kNWw5&R0=5wSzhQw1O2mDr z+)KzSVZUaPOJUwK^D^6QLPSi*IbqzAo70t4WMo8zMMMuDRh@g>hx-S!{?5aH?*o8e z&HUHi`yW-cI=#m~^ZH*iEBq1&$00;__sl$~=2K=oXvAH(+{$rUT&{g|X!lIC5cB9X z%^U)O@I(TQ2mWkY z{2YWWf9RRn4~N4cG9EnQPDS1e%R5$i#mqOte8of;#Jne@g&5oD)X;2H;JhyZv0j(S zb=Ya#8Mt?kQQWxSdiZ;Dd+*)eXVr%(_`})diLbgi@ufFL@Dro+%V~TbuT|w*Sgu+4 zhMBLJ`HG3>g$W$p%gDPa_~Ygp&G|i| zFTODGwO3}g_l35Xq;_*%0Kf$cUkb|wF<%nlo{9HJv?HWO1d51KW5N{?YhIaI?+n$X zv+^l@uu|^vP?e9H>oU(9TlceR(672O^R>6e&acXy1JSk@rvPEcW4>Ua(Wch9jv6qU z3^43J!78(7@w8~$o49oj2VQ{c%AL4 zd1a%m_|z3zeBo-# zISBQME3^NRJH+1tfS3Lj{s}Oj3b~)UL=Es?e0loM{w99q^XhXQ`2X}~|C^ps{|9@6 Z{{?8~&-hws#=Zam002ovPDHLkV1mwoX@dX& literal 0 HcmV?d00001 diff --git a/src/materials/Material.js b/src/materials/Material.js index 7a218642..73231518 100644 --- a/src/materials/Material.js +++ b/src/materials/Material.js @@ -8,3 +8,4 @@ THREE.SmoothShading = 1; THREE.NormalBlending = 0; THREE.AdditiveBlending = 1; THREE.SubtractiveBlending = 2; +THREE.BillboardBlending = 3; diff --git a/src/objects/ParticleSystem.js b/src/objects/ParticleSystem.js index dca35c9d..e1f9e557 100644 --- a/src/objects/ParticleSystem.js +++ b/src/objects/ParticleSystem.js @@ -8,6 +8,8 @@ THREE.ParticleSystem = function ( geometry, materials ) { this.geometry = geometry; this.materials = materials instanceof Array ? materials : [ materials ]; + + this.sortParticles = false; }; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 03b75ccf..f7d0a3d6 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -31,6 +31,9 @@ THREE.WebGLRenderer = function ( parameters ) { _normalMatrixArray = new Float32Array(9), _objectMatrixArray = new Float32Array(16), + _projScreenMatrix = new THREE.Matrix4(), + _vector3 = new THREE.Vector4(), + // parameters defaults antialias = true, @@ -194,6 +197,8 @@ THREE.WebGLRenderer = function ( parameters ) { geometry.__vertexArray = new Float32Array( nvertices * 3 ); geometry.__particleArray = new Uint16Array( nvertices ); + + geometry.__sortArray = []; geometry.__webGLParticleCount = nvertices; @@ -672,35 +677,71 @@ THREE.WebGLRenderer = function ( parameters ) { }; - this.setParticleBuffers = function( geometry, hint, dirtyVertices, dirtyElements ) { + this.setParticleBuffers = function( geometry, hint, dirtyVertices, dirtyElements, object, camera ) { var v, vertex, offset, vertices = geometry.vertices, vl = vertices.length, vertexArray = geometry.__vertexArray, - particleArray = geometry.__particleArray; - - if ( dirtyVertices ) { + particleArray = geometry.__particleArray, + + sortArray = geometry.__sortArray; + if ( object.sortParticles ) { + + _projScreenMatrix.multiply( camera.projectionMatrix, camera.matrix ); + _projScreenMatrix.multiplySelf( object.matrix ); + for ( v = 0; v < vl; v++ ) { vertex = vertices[ v ].position; - + + _vector3.copy( vertex ); + _projScreenMatrix.multiplyVector3( _vector3 ); + + sortArray[ v ] = [ _vector3.z, v ]; + + } + + sortArray.sort( function(a,b) { return b[0] - a[0]; } ); + + for ( v = 0; v < vl; v++ ) { + + vertex = vertices[ sortArray[v][1] ].position; + offset = v * 3; - + vertexArray[ offset ] = vertex.x; vertexArray[ offset + 1 ] = vertex.y; vertexArray[ offset + 2 ] = vertex.z; + + } + + } else { + + if ( dirtyVertices ) { + + for ( v = 0; v < vl; v++ ) { + + vertex = vertices[ v ].position; + + offset = v * 3; + + vertexArray[ offset ] = vertex.x; + vertexArray[ offset + 1 ] = vertex.y; + vertexArray[ offset + 2 ] = vertex.z; + + } } } - + // yeah, this is silly as order of element indices is currently fixed // though this could change if some use case arises // (like depth-sorting of semi-opaque particles) - + if ( dirtyElements ) { for ( v = 0; v < vl; v++ ) { @@ -710,6 +751,7 @@ THREE.WebGLRenderer = function ( parameters ) { } } + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webGLVertexBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, vertexArray, hint ); @@ -1094,9 +1136,15 @@ THREE.WebGLRenderer = function ( parameters ) { var o, ol, webGLObject, object, buffer, lights = scene.lights, - fog = scene.fog; + fog = scene.fog, + ol; - this.initWebGLObjects( scene ); + camera.autoUpdateMatrix && camera.updateMatrix(); + + _viewMatrixArray.set( camera.matrix.flatten() ); + _projectionMatrixArray.set( camera.projectionMatrix.flatten() ); + + this.initWebGLObjects( scene, camera ); setRenderTarget( renderTarget, clear !== undefined ? clear : true ); @@ -1106,14 +1154,11 @@ THREE.WebGLRenderer = function ( parameters ) { } - camera.autoUpdateMatrix && camera.updateMatrix(); - - _viewMatrixArray.set( camera.matrix.flatten() ); - _projectionMatrixArray.set( camera.projectionMatrix.flatten() ); - - // opaque pass - - for ( o = 0, ol = scene.__webGLObjects.length; o < ol; o++ ) { + // set matrices and faces + + ol = scene.__webGLObjects.length; + + for ( o = 0; o < ol; o++ ) { webGLObject = scene.__webGLObjects[ o ]; @@ -1122,6 +1167,8 @@ THREE.WebGLRenderer = function ( parameters ) { if ( object.visible ) { + object.autoUpdateMatrix && object.updateMatrix(); + if( object.doubleSided ) { _gl.disable( _gl.CULL_FACE ); @@ -1142,7 +1189,22 @@ THREE.WebGLRenderer = function ( parameters ) { } } + + } + + } + // opaque pass + + for ( o = 0; o < ol; o++ ) { + + webGLObject = scene.__webGLObjects[ o ]; + + object = webGLObject.object; + buffer = webGLObject.buffer; + + if ( object.visible ) { + this.setupMatrices( object, camera ); this.renderPass( camera, lights, fog, object, buffer, THREE.NormalBlending, false ); @@ -1152,7 +1214,7 @@ THREE.WebGLRenderer = function ( parameters ) { // transparent pass - for ( o = 0, ol = scene.__webGLObjects.length; o < ol; o++ ) { + for ( o = 0; o < ol; o++ ) { webGLObject = scene.__webGLObjects[ o ]; @@ -1162,7 +1224,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( object.visible ) { this.setupMatrices( object, camera ); - + // opaque blended materials this.renderPass( camera, lights, fog, object, buffer, THREE.AdditiveBlending, false ); @@ -1177,6 +1239,10 @@ THREE.WebGLRenderer = function ( parameters ) { this.renderPass( camera, lights, fog, object, buffer, THREE.NormalBlending, true ); + // billboard materials + + this.renderPass( camera, lights, fog, object, buffer, THREE.BillboardBlending, false ); + } } @@ -1191,7 +1257,7 @@ THREE.WebGLRenderer = function ( parameters ) { }; - this.initWebGLObjects = function( scene ) { + this.initWebGLObjects = function( scene, camera ) { function add_buffer( objmap, id, buffer, object ) { @@ -1306,9 +1372,9 @@ THREE.WebGLRenderer = function ( parameters ) { } - if( geometry.__dirtyVertices ) { + if( geometry.__dirtyVertices || object.sortParticles ) { - this.setParticleBuffers( geometry, _gl.DYNAMIC_DRAW, geometry.__dirtyVertices, geometry.__dirtyElements ); + this.setParticleBuffers( geometry, _gl.DYNAMIC_DRAW, geometry.__dirtyVertices, geometry.__dirtyElements, object, camera ); } @@ -1346,8 +1412,6 @@ THREE.WebGLRenderer = function ( parameters ) { this.setupMatrices = function ( object, camera ) { - object.autoUpdateMatrix && object.updateMatrix(); - _modelViewMatrix.multiply( camera.matrix, object.matrix ); _modelViewMatrixArray.set( _modelViewMatrix.flatten() ); @@ -1392,12 +1456,20 @@ THREE.WebGLRenderer = function ( parameters ) { break; + case THREE.BillboardBlending: + + _gl.blendEquation( _gl.FUNC_ADD ); + _gl.blendFunc( _gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA); + + break; + default: _gl.blendEquation( _gl.FUNC_ADD ); _gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA ); break; + } }; @@ -1994,7 +2066,7 @@ THREE.Snippets = { "float fogFactor = smoothstep( fogNear, fogFar, depth );", "#endif", - "gl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );", + "gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );", "#endif"